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 v3 4/5] Implement "set cwd" command on GDB


> Cc: sergiodj@redhat.com, gdb-patches@sourceware.org
> From: Pedro Alves <palves@redhat.com>
> Date: Wed, 27 Sep 2017 15:01:58 +0100
> 
> Let's say that GDB keeps track of the desired cwd for the inferior
> as a single string, like Sergio's patch is doing.  Say the user does:
> 
>  $ gdb
>  (gdb) file program
>  (gdb) set cwd ~
> 
> At this point, GDB it not "connected" to any target yet.  However,
> if the user types "run", GDB automatically uses the native
> target to run the inferior.  So typing "run" after the above is
> equivalent to:
> 
>  $ gdb
>  (gdb) file program
>  (gdb) set cwd ~
>  (gdb) target native
>  (gdb) run
> 
> OK, now the question is, when to expand that '~'.  If it is
> expanded immediately at "set cwd" time, then we end up expanding
> it incorrectly in case the user actually wanted to debug remotely:

How about expanding it as part of "target FOO"?

> If GDB does not expand the set cwd path ever except internally
> when starting the inferior, then the problems shown just above
> never happen.

But that's an illusory advantage, isn't it?  Because we then keep "~",
but it expands to something different for every target, and the user
has no way of knowing what that will do on another target.  Moreover,
the user might not even want to have a different expansion for each
target.

>  $ gdb
>  (gdb) file program
>  (gdb) set cwd ~
>  (gdb) show cwd
>  cwd is: ~   
>  expands to /home/pedro on current target
>  (gdb) start
>  (gdb) show cwd
>  cwd is: ~   
>  expands to /home/pedro on current target
>  (gdb) kill
>  (gdb) target extended-remote foo:12345
>  (gdb) show cwd
>  cwd is: ~
>  expands to /mnt/home/palves on current target
>  (gdb) disconnect
>  (gdb) target extended-remote bar:12345
>  (gdb) show cwd
>  cwd is: ~   
>  expands to /nfs/homes/pedro on current target
> 
> I'm not sure it's worth the trouble to show the
> expansions like this.  But if we make GDB _not_ expand
> the "set cwd" setting's value itself, as I was proposing,
> then we can always come back and improve GDB's output like
> above, to inform the user what the setting expands to,
> as extra info.

Maybe making "show cwd" expand in the right context would be a good
middle-ground.


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