[PATCH v4 15/44] gdbserver: check process when we need a process
Markus Metzger <[email protected]>
| Newsgroups | gmane.comp.gdb.patches |
|---|---|
| Message-ID | <[email protected]> |
Many qXfer features deal with process properties but check that there is a
current thread. Check that we have a current process, instead. This is
clearer and allows later patches to remove the need for having a thread.
---
gdbserver/server.cc | 16 +++++++++-------
gdbserver/tdesc.cc | 5 +++--
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index 13a806421a0..a7e976c0f75 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -1810,11 +1810,11 @@ handle_qxfer_auxv (const char *annex,
if (!the_target->supports_read_auxv () || writebuf != NULL)
return -2;
- if (annex[0] != '\0' || current_thread == NULL)
+ process_info *process = current_process ();
+ if (annex[0] != '\0' || process == nullptr)
return -1;
- return the_target->read_auxv (current_thread->id.pid (), offset, readbuf,
- len);
+ return the_target->read_auxv (process->pid, offset, readbuf, len);
}
/* Handle qXfer:exec-file:read. */
@@ -1832,10 +1832,11 @@ handle_qxfer_exec_file (const char *annex,
if (annex[0] == '\0')
{
- if (current_thread == NULL)
+ process_info *process = current_process ();
+ if (process == nullptr)
return -1;
- pid = current_thread->id.pid ();
+ pid = process->pid;
}
else
{
@@ -1876,7 +1877,7 @@ handle_qxfer_features (const char *annex,
if (writebuf != NULL)
return -2;
- if (!target_running ())
+ if (!current_process ())
return -1;
/* Grab the correct annex. */
@@ -1906,7 +1907,8 @@ handle_qxfer_libraries (const char *annex,
if (writebuf != NULL)
return -2;
- if (annex[0] != '\0' || current_thread == NULL)
+ process_info *process = current_process ();
+ if (annex[0] != '\0' || process == nullptr)
return -1;
std::string document = "<library-list version=\"1.0\">\n";
diff --git a/gdbserver/tdesc.cc b/gdbserver/tdesc.cc
index cb8aad84f54..bf49f3a8b53 100644
--- a/gdbserver/tdesc.cc
+++ b/gdbserver/tdesc.cc
@@ -127,10 +127,11 @@ copy_target_description (struct target_desc *dest,
const struct target_desc *
current_target_desc (void)
{
- if (current_thread == NULL)
+ process_info *process = current_process ();
+ if (process == nullptr)
return &default_description;
- return current_process ()->tdesc;
+ return process->tdesc;
}
/* An empty structure. */
--
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.