Added backtrace to C++ expection handler and memory related fault handlers.

This commit is contained in:
Michael Mueller
2025-06-03 15:22:09 +02:00
parent 92ed8c926b
commit dccd1ddfc3
3 changed files with 34 additions and 13 deletions

View File

@@ -15,6 +15,7 @@
/* Genode includes */
#include <rm_session/rm_session.h>
#include <os/backtrace.h>
/* base-internal includes */
#include <base/internal/native_thread.h>
@@ -102,18 +103,29 @@ struct Page_fault_info
void print(Genode::Output &out) const
{
Genode::print(out, "pd='", pd, "' "
"thread='", thread, "' "
"cpu=", cpu, " "
"ip=", Hex(ip), " "
"address=", Hex(addr), " "
"stack pointer=", Hex(sp), " "
"qualifiers=", Hex(pf_type), " ",
pf_type & Ipc_pager::ERR_I ? "I" : "i",
pf_type & Ipc_pager::ERR_R ? "R" : "r",
pf_type & Ipc_pager::ERR_U ? "U" : "u",
pf_type & Ipc_pager::ERR_W ? "W" : "w",
pf_type & Ipc_pager::ERR_P ? "P" : "p");
Genode::print(
out, "pd='", pd,
"' "
"thread='",
thread,
"' "
"cpu=",
cpu,
" "
"ip=",
Hex(ip),
" "
"address=",
Hex(addr),
" "
"stack pointer=",
Hex(sp),
" "
"qualifiers=",
Hex(pf_type), " ", pf_type & Ipc_pager::ERR_I ? "I" : "i",
pf_type & Ipc_pager::ERR_R ? "R" : "r", pf_type & Ipc_pager::ERR_U ? "U" : "u",
pf_type & Ipc_pager::ERR_W ? "W" : "w", pf_type & Ipc_pager::ERR_P ? "P" : "p");
Genode::backtrace();
}
};
@@ -236,6 +248,8 @@ void Pager_object::exception(uint8_t exit_id)
res == 0xFF ? "no signal handler"
: (res == NOVA_OK ? "" : "recall failed"));
Genode::backtrace();
Tukija::revoke(Obj_crd(exc_pt_sel_client(), NUM_INITIAL_PT_LOG2));
enum { TRAP_BREAKPOINT = 3 };

View File

@@ -14,6 +14,7 @@
#include <base/slab.h>
#include <util/construct_at.h>
#include <util/misc_math.h>
#include <os/backtrace.h>
using namespace Genode;
@@ -425,6 +426,7 @@ void Slab::_free(void *addr)
if (!e->used()) {
error("slab address ", addr, " freed which is unused");
Genode::backtrace();
return;
}

View File

@@ -23,6 +23,8 @@
/* base-internal includes */
#include <base/internal/globals.h>
#include <os/backtrace.h>
extern "C" char __eh_frame_start__[]; /* from linker script */
extern "C" void __register_frame (const void *begin); /* from libgcc_eh */
extern "C" char *__cxa_demangle(const char *mangled_name,
@@ -63,9 +65,12 @@ static void terminate_handler()
Genode::error("Uncaught exception of type "
"'", Genode::Cstring(demangled_name), "'");
free(demangled_name);
Genode::backtrace();
} else {
Genode::error("Uncaught exception of type '", t->name(), "' "
Genode::error("Uncaught exception of type '", t->name(),
"' "
"(use 'c++filt -t' to demangle)");
Genode::backtrace();
}
}