]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* breakpoint.h (breakpoint_restore_shadows): New
authorDaniel Jacobowitz <drow@false.org>
Thu, 13 Mar 2008 12:22:14 +0000 (12:22 +0000)
committerDaniel Jacobowitz <drow@false.org>
Thu, 13 Mar 2008 12:22:14 +0000 (12:22 +0000)
declaration.
* breakpoint.c (breakpoint_restore_shadows): New.
(read_memory_nobpt): Delete.
* gdbcore.h (read_memory_nobpt): Delete declaration.
* target.c (memory_xfer_partial): Call
breakpoint_restore_shadows.
(restore_show_memory_breakpoints)
(make_show_memory_beakpoints_cleanup): New.
(show_memory_breakpoints): New.
* target.h (make_show_memory_beakpoints_cleanup): Declare.
* ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint):
Make sure we see memory breakpoints when checking if
breakpoint is still there.
* alpha-tdep.c, alphanbsd-tdep.c, frame.c, frv-tdep.c,
hppa-linux-tdep.c, hppa-tdep.c, i386-linux-nat.c, i386-tdep.c,
m68klinux-tdep.c, mips-tdep.c, mn10300-tdep.c, s390-tdep.c,
sparc-tdep.c: Use target_read_memory instead of read_memory_nobpt.

21 files changed:
gdb/ChangeLog
gdb/Makefile.in
gdb/alpha-tdep.c
gdb/alphanbsd-tdep.c
gdb/breakpoint.c
gdb/breakpoint.h
gdb/frame.c
gdb/frv-tdep.c
gdb/gdbcore.h
gdb/hppa-linux-tdep.c
gdb/hppa-tdep.c
gdb/i386-linux-nat.c
gdb/i386-tdep.c
gdb/m68klinux-tdep.c
gdb/mips-tdep.c
gdb/mn10300-tdep.c
gdb/ppc-linux-tdep.c
gdb/s390-tdep.c
gdb/sparc-tdep.c
gdb/target.c
gdb/target.h

index 7a2289bc22ee8c995c2e585a6c424dfe30e31068..7a8eb9502816d6c4366acb8ba4a90f3098410426 100644 (file)
@@ -1,3 +1,25 @@
+2008-03-13  Vladimir Prus  <vladimir@codesourcery.com>
+           Daniel Jacobowitz  <dan@codesourcery.com>
+
+       * breakpoint.h (breakpoint_restore_shadows): New
+       declaration.
+       * breakpoint.c (breakpoint_restore_shadows): New.
+       (read_memory_nobpt): Delete.
+       * gdbcore.h (read_memory_nobpt): Delete declaration.
+       * target.c (memory_xfer_partial): Call
+       breakpoint_restore_shadows.
+       (restore_show_memory_breakpoints)
+       (make_show_memory_beakpoints_cleanup): New.
+       (show_memory_breakpoints): New.
+       * target.h (make_show_memory_beakpoints_cleanup): Declare.
+       * ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint):
+       Make sure we see memory breakpoints when checking if
+       breakpoint is still there.
+       * alpha-tdep.c, alphanbsd-tdep.c, frame.c, frv-tdep.c,
+       hppa-linux-tdep.c, hppa-tdep.c, i386-linux-nat.c, i386-tdep.c,
+       m68klinux-tdep.c, mips-tdep.c, mn10300-tdep.c, s390-tdep.c,
+       sparc-tdep.c: Use target_read_memory instead of read_memory_nobpt.
+
 2008-03-12  Pedro Alves  <pedro@codesourcery.com>
 
        * thread.c (add_thread): Use printf_unfiltered to print.
index 5cf5131259b94baa22a21d07a63c0e32a1159da8..00aecb9139757f306c87b8a1d6188e97b12e4ebe 100644 (file)
@@ -2873,7 +2873,7 @@ symtab.o: symtab.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(gdbcore_h) \
 target.o: target.c $(defs_h) $(gdb_string_h) $(target_h) $(gdbcmd_h) \
        $(symtab_h) $(inferior_h) $(bfd_h) $(symfile_h) $(objfiles_h) \
        $(gdb_wait_h) $(dcache_h) $(regcache_h) $(gdb_assert_h) $(gdbcore_h) \
