+2015-05-12 Gary Benson <gbenson@redhat.com>
+
+ * 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.
+
2015-05-09 Siva Chandra Reddy <sivachandra@google.com>
* NEWS (Python Scripting): Mention the new gdb.Value methods.
+2015-05-12 Gary Benson <gbenson@redhat.com>
+
+ * gdb.texinfo (General Query Packets): Document
+ qXfer:exec-file:read with empty annex.
+
2015-05-09 Siva Chandra Reddy <sivachandra@google.com>
* python.texi (Values From Inferior): Add descriptions of new
Return the full absolute name of the file that was executed to create
a process running on the remote system. The annex specifies the
numeric process ID of the process to query, encoded as a hexadecimal
-number.
+number. If the annex part is empty the remote stub should return the
+filename corresponding to the currently executing process.
This packet is not probed by default; the remote stub must request it,
by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
+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.
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);
/* If no main executable is currently open then attempt to
open the file that was executed to create this inferior. */
- if (try_open_exec && !fake_pid_p && get_exec_file (0) == NULL)
+ if (try_open_exec && get_exec_file (0) == NULL)
exec_file_locate_attach (pid, 1);
return inf;
remote_pid_to_exec_file (struct target_ops *self, int pid)
{
static char *filename = NULL;
- char annex[9];
+ struct inferior *inf;
+ char *annex = NULL;
if (packet_support (PACKET_qXfer_exec_file) != PACKET_ENABLE)
return NULL;
if (filename != NULL)
xfree (filename);
- xsnprintf (annex, sizeof (annex), "%x", pid);
+ inf = find_inferior_pid (pid);
+ if (inf == NULL)
+ internal_error (__FILE__, __LINE__,
+ _("not currently attached to process %d"), pid);
+
+ if (!inf->fake_pid_p)
+ {
+ const int annex_size = 9;
+
+ annex = alloca (annex_size);
+ xsnprintf (annex, annex_size, "%x", pid);
+ }
+
filename = target_read_stralloc (¤t_target,
TARGET_OBJECT_EXEC_FILE, annex);