This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v3 4/5] Implement "set cwd" command on GDB
On 09/22/2017 07:56 PM, Eli Zaretskii wrote:
> There's no contradiction between these two sides of this issue. For
> native debugging, host == target, so the host can expand. For the
> non-native debugging, you can ask the target to do the expansion and
> store the result.
You can't, not as the actual value of the setting, because the
setting can be tweaked before GDB is even connected to a target.
I.e., you can do:
(gdb) set cwd ~ # I haven't even connected to a target yet.
# Where should this be expanded?
# On host may be incorrect.
# '~' -> /home/pedro on this machine
(gdb) target extended-remote foo:9999
(gdb) start
error: /home/pedro does not exist
# '~' is /mount/home/pedro on 'foo'
(gdb) kill
(gdb) target extended-remote bar:9999
(gdb) start
error: /home/pedro does not exist
# '~' is /nfs/home/palves on 'bar'
It may be useful to display the expanded path as extra info,
like in:
(gdb) set cwd ~foo/bar
(gdb) show cwd
The current directory is ~foo/bar (/home/foo/bar)
^^^^^^^^^^^^^
though that'd require a new remote protocol packet.
> Either way IMO is better than expanding at run
> time, because the latter makes the expansion dependent on factors
> which could be out of the user control,
I don't see what the problem is here.
> and also requires every use
> of the value to call gdb_tilde_expand, thus wasting cycles.
I don't think that significant, compared to all the other
work / syscalls / remote protocol roundtrips that we have
to do to start a process.
Thanks,
Pedro Alves