Fix PR threads/19422 - show which thread caused stop
[deliverable/binutils-gdb.git] / gdb / mem-break.c
index f772f56b0c11ee26d74b0cc7426b495669483dbc..9bb4c454df0dbfa9da1a5d1df90bd891eb5b7d11 100644 (file)
@@ -1,6 +1,6 @@
 /* Simulate breakpoints by patching locations in the target system, for GDB.
 
-   Copyright (C) 1990-2014 Free Software Foundation, Inc.
+   Copyright (C) 1990-2016 Free Software Foundation, Inc.
 
    Contributed by Cygnus Support.  Written by John Gilmore.
 
@@ -53,12 +53,21 @@ default_memory_insert_breakpoint (struct gdbarch *gdbarch,
 
   /* Save the memory contents in the shadow_contents buffer and then
      write the breakpoint instruction.  */
-  bp_tgt->shadow_len = bplen;
-  readbuf = alloca (bplen);
+  readbuf = (gdb_byte *) alloca (bplen);
   val = target_read_memory (addr, readbuf, bplen);
   if (val == 0)
     {
+      /* These must be set together, either before or after the shadow
+        read, so that if we're "reinserting" a breakpoint that
+        doesn't have a shadow yet, the breakpoint masking code inside
+        target_read_memory doesn't mask out this breakpoint using an
+        unfilled shadow buffer.  The core may be trying to reinsert a
+        permanent breakpoint, for targets that support breakpoint
+        conditions/commands on the target side for some types of
+        breakpoints, such as target remote.  */
+      bp_tgt->shadow_len = bplen;
       memcpy (bp_tgt->shadow_contents, readbuf, bplen);
+
       val = target_write_raw_memory (addr, bp, bplen);
     }
 
This page took 0.025659 seconds and 4 git commands to generate.