[PATCH v4 18/44] gdbserver: improve threads debug output for process general thread

Markus Metzger <[email protected]>
Newsgroups gmane.comp.gdb.patches
Message-ID <[email protected]>
Setting the general thread to a process produces

    [threads] set_desired_thread: did not find thread for general_thread <pid>.0.0, but found process

Handle that case separately in set_desired_thread() and produce

    [threads] set_desired_thread: did not find process for general_thread <pid>.0.0

if no such process can be found.
---
 gdbserver/target.cc | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 43ef421df74..d97d2334344 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -34,8 +34,20 @@ bool
 set_desired_thread ()
 {
   client_state &cs = get_client_state ();
-  thread_info *found = find_thread_ptid (cs.general_thread);
+  if (cs.general_thread.is_pid ())
+    {
+      process_info *proc = find_process_pid (cs.general_thread.pid ());
+      if (proc == nullptr)
+	{
+	  threads_debug_printf
+	    ("did not find process for general_thread %s",
+	     cs.general_thread.to_string ().c_str ());
+	}
+      switch_to_process (proc);
+      return false;
+    }
 
+  thread_info *found = find_thread_ptid (cs.general_thread);
   if (found == nullptr)
     {
       process_info *proc = find_process_pid (cs.general_thread.pid ());
-- 
2.43.0

________________________________________
Intel Deutschland GmbH 

Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany 

Tel: +49 (89) 99143-0 

www.intel.de 

Managing Directors: Candice Moore, Jeffrey Schneiderman, Ramachandran Sitaraman

Chairperson of the Supervisory Board: Sonja Pierer

Registered Seat: Munich Commercial Register B: Amtsgericht Munich HRB 186928

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.