Skip to content

Commit ae589ce

Browse files
committed
feat(debug): print func name in si command
1 parent 7212a60 commit ae589ce

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

sim/src/dbg.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
#include <dbg.h>
55
#include <decode.h>
66
#include <disasm.h>
7+
#include "ftrace.h"
78

9+
extern SymbolTable *sym_table;
810
extern LLVMDisasmContextRef disasm_ctx;
911

1012
static void cmd_help() {
@@ -43,6 +45,14 @@ static void cmd_step(int steps) {
4345
// Print the address and the disassembled instruction
4446
printf("\33[1;34m=> 0x%016lx\33[1;0m: \t%s\n", current_pc, asm_buf);
4547

48+
// Look up and print the function name if available
49+
if (sym_table) {
50+
const FuncSymbol *func_symbol = find_func(sym_table, current_pc);
51+
if (func_symbol) {
52+
printf("\33[1;34m0x%08lx\33[1;0m in \33[1;33m%s\33[1;0m ()\n", func_symbol->address, func_symbol->name);
53+
}
54+
}
55+
4656
// Execute the instruction
4757
exec_once();
4858
}

sim/src/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ int main(int argc, char *argv[]){
3131

3232
init_cpu();
3333
if (argc > 2 && strcmp(argv[2], "--debug") == 0) {
34+
init_llvm_disassembler();
3435
debug_loop();
3536
}
3637
else if (argc > 2 && strcmp(argv[2], "--batch") == 0) {

sim/src/memory.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ void load_elf_symbols(const char *file_path) {
100100
exit(1);
101101
}
102102

103-
printf("Entry point: 0x%lx\n", ehdr.e_entry);
104-
105103
Elf_Scn *scn = NULL;
106104
GElf_Shdr shdr;
107105
while ((scn = elf_nextscn(elf, scn)) != NULL) {

0 commit comments

Comments
 (0)