This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Locate executables on remote stubs without multiprocess extensions
- From: Pedro Alves <palves at redhat dot com>
- To: Gary Benson <gbenson at redhat dot com>, gdb-patches at sourceware dot org
- Cc: Philippe Waroquiers <philippe dot waroquiers at skynet dot be>
- Date: Mon, 11 May 2015 15:37:28 +0100
- Subject: Re: [PATCH] Locate executables on remote stubs without multiprocess extensions
- Authentication-results: sourceware.org; auth=none
- References: <20150506103145 dot GA30896 at blade dot nx> <1430932230-12551-1-git-send-email-gbenson at redhat dot com> <20150506171647 dot GA12725 at blade dot nx>
On 05/06/2015 06:16 PM, Gary Benson wrote:
> Gary Benson wrote:
> @@ -11718,7 +11719,15 @@ remote_pid_to_exec_file (struct target_ops *self, int pid)
> if (filename != NULL)
> xfree (filename);
>
> - xsnprintf (annex, sizeof (annex), "%x", pid);
> + inf = find_inferior_pid (pid);
> + if (inf != NULL && !inf->fake_pid_p)
This will silently do the wrong thing (retrieve the exec file
of the server's current thread/process) if this method is ever
used to try to fetch the exec out of a process that we're
_not_ currently attached to. Maybe this should be:
if (inf == NULL)
internal_error (__FILE__, __LINE__,
"attempt to retrieve exec-file of not-debugged process");
if (!inf->fake_pid_p)
>> diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
>> index d2e20d9..516a311 100644
>> --- a/gdb/gdbserver/server.c
>> +++ b/gdb/gdbserver/server.c
>> @@ -1144,17 +1144,32 @@ handle_qxfer_exec_file (const char *const_annex,
>> gdb_byte *readbuf, const gdb_byte *writebuf,
>> ULONGEST offset, LONGEST len)
>> {
>> - char *annex, *file;
>> + char *file;
>> ULONGEST pid;
>> int total_len;
>>
>> if (the_target->pid_to_exec_file == NULL || writebuf != NULL)
>> return -2;
>>
>> - annex = alloca (strlen (const_annex) + 1);
>> - strcpy (annex, const_annex);
>> - annex = unpack_varlen_hex (annex, &pid);
>> - if (annex[0] != '\0' || pid == 0)
>> + if (const_annex[0] == '\0')
>> + {
>> + if (current_thread == NULL)
>> + return -1;
>> +
>> + pid = pid_of (current_thread);
>> + }
>> + else
>> + {
>> + char *annex = alloca (strlen (const_annex) + 1);
>> +
>> + strcpy (annex, const_annex);
>> + annex = unpack_varlen_hex (annex, &pid);
>> +
>> + if (annex[0] != '\0')
>> + return -1;
>> + }
>> +
>> + if (pid < 0)
>> return -1;
>
> Oops, this should be "<=".
This is OK with that change and the point above addressed.
Thanks,
Pedro Alves