[PATCH v4 16/44] gdb: use process in xfer_partial if inferior_ptid is null_ptid

Markus Metzger <[email protected]>
Newsgroups gmane.comp.gdb.patches
Message-ID <[email protected]>
Some objects we want to xfer are per-process and do not necessarily
require a thread, e.g. the target description or libraries.

If we have not selected a thread, i.e. inferior_ptid is null_ptid, fall
back to the process for setting the general thread.  This allows fetching
those per-process objects.

This is in preparation for allowing inferiors without threads.
---
 gdb/remote.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/gdb/remote.c b/gdb/remote.c
index 05cda9d0b0c..50e90ad8440 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -12237,8 +12237,17 @@ remote_target::xfer_partial (enum target_object object,
   int unit_size
     = gdbarch_addressable_memory_unit_size (current_inferior ()->arch ());
 
+  /* Some objects require a thread, whereas others only require a process.
+     If we have no current thread, use the current process, instead.  */
+  ptid_t ptid = inferior_ptid;
+  if (ptid == null_ptid)
+    {
+      inferior *inf = current_inferior ();
+      if (inf != nullptr)
+	ptid = ptid_t (inf->pid);
+    }
   set_remote_traceframe ();
-  set_general_thread (inferior_ptid);
+  set_general_thread (ptid);
 
   rs = get_remote_state ();
 
-- 
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.