Merge tag 'v0.9.20-alpha'

This commit is contained in:
ed
2025-06-13 23:07:02 -04:00
306 changed files with 15074 additions and 13393 deletions
+1 -3
View File
@@ -17,9 +17,7 @@ jobs:
target: target:
- raddbg - raddbg
- radlink - radlink
- rdi_from_pdb - radbin
- raddump
- rdi_breakpad_from_pdb
compiler: compiler:
- msvc - msvc
- clang - clang
+7 -8
View File
@@ -24,6 +24,7 @@ cd /D "%~dp0"
:: ::
:: - `asan`: enable address sanitizer :: - `asan`: enable address sanitizer
:: - `telemetry`: enable RAD telemetry profiling support :: - `telemetry`: enable RAD telemetry profiling support
:: - `spall`: enable spall profiling support
:: --- Unpack Arguments ------------------------------------------------------- :: --- Unpack Arguments -------------------------------------------------------
for %%a in (%*) do set "%%a=1" for %%a in (%*) do set "%%a=1"
@@ -39,21 +40,22 @@ if "%~1"=="release" if "%~2"=="" echo [default mode, assuming `raddbg` build] &&
:: --- Unpack Command Line Build Arguments ------------------------------------ :: --- Unpack Command Line Build Arguments ------------------------------------
set auto_compile_flags= set auto_compile_flags=
if "%telemetry%"=="1" set auto_compile_flags=%auto_compile_flags% -DPROFILE_TELEMETRY=1 && echo [telemetry profiling enabled] if "%telemetry%"=="1" set auto_compile_flags=%auto_compile_flags% -DPROFILE_TELEMETRY=1 && echo [telemetry profiling enabled]
if "%spall%"=="1" set auto_compile_flags=%auto_compile_flags% -DPROFILE_SPALL=1 && echo [spall profiling enabled]
if "%asan%"=="1" set auto_compile_flags=%auto_compile_flags% -fsanitize=address && echo [asan enabled] if "%asan%"=="1" set auto_compile_flags=%auto_compile_flags% -fsanitize=address && echo [asan enabled]
if "%opengl%"=="1" set auto_compile_flags=%auto_compile_flags% -DR_BACKEND=R_BACKEND_OPENGL && echo [opengl render backend] if "%opengl%"=="1" set auto_compile_flags=%auto_compile_flags% -DR_BACKEND=R_BACKEND_OPENGL && echo [opengl render backend]
:: --- Compile/Link Line Definitions ------------------------------------------ :: --- Compile/Link Line Definitions ------------------------------------------
set cl_common= /I..\src\ /I..\local\ /nologo /FC /Z7 set cl_common= /I..\src\ /I..\local\ /nologo /FC /Z7
set clang_common= -I..\src\ -I..\local\ -gcodeview -fdiagnostics-absolute-paths -Wall -Wno-unknown-warning-option -Wno-missing-braces -Wno-unused-function -Wno-writable-strings -Wno-unused-value -Wno-unused-variable -Wno-unused-local-typedef -Wno-deprecated-register -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-single-bit-bitfield-constant-conversion -Wno-compare-distinct-pointer-types -Wno-initializer-overrides -Wno-incompatible-pointer-types-discards-qualifiers -Xclang -flto-visibility-public-std -D_USE_MATH_DEFINES -Dstrdup=_strdup -Dgnu_printf=printf -ferror-limit=10000
set cl_debug= call cl /Od /Ob1 /DBUILD_DEBUG=1 %cl_common% %auto_compile_flags% set cl_debug= call cl /Od /Ob1 /DBUILD_DEBUG=1 %cl_common% %auto_compile_flags%
set cl_release= call cl /O2 /DBUILD_DEBUG=0 %cl_common% %auto_compile_flags% set cl_release= call cl /O2 /DBUILD_DEBUG=0 %cl_common% %auto_compile_flags%
set cl_link= /link /MANIFEST:EMBED /INCREMENTAL:NO /pdbaltpath:%%%%_PDB%%%% /NATVIS:"%~dp0\src\natvis\base.natvis" /noexp
set cl_out= /out:
set cl_linker=
set clang_common= -I..\src\ -I..\local\ -gcodeview -fdiagnostics-absolute-paths -Wall -Wno-unknown-warning-option -Wno-missing-braces -Wno-unused-function -Wno-unused-parameter -Wno-writable-strings -Wno-missing-field-initializers -Wno-unused-value -Wno-unused-variable -Wno-unused-local-typedef -Wno-deprecated-register -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-single-bit-bitfield-constant-conversion -Wno-compare-distinct-pointer-types -Wno-initializer-overrides -Wno-incompatible-pointer-types-discards-qualifiers -Xclang -flto-visibility-public-std -D_USE_MATH_DEFINES -Dstrdup=_strdup -Dgnu_printf=printf -ferror-limit=10000
set clang_debug= call clang -g -O0 -DBUILD_DEBUG=1 %clang_common% %auto_compile_flags% set clang_debug= call clang -g -O0 -DBUILD_DEBUG=1 %clang_common% %auto_compile_flags%
set clang_release= call clang -g -O2 -DBUILD_DEBUG=0 %clang_common% %auto_compile_flags% set clang_release= call clang -g -O2 -DBUILD_DEBUG=0 %clang_common% %auto_compile_flags%
set cl_link= /link /MANIFEST:EMBED /INCREMENTAL:NO /pdbaltpath:%%%%_PDB%%%% /NATVIS:"%~dp0\src\natvis\base.natvis" /noexp
set clang_link= -fuse-ld=lld -Xlinker /MANIFEST:EMBED -Xlinker /pdbaltpath:%%%%_PDB%%%% -Xlinker /NATVIS:"%~dp0\src\natvis\base.natvis" set clang_link= -fuse-ld=lld -Xlinker /MANIFEST:EMBED -Xlinker /pdbaltpath:%%%%_PDB%%%% -Xlinker /NATVIS:"%~dp0\src\natvis\base.natvis"
set cl_out= /out:
set clang_out= -o set clang_out= -o
set cl_linker=
set clang_linker= -Xlinker set clang_linker= -Xlinker
:: --- Per-Build Settings ----------------------------------------------------- :: --- Per-Build Settings -----------------------------------------------------
@@ -108,11 +110,8 @@ if not "%no_meta%"=="1" (
pushd build pushd build
if "%raddbg%"=="1" set didbuild=1 && %compile% ..\src\raddbg\raddbg_main.c %compile_link% %link_icon% %out%raddbg.exe || exit /b 1 if "%raddbg%"=="1" set didbuild=1 && %compile% ..\src\raddbg\raddbg_main.c %compile_link% %link_icon% %out%raddbg.exe || exit /b 1
if "%radlink%"=="1" set didbuild=1 && %compile% ..\src\linker\lnk.c %compile_link% %linker% /NOIMPLIB %linker% /NATVIS:"%~dp0\src\linker\linker.natvis" %out%radlink.exe || exit /b 1 if "%radlink%"=="1" set didbuild=1 && %compile% ..\src\linker\lnk.c %compile_link% %linker% /NOIMPLIB %linker% /NATVIS:"%~dp0\src\linker\linker.natvis" %out%radlink.exe || exit /b 1
if "%radcon%"=="1" set didbuild=1 && %compile% ..\src\radcon\radcon_main.c %compile_link% %out%radcon.exe || exit /b 1 if "%radbin%"=="1" set didbuild=1 && %compile% ..\src\radbin\radbin_main.c %compile_link% %out%radbin.exe || exit /b 1
if "%raddump%"=="1" set didbuild=1 && %compile% ..\src\raddump\raddump_main.c %compile_link% %out%raddump.exe || exit /b 1 if "%raddump%"=="1" set didbuild=1 && %compile% ..\src\raddump\raddump_main.c %compile_link% %out%raddump.exe || exit /b 1
if "%rdi_from_pdb%"=="1" set didbuild=1 && %compile% ..\src\rdi_from_pdb\rdi_from_pdb_main.c %compile_link% %out%rdi_from_pdb.exe || exit /b 1
if "%rdi_from_dwarf%"=="1" set didbuild=1 && %compile% ..\src\rdi_from_dwarf\rdi_from_dwarf_main.c %compile_link% %out%rdi_from_dwarf.exe || exit /b 1
if "%rdi_breakpad_from_pdb%"=="1" set didbuild=1 && %compile% ..\src\rdi_breakpad_from_pdb\rdi_breakpad_from_pdb_main.c %compile_link% %out%rdi_breakpad_from_pdb.exe || exit /b 1
if "%tester%"=="1" set didbuild=1 && %compile% ..\src\tester\tester_main.c %compile_link% %out%tester.exe || exit /b 1 if "%tester%"=="1" set didbuild=1 && %compile% ..\src\tester\tester_main.c %compile_link% %out%tester.exe || exit /b 1
if "%ryan_scratch%"=="1" set didbuild=1 && %compile% ..\src\scratch\ryan_scratch.c %compile_link% %out%ryan_scratch.exe || exit /b 1 if "%ryan_scratch%"=="1" set didbuild=1 && %compile% ..\src\scratch\ryan_scratch.c %compile_link% %out%ryan_scratch.exe || exit /b 1
if "%eval_scratch%"=="1" set didbuild=1 && %compile% ..\src\scratch\eval_scratch.c %compile_link% %out%eval_scratch.exe || exit /b 1 if "%eval_scratch%"=="1" set didbuild=1 && %compile% ..\src\scratch\eval_scratch.c %compile_link% %out%eval_scratch.exe || exit /b 1
+4 -1
View File
@@ -46,7 +46,7 @@ load_paths =
commands = commands =
{ {
//- rjf: [raddbg] //- rjf: [raddbg]
.f1 = { .win = "raddbg_stable --ipc kill_all && build raddbg telemetry", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, }, // .f1 = { .win = "raddbg_stable --ipc kill_all && build raddbg telemetry", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
//- rjf: [textperf] //- rjf: [textperf]
// .f1 = { .win = "raddbg_stable --ipc kill_all && build no_meta telemetry textperf && raddbg_stable --ipc bring_to_front && raddbg_stable --ipc run", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, }, // .f1 = { .win = "raddbg_stable --ipc kill_all && build no_meta telemetry textperf && raddbg_stable --ipc bring_to_front && raddbg_stable --ipc run", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
@@ -54,6 +54,9 @@ commands =
//- rjf: [tester] //- rjf: [tester]
// .f1 = { .win = "raddbg_stable --ipc kill_all && build no_meta tester", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, }, // .f1 = { .win = "raddbg_stable --ipc kill_all && build no_meta tester", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
//- rjf: [radbin]
.f1 = { .win = "raddbg_stable --ipc kill_all && build radbin", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
//- rjf: running target //- rjf: running target
.f3 = { .win = "raddbg_stable --ipc run", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, }, .f3 = { .win = "raddbg_stable --ipc run", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
// .f3 = { .win = "pushd build && raddbg --user:dev.raddbg_user && popd", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, }, // .f3 = { .win = "pushd build && raddbg --user:dev.raddbg_user && popd", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
+34 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#undef LAYER_COLOR #undef LAYER_COLOR
@@ -234,6 +234,39 @@ async_execute_work(ASYNC_Work work)
} }
} }
////////////////////////////////
//~ rjf: Root Allocation/Deallocation
internal ASYNC_Root *
async_root_alloc(void)
{
Arena *arena = arena_alloc();
ASYNC_Root *root = push_array(arena, ASYNC_Root, 1);
root->arenas = push_array(arena, Arena *, async_thread_count());
root->arenas[0] = arena;
for(U64 idx = 1; idx < async_thread_count(); idx += 1)
{
root->arenas[idx] = arena_alloc();
}
return root;
}
internal void
async_root_release(ASYNC_Root *root)
{
for(U64 idx = 1; idx < async_thread_count(); idx += 1)
{
arena_release(root->arenas[idx]);
}
arena_release(root->arenas[0]);
}
internal Arena *
async_root_thread_arena(ASYNC_Root *root)
{
return root->arenas[async_work_thread_idx];
}
//////////////////////////////// ////////////////////////////////
//~ rjf: Work Thread Entry Point //~ rjf: Work Thread Entry Point
+17 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef ASYNC_H #ifndef ASYNC_H
@@ -70,6 +70,15 @@ struct ASYNC_TaskList
U64 count; U64 count;
}; };
////////////////////////////////
//~ rjf: Root (Per-Worker-Thread Arena Bundle)
typedef struct ASYNC_Root ASYNC_Root;
struct ASYNC_Root
{
Arena **arenas;
};
//////////////////////////////// ////////////////////////////////
//~ rjf: Shared State Bundle //~ rjf: Shared State Bundle
@@ -138,6 +147,13 @@ internal void *async_task_join(ASYNC_Task *task);
internal ASYNC_Work async_pop_work(void); internal ASYNC_Work async_pop_work(void);
internal void async_execute_work(ASYNC_Work work); internal void async_execute_work(ASYNC_Work work);
////////////////////////////////
//~ rjf: Root Allocation/Deallocation
internal ASYNC_Root *async_root_alloc(void);
internal void async_root_release(ASYNC_Root *root);
internal Arena *async_root_thread_arena(ASYNC_Root *root);
//////////////////////////////// ////////////////////////////////
//~ rjf: Work Thread Entry Point //~ rjf: Work Thread Entry Point
+7 -2
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//////////////////////////////// ////////////////////////////////
@@ -37,6 +37,7 @@ arena_alloc_(ArenaParams *params)
base = os_reserve(reserve_size); base = os_reserve(reserve_size);
os_commit(base, commit_size); os_commit(base, commit_size);
} }
raddbg_annotate_vaddr_range(base, reserve_size, "arena %s:%i", params->allocation_site_file, params->allocation_site_line);
} }
// rjf: panic on arena creation failure // rjf: panic on arena creation failure
@@ -58,6 +59,8 @@ arena_alloc_(ArenaParams *params)
arena->pos = ARENA_HEADER_SIZE; arena->pos = ARENA_HEADER_SIZE;
arena->cmt = commit_size; arena->cmt = commit_size;
arena->res = reserve_size; arena->res = reserve_size;
arena->allocation_site_file = params->allocation_site_file;
arena->allocation_site_line = params->allocation_site_line;
#if ARENA_FREE_LIST #if ARENA_FREE_LIST
arena->free_size = 0; arena->free_size = 0;
arena->free_last = 0; arena->free_last = 0;
@@ -123,7 +126,9 @@ arena_push(Arena *arena, U64 size, U64 align)
} }
new_block = arena_alloc(.reserve_size = res_size, new_block = arena_alloc(.reserve_size = res_size,
.commit_size = cmt_size, .commit_size = cmt_size,
.flags = current->flags); .flags = current->flags,
.allocation_site_file = current->allocation_site_file,
.allocation_site_line = current->allocation_site_line);
} }
new_block->base_pos = current->base_pos + current->res; new_block->base_pos = current->base_pos + current->res;
+6 -2
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef BASE_ARENA_H #ifndef BASE_ARENA_H
@@ -26,6 +26,8 @@ struct ArenaParams
U64 reserve_size; U64 reserve_size;
U64 commit_size; U64 commit_size;
void *optional_backing_buffer; void *optional_backing_buffer;
char *allocation_site_file;
int allocation_site_line;
}; };
typedef struct Arena Arena; typedef struct Arena Arena;
@@ -40,6 +42,8 @@ struct Arena
U64 pos; U64 pos;
U64 cmt; U64 cmt;
U64 res; U64 res;
char *allocation_site_file;
int allocation_site_line;
#if ARENA_FREE_LIST #if ARENA_FREE_LIST
U64 free_size; U64 free_size;
Arena *free_last; Arena *free_last;
@@ -66,7 +70,7 @@ global ArenaFlags arena_default_flags = 0;
//- rjf: arena creation/destruction //- rjf: arena creation/destruction
internal Arena *arena_alloc_(ArenaParams *params); internal Arena *arena_alloc_(ArenaParams *params);
#define arena_alloc(...) arena_alloc_(&(ArenaParams){.reserve_size = arena_default_reserve_size, .commit_size = arena_default_commit_size, .flags = arena_default_flags, __VA_ARGS__}) #define arena_alloc(...) arena_alloc_(&(ArenaParams){.reserve_size = arena_default_reserve_size, .commit_size = arena_default_commit_size, .flags = arena_default_flags, .allocation_site_file = __FILE__, .allocation_site_line = __LINE__, __VA_ARGS__})
internal void arena_release(Arena *arena); internal void arena_release(Arena *arena);
//- rjf: arena push/pop/pos core functions //- rjf: arena push/pop/pos core functions
+37 -59
View File
@@ -1,19 +1,8 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//////////////////////////////// ////////////////////////////////
//~ NOTE(rjf): Command Line Option Parsing //~ rjf: Command Line Parsing Functions
internal U64
cmd_line_hash_from_string(String8 string)
{
U64 result = 5381;
for(U64 i = 0; i < string.size; i += 1)
{
result = ((result << 5) + result) + string.str[i];
}
return result;
}
internal CmdLineOpt ** internal CmdLineOpt **
cmd_line_slot_from_string(CmdLine *cmd_line, String8 string) cmd_line_slot_from_string(CmdLine *cmd_line, String8 string)
@@ -21,7 +10,7 @@ cmd_line_slot_from_string(CmdLine *cmd_line, String8 string)
CmdLineOpt **slot = 0; CmdLineOpt **slot = 0;
if(cmd_line->option_table_size != 0) if(cmd_line->option_table_size != 0)
{ {
U64 hash = cmd_line_hash_from_string(string); U64 hash = u64_hash_from_str8(string);
U64 bucket = hash % cmd_line->option_table_size; U64 bucket = hash % cmd_line->option_table_size;
slot = &cmd_line->option_table[bucket]; slot = &cmd_line->option_table[bucket];
} }
@@ -64,7 +53,7 @@ cmd_line_insert_opt(Arena *arena, CmdLine *cmd_line, String8 string, String8List
{ {
var = push_array(arena, CmdLineOpt, 1); var = push_array(arena, CmdLineOpt, 1);
var->hash_next = *slot; var->hash_next = *slot;
var->hash = cmd_line_hash_from_string(string); var->hash = u64_hash_from_str8(string);
var->string = push_str8_copy(arena, string); var->string = push_str8_copy(arena, string);
var->value_strings = values; var->value_strings = values;
StringJoin join = {0}; StringJoin join = {0};
@@ -83,28 +72,25 @@ cmd_line_from_string_list(Arena *arena, String8List command_line)
{ {
CmdLine parsed = {0}; CmdLine parsed = {0};
parsed.exe_name = command_line.first->string; parsed.exe_name = command_line.first->string;
parsed.option_table_size = 64;
// NOTE(rjf): Set up config option table.
{
parsed.option_table_size = 4096;
parsed.option_table = push_array(arena, CmdLineOpt *, parsed.option_table_size); parsed.option_table = push_array(arena, CmdLineOpt *, parsed.option_table_size);
}
// NOTE(rjf): Parse command line. //- rjf: parse options / inputs
B32 after_passthrough_option = 0; B32 after_passthrough_option = 0;
B32 first_passthrough = 1; B32 first_passthrough = 1;
for(String8Node *node = command_line.first->next, *next = 0; node != 0; node = next) for(String8Node *node = command_line.first->next, *next = 0; node != 0; node = next)
{ {
next = node->next; next = node->next;
String8 option_name = node->string;
// NOTE(rjf): Look at --, -, or / (only on Windows) at the start of an //- rjf: look at --, -, or / (only on Windows) at the start of an
// argument to determine if it's a flag option. All arguments after a // argument to determine if it's a flag option. all arguments after a
// single "--" (with no trailing string on the command line will be // single "--" (with no trailing string on the command line will be
// considered as input files. // considered as passthrough input strings.
B32 is_option = 1; B32 is_option = 0;
if(after_passthrough_option == 0) String8 option_name = node->string;
if(!after_passthrough_option)
{ {
is_option = 1;
if(str8_match(node->string, str8_lit("--"), 0)) if(str8_match(node->string, str8_lit("--"), 0))
{ {
after_passthrough_option = 1; after_passthrough_option = 1;
@@ -128,69 +114,61 @@ cmd_line_from_string_list(Arena *arena, String8List command_line)
is_option = 0; is_option = 0;
} }
} }
else
{
is_option = 0;
}
// NOTE(rjf): This string is an option. //- rjf: string is an option
if(is_option) if(is_option)
{ {
B32 has_arguments = 0; // rjf: unpack option prefix
U64 arg_signifier_position1 = str8_find_needle(option_name, 0, str8_lit(":"), 0); B32 has_values = 0;
U64 arg_signifier_position2 = str8_find_needle(option_name, 0, str8_lit("="), 0); U64 value_signifier_position1 = str8_find_needle(option_name, 0, str8_lit(":"), 0);
U64 arg_signifier_position = Min(arg_signifier_position1, arg_signifier_position2); U64 value_signifier_position2 = str8_find_needle(option_name, 0, str8_lit("="), 0);
String8 arg_portion_this_string = str8_skip(option_name, arg_signifier_position+1); U64 value_signifier_position = Min(value_signifier_position1, value_signifier_position2);
if(arg_signifier_position < option_name.size) String8 value_portion_this_string = str8_skip(option_name, value_signifier_position+1);
if(value_signifier_position < option_name.size)
{ {
has_arguments = 1; has_values = 1;
} }
option_name = str8_prefix(option_name, arg_signifier_position); option_name = str8_prefix(option_name, value_signifier_position);
String8List arguments = {0}; // rjf: parse option's values
String8List values = {0};
// NOTE(rjf): Parse arguments. if(has_values)
if(has_arguments)
{ {
for(String8Node *n = node; n; n = n->next) for(String8Node *n = node; n; n = n->next)
{ {
next = n->next; next = n->next;
String8 string = n->string; String8 string = n->string;
if(n == node) if(n == node)
{ {
string = arg_portion_this_string; string = value_portion_this_string;
} }
U8 splits[] = { ',' }; U8 splits[] = { ',' };
String8List args_in_this_string = str8_split(arena, string, splits, ArrayCount(splits), 0); String8List values_in_this_string = str8_split(arena, string, splits, ArrayCount(splits), 0);
for(String8Node *sub_arg = args_in_this_string.first; sub_arg; sub_arg = sub_arg->next) for(String8Node *sub_val = values_in_this_string.first; sub_val; sub_val = sub_val->next)
{ {
str8_list_push(arena, &arguments, sub_arg->string); str8_list_push(arena, &values, sub_val->string);
} }
if(!str8_match(str8_postfix(n->string, 1), str8_lit(","), 0) && if(!str8_match(str8_postfix(n->string, 1), str8_lit(","), 0) &&
(n != node || arg_portion_this_string.size != 0)) (n != node || value_portion_this_string.size != 0))
{ {
break; break;
} }
} }
} }
// NOTE(rjf): Register config variable. // rjf: store
cmd_line_insert_opt(arena, &parsed, option_name, arguments); cmd_line_insert_opt(arena, &parsed, option_name, values);
} }
// NOTE(rjf): Default path, treat as a passthrough config option to be //- rjf: default path - treat as a passthrough input
// handled by tool-specific code.
else if(!str8_match(node->string, str8_lit("--"), 0) || !first_passthrough) else if(!str8_match(node->string, str8_lit("--"), 0) || !first_passthrough)
{ {
str8_list_push(arena, &parsed.inputs, node->string); str8_list_push(arena, &parsed.inputs, node->string);
after_passthrough_option = 1;
first_passthrough = 0; first_passthrough = 0;
} }
} }
// rjf: fill argc/argv //- rjf: fill argc/argv
parsed.argc = command_line.node_count; parsed.argc = command_line.node_count;
parsed.argv = push_array(arena, char *, parsed.argc); parsed.argv = push_array(arena, char *, parsed.argc);
{ {
@@ -239,12 +217,12 @@ internal B32
cmd_line_has_flag(CmdLine *cmd_line, String8 name) cmd_line_has_flag(CmdLine *cmd_line, String8 name)
{ {
CmdLineOpt *var = cmd_line_opt_from_string(cmd_line, name); CmdLineOpt *var = cmd_line_opt_from_string(cmd_line, name);
return(var != 0); return (var != 0);
} }
internal B32 internal B32
cmd_line_has_argument(CmdLine *cmd_line, String8 name) cmd_line_has_argument(CmdLine *cmd_line, String8 name)
{ {
CmdLineOpt *var = cmd_line_opt_from_string(cmd_line, name); CmdLineOpt *var = cmd_line_opt_from_string(cmd_line, name);
return(var != 0 && var->value_strings.node_count > 0); return (var != 0 && var->value_strings.node_count > 0);
} }
+2 -3
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef BASE_COMMAND_LINE_H #ifndef BASE_COMMAND_LINE_H
@@ -39,9 +39,8 @@ struct CmdLine
}; };
//////////////////////////////// ////////////////////////////////
//~ NOTE(rjf): Command Line Option Parsing //~ rjf: Command Line Parsing Functions
internal U64 cmd_line_hash_from_string(String8 string);
internal CmdLineOpt** cmd_line_slot_from_string(CmdLine *cmd_line, String8 string); internal CmdLineOpt** cmd_line_slot_from_string(CmdLine *cmd_line, String8 string);
internal CmdLineOpt* cmd_line_opt_from_slot(CmdLineOpt **slot, String8 string); internal CmdLineOpt* cmd_line_opt_from_slot(CmdLineOpt **slot, String8 string);
internal void cmd_line_push_opt(CmdLineOptList *list, CmdLineOpt *var); internal void cmd_line_push_opt(CmdLineOptList *list, CmdLineOpt *var);
+2 -2
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef BASE_CONTEXT_CRACKING_H #ifndef BASE_CONTEXT_CRACKING_H
@@ -159,7 +159,7 @@
#endif #endif
#if !defined(BUILD_VERSION_PATCH) #if !defined(BUILD_VERSION_PATCH)
# define BUILD_VERSION_PATCH 18 # define BUILD_VERSION_PATCH 20
#endif #endif
#define BUILD_VERSION_STRING_LITERAL Stringify(BUILD_VERSION_MAJOR) "." Stringify(BUILD_VERSION_MINOR) "." Stringify(BUILD_VERSION_PATCH) #define BUILD_VERSION_STRING_LITERAL Stringify(BUILD_VERSION_MAJOR) "." Stringify(BUILD_VERSION_MINOR) "." Stringify(BUILD_VERSION_PATCH)
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//////////////////////////////// ////////////////////////////////
+11 -9
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef BASE_CORE_H #ifndef BASE_CORE_H
@@ -346,7 +346,7 @@ C_LINKAGE void __asan_unpoison_memory_region(void const volatile *addr, size_t s
#else #else
# error Missing pointer-to-integer cast for this architecture. # error Missing pointer-to-integer cast for this architecture.
#endif #endif
#define PtrFromInt(i) (void*)((U8*)0 + (i)) #define PtrFromInt(i) (void*)(i)
#define Compose64Bit(a,b) ((((U64)a) << 32) | ((U64)b)); #define Compose64Bit(a,b) ((((U64)a) << 32) | ((U64)b));
#define AlignPow2(x,b) (((x) + (b) - 1)&(~((b) - 1))) #define AlignPow2(x,b) (((x) + (b) - 1)&(~((b) - 1)))
@@ -487,14 +487,16 @@ typedef enum OperatingSystem
} }
OperatingSystem; OperatingSystem;
typedef enum ImageType typedef enum ExecutableImageKind
{ {
Image_Null, ExecutableImageKind_Null,
Image_CoffPe, ExecutableImageKind_CoffPe,
Image_Elf32, ExecutableImageKind_Elf32,
Image_Elf64, ExecutableImageKind_Elf64,
Image_Macho ExecutableImageKind_Macho,
} ImageType; ExecutableImageKind_COUNT
}
ExecutableImageKind;
typedef enum Arch typedef enum Arch
{ {
+6 -4
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
global U64 global_update_tick_idx = 0; global U64 global_update_tick_idx = 0;
@@ -17,6 +17,11 @@ main_thread_base_entry_point(int arguments_count, char **arguments)
tmInitialize(sizeof(tm_data), tm_data); tmInitialize(sizeof(tm_data), tm_data);
#endif #endif
//- rjf: set up spall
#if PROFILE_SPALL
spall_profile = spall_init_file_ex("spall_capture", 1, 0);
#endif
//- rjf: parse command line //- rjf: parse command line
String8List command_line_argument_strings = os_string_list_from_argcv(scratch.arena, arguments_count, arguments); String8List command_line_argument_strings = os_string_list_from_argcv(scratch.arena, arguments_count, arguments);
CmdLine cmdline = cmd_line_from_string_list(scratch.arena, command_line_argument_strings); CmdLine cmdline = cmd_line_from_string_list(scratch.arena, command_line_argument_strings);
@@ -36,9 +41,6 @@ main_thread_base_entry_point(int arguments_count, char **arguments)
#if defined(ASYNC_H) && !defined(ASYNC_INIT_MANUAL) #if defined(ASYNC_H) && !defined(ASYNC_INIT_MANUAL)
async_init(&cmdline); async_init(&cmdline);
#endif #endif
#if defined(RDI_FROM_PDB_H) && !defined(P2R_INIT_MANUAL)
p2r_init();
#endif
#if defined(HASH_STORE_H) && !defined(HS_INIT_MANUAL) #if defined(HASH_STORE_H) && !defined(HS_INIT_MANUAL)
hs_init(); hs_init();
#endif #endif
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef BASE_ENTRY_POINT_H #ifndef BASE_ENTRY_POINT_H
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//////////////////////////////// ////////////////////////////////
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef BASE_INC_H #ifndef BASE_INC_H
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//////////////////////////////// ////////////////////////////////
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef BASE_LOG_H #ifndef BASE_LOG_H
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
internal void internal void
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef BASE_MARKUP_H #ifndef BASE_MARKUP_H
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//////////////////////////////// ////////////////////////////////
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef BASE_MATH_H #ifndef BASE_MATH_H
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//////////////////////////////// ////////////////////////////////
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef BASE_META_H #ifndef BASE_META_H
+30 -1
View File
@@ -1,2 +1,31 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#if PROFILE_SPALL
internal inline void
spall_begin(char *fmt, ...)
{
if(spall_buffer.data == 0)
{
spall_buffer.length = MB(1);
spall_buffer.data = os_reserve(spall_buffer.length);
os_commit(spall_buffer.data, spall_buffer.length);
spall_buffer_init(&spall_profile, &spall_buffer);
}
if(spall_pid == 0)
{
spall_pid = os_get_process_info()->pid;
}
if(spall_tid == 0)
{
spall_tid = os_tid();
}
Temp scratch = scratch_begin(0, 0);
va_list args;
va_start(args, fmt);
String8 string = push_str8fv(scratch.arena, fmt, args);
spall_buffer_begin_ex(&spall_profile, &spall_buffer, string.str, string.size, os_now_microseconds(), spall_tid, spall_pid);
va_end(args);
scratch_end(scratch);
}
#endif
+34 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef BASE_PROFILE_H #ifndef BASE_PROFILE_H
@@ -10,6 +10,9 @@
#if !defined(PROFILE_TELEMETRY) #if !defined(PROFILE_TELEMETRY)
# define PROFILE_TELEMETRY 0 # define PROFILE_TELEMETRY 0
#endif #endif
#if !defined(PROFILE_SPALL)
# define PROFILE_SPALL 0
#endif
//////////////////////////////// ////////////////////////////////
//~ rjf: Third Party Includes //~ rjf: Third Party Includes
@@ -19,6 +22,8 @@
# if OS_WINDOWS # if OS_WINDOWS
# pragma comment(lib, "rad_tm_win64.lib") # pragma comment(lib, "rad_tm_win64.lib")
# endif # endif
#elif PROFILE_SPALL
# include "spall.h"
#endif #endif
//////////////////////////////// ////////////////////////////////
@@ -61,6 +66,34 @@ scratch_end(scratch); \
} }
#endif #endif
////////////////////////////////
//~ rjf: Spall Profile Defines
#if PROFILE_SPALL
global U64 spall_capturing = 0;
global SpallProfile spall_profile = {0};
thread_static SpallBuffer spall_buffer = {0};
thread_static U32 spall_tid = 0;
thread_static U32 spall_pid = 0;
internal inline void spall_begin(char *fmt, ...);
# define ProfBegin(...) (spall_capturing ? (spall_begin(__VA_ARGS__), 0) : 0)
# define ProfBeginDynamic(...) (spall_capturing ? (spall_begin(__VA_ARGS__), 0) : 0)
# define ProfEnd(...) (spall_capturing ? (spall_buffer_end_ex(&spall_profile, &spall_buffer, os_now_microseconds(), spall_tid, spall_pid)), 0 : 0)
# define ProfTick(...)
# define ProfIsCapturing(...) (!!spall_capturing)
# define ProfBeginCapture(...) (spall_capturing = 1)
# define ProfEndCapture(...) (spall_capturing = 0, spall_flush(&spall_profile))
# define ProfThreadName(...)
# define ProfMsg(...)
# define ProfBeginLockWait(...)
# define ProfEndLockWait(...)
# define ProfLockTake(...)
# define ProfLockDrop(...)
# define ProfColor(color)
# define ProfBeginV(...)
# define ProfNoteV(...)
#endif
//////////////////////////////// ////////////////////////////////
//~ rjf: Zeroify Undefined Defines //~ rjf: Zeroify Undefined Defines
+24 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//////////////////////////////// ////////////////////////////////
@@ -2484,3 +2484,26 @@ str8_deserial_read_block(String8 string, U64 off, U64 size, String8 *block_out)
*block_out = str8_substr(string, range); *block_out = str8_substr(string, range);
return block_out->size; return block_out->size;
} }
////////////////////////////////
//~ rjf: Basic String Hashes
#if !defined(XXH_IMPLEMENTATION)
# define XXH_IMPLEMENTATION
# define XXH_STATIC_LINKING_ONLY
# include "third_party/xxHash/xxhash.h"
#endif
internal U64
u64_hash_from_seed_str8(U64 seed, String8 string)
{
U64 result = XXH3_64bits_withSeed(string.str, string.size, seed);
return result;
}
internal U64
u64_hash_from_str8(String8 string)
{
U64 result = u64_hash_from_seed_str8(5381, string);
return result;
}
+7 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef BASE_STRINGS_H #ifndef BASE_STRINGS_H
@@ -433,4 +433,10 @@ internal U64 str8_deserial_read_block(String8 string, U64 off, U64 size, Stri
#define str8_deserial_read_array(string, off, ptr, count) str8_deserial_read((string), (off), (ptr), sizeof(*(ptr))*(count), sizeof(*(ptr))) #define str8_deserial_read_array(string, off, ptr, count) str8_deserial_read((string), (off), (ptr), sizeof(*(ptr))*(count), sizeof(*(ptr)))
#define str8_deserial_read_struct(string, off, ptr) str8_deserial_read_array(string, off, ptr, 1) #define str8_deserial_read_struct(string, off, ptr) str8_deserial_read_array(string, off, ptr, 1)
////////////////////////////////
//~ rjf: Basic String Hashes
internal U64 u64_hash_from_seed_str8(U64 seed, String8 string);
internal U64 u64_hash_from_str8(String8 string);
#endif // BASE_STRINGS_H #endif // BASE_STRINGS_H
+30 -20
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//////////////////////////////// ////////////////////////////////
@@ -10,10 +10,12 @@ C_LINKAGE thread_static TCTX* tctx_thread_local = 0;
#endif #endif
internal void internal void
tctx_init_and_equip(TCTX *tctx){ tctx_init_and_equip(TCTX *tctx)
{
MemoryZeroStruct(tctx); MemoryZeroStruct(tctx);
Arena **arena_ptr = tctx->arenas; Arena **arena_ptr = tctx->arenas;
for (U64 i = 0; i < ArrayCount(tctx->arenas); i += 1, arena_ptr += 1){ for(U64 i = 0; i < ArrayCount(tctx->arenas); i += 1, arena_ptr += 1)
{
*arena_ptr = arena_alloc(); *arena_ptr = arena_alloc();
} }
tctx_thread_local = tctx; tctx_thread_local = tctx;
@@ -28,37 +30,42 @@ tctx_release(void)
} }
} }
internal TCTX* internal TCTX *
tctx_get_equipped(void){ tctx_get_equipped(void)
return(tctx_thread_local); {
return tctx_thread_local;
} }
internal Arena* internal Arena *
tctx_get_scratch(Arena **conflicts, U64 count){ tctx_get_scratch(Arena **conflicts, U64 count)
{
TCTX *tctx = tctx_get_equipped(); TCTX *tctx = tctx_get_equipped();
Arena *result = 0; Arena *result = 0;
Arena **arena_ptr = tctx->arenas; Arena **arena_ptr = tctx->arenas;
for (U64 i = 0; i < ArrayCount(tctx->arenas); i += 1, arena_ptr += 1){ for(U64 i = 0; i < ArrayCount(tctx->arenas); i += 1, arena_ptr += 1)
{
Arena **conflict_ptr = conflicts; Arena **conflict_ptr = conflicts;
B32 has_conflict = 0; B32 has_conflict = 0;
for (U64 j = 0; j < count; j += 1, conflict_ptr += 1){ for(U64 j = 0; j < count; j += 1, conflict_ptr += 1)
if (*arena_ptr == *conflict_ptr){ {
if(*arena_ptr == *conflict_ptr)
{
has_conflict = 1; has_conflict = 1;
break; break;
} }
} }
if (!has_conflict){ if(!has_conflict)
{
result = *arena_ptr; result = *arena_ptr;
break; break;
} }
} }
return result;
return(result);
} }
internal void internal void
tctx_set_thread_name(String8 string){ tctx_set_thread_name(String8 string)
{
TCTX *tctx = tctx_get_equipped(); TCTX *tctx = tctx_get_equipped();
U64 size = ClampTop(string.size, sizeof(tctx->thread_name)); U64 size = ClampTop(string.size, sizeof(tctx->thread_name));
MemoryCopy(tctx->thread_name, string.str, size); MemoryCopy(tctx->thread_name, string.str, size);
@@ -66,21 +73,24 @@ tctx_set_thread_name(String8 string){
} }
internal String8 internal String8
tctx_get_thread_name(void){ tctx_get_thread_name(void)
{
TCTX *tctx = tctx_get_equipped(); TCTX *tctx = tctx_get_equipped();
String8 result = str8(tctx->thread_name, tctx->thread_name_size); String8 result = str8(tctx->thread_name, tctx->thread_name_size);
return(result); return result;
} }
internal void internal void
tctx_write_srcloc(char *file_name, U64 line_number){ tctx_write_srcloc(char *file_name, U64 line_number)
{
TCTX *tctx = tctx_get_equipped(); TCTX *tctx = tctx_get_equipped();
tctx->file_name = file_name; tctx->file_name = file_name;
tctx->line_number = line_number; tctx->line_number = line_number;
} }
internal void internal void
tctx_read_srcloc(char **file_name, U64 *line_number){ tctx_read_srcloc(char **file_name, U64 *line_number)
{
TCTX *tctx = tctx_get_equipped(); TCTX *tctx = tctx_get_equipped();
*file_name = tctx->file_name; *file_name = tctx->file_name;
*line_number = tctx->line_number; *line_number = tctx->line_number;
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef BASE_THREAD_CONTEXT_H #ifndef BASE_THREAD_CONTEXT_H
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//////////////////////////////// ////////////////////////////////
+993 -993
View File
File diff suppressed because it is too large Load Diff
+10 -10
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
internal String8 internal String8
@@ -23,9 +23,9 @@ internal String8
cv_string_from_language(CV_Language x) cv_string_from_language(CV_Language x)
{ {
switch (x) { switch (x) {
#define X(_n,_i) case _i: return str8_lit(Stringify(_n)); #define X(_n,_i) case _i: return str8_lit(Stringify(_n));
CV_LanguageXList(X) CV_LanguageXList(X)
#undef X #undef X
} }
return str8_zero(); return str8_zero();
} }
@@ -59,16 +59,16 @@ cv_string_from_reg_id(Arena *arena, CV_Arch arch, U32 id)
switch (arch) { switch (arch) {
case CV_Arch_8086: { case CV_Arch_8086: {
switch (id) { switch (id) {
#define X(_N, _ID, ...) case _ID: result = str8_lit(Stringify(_N)); break; #define X(_N, _ID, ...) case _ID: result = str8_lit(Stringify(_N)); break;
CV_Reg_X86_XList(X) CV_Reg_X86_XList(X)
#undef X #undef X
} }
} break; } break;
case CV_Arch_X64: { case CV_Arch_X64: {
switch (id) { switch (id) {
#define X(_N, _ID, ...) case _ID: result = str8_lit(Stringify(_N)); break; #define X(_N, _ID, ...) case _ID: result = str8_lit(Stringify(_N)); break;
CV_Reg_X64_XList(X) CV_Reg_X64_XList(X)
#undef X #undef X
} }
} break; } break;
default: NotImplemented; break; default: NotImplemented; break;
@@ -327,9 +327,9 @@ internal String8
cv_string_from_c13_subsection_kind(CV_C13SubSectionKind x) cv_string_from_c13_subsection_kind(CV_C13SubSectionKind x)
{ {
switch (x) { switch (x) {
#define X(_N, _ID) case CV_C13SubSectionKind_##_N: return str8_lit(Stringify(_N)); #define X(_N, _ID) case CV_C13SubSectionKind_##_N: return str8_lit(Stringify(_N));
CV_C13SubSectionKindXList(X) CV_C13SubSectionKindXList(X)
#undef X #undef X
} }
return str8_zero(); return str8_zero();
} }
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef CODEVIEW_ENUM_H #ifndef CODEVIEW_ENUM_H
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//- Hasher //- Hasher
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef CODEVIEW_PARSE_H #ifndef CODEVIEW_PARSE_H
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//- GENERATED CODE //- GENERATED CODE
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//- GENERATED CODE //- GENERATED CODE
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
internal U64 internal U64
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef COFF_H #ifndef COFF_H
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
internal String8 internal String8
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef COFF_ENUM_H #ifndef COFF_ENUM_H
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
internal B32 internal B32
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef COFF_PARSE_H #ifndef COFF_PARSE_H
+2 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//////////////////////////////// ////////////////////////////////
@@ -17,6 +17,7 @@ CTRL_EntityKindTable:
{PendingThreadName pending_thread_name "Pending Thread Name" } {PendingThreadName pending_thread_name "Pending Thread Name" }
{PendingThreadColor pending_thread_color "Pending Thread Color" } {PendingThreadColor pending_thread_color "Pending Thread Color" }
{Breakpoint breakpoint "Breakpoint" } {Breakpoint breakpoint "Breakpoint" }
{AddressRangeAnnotation address_range_annotation "Address Range Annotation" }
} }
@enum CTRL_EntityKind: @enum CTRL_EntityKind:
+57 -33
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//////////////////////////////// ////////////////////////////////
@@ -1399,6 +1399,15 @@ ctrl_entity_store_apply_events(CTRL_EntityCtxRWStore *store, CTRL_EventList *lis
} }
} }
}break; }break;
//- rjf: address range annotations
case CTRL_EventKind_SetVAddrRangeNote:
{
CTRL_Entity *process = ctrl_entity_from_handle(&store->ctx, event->parent);
CTRL_Entity *annotation = ctrl_entity_alloc(store, process, CTRL_EntityKind_AddressRangeAnnotation, Arch_Null, ctrl_handle_zero(), 0);
annotation->vaddr_range = event->vaddr_rng;
ctrl_entity_equip_string(store, annotation, event->string);
}break;
} }
} }
} }
@@ -1652,14 +1661,13 @@ ctrl_key_from_process_vaddr_range(CTRL_Handle process, Rng1U64 vaddr_range, B32
//- rjf: loop: try to look for current results, request if not there, wait if we can, repeat until we can't //- rjf: loop: try to look for current results, request if not there, wait if we can, repeat until we can't
U64 mem_gen = ctrl_mem_gen(); U64 mem_gen = ctrl_mem_gen();
B32 key_is_stale = 0; B32 key_is_stale = 0;
B32 requested = 0;
for(;;) for(;;)
{ {
//- rjf: step 1: [read-only] try to look for current results for key's ID //- rjf: step 1: [read-only] try to look for current results for key's ID; wait if working & retry
B32 id_exists = 0; B32 id_exists = 0;
B32 id_stale = 0; B32 id_stale = 0;
B32 id_working = 0; B32 id_working = 0;
OS_MutexScopeR(process_stripe->rw_mutex) OS_MutexScopeR(process_stripe->rw_mutex) for(;;)
{ {
for(CTRL_ProcessMemoryCacheNode *process_n = process_slot->first; process_n != 0; process_n = process_n->next) for(CTRL_ProcessMemoryCacheNode *process_n = process_slot->first; process_n != 0; process_n = process_n->next)
{ {
@@ -1680,6 +1688,14 @@ ctrl_key_from_process_vaddr_range(CTRL_Handle process, Rng1U64 vaddr_range, B32
} }
} }
end_fast_lookup:; end_fast_lookup:;
if(os_now_microseconds() >= endt_us || !id_working)
{
break;
}
else
{
os_condition_variable_wait_rw_r(process_stripe->cv, process_stripe->rw_mutex, endt_us);
}
} }
key_is_stale = id_stale; key_is_stale = id_stale;
@@ -1693,7 +1709,9 @@ ctrl_key_from_process_vaddr_range(CTRL_Handle process, Rng1U64 vaddr_range, B32
//- rjf: step 3: if the ID does not exist in the process' cache, then we //- rjf: step 3: if the ID does not exist in the process' cache, then we
// need to build a node for it. if that, or if the ID is stale, then also // need to build a node for it. if that, or if the ID is stale, then also
// request that that range is streamed. // request that that range is streamed & wait for its result (for as long
// as we have.)
B32 requested = 0;
if(!id_exists || (id_exists && id_stale && !id_working)) if(!id_exists || (id_exists && id_stale && !id_working))
{ {
B32 node_needs_stream = 0; B32 node_needs_stream = 0;
@@ -1722,17 +1740,16 @@ ctrl_key_from_process_vaddr_range(CTRL_Handle process, Rng1U64 vaddr_range, B32
range_n->vaddr_range = vaddr_range; range_n->vaddr_range = vaddr_range;
range_n->zero_terminated = zero_terminated; range_n->zero_terminated = zero_terminated;
range_n->id = id; range_n->id = id;
ins_atomic_u64_inc_eval(&range_n->working_count);
node_needs_stream = 1; node_needs_stream = 1;
} }
else else
{ {
node_needs_stream = (range_n->mem_gen < mem_gen); node_needs_stream = (range_n->mem_gen < mem_gen);
}
if(node_needs_stream) if(node_needs_stream)
{ {
ins_atomic_u64_inc_eval(&range_n->working_count); ins_atomic_u64_inc_eval(&range_n->working_count);
} }
}
node_working_count = &range_n->working_count; node_working_count = &range_n->working_count;
break; break;
} }
@@ -1768,21 +1785,11 @@ ctrl_key_from_process_vaddr_range(CTRL_Handle process, Rng1U64 vaddr_range, B32
} }
} }
//- rjf: step 4: if we have no time to wait, then abort; if we submitted a //- rjf: step 4: if we didn't request, and if we aren't working, then exit
// request, but the work is done and we have no results, then abort; if(!requested && !id_working)
// otherwise, wait on this process' stripe
if(os_now_microseconds() >= endt_us)
{ {
break; break;
} }
else if(!id_working && requested)
{
break;
}
else OS_MutexScopeR(process_stripe->rw_mutex)
{
os_condition_variable_wait_rw_r(process_stripe->cv, process_stripe->rw_mutex, endt_us);
}
} }
if(out_is_stale) if(out_is_stale)
{ {
@@ -3399,7 +3406,10 @@ ctrl_call_stack_from_thread(CTRL_Scope *scope, CTRL_EntityCtx *entity_ctx, CTRL_
// //
B32 can_request = !ins_atomic_u64_eval(&ctrl_state->ctrl_thread_run_state); B32 can_request = !ins_atomic_u64_eval(&ctrl_state->ctrl_thread_run_state);
B32 did_request = 0; B32 did_request = 0;
OS_MutexScopeR(stripe->rw_mutex) for(;;) OS_MutexScopeR(stripe->rw_mutex)
{
CTRL_CallStackCacheNode *taken_node = 0;
for(;;)
{ {
//////////////////////////// ////////////////////////////
//- rjf: try to grab cached //- rjf: try to grab cached
@@ -3418,7 +3428,7 @@ ctrl_call_stack_from_thread(CTRL_Scope *scope, CTRL_EntityCtx *entity_ctx, CTRL_
is_stale = (reg_gen > n->reg_gen || mem_gen > n->mem_gen); is_stale = (reg_gen > n->reg_gen || mem_gen > n->mem_gen);
is_working = (n->working_count > 0); is_working = (n->working_count > 0);
call_stack = n->call_stack; call_stack = n->call_stack;
ctrl_scope_touch_call_stack_node__stripe_r_guarded(scope, stripe, n); taken_node = node;
break; break;
} }
} }
@@ -3480,6 +3490,11 @@ ctrl_call_stack_from_thread(CTRL_Scope *scope, CTRL_EntityCtx *entity_ctx, CTRL_
os_condition_variable_wait_rw_r(stripe->cv, stripe->rw_mutex, endt_us); os_condition_variable_wait_rw_r(stripe->cv, stripe->rw_mutex, endt_us);
} }
} }
if(taken_node != 0)
{
ctrl_scope_touch_call_stack_node__stripe_r_guarded(scope, stripe, taken_node);
}
}
return call_stack; return call_stack;
} }
@@ -3974,13 +3989,8 @@ ctrl_thread__module_open(CTRL_Handle process, CTRL_Handle module, Rng1U64 vaddr_
file_header_off + sizeof(COFF_FileHeader) + opt_ext_size); file_header_off + sizeof(COFF_FileHeader) + opt_ext_size);
//- rjf: read optional header //- rjf: read optional header
U16 optional_magic = 0;
U64 image_base = 0;
U64 entry_point = 0; U64 entry_point = 0;
U32 data_dir_count = 0; U32 data_dir_count = 0;
U64 virt_section_align = 0;
U64 file_section_align = 0;
Rng1U64 *data_dir_franges = 0;
if(opt_ext_size > 0) if(opt_ext_size > 0)
{ {
// rjf: read magic number // rjf: read magic number
@@ -3996,10 +4006,7 @@ ctrl_thread__module_open(CTRL_Handle process, CTRL_Handle module, Rng1U64 vaddr_
{ {
PE_OptionalHeader32 pe_optional = {0}; PE_OptionalHeader32 pe_optional = {0};
dmn_process_read_struct(process.dmn_handle, vaddr_range.min + opt_ext_off_range.min, &pe_optional); dmn_process_read_struct(process.dmn_handle, vaddr_range.min + opt_ext_off_range.min, &pe_optional);
image_base = pe_optional.image_base;
entry_point = pe_optional.entry_point_va; entry_point = pe_optional.entry_point_va;
virt_section_align = pe_optional.section_alignment;
file_section_align = pe_optional.file_alignment;
reported_data_dir_offset = sizeof(pe_optional); reported_data_dir_offset = sizeof(pe_optional);
reported_data_dir_count = pe_optional.data_dir_count; reported_data_dir_count = pe_optional.data_dir_count;
}break; }break;
@@ -4007,10 +4014,7 @@ ctrl_thread__module_open(CTRL_Handle process, CTRL_Handle module, Rng1U64 vaddr_
{ {
PE_OptionalHeader32Plus pe_optional = {0}; PE_OptionalHeader32Plus pe_optional = {0};
dmn_process_read_struct(process.dmn_handle, vaddr_range.min + opt_ext_off_range.min, &pe_optional); dmn_process_read_struct(process.dmn_handle, vaddr_range.min + opt_ext_off_range.min, &pe_optional);
image_base = pe_optional.image_base;
entry_point = pe_optional.entry_point_va; entry_point = pe_optional.entry_point_va;
virt_section_align = pe_optional.section_alignment;
file_section_align = pe_optional.file_alignment;
reported_data_dir_offset = sizeof(pe_optional); reported_data_dir_offset = sizeof(pe_optional);
reported_data_dir_count = pe_optional.data_dir_count; reported_data_dir_count = pe_optional.data_dir_count;
}break; }break;
@@ -4660,6 +4664,15 @@ ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg,
out_evt->entity_id = event->code; out_evt->entity_id = event->code;
out_evt->rgba = event->user_data; out_evt->rgba = event->user_data;
}break; }break;
case DMN_EventKind_SetVAddrRangeNote:
{
CTRL_Event *out_evt = ctrl_event_list_push(scratch.arena, &evts);
out_evt->kind = CTRL_EventKind_SetVAddrRangeNote;
out_evt->parent = ctrl_handle_make(CTRL_MachineID_Local, event->process);
out_evt->msg_id = msg->msg_id;
out_evt->vaddr_rng = r1u64(event->address, event->address + event->size);
out_evt->string = event->string;
}
case DMN_EventKind_SetBreakpoint: case DMN_EventKind_SetBreakpoint:
{ {
CTRL_Event *out_evt = ctrl_event_list_push(scratch.arena, &evts); CTRL_Event *out_evt = ctrl_event_list_push(scratch.arena, &evts);
@@ -6747,7 +6760,7 @@ ASYNC_WORK_DEF(ctrl_mem_stream_work)
{ {
if(hs_id_match(range_n->id, key.id)) if(hs_id_match(range_n->id, key.id))
{ {
if(!u128_match(u128_zero(), hash)) if(pre_read_mem_gen == post_read_mem_gen)
{ {
range_n->mem_gen = post_read_mem_gen; range_n->mem_gen = post_read_mem_gen;
} }
@@ -6761,6 +6774,13 @@ ASYNC_WORK_DEF(ctrl_mem_stream_work)
//- rjf: broadcast changes //- rjf: broadcast changes
os_condition_variable_broadcast(process_stripe->cv); os_condition_variable_broadcast(process_stripe->cv);
if(!u128_match(u128_zero(), hash))
{
if(ctrl_state->wakeup_hook != 0)
{
ctrl_state->wakeup_hook();
}
}
ProfEnd(); ProfEnd();
ProfEnd(); ProfEnd();
return 0; return 0;
@@ -7004,6 +7024,10 @@ ASYNC_WORK_DEF(ctrl_call_stack_build_work)
//- rjf: broadcast update //- rjf: broadcast update
os_condition_variable_broadcast(stripe->cv); os_condition_variable_broadcast(stripe->cv);
if(ctrl_state->wakeup_hook != 0)
{
ctrl_state->wakeup_hook();
}
} }
scratch_end(scratch); scratch_end(scratch);
+2 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef CTRL_CORE_H #ifndef CTRL_CORE_H
@@ -424,6 +424,7 @@ typedef enum CTRL_EventKind
CTRL_EventKind_ThreadColor, CTRL_EventKind_ThreadColor,
CTRL_EventKind_SetBreakpoint, CTRL_EventKind_SetBreakpoint,
CTRL_EventKind_UnsetBreakpoint, CTRL_EventKind_UnsetBreakpoint,
CTRL_EventKind_SetVAddrRangeNote,
//- rjf: memory //- rjf: memory
CTRL_EventKind_MemReserve, CTRL_EventKind_MemReserve,
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#undef LAYER_COLOR #undef LAYER_COLOR
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef CTRL_INC_H #ifndef CTRL_INC_H
+5 -3
View File
@@ -1,10 +1,10 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//- GENERATED CODE //- GENERATED CODE
C_LINKAGE_BEGIN C_LINKAGE_BEGIN
String8 ctrl_entity_kind_code_name_table[11] = String8 ctrl_entity_kind_code_name_table[12] =
{ {
{0}, {0},
str8_lit_comp("root"), str8_lit_comp("root"),
@@ -17,9 +17,10 @@ str8_lit_comp("debug_info_path"),
str8_lit_comp("pending_thread_name"), str8_lit_comp("pending_thread_name"),
str8_lit_comp("pending_thread_color"), str8_lit_comp("pending_thread_color"),
str8_lit_comp("breakpoint"), str8_lit_comp("breakpoint"),
str8_lit_comp("address_range_annotation"),
}; };
String8 ctrl_entity_kind_display_string_table[11] = String8 ctrl_entity_kind_display_string_table[12] =
{ {
{0}, {0},
str8_lit_comp("Root"), str8_lit_comp("Root"),
@@ -32,6 +33,7 @@ str8_lit_comp("DebugInfoPath"),
str8_lit_comp("PendingThreadName"), str8_lit_comp("PendingThreadName"),
str8_lit_comp("PendingThreadColor"), str8_lit_comp("PendingThreadColor"),
str8_lit_comp("Breakpoint"), str8_lit_comp("Breakpoint"),
str8_lit_comp("AddressRangeAnnotation"),
}; };
U32 ctrl_exception_code_kind_code_table[38] = U32 ctrl_exception_code_kind_code_table[38] =
+4 -3
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//- GENERATED CODE //- GENERATED CODE
@@ -19,6 +19,7 @@ CTRL_EntityKind_DebugInfoPath,
CTRL_EntityKind_PendingThreadName, CTRL_EntityKind_PendingThreadName,
CTRL_EntityKind_PendingThreadColor, CTRL_EntityKind_PendingThreadColor,
CTRL_EntityKind_Breakpoint, CTRL_EntityKind_Breakpoint,
CTRL_EntityKind_AddressRangeAnnotation,
CTRL_EntityKind_COUNT, CTRL_EntityKind_COUNT,
} CTRL_EntityKind; } CTRL_EntityKind;
@@ -66,8 +67,8 @@ CTRL_ExceptionCodeKind_COUNT,
} CTRL_ExceptionCodeKind; } CTRL_ExceptionCodeKind;
C_LINKAGE_BEGIN C_LINKAGE_BEGIN
extern String8 ctrl_entity_kind_code_name_table[11]; extern String8 ctrl_entity_kind_code_name_table[12];
extern String8 ctrl_entity_kind_display_string_table[11]; extern String8 ctrl_entity_kind_display_string_table[12];
extern U32 ctrl_exception_code_kind_code_table[38]; extern U32 ctrl_exception_code_kind_code_table[38];
extern String8 ctrl_exception_code_kind_display_string_table[38]; extern String8 ctrl_exception_code_kind_display_string_table[38];
extern String8 ctrl_exception_code_kind_lowercase_code_string_table[38]; extern String8 ctrl_exception_code_kind_lowercase_code_string_table[38];
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#undef LAYER_COLOR #undef LAYER_COLOR
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef DASM_CACHE_H #ifndef DASM_CACHE_H
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//////////////////////////////// ////////////////////////////////
+11 -7
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#undef LAYER_COLOR #undef LAYER_COLOR
@@ -378,10 +378,12 @@ d_trap_net_from_thread__step_over_line(Arena *arena, CTRL_Entity *thread)
// rjf: line vaddr range => line's machine code // rjf: line vaddr range => line's machine code
String8 machine_code = {0}; String8 machine_code = {0};
B32 good_machine_code = 0;
if(good_line_info) if(good_line_info)
{ {
CTRL_ProcessMemorySlice machine_code_slice = ctrl_process_memory_slice_from_vaddr_range(scratch.arena, process->handle, line_vaddr_rng, os_now_microseconds()+50000); CTRL_ProcessMemorySlice machine_code_slice = ctrl_process_memory_slice_from_vaddr_range(scratch.arena, process->handle, line_vaddr_rng, os_now_microseconds()+50000);
machine_code = machine_code_slice.data; machine_code = machine_code_slice.data;
good_machine_code = (machine_code.size == dim_1u64(line_vaddr_rng) && !machine_code_slice.any_byte_bad);
LogInfoNamedBlockF("machine_code_slice") LogInfoNamedBlockF("machine_code_slice")
{ {
log_infof("stale: %i\n", machine_code_slice.stale); log_infof("stale: %i\n", machine_code_slice.stale);
@@ -402,7 +404,7 @@ d_trap_net_from_thread__step_over_line(Arena *arena, CTRL_Entity *thread)
// rjf: machine code => ctrl flow analysis // rjf: machine code => ctrl flow analysis
DASM_CtrlFlowInfo ctrl_flow_info = {0}; DASM_CtrlFlowInfo ctrl_flow_info = {0};
if(good_line_info) if(good_machine_code)
{ {
ctrl_flow_info = dasm_ctrl_flow_info_from_arch_vaddr_code(scratch.arena, ctrl_flow_info = dasm_ctrl_flow_info_from_arch_vaddr_code(scratch.arena,
DASM_InstFlag_Call| DASM_InstFlag_Call|
@@ -423,7 +425,7 @@ d_trap_net_from_thread__step_over_line(Arena *arena, CTRL_Entity *thread)
} }
// rjf: push traps for all exit points // rjf: push traps for all exit points
if(good_line_info) for(DASM_CtrlFlowPointNode *n = ctrl_flow_info.exit_points.first; n != 0; n = n->next) if(good_machine_code) for(DASM_CtrlFlowPointNode *n = ctrl_flow_info.exit_points.first; n != 0; n = n->next)
{ {
DASM_CtrlFlowPoint *point = &n->v; DASM_CtrlFlowPoint *point = &n->v;
CTRL_TrapFlags flags = 0; CTRL_TrapFlags flags = 0;
@@ -534,15 +536,17 @@ d_trap_net_from_thread__step_into_line(Arena *arena, CTRL_Entity *thread)
// rjf: line vaddr range => line's machine code // rjf: line vaddr range => line's machine code
String8 machine_code = {0}; String8 machine_code = {0};
B32 good_machine_code = 0;
if(good_line_info) if(good_line_info)
{ {
CTRL_ProcessMemorySlice machine_code_slice = ctrl_process_memory_slice_from_vaddr_range(scratch.arena, process->handle, line_vaddr_rng, os_now_microseconds()+5000); CTRL_ProcessMemorySlice machine_code_slice = ctrl_process_memory_slice_from_vaddr_range(scratch.arena, process->handle, line_vaddr_rng, os_now_microseconds()+5000);
machine_code = machine_code_slice.data; machine_code = machine_code_slice.data;
good_machine_code = (machine_code.size == dim_1u64(line_vaddr_rng) && !machine_code_slice.any_byte_bad);
} }
// rjf: machine code => ctrl flow analysis // rjf: machine code => ctrl flow analysis
DASM_CtrlFlowInfo ctrl_flow_info = {0}; DASM_CtrlFlowInfo ctrl_flow_info = {0};
if(good_line_info) if(good_machine_code)
{ {
ctrl_flow_info = dasm_ctrl_flow_info_from_arch_vaddr_code(scratch.arena, ctrl_flow_info = dasm_ctrl_flow_info_from_arch_vaddr_code(scratch.arena,
DASM_InstFlag_Call| DASM_InstFlag_Call|
@@ -557,7 +561,7 @@ d_trap_net_from_thread__step_into_line(Arena *arena, CTRL_Entity *thread)
// rjf: determine last // rjf: determine last
DASM_CtrlFlowPoint *last_call_point = 0; DASM_CtrlFlowPoint *last_call_point = 0;
if(good_line_info) for(DASM_CtrlFlowPointNode *n = ctrl_flow_info.exit_points.first; n != 0; n = n->next) if(good_machine_code) for(DASM_CtrlFlowPointNode *n = ctrl_flow_info.exit_points.first; n != 0; n = n->next)
{ {
if(n->v.inst_flags & DASM_InstFlag_Call) if(n->v.inst_flags & DASM_InstFlag_Call)
{ {
@@ -566,7 +570,7 @@ d_trap_net_from_thread__step_into_line(Arena *arena, CTRL_Entity *thread)
} }
// rjf: push traps for all exit points // rjf: push traps for all exit points
if(good_line_info) for(DASM_CtrlFlowPointNode *n = ctrl_flow_info.exit_points.first; n != 0; n = n->next) if(good_machine_code) for(DASM_CtrlFlowPointNode *n = ctrl_flow_info.exit_points.first; n != 0; n = n->next)
{ {
DASM_CtrlFlowPoint *point = &n->v; DASM_CtrlFlowPoint *point = &n->v;
CTRL_TrapFlags flags = 0; CTRL_TrapFlags flags = 0;
@@ -836,7 +840,7 @@ d_lines_array_from_dbgi_key_file_path_line_range(Arena *arena, DI_Key dbgi_key,
override_n = override_n->next) override_n = override_n->next)
{ {
String8 file_path = override_n->string; String8 file_path = override_n->string;
String8 file_path_normalized = lower_from_str8(scratch.arena, file_path); String8 file_path_normalized = lower_from_str8(scratch.arena, path_normalized_from_string(scratch.arena, file_path));
// rjf: binary -> rdi // rjf: binary -> rdi
RDI_Parsed *rdi = di_rdi_from_key(scope, &dbgi_key, 0); RDI_Parsed *rdi = di_rdi_from_key(scope, &dbgi_key, 0);
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef DBG_ENGINE_CORE_H #ifndef DBG_ENGINE_CORE_H
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#include "dbg_engine_core.c" #include "dbg_engine_core.c"
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef DBG_ENGINE_INC_H #ifndef DBG_ENGINE_INC_H
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//- GENERATED CODE //- GENERATED CODE
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//- GENERATED CODE //- GENERATED CODE
+4 -3
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#undef LAYER_COLOR #undef LAYER_COLOR
@@ -1026,15 +1026,16 @@ ASYNC_WORK_DEF(di_parse_work)
params.inherit_env = 1; params.inherit_env = 1;
params.consoleless = 1; params.consoleless = 1;
str8_list_pushf(scratch.arena, &params.cmd_line, "raddbg"); str8_list_pushf(scratch.arena, &params.cmd_line, "raddbg");
str8_list_pushf(scratch.arena, &params.cmd_line, "--convert"); str8_list_pushf(scratch.arena, &params.cmd_line, "--bin");
str8_list_pushf(scratch.arena, &params.cmd_line, "--quiet"); str8_list_pushf(scratch.arena, &params.cmd_line, "--quiet");
if(should_compress) if(should_compress)
{ {
str8_list_pushf(scratch.arena, &params.cmd_line, "--compress"); str8_list_pushf(scratch.arena, &params.cmd_line, "--compress");
} }
// str8_list_pushf(scratch.arena, &params.cmd_line, "--capture"); // str8_list_pushf(scratch.arena, &params.cmd_line, "--capture");
str8_list_pushf(scratch.arena, &params.cmd_line, "--pdb:%S", og_path); str8_list_pushf(scratch.arena, &params.cmd_line, "--rdi");
str8_list_pushf(scratch.arena, &params.cmd_line, "--out:%S", rdi_path); str8_list_pushf(scratch.arena, &params.cmd_line, "--out:%S", rdi_path);
str8_list_pushf(scratch.arena, &params.cmd_line, "%S", og_path);
process = os_process_launch(&params); process = os_process_launch(&params);
} }
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef DBGI_H #ifndef DBGI_H
+2 -8
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//////////////////////////////// ////////////////////////////////
@@ -158,31 +158,25 @@ dmn_rsp_from_thread(DMN_Handle thread)
} }
//////////////////////////////// ////////////////////////////////
//~ Memory Helpers //~ rjf: Process Reading Helper Functions (Helpers, Implemented Once)
internal String8 internal String8
dmn_process_read_cstring(Arena *arena, DMN_Handle process, U64 addr) dmn_process_read_cstring(Arena *arena, DMN_Handle process, U64 addr)
{ {
Temp scratch = scratch_begin(&arena, 1); Temp scratch = scratch_begin(&arena, 1);
String8List block_list = {0}; String8List block_list = {0};
for(U64 cursor = addr, stride = 256; ; cursor += stride) for(U64 cursor = addr, stride = 256; ; cursor += stride)
{ {
U8 *raw_block = push_array_no_zero(scratch.arena, U8, stride); U8 *raw_block = push_array_no_zero(scratch.arena, U8, stride);
U64 read_size = dmn_process_read(process, r1u64(cursor, cursor + stride), raw_block); U64 read_size = dmn_process_read(process, r1u64(cursor, cursor + stride), raw_block);
String8 block = str8_cstring_capped(raw_block, raw_block + read_size); String8 block = str8_cstring_capped(raw_block, raw_block + read_size);
str8_list_push(scratch.arena, &block_list, block); str8_list_push(scratch.arena, &block_list, block);
if(read_size != stride || (block.size+1 <= read_size && block.str[block.size] == 0)) if(read_size != stride || (block.size+1 <= read_size && block.str[block.size] == 0))
{ {
break; break;
} }
} }
String8 result = str8_list_join(arena, &block_list, 0); String8 result = str8_list_join(arena, &block_list, 0);
scratch_end(scratch); scratch_end(scratch);
return result; return result;
} }
+6 -2
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef DEMON_CORE_H #ifndef DEMON_CORE_H
@@ -190,6 +190,11 @@ internal DMN_Event *dmn_event_list_push(Arena *arena, DMN_EventList *list);
internal U64 dmn_rip_from_thread(DMN_Handle thread); internal U64 dmn_rip_from_thread(DMN_Handle thread);
internal U64 dmn_rsp_from_thread(DMN_Handle thread); internal U64 dmn_rsp_from_thread(DMN_Handle thread);
////////////////////////////////
//~ rjf: Process Reading Helper Functions (Helpers, Implemented Once)
internal String8 dmn_process_read_cstring(Arena *arena, DMN_Handle process, U64 addr);
//////////////////////////////// ////////////////////////////////
//~ rjf: @dmn_os_hooks Main Layer Initialization (Implemented Per-OS) //~ rjf: @dmn_os_hooks Main Layer Initialization (Implemented Per-OS)
@@ -236,7 +241,6 @@ internal U64 dmn_process_read(DMN_Handle process, Rng1U64 range, void *dst);
internal B32 dmn_process_write(DMN_Handle process, Rng1U64 range, void *src); internal B32 dmn_process_write(DMN_Handle process, Rng1U64 range, void *src);
#define dmn_process_read_struct(process, vaddr, ptr) dmn_process_read((process), r1u64((vaddr), (vaddr)+(sizeof(*ptr))), ptr) #define dmn_process_read_struct(process, vaddr, ptr) dmn_process_read((process), r1u64((vaddr), (vaddr)+(sizeof(*ptr))), ptr)
#define dmn_process_write_struct(process, vaddr, ptr) dmn_process_write((process), r1u64((vaddr), (vaddr)+(sizeof(*ptr))), ptr) #define dmn_process_write_struct(process, vaddr, ptr) dmn_process_write((process), r1u64((vaddr), (vaddr)+(sizeof(*ptr))), ptr)
internal String8 dmn_process_read_cstring(Arena *arena, DMN_Handle process, U64 addr);
//- rjf: threads //- rjf: threads
internal Arch dmn_arch_from_thread(DMN_Handle handle); internal Arch dmn_arch_from_thread(DMN_Handle handle);
+1
View File
@@ -24,6 +24,7 @@ DMN_EventKindTable:
{SetThreadColor} {SetThreadColor}
{SetBreakpoint} {SetBreakpoint}
{UnsetBreakpoint} {UnsetBreakpoint}
{SetVAddrRangeNote}
} }
@table(name) @table(name)
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#include "demon/demon_core.c" #include "demon/demon_core.c"
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef DEMON_INC_H #ifndef DEMON_INC_H
+3 -2
View File
@@ -1,10 +1,10 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//- GENERATED CODE //- GENERATED CODE
C_LINKAGE_BEGIN C_LINKAGE_BEGIN
String8 dmn_event_kind_string_table[20] = String8 dmn_event_kind_string_table[21] =
{ {
str8_lit_comp("Null"), str8_lit_comp("Null"),
str8_lit_comp("Error"), str8_lit_comp("Error"),
@@ -26,6 +26,7 @@ str8_lit_comp("SetThreadName"),
str8_lit_comp("SetThreadColor"), str8_lit_comp("SetThreadColor"),
str8_lit_comp("SetBreakpoint"), str8_lit_comp("SetBreakpoint"),
str8_lit_comp("UnsetBreakpoint"), str8_lit_comp("UnsetBreakpoint"),
str8_lit_comp("SetVAddrRangeNote"),
}; };
String8 dmn_exception_kind_string_table[5] = String8 dmn_exception_kind_string_table[5] =
+3 -2
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//- GENERATED CODE //- GENERATED CODE
@@ -28,6 +28,7 @@ DMN_EventKind_SetThreadName,
DMN_EventKind_SetThreadColor, DMN_EventKind_SetThreadColor,
DMN_EventKind_SetBreakpoint, DMN_EventKind_SetBreakpoint,
DMN_EventKind_UnsetBreakpoint, DMN_EventKind_UnsetBreakpoint,
DMN_EventKind_SetVAddrRangeNote,
DMN_EventKind_COUNT, DMN_EventKind_COUNT,
} DMN_EventKind; } DMN_EventKind;
@@ -61,7 +62,7 @@ DMN_ExceptionKind_COUNT,
} DMN_ExceptionKind; } DMN_ExceptionKind;
C_LINKAGE_BEGIN C_LINKAGE_BEGIN
extern String8 dmn_event_kind_string_table[20]; extern String8 dmn_event_kind_string_table[21];
extern String8 dmn_exception_kind_string_table[5]; extern String8 dmn_exception_kind_string_table[5];
C_LINKAGE_END C_LINKAGE_END
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//////////////////////////////// ////////////////////////////////
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef DEMON_CORE_LINUX_H #ifndef DEMON_CORE_LINUX_H
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
// TODO(allen): run controls: ignore_previous_exception // TODO(allen): run controls: ignore_previous_exception
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef DEMON_OS_LINUX_H #ifndef DEMON_OS_LINUX_H
+16 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//////////////////////////////// ////////////////////////////////
@@ -2560,6 +2560,21 @@ dmn_ctrl_run(Arena *arena, DMN_CtrlCtx *ctx, DMN_RunCtrls *ctrls)
if(exec) { e->flags |= DMN_TrapFlag_BreakOnExecute; } if(exec) { e->flags |= DMN_TrapFlag_BreakOnExecute; }
}break; }break;
//- rjf: fill set-vaddr-range-note info
case DMN_W32_EXCEPTION_RADDBG_SET_VADDR_RANGE_NOTE:
{
U64 vaddr = exception->ExceptionInformation[0];
U64 size = exception->ExceptionInformation[1];
U64 name_vaddr = exception->ExceptionInformation[2];
U64 name_size = exception->ExceptionInformation[3];
U8 *name_buffer = push_array(arena, U8, name_size);
dmn_w32_process_read(process->handle, r1u64(name_vaddr, name_vaddr+name_size), name_buffer),
e->kind = DMN_EventKind_SetVAddrRangeNote;
e->address = vaddr;
e->size = size;
e->string = str8(name_buffer, name_size);
}break;
//- rjf: unhandled exception case //- rjf: unhandled exception case
default: default:
{ {
+2 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef DEMON_CORE_WIN32_H #ifndef DEMON_CORE_WIN32_H
@@ -58,6 +58,7 @@
#define DMN_w32_EXCEPTION_CLR 0xE0434352u #define DMN_w32_EXCEPTION_CLR 0xE0434352u
#define DMN_W32_EXCEPTION_RADDBG_SET_THREAD_COLOR 0x00524144u #define DMN_W32_EXCEPTION_RADDBG_SET_THREAD_COLOR 0x00524144u
#define DMN_W32_EXCEPTION_RADDBG_SET_BREAKPOINT 0x00524145u #define DMN_W32_EXCEPTION_RADDBG_SET_BREAKPOINT 0x00524145u
#define DMN_W32_EXCEPTION_RADDBG_SET_VADDR_RANGE_NOTE 0x00524156u
//////////////////////////////// ////////////////////////////////
//~ rjf: Win32 Register Codes //~ rjf: Win32 Register Codes
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//////////////////////////////// ////////////////////////////////
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef DRAW_H #ifndef DRAW_H
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
@table(name, name_lower, type, default_init) @table(name, name_lower, type, default_init)
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//- GENERATED CODE //- GENERATED CODE
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//- GENERATED CODE //- GENERATED CODE
+25 -25
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
internal U64 internal U64
@@ -73,9 +73,9 @@ internal DW_AttribClass
dw_attrib_class_from_attrib_kind_v2(DW_AttribKind k) dw_attrib_class_from_attrib_kind_v2(DW_AttribKind k)
{ {
switch (k) { switch (k) {
#define X(_N,_C) case DW_Attrib_##_N: return _C; #define X(_N,_C) case DW_Attrib_##_N: return _C;
DW_AttribKind_ClassFlags_V2_XList(X) DW_AttribKind_ClassFlags_V2_XList(X)
#undef X #undef X
} }
return DW_AttribClass_Null; return DW_AttribClass_Null;
} }
@@ -84,9 +84,9 @@ internal DW_AttribClass
dw_attrib_class_from_attrib_kind_v3(DW_AttribKind k) dw_attrib_class_from_attrib_kind_v3(DW_AttribKind k)
{ {
switch (k) { switch (k) {
#define X(_N,_C) case DW_Attrib_##_N: return _C; #define X(_N,_C) case DW_Attrib_##_N: return _C;
DW_AttribKind_ClassFlags_V3_XList(X) DW_AttribKind_ClassFlags_V3_XList(X)
#undef X #undef X
} }
return DW_AttribClass_Null; return DW_AttribClass_Null;
} }
@@ -95,9 +95,9 @@ internal DW_AttribClass
dw_attrib_class_from_attrib_kind_v4(DW_AttribKind k) dw_attrib_class_from_attrib_kind_v4(DW_AttribKind k)
{ {
switch (k) { switch (k) {
#define X(_N,_C) case DW_Attrib_##_N: return _C; #define X(_N,_C) case DW_Attrib_##_N: return _C;
DW_AttribKind_ClassFlags_V4_XList(X) DW_AttribKind_ClassFlags_V4_XList(X)
#undef X #undef X
} }
return DW_AttribClass_Null; return DW_AttribClass_Null;
} }
@@ -106,9 +106,9 @@ internal DW_AttribClass
dw_attrib_class_from_attrib_kind_v5(DW_AttribKind k) dw_attrib_class_from_attrib_kind_v5(DW_AttribKind k)
{ {
switch (k) { switch (k) {
#define X(_N,_C) case DW_Attrib_##_N: return _C; #define X(_N,_C) case DW_Attrib_##_N: return _C;
DW_AttribKind_ClassFlags_V5_XList(X) DW_AttribKind_ClassFlags_V5_XList(X)
#undef X #undef X
} }
return DW_AttribClass_Null; return DW_AttribClass_Null;
} }
@@ -117,9 +117,9 @@ internal DW_AttribClass
dw_attrib_class_from_attrib_kind_gnu(DW_AttribKind k) dw_attrib_class_from_attrib_kind_gnu(DW_AttribKind k)
{ {
switch (k) { switch (k) {
#define X(_N,_C) case DW_Attrib_##_N: return _C; #define X(_N,_C) case DW_Attrib_##_N: return _C;
DW_AttribKind_ClassFlags_GNU_XList(X) DW_AttribKind_ClassFlags_GNU_XList(X)
#undef X #undef X
} }
return DW_AttribClass_Null; return DW_AttribClass_Null;
} }
@@ -128,9 +128,9 @@ internal DW_AttribClass
dw_attrib_class_from_attrib_kind_llvm(DW_AttribKind k) dw_attrib_class_from_attrib_kind_llvm(DW_AttribKind k)
{ {
switch (k) { switch (k) {
#define X(_N,_C) case DW_Attrib_##_N: return _C; #define X(_N,_C) case DW_Attrib_##_N: return _C;
DW_AttribKind_ClassFlags_LLVM_XList(X) DW_AttribKind_ClassFlags_LLVM_XList(X)
#undef X #undef X
} }
return DW_AttribClass_Null; return DW_AttribClass_Null;
} }
@@ -139,9 +139,9 @@ internal DW_AttribClass
dw_attrib_class_from_attrib_kind_apple(DW_AttribKind k) dw_attrib_class_from_attrib_kind_apple(DW_AttribKind k)
{ {
switch (k) { switch (k) {
#define X(_N,_C) case DW_Attrib_##_N: return _C; #define X(_N,_C) case DW_Attrib_##_N: return _C;
DW_AttribKind_ClassFlags_APPLE_XList(X) DW_AttribKind_ClassFlags_APPLE_XList(X)
#undef X #undef X
} }
return DW_AttribClass_Null; return DW_AttribClass_Null;
} }
@@ -150,9 +150,9 @@ internal DW_AttribClass
dw_attrib_class_from_attrib_kind_mips(DW_AttribKind k) dw_attrib_class_from_attrib_kind_mips(DW_AttribKind k)
{ {
switch (k) { switch (k) {
#define X(_N,_C) case DW_Attrib_##_N: return _C; #define X(_N,_C) case DW_Attrib_##_N: return _C;
DW_AttribKind_ClassFlags_MIPS_XList(X) DW_AttribKind_ClassFlags_MIPS_XList(X)
#undef X #undef X
} }
return DW_AttribClass_Null; return DW_AttribClass_Null;
} }
@@ -202,7 +202,7 @@ dw_attrib_class_from_attrib_kind(DW_Version ver, DW_Ext ext, DW_AttribKind k)
internal DW_AttribClass internal DW_AttribClass
dw_attrib_class_from_form_kind(DW_Version ver, DW_FormKind k) dw_attrib_class_from_form_kind(DW_Version ver, DW_FormKind k)
{ {
#define X(_N,_C) case DW_Form_##_N: return _C; #define X(_N,_C) case DW_Form_##_N: return _C;
switch (k) { switch (k) {
DW_Form_AttribClass_GNU_XList(X) DW_Form_AttribClass_GNU_XList(X)
@@ -233,7 +233,7 @@ dw_attrib_class_from_form_kind(DW_Version ver, DW_FormKind k)
} break; } break;
case DW_Version_Null: break; case DW_Version_Null: break;
} }
#undef X #undef X
return DW_AttribClass_Null; return DW_AttribClass_Null;
} }
@@ -250,9 +250,9 @@ internal String8
dw_name_string_from_section_kind(DW_SectionKind k) dw_name_string_from_section_kind(DW_SectionKind k)
{ {
switch (k) { switch (k) {
#define X(_N,_L,_M,_D) case DW_Section_##_N: return str8_lit(_L); #define X(_N,_L,_M,_D) case DW_Section_##_N: return str8_lit(_L);
DW_SectionKind_XList(X) DW_SectionKind_XList(X)
#undef X #undef X
} }
return str8_zero(); return str8_zero();
} }
@@ -261,9 +261,9 @@ internal String8
dw_mach_name_string_from_section_kind(DW_SectionKind k) dw_mach_name_string_from_section_kind(DW_SectionKind k)
{ {
switch (k) { switch (k) {
#define X(_N,_L,_M,_D) case DW_Section_##_N: return str8_lit(_M); #define X(_N,_L,_M,_D) case DW_Section_##_N: return str8_lit(_M);
DW_SectionKind_XList(X) DW_SectionKind_XList(X)
#undef X #undef X
} }
return str8_zero(); return str8_zero();
} }
@@ -272,9 +272,9 @@ internal String8
dw_dwo_name_string_from_section_kind(DW_SectionKind k) dw_dwo_name_string_from_section_kind(DW_SectionKind k)
{ {
switch (k) { switch (k) {
#define X(_N,_L,_M,_D) case DW_Section_##_N: return str8_lit(_D); #define X(_N,_L,_M,_D) case DW_Section_##_N: return str8_lit(_D);
DW_SectionKind_XList(X) DW_SectionKind_XList(X)
#undef X #undef X
} }
return str8_zero(); return str8_zero();
} }
+1333 -1333
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
internal B32 internal B32
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef DWARF_COFF_H #ifndef DWARF_COFF_H
+3
View File
@@ -33,6 +33,9 @@ dw_is_dwarf_present_elf_section_table(String8 raw_image, ELF_BinInfo *bin)
return is_dwarf_present; return is_dwarf_present;
} }
#define SINFL_IMPLEMENTATION
#include "third_party/sinfl/sinfl.h"
internal DW_Input internal DW_Input
dw_input_from_elf_section_table(Arena *arena, String8 raw_image, ELF_BinInfo *bin) dw_input_from_elf_section_table(Arena *arena, String8 raw_image, ELF_BinInfo *bin)
{ {
+20 -20
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
internal String8 internal String8
@@ -6,7 +6,7 @@ dw_string_from_expr_op(Arena *arena, DW_Version ver, DW_Ext ext, DW_ExprOp op)
{ {
String8 result = {0}; String8 result = {0};
#define X(_N,...) case DW_ExprOp_##_N: result = str8_lit(Stringify(_N)); goto exit; #define X(_N,...) case DW_ExprOp_##_N: result = str8_lit(Stringify(_N)); goto exit;
if (ext & DW_Ext_GNU) { if (ext & DW_Ext_GNU) {
switch (op) { switch (op) {
DW_Expr_GNU_XList(X); DW_Expr_GNU_XList(X);
@@ -34,11 +34,11 @@ dw_string_from_expr_op(Arena *arena, DW_Version ver, DW_Ext ext, DW_ExprOp op)
case DW_Version_Null: case DW_Version_Null:
break; break;
} }
#undef X #undef X
result = push_str8f(arena, "%x", op); result = push_str8f(arena, "%x", op);
exit:; exit:;
return result; return result;
} }
@@ -47,11 +47,11 @@ dw_string_from_tag_kind(Arena *arena, DW_TagKind kind)
{ {
switch (kind) { switch (kind) {
case DW_Tag_Null: return str8_lit("Null"); case DW_Tag_Null: return str8_lit("Null");
#define X(_N,_ID) case DW_Tag_##_N: return str8_lit(Stringify(_N)); #define X(_N,_ID) case DW_Tag_##_N: return str8_lit(Stringify(_N));
DW_Tag_V3_XList(X) DW_Tag_V3_XList(X)
DW_Tag_V5_XList(X) DW_Tag_V5_XList(X)
DW_Tag_GNU_XList(X) DW_Tag_GNU_XList(X)
#undef X #undef X
} }
return push_str8f(arena, "%llx", kind); return push_str8f(arena, "%llx", kind);
} }
@@ -59,7 +59,7 @@ dw_string_from_tag_kind(Arena *arena, DW_TagKind kind)
internal String8 internal String8
dw_string_from_attrib_kind(Arena *arena, DW_Version ver, DW_Ext ext, DW_AttribKind kind) dw_string_from_attrib_kind(Arena *arena, DW_Version ver, DW_Ext ext, DW_AttribKind kind)
{ {
#define X(_N,...) case DW_Attrib_##_N: return str8_lit(Stringify(_N)); #define X(_N,...) case DW_Attrib_##_N: return str8_lit(Stringify(_N));
while (ext) { while (ext) {
U64 z = 64-clz64(ext); U64 z = 64-clz64(ext);
@@ -104,7 +104,7 @@ dw_string_from_attrib_kind(Arena *arena, DW_Version ver, DW_Ext ext, DW_AttribKi
} // fall-through } // fall-through
case DW_Version_Null: break; case DW_Version_Null: break;
} }
#undef X #undef X
return str8_zero(); return str8_zero();
} }
@@ -112,7 +112,7 @@ dw_string_from_attrib_kind(Arena *arena, DW_Version ver, DW_Ext ext, DW_AttribKi
internal String8 internal String8
dw_string_from_form_kind(Arena *arena, DW_Version ver, DW_FormKind kind) dw_string_from_form_kind(Arena *arena, DW_Version ver, DW_FormKind kind)
{ {
#define X(_N,...) case DW_Form_##_N: return str8_lit(Stringify(_N)); #define X(_N,...) case DW_Form_##_N: return str8_lit(Stringify(_N));
switch (ver) { switch (ver) {
case DW_Version_5: { case DW_Version_5: {
switch (kind) { switch (kind) {
@@ -132,7 +132,7 @@ dw_string_from_form_kind(Arena *arena, DW_Version ver, DW_FormKind kind)
} // fall-through } // fall-through
case DW_Version_Null: break; case DW_Version_Null: break;
} }
#undef X #undef X
String8 result = push_str8f(arena, "%x", kind); String8 result = push_str8f(arena, "%x", kind);
return result; return result;
} }
@@ -141,9 +141,9 @@ internal String8
dw_string_from_language(Arena *arena, DW_Language kind) dw_string_from_language(Arena *arena, DW_Language kind)
{ {
switch (kind) { switch (kind) {
#define X(_N,_ID) case DW_Language_##_N: return str8_lit(Stringify(_N)); #define X(_N,_ID) case DW_Language_##_N: return str8_lit(Stringify(_N));
DW_Language_XList(X) DW_Language_XList(X)
#undef X #undef X
} }
return push_str8f(arena, "%x", kind); return push_str8f(arena, "%x", kind);
} }
@@ -196,9 +196,9 @@ internal String8
dw_string_from_std_opcode(Arena *arena, DW_StdOpcode kind) dw_string_from_std_opcode(Arena *arena, DW_StdOpcode kind)
{ {
switch (kind) { switch (kind) {
#define X(_N,_ID) case DW_StdOpcode_##_N: return str8_lit(Stringify(_N)); #define X(_N,_ID) case DW_StdOpcode_##_N: return str8_lit(Stringify(_N));
DW_StdOpcode_XList(X) DW_StdOpcode_XList(X)
#undef X #undef X
} }
return push_str8f(arena, "%x", kind); return push_str8f(arena, "%x", kind);
} }
@@ -207,9 +207,9 @@ internal String8
dw_string_from_ext_opcode(Arena *arena, DW_ExtOpcode kind) dw_string_from_ext_opcode(Arena *arena, DW_ExtOpcode kind)
{ {
switch (kind) { switch (kind) {
#define X(_N,_ID) case DW_ExtOpcode_##_N: return str8_lit(Stringify(_N)); #define X(_N,_ID) case DW_ExtOpcode_##_N: return str8_lit(Stringify(_N));
DW_ExtOpcode_XList(X) DW_ExtOpcode_XList(X)
#undef X #undef X
default: InvalidPath; break; default: InvalidPath; break;
} }
return push_str8f(arena, "%x", kind); return push_str8f(arena, "%x", kind);
@@ -244,16 +244,16 @@ dw_string_from_register(Arena *arena, Arch arch, U64 reg_id)
case Arch_Null: break; case Arch_Null: break;
case Arch_x86: { case Arch_x86: {
switch (reg_id) { switch (reg_id) {
#define X(_N, _ID, ...) case DW_RegX86_##_N: reg_str = str8_lit(Stringify(_N)); break; #define X(_N, _ID, ...) case DW_RegX86_##_N: reg_str = str8_lit(Stringify(_N)); break;
DW_Regs_X86_XList(X) DW_Regs_X86_XList(X)
#undef X #undef X
} }
} break; } break;
case Arch_x64: { case Arch_x64: {
switch (reg_id) { switch (reg_id) {
#define X(_N, _ID, ...) case DW_RegX64_##_N: reg_str = str8_lit(Stringify(_N)); break; #define X(_N, _ID, ...) case DW_RegX64_##_N: reg_str = str8_lit(Stringify(_N)); break;
DW_Regs_X64_XList(X) DW_Regs_X64_XList(X)
#undef X #undef X
} }
} break; } break;
case Arch_arm32: NotImplemented; break; case Arch_arm32: NotImplemented; break;
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef DWARF_ENUM_H #ifndef DWARF_ENUM_H
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//- analyzers //- analyzers
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef DWARF_EXPR_H #ifndef DWARF_EXPR_H
+5 -5
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
internal U64 internal U64
@@ -174,8 +174,8 @@ dw_section_kind_from_string(String8 string)
{ {
DW_SectionKind s = DW_Section_Null; DW_SectionKind s = DW_Section_Null;
#define X(_K,_L,_M,_W) \ #define X(_K,_L,_M,_W) \
if (str8_match_lit(_L, string, 0)) { s = DW_Section_##_K; } \ if (str8_match_lit(_L, string, 0)) { s = DW_Section_##_K; } \
if (str8_match_lit(_M, string, 0)) { s = DW_Section_##_K; } if (str8_match_lit(_M, string, 0)) { s = DW_Section_##_K; }
DW_SectionKind_XList(X) DW_SectionKind_XList(X)
#undef X #undef X
return s; return s;
@@ -186,7 +186,7 @@ dw_section_dwo_kind_from_string(String8 string)
{ {
DW_SectionKind s = DW_Section_Null; DW_SectionKind s = DW_Section_Null;
#define X(_K,_L,_M,_W) \ #define X(_K,_L,_M,_W) \
if (str8_match_lit(_W, string, 0)) { s = DW_Section_##_K; } if (str8_match_lit(_W, string, 0)) { s = DW_Section_##_K; }
DW_SectionKind_XList(X) DW_SectionKind_XList(X)
#undef X #undef X
return s; return s;
@@ -2727,7 +2727,7 @@ dw_read_line_vm_header(Arena *arena,
bytes_read = unit_cursor; bytes_read = unit_cursor;
exit:; exit:;
scratch_end(scratch); scratch_end(scratch);
return bytes_read; return bytes_read;
} }
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef DWARF_PARSE_H #ifndef DWARF_PARSE_H
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
internal U64 dw_based_range_read(void *base, Rng1U64 range, U64 off, U64 size, void *out) { return 0; } internal U64 dw_based_range_read(void *base, Rng1U64 range, U64 off, U64 size, void *out) { return 0; }
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef DWARF_UNWIND_H #ifndef DWARF_UNWIND_H
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
@table(name) @table(name)
+167 -55
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//////////////////////////////// ////////////////////////////////
@@ -189,6 +189,13 @@ e_space_make(E_SpaceKind kind)
return space; return space;
} }
internal B32
e_space_match(E_Space a, E_Space b)
{
B32 result = MemoryMatchStruct(&a, &b);
return result;
}
//////////////////////////////// ////////////////////////////////
//~ rjf: Map Functions //~ rjf: Map Functions
@@ -445,22 +452,61 @@ e_auto_hook_map_insert_new_(Arena *arena, E_AutoHookMap *map, E_AutoHookParams *
type_key = e_type_key_from_expr(parse.expr); type_key = e_type_key_from_expr(parse.expr);
} }
// rjf: get type pattern parts // rjf: extract type pattern
String8List pattern_parts = {0}; E_Pattern pattern = {0};
if(e_type_key_match(e_type_key_zero(), type_key)) if(e_type_key_match(e_type_key_zero(), type_key))
{ {
U8 pattern_split = '?'; U64 start_string_off = 0;
pattern_parts = str8_split(arena, params->type_pattern, &pattern_split, 1, StringSplitFlag_KeepEmpties); for(U64 off = 0; off <= params->type_pattern.size; off += 1)
{
U8 byte = (off < params->type_pattern.size ? params->type_pattern.str[off] : 0);
if(byte == 0 || byte == '?')
{
String8 new_part = str8_substr(params->type_pattern, r1u64(start_string_off, off));
if(new_part.size != 0)
{
E_PatternPart *p = push_array(arena, E_PatternPart, 1);
SLLQueuePush(pattern.first_part, pattern.last_part, p);
p->string = new_part;
pattern.count += 1;
}
}
if(byte == '?')
{
E_PatternPart *p = push_array(arena, E_PatternPart, 1);
SLLQueuePush(pattern.first_part, pattern.last_part, p);
pattern.count += 1;
if(off+1 < params->type_pattern.size && params->type_pattern.str[off+1] == '{')
{
off += 2;
String8 wildcard_inst_names_string = str8_skip(params->type_pattern, off);
wildcard_inst_names_string = str8_prefix(wildcard_inst_names_string, str8_find_needle(wildcard_inst_names_string, 0, str8_lit("}"), 0));
if(wildcard_inst_names_string.size != 0)
{
Temp scratch = scratch_begin(&arena, 1);
U8 wildcard_inst_name_split_char = ',';
String8List wildcard_inst_names = str8_split(scratch.arena, wildcard_inst_names_string, &wildcard_inst_name_split_char, 1, 0);
for(String8Node *n = wildcard_inst_names.first; n != 0; n = n->next)
{
str8_list_push(arena, &p->wildcard_inst_names, str8_skip_chop_whitespace(n->string));
}
scratch_end(scratch);
off += wildcard_inst_names_string.size;
}
}
start_string_off = off+1;
}
}
} }
// rjf: if the type key is nonzero, *or* we have type patterns, then insert // rjf: if the type key is nonzero, *or* we have type patterns, then insert
// into map accordingle // into map accordingly
if(!e_type_key_match(e_type_key_zero(), type_key) || if(!e_type_key_match(e_type_key_zero(), type_key) ||
pattern_parts.node_count != 0) pattern.count != 0)
{ {
E_AutoHookNode *node = push_array(arena, E_AutoHookNode, 1); E_AutoHookNode *node = push_array(arena, E_AutoHookNode, 1);
node->type_string = str8_skip_chop_whitespace(e_type_string_from_key(arena, type_key)); node->type_string = str8_skip_chop_whitespace(e_type_string_from_key(arena, type_key));
node->type_pattern_parts = pattern_parts; node->type_pattern = pattern;
node->expr_string = push_str8_copy(arena, params->tag_expr_string); node->expr_string = push_str8_copy(arena, params->tag_expr_string);
if(!e_type_key_match(e_type_key_zero(), type_key)) if(!e_type_key_match(e_type_key_zero(), type_key))
{ {
@@ -1037,18 +1083,20 @@ e_value_eval_from_eval(E_Eval eval)
//- rjf: type key -> auto hooks //- rjf: type key -> auto hooks
internal E_ExprList internal E_AutoHookMatchList
e_auto_hook_exprs_from_type_key(Arena *arena, E_TypeKey type_key) e_push_auto_hook_matches_from_type_key(Arena *arena, E_TypeKey type_key)
{ {
ProfBeginFunction(); ProfBeginFunction();
E_ExprList exprs = {0}; E_AutoHookMatchList matches = {0};
if(e_ir_ctx != 0) if(e_ir_ctx != 0)
{ {
Temp scratch = scratch_begin(&arena, 1); Temp scratch = scratch_begin(&arena, 1);
E_AutoHookMap *map = e_ir_ctx->auto_hook_map; E_AutoHookMap *map = e_ir_ctx->auto_hook_map;
String8 type_string = str8_skip_chop_whitespace(e_type_string_from_key(scratch.arena, type_key)); String8 type_string = str8_skip_chop_whitespace(e_type_string_from_key(scratch.arena, type_key));
////////////////////////////
//- rjf: gather exact-type-key-matches from the map //- rjf: gather exact-type-key-matches from the map
//
if(map != 0 && map->slots_count != 0) if(map != 0 && map->slots_count != 0)
{ {
U64 hash = e_hash_from_string(5381, type_string); U64 hash = e_hash_from_string(5381, type_string);
@@ -1057,44 +1105,132 @@ e_auto_hook_exprs_from_type_key(Arena *arena, E_TypeKey type_key)
{ {
if(str8_match(n->type_string, type_string, 0)) if(str8_match(n->type_string, type_string, 0))
{ {
E_Expr *expr = e_parse_from_string(n->expr_string).expr; E_AutoHookMatch *match = push_array(arena, E_AutoHookMatch, 1);
e_expr_list_push(arena, &exprs, expr); SLLQueuePush(matches.first, matches.last, match);
match->expr = e_parse_from_string(n->expr_string).expr;
matches.count += 1;
} }
} }
} }
////////////////////////////
//- rjf: gather fuzzy matches from all patterns in the map //- rjf: gather fuzzy matches from all patterns in the map
//
if(map != 0 && map->first_pattern != 0) if(map != 0 && map->first_pattern != 0)
{ {
for(E_AutoHookNode *auto_hook_node = map->first_pattern; for(E_AutoHookNode *auto_hook_node = map->first_pattern;
auto_hook_node != 0; auto_hook_node != 0;
auto_hook_node = auto_hook_node->pattern_order_next) auto_hook_node = auto_hook_node->pattern_order_next)
{ {
////////////////////////
//- rjf: determine if this pattern fits this type's string; gather wildcard instances
//
E_AutoHookWildcardInst *first_wildcard_inst = 0;
E_AutoHookWildcardInst *last_wildcard_inst = 0;
B32 fits_this_type_string = 1; B32 fits_this_type_string = 1;
{
U64 scan_pos = 0; U64 scan_pos = 0;
for(String8Node *n = auto_hook_node->type_pattern_parts.first; n != 0; n = n->next) for(E_PatternPart *part = auto_hook_node->type_pattern.first_part; part != 0 && fits_this_type_string; part = part->next)
{ {
if(n->string.size == 0) String8 pattern_string = part->string;
//- rjf: skip whitespace
for(;scan_pos < type_string.size;)
{ {
continue; if(char_is_space(type_string.str[scan_pos]))
{
scan_pos += 1;
} }
U64 pattern_part_pos = str8_find_needle(type_string, scan_pos, n->string, 0); else
if(pattern_part_pos > scan_pos && n == auto_hook_node->type_pattern_parts.first)
{ {
fits_this_type_string = 0;
break; break;
} }
if(pattern_part_pos >= type_string.size) }
//- rjf: no pattern string -> wildcard. skip wildcard portion
if(pattern_string.size == 0)
{
String8 terminator_pattern_string = part->next ? part->next->string : str8_zero();
U64 brace_nest_depth = 0;
U64 paren_nest_depth = 0;
U64 angle_nest_depth = 0;
U64 brack_nest_depth = 0;
U64 start_inst_off = scan_pos;
String8Node *wildcard_inst_name_node = part->wildcard_inst_names.first;
for(B32 done = 0; !done && scan_pos < type_string.size; scan_pos += 1)
{
if(0){}
else if(type_string.str[scan_pos] == '{') { brace_nest_depth += 1; }
else if(type_string.str[scan_pos] == '(') { paren_nest_depth += 1; }
else if(type_string.str[scan_pos] == '<') { angle_nest_depth += 1; }
else if(type_string.str[scan_pos] == '[') { brack_nest_depth += 1; }
else if(type_string.str[scan_pos] == '}' && brace_nest_depth > 0) { brace_nest_depth -= 1; }
else if(type_string.str[scan_pos] == ')' && paren_nest_depth > 0) { paren_nest_depth -= 1; }
else if(type_string.str[scan_pos] == '>' && angle_nest_depth > 0) { angle_nest_depth -= 1; }
else if(type_string.str[scan_pos] == ']' && brack_nest_depth > 0) { brack_nest_depth -= 1; }
else if(part->next == 0)
{
done = 1;
scan_pos = type_string.size;
}
else if(str8_match(terminator_pattern_string, str8_skip(type_string, scan_pos), StringMatchFlag_RightSideSloppy))
{
done = 1;
}
if((type_string.str[scan_pos] == ',' || done) &&
brace_nest_depth == 0 &&
paren_nest_depth == 0 &&
angle_nest_depth == 0 &&
brack_nest_depth == 0)
{
String8 wildcard_inst_string = str8_skip_chop_whitespace(str8_substr(type_string, r1u64(start_inst_off, scan_pos)));
start_inst_off = scan_pos+1;
E_AutoHookWildcardInst *inst = push_array(arena, E_AutoHookWildcardInst, 1);
SLLQueuePush(first_wildcard_inst, last_wildcard_inst, inst);
inst->name = wildcard_inst_name_node ? wildcard_inst_name_node->string : str8_zero();
inst->inst_expr = e_parse_from_string(wildcard_inst_string).expr;
if(wildcard_inst_name_node)
{
wildcard_inst_name_node = wildcard_inst_name_node->next;
}
}
if(done)
{ {
fits_this_type_string = 0;
break; break;
} }
scan_pos = pattern_part_pos + n->string.size;
} }
}
//- rjf: pattern string -> find next occurrence.
else if(pattern_string.size != 0)
{
if(!str8_match(str8_substr(type_string, r1u64(scan_pos, scan_pos+pattern_string.size)), pattern_string, 0))
{
fits_this_type_string = 0;
}
else
{
scan_pos += pattern_string.size;
}
}
}
if(fits_this_type_string && scan_pos < type_string.size)
{
fits_this_type_string = 0;
}
}
////////////////////////
//- rjf: push match if this type fits
//
if(fits_this_type_string) if(fits_this_type_string)
{ {
E_Expr *expr = e_parse_from_string(auto_hook_node->expr_string).expr; E_AutoHookMatch *match = push_array(arena, E_AutoHookMatch, 1);
e_expr_list_push(arena, &exprs, expr); SLLQueuePush(matches.first, matches.last, match);
match->expr = e_parse_from_string(auto_hook_node->expr_string).expr;
match->first_wildcard_inst = first_wildcard_inst;
match->last_wildcard_inst = last_wildcard_inst;
matches.count += 1;
} }
} }
} }
@@ -1102,13 +1238,13 @@ e_auto_hook_exprs_from_type_key(Arena *arena, E_TypeKey type_key)
scratch_end(scratch); scratch_end(scratch);
} }
ProfEnd(); ProfEnd();
return exprs; return matches;
} }
internal E_ExprList internal E_AutoHookMatchList
e_auto_hook_exprs_from_type_key__cached(E_TypeKey type_key) e_auto_hook_matches_from_type_key(E_TypeKey type_key)
{ {
E_ExprList exprs = {0}; E_AutoHookMatchList matches = {0};
{ {
U64 hash = e_hash_from_string(5381, str8_struct(&type_key)); U64 hash = e_hash_from_string(5381, str8_struct(&type_key));
U64 slot_idx = hash%e_cache->type_auto_hook_cache_map->slots_count; U64 slot_idx = hash%e_cache->type_auto_hook_cache_map->slots_count;
@@ -1127,11 +1263,11 @@ e_auto_hook_exprs_from_type_key__cached(E_TypeKey type_key)
node = push_array(e_cache->arena, E_TypeAutoHookCacheNode, 1); node = push_array(e_cache->arena, E_TypeAutoHookCacheNode, 1);
SLLQueuePush(e_cache->type_auto_hook_cache_map->slots[slot_idx].first, e_cache->type_auto_hook_cache_map->slots[slot_idx].last, node); SLLQueuePush(e_cache->type_auto_hook_cache_map->slots[slot_idx].first, e_cache->type_auto_hook_cache_map->slots[slot_idx].last, node);
node->key = type_key; node->key = type_key;
node->exprs = e_auto_hook_exprs_from_type_key(e_cache->arena, type_key); node->matches = e_push_auto_hook_matches_from_type_key(e_cache->arena, type_key);
} }
exprs = node->exprs; matches = node->matches;
} }
return exprs; return matches;
} }
//- rjf: string IDs //- rjf: string IDs
@@ -1233,30 +1369,6 @@ e_range_size_from_eval(E_Eval eval)
E_TypeKind type_core_kind = e_type_kind_from_key(type_core); E_TypeKind type_core_kind = e_type_kind_from_key(type_core);
B32 got_size = 0; B32 got_size = 0;
// rjf: try getting size from expansions
if(!got_size)
{
E_TypeKey maybe_lens_type_key = e_type_key_unwrap(eval.irtree.type_key, E_TypeUnwrapFlag_Meta);
E_TypeKind maybe_lens_type_kind = e_type_kind_from_key(maybe_lens_type_key);
if(maybe_lens_type_kind == E_TypeKind_Lens)
{
E_TypeExpandRule *expand_rule = e_expand_rule_from_type_key(maybe_lens_type_key);
if(expand_rule->info != 0)
{
Temp scratch = scratch_begin(0, 0);
U64 element_size = e_type_byte_size_from_key(e_type_key_unwrap(type_core, E_TypeUnwrapFlag_All));
E_TypeExpandInfo expand_info = expand_rule->info(scratch.arena, eval, str8_zero());
U64 new_result_maybe = expand_info.expr_count * element_size;
if(new_result_maybe != 0)
{
result = new_result_maybe;
got_size = 1;
}
scratch_end(scratch);
}
}
}
// rjf: try getting size from intrinsic type (e.g. arrays/etc.) // rjf: try getting size from intrinsic type (e.g. arrays/etc.)
if(!got_size) if(!got_size)
{ {
+49 -5
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef EVAL_CORE_H #ifndef EVAL_CORE_H
@@ -663,13 +663,54 @@ struct E_String2TypeKeyMap
//////////////////////////////// ////////////////////////////////
//~ rjf: Type Pattern -> Hook Key Data Structure (Type Views) //~ rjf: Type Pattern -> Hook Key Data Structure (Type Views)
typedef struct E_PatternPart E_PatternPart;
struct E_PatternPart
{
E_PatternPart *next;
String8 string;
String8List wildcard_inst_names;
};
typedef struct E_Pattern E_Pattern;
struct E_Pattern
{
E_PatternPart *first_part;
E_PatternPart *last_part;
U64 count;
};
typedef struct E_AutoHookWildcardInst E_AutoHookWildcardInst;
struct E_AutoHookWildcardInst
{
E_AutoHookWildcardInst *next;
String8 name;
E_Expr *inst_expr;
};
typedef struct E_AutoHookMatch E_AutoHookMatch;
struct E_AutoHookMatch
{
E_AutoHookMatch *next;
E_Expr *expr;
E_AutoHookWildcardInst *first_wildcard_inst;
E_AutoHookWildcardInst *last_wildcard_inst;
};
typedef struct E_AutoHookMatchList E_AutoHookMatchList;
struct E_AutoHookMatchList
{
E_AutoHookMatch *first;
E_AutoHookMatch *last;
U64 count;
};
typedef struct E_AutoHookNode E_AutoHookNode; typedef struct E_AutoHookNode E_AutoHookNode;
struct E_AutoHookNode struct E_AutoHookNode
{ {
E_AutoHookNode *hash_next; E_AutoHookNode *hash_next;
E_AutoHookNode *pattern_order_next; E_AutoHookNode *pattern_order_next;
String8 type_string; String8 type_string;
String8List type_pattern_parts; E_Pattern type_pattern;
String8 expr_string; String8 expr_string;
}; };
@@ -890,7 +931,7 @@ struct E_TypeAutoHookCacheNode
{ {
E_TypeAutoHookCacheNode *next; E_TypeAutoHookCacheNode *next;
E_TypeKey key; E_TypeKey key;
E_ExprList exprs; E_AutoHookMatchList matches;
}; };
typedef struct E_TypeAutoHookCacheSlot E_TypeAutoHookCacheSlot; typedef struct E_TypeAutoHookCacheSlot E_TypeAutoHookCacheSlot;
@@ -1042,6 +1083,8 @@ struct E_Cache
//- rjf: [ir] ir gen options //- rjf: [ir] ir gen options
B32 disallow_autohooks; B32 disallow_autohooks;
B32 disallow_chained_fastpaths; B32 disallow_chained_fastpaths;
E_AutoHookWildcardInst *first_wildcard_inst;
E_AutoHookWildcardInst *last_wildcard_inst;
//- rjf: [ir] ir caches //- rjf: [ir] ir caches
E_UsedExprMap *used_expr_map; E_UsedExprMap *used_expr_map;
@@ -1108,6 +1151,7 @@ internal E_MsgList e_msg_list_copy(Arena *arena, E_MsgList *src);
//~ rjf: Space Functions //~ rjf: Space Functions
internal E_Space e_space_make(E_SpaceKind kind); internal E_Space e_space_make(E_SpaceKind kind);
internal B32 e_space_match(E_Space a, E_Space b);
//////////////////////////////// ////////////////////////////////
//~ rjf: Map Functions //~ rjf: Map Functions
@@ -1227,8 +1271,8 @@ internal E_Eval e_value_eval_from_eval(E_Eval eval);
#define e_value_from_expr(expr) e_value_eval_from_eval(e_eval_from_expr(expr)).value #define e_value_from_expr(expr) e_value_eval_from_eval(e_eval_from_expr(expr)).value
//- rjf: type key -> auto hooks //- rjf: type key -> auto hooks
internal E_ExprList e_auto_hook_exprs_from_type_key(Arena *arena, E_TypeKey type_key); internal E_AutoHookMatchList e_push_auto_hook_matches_from_type_key(Arena *arena, E_TypeKey type_key);
internal E_ExprList e_auto_hook_exprs_from_type_key__cached(E_TypeKey type_key); internal E_AutoHookMatchList e_auto_hook_matches_from_type_key(E_TypeKey type_key);
//- rjf: string IDs //- rjf: string IDs
internal U64 e_id_from_string(String8 string); internal U64 e_id_from_string(String8 string);
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#include "eval/eval_core.c" #include "eval/eval_core.c"
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef EVAL_INC_H #ifndef EVAL_INC_H
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
//////////////////////////////// ////////////////////////////////
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef EVAL_INTERPRET_H #ifndef EVAL_INTERPRET_H

Some files were not shown because too many files have changed in this diff Show More