-       $(exceptions_h) $(target_descriptions_h)
+       $(exceptions_h) $(target_descriptions_h) $(gdb_stdint_h)
 target-descriptions.o: target-descriptions.c $(defs_h) $(arch_utils_h) \
        $(target_h) $(target_descriptions_h) $(vec_h) $(xml_tdesc_h) \
        $(gdbcmd_h) $(gdb_assert_h) $(gdbtypes_h) $(reggroups_h) \
index 27b486999b73167d69940cb451a2ec22906ff717..6a55700bcbf50031ca7ebed71664b9febd9a961a 100644 (file)
@@ -638,7 +638,7 @@ alpha_read_insn (CORE_ADDR pc)
   gdb_byte buf[ALPHA_INSN_SIZE];
   int status;
 
-  status = read_memory_nobpt (pc, buf, sizeof (buf));
+  status = target_read_memory (pc, buf, sizeof (buf));
   if (status)
     memory_error (status, pc);
   return extract_unsigned_integer (buf, sizeof (buf));
index dc086523c74a2d443666e1944af52ec9f0a64f8b..47b479157efa256dc78610258cfee51206289dfd 100644 (file)
@@ -216,7 +216,7 @@ alphanbsd_sigtramp_offset (CORE_ADDR pc)
   LONGEST off;
   int i;
 
-  if (read_memory_nobpt (pc, (char *) w, 4) != 0)
+  if (target_read_memory (pc, (char *) w, 4) != 0)
     return -1;
 
   for (i = 0; i < RETCODE_NWORDS; i++)
@@ -230,7 +230,7 @@ alphanbsd_sigtramp_offset (CORE_ADDR pc)
   off = i * 4;
   pc -= off;
 
-  if (read_memory_nobpt (pc, (char *) ret, sizeof (ret)) != 0)
+  if (target_read_memory (pc, (char *) ret, sizeof (ret)) != 0)
     return -1;
 
   if (memcmp (ret, sigtramp_retcode, RETCODE_SIZE) == 0)
index 8dc6f40127d3c6e863bbe1448213a9f98db1dfbc..4fbda0b6e8e52da944b6810a68bacd5c0a3816a4 100644 (file)
@@ -702,25 +702,16 @@ commands_from_control_command (char *arg, struct command_line *cmd)
   error (_("No breakpoint number %d."), bnum);
 }
 \f
-/* Like target_read_memory() but if breakpoints are inserted, return
-   the shadow contents instead of the breakpoints themselves.
+/* Update BUF, which is LEN bytes read from the target address MEMADDR,
+   by replacing any memory breakpoints with their shadowed contents.  */
 
