From 959de0d83468b49c4c74a0cc482f181ca3ca61b8 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Fri, 16 Oct 2026 08:18:10 -0700 Subject: [PATCH] update rdi_parse samples, add voff -> procedure name --- src/lib_rdi/rdi_parse.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/lib_rdi/rdi_parse.h b/src/lib_rdi/rdi_parse.h index 5349348d..06a8d58a 100644 --- a/src/lib_rdi/rdi_parse.h +++ b/src/lib_rdi/rdi_parse.h @@ -15,13 +15,13 @@ { RDI_Parsed *rdi = ...; char *name = "mule_main"; - RDI_Procedure *procedure = rdi_procedure_from_name_cstr(rdi, name); // 1. name -> procedure + RDI_Symbol *procedure = rdi_procedure_from_name_cstr(rdi, name); // 1. name -> procedure RDI_U64 procedure_first_voff = rdi_first_voff_from_procedure(rdi, procedure); // 2. procedure -> virtual offset RDI_Line line = rdi_line_from_voff(rdi, procedure_first_voff); // 3. virtual offset -> line RDI_SourceFile *file = rdi_source_file_from_line(rdi, &line); // 4. line -> source file RDI_U64 file_path_size = 0; // 5. source file -> path RDI_U8 *file_path = rdi_normal_path_from_source_file(rdi, file, &file_path_size); - printf("%s is at %.*s:%u\n", name, (int)file_path_size, file_path, line.line_num); + printf("%s is at %.*s:%u\n", name, (int)file_path_size, file_path, line.line_num); // " is at :" } // Line -> Procedure Name @@ -31,10 +31,20 @@ RDI_U32 line_num = 2557; RDI_SourceFile *file = rdi_source_file_from_normal_path_cstr(rdi, path); // 1. path -> source file RDI_U64 voff = rdi_first_voff_from_source_file_line_num(rdi, file, line_num); // 2. (source file, line) -> virtual offset - RDI_Procedure *procedure = rdi_procedure_from_voff(rdi, voff); // 3. virtual offset -> procedure + RDI_Symbol *procedure = rdi_procedure_from_voff(rdi, voff); // 3. virtual offset -> procedure RDI_U64 name_size = 0; // 4. procedure -> name RDI_U8 *name = rdi_name_from_procedure(rdi, procedure, &name_size); - printf("%s:%u is inside %.*s\n", path, line_num, (int)name_size, name); + printf("%s:%u is inside %.*s\n", path, line_num, (int)name_size, name); // ": is inside " +} + +// Virtual Offset -> Procedure Name +{ + RDI_Parsed *rdi = ...; + RDI_U64 voff = ...; + RDI_Symbol *procedure = rdi_procedure_from_voff(rdi, voff); // 1. voff -> procedure + RDI_U64 name_size = 0; // 2. procedure -> name + RDI_U8 *name = rdi_name_from_procedure(rdi, procedure, &name_size); + printf("0x%llx is inside %.*s\n", voff, (int)name_size, name); // " is inside " } #endif