mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-08 14:58:08 +00:00
jump destination symbol name visualization in disassembly
This commit is contained in:
@@ -436,8 +436,11 @@ dasm_parse_thread__entry_point(void *p)
|
||||
// rjf: analyze
|
||||
struct ud_operand *first_op = (struct ud_operand *)ud_insn_opr(&udc, 0);
|
||||
U64 rel_voff = (first_op != 0 && first_op->type == UD_OP_JIMM) ? ud_syn_rel_target(&udc, first_op) : 0;
|
||||
U64 jump_dst_vaddr = rel_voff;
|
||||
|
||||
// rjf: push strings derived from voff -> line info
|
||||
if(params.style_flags & DASM_StyleFlag_SourceFilesNames|DASM_StyleFlag_SourceLines)
|
||||
{
|
||||
if(dbgi != &dbgi_parse_nil)
|
||||
{
|
||||
U64 voff = (params.vaddr+off) - params.base_vaddr;
|
||||
@@ -454,7 +457,8 @@ dasm_parse_thread__entry_point(void *p)
|
||||
file_normalized_full_path.str = rdi_string_from_idx(rdi, file->normal_full_path_string_idx, &file_normalized_full_path.size);
|
||||
if(file != last_file)
|
||||
{
|
||||
if(file->normal_full_path_string_idx != 0 && file_normalized_full_path.size != 0)
|
||||
if(params.style_flags & DASM_StyleFlag_SourceFilesNames &&
|
||||
file->normal_full_path_string_idx != 0 && file_normalized_full_path.size != 0)
|
||||
{
|
||||
DASM_Inst inst = {0};
|
||||
dasm_inst_chunk_list_push(scratch.arena, &inst_list, 1024, &inst);
|
||||
@@ -462,7 +466,9 @@ dasm_parse_thread__entry_point(void *p)
|
||||
}
|
||||
last_file = file;
|
||||
}
|
||||
if(line && line != last_line && file->normal_full_path_string_idx != 0 && file_normalized_full_path.size != 0)
|
||||
if(line && line != last_line && file->normal_full_path_string_idx != 0 &&
|
||||
params.style_flags & DASM_StyleFlag_SourceLines &&
|
||||
file_normalized_full_path.size != 0)
|
||||
{
|
||||
FileProperties props = os_properties_from_file_path(file_normalized_full_path);
|
||||
if(props.modified != 0)
|
||||
@@ -498,6 +504,7 @@ dasm_parse_thread__entry_point(void *p)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: push
|
||||
String8 addr_part = {0};
|
||||
@@ -524,7 +531,24 @@ dasm_parse_thread__entry_point(void *p)
|
||||
str8_list_push(scratch.arena, &code_bytes_strings, str8_lit(" "));
|
||||
code_bytes_part = str8_list_join(scratch.arena, &code_bytes_strings, 0);
|
||||
}
|
||||
String8 inst_string = push_str8f(scratch.arena, "%S%S%s", addr_part, code_bytes_part, udc.asm_buf);
|
||||
String8 symbol_part = {0};
|
||||
if(jump_dst_vaddr != 0 && dbgi != &dbgi_parse_nil && params.style_flags & DASM_StyleFlag_SymbolNames)
|
||||
{
|
||||
RDI_U32 scope_idx = rdi_vmap_idx_from_voff(rdi->scope_vmap, rdi->scope_vmap_count, jump_dst_vaddr-params.base_vaddr);
|
||||
if(scope_idx != 0)
|
||||
{
|
||||
RDI_Scope *scope = rdi_element_from_idx(rdi, scopes, scope_idx);
|
||||
RDI_U32 procedure_idx = scope->proc_idx;
|
||||
RDI_Procedure *procedure = rdi_element_from_idx(rdi, procedures, procedure_idx);
|
||||
String8 procedure_name = {0};
|
||||
procedure_name.str = rdi_string_from_idx(rdi, procedure->name_string_idx, &procedure_name.size);
|
||||
if(procedure_name.size != 0)
|
||||
{
|
||||
symbol_part = push_str8f(scratch.arena, " (%S)", procedure_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
String8 inst_string = push_str8f(scratch.arena, "%S%S%s%S", addr_part, code_bytes_part, udc.asm_buf, symbol_part);
|
||||
DASM_Inst inst = {off, rel_voff, r1u64(inst_strings.total_size + inst_strings.node_count,
|
||||
inst_strings.total_size + inst_strings.node_count + inst_string.size)};
|
||||
dasm_inst_chunk_list_push(scratch.arena, &inst_list, 1024, &inst);
|
||||
|
||||
@@ -12,6 +12,9 @@ enum
|
||||
{
|
||||
DASM_StyleFlag_Addresses = (1<<0),
|
||||
DASM_StyleFlag_CodeBytes = (1<<1),
|
||||
DASM_StyleFlag_SourceFilesNames = (1<<2),
|
||||
DASM_StyleFlag_SourceLines = (1<<3),
|
||||
DASM_StyleFlag_SymbolNames = (1<<4),
|
||||
};
|
||||
|
||||
typedef enum DASM_Syntax
|
||||
|
||||
@@ -6038,7 +6038,7 @@ DF_VIEW_SETUP_FUNCTION_DEF(Disassembly)
|
||||
dv->mark = txt_pt(1, 1);
|
||||
dv->preferred_column = 1;
|
||||
dv->find_text_arena = df_view_push_arena_ext(view);
|
||||
dv->style_flags = DASM_StyleFlag_Addresses;
|
||||
dv->style_flags = DASM_StyleFlag_Addresses|DASM_StyleFlag_SourceFilesNames|DASM_StyleFlag_SourceLines|DASM_StyleFlag_SymbolNames;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1146,6 +1146,7 @@ txt_token_array_from_string__disasm_x64_intel(Arena *arena, U64 *bytes_processed
|
||||
B32 escaped = 0;
|
||||
B32 string_is_char = 0;
|
||||
S32 brace_nest = 0;
|
||||
S32 paren_nest = 0;
|
||||
for(U64 advance = 0; off <= string.size; off += advance)
|
||||
{
|
||||
U8 byte = (off+0 < string.size) ? string.str[off+0] : 0;
|
||||
@@ -1218,6 +1219,14 @@ txt_token_array_from_string__disasm_x64_intel(Arena *arena, U64 *bytes_processed
|
||||
{
|
||||
brace_nest -= 1;
|
||||
}
|
||||
if(byte == '(')
|
||||
{
|
||||
paren_nest += 1;
|
||||
}
|
||||
else if(byte == ')')
|
||||
{
|
||||
paren_nest -= 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1306,6 +1315,10 @@ txt_token_array_from_string__disasm_x64_intel(Arena *arena, U64 *bytes_processed
|
||||
{
|
||||
active_token_kind = TXT_TokenKind_Numeric;
|
||||
}
|
||||
if(paren_nest != 0 && active_token_kind == TXT_TokenKind_Keyword)
|
||||
{
|
||||
active_token_kind = TXT_TokenKind_Identifier;
|
||||
}
|
||||
TXT_Token token = {active_token_kind, r1u64(active_token_start_off, off+advance)};
|
||||
txt_token_chunk_list_push(arena, &tokens, 1024, &token);
|
||||
active_token_kind = TXT_TokenKind_Null;
|
||||
|
||||
Reference in New Issue
Block a user