-   Read "memory data" from whatever target or inferior we have. 
-   Returns zero if successful, errno value if not.  EIO is used
-   for address out of bounds.  If breakpoints are inserted, returns
-   shadow contents, not the breakpoints themselves.  From breakpoint.c.  */
-
-int
-read_memory_nobpt (CORE_ADDR memaddr, gdb_byte *myaddr, unsigned len)
+void
+breakpoint_restore_shadows (gdb_byte *buf, ULONGEST memaddr, LONGEST len)
 {
-  int status;
-  const struct bp_location *b;
+  struct bp_location *b;
   CORE_ADDR bp_addr = 0;
   int bp_size = 0;
-
-  if (gdbarch_breakpoint_from_pc (current_gdbarch, &bp_addr, &bp_size) == NULL)
-    /* No breakpoints on this machine. */
-    return target_read_memory (memaddr, myaddr, len);
+  int bptoffset = 0;
 
   ALL_BP_LOCATIONS (b)
   {
@@ -739,59 +730,35 @@ read_memory_nobpt (CORE_ADDR memaddr, gdb_byte *myaddr, unsigned len)
     if (bp_size == 0)
       /* bp isn't valid, or doesn't shadow memory.  */
       continue;
+
     if (bp_addr + bp_size <= memaddr)
       /* The breakpoint is entirely before the chunk of memory we
          are reading.  */
       continue;
+
     if (bp_addr >= memaddr + len)
       /* The breakpoint is entirely after the chunk of memory we are
          reading. */
       continue;
-    /* Copy the breakpoint from the shadow contents, and recurse for
-       the things before and after.  */
-    {
-      /* Offset within shadow_contents.  */
-      int bptoffset = 0;
-
-      if (bp_addr < memaddr)
-       {
-         /* Only copy the second part of the breakpoint.  */
-         bp_size -= memaddr - bp_addr;
-         bptoffset = memaddr - bp_addr;
-         bp_addr = memaddr;
-       }
-
-      if (bp_addr + bp_size > memaddr + len)
-       {
-         /* Only copy the first part of the breakpoint.  */
-         bp_size -= (bp_addr + bp_size) - (memaddr + len);
-       }
 
-      memcpy (myaddr + bp_addr - memaddr,
-             b->target_info.shadow_contents + bptoffset, bp_size);
+    /* Offset within shadow_contents.  */
+    if (bp_addr < memaddr)
+      {
+       /* Only copy the second part of the breakpoint.  */
+       bp_size -= memaddr - bp_addr;
+       bptoffset = memaddr - bp_addr;
+       bp_addr = memaddr;
+      }
 
-      if (bp_addr > memaddr)
-       {
-         /* Copy the section of memory before the breakpoint.  */
-         status = read_memory_nobpt (memaddr, myaddr, bp_addr - memaddr);
-         if (status != 0)
-           return status;
-       }
+    if (bp_addr + bp_size > memaddr + len)
+      {
+       /* Only copy the first part of the breakpoint.  */
+       bp_size -= (bp_addr + bp_size) - (memaddr + len);
+      }
 
-      if (bp_addr + bp_size < memaddr + len)
-       {
-         /* Copy the section of memory after the breakpoint.  */
-         status = read_memory_nobpt (bp_addr + bp_size,
-                                     myaddr + bp_addr + bp_size - memaddr,
-                                     memaddr + len - (bp_addr + bp_size));
-         if (status != 0)
-           return status;
-       }
-      return 0;
-    }
+    memcpy (buf + bp_addr - memaddr,
+           b->target_info.shadow_contents + bptoffset, bp_size);
   }
-  /* Nothing overlaps.  Just call read_memory_noerr.  */
-  return target_read_memory (memaddr, myaddr, len);
 }
 \f
 
@@ -4299,7 +4266,7 @@ set_raw_breakpoint (struct symtab_and_line sal, enum bptype bptype)
   /* Adjust the breakpoint's address prior to allocating a location.
      Once we call allocate_bp_location(), that mostly uninitialized
      location will be placed on the location chain.  Adjustment of the
-     breakpoint may cause read_memory_nobpt() to be called and we do
+     breakpoint may cause target_read_memory() to be called and we do
      not want its scan of the location chain to find a breakpoint and
      location that's only been partially initialized.  */
   adjusted_address = adjust_breakpoint_address (sal.pc, bptype);
index 16bb927c6fbd65e53b65e3818ad66bc8d8e8cd53..537645570e45ec2a363b7a180016408ed1fe4f64 100644 (file)
@@ -859,4 +859,9 @@ extern int deprecated_remove_raw_breakpoint (void *);
    target.  */
 int watchpoints_triggered (struct target_waitstatus *);
 
+/* Update BUF, which is LEN bytes read from the target address MEMADDR,
+   by replacing any memory breakpoints with their shadowed contents.  */
+void breakpoint_restore_shadows (gdb_byte *buf, ULONGEST memaddr, 
+                                LONGEST len);
+
 #endif /* !defined (BREAKPOINT_H) */
index ded9ae701708a33c03c9c85f1db5de35613336a4..9434ce79d670f505eb7bf6f109791e1511ecc36d 100644 (file)
@@ -1691,8 +1691,8 @@ int
 safe_frame_unwind_memory (struct frame_info *this_frame,
                          CORE_ADDR addr, gdb_byte *buf, int len)
 {
-  /* NOTE: read_memory_nobpt returns zero on success!  */
-  return !read_memory_nobpt (addr, buf, len);
+  /* NOTE: target_read_memory returns zero on success!  */
+  return !target_read_memory (addr, buf, len);
 }
 
 /* Architecture method.  */
