|
|
0b42f8 |
Locate executables on remote stubs without multiprocess extensions
|
|
|
0b42f8 |
|
|
|
0b42f8 |
From: Gary Benson <gbenson@redhat.com>
|
|
|
0b42f8 |
|
|
|
0b42f8 |
This commit allows GDB to determine filenames of main executables
|
|
|
0b42f8 |
when debugging using remote stubs without multiprocess extensions.
|
|
|
0b42f8 |
The qXfer:exec-file:read packet is extended to allow an empty
|
|
|
0b42f8 |
annex, with the meaning that the remote stub should supply the
|
|
|
0b42f8 |
filename of whatever it thinks is the current process.
|
|
|
0b42f8 |
|
|
|
0b42f8 |
gdb/ChangeLog:
|
|
|
0b42f8 |
|
|
|
0b42f8 |
* remote.c (remote_add_inferior): Call exec_file_locate_attach
|
|
|
0b42f8 |
for fake PIDs as well as real ones.
|
|
|
0b42f8 |
(remote_pid_to_exec_file): Send empty annex if PID is fake.
|
|
|
0b42f8 |
|
|
|
0b42f8 |
gdb/doc/ChangeLog:
|
|
|
0b42f8 |
|
|
|
0b42f8 |
* gdb.texinfo (General Query Packets): Document
|
|
|
0b42f8 |
qXfer:exec-file:read with empty annex.
|
|
|
0b42f8 |
|
|
|
0b42f8 |
gdb/gdbserver/ChangeLog:
|
|
|
0b42f8 |
|
|
|
0b42f8 |
* server.c (handle_qxfer_exec_file): Use current process
|
|
|
0b42f8 |
if annex is empty.
|
|
|
0b42f8 |
---
|
|
|
0b42f8 |
gdb/gdbserver/server.c | 26 +++++++++++++++++++++-----
|
|
|
0b42f8 |
1 file changed, 21 insertions(+), 5 deletions(-)
|
|
|
0b42f8 |
|
|
|
0b42f8 |
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
|
|
|
0b42f8 |
index 78cf155..c1719da 100644
|
|
|
0b42f8 |
--- a/gdb/gdbserver/server.c
|
|
|
0b42f8 |
+++ b/gdb/gdbserver/server.c
|
|
|
0b42f8 |
@@ -29,6 +29,7 @@
|
|
|
0b42f8 |
#endif
|
|
|
0b42f8 |
#include "gdb_wait.h"
|
|
|
0b42f8 |
#include "btrace-common.h"
|
|
|
0b42f8 |
+#include "linux-low.h"
|
|
|
0b42f8 |
|
|
|
0b42f8 |
/* The thread set with an `Hc' packet. `Hc' is deprecated in favor of
|
|
|
0b42f8 |
`vCont'. Note the multi-process extensions made `vCont' a
|
|
|
0b42f8 |
@@ -1012,17 +1013,32 @@ handle_qxfer_exec_file (const char *const_annex,
|
|
|
0b42f8 |
gdb_byte *readbuf, const gdb_byte *writebuf,
|
|
|
0b42f8 |
ULONGEST offset, LONGEST len)
|
|
|
0b42f8 |
{
|
|
|
0b42f8 |
- char *annex, *file;
|
|
|
0b42f8 |
+ char *file;
|
|
|
0b42f8 |
ULONGEST pid;
|
|
|
0b42f8 |
int total_len;
|
|
|
0b42f8 |
|
|
|
0b42f8 |
if (the_target->pid_to_exec_file == NULL || writebuf != NULL)
|
|
|
0b42f8 |
return -2;
|
|
|
0b42f8 |
|
|
|
0b42f8 |
- annex = alloca (strlen (const_annex) + 1);
|
|
|
0b42f8 |
- strcpy (annex, const_annex);
|
|
|
0b42f8 |
- annex = unpack_varlen_hex (annex, &pid;;
|
|
|
0b42f8 |
- if (annex[0] != '\0' || pid == 0)
|
|
|
0b42f8 |
+ if (const_annex[0] == '\0')
|
|
|
0b42f8 |
+ {
|
|
|
0b42f8 |
+ if (current_inferior == NULL)
|
|
|
0b42f8 |
+ return -1;
|
|
|
0b42f8 |
+
|
|
|
0b42f8 |
+ pid = ptid_get_pid (current_inferior->entry.id);
|
|
|
0b42f8 |
+ }
|
|
|
0b42f8 |
+ else
|
|
|
0b42f8 |
+ {
|
|
|
0b42f8 |
+ char *annex = alloca (strlen (const_annex) + 1);
|
|
|
0b42f8 |
+
|
|
|
0b42f8 |
+ strcpy (annex, const_annex);
|
|
|
0b42f8 |
+ annex = unpack_varlen_hex (annex, &pid;;
|
|
|
0b42f8 |
+
|
|
|
0b42f8 |
+ if (annex[0] != '\0')
|
|
|
0b42f8 |
+ return -1;
|
|
|
0b42f8 |
+ }
|
|
|
0b42f8 |
+
|
|
|
0b42f8 |
+ if (pid <= 0)
|
|
|
0b42f8 |
return -1;
|
|
|
0b42f8 |
|
|
|
0b42f8 |
file = (*the_target->pid_to_exec_file) (pid);
|