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]

[commit] Check for shared libraries in start_remote


This has bugged me for years, but Vlad reminded me of it yesterday, so
I fixed it.  When you connect to a remote target, we used to first
call start_remote, which calls normal_stop and prints out the frame,
and then call solib_add.  So you would see "0x0xxx in ?? ()" and then
if you typed "frame" it would have loaded symbols and show you where
you really were.

So, if we load shared libraries in the logical place before calling
normal_stop, everything just works...

Tested with gdbserver on x86_64-pc-linux-gnu, and checked in.

-- 
Daniel Jacobowitz
CodeSourcery

2006-10-18  Daniel Jacobowitz  <dan@codesourcery.com>

	* inferior.h (start_remote): Update prototype.
	* infrun.c (start_remote): Take FROM_TTY.  Call
	post_create_inferior.
	* monitor.c (monitor_open): Update call to start_remote.
	* remote-sds.c (sds_start_remote, sds_open): Likewise.
	* remote.c (remote_start_remote): Likewise.
	(remote_start_remote_dummy): Removed.
	(remote_open): Update call to remote_start_remote.  Do not call
	post_create_inferior here.

Index: inferior.h
===================================================================
RCS file: /cvs/src/src/gdb/inferior.h,v
retrieving revision 1.75
diff -u -p -r1.75 inferior.h
--- inferior.h	24 Jan 2006 22:34:34 -0000	1.75
+++ inferior.h	18 Oct 2006 16:52:42 -0000
@@ -269,7 +269,7 @@ extern int gdb_has_a_terminal (void);
 
 /* From infrun.c */
 
-extern void start_remote (void);
+extern void start_remote (int from_tty);
 
 extern void normal_stop (void);
 
Index: infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.215
diff -u -p -r1.215 infrun.c
--- infrun.c	10 Sep 2006 16:21:03 -0000	1.215
+++ infrun.c	18 Oct 2006 16:52:43 -0000
@@ -2,8 +2,9 @@
    process.
 
    Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
-   1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free
-   Software Foundation, Inc.
+   1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+   2006
+   Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -832,7 +833,7 @@ proceed (CORE_ADDR addr, enum target_sig
 /* Start remote-debugging of a machine over a serial link.  */
 
 void
-start_remote (void)
+start_remote (int from_tty)
 {
   init_thread_list ();
   init_wait_for_inferior ();
@@ -854,6 +855,12 @@ start_remote (void)
      is currently running and GDB state should be set to the same as
      for an async run. */
   wait_for_inferior ();
+
+  /* Now that the inferior has stopped, do any bookkeeping like
+     loading shared libraries.  We want to do this before normal_stop,
+     so that the displayed frame is up to date.  */
+  post_create_inferior (&current_target, from_tty);
+
   normal_stop ();
 }
 
Index: monitor.c
===================================================================
RCS file: /cvs/src/src/gdb/monitor.c,v
retrieving revision 1.65
diff -u -p -r1.65 monitor.c
--- monitor.c	18 Jul 2006 20:45:01 -0000	1.65
+++ monitor.c	18 Oct 2006 16:52:43 -0000
@@ -812,7 +812,7 @@ monitor_open (char *args, struct monitor
 
   monitor_printf (current_monitor->line_term);
 
-  start_remote ();
+  start_remote (from_tty);
 }
 
 /* Close out all files and local state before this target loses
Index: remote-sds.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-sds.c,v
retrieving revision 1.43
diff -u -p -r1.43 remote-sds.c
--- remote-sds.c	18 Apr 2006 19:20:06 -0000	1.43
+++ remote-sds.c	18 Oct 2006 16:52:43 -0000
@@ -148,8 +148,9 @@ sds_close (int quitting)
 /* Stub for catch_errors.  */
 
 static int
-sds_start_remote (void *dummy)
+sds_start_remote (void *from_tty_p)
 {
+  int from_tty = * (int *) from_tty;
   int c;
   unsigned char buf[200];
 
@@ -173,7 +174,7 @@ sds_start_remote (void *dummy)
 
   immediate_quit--;
 
-  start_remote ();		/* Initialize gdb process mechanisms */
+  start_remote (from_tty);	/* Initialize gdb process mechanisms */
   return 1;
 }
 
@@ -224,7 +225,7 @@ device is attached to the remote system 
   /* Start the remote connection; if error (0), discard this target.
      In particular, if the user quits, be sure to discard it (we'd be
      in an inconsistent state otherwise).  */
-  if (!catch_errors (sds_start_remote, NULL,
+  if (!catch_errors (sds_start_remote, &from_tty,
 		     "Couldn't establish connection to remote target\n",
 		     RETURN_MASK_ALL))
     pop_target ();
Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.233
diff -u -p -r1.233 remote.c
--- remote.c	17 Oct 2006 15:43:51 -0000	1.233
+++ remote.c	18 Oct 2006 16:52:44 -0000
@@ -1987,20 +1987,13 @@ get_offsets (void)
   objfile_relocate (symfile_objfile, offs);
 }
 
-/* Stub for catch_errors.  */
-
-static int
-remote_start_remote_dummy (struct ui_out *uiout, void *dummy)
-{
-  start_remote ();		/* Initialize gdb process mechanisms.  */
-  /* NOTE: Return something >=0.  A -ve value is reserved for
-     catch_exceptions.  */
-  return 1;
-}
+/* Stub for catch_exception.  */
 
 static void
-remote_start_remote (struct ui_out *uiout, void *dummy)
+remote_start_remote (struct ui_out *uiout, void *from_tty_p)
 {
+  int from_tty = * (int *) from_tty_p;
+
   immediate_quit++;		/* Allow user to interrupt it.  */
 
   /* Ack any packet which the remote side has already sent.  */
@@ -2016,7 +2009,7 @@ remote_start_remote (struct ui_out *uiou
   putpkt ("?");			/* Initiate a query from remote machine.  */
   immediate_quit--;
 
-  remote_start_remote_dummy (uiout, dummy);
+  start_remote (from_tty);	/* Initialize gdb process mechanisms.  */
 }
 
 /* Open a connection to a remote debugger.
@@ -2458,7 +2451,8 @@ remote_open_1 (char *name, int from_tty,
      function.  See cli-dump.c.  */
   {
     struct gdb_exception ex
-      = catch_exception (uiout, remote_start_remote, NULL, RETURN_MASK_ALL);
+      = catch_exception (uiout, remote_start_remote, &from_tty,
+			 RETURN_MASK_ALL);
     if (ex.reason < 0)
       {
 	pop_target ();
@@ -2478,8 +2472,6 @@ remote_open_1 (char *name, int from_tty,
       getpkt (&rs->buf, &rs->buf_size, 0);
     }
 
-  post_create_inferior (&current_target, from_tty);
-
   if (exec_bfd) 	/* No use without an exec file.  */
     remote_check_symbols (symfile_objfile);
 }


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