index d025399ad387ec0753f0b6f556229c477ffd78df..1611d2299a1b74d915f2a9b49b6474486e69ac43 100644 (file)
@@ -449,7 +449,7 @@ frv_adjust_breakpoint_address (struct gdbarch *gdbarch, CORE_ADDR bpaddr)
       char instr[frv_instr_size];
       int status;
 
-      status = read_memory_nobpt (addr, instr, sizeof instr);
+      status = target_read_memory (addr, instr, sizeof instr);
 
       if (status != 0)
        break;
index 895fefbf9df609c26f22e00a63273d03c16947a5..383cc3f96a73472d4bee000e71a821aba5096d03 100644 (file)
@@ -39,18 +39,6 @@ extern char *get_exec_file (int err);
 
 extern int have_core_file_p (void);
 
-/* Read "memory data" from whatever target or inferior we have.
-   Returns zero if successful, errno value if not.  EIO is used for
-   address out of bounds.  If breakpoints are inserted, returns shadow
-   contents, not the breakpoints themselves.  From breakpoint.c.  */
-
-/* NOTE: cagney/2004-06-10: Code reading from a live inferior can use
-   the get_frame_memory methods, code reading from an exec can use the
-   target methods.  */
-
-extern int read_memory_nobpt (CORE_ADDR memaddr, gdb_byte *myaddr,
-                             unsigned len);
-
 /* Report a memory error with error().  */
 
 extern void memory_error (int status, CORE_ADDR memaddr);
