2

I am working on a huge program that employs a (custom built) micro-threading solution. It sometimes happens that I need debug a crash. During such times, it is useful to be able to switch from one micro-thread to another.

If I'm doing live debugging, I can replace all of the registers to those that came from the micro-thread context. I have written a macro to do just that, and it works really well.

The problem is that I cannot change the register values if I am doing post-mortem debugging (from a core file). In such a case, I have no way to tell GDB to change its concept of what the current frame is, as all registers are considered read-only in that case.

Is there a way to tell GDB about my custom context management?

Shachar

Shachar Shemesh
  • 8,193
  • 6
  • 25
  • 57
  • Hi, i'm currently facing the same issue, have you found any solution to that ? I am looking into the `libthread-db` that can be passed to GDB, (see [doc](https://sourceware.org/gdb/onlinedocs/gdb/Threads.html)). Maybe it is possible to implement `gdb/common/gdb_thread_db.h` and then use this library but i am still struggling with this. Thanks! – d6bels Feb 11 '14 at 13:41
  • At this point in time, no solution, yet. I will look into what you suggested, though. – Shachar Shemesh Mar 03 '14 at 09:40
  • I have tried implementing a draft of this libthread_db that can interact with my custom thread's structure. So far I have come set some thread IDs and such attributes, but I am still stuck at finding out how to have GDB understanding the context and replace the threads where they were. – d6bels Mar 05 '14 at 14:34
  • I am also prodiving you with [my thread](http://stackoverflow.com/questions/18374474/how-does-gdb-know-about-threads) just in case something shows up there. – d6bels Mar 05 '14 at 14:50

1 Answers1

0

There's not a simple, built-in way to do this in gdb.

I think probably the simplest way would be to write a version of gdbserver that can read your core files and that presents your micro-threads to gdb as real threads. There's been at least one gdbserver out there that can read core files already, so maybe it isn't crazily hard. However, I couldn't really say for sure.

Tom Tromey
  • 21,507
  • 2
  • 45
  • 63