diff options
author | Sergio Durigan Junior <sergiodj@redhat.com> | 2017-09-20 19:15:40 -0400 |
---|---|---|
committer | Sergio Durigan Junior <sergiodj@redhat.com> | 2017-10-04 02:01:45 -0400 |
commit | bc3b087de2401c65c02730d346e8bea4dc0504ae (patch) | |
tree | 49dff0f07ac85554669e8f7d807a4527743e7ab5 /gdb/doc | |
parent | d092c5a2465ece3435131ae6fef1ccb6e70986cb (diff) | |
download | binutils-gdb-bc3b087de2401c65c02730d346e8bea4dc0504ae.tar.gz |
Extend "set cwd" to work on gdbserver
This is the "natural" extension necessary for the "set cwd" command
(and the whole "set the inferior's cwd" logic) to work on gdbserver.
The idea here is to have a new remote packet, QSetWorkingDir (name
adopted from LLDB's extension to the RSP, as can be seen at
<https://raw.githubusercontent.com/llvm-mirror/lldb/master/docs/lldb-gdb-remote.txt>),
which sends an hex-encoded string representing the working directory
that the remote inferior will use. There is a slight difference from
the packet proposed by LLDB: GDB's version will accept empty
arguments, meaning that the user wants to clear the previously set
working directory for the inferior (i.e., "set cwd" without arguments
on GDB).
For UNIX-like targets this feature is already implemented on
nat/fork-inferior.c, and all gdbserver has to do is to basically
implement "set_inferior_cwd" and call it whenever such packet arrives.
For other targets, like Windows, it is possible to use the existing
"get_inferior_cwd" function and do the necessary steps to make sure
that the inferior will use the specified working directory.
Aside from that, the patch consists basically of updates to the
testcase (making it available on remote targets) and the
documentation.
No regressions found.
gdb/ChangeLog:
2017-10-04 Sergio Durigan Junior <sergiodj@redhat.com>
* NEWS (Changes since GDB 8.0): Add entry about new
'set-cwd-on-gdbserver' feature.
(New remote packets): Add entry for QSetWorkingDir.
* common/common-inferior.h (set_inferior_cwd): New prototype.
* infcmd.c (set_inferior_cwd): Remove "static".
(show_cwd_command): Expand text to include remote debugging.
* remote.c: Add PACKET_QSetWorkingDir.
(remote_protocol_features) <QSetWorkingDir>: New entry for
PACKET_QSetWorkingDir.
(extended_remote_set_inferior_cwd): New function.
(extended_remote_create_inferior): Call
"extended_remote_set_inferior_cwd".
(_initialize_remote): Call "add_packet_config_cmd" for
QSetWorkingDir.
gdb/gdbserver/ChangeLog:
2017-10-04 Sergio Durigan Junior <sergiodj@redhat.com>
* inferiors.c (set_inferior_cwd): New function.
* server.c (handle_general_set): Handle QSetWorkingDir packet.
(handle_query): Inform that QSetWorkingDir is supported.
* win32-low.c (create_process): Pass the inferior's cwd to
CreateProcess.
gdb/testsuite/ChangeLog:
2017-10-04 Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.base/set-cwd.exp: Make it available on
native-extended-gdbserver.
gdb/doc/ChangeLog:
2017-10-04 Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.texinfo (Starting your Program) <The working directory.>:
Mention remote debugging.
(Working Directory) <Your Program's Working Directory>:
Likewise.
(Connecting) <Remote Packet>: Add "set-working-dir"
and "QSetWorkingDir" to the table.
(Remote Protocol) <QSetWorkingDir>: New item, explaining the
packet.
Diffstat (limited to 'gdb/doc')
-rw-r--r-- | gdb/doc/ChangeLog | 11 | ||||
-rw-r--r-- | gdb/doc/gdb.texinfo | 36 |
2 files changed, 44 insertions, 3 deletions
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 4ded14ae2a0..e3ea4ec614e 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,6 +1,17 @@ 2017-10-04 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.texinfo (Starting your Program) <The working directory.>: + Mention remote debugging. + (Working Directory) <Your Program's Working Directory>: + Likewise. + (Connecting) <Remote Packet>: Add "set-working-dir" + and "QSetWorkingDir" to the table. + (Remote Protocol) <QSetWorkingDir>: New item, explaining the + packet. + +2017-10-04 Sergio Durigan Junior <sergiodj@redhat.com> + + * gdb.texinfo (Starting your Program) <The working directory.>: Mention new "set cwd" command. (Working Directory) <Your Program's Working Directory>: Rephrase to explain that "set cwd" exists and is the default diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index a68107dddb0..bfeb7a9a35d 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -2059,8 +2059,10 @@ your program. @xref{Environment, ,Your Program's Environment}. @item The @emph{working directory.} You can set your program's working directory with the command @kbd{set cwd}. If you do not set any working directory with this -command, your program will inherit @value{GDBN}'s working directory. -@xref{Working Directory, ,Your Program's Working Directory}. +command, your program will inherit @value{GDBN}'s working directory if +native debugging, or the remote server's working directory if remote +debugging. @xref{Working Directory, ,Your Program's Working +Directory}. @item The @emph{standard input and output.} Your program normally uses the same device for standard input and @@ -2439,7 +2441,9 @@ Each time you start your program with @code{run}, the inferior will be initialized with the current working directory specified by the @kbd{set cwd} command. If no directory has been specified by this command, then the inferior will inherit @value{GDBN}'s current working -directory as its working directory. +directory as its working directory if native debugging, or it will +inherit the remote server's current working directory if remote +debugging. @table @code @kindex set cwd @@ -21003,6 +21007,10 @@ are: @tab @code{QEnvironmentReset} @tab @code{Reset the inferior environment (i.e., unset user-set variables)} +@item @code{set-working-dir} +@tab @code{QSetWorkingDir} +@tab @code{set cwd} + @item @code{conditional-breakpoints-packet} @tab @code{Z0 and Z1} @tab @code{Support for target-side breakpoint condition evaluation} @@ -36860,6 +36868,28 @@ by supplying an appropriate @samp{qSupported} response actually support passing environment variables to the starting inferior. +@item QSetWorkingDir:@r{[}@var{directory}@r{]} +@anchor{QSetWorkingDir packet} +@cindex set working directory, remote request +@cindex @samp{QSetWorkingDir} packet +This packet is used to inform the remote server of the intended +current working directory for programs that are going to be executed. + +The packet is composed by @var{directory}, an hex encoded +representation of the directory that the remote inferior will use as +its current working directory. If @var{directory} is an empty string, +the remote server should reset the inferior's current working +directory to its original, empty value. + +This packet is only available in extended mode (@pxref{extended +mode}). + +Reply: +@table @samp +@item OK +The request succeeded. +@end table + @item qfThreadInfo @itemx qsThreadInfo @cindex list active threads, remote request |