From: Gary Benson <gbenson@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 5/7] Implement remote_pid_to_exec_file using qXfer:exec-file:read
Date: Wed, 01 Apr 2015 11:29:00 -0000 [thread overview]
Message-ID: <1427887341-31819-6-git-send-email-gbenson@redhat.com> (raw)
In-Reply-To: <1427887341-31819-1-git-send-email-gbenson@redhat.com>
This commit adds a new packet "qXfer:exec-file:read" to the remote
protocol that can be used to obtain the pathname of the file that
was executed to create a process on the remote system. Support for
this packet is added to GDB and remote_ops.to_pid_to_exec_file is
implemented using it.
gdb/ChangeLog:
* target.h (TARGET_OBJECT_EXEC_FILE): New enum value.
* remote.c (PACKET_qXfer_exec_file): Likewise.
(remote_protocol_features): Register the
"qXfer:exec-file:read" feature.
(remote_xfer_partial): Handle TARGET_OBJECT_EXEC_FILE.
(remote_pid_to_exec_file): New function.
(init_remote_ops): Initialize to_pid_to_exec_file.
(_initialize_remote): Register new "set/show remote
pid-to-exec-file-packet" command.
* NEWS: Announce new qXfer:exec-file:read packet.
gdb/doc/ChangeLog:
* gdb.texinfo (Remote Configuration): Document the "set/show
remote pid-to-exec-file-packet" command.
(General Query Packets): Document the qXfer:exec-file:read
qSupported features. Document the qXfer:exec-file:read packet.
---
gdb/ChangeLog | 13 +++++++++++++
gdb/NEWS | 4 ++++
gdb/doc/ChangeLog | 7 +++++++
gdb/doc/gdb.texinfo | 22 ++++++++++++++++++++++
gdb/remote.c | 35 +++++++++++++++++++++++++++++++++++
gdb/target.h | 7 ++++++-
6 files changed, 87 insertions(+), 1 deletions(-)
diff --git a/gdb/NEWS b/gdb/NEWS
index dec60cb..1486acb 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -90,6 +90,10 @@ hwbreak stop reason
vFile:fstat:
Return information about files on the remote system.
+qXfer:exec-file:read
+ Return the pathname of the file that was executed to create a
+ process running on the remote system.
+
* The info record command now shows the recording format and the
branch tracing configuration for the current thread when using
the btrace record target.
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 692d70e..3c4e47a 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -19677,6 +19677,10 @@ are:
@tab @code{Z4}
@tab @code{awatch}
+@item @code{pid-to-exec-file}
+@tab @code{qXfer:exec-file:read}
+@tab @code{attach}, @code{run}
+
@item @code{target-features}
@tab @code{qXfer:features:read}
@tab @code{set architecture}
@@ -35900,6 +35904,11 @@ These are the currently defined stub features and their properties:
@tab @samp{-}
@tab Yes
+@item @samp{qXfer:exec-file:read}
+@tab No
+@tab @samp{-}
+@tab Yes
+
@item @samp{qXfer:features:read}
@tab No
@tab @samp{-}
@@ -36103,6 +36112,10 @@ packet (@pxref{qXfer btrace read}).
The remote stub understands the @samp{qXfer:btrace-conf:read}
packet (@pxref{qXfer btrace-conf read}).
+@item qXfer:exec-file:read
+The remote stub understands the @samp{qXfer:exec-file:read} packet
+(@pxref{qXfer executable filename read}).
+
@item qXfer:features:read
The remote stub understands the @samp{qXfer:features:read} packet
(@pxref{qXfer target description read}).
@@ -36417,6 +36430,15 @@ Return a description of the current branch trace configuration.
This packet is not probed by default; the remote stub must request it
by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
+@item qXfer:exec-file:read:@var{annex}:@var{offset},@var{length}
+@anchor{qXfer executable filename read}
+Return the pathname 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.
+
+This packet is not probed by default; the remote stub must request it,
+by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
+
@item qXfer:features:read:@var{annex}:@var{offset},@var{length}
@anchor{qXfer target description read}
Access the @dfn{target description}. @xref{Target Descriptions}. The
diff --git a/gdb/remote.c b/gdb/remote.c
index 69a67a8..a307e68 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -1252,6 +1252,7 @@ enum {
PACKET_vFile_fstat,
PACKET_qXfer_auxv,
PACKET_qXfer_features,
+ PACKET_qXfer_exec_file,
PACKET_qXfer_libraries,
PACKET_qXfer_libraries_svr4,
PACKET_qXfer_memory_map,
@@ -3963,6 +3964,8 @@ static const struct protocol_feature remote_protocol_features[] = {
{ "PacketSize", PACKET_DISABLE, remote_packet_size, -1 },
{ "qXfer:auxv:read", PACKET_DISABLE, remote_supported_packet,
PACKET_qXfer_auxv },
+ { "qXfer:exec-file:read", PACKET_DISABLE, remote_supported_packet,
+ PACKET_qXfer_exec_file },
{ "qXfer:features:read", PACKET_DISABLE, remote_supported_packet,
PACKET_qXfer_features },
{ "qXfer:libraries:read", PACKET_DISABLE, remote_supported_packet,
@@ -9035,6 +9038,11 @@ remote_xfer_partial (struct target_ops *ops, enum target_object object,
len, xfered_len,
&remote_protocol_packets[PACKET_qXfer_btrace_conf]);
+ case TARGET_OBJECT_EXEC_FILE:
+ return remote_read_qxfer (ops, "exec-file", annex, readbuf, offset,
+ len, xfered_len,
+ &remote_protocol_packets[PACKET_qXfer_exec_file]);
+
default:
return TARGET_XFER_E_IO;
}
@@ -11642,6 +11650,29 @@ remote_load (struct target_ops *self, const char *name, int from_tty)
generic_load (name, from_tty);
}
+/* Accepts an integer PID; returns a string representing a file that
+ can be opened on the remote side to get the symbols for the child
+ process. Returns NULL if the operation is not supported. */
+
+static char *
+remote_pid_to_exec_file (struct target_ops *self, int pid)
+{
+ static char *filename = NULL;
+ char annex[9];
+
+ if (packet_support (PACKET_qXfer_exec_file) != PACKET_ENABLE)
+ return NULL;
+
+ if (filename != NULL)
+ xfree (filename);
+
+ xsnprintf (annex, sizeof (annex), "%x", pid);
+ filename = target_read_stralloc (¤t_target,
+ TARGET_OBJECT_EXEC_FILE, annex);
+
+ return filename;
+}
+
static void
init_remote_ops (void)
{
@@ -11691,6 +11722,7 @@ Specify the serial device it is connected to\n\
remote_ops.to_stop = remote_stop;
remote_ops.to_xfer_partial = remote_xfer_partial;
remote_ops.to_rcmd = remote_rcmd;
+ remote_ops.to_pid_to_exec_file = remote_pid_to_exec_file;
remote_ops.to_log_command = serial_log_command;
remote_ops.to_get_thread_local_address = remote_get_thread_local_address;
remote_ops.to_stratum = process_stratum;
@@ -12219,6 +12251,9 @@ Show the maximum size of the address (in bits) in a memory packet."), NULL,
add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_auxv],
"qXfer:auxv:read", "read-aux-vector", 0);
+ add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_exec_file],
+ "qXfer:exec-file:read", "pid-to-exec-file", 0);
+
add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_features],
"qXfer:features:read", "target-features", 0);
diff --git a/gdb/target.h b/gdb/target.h
index 01ec5f5..693379a 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -204,7 +204,12 @@ enum target_object
/* Branch trace data, in XML format. */
TARGET_OBJECT_BTRACE,
/* Branch trace configuration, in XML format. */
- TARGET_OBJECT_BTRACE_CONF
+ TARGET_OBJECT_BTRACE_CONF,
+ /* The pathname of the executable file that was run to create
+ a specified process. ANNEX should be a string representation
+ of the process ID of the process in question, in hexadecimal
+ format. */
+ TARGET_OBJECT_EXEC_FILE,
/* Possible future objects: TARGET_OBJECT_FILE, ... */
};
--
1.7.1
next prev parent reply other threads:[~2015-04-01 11:29 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-01 11:22 [PATCH 0/7] Do not require "file" commands for remote targets Gary Benson
2015-04-01 11:22 ` [PATCH 1/7] Introduce exec_file_locate_attach Gary Benson
2015-04-01 11:22 ` [PATCH 2/7] Introduce exec_file_find Gary Benson
2015-04-01 11:22 ` [PATCH 3/7] Use gdb_sysroot for main executable on attach Gary Benson
2015-04-01 14:53 ` Eli Zaretskii
2015-04-15 12:45 ` Gary Benson
2015-04-15 10:43 ` Pedro Alves
2015-04-01 11:27 ` [PATCH 4/7] Introduce linux_pid_to_exec_file Gary Benson
2015-04-06 16:41 ` Doug Evans
2015-04-07 9:07 ` Gary Benson
2015-04-08 3:15 ` Doug Evans
2015-04-08 8:06 ` Gary Benson
2015-04-15 9:37 ` Pedro Alves
2015-04-15 13:14 ` [PATCH 4/7 v2] Introduce linux_proc_pid_to_exec_file Gary Benson
2015-04-15 16:01 ` Pedro Alves
2015-04-01 11:29 ` Gary Benson [this message]
2015-04-01 14:55 ` [PATCH 5/7] Implement remote_pid_to_exec_file using qXfer:exec-file:read Eli Zaretskii
2015-04-06 17:00 ` Doug Evans
2015-04-06 17:21 ` Eli Zaretskii
2015-04-06 21:57 ` Doug Evans
2015-04-07 6:09 ` Eli Zaretskii
2015-04-07 9:08 ` Gary Benson
2015-04-08 1:57 ` Doug Evans
2015-04-08 6:00 ` Eli Zaretskii
2015-04-01 11:30 ` [PATCH 6/7] Implement qXfer:exec-file:read in gdbserver Gary Benson
2015-04-06 17:11 ` Doug Evans
2015-04-07 9:19 ` Gary Benson
2015-04-17 23:43 ` Possible regression on gdb.base/attach.exp when using native-extended-gdbserver (was: Re: [PATCH 6/7] Implement qXfer:exec-file:read in gdbserver) Sergio Durigan Junior
2015-04-20 9:13 ` Gary Benson
2015-04-20 10:41 ` [OB PATCH] Fix three test failures with extended remote targets Gary Benson
2015-04-01 11:39 ` [PATCH 7/7] Access executable from remote system when first inferior appears Gary Benson
2015-04-15 10:24 ` Pedro Alves
2015-04-15 13:56 ` Gary Benson
2015-04-15 14:06 ` Gary Benson
2015-04-15 16:15 ` Pedro Alves
2015-04-15 16:09 ` Pedro Alves
2015-04-16 8:23 ` Gary Benson
2015-04-15 16:13 ` Pedro Alves
2015-04-16 9:30 ` Gary Benson
2015-04-16 9:53 ` Pedro Alves
2015-04-16 11:47 ` Gary Benson
2015-04-16 15:06 ` Eli Zaretskii
2015-04-16 15:23 ` Pedro Alves
2015-04-16 15:05 ` Eli Zaretskii
2015-04-16 19:34 ` Gary Benson
2015-04-15 16:21 ` Eli Zaretskii
2015-04-15 10:47 ` [PATCH 0/7] Do not require "file" commands for remote targets Pedro Alves
2015-04-15 12:02 ` Gary Benson
2015-04-15 12:16 ` Pedro Alves
2015-04-15 14:16 ` Gary Benson
2015-04-15 16:20 ` Pedro Alves
2015-04-17 9:01 ` Gary Benson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1427887341-31819-6-git-send-email-gbenson@redhat.com \
--to=gbenson@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox