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 0/4] New "set cwd" command


On Tuesday, September 12 2017, Eli Zaretskii wrote:

>> From: Sergio Durigan Junior <sergiodj@redhat.com>
>> Cc: Pedro Alves <palves@redhat.com>
>> Date: Tue, 12 Sep 2017 00:23:21 -0400
>> 
>> This patch series is a followup of the discussion that happened at:
>> 
>>   https://sourceware.org/ml/gdb-patches/2017-09/msg00160.html
>> 
>> It implements a new GDB command, "set cwd", which is used to set the
>> current working directory of the inferior that will be started.  This
>> is a GDB-only command for now; its gdbserver counterpart will come
>> later.
>
> Can you summarize the idea, please?  (I didn't follow that
> discussion.)  Do we chdir into that directory each time before we
> run/resume the debuggee?  Or do we use the shell (in which case this
> is limited to Posix hosts)?  Or something else?

Sure.

The idea is that there are other inferior commands already, like "set
args" or "set environment", which function per-inferior.  However, the
current "cd" command doesn't, and this is not only a discrepancy but
also gets in the way of a future feature that will implemented: the
ability to tell gdbserver to cd into another directory before starting
the remote inferior.

GDB's cd_command uses chdir, but also uses tilde_expand, from readline,
to expand the path given by the user.  It also runs right when the user
invokes "cd" from the CLI.

The new "set cwd" command also uses chdir (i.e., no shell involved), but
because it is shared code between GDB and gdbserver, and because
gdbserver doesn't link against readline, it cannot use tilde_expand.
Therefore I had to import the "glob" module from gnulib. And also, this
specific chdir is only invoked after the call to fork/vfork on
fork_inferior, but before we actually execute the binary.

I hope I could clarify this for you, but please let me know if you have
more questions.

Thanks,

-- 
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]