Re: [PATCH] Make only user-specified executable filenames sticky

Pedro Alves
2015-05-12T10:36:36Z

On 05/11/2015 09:23 PM, Doug Evans wrote:
> On Wed, May 6, 2015 at 3:26 AM, Gary Benson <gbenson@redhat.com> wrote:

>> This commit updates GDB to keep track of which executable filenames
>> were supplied by the user. When GDB might attempt to determine an
>> executable filename and one is already set, filenames determined by
>> GDB may be overridden but user-supplied filenames will not.
>
> I can imagine sometimes wanting either behaviour, depending on
> the situation.

Yeah, AFAICS, both examples you gave work the same before
and after Gary's patch.

> E.g., if I supply a file name do some stuff, and then change
> my mind or wish to investigate a difference process I may
> wish gdb to automagically pick up the file name of the new process.

In that case, one can use "file; attach PID".

That is, you can just unload the previous program, so that GDB picks
up the new one automatically on next attach.

Another way to handle that would be to leave the file loaded
in inferior 1, and switch to a new inferior to investigate
the other process.

> OTOH other times I may wish to override what gdb would
> automagically choose and supply my own file name.

That'd be "file PROGRAM; attach PID".

The difference is that with Gary's patch, "attach PID1; attach PID2"
just works, while today we don't even get a warning.
If for some odd reason, after Gary's patch, the user wants to force
the executable of PID1 on PID2, he can still do e.g.,
"info inferiors; file paste_program_name" before the second attach.

We don't have a command to get out of:

"file wrong_program; attach PID"

that is, a command to issue after the attach to re-fetch the program
name from the running process, without detaching first.
Though if we had a warning that printed the expected program name,
the user could copy/paste from that.

Thanks,
Pedro Alves