eliminate assumptions of module presence in unwinding codepaths, & callstack UI; fixes callstacks for JIT'd code

This commit is contained in:
Ryan Fleury
2024-01-23 14:26:43 -08:00
parent 8bf8112edd
commit 804a8406b9
4 changed files with 84 additions and 98 deletions
+11 -42
View File
@@ -1,49 +1,18 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
// build with:
// cl /Zi /nologo look_at_raddbg.c
#include <windows.h>
#include <stdio.h>
#include <stdint.h>
#include "raddbg_format/raddbg_format.h"
#include "raddbg_format/raddbg_format_parse.h"
#include "raddbg_format/raddbg_format.c"
#include "raddbg_format/raddbg_format_parse.c"
#include <windows.h>
typedef struct Foo Foo;
struct Foo
{
int x;
int y;
int z;
};
int main(int argument_count, char **arguments)
{
Foo foo = {123, 456, 789};
HANDLE file = CreateFileA(arguments[1], GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
DWORD size_hi32 = 0;
DWORD size_lo32 = GetFileSize(file, &size_hi32);
HANDLE map = CreateFileMappingA(file, 0, PAGE_READONLY, 0, 0, 0);
uint64_t data_size = (size_lo32 | ((uint64_t)size_hi32 << 32));
uint8_t *data = (uint8_t *)MapViewOfFile(map, FILE_MAP_READ, 0, 0, data_size);
RADDBG_Parsed rdbg = {0};
RADDBG_ParseStatus parse_status = raddbg_parse(data, data_size, &rdbg);
uint64_t foo_count = 0;
for(uint64_t idx = 0; idx < rdbg.type_node_count; idx += 1)
{
RADDBG_TypeNode *type_node = &rdbg.type_nodes[idx];
if(RADDBG_TypeKind_FirstUserDefined <= type_node->kind && type_node->kind <= RADDBG_TypeKind_LastUserDefined)
{
uint64_t name_size = 0;
uint8_t *name = raddbg_string_from_idx(&rdbg, type_node->user_defined.name_string_idx, &name_size);
if(name_size == 3 && name[0] == 'f' && name[1] == 'o' && name[2] == 'o')
{
foo_count += 1;
}
}
}
printf("%s -> %I64u foos\n", arguments[1], foo_count);
int main(void) {
printf("1\n");
VOID *code = VirtualAlloc(0, 0x1000, MEM_COMMIT|MEM_RESERVE, PAGE_EXECUTE_READWRITE);
*((uint32_t*)code) = 0xCCCCCCCC;
((void (__fastcall *)()) code)();
printf("2\n");
return 0;
}