From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19700 invoked by alias); 24 Feb 2011 11:40:19 -0000 Received: (qmail 19609 invoked by uid 22791); 24 Feb 2011 11:40:18 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_CP,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 24 Feb 2011 11:40:07 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p1OBe5jn031576 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 24 Feb 2011 06:40:05 -0500 Received: from host1.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p1OBe3Gd017737 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 24 Feb 2011 06:40:05 -0500 Received: from host1.dyn.jankratochvil.net (localhost [127.0.0.1]) by host1.dyn.jankratochvil.net (8.14.4/8.14.4) with ESMTP id p1OBe2qP020694 for ; Thu, 24 Feb 2011 12:40:02 +0100 Received: (from jkratoch@localhost) by host1.dyn.jankratochvil.net (8.14.4/8.14.4/Submit) id p1OBe2gY020627 for gdb-patches@sourceware.org; Thu, 24 Feb 2011 12:40:02 +0100 Date: Thu, 24 Feb 2011 12:42:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patch] [gdbserver] Do not crash on file load without inferior Message-ID: <20110224114001.GA24673@host1.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) 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-02/txt/msg00692.txt.bz2 Hi Pedro, I always got: (gdb) file .../gdb/testsuite/gdb.server/ext-run Load new symbol table from ".../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 Remote connection closed (gdb) if one connects to gdbserver --multi before loading the file. One needs to load the file first to be able to place a breakpoint at *_start or main. But I face other bugs so I cannot say much more. I do not think this patch can ever have a regression. Thanks, Jan gdb/gdbserver/ 2011-02-24 Jan Kratochvil * server.c (handle_query) : Do not error on NULL CURRENT_INFERIOR. gdb/testsuite/ 2011-02-24 Jan Kratochvil * gdb.server/ext-run.exp (load new file without any gdbserver inferior): New test. --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -1373,13 +1373,17 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p) the library at all. We also re-validate breakpoints when we see a second GDB breakpoint for the same address, and or when we access breakpoint shadows. */ - validate_breakpoints (); - if (target_supports_tracepoints ()) - tracepoint_look_up_symbols (); + if (current_inferior != NULL) + { + validate_breakpoints (); - if (target_running () && the_target->look_up_symbols != NULL) - (*the_target->look_up_symbols) (); + if (target_supports_tracepoints ()) + tracepoint_look_up_symbols (); + + if (target_running () && the_target->look_up_symbols != NULL) + (*the_target->look_up_symbols) (); + } strcpy (own_buf, "OK"); return; --- a/gdb/testsuite/gdb.server/ext-run.exp +++ b/gdb/testsuite/gdb.server/ext-run.exp @@ -60,4 +60,9 @@ if { [istarget *-*-linux*] } { } gdb_test "kill" "" "kill" "Kill the program being debugged.*" "y" + +gdb_load $binfile +gdb_test "monitor help" "The following monitor commands.*" \ + "load new file without any gdbserver inferior" + gdb_test_no_output "monitor exit"