Replies: 1 comment
-
|
There are several ways you could do that. If you use the stdlib then at runtime you can do module myos;
alias PanicFn = fn void(String message, String file, String function, uint line);
PanicFn panic = &default_panic;
fn void default_panic(String message, String file, String function, uint line)
{
print("something went wrong!!");
print_the_backtrace();
$$trap(); // ud2 on x86_64
}
// you can also use a lambda if you don't intend to swap out & back the panic function at runtime:
PanicFn panic = fn (message, file, function, line)
{
...
};then if you use a this is a general overview of the code for how backtraces are collected & printed on panic in the stdlib that you could look at for your own implementation, but you don't necessarily have to follow it: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am pretty new to C3 and I was looking at it. I am currently in development of a hobby OS and I use elf binaries. I noticed that the ELF format does not have stack traces. In a freestanding environment that is totally understandable. However, I also have the power to drive whatever allocation is necessary for C3 to accomplish stack traces. Does anyone have any idea if C3 exposes anything I can integrate with for stack traces?
Beta Was this translation helpful? Give feedback.
All reactions