diff options
author | Gary Benson <gbenson@redhat.com> | 2015-05-12 11:57:52 +0100 |
---|---|---|
committer | Gary Benson <gbenson@redhat.com> | 2015-05-12 11:57:52 +0100 |
commit | 835205d078aa3b78180da1512f8019ab064032e7 (patch) | |
tree | 61bf26b5330e9cd64d7aa6cb8281feb03f9e6948 /gdb/gdbserver | |
parent | 5b155b955ab0f4b6db3a5edb049f8e4d5a712f4a (diff) | |
download | binutils-gdb-835205d078aa3b78180da1512f8019ab064032e7.tar.gz |
Locate executables on remote stubs without multiprocess extensions
This commit allows GDB to determine filenames of main executables
when debugging using remote stubs without multiprocess extensions.
The qXfer:exec-file:read packet is extended to allow an empty
annex, with the meaning that the remote stub should supply the
filename of whatever it thinks is the current process.
gdb/ChangeLog:
* remote.c (remote_add_inferior): Call exec_file_locate_attach
for fake PIDs as well as real ones.
(remote_pid_to_exec_file): Send empty annex if PID is fake.
gdb/doc/ChangeLog:
* gdb.texinfo (General Query Packets): Document
qXfer:exec-file:read with empty annex.
gdb/gdbserver/ChangeLog:
* server.c (handle_qxfer_exec_file): Use current process
if annex is empty.
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r-- | gdb/gdbserver/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/gdbserver/server.c | 25 |
2 files changed, 25 insertions, 5 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index c33f90a10c3..94146b8f48b 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,8 @@ +2015-05-12 Gary Benson <gbenson@redhat.com> + + * server.c (handle_qxfer_exec_file): Use current process + if annex is empty. + 2015-05-08 Sandra Loosemore <sandra@codesourcery.com> * linux-nios2-low.c: Include elf/common.h. Adjust comments. diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index 3f9bb8938d6..174ab398b0b 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -1146,17 +1146,32 @@ handle_qxfer_exec_file (const char *const_annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, LONGEST len) { - char *annex, *file; + char *file; ULONGEST pid; int total_len; if (the_target->pid_to_exec_file == NULL || writebuf != NULL) return -2; - annex = alloca (strlen (const_annex) + 1); - strcpy (annex, const_annex); - annex = unpack_varlen_hex (annex, &pid); - if (annex[0] != '\0' || pid == 0) + if (const_annex[0] == '\0') + { + if (current_thread == NULL) + return -1; + + pid = pid_of (current_thread); + } + else + { + char *annex = alloca (strlen (const_annex) + 1); + + strcpy (annex, const_annex); + annex = unpack_varlen_hex (annex, &pid); + + if (annex[0] != '\0') + return -1; + } + + if (pid <= 0) return -1; file = (*the_target->pid_to_exec_file) (pid); |