gdb/42: attaching to threaded program ( mozilla ) causes assertion failed

Mark Kettenis kettenis@wins.uva.nl
Sat Mar 17 15:38:00 GMT 2001


The following reply was made to PR gdb/42; it has been noted by GNATS.

From: Mark Kettenis <kettenis@wins.uva.nl>
To: blizzard@redhat.com
Cc: gdb-gnats@sources.redhat.com
Subject: Re: gdb/42: attaching to threaded program ( mozilla ) causes assertion failed
Date: Sun, 18 Mar 2001 00:19:01 +0100

 Here's a patch that seems to fix the problem for me.  With this patch
 I can attach to the linux-dp program that's in the GDB testsuite.
 Sending SIGINT and hitting breakpoints seems to be doing the right
 thing.  I haven't tested it with Mozilla though.  Could you please
 test this patch and report back to me whether it works?
 
 Mark
 
 PS Detaching from the program isn't implemented yet.  Trying to do so
 prints the message "Not implemented yet".  After this point GDB is
 thoroughly confused and mostly unusable.  I'll see if I can fix that
 problem too.
 
 
 2001-03-18  Mark Kettenis  <kettenis@gnu.org>
 
 	Fix PR gdb/42.
 	* lin-lwp.c (lin_lwp_attach_lwp): Only attach to the LWP and mark
 	it as signalled if it's a cloned process.
 	* thread-db.c (attach_thread): Unconditionally call ATTACH_LWP if
 	defined.
 
 
 Index: lin-lwp.c
 ===================================================================
 RCS file: /cvs/src/src/gdb/lin-lwp.c,v
 retrieving revision 1.6
 diff -u -p -r1.6 lin-lwp.c
 --- lin-lwp.c 2001/03/01 01:39:21 1.6
 +++ lin-lwp.c 2001/03/17 23:08:55
 @@ -337,11 +337,14 @@ lin_lwp_attach_lwp (int pid, int verbose
    if (verbose)
      printf_filtered ("[New %s]\n", target_pid_to_str (pid));
  
 -  if (ptrace (PTRACE_ATTACH, GET_LWP (pid), 0, 0) < 0)
 +  /* We assume that we're already tracing the initial process.  */
 +  if (is_cloned (pid) && ptrace (PTRACE_ATTACH, GET_LWP (pid), 0, 0) < 0)
      error ("Can't attach %s: %s", target_pid_to_str (pid), strerror (errno));
  
    lp = add_lwp (pid);
 -  lp->signalled = 1;
 +
 +  if (is_cloned (pid))
 +    lp->signalled = 1;
  }
  
  static void
 Index: thread-db.c
 ===================================================================
 RCS file: /cvs/src/src/gdb/thread-db.c,v
 retrieving revision 1.5
 diff -u -p -r1.5 thread-db.c
 --- thread-db.c 2001/03/01 01:39:21 1.5
 +++ thread-db.c 2001/03/17 23:08:55
 @@ -611,8 +611,7 @@ attach_thread (int pid, const td_thrhand
  
    /* Under Linux, we have to attach to each and every thread.  */
  #ifdef ATTACH_LWP
 -  if (ti_p->ti_lid != GET_PID (pid))
 -    ATTACH_LWP (BUILD_LWP (ti_p->ti_lid, GET_PID (pid)), 0);
 +  ATTACH_LWP (BUILD_LWP (ti_p->ti_lid, GET_PID (pid)), 0);
  #endif
  
    /* Enable thread event reporting for this thread.  */
 



More information about the Gdb-prs mailing list