Single stepping through threads

Kelly Yancey kelly at nttmcl.com
Tue Nov 30 18:52:13 PST 2004


   Is there a way to single-step (trap on the next instruction, not gdb's 
step) a single thread in a process without any remaining threads running 
concurrently *without* reimplementing gdb?  My application is not a full 
debugger; all it needs to do is single-step through an application. 
However, I need to be certain that every instruction that is executed (no 
matter which thread it is in) traps so my tracing process can inspect the 
state of the application.  My utility works fine for single-thread 
processes, but by my reading of kse_create(), new threads are created with 
the P_TRACED bit cleared meaning my utility has no control over them.
   It looks like the functionality I am after is provided by libthread_db, 
but it appears to require ps_global_lookup() to determine which threading 
library the application is using.  However, to implement 
ps_global_lookup() I would have to add logic to parse the symbol table in 
the target program, assuming it even has one.  Which gets me to the crux 
of my quandary: I'm not implementing a debugger, I don't particularly want 
to implement a debugger, and even if I did I cannot assume that the 
programs I am trying to trace have any debugging symbols.  So how do I 
control a multithreaded application?  As I see no special support for 
threads in truss(1), can I assume that procfs somehow avoids this issue?

   Thanks,

   Kelly



More information about the freebsd-threads mailing list