From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 130662 invoked by alias); 11 May 2015 14:37:36 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 130652 invoked by uid 89); 11 May 2015 14:37:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 11 May 2015 14:37:34 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t4BEbUpk024579 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 11 May 2015 10:37:30 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t4BEbSo3026101; Mon, 11 May 2015 10:37:29 -0400 Message-ID: <5550BEA8.6070602@redhat.com> Date: Mon, 11 May 2015 14:37:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Gary Benson , gdb-patches@sourceware.org CC: Philippe Waroquiers Subject: Re: [PATCH] Locate executables on remote stubs without multiprocess extensions References: <20150506103145.GA30896@blade.nx> <1430932230-12551-1-git-send-email-gbenson@redhat.com> <20150506171647.GA12725@blade.nx> In-Reply-To: <20150506171647.GA12725@blade.nx> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2015-05/txt/msg00255.txt.bz2 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