From: Vladimir Prus Date: Fri, 30 Jan 2009 18:43:05 +0000 (+0000) Subject: PR 8145. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=592375cda9444b66538fb4811db6094e37664847;p=binutils-gdb.git PR 8145. * thread.c (do_captured_list_thread_ids): Report the current thread id. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index cf6678edabb..a1f37c61119 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2009-01-30 Vladimir Prus + + PR 8145. + * thread.c (do_captured_list_thread_ids): Report the current + thread id. + 2009-01-30 Vladimir Prus * breakpoint.c (create_breakpoint, create_breakpoints) diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 8b3d084f1ca..69c9d20df66 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,9 @@ +2009-01-30 Vladimir Prus + + * gdb.texinfo (GDB/MI Thread Commands): Document the + 'current-thread-id' field. Remove the example with zero threads, + since current GDB won't ever report that if there's inferior. + 2009-01-30 Vladimir Prus * gdb.texinfo (GDB/MI Breakpoint Commands): Document the -d diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 9f545d5ff3a..166b84d5798 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -20513,23 +20513,11 @@ Part of @samp{info threads} supplies the same information. @subsubheading Example -No threads present, besides the main process: - -@smallexample -(gdb) --thread-list-ids -^done,thread-ids=@{@},number-of-threads="0" -(gdb) -@end smallexample - - -Several threads: - @smallexample (gdb) -thread-list-ids ^done,thread-ids=@{thread-id="3",thread-id="2",thread-id="1"@}, -number-of-threads="3" +current-thread-id="1",number-of-threads="3" (gdb) @end smallexample diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 9e636b927dd..3b3735c570a 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2009-01-30 Vladimir Prus + + * lib/mi-support.exp (et_mi_thread_list) + (check_mi_and_console_threads): Adjust for current thread in + -thread-list-ids output. + 2009-01-30 Vladimir Prus * gdb.mi/mi-break.exp (test_disabled_creation): New. diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp index 7822e665a2b..a85e373f4e9 100644 --- a/gdb/testsuite/lib/mi-support.exp +++ b/gdb/testsuite/lib/mi-support.exp @@ -1605,7 +1605,7 @@ proc get_mi_thread_list {name} { # ^done,thread-ids=[thread-id="1",thread-id="2",...],number-of-threads="N" # (gdb) mi_gdb_test "-thread-list-ids" \ - {.*\^done,thread-ids={(thread-id="[0-9]+"(,)?)+},number-of-threads="[0-9]+"} \ + {.*\^done,thread-ids={(thread-id="[0-9]+"(,)?)+},current-thread-id="[0-9]+",number-of-threads="[0-9]+"} \ "-thread_list_ids ($name)" set output {} @@ -1639,7 +1639,7 @@ proc check_mi_and_console_threads {name} { global expect_out mi_gdb_test "-thread-list-ids" \ - {.*\^done,thread-ids={(thread-id="[0-9]+"(,)*)+},number-of-threads="[0-9]+"} \ + {.*\^done,thread-ids={(thread-id="[0-9]+"(,)*)+},current-thread-id="[0-9]+",number-of-threads="[0-9]+"} \ "-thread-list-ids ($name)" set mi_output {} if {[info exists expect_out(buffer)]} { diff --git a/gdb/thread.c b/gdb/thread.c index 8a98b8ec4b6..1d6d9c4d8c6 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -410,6 +410,7 @@ do_captured_list_thread_ids (struct ui_out *uiout, void *arg) struct thread_info *tp; int num = 0; struct cleanup *cleanup_chain; + int current_thread = -1; prune_threads (); target_find_new_threads (); @@ -420,11 +421,18 @@ do_captured_list_thread_ids (struct ui_out *uiout, void *arg) { if (tp->state_ == THREAD_EXITED) continue; + + if (ptid_equal (tp->ptid, inferior_ptid)) + current_thread = tp->num; + num++; ui_out_field_int (uiout, "thread-id", tp->num); } do_cleanups (cleanup_chain); + + if (current_thread != -1) + ui_out_field_int (uiout, "current-thread-id", current_thread); ui_out_field_int (uiout, "number-of-threads", num); return GDB_RC_OK; }