I have this gdb macro that is used to print meaningful stacks when debugging a mono executable version. It iterates over all stack frames, indicates whether this frame is native or managed. If it is managed, it uses the information from mono_pmip () to print a decent description of this frame. If it is native, it calls gdb "frame" to describe the frame.
define mono_backtrace select-frame 0 set $i = 0 while ($i < $arg0) set $foo = mono_pmip ($pc) if ($foo == 0x00) frame else printf "#%d %p in %s\n", $i, $pc, $foo end up-silently set $i = $i + 1 end end
Two questions related to this:
How can I remove the $ arg0 argument and pass it through all the frames until it reaches the top of the stack?
How can I get a "frame" (or an alternative) only to print the name of the function (for example, bt), and not the actual line of source code in this function ?. Current output:
#1 0x000c21f6 in mono_handle_exception (ctx=0xbfffe7f0, obj=0x64bf18, original_ip=0x65024a, test_only=0) at mini-exceptions.c:1504 1504 return mono_handle_exception_internal (ctx, obj, original_ip, test_only, NULL, NULL);
While I want the result to match what bt does:
#1 0x000c21f6 in mono_handle_exception (ctx=0xbfffe7f0, obj=0x64bf18, original_ip=0x65024a, test_only=0) at mini-exceptions.c:1504
source share