[2/3] gdb: show task number in describe_other_breakpoints

Message ID 8716dc72011765a13c3eee0b60a262fbcbd48d41.1675869497.git.aburgess@redhat.com
State New
Headers
Series Avoid printing global thread-id in CLI command output |

Commit Message

Andrew Burgess Feb. 8, 2023, 3:23 p.m. UTC
  I noticed that describe_other_breakpoints doesn't show the task
number, but does show the thread-id.  I can't see any reason why we'd
want to not show the task number in this situation, so this commit
adds this missing information, and extends gdb.ada/tasks.exp to check
this case.
---
 gdb/breakpoint.c                |  2 ++
 gdb/testsuite/gdb.ada/tasks.exp | 17 +++++++++++------
 2 files changed, 13 insertions(+), 6 deletions(-)
  

Comments

Pedro Alves Feb. 8, 2023, 5:55 p.m. UTC | #1
On 2023-02-08 3:23 p.m., Andrew Burgess via Gdb-patches wrote:

>  # Now, insert a breakpoint that should stop only if task 3 stops, and
> -# extract its number.
> -gdb_breakpoint "break_me task 3" message
> -set bp_number [get_integer_valueof "\$bpnum" -1]
> -if {$bp_number < 0} {
> -    return
> -}
> +# extract its number.  Use gdb_test here so that we can validate that
> +# the 'Breakpoint ... also set at' line correctly includes the task
> +# number of the prevoius breakpoint.

prevoius -> previous

Otherwise,
 
 Approved-By: Pedro Alves <pedro@palves.net>

Thanks,
Pedro Alves

> +gdb_test "break break_me task 3" \
> +    [multi_line \
> +	 "Note: breakpoint $bp_number \\(task 1\\) also set at pc $hex\\." \
> +	 "Breakpoint $decimal at $hex: \[^\r\n\]+"]
> +set bp_number [get_integer_valueof "\$bpnum" "INVALID" \
> +		   "get number of breakpoint for task 3"]
>  gdb_test "info breakpoints" "foo.adb:${decimal}\r\n\\s+stop only in task 3" \
>      "check info breakpoints for task 3 breakpoint"
>  
>
  
Andrew Burgess Feb. 11, 2023, 5:42 p.m. UTC | #2
Pedro Alves <pedro@palves.net> writes:

> On 2023-02-08 3:23 p.m., Andrew Burgess via Gdb-patches wrote:
>
>>  # Now, insert a breakpoint that should stop only if task 3 stops, and
>> -# extract its number.
>> -gdb_breakpoint "break_me task 3" message
>> -set bp_number [get_integer_valueof "\$bpnum" -1]
>> -if {$bp_number < 0} {
>> -    return
>> -}
>> +# extract its number.  Use gdb_test here so that we can validate that
>> +# the 'Breakpoint ... also set at' line correctly includes the task
>> +# number of the prevoius breakpoint.
>
> prevoius -> previous
>
> Otherwise,
>  
>  Approved-By: Pedro Alves <pedro@palves.net>

Fixed the typo and pushed.

Thanks,
Andrew
  

Patch

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 701555a060e..6b576859592 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -7049,6 +7049,8 @@  describe_other_breakpoints (struct gdbarch *gdbarch,
 		struct thread_info *thr = find_thread_global_id (b->thread);
 		gdb_printf (" (thread %s)", print_thread_id (thr));
 	      }
+	    else if (b->task != 0)
+	      gdb_printf (" (task %d)", b->task);
 	    gdb_printf ("%s%s ",
 			((b->enable_state == bp_disabled
 			  || b->enable_state == bp_call_disabled)
diff --git a/gdb/testsuite/gdb.ada/tasks.exp b/gdb/testsuite/gdb.ada/tasks.exp
index 88ef123865b..83692054e4f 100644
--- a/gdb/testsuite/gdb.ada/tasks.exp
+++ b/gdb/testsuite/gdb.ada/tasks.exp
@@ -50,16 +50,21 @@  gdb_test "watch j task 1 task 3" "You can specify only one task\\."
 # breakpoint in the list that matched the triggered-breakpoint's
 # address, no matter which task it was specific to.
 gdb_test "break break_me task 1" "Breakpoint .* at .*"
+set bp_number [get_integer_valueof "\$bpnum" "INVALID" \
+		   "get number of breakpoint for task 1"]
 gdb_test "info breakpoints" "foo.adb:${decimal}\r\n\\s+stop only in task 1" \
     "check info breakpoints for task 1 breakpoint"
 
 # Now, insert a breakpoint that should stop only if task 3 stops, and
-# extract its number.
-gdb_breakpoint "break_me task 3" message
-set bp_number [get_integer_valueof "\$bpnum" -1]
-if {$bp_number < 0} {
-    return
-}
+# extract its number.  Use gdb_test here so that we can validate that
+# the 'Breakpoint ... also set at' line correctly includes the task
+# number of the prevoius breakpoint.
+gdb_test "break break_me task 3" \
+    [multi_line \
+	 "Note: breakpoint $bp_number \\(task 1\\) also set at pc $hex\\." \
+	 "Breakpoint $decimal at $hex: \[^\r\n\]+"]
+set bp_number [get_integer_valueof "\$bpnum" "INVALID" \
+		   "get number of breakpoint for task 3"]
 gdb_test "info breakpoints" "foo.adb:${decimal}\r\n\\s+stop only in task 3" \
     "check info breakpoints for task 3 breakpoint"