From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8797 invoked by alias); 4 Mar 2011 21:25:14 -0000 Received: (qmail 8777 invoked by uid 22791); 4 Mar 2011 21:25:13 -0000 X-SWARE-Spam-Status: No, hits=-0.8 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN X-Spam-Check-By: sourceware.org Received: from imr3.ericy.com (HELO imr3.ericy.com) (198.24.6.13) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 04 Mar 2011 21:25:06 +0000 Received: from eusaamw0707.eamcs.ericsson.se ([147.117.20.32]) by imr3.ericy.com (8.13.8/8.13.8) with ESMTP id p24LOnG7012578 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Fri, 4 Mar 2011 15:24:54 -0600 Received: from EUSAACMS0703.eamcs.ericsson.se ([169.254.1.208]) by eusaamw0707.eamcs.ericsson.se ([147.117.20.32]) with mapi; Fri, 4 Mar 2011 16:24:53 -0500 From: Marc Khouzam To: "'Pedro Alves'" , "'gdb-patches@sourceware.org'" CC: "'Jan Kratochvil'" Date: Fri, 04 Mar 2011 21:25:00 -0000 Subject: RE: [patch] [gdbserver] Do not crash on file load without inferior Message-ID: References: <20110224114001.GA24673@host1.dyn.jankratochvil.net> <201102241242.49342.pedro@codesourcery.com> In-Reply-To: <201102241242.49342.pedro@codesourcery.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-IsSubscribed: yes 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 X-SW-Source: 2011-03/txt/msg00327.txt.bz2 =20 > -----Original Message----- > From: gdb-patches-owner@sourceware.org=20 > [mailto:gdb-patches-owner@sourceware.org] On Behalf Of Pedro Alves > Sent: Thursday, February 24, 2011 7:43 AM > To: gdb-patches@sourceware.org > Cc: Jan Kratochvil > Subject: Re: [patch] [gdbserver] Do not crash on file load=20 > without inferior >=20 > On Thursday 24 February 2011 11:40:02, Jan Kratochvil wrote: > > Hi Pedro, > >=20 > > I always got: > >=20 > > (gdb) file .../gdb/testsuite/gdb.server/ext-run > > Load new symbol table from=20 > ".../gdb/testsuite/gdb.server/ext-run"? (y or n) y > > Reading symbols from .../gdb/testsuite/gdb.server/ext-run...done. > > gdbserver: Current inferior requested, but current_inferior is NULL > >=20 > > Remote connection closed > > (gdb) > >=20 > > if one connects to gdbserver --multi before loading the=20 > file. One needs to > > load the file first to be able to place a breakpoint at=20 > *_start or main. > >=20 > > But I face other bugs so I cannot say much more. > >=20 > > I do not think this patch can ever have a regression. >=20 > Thanks. I that revealed a problem on the GDB side instead. >=20 > E.g., if you have two inferiors loaded, and the not-current > inferior is running, but you do "file" on the not-running-yet > inferior, you'll see: >=20 > $ ./gdb ./testsuite/gdb.server/ext-run -ex "tar=20 > extended-remote :9999" -ex "set remote exec-file=20 > /home/pedro/gdb/baseline/build/gdb/testsuite/gdb.server/ext-ru > n" -ex "start" > ... > Reading symbols from=20 > /home/pedro/gdb/baseline/build/gdb/testsuite/gdb.server/ext-ru > n...done. > Setting up the environment for debugging gdb. > Remote debugging using :9999 > Temporary breakpoint 1 at 0x4004ef: file=20 > ../../../src/gdb/testsuite/gdb.server/server.c, line 21. > Starting program:=20 > /home/pedro/gdb/baseline/build/gdb/testsuite/gdb.server/ext-run=20 >=20 > Temporary breakpoint 1, main (argc=3D1, argv=3D0x7fffffffe068) at=20 > ../../../src/gdb/testsuite/gdb.server/server.c:21 > 21 return 0; > (gdb) add-inferior=20 > Added inferior 2 > (gdb) info inferiors=20 > Num Description Executable=20=20=20=20=20=20=20=20 > 2 =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20 > * 1 process 15952=20=20=20=20=20 > /home/pedro/gdb/baseline/build/gdb/testsuite/gdb.server/ext-run=20 > (gdb) inferior 2 > [Switching to inferior 2 [Thread 0.0] ()] > (gdb) set debug remote 1 > (gdb) file=20 > /home/pedro/gdb/baseline/build/gdb/testsuite/gdb.server/ext-run > Reading symbols from=20 > /home/pedro/gdb/baseline/build/gdb/testsuite/gdb.server/ext-ru > n...done. > Sending packet: $Hgp0.0#ad...Packet received: OK > ^^^^^^^ > Sending packet: $qSymbol::#5b...Packet received:=20 > qSymbol:6764625f6167656e745f6764625f74705f686561705f627566666572 > Sending packet:=20 > $qSymbol::6764625f6167656e745f6764625f74705f686561705f62756666 > 6572#1e...Packet received:=20 > qSymbol:6764625f6167656e745f6764625f6a756d705f7061645f627566666572 > Sending packet:=20 > $qSymbol::6764625f6167656e745f6764625f6a756d705f7061645f627566 > 666572#e1...Packet received:=20 > qSymbol:6764625f6167656e745f6764625f6a756d705f7061645f62756666 > 65725f656e64 > Sending packet:=20 > $qSymbol::6764625f6167656e745f6764625f6a756d705f7061645f627566 > 6665725f656e64#ec...Packet received:=20 > qSymbol:6764625f6167656e745f636f6c6c656374696e67 >=20 >=20 > But, Hgp0.0 means select _any_ thread in any process, not _no=20 > thread at all_. > Meaning GDBserver's current_inferior ends up set to a thread of the > wrong process, and GDBserver is querying inferior 1's symbols on > inferior 2! See on GDBserver: >=20 > (gdb) p current_inferior->entry.id=20 > $3 =3D {pid =3D 15952, lwp =3D 15952, tid =3D 0} That sounds pretty bad. Any chance of getting a fix for this in the 7_2 branch? Which I gather would fix the problem Jan originally reported. Having to specify the 'file' before connecting to the target is a regression from previous versions of GDB and I was hoping not to have to special-case it in Eclipse :-) Thanks Marc >=20 > So I think that we shouldn't send qSymbol at all when inferior_ptid is > null_ptid or rather with !target_has_execution (which ends up in > default_child_has_execution and currently resolves the same)? >=20 > --=20 > Pedro Alves >=20