]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
2011-12-20 Pedro Alves <alves.ped@gmail.com>
authorPedro Alves <palves@redhat.com>
Tue, 20 Dec 2011 10:40:15 +0000 (10:40 +0000)
committerPedro Alves <palves@redhat.com>
Tue, 20 Dec 2011 10:40:15 +0000 (10:40 +0000)
    Jan Kratochvil  <jan.kratochvil@redhat.com>

        * linux-nat.c (add_lwp): Don't call linux_nat_new_thread on the
first LWP.
* amd64-linux-nat.c (update_debug_registers_callback): Instantiate
`lwp->arch_private' if NULL.
(amd64_linux_prepare_to_resume): Do nothing if `lwp->arch_private'
is NULL.
* i386-linux-nat.c (update_debug_registers_callback): Instantiate
`lwp->arch_private' if NULL.
(i386_linux_prepare_to_resume): Do nothing if `lwp->arch_private'
is NULL.

gdb/ChangeLog
gdb/amd64-linux-nat.c
gdb/i386-linux-nat.c
gdb/linux-nat.c

index 2eba21ac9a370387308c95c0377f43da92ada083..66cd31ef8280b91f383034875cbd4e521cc3dee3 100644 (file)
@@ -1,3 +1,17 @@
+2011-12-20  Pedro Alves  <alves.ped@gmail.com>
+           Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+        * linux-nat.c (add_lwp): Don't call linux_nat_new_thread on the
+       first LWP.
+       * amd64-linux-nat.c (update_debug_registers_callback): Instantiate
+       `lwp->arch_private' if NULL.
+       (amd64_linux_prepare_to_resume): Do nothing if `lwp->arch_private'
+       is NULL.
+       * i386-linux-nat.c (update_debug_registers_callback): Instantiate
+       `lwp->arch_private' if NULL.
+       (i386_linux_prepare_to_resume): Do nothing if `lwp->arch_private'
+       is NULL.
+
 2011-12-19  Doug Evans  <dje@google.com>
 
        * python/py-auto-load.c (info_auto_load_scripts): Pass address of
index 288160b33896da4e37b6ff3f54925020a13224f6..865b9713d818fa0e8fde0f60abdba960390cdf31 100644 (file)
@@ -343,6 +343,9 @@ amd64_linux_dr_get_status (void)
 static int
 update_debug_registers_callback (struct lwp_info *lwp, void *arg)
 {
+  if (lwp->arch_private == NULL)
+    lwp->arch_private = XCNEW (struct arch_lwp_info);
+
   /* The actual update is done later just before resuming the lwp, we
      just mark that the registers need updating.  */
   lwp->arch_private->debug_registers_changed = 1;
@@ -386,6 +389,12 @@ amd64_linux_prepare_to_resume (struct lwp_info *lwp)
 {
   int clear_status = 0;
 
+  /* NULL means this is the main thread still going through the shell,
+     or, no watchpoint has been set yet.  In that case, there's
+     nothing to do.  */
+  if (lwp->arch_private == NULL)
+    return;
+
   if (lwp->arch_private->debug_registers_changed)
     {
       struct i386_debug_reg_state *state = i386_debug_reg_state ();
index 190979b8a6653587160c66b154ed8246cce63c86..45279135a283d7be16a06fc87af31ae2115ba687 100644 (file)
@@ -715,6 +715,9 @@ i386_linux_dr_get_status (void)
 static int
 update_debug_registers_callback (struct lwp_info *lwp, void *arg)
 {
+  if (lwp->arch_private == NULL)
+    lwp->arch_private = XCNEW (struct arch_lwp_info);
+
   /* The actual update is done later just before resuming the lwp, we
      just mark that the registers need updating.  */
   lwp->arch_private->debug_registers_changed = 1;
@@ -758,6 +761,12 @@ i386_linux_prepare_to_resume (struct lwp_info *lwp)
 {
   int clear_status = 0;
 
+  /* NULL means this is the main thread still going through the shell,
+     or, no watchpoint has been set yet.  In that case, there's
+     nothing to do.  */
+  if (lwp->arch_private == NULL)
+    return;
+
   if (lwp->arch_private->debug_registers_changed)
     {
       struct i386_debug_reg_state *state = i386_debug_reg_state ();
index 1cbfc44456c54b4a858a780fdd4a293ea4ddd0b3..e5f7c3e8ee56ee008fd11e3c5069ba82232b3111 100644 (file)
@@ -1151,7 +1151,15 @@ add_lwp (ptid_t ptid)
   lp->next = lwp_list;
   lwp_list = lp;
 
-  if (linux_nat_new_thread != NULL)
+  /* Let the arch specific bits know about this new thread.  Current
+     clients of this callback take the opportunity to install
+     watchpoints in the new thread.  Don't do this for the first
+     thread though.  If we're spawning a child ("run"), the thread
+     executes the shell wrapper first, and we shouldn't touch it until
+     it execs the program we want to debug.  For "attach", it'd be
+     okay to call the callback, but it's not necessary, because
+     watchpoints can't yet have been inserted into the inferior.  */
+  if (num_lwps (GET_PID (ptid)) > 1 && linux_nat_new_thread != NULL)
     linux_nat_new_thread (lp);
 
   return lp;