> compile NEMU
221220000 张三 Linux zzy 5.15.146.1-microsoft-standard-WSL2 #1 SMP Thu Jan 11 04:09:03 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux 10:01:53 up 41 min, 1 user, load average: 0.19, 0.20, 0.24
This commit is contained in:
@ -221,6 +221,11 @@ config FTRACE_DISPLAY
|
||||
bool "Enable to ftrace log in 'statistic'(must end of log file)"
|
||||
default n
|
||||
|
||||
config FTRACE_INST
|
||||
depends on FTRACE
|
||||
bool "Enable ftrace in itrace means in every instruction to show what function name"
|
||||
default n
|
||||
|
||||
|
||||
config DIFFTEST
|
||||
depends on TARGET_NATIVE_ELF
|
||||
|
@ -45,18 +45,14 @@ static void iringbuf_append(const char* log) {
|
||||
}
|
||||
|
||||
static void iringbuf_display(void) {
|
||||
log_write("--- START IRINGBUF ---\n");
|
||||
for (int i = 0; i < CONFIG_IRINGBUF_LINENUM; i ++) {
|
||||
if (iringbuf[i][0] != '\0')
|
||||
log_write("%-4s%s\n", i == irb_pos ? "-->" : "", iringbuf[i]);
|
||||
log_write("iringbuf %3d %-4s%s\n", i, i == irb_pos ? "-->" : "", iringbuf[i]);
|
||||
}
|
||||
log_write("--- END IRINGBUF ---\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FTRACE
|
||||
void ftrace_display();
|
||||
|
||||
#endif
|
||||
|
||||
static void trace_and_difftest(Decode *_this, vaddr_t dnpc) {
|
||||
@ -100,6 +96,10 @@ static void exec_once(Decode *s, vaddr_t pc) {
|
||||
memset(p, ' ', space_len);
|
||||
p += space_len;
|
||||
|
||||
#ifdef CONFIG_FTRACE_INST
|
||||
int ftrace_inst(char* p, size_t size, vaddr_t pc);
|
||||
p += ftrace_inst(p, s->logbuf + sizeof(s->logbuf) - p, s->pc);
|
||||
#endif
|
||||
#ifndef CONFIG_ISA_loongarch32r
|
||||
void disassemble(char *str, int size, uint64_t pc, uint8_t *code, int nbyte);
|
||||
disassemble(p, s->logbuf + sizeof(s->logbuf) - p,
|
||||
@ -126,6 +126,7 @@ static void statistic() {
|
||||
iringbuf_display();
|
||||
#endif
|
||||
#ifdef CONFIG_FTRACE_DISPLAY
|
||||
void ftrace_display();
|
||||
ftrace_display();
|
||||
#endif
|
||||
IFNDEF(CONFIG_TARGET_AM, setlocale(LC_NUMERIC, ""));
|
||||
|
@ -14,18 +14,27 @@ typedef struct {
|
||||
word_t size;
|
||||
char fname[32];
|
||||
} Elf_Ftrace;
|
||||
// [start, start + size) == [start, end]
|
||||
// [start, start + size) == [start, end)
|
||||
static int elf_ftrace_size = 0;
|
||||
static Elf_Ftrace elf_ftrace[128];
|
||||
|
||||
#ifdef CONFIG_FTRACE_DISPLAY
|
||||
void ftrace_display() {
|
||||
for (int i = 0; i < elf_ftrace_size; i ++) {
|
||||
log_write("ftrace %d: ["FMT_WORD", "FMT_WORD"] %s\n", i, elf_ftrace[i].start, elf_ftrace[i].end, elf_ftrace[i].fname);
|
||||
log_write("ftrace %3d: ["FMT_WORD", "FMT_WORD") %s\n", i, elf_ftrace[i].start, elf_ftrace[i].end, elf_ftrace[i].fname);
|
||||
}
|
||||
}
|
||||
#else
|
||||
void ftrace_display() {}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FTRACE_INST
|
||||
int ftrace_inst(char* log, size_t size, vaddr_t pc) {
|
||||
for (int i = 0; i < elf_ftrace_size; i ++) {
|
||||
if (pc >= elf_ftrace[i].start && pc < elf_ftrace[i].end) {
|
||||
return snprintf(log, size, "%s", elf_ftrace[i].fname);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
void init_elf(const char* elf_file) {
|
||||
@ -103,7 +112,7 @@ void init_elf(const char* elf_file) {
|
||||
|
||||
// filling ftrace
|
||||
for (int i = 0; i < symt_len; i ++) {
|
||||
Log("%3d: %08x "FMT_WORD" "FMT_WORD"", i, symt[i].st_value, symt[i].st_size, symt[i].st_name);
|
||||
// Log("%3d: %08x "FMT_WORD" "FMT_WORD"", i, symt[i].st_value, symt[i].st_size, symt[i].st_name);
|
||||
if (ELF_ST_TYPE(symt[i].st_info) == STT_FUNC) {
|
||||
// Warning due to elf_ftrace is global variable so you don't need to set '\0' in the end
|
||||
strncpy(elf_ftrace[elf_ftrace_size].fname, buffer + symt[i].st_name,
|
||||
@ -111,7 +120,7 @@ void init_elf(const char* elf_file) {
|
||||
elf_ftrace[elf_ftrace_size].start = symt[i].st_value;
|
||||
elf_ftrace[elf_ftrace_size].size = symt[i].st_size;
|
||||
elf_ftrace[elf_ftrace_size].end = elf_ftrace[elf_ftrace_size].start + \
|
||||
elf_ftrace[elf_ftrace_size].size - 1;
|
||||
elf_ftrace[elf_ftrace_size].size;
|
||||
elf_ftrace_size ++;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user