index 50aaa98dcc89b99756222aac8415e737dcaf8ae9..1e0e5833eb7075ef863b6a28f70e2b5228a83dbb 100644 (file)
@@ -101,7 +101,7 @@ insns_match_pattern (CORE_ADDR pc,
     {
       char buf[4];
 
-      read_memory_nobpt (npc, buf, 4);
+      target_read_memory (npc, buf, 4);
       insn[i] = extract_unsigned_integer (buf, 4);
       if ((insn[i] & pattern[i].mask) == pattern[i].data)
         npc += 4;
index 35ede18274d07f3a77f40e6f22d057f65043f0ed..d91ed95edd08d71ac6983d2a1c1554bfbf3e5361 100644 (file)
@@ -545,7 +545,7 @@ hppa_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
   char buf[4];
   int off;
 
-  status = read_memory_nobpt (pc, buf, 4);
+  status = target_read_memory (pc, buf, 4);
   if (status != 0)
     return 0;
 
@@ -1552,7 +1552,7 @@ restart:
       old_save_sp = save_sp;
       old_stack_remaining = stack_remaining;
 
-      status = read_memory_nobpt (pc, buf, 4);
+      status = target_read_memory (pc, buf, 4);
       inst = extract_unsigned_integer (buf, 4);
 
       /* Yow! */
@@ -1603,7 +1603,7 @@ restart:
                 && reg_num <= 26)
            {
              pc += 4;
-             status = read_memory_nobpt (pc, buf, 4);
+             status = target_read_memory (pc, buf, 4);
              inst = extract_unsigned_integer (buf, 4);
              if (status != 0)
                return pc;
@@ -1616,7 +1616,7 @@ restart:
       reg_num = inst_saves_fr (inst);
       save_fr &= ~(1 << reg_num);
 
-      status = read_memory_nobpt (pc + 4, buf, 4);
+      status = target_read_memory (pc + 4, buf, 4);
       next_inst = extract_unsigned_integer (buf, 4);
 
       /* Yow! */
@@ -1647,13 +1647,13 @@ restart:
                      <= (gdbarch_ptr_bit (gdbarch) == 64 ? 11 : 7))
            {
              pc += 8;
-             status = read_memory_nobpt (pc, buf, 4);
+             status = target_read_memory (pc, buf, 4);
              inst = extract_unsigned_integer (buf, 4);
              if (status != 0)
                return pc;
              if ((inst & 0xfc000000) != 0x34000000)
                break;
-             status = read_memory_nobpt (pc + 4, buf, 4);
+             status = target_read_memory (pc + 4, buf, 4);
              next_inst = extract_unsigned_integer (buf, 4);
              if (status != 0)
                return pc;
@@ -2857,7 +2857,7 @@ hppa_match_insns (CORE_ADDR pc, struct insn_pattern *pattern,
     {
       gdb_byte buf[HPPA_INSN_SIZE];
 
-      read_memory_nobpt (npc, buf, HPPA_INSN_SIZE);
+      target_read_memory (npc, buf, HPPA_INSN_SIZE);
       insn[i] = extract_unsigned_integer (buf, HPPA_INSN_SIZE);
       if ((insn[i] & pattern[i].mask) == pattern[i].data)
         npc += 4;
index bff376c2110c8ad348be29b16095038e8825ca37..146f5a65133c3437530f91c1308bba5789b8a913 100644 (file)
@@ -770,7 +770,7 @@ i386_linux_resume (ptid_t ptid, int step, enum target_signal signal)
          that's about to be restored, and set the trace flag there.  */
 
       /* First check if PC is at a system call.  */
-      if (read_memory_nobpt (pc, buf, LINUX_SYSCALL_LEN) == 0
+      if (target_read_memory (pc, buf, LINUX_SYSCALL_LEN) == 0
          && memcmp (buf, linux_syscall, LINUX_SYSCALL_LEN) == 0)
        {
          ULONGEST syscall;
index d29d92efa9dcee8d8d8dc210c079a3569ffb0ccf..dc21706e7f1ea03f3d2d1bc5f5ab973f5ec4814e 100644 (file)
@@ -344,7 +344,7 @@ i386_follow_jump (CORE_ADDR pc)
   long delta = 0;
   int data16 = 0;
 
-  read_memory_nobpt (pc, &op, 1);
+  target_read_memory (pc, &op, 1);
   if (op == 0x66)
     {
       data16 = 1;
@@ -410,12 +410,12 @@ i386_analyze_struct_return (CORE_ADDR pc, CORE_ADDR current_pc,
   if (current_pc <= pc)
     return pc;
 
-  read_memory_nobpt (pc, &op, 1);
+  target_read_memory (pc, &op, 1);
 
   if (op != 0x58)              /* popl %eax */
     return pc;
 
-  read_memory_nobpt (pc + 1, buf, 4);
+  target_read_memory (pc + 1, buf, 4);
   if (memcmp (buf, proto1, 3) != 0 && memcmp (buf, proto2, 4) != 0)
     return pc;
 
@@ -454,7 +454,7 @@ i386_skip_probe (CORE_ADDR pc)
   gdb_byte buf[8];
   gdb_byte op;
 
-  read_memory_nobpt (pc, &op, 1);
+  target_read_memory (pc, &op, 1);
 
   if (op == 0x68 || op == 0x6a)
     {
@@ -541,7 +541,7 @@ i386_match_insn (CORE_ADDR pc, struct i386_insn *skip_insns)
   struct i386_insn *insn;
   gdb_byte op;
 
-  read_memory_nobpt (pc, &op, 1);
+  target_read_memory (pc, &op, 1);
 
   for (insn = skip_insns; insn->len > 0; insn++)
     {
@@ -554,7 +554,7 @@ i386_match_insn (CORE_ADDR pc, struct i386_insn *skip_insns)
          gdb_assert (insn->len > 1);
          gdb_assert (insn->len <= I386_MAX_INSN_LEN);
 
-         read_memory_nobpt (pc + 1, buf, insn->len - 1);
+         target_read_memory (pc + 1, buf, insn->len - 1);
          for (i = 1; i < insn->len; i++)
            {
              if ((buf[i - 1] & insn->mask[i]) != insn->insn[i])
@@ -632,7 +632,7 @@ i386_skip_noop (CORE_ADDR pc)
   gdb_byte op;
   int check = 1;
 
-  read_memory_nobpt (pc, &op, 1);
+  target_read_memory (pc, &op, 1);
 
   while (check) 
     {
@@ -641,7 +641,7 @@ i386_skip_noop (CORE_ADDR pc)
       if (op == 0x90) 
        {
          pc += 1;
-         read_memory_nobpt (pc, &op, 1);
+         target_read_memory (pc, &op, 1);
          check = 1;
        }
       /* Ignore no-op instruction `mov %edi, %edi'.
@@ -657,11 +657,11 @@ i386_skip_noop (CORE_ADDR pc)
 
       else if (op == 0x8b)
        {
-         read_memory_nobpt (pc + 1, &op, 1);
+         target_read_memory (pc + 1, &op, 1);
          if (op == 0xff)
            {
              pc += 2;
-             read_memory_nobpt (pc, &op, 1);
+             target_read_memory (pc, &op, 1);
              check = 1;
            }
        }
@@ -685,7 +685,7 @@ i386_analyze_frame_setup (CORE_ADDR pc, CORE_ADDR limit,
   if (limit <= pc)
     return limit;
 
-  read_memory_nobpt (pc, &op, 1);
+  target_read_memory (pc, &op, 1);
 
   if (op == 0x55)              /* pushl %ebp */
     {
@@ -720,7 +720,7 @@ i386_analyze_frame_setup (CORE_ADDR pc, CORE_ADDR limit,
       if (limit <= pc + skip)
        return limit;
 
-      read_memory_nobpt (pc + skip, &op, 1);
+      target_read_memory (pc + skip, &op, 1);
 
       /* Check for `movl %esp, %ebp' -- can be written in two ways.  */
       switch (op)
@@ -754,7 +754,7 @@ i386_analyze_frame_setup (CORE_ADDR pc, CORE_ADDR limit,
 
         NOTE: You can't subtract a 16-bit immediate from a 32-bit
         reg, so we don't have to worry about a data16 prefix.  */
-      read_memory_nobpt (pc, &op, 1);
+      target_read_memory (pc, &op, 1);
       if (op == 0x83)
        {
          /* `subl' with 8-bit immediate.  */
@@ -810,7 +810,7 @@ i386_analyze_register_saves (CORE_ADDR pc, CORE_ADDR current_pc,
     offset -= cache->locals;
   for (i = 0; i < 8 && pc < current_pc; i++)
     {
-      read_memory_nobpt (pc, &op, 1);
+      target_read_memory (pc, &op, 1);
       if (op < 0x50 || op > 0x57)
        break;
 
@@ -900,7 +900,7 @@ i386_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
 
   for (i = 0; i < 6; i++)
     {
-      read_memory_nobpt (pc + i, &op, 1);
+      target_read_memory (pc + i, &op, 1);
       if (pic_pat[i] != op)
        break;
     }
@@ -908,7 +908,7 @@ i386_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
     {
       int delta = 6;
 
-      read_memory_nobpt (pc + delta, &op, 1);
+      target_read_memory (pc + delta, &op, 1);
 
       if (op == 0x89)          /* movl %ebx, x(%ebp) */
        {
@@ -921,7 +921,7 @@ i386_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
          else                  /* Unexpected instruction.  */
            delta = 0;
 
-          read_memory_nobpt (pc + delta, &op, 1);
+          target_read_memory (pc + delta, &op, 1);
        }
 
       /* addl y,%ebx */
index c0eb9d59a59b2e88779626f301a6c13c3c6ef72f..eaa103149661814d925549e5d5c11ef1e71ef895 100644 (file)
@@ -69,7 +69,7 @@ m68k_linux_pc_in_sigtramp (CORE_ADDR pc, char *name)
   char buf[12];
   unsigned long insn0, insn1, insn2;
 
-  if (read_memory_nobpt (pc - 4, buf, sizeof (buf)))
+  if (target_read_memory (pc - 4, buf, sizeof (buf)))
     return 0;
   insn1 = extract_unsigned_integer (buf + 4, 4);
   insn2 = extract_unsigned_integer (buf + 8, 4);
index 02217cdd6e574e548dc7fd07889062e89d167e9f..8b0290eeb22fc1421dfe923653a09b11e71caf66 100644 (file)
@@ -926,7 +926,7 @@ mips_fetch_instruction (CORE_ADDR addr)
     }
   else
     instlen = MIPS_INSN32_SIZE;
-  status = read_memory_nobpt (addr, buf, instlen);
+  status = target_read_memory (addr, buf, instlen);
   if (status)
     memory_error (status, addr);
   return extract_unsigned_integer (buf, instlen);
index 30483364b196d5b5ae4d0e66ee73625bb2586412..37236857fe386c4827e463c05622eedf6c840516 100644 (file)
@@ -620,7 +620,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch, struct frame_info *fi,
        goto finish_prologue;
 
       /* Get the next two bytes so the prologue scan can continue.  */
-      status = read_memory_nobpt (addr, buf, 2);
+      status = target_read_memory (addr, buf, 2);
       if (status != 0)
        goto finish_prologue;
     }
@@ -761,7 +761,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch, struct frame_info *fi,
       if (!fmov_found)
        {
          addr = restore_addr;
-         status = read_memory_nobpt (addr, buf, 2);
+         status = target_read_memory (addr, buf, 2);
          if (status != 0)
            goto finish_prologue;
          stack_extra_size = 0;
index 872db01672ca0c47a2c7983bcf982b7fbded9d94..d0901de02c7d42821fb07afed6fd2557385719d7 100644 (file)
@@ -281,12 +281,15 @@ ppc_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
   int val;
   int bplen;
   gdb_byte old_contents[BREAKPOINT_MAX];
+  struct cleanup *cleanup;
 
   /* Determine appropriate breakpoint contents and size for this address.  */
   bp = gdbarch_breakpoint_from_pc (gdbarch, &addr, &bplen);
   if (bp == NULL)
     error (_("Software breakpoints not implemented for this target."));
 
+  /* Make sure we see the memory breakpoints.  */
+  cleanup = make_show_memory_breakpoints_cleanup (1);
   val = target_read_memory (addr, old_contents, bplen);
 
   /* If our breakpoint is no longer at the address, this means that the
@@ -295,6 +298,7 @@ ppc_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
   if (val == 0 && memcmp (bp, old_contents, bplen) == 0)
     val = target_write_memory (addr, bp_tgt->shadow_contents, bplen);
 
+  do_cleanups (cleanup);
   return val;
 }
 
index 9cb639b147d4180f11b459e68481f95ac5464fd4..bfcb247dfe8ad371558cbb47ddb9b4dbd4ea0367 100644 (file)
@@ -503,12 +503,12 @@ s390_readinstruction (bfd_byte instr[], CORE_ADDR at)
   static int s390_instrlen[] = { 2, 4, 4, 6 };
   int instrlen;
 
-  if (read_memory_nobpt (at, &instr[0], 2))
+  if (target_read_memory (at, &instr[0], 2))
     return -1;
   instrlen = s390_instrlen[instr[0] >> 6];
   if (instrlen > 2)
     {
-      if (read_memory_nobpt (at + 2, &instr[2], instrlen - 2))
+      if (target_read_memory (at + 2, &instr[2], instrlen - 2))
         return -1;
     }
   return instrlen;
@@ -1132,19 +1132,19 @@ s390_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
   int d2;
 
   if (word_size == 4
-      && !read_memory_nobpt (pc - 4, insn, 4)
+      && !target_read_memory (pc - 4, insn, 4)
       && is_rs (insn, op_lm, &r1, &r3, &d2, &b2)
       && r3 == S390_SP_REGNUM - S390_R0_REGNUM)
     return 1;
 
   if (word_size == 4
-      && !read_memory_nobpt (pc - 6, insn, 6)
+      && !target_read_memory (pc - 6, insn, 6)
       && is_rsy (insn, op1_lmy, op2_lmy, &r1, &r3, &d2, &b2)
       && r3 == S390_SP_REGNUM - S390_R0_REGNUM)
     return 1;
 
   if (word_size == 8
-      && !read_memory_nobpt (pc - 6, insn, 6)
+      && !target_read_memory (pc - 6, insn, 6)
       && is_rsy (insn, op1_lmg, op2_lmg, &r1, &r3, &d2, &b2)
       && r3 == S390_SP_REGNUM - S390_R0_REGNUM)
     return 1;
@@ -1658,7 +1658,7 @@ s390_sigtramp_frame_sniffer (struct frame_info *next_frame)
   CORE_ADDR pc = frame_pc_unwind (next_frame);
   bfd_byte sigreturn[2];
 
-  if (read_memory_nobpt (pc, sigreturn, 2))
+  if (target_read_memory (pc, sigreturn, 2))
     return NULL;
 
   if (sigreturn[0] != 0x0a /* svc */)
index 10656734d349bb6f3fb9ad2abc2fce7405cd96b2..4d690efc16f698c5d45462da586d49c388d19f0c 100644 (file)
@@ -99,7 +99,7 @@ sparc_fetch_instruction (CORE_ADDR pc)
   int i;
 
   /* If we can't read the instruction at PC, return zero.  */
-  if (read_memory_nobpt (pc, buf, sizeof (buf)))
+  if (target_read_memory (pc, buf, sizeof (buf)))
     return 0;
 
   insn = 0;
index ceb71b36cde459d360e811b88e00dd34cb9f1d7f..9d2f1fd355e0598b017eeec993956ba7b9ba4bb7 100644 (file)
@@ -39,6 +39,7 @@
 #include "gdbcore.h"
 #include "exceptions.h"
 #include "target-descriptions.h"
+#include "gdb_stdint.h"
 
 static void target_info (char *, int);
 
@@ -203,6 +204,11 @@ int attach_flag;
 
 static int trust_readonly = 0;
 
+/* Nonzero if we should show true memory content including
+   memory breakpoint inserted by gdb.  */
+
+static int show_memory_breakpoints = 0;
+
 /* Non-zero if we want to see trace of target level stuff.  */
 
 static int targetdebug = 0;
@@ -1064,7 +1070,11 @@ memory_xfer_partial (struct target_ops *ops, void *readbuf, const void *writebuf
       if (res <= 0)
        return -1;
       else
-       return res;
+       {
+         if (readbuf && !show_memory_breakpoints)
+           breakpoint_restore_shadows (readbuf, memaddr, reg_len);
+         return res;
+       }
     }
 
   /* If none of those methods found the memory we wanted, fall back
@@ -1082,22 +1092,41 @@ memory_xfer_partial (struct target_ops *ops, void *readbuf, const void *writebuf
       res = ops->to_xfer_partial (ops, TARGET_OBJECT_MEMORY, NULL,
                                  readbuf, writebuf, memaddr, reg_len);
       if (res > 0)
-       return res;
+       break;
 
       /* We want to continue past core files to executables, but not
         past a running target's memory.  */
       if (ops->to_has_all_memory)
-       return res;
+       break;
 
       ops = ops->beneath;
     }
   while (ops != NULL);
 
+  if (readbuf && !show_memory_breakpoints)
+    breakpoint_restore_shadows (readbuf, memaddr, reg_len);
+
   /* If we still haven't got anything, return the last error.  We
      give up.  */
   return res;
 }
 
+static void
+restore_show_memory_breakpoints (void *arg)
+{
+  show_memory_breakpoints = (uintptr_t) arg;
+}
+
+struct cleanup *
+make_show_memory_breakpoints_cleanup (int show)
+{
+  int current = show_memory_breakpoints;
+  show_memory_breakpoints = show;
+
+  return make_cleanup (restore_show_memory_breakpoints,
+                      (void *) (uintptr_t) current);
+}
+
 static LONGEST
 target_xfer_partial (struct target_ops *ops,
                     enum target_object object, const char *annex,
index b7038304cbad2802fa18ddb2ec0d8d8950dd1abb..9a34244e3b651703f4547e5b39f76d5dd88c75a2 100644 (file)
@@ -1250,6 +1250,11 @@ extern enum target_signal target_signal_from_command (int);
 
 /* Any target can call this to switch to remote protocol (in remote.c). */
 extern void push_remote_target (char *name, int from_tty);
+
+/* Set the show memory breakpoints mode to show, and installs a cleanup
+   to restore it back to the current value.  */
+extern struct cleanup *make_show_memory_breakpoints_cleanup (int show);
+
 \f
 /* Imported from machine dependent code */