gdb: don't use the global thread-id in the saved breakpoints file

I noticed that breakpoint::print_recreate_thread was printing the
global thread-id.  This function is used to implement the 'save
breakpoints' command, and should be writing out suitable CLI commands
for recreating the current breakpoints.  The CLI does not use global
thread-ids, but instead uses the inferior specific thread-ids,
e.g. "2.1".

After some discussion on the mailing list it was suggested that the
most consistent solution would be for the saved breakpoints file to
always contain the inferior-qualified thread-id, so the file would
include "thread 1.1" instead of just "thread 1", even when there is
only a single inferior.

So, this commit adds print_full_thread_id, which is just like the
existing print_thread_id, only it always prints the inferior-qualified
thread-id.

I then update the existing print_thread_id to make use of this new
function, and finally, I update  breakpoint::print_recreate_thread to
also use this new function.

There's a multi-inferior test that confirms the saved breakpoints file
correctly includes the fully-qualified thread-id, and I've also
updated the single inferior test gdb.base/save-bp.exp to have it
validate that the saved breakpoints file includes the
inferior-qualified thread-id, even for this single inferior case.
This commit is contained in:
Andrew Burgess
2023-02-08 13:56:22 +00:00
parent 834e4d7162
commit 442716d400
5 changed files with 86 additions and 6 deletions

View File

@@ -661,6 +661,10 @@ extern int show_inferior_qualified_tids (void);
circular static buffer, NUMCELLS deep. */
const char *print_thread_id (struct thread_info *thr);
/* Like print_thread_id, but always prints the inferior-qualified form,
even when there is only a single inferior. */
const char *print_full_thread_id (struct thread_info *thr);
/* Boolean test for an already-known ptid. */
extern bool in_thread_list (process_stratum_target *targ, ptid_t ptid);