This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] [gdbserver] Do not crash on file load without inferior


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  <jan.kratochvil@redhat.com>

	* server.c (handle_query) <qSymbol::>: Do not error on NULL
	CURRENT_INFERIOR.

gdb/testsuite/
2011-02-24  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* 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"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]