Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Report current thread in -thread-list-ids output
@ 2009-01-30 19:43 Vladimir Prus
  2009-01-30 21:10 ` Pedro Alves
  2009-01-30 21:51 ` Eli Zaretskii
  0 siblings, 2 replies; 4+ messages in thread
From: Vladimir Prus @ 2009-01-30 19:43 UTC (permalink / raw)
  To: gdb-patches, Eli Zaretskii

[-- Attachment #1: Type: text/plain, Size: 517 bytes --]


This patch makes the MI -thread-list-ids report the current thread.
It is advantageous for a frontend like Eclipse, that does not report
any details about a thread whatsoever except for the id, and whether
a thread is selected. If -thread-list-ids reports current thread, then
Eclipse can use -thread-list-ids as opposed to 'info thread', and be
a little bit faster.

The change in thread.c actually touches MI-only function, so I assume
I'm free to make this change. Eli, does the doc change look good?

- Volodya


[-- Attachment #2: thread_list_ids.diff --]
[-- Type: text/x-diff, Size: 2001 bytes --]

commit 52cc9bd1b3137c918c8ecd389d2059684b32a9a0
Author: Vladimir Prus <vladimir@codesourcery.com>
Date:   Fri Jan 30 19:34:11 2009 +0300

    Make -thread-list-ids report the current thread.
    
    	gdb/doc/
    	* 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.
    
    	gdb/
    	* thread.c (do_captured_list_thread_ids): Report the current
    	thread id.

diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 583d96c..9a4cd68 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -20497,23 +20497,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/thread.c b/gdb/thread.c
index 8a98b8e..1d6d9c4 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;
 }

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Report current thread in -thread-list-ids output
  2009-01-30 21:10 ` Pedro Alves
@ 2009-01-30 20:36   ` Pedro Alves
  0 siblings, 0 replies; 4+ messages in thread
From: Pedro Alves @ 2009-01-30 20:36 UTC (permalink / raw)
  To: gdb-patches; +Cc: Vladimir Prus, gdb-patches, Eli Zaretskii

On Friday 30 January 2009 16:39:42, Vladimir Prus wrote:
> 
> This patch makes the MI -thread-list-ids report the current thread.
> It is advantageous for a frontend like Eclipse, that does not report
> any details about a thread whatsoever except for the id, and whether
> a thread is selected. If -thread-list-ids reports current thread, then
> Eclipse can use -thread-list-ids as opposed to 'info thread', and be
> a little bit faster.
> 
> The change in thread.c actually touches MI-only function, so I assume
> I'm free to make this change.

In any case, it looks good to me.  This fixes PR8145,

<http://sourceware.org/bugzilla/show_bug.cgi?id=8145> .

> Eli, does the doc change look good? 

-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Report current thread in -thread-list-ids output
  2009-01-30 19:43 Report current thread in -thread-list-ids output Vladimir Prus
@ 2009-01-30 21:10 ` Pedro Alves
  2009-01-30 20:36   ` Pedro Alves
  2009-01-30 21:51 ` Eli Zaretskii
  1 sibling, 1 reply; 4+ messages in thread
From: Pedro Alves @ 2009-01-30 21:10 UTC (permalink / raw)
  To: gdb-patches; +Cc: Vladimir Prus, gdb-patches, Eli Zaretskii

On Friday 30 January 2009 16:39:42, Vladimir Prus wrote:
> 
> This patch makes the MI -thread-list-ids report the current thread.
> It is advantageous for a frontend like Eclipse, that does not report
> any details about a thread whatsoever except for the id, and whether
> a thread is selected. If -thread-list-ids reports current thread, then
> Eclipse can use -thread-list-ids as opposed to 'info thread', and be
> a little bit faster.
> 
> The change in thread.c actually touches MI-only function, so I assume
> I'm free to make this change.

In any case, it looks good to me.  This fixes PR8145,

<http://sourceware.org/bugzilla/show_bug.cgi?id=8145> .

> Eli, does the doc change look good? 

-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Report current thread in -thread-list-ids output
  2009-01-30 19:43 Report current thread in -thread-list-ids output Vladimir Prus
  2009-01-30 21:10 ` Pedro Alves
@ 2009-01-30 21:51 ` Eli Zaretskii
  1 sibling, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2009-01-30 21:51 UTC (permalink / raw)
  To: Vladimir Prus; +Cc: gdb-patches

> From: Vladimir Prus <vladimir@codesourcery.com>
> Date: Fri, 30 Jan 2009 19:39:42 +0300
> 
> Eli, does the doc change look good?

Yes, thanks.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-01-30 17:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-30 19:43 Report current thread in -thread-list-ids output Vladimir Prus
2009-01-30 21:10 ` Pedro Alves
2009-01-30 20:36   ` Pedro Alves
2009-01-30 21:51 ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox