gdb: add threads debugging switch

Add new commands:

  set debug threads on|off
  show debug threads

Prints additional debug information relating to thread creation and
deletion.

GDB already announces when threads are created of course.... most of
the time, but sometimes threads are added silently, in which case this
debug message is the only mechanism to see the thread being added.
Also, though GDB does announce when a thread exits, it doesn't
announce when the thread object is deleted, I've added a debug message
for that.

Additionally, having message printed through the debug system will
cause the messages to be nested to an appropriate depth when other
debug sub-systems are turned on (especially things like `infrun` and
`lin-lwp`).
This commit is contained in:
Andrew Burgess
2021-11-12 10:30:27 +00:00
parent 85adb21d04
commit 5b0a3d6242
5 changed files with 63 additions and 0 deletions

View File

@@ -38,6 +38,16 @@ struct symtab;
struct inferior;
struct process_stratum_target;
/* When true, print debug messages related to GDB thread creation and
deletion. */
extern bool debug_threads;
/* Print a "threads" debug statement. */
#define threads_debug_printf(fmt, ...) \
debug_prefixed_printf_cond (debug_threads, "threads", fmt, ##__VA_ARGS__)
/* Frontend view of the thread state. Possible extensions: stepping,
finishing, until(ling),...
@@ -235,6 +245,7 @@ class thread_info : public refcounted_object,
{
public:
explicit thread_info (inferior *inf, ptid_t ptid);
~thread_info ();
bool deletable () const;