fix (stack-tracing): fixed symbol name resolve bug when function is extern / assembly
This commit is contained in:
parent
9b50ca77da
commit
6d60157da0
|
@ -39,6 +39,6 @@ typedef struct {
|
|||
} symbol_T;
|
||||
|
||||
symbol_T* symbol_resolve_from_name (symbol_T* symbols, uint64_t num_symbols, string_t name);
|
||||
symbol_T* symbol_resolve_function_from_rip (symbol_T* symbols, uint64_t num_symbols, uint64_t rip);
|
||||
symbol_T* symbol_resolve_from_rip (symbol_T* symbols, uint64_t num_symbols, uint64_t rip);
|
||||
|
||||
#endif //NOX_SYMBOLS_H
|
||||
|
|
|
@ -36,7 +36,7 @@ void stack_trace_call_stack(uint64_t rbp) {
|
|||
log(LOG_NONE, " 0x%x -> <failed to resolve symbol> (process NULL reference)", rip);
|
||||
return;
|
||||
}
|
||||
symbol_T* symbol = symbol_resolve_function_from_rip(process->executable->symbols, process->executable->num_symbols, rip);
|
||||
symbol_T* symbol = symbol_resolve_from_rip(process->executable->symbols, process->executable->num_symbols, rip);
|
||||
|
||||
if (symbol == NULL) {
|
||||
log(LOG_NONE, " 0x%x -> <failed to resolve symbol> (symbol NULL reference)", rip);
|
||||
|
|
|
@ -89,7 +89,7 @@ void panic_log_call_stack(cpu_state_T* state) {
|
|||
log(LOG_NONE, "Call Stack:");
|
||||
stack_trace_call_stack(state->rbp);
|
||||
|
||||
symbol_T* symbol = symbol_resolve_function_from_rip(process->executable->symbols, process->executable->num_symbols, state->rip);
|
||||
symbol_T* symbol = symbol_resolve_from_rip(process->executable->symbols, process->executable->num_symbols,state->rip);
|
||||
if (symbol == NULL) {
|
||||
log(LOG_NONE, " 0x%x -> <failed to resolve symbol> (symbol NULL reference)", state->rip);
|
||||
return;
|
||||
|
|
|
@ -33,13 +33,12 @@ symbol_T* symbol_resolve_from_name(symbol_T* symbols, uint64_t num_symbols, stri
|
|||
return NULL;
|
||||
}
|
||||
|
||||
symbol_T* symbol_resolve_function_from_rip(symbol_T* symbols, uint64_t num_symbols, uint64_t rip) {
|
||||
symbol_T* symbol_resolve_from_rip(symbol_T* symbols, uint64_t num_symbols, uint64_t rip) {
|
||||
symbol_T* symbol = NULL;
|
||||
|
||||
for (uint64_t i = 0; i < num_symbols; i++) {
|
||||
if (symbols[i].address <= rip &&
|
||||
(symbol == NULL || symbols[i].address > symbol->address) &&
|
||||
symbols[i].type == SYMBOL_FUNCTION)
|
||||
(symbol == NULL || symbols[i].address > symbol->address))
|
||||
{
|
||||
symbol = &symbols[i];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue