This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2 5/5] Extend "set cwd" to work on gdbserver


On Wednesday, September 20 2017, I wrote:

> On Wednesday, September 20 2017, Pedro Alves wrote:
>
>> On 09/19/2017 05:28 AM, Sergio Durigan Junior wrote:
>>> 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 gdbserver is supposed to cd into before executing the inferior.
>>> The good thing is that since this feature is already implemented on
>>> nat/fork-inferior.c, all gdbserver has to do is to basically implement
>>> "set_inferior_cwd" and call it whenever such packet arrives.
>>> 
>>> Aside from that, the patch consists basically of updates to the
>>> testcase (making it available on remote targets) the documentation.
>>> 
>>> No regressions found.
>>> 
>>> gdb/ChangeLog:
>>> yyyy-mm-dd  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".
>>> 	* remote.c: Add PACKET_QSetWorkingDir.
>>> 	(remote_protocol_features) <QSetWorkingDir>: New entry for
>>> 	PACKET_QSetWorkingDir.
>>> 	(extended_remote_handle_inferior_cwd): New function.
>>> 	(extended_remote_create_inferior): Call
>>> 	"extended_remote_handle_inferior_cwd".
>>> 	(_initialize_remote): Call "add_packet_config_cmd" for
>>> 	QSetWorkingDir.
>>> 
>>> gdb/gdbserver/ChangeLog:
>>> yyyy-mm-dd  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 "inferior_cwd" to
>>> 	CreateProcess.
>>> 
>>> gdb/testsuite/ChangeLog:
>>> yyyy-mm-dd  Sergio Durigan Junior  <sergiodj@redhat.com>
>>> 
>>> 	* gdb.base/set-cwd.exp: Make it available on gdbserver.
>>> 
>>> gdb/doc/ChangeLog:
>>> yyyy-mm-dd  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.
>>> ---
>>>  gdb/NEWS                           | 11 ++++++++++
>>>  gdb/common/common-inferior.h       |  4 ++++
>>>  gdb/doc/gdb.texinfo                | 44 ++++++++++++++++++++++++++++++++++----
>>>  gdb/gdbserver/inferiors.c          |  9 ++++++++
>>>  gdb/gdbserver/server.c             | 18 +++++++++++++++-
>>>  gdb/gdbserver/win32-low.c          |  5 +++--
>>>  gdb/infcmd.c                       |  5 ++---
>>>  gdb/remote.c                       | 35 ++++++++++++++++++++++++++++++
>>>  gdb/testsuite/gdb.base/set-cwd.exp | 14 ++++++++----
>>>  9 files changed, 131 insertions(+), 14 deletions(-)
>>> 
>>> diff --git a/gdb/NEWS b/gdb/NEWS
>>> index 0dcfcc98af..a0f78e4c35 100644
>>> --- a/gdb/NEWS
>>> +++ b/gdb/NEWS
>>> @@ -39,6 +39,14 @@
>>>       variables that are to be set or unset from GDB.  These variables
>>>       will affect the environment to be passed to the inferior.
>>>  
>>> +  ** On Unix systems, GDBserver is now able to enter a directory
>>> +     before starting an inferior.
>>> +
>>> +     This is done by using the "cd" command in GDB, which instructs it
>>> +     to tell GDBserver about this directory change the next time an
>>> +     inferior is run.  If you want to make GDBserver enter the
>>> +     directory your GDB is currently in, you can do a "cd ." in GDB.
>>
>> This all looks stale to me.
>
> Indeed, sorry about this mistake.  I will rewrite the entry as follows:
>
> * New features in the GDB remote stub, GDBserver
>
>   ** GDBserver is now able to enter a directory before starting an
>      inferior.
>
>      The user can set the desired working directory to be used by the
>      remote inferior on GDB, using the new "set cwd" command, which
>      will instruct GDB to tell GDBserver about this directory change
>      the next time an inferior is run.

Actually, the first sentence is still wrong.  How about:

  ** GDBserver is now able to set the inferior's current working
     directory.

     The user can set the desired working directory to be used by the
     remote inferior on GDB, using the new "set cwd" command, which
     will instruct GDB to tell GDBserver about this directory change
     the next time an inferior is run.

?

-- 
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF  31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]