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

Philippe Waroquiers
2015-06-07T11:40:39Z

On Fri, 2015-06-05 at 12:22 +0100, Gary Benson wrote:
> Built and regtested on RHEL6.6 x86_64.
I tested with the last SVN version of the Valgrind gdbserver (that
supports qXfer:exec-file:read+).

The patch introduces a regression:
with the patch, GDB does not anymore automatically load the
exec-file.

I bypassed this problem by ignoring fake_pid_p in remote.c:
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -1624,9 +1624,13 @@ remote_add_inferior (int fake_pid_p, int pid, int
attached,
inf->attach_flag = attached;
inf->fake_pid_p = fake_pid_p;

- /* If no main executable is currently open then attempt to
- open the file that was executed to create this inferior. */
- if (try_open_exec && get_exec_file (0) == NULL)
+ /* Attempt to open the file that was executed to create this
+ inferior. If the user has explicitly specified executable
+ and/or symbol files then warn the user if their choices do
+ not match. Otherwise, set exec_file and symfile_objfile to
+ the new file. */
+ printf("fake_pid_p %d\n", fake_pid_p);
+ if (try_open_exec)// && !fake_pid_p)
exec_file_locate_attach (pid, 1);

Effectively, the printf shows that with Valgrind gdbsrv,
fake_pid_p value is 1.

When ignoring fake_pid_p, GDB can properly attach
to different Valgrind gdbsrv, and changes of executable
as expected.

Philippe