feature (stack-tracing): requesting symbol table from currently running process

This commit is contained in:
antifallobst 2023-03-04 16:54:20 +01:00
parent 24693baa1d
commit ebe10b359d
2 changed files with 15 additions and 5 deletions

View File

@ -23,6 +23,7 @@
#include "mm/stack.h"
#include "utils/logger.h"
#include "proc/scheduler.h"
void stack_dump_call_info(uint64_t rip, symbol_T* symbol) {
log(LOG_NONE, " 0x%x+%xw -> %s", symbol->address, rip - symbol->address, symbol->name);
@ -30,7 +31,8 @@ void stack_dump_call_info(uint64_t rip, symbol_T* symbol) {
void stack_trace_call_stack(uint64_t rbp) {
uint64_t rip = ((uint64_t*)rbp)[1];
symbol_T* symbol = symbol_resolve_function_from_rip(g_kernel_executable->symbols, g_kernel_executable->num_symbols, rip);
process_T* process = scheduler_get_current_process();
symbol_T* symbol = symbol_resolve_function_from_rip(process->executable->symbols, process->executable->num_symbols, rip);
if (symbol != NULL && !string_compare(symbol->name, "_start")) {
stack_trace_call_stack(((uint64_t*)rbp)[0]);

View File

@ -26,6 +26,7 @@
#include "utils/core.h"
#include "platform/exceptions.h"
#include "mm/stack.h"
#include "proc/scheduler.h"
void panic_log_paging_info(cpu_state_T* state) {
log(LOG_NONE, "Paging Info:");
@ -78,15 +79,22 @@ void panic_log_registers(cpu_state_T* state) {
}
void panic_log_call_stack(cpu_state_T* state) {
process_T* process = scheduler_get_current_process();
if (process == NULL || process->executable == NULL) {
log(LOG_NONE, "Call Stack not resolvable (no symbol data access)");
return;
}
log(LOG_NONE, "Call Stack:");
stack_trace_call_stack(state->rbp);
symbol_T* symbol = symbol_resolve_function_from_rip(g_kernel_executable->symbols, g_kernel_executable->num_symbols, state->rip);
if (symbol != NULL) {
stack_dump_call_info(state->rip, symbol);
} else {
symbol_T* symbol = symbol_resolve_function_from_rip(process->executable->symbols, process->executable->num_symbols, state->rip);
if (symbol == NULL) {
log(LOG_NONE, " 0x%x -> <failed to resolve symbol>", state->rip);
return;
}
stack_dump_call_info(state->rip, symbol);
}
void panic(cpu_state_T* state, string_t message) {