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]

Re: [PATCH] Handle absence of DT_DEBUG while debugging ld.so


A Tuesday 29 July 2008 13:12:44, Daniel Jacobowitz wrote:
> On Mon, Jul 28, 2008 at 11:57:15PM -0300, Luis Machado wrote:
> > Yes, this specific address seems broken somehow. This is the first
> > _r_debug entry GDB gets:
>
> Looks like the section offsets are not set yet.
>
> > And this is the next _r_debug minimal symbol entry GDB gets:
>
> What do you mean by "next"?  What commands did you use to get this
> output?
>
> Also, with GDB 6.8 I can "continue" after this error.  With HEAD:
>
> Continuing.
> Cannot execute this command while the selected thread is running.
>
> Hey, Pedro?  Cleanup trouble?

Sort of.  When handling internal events we don't adjust the running
state of the thread, only the executing property.  This is so the
user/frontend doesn't see a bunch of not interesting
running/stopped notifications, like say thread hopping, going through
the shell doing execs, etc.

In this case, we were still not finished with create inferior dances,
and were inside a post_create_inferior.  

Note that post_create_inferior requires a !is_executing inferior, on
entry, and, it is allowed (and it does) to internally start/stop the
inferior (solib handlers do this, see *_create_inferior_hook).

If an error is thrown out of the deep bowls of post_create_inferior,
we should just propagate GDB's knowledge of the executing state to
the user/frontend running state.  This restores the old behaviour.

I now get:

 (gdb) r
 Starting program: /lib/ld-2.7.so
 Cannot access memory at address 0x21ec88
 (gdb) info threads
 * 1 process 30943  0x00007ffff7fe2a60 in ?? ()
 (gdb) c
 Continuing.
 Usage: ld.so [OPTION]... EXECUTABLE-FILE [ARGS-FOR-PROGRAM...]
 You have invoked `ld.so', the helper program for shared library executables.

 ...

 Program exited with code 0177.

OK?

-- 
Pedro Alves
2008-07-29  Pedro Alves  <pedro@codesourcery.com>

	* infcmd.c (post_create_inferior): Rename to ...
	(post_create_inferior_1): ... this and make static.
	(fix_running_state): New.
	(post_create_inferior): New.

---
 gdb/infcmd.c |   26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

Index: src/gdb/infcmd.c
===================================================================
--- src.orig/gdb/infcmd.c	2008-07-29 13:40:22.000000000 +0100
+++ src/gdb/infcmd.c	2008-07-29 13:44:02.000000000 +0100
@@ -408,8 +408,8 @@ tty_command (char *file, int from_tty)
    means (running, attaching, connecting, et cetera).  The target
    should be stopped.  */
 
-void
-post_create_inferior (struct target_ops *target, int from_tty)
+static void
+post_create_inferior_1 (struct target_ops *target, int from_tty)
 {
   /* Be sure we own the terminal in case write operations are performed.  */ 
   target_terminal_ours ();
@@ -445,6 +445,28 @@ post_create_inferior (struct target_ops 
   observer_notify_inferior_created (target, from_tty);
 }
 
+/* If an error happened, propagate GDB's knowledge of the executing
+   state to the frontend/user running state.  */
+
+static void
+fix_running_state (void *arg)
+{
+  if (is_exited (inferior_ptid))
+    return;
+  set_running (inferior_ptid,
+	       is_executing (inferior_ptid));
+}
+
+/* See post_create_inferior_1 for description.  */
+
+void
+post_create_inferior (struct target_ops *target, int from_tty)
+{
+  struct cleanup *old_chain = make_cleanup (fix_running_state, NULL);
+  post_create_inferior_1 (target, from_tty);
+  discard_cleanups (old_chain);
+}
+
 /* Kill the inferior if already running.  This function is designed
    to be called when we are about to start the execution of the program
    from the beginning.  Ask the user to confirm that he wants to restart

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