mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-13 07:32:23 -07:00
move rdi_dump over to dbgi layer
This commit is contained in:
+2
-2
@@ -203,7 +203,7 @@ di_string_bucket_idx_from_string_size(U64 size)
|
||||
case 1<<8: {bucket_idx = 4;}break;
|
||||
case 1<<9: {bucket_idx = 5;}break;
|
||||
case 1<<10:{bucket_idx = 6;}break;
|
||||
default:{bucket_idx = ArrayCount(((CTRL_EntityStore *)0)->free_string_chunks)-1;}break;
|
||||
default:{bucket_idx = ArrayCount(((DI_Stripe *)0)->free_string_chunks)-1;}break;
|
||||
}
|
||||
return bucket_idx;
|
||||
}
|
||||
@@ -658,7 +658,7 @@ di_parse_thread__entry_point(void *p)
|
||||
}
|
||||
if(!og_format_is_known)
|
||||
{
|
||||
if(data.size >= 2 && *(U16 *)data.str == PE_DOS_MAGIC)
|
||||
if(data.size >= 2 && *(U16 *)data.str == 0x5a4d)
|
||||
{
|
||||
og_format_is_known = 1;
|
||||
og_is_pe = 1;
|
||||
|
||||
@@ -19,15 +19,21 @@
|
||||
#include "lib_rdi_format/rdi_format_parse.h"
|
||||
#include "lib_rdi_format/rdi_format.c"
|
||||
#include "lib_rdi_format/rdi_format_parse.c"
|
||||
#include "third_party/rad_lzb_simple/rad_lzb_simple.h"
|
||||
#include "third_party/rad_lzb_simple/rad_lzb_simple.c"
|
||||
|
||||
//- rjf: [h]
|
||||
#include "base/base_inc.h"
|
||||
#include "os/os_inc.h"
|
||||
#include "path/path.h"
|
||||
#include "dbgi/dbgi.h"
|
||||
#include "rdi_dump.h"
|
||||
|
||||
//- rjf: [c]
|
||||
#include "base/base_inc.c"
|
||||
#include "os/os_inc.c"
|
||||
#include "path/path.c"
|
||||
#include "dbgi/dbgi.c"
|
||||
#include "rdi_dump.c"
|
||||
|
||||
////////////////////////////////
|
||||
@@ -40,6 +46,7 @@ entry_point(CmdLine *cmd_line)
|
||||
//- rjf: set up
|
||||
//
|
||||
Arena *arena = arena_alloc();
|
||||
DI_Scope *di_scope = di_scope_open();
|
||||
String8List errors = {0};
|
||||
|
||||
//////////////////////////////
|
||||
@@ -70,11 +77,8 @@ entry_point(CmdLine *cmd_line)
|
||||
String8 input_data = {0};
|
||||
DumpFlags dump_flags = (U32)0xffffffff;
|
||||
{
|
||||
// rjf: extract input file path & load data
|
||||
// rjf: extract input file path
|
||||
input_name = str8_list_first(&cmd_line->inputs);
|
||||
if(input_name.size > 0) { input_data = os_data_from_file_path(arena, input_name); }
|
||||
else {str8_list_pushf(arena, &errors, "error (input): No input RDI file specified.");}
|
||||
if(input_name.size != 0 && input_data.size == 0) { str8_list_pushf(arena, &errors, "error (input): No input RDI file successfully loaded; either the path or file contents are invalid."); }
|
||||
|
||||
// rjf: extract dump options
|
||||
{
|
||||
@@ -107,17 +111,22 @@ entry_point(CmdLine *cmd_line)
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: parse raddbg from input data
|
||||
//- rjf: obtain rdi parse
|
||||
//
|
||||
RDI_ParseStatus parse_status = RDI_ParseStatus_Good;
|
||||
RDI_Parsed raddbg_ = {0};
|
||||
RDI_Parsed *raddbg = &raddbg_;
|
||||
RDI_Parsed *rdi = &di_rdi_parsed_nil;
|
||||
if(input_name.size == 0)
|
||||
{
|
||||
parse_status = rdi_parse(input_data.str, input_data.size, &raddbg_);
|
||||
if(parse_status != RDI_ParseStatus_Good)
|
||||
{
|
||||
str8_list_pushf(arena, &errors, "error (parse): RDI file wasn't parsed successfully. (0x%x)", parse_status);
|
||||
}
|
||||
str8_list_pushf(arena, &errors, "error (input): No input RDI file specified.");
|
||||
}
|
||||
else
|
||||
{
|
||||
DI_Key key = {input_name};
|
||||
di_open(&key);
|
||||
rdi = di_rdi_from_key(di_scope, &key, max_U64);
|
||||
}
|
||||
if(rdi == &di_rdi_parsed_nil)
|
||||
{
|
||||
str8_list_pushf(arena, &errors, "error (input): No input RDI file successfully loaded; either the path or file contents are invalid.");
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
@@ -133,13 +142,13 @@ entry_point(CmdLine *cmd_line)
|
||||
//- rjf: build dump strings
|
||||
//
|
||||
String8List dump = {0};
|
||||
if(parse_status == RDI_ParseStatus_Good)
|
||||
if(rdi != &di_rdi_parsed_nil)
|
||||
{
|
||||
//- rjf: DATA SECTIONS
|
||||
if(dump_flags & DumpFlag_DataSections)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, "# DATA SECTIONS:\n");
|
||||
rdi_stringize_data_sections(arena, &dump, raddbg, 1);
|
||||
rdi_stringize_data_sections(arena, &dump, rdi, 1);
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
|
||||
@@ -147,7 +156,7 @@ entry_point(CmdLine *cmd_line)
|
||||
if(dump_flags & DumpFlag_TopLevelInfo)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, "# TOP LEVEL INFO:\n");
|
||||
rdi_stringize_top_level_info(arena, &dump, raddbg, raddbg->top_level_info, 1);
|
||||
rdi_stringize_top_level_info(arena, &dump, rdi, rdi->top_level_info, 1);
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
|
||||
@@ -155,11 +164,11 @@ entry_point(CmdLine *cmd_line)
|
||||
if(dump_flags & DumpFlag_BinarySections)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, "# BINARY SECTIONS:\n");
|
||||
RDI_BinarySection *ptr = raddbg->binary_sections;
|
||||
for(U32 i = 0; i < raddbg->binary_sections_count; i += 1, ptr += 1)
|
||||
RDI_BinarySection *ptr = rdi->binary_sections;
|
||||
for(U32 i = 0; i < rdi->binary_sections_count; i += 1, ptr += 1)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " section[%u]:\n", i);
|
||||
rdi_stringize_binary_section(arena, &dump, raddbg, ptr, 2);
|
||||
rdi_stringize_binary_section(arena, &dump, rdi, ptr, 2);
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
@@ -170,16 +179,16 @@ entry_point(CmdLine *cmd_line)
|
||||
{
|
||||
RDI_FilePathBundle file_path_bundle = {0};
|
||||
{
|
||||
file_path_bundle.file_paths = raddbg->file_paths;
|
||||
file_path_bundle.file_path_count = raddbg->file_paths_count;
|
||||
file_path_bundle.file_paths = rdi->file_paths;
|
||||
file_path_bundle.file_path_count = rdi->file_paths_count;
|
||||
}
|
||||
str8_list_pushf(arena, &dump, "# FILE PATHS\n");
|
||||
RDI_FilePathNode *ptr = raddbg->file_paths;
|
||||
for(U32 i = 0; i < raddbg->file_paths_count; i += 1, ptr += 1)
|
||||
RDI_FilePathNode *ptr = rdi->file_paths;
|
||||
for(U32 i = 0; i < rdi->file_paths_count; i += 1, ptr += 1)
|
||||
{
|
||||
if(ptr->parent_path_node == 0)
|
||||
{
|
||||
rdi_stringize_file_path(arena, &dump, raddbg, &file_path_bundle, ptr, 1);
|
||||
rdi_stringize_file_path(arena, &dump, rdi, &file_path_bundle, ptr, 1);
|
||||
}
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
@@ -189,11 +198,11 @@ entry_point(CmdLine *cmd_line)
|
||||
if(dump_flags & DumpFlag_SourceFiles)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, "# SOURCE FILES\n");
|
||||
RDI_SourceFile *ptr = raddbg->source_files;
|
||||
for(U32 i = 0; i < raddbg->source_files_count; i += 1, ptr += 1)
|
||||
RDI_SourceFile *ptr = rdi->source_files;
|
||||
for(U32 i = 0; i < rdi->source_files_count; i += 1, ptr += 1)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " source_file[%u]:\n", i);
|
||||
rdi_stringize_source_file(arena, &dump, raddbg, ptr, 2);
|
||||
rdi_stringize_source_file(arena, &dump, rdi, ptr, 2);
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
@@ -203,11 +212,11 @@ entry_point(CmdLine *cmd_line)
|
||||
if(dump_flags & DumpFlag_Units)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, "# UNITS\n");
|
||||
RDI_Unit *ptr = raddbg->units;
|
||||
for (U32 i = 0; i < raddbg->units_count; i += 1, ptr += 1)
|
||||
RDI_Unit *ptr = rdi->units;
|
||||
for (U32 i = 0; i < rdi->units_count; i += 1, ptr += 1)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " unit[%u]:\n", i);
|
||||
rdi_stringize_unit(arena, &dump, raddbg, ptr, 2);
|
||||
rdi_stringize_unit(arena, &dump, rdi, ptr, 2);
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
@@ -217,8 +226,8 @@ entry_point(CmdLine *cmd_line)
|
||||
if(dump_flags & DumpFlag_UnitVMap)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, "# UNIT VMAP\n");
|
||||
RDI_VMapEntry *ptr = raddbg->unit_vmap;
|
||||
for(U32 i = 0; i < raddbg->unit_vmap_count; i += 1, ptr += 1)
|
||||
RDI_VMapEntry *ptr = rdi->unit_vmap;
|
||||
for(U32 i = 0; i < rdi->unit_vmap_count; i += 1, ptr += 1)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " 0x%08x: %llu\n", ptr->voff, ptr->idx);
|
||||
}
|
||||
@@ -229,11 +238,11 @@ entry_point(CmdLine *cmd_line)
|
||||
if(dump_flags & DumpFlag_TypeNodes)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, "# TYPE NODES:\n");
|
||||
RDI_TypeNode *ptr = raddbg->type_nodes;
|
||||
for(U32 i = 0; i < raddbg->type_nodes_count; i += 1, ptr += 1)
|
||||
RDI_TypeNode *ptr = rdi->type_nodes;
|
||||
for(U32 i = 0; i < rdi->type_nodes_count; i += 1, ptr += 1)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " type[%u]:\n", i);
|
||||
rdi_stringize_type_node(arena, &dump, raddbg, ptr, 2);
|
||||
rdi_stringize_type_node(arena, &dump, rdi, ptr, 2);
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
@@ -244,17 +253,17 @@ entry_point(CmdLine *cmd_line)
|
||||
{
|
||||
RDI_UDTMemberBundle member_bundle = {0};
|
||||
{
|
||||
member_bundle.members = raddbg->members;
|
||||
member_bundle.enum_members = raddbg->enum_members;
|
||||
member_bundle.member_count = raddbg->members_count;
|
||||
member_bundle.enum_member_count = raddbg->enum_members_count;
|
||||
member_bundle.members = rdi->members;
|
||||
member_bundle.enum_members = rdi->enum_members;
|
||||
member_bundle.member_count = rdi->members_count;
|
||||
member_bundle.enum_member_count = rdi->enum_members_count;
|
||||
}
|
||||
str8_list_pushf(arena, &dump, "# UDTS:\n");
|
||||
RDI_UDT *ptr = raddbg->udts;
|
||||
for(U32 i = 0; i < raddbg->udts_count; i += 1, ptr += 1)
|
||||
RDI_UDT *ptr = rdi->udts;
|
||||
for(U32 i = 0; i < rdi->udts_count; i += 1, ptr += 1)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " udt[%u]:\n", i);
|
||||
rdi_stringize_udt(arena, &dump, raddbg, &member_bundle, ptr, 2);
|
||||
rdi_stringize_udt(arena, &dump, rdi, &member_bundle, ptr, 2);
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
@@ -264,11 +273,11 @@ entry_point(CmdLine *cmd_line)
|
||||
if(dump_flags & DumpFlag_GlobalVariables)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, "# GLOBAL VARIABLES:\n");
|
||||
RDI_GlobalVariable *ptr = raddbg->global_variables;
|
||||
for(U32 i = 0; i < raddbg->global_variables_count; i += 1, ptr += 1)
|
||||
RDI_GlobalVariable *ptr = rdi->global_variables;
|
||||
for(U32 i = 0; i < rdi->global_variables_count; i += 1, ptr += 1)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " global_variable[%u]:\n", i);
|
||||
rdi_stringize_global_variable(arena, &dump, raddbg, ptr, 2);
|
||||
rdi_stringize_global_variable(arena, &dump, rdi, ptr, 2);
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
@@ -278,8 +287,8 @@ entry_point(CmdLine *cmd_line)
|
||||
if(dump_flags & DumpFlag_GlobalVMap)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, "# GLOBAL VMAP:\n");
|
||||
RDI_VMapEntry *ptr = raddbg->global_vmap;
|
||||
for(U32 i = 0; i < raddbg->global_vmap_count; i += 1, ptr += 1)
|
||||
RDI_VMapEntry *ptr = rdi->global_vmap;
|
||||
for(U32 i = 0; i < rdi->global_vmap_count; i += 1, ptr += 1)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " 0x%08x: %llu\n", ptr->voff, ptr->idx);
|
||||
}
|
||||
@@ -290,11 +299,11 @@ entry_point(CmdLine *cmd_line)
|
||||
if(dump_flags & DumpFlag_ThreadVariables)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, "# THREAD VARIABLES:\n");
|
||||
RDI_ThreadVariable *ptr = raddbg->thread_variables;
|
||||
for(U32 i = 0; i < raddbg->thread_variables_count; i += 1, ptr += 1)
|
||||
RDI_ThreadVariable *ptr = rdi->thread_variables;
|
||||
for(U32 i = 0; i < rdi->thread_variables_count; i += 1, ptr += 1)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " thread_variable[%u]:\n", i);
|
||||
rdi_stringize_thread_variable(arena, &dump, raddbg, ptr, 2);
|
||||
rdi_stringize_thread_variable(arena, &dump, rdi, ptr, 2);
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
@@ -304,11 +313,11 @@ entry_point(CmdLine *cmd_line)
|
||||
if(dump_flags & DumpFlag_Procedures)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, "# PROCEDURES:\n");
|
||||
RDI_Procedure *ptr = raddbg->procedures;
|
||||
for(U32 i = 0; i < raddbg->procedures_count; i += 1, ptr += 1)
|
||||
RDI_Procedure *ptr = rdi->procedures;
|
||||
for(U32 i = 0; i < rdi->procedures_count; i += 1, ptr += 1)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " procedure[%u]:\n", i);
|
||||
rdi_stringize_procedure(arena, &dump, raddbg, ptr, 2);
|
||||
rdi_stringize_procedure(arena, &dump, rdi, ptr, 2);
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
@@ -319,24 +328,24 @@ entry_point(CmdLine *cmd_line)
|
||||
{
|
||||
RDI_ScopeBundle scope_bundle = {0};
|
||||
{
|
||||
scope_bundle.scopes = raddbg->scopes;
|
||||
scope_bundle.scope_count = raddbg->scopes_count;
|
||||
scope_bundle.scope_voffs = raddbg->scope_voffs;
|
||||
scope_bundle.scope_voff_count = raddbg->scope_voffs_count;
|
||||
scope_bundle.locals = raddbg->locals;
|
||||
scope_bundle.local_count = raddbg->locals_count;
|
||||
scope_bundle.location_blocks = raddbg->location_blocks;
|
||||
scope_bundle.location_block_count = raddbg->location_blocks_count;
|
||||
scope_bundle.location_data = raddbg->location_data;
|
||||
scope_bundle.location_data_size = raddbg->location_data_size;
|
||||
scope_bundle.scopes = rdi->scopes;
|
||||
scope_bundle.scope_count = rdi->scopes_count;
|
||||
scope_bundle.scope_voffs = rdi->scope_voffs;
|
||||
scope_bundle.scope_voff_count = rdi->scope_voffs_count;
|
||||
scope_bundle.locals = rdi->locals;
|
||||
scope_bundle.local_count = rdi->locals_count;
|
||||
scope_bundle.location_blocks = rdi->location_blocks;
|
||||
scope_bundle.location_block_count = rdi->location_blocks_count;
|
||||
scope_bundle.location_data = rdi->location_data;
|
||||
scope_bundle.location_data_size = rdi->location_data_size;
|
||||
}
|
||||
str8_list_pushf(arena, &dump, "# SCOPES:\n");
|
||||
RDI_Scope *ptr = raddbg->scopes;
|
||||
for(U32 i = 0; i < raddbg->scopes_count; i += 1, ptr += 1)
|
||||
RDI_Scope *ptr = rdi->scopes;
|
||||
for(U32 i = 0; i < rdi->scopes_count; i += 1, ptr += 1)
|
||||
{
|
||||
if(ptr->parent_scope_idx == 0)
|
||||
{
|
||||
rdi_stringize_scope(arena, &dump, raddbg, &scope_bundle, ptr, 1);
|
||||
rdi_stringize_scope(arena, &dump, rdi, &scope_bundle, ptr, 1);
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
}
|
||||
@@ -347,8 +356,8 @@ entry_point(CmdLine *cmd_line)
|
||||
if(dump_flags & DumpFlag_ScopeVMap)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, "# SCOPE VMAP:\n");
|
||||
RDI_VMapEntry *ptr = raddbg->scope_vmap;
|
||||
for(U32 i = 0; i < raddbg->scope_vmap_count; i += 1, ptr += 1)
|
||||
RDI_VMapEntry *ptr = rdi->scope_vmap;
|
||||
for(U32 i = 0; i < rdi->scope_vmap_count; i += 1, ptr += 1)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " 0x%08x: %llu\n", ptr->voff, ptr->idx);
|
||||
}
|
||||
@@ -359,11 +368,11 @@ entry_point(CmdLine *cmd_line)
|
||||
if(dump_flags & DumpFlag_NameMaps)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, "# NAME MAP:\n");
|
||||
RDI_NameMap *ptr = raddbg->name_maps;
|
||||
for(U32 i = 0; i < raddbg->name_maps_count; i += 1, ptr += 1)
|
||||
RDI_NameMap *ptr = rdi->name_maps;
|
||||
for(U32 i = 0; i < rdi->name_maps_count; i += 1, ptr += 1)
|
||||
{
|
||||
RDI_ParsedNameMap name_map = {0};
|
||||
rdi_name_map_parse(raddbg, ptr, &name_map);
|
||||
rdi_name_map_parse(rdi, ptr, &name_map);
|
||||
str8_list_pushf(arena, &dump, " name_map[%u]:\n", i);
|
||||
RDI_NameMapBucket *bucket = name_map.buckets;
|
||||
for(U32 j = 0; j < name_map.bucket_count; j += 1, bucket += 1)
|
||||
@@ -376,7 +385,7 @@ entry_point(CmdLine *cmd_line)
|
||||
for(;node < node_opl; node += 1)
|
||||
{
|
||||
String8 string = {0};
|
||||
string.str = rdi_string_from_idx(raddbg, node->string_idx, &string.size);
|
||||
string.str = rdi_string_from_idx(rdi, node->string_idx, &string.size);
|
||||
str8_list_pushf(arena, &dump, " match \"%.*s\": ", str8_varg(string));
|
||||
if(node->match_count == 1)
|
||||
{
|
||||
@@ -386,7 +395,7 @@ entry_point(CmdLine *cmd_line)
|
||||
{
|
||||
RDI_U32 idx_count = 0;
|
||||
RDI_U32 *idx_run =
|
||||
rdi_idx_run_from_first_count(raddbg, node->match_idx_or_idx_run_first,
|
||||
rdi_idx_run_from_first_count(rdi, node->match_idx_or_idx_run_first,
|
||||
node->match_count, &idx_count);
|
||||
if(idx_count > 0)
|
||||
{
|
||||
@@ -411,10 +420,10 @@ entry_point(CmdLine *cmd_line)
|
||||
if(dump_flags & DumpFlag_Strings)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, "# STRINGS:\n");
|
||||
for(U64 string_idx = 0; string_idx < raddbg->string_count; string_idx += 1)
|
||||
for(U64 string_idx = 0; string_idx < rdi->string_count; string_idx += 1)
|
||||
{
|
||||
String8 string = {0};
|
||||
string.str = rdi_string_from_idx(raddbg, string_idx, &string.size);
|
||||
string.str = rdi_string_from_idx(rdi, string_idx, &string.size);
|
||||
str8_list_pushf(arena, &dump, " string[%I64u]: \"%S\"\n", string_idx, string);
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
@@ -428,4 +437,6 @@ entry_point(CmdLine *cmd_line)
|
||||
{
|
||||
fwrite(n->string.str, 1, n->string.size, stdout);
|
||||
}
|
||||
|
||||
di_scope_close(di_scope);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user