Yesterday Toshok wrote me a little gdb script to print a monoificated stacktrace in gdb. That was nice of him, but not exactly what I was looking for. What I really wanted was an entirely managed stack trace that I could print out with a single function call. Thanks to the thread dumping stuff Zoltan added a few weeks ago, you can use this gdb script I wrote to do this:
define mono_stack set $mono_thread = mono_thread_current () if ($mono_thread == 0x00) printf "No mono thread associated with this thread\n" else set $ucp = malloc (sizeof (ucontext_t)) call (void) getcontext ($ucp) call (void) mono_print_thread_dump ($ucp) call (void) free ($ucp) end end
(Is there a way to allocate stuff on the “stack” with gdb?)
Anyway, this works well for me, and so I’ve added it to the wiki.
