> compile NEMU
ysyx_22040000 李心杨 Linux calcite 6.6.19 #1-NixOS SMP PREEMPT_DYNAMIC Fri Mar 1 12:35:11 UTC 2024 x86_64 GNU/Linux 19:29:51 up 6:35, 2 users, load average: 0.51, 0.55, 0.46
This commit is contained in:
parent
173d04977c
commit
728fa8052d
1 changed files with 8 additions and 6 deletions
|
@ -17,15 +17,14 @@ static int cmp_func_t(const void *a, const void *b) {
|
||||||
return ((func_t *)a)->start > ((func_t *)b)->start;
|
return ((func_t *)a)->start > ((func_t *)b)->start;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *get_func_name(vaddr_t addr) {
|
static func_t *get_func(vaddr_t addr) {
|
||||||
int l = 0, r = func_table_len - 1;
|
int l = 0, r = func_table_len - 1;
|
||||||
while(l <= r) {
|
while(l <= r) {
|
||||||
int mid = (l + r) / 2;
|
int mid = (l + r) / 2;
|
||||||
if(func_table[mid].start <= addr) l = mid + 1;
|
if(func_table[mid].start <= addr) l = mid + 1;
|
||||||
else r = mid - 1;
|
else r = mid - 1;
|
||||||
}
|
}
|
||||||
// if(func_table[l].start + func_table[l].len < addr) return "???";
|
return l == 0 ? NULL : &func_table[l - 1];
|
||||||
return l == 0 ? "???" : func_table[l - 1].name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_elf(const char *path) {
|
void init_elf(const char *path) {
|
||||||
|
@ -101,11 +100,12 @@ failed_nosym:
|
||||||
}
|
}
|
||||||
|
|
||||||
void ftrace_call(vaddr_t pc, vaddr_t addr) {
|
void ftrace_call(vaddr_t pc, vaddr_t addr) {
|
||||||
|
func_t *f = get_func(addr);
|
||||||
Assert(ftrace_stack_len < CONFIG_FTRACE_STACK_SIZE,
|
Assert(ftrace_stack_len < CONFIG_FTRACE_STACK_SIZE,
|
||||||
"Ftrace stack exceed size limit, consider turn off ftrace or increase "
|
"Ftrace stack exceed size limit, consider turn off ftrace or increase "
|
||||||
"FTRACE_STACK_SIZE.");
|
"FTRACE_STACK_SIZE.");
|
||||||
ftrace_stack[ftrace_stack_len] = pc + 4;
|
ftrace_stack[ftrace_stack_len] = pc + 4;
|
||||||
Trace("%*s0x%x call [%s@0x%x]", ftrace_stack_len, "", pc, get_func_name(addr),
|
Trace("%*s0x%x call <%s@0x%x>", ftrace_stack_len, "", pc, f == NULL ? "???" : f->name,
|
||||||
addr);
|
addr);
|
||||||
ftrace_stack_len++;
|
ftrace_stack_len++;
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,9 @@ void ftrace_return(vaddr_t pc, vaddr_t addr) {
|
||||||
for (; addr != ftrace_stack[ftrace_stack_len] && ftrace_stack_len >= 0;
|
for (; addr != ftrace_stack[ftrace_stack_len] && ftrace_stack_len >= 0;
|
||||||
ftrace_stack_len--) {
|
ftrace_stack_len--) {
|
||||||
vaddr_t tco_addr = ftrace_stack[ftrace_stack_len];
|
vaddr_t tco_addr = ftrace_stack[ftrace_stack_len];
|
||||||
Trace("%*s0x%x <TCO> [%s@0x%x] ", ftrace_stack_len, "", pc, get_func_name(tco_addr), tco_addr);
|
func_t *f = get_func(tco_addr);
|
||||||
|
Trace("%*s0x%x <TCO> [%s@0x%x] ", ftrace_stack_len, "", pc, f == NULL ? "???" : f->name, tco_addr - f->start);
|
||||||
}
|
}
|
||||||
Trace("%*s0x%x ret [%s@0x%x]", ftrace_stack_len, "", pc, get_func_name(addr), addr);
|
func_t *f = get_func(addr);
|
||||||
|
Trace("%*s0x%x ret <%s+0x%x>", ftrace_stack_len, "", pc, f == NULL ? "???" : f->name, addr - f->start);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue