* breakpoint.c (should_be_inserted): Don't insert breakpoints if
authorPedro Alves <palves@redhat.com>
Sun, 15 Nov 2009 20:08:03 +0000 (20:08 +0000)
committerPedro Alves <palves@redhat.com>
Sun, 15 Nov 2009 20:08:03 +0000 (20:08 +0000)
the pspace doesn't allow breakpoints.
(insert_breakpoint_locations): Remove waiting_for_vfork_done
special case.  Expect watchpoints that shouldn't be inserted, to
not be inserted.
* progspace.h (struct program_space) <breakpoints_not_allowed>:
New field.
* infrun.c (handle_inferior_event): Clear it.
* linux-nat.c (linux_child_follow_fork): Set it.

gdb/ChangeLog
gdb/breakpoint.c
gdb/infrun.c
gdb/linux-nat.c
gdb/progspace.h

index 7769fff24e65c258dc5133bf763d4c1e8cc19688..500eaf826ac8f87477ca2d47326856c29a69f4e8 100644 (file)
@@ -1,3 +1,15 @@
+2009-11-15  Pedro Alves  <pedro@codesourcery.com>
+
+       * breakpoint.c (should_be_inserted): Don't insert breakpoints if
+       the pspace doesn't allow breakpoints.
+       (insert_breakpoint_locations): Remove waiting_for_vfork_done
+       special case.  Expect watchpoints that shouldn't be inserted, to
+       not be inserted.
+       * progspace.h (struct program_space) <breakpoints_not_allowed>:
+       New field.
+       * infrun.c (handle_inferior_event): Clear it.
+       * linux-nat.c (linux_child_follow_fork): Set it.
+
 2009-11-13  Doug Evans  <dje@google.com>
 
        * dcache.c (dcache_hit, dcache_read_line): Tweak comments.
index cadc53645969b44f40ed52dd5dc950adc58ca17d..0034338a0ee261bc1bf0627ac9ea9872ec20d380 100644 (file)
@@ -1193,6 +1193,17 @@ should_be_inserted (struct bp_location *bpt)
   if (!bpt->enabled || bpt->shlib_disabled || bpt->duplicate)
     return 0;
 
+  /* This is set for example, when we're attached to the parent of a
+     vfork, and have detached from the child.  The child is running
+     free, and we expect it to do an exec or exit, at which point the
+     OS makes the parent schedulable again (and the target reports
+     that the vfork is done).  Until the child is done with the shared
+     memory region, do not insert breakpoints in the parent, otherwise
+     the child could still trip on the parent's breakpoints.  Since
+     the parent is blocked anyway, it won't miss any breakpoint.  */
+  if (bpt->pspace->breakpoints_not_allowed)
+    return 0;
+
   /* Tracepoints are inserted by the target at a time of its choosing,
      not by us.  */
   if (bpt->owner->type == bp_tracepoint)
@@ -1530,25 +1541,6 @@ insert_breakpoint_locations (void)
          && ptid_equal (inferior_ptid, null_ptid))
        continue;
 
-      if (!ptid_equal (inferior_ptid, null_ptid))
-       {
-         struct inferior *inf = current_inferior ();
-         if (inf->waiting_for_vfork_done)
-           {
-             /* This is set when we're attached to the parent of the
-                vfork, and have detached from the child.  The child
-                is running free, and we expect it to do an exec or
-                exit, at which point the OS makes the parent
-                schedulable again (and the target reports that the
-                vfork is done).  Until the child is done with the
-                shared memory region, do not insert breakpoints in
-                parent, otherwise the child could still trip on the
-                parent's breakpoints.  Since the parent is blocked
-                anyway, it won't miss any breakpoint.  */
-             continue;
-           }
-       }
-
       val = insert_bp_location (b, tmp_error_stream,
                                    &disabled_breaks,
                                    &hw_breakpoint_error);
@@ -1573,7 +1565,7 @@ insert_breakpoint_locations (void)
        continue;
       
       for (loc = bpt->loc; loc; loc = loc->next)
-       if (!loc->inserted)
+       if (!loc->inserted && should_be_inserted (loc))
          {
            some_failed = 1;
            break;
index 9d8ab68cfac0559492aa6f08197e0f46329d16a9..c28366f5da92128556004c445a12f4760c8b88bd 100644 (file)
@@ -3004,6 +3004,7 @@ handle_inferior_event (struct execution_control_state *ecs)
        context_switch (ecs->ptid);
 
       current_inferior ()->waiting_for_vfork_done = 0;
+      current_inferior ()->pspace->breakpoints_not_allowed = 0;
       /* This also takes care of reinserting breakpoints in the
         previously locked inferior.  */
       keep_going (ecs);
index c0c024073142a84a8f92127b22c856d8177f85f5..95feca6d363c83318511b7b4a36976a03e38108b 100644 (file)
@@ -793,6 +793,7 @@ holding the child stopped.  Try \"set detach-on-fork\" or \
             subsequent child exec or exit is enough to know when does
             the child stops using the parent's address space.  */
          parent_inf->waiting_for_vfork_done = detach_fork;
+         parent_inf->pspace->breakpoints_not_allowed = detach_fork;
 
          lp = find_lwp_pid (pid_to_ptid (parent_pid));
          gdb_assert (linux_supports_tracefork_flag >= 0);
index 0cf1382b77a33d8869d9b0127397205694a3c0e3..4d87d16863b29599fb300f94e02566255b1c95bb 100644 (file)
@@ -165,6 +165,10 @@ struct program_space
        to set breakpoints point at the wrong addresses.  */
     int executing_startup;
 
+    /* True if no breakpoints should be inserted in this program
+       space.  */
+    int breakpoints_not_allowed;
+
     /* The object file that the main symbol table was loaded from
        (e.g. the argument to the "symbol-file" or "file" command).  */
     struct objfile *symfile_object_file;
This page took 0.041839 seconds and 4 git commands to generate.