From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6164 invoked by alias); 10 Mar 2008 20:43:11 -0000 Received: (qmail 6154 invoked by uid 22791); 10 Mar 2008 20:43:08 -0000 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 10 Mar 2008 20:42:47 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id 20156983B5; Mon, 10 Mar 2008 20:42:45 +0000 (GMT) Received: from caradoc.them.org (22.svnf5.xdsl.nauticom.net [209.195.183.55]) by nan.false.org (Postfix) with ESMTP id 125F29801D; Mon, 10 Mar 2008 20:42:44 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.69) (envelope-from ) id 1JYopW-0000JS-II; Mon, 10 Mar 2008 16:42:42 -0400 Date: Mon, 10 Mar 2008 20:43:00 -0000 From: Daniel Jacobowitz To: Vladimir Prus Cc: gdb-patches@sources.redhat.com Subject: Re: [RFA] Try2: Ignore breakpoints when reading memory. Message-ID: <20080310204242.GA14908@caradoc.them.org> Mail-Followup-To: Vladimir Prus , gdb-patches@sources.redhat.com References: <200802241750.41264.vladimir@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200802241750.41264.vladimir@codesourcery.com> User-Agent: Mutt/1.5.17 (2007-12-11) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-03/txt/msg00106.txt.bz2 On Sun, Feb 24, 2008 at 05:50:39PM +0300, Vladimir Prus wrote: > > This a second attempt at making gdb always ignore > any memory breakpoints that are inserted and show the original > memory content. This patch is the immediate prerequisite for the > patch that makes breakpoints always inserted. > > Unlike the previous patch, there's a mechanism to: > 1. Control the new behaviour from command line. Do you think we need the option is useful? I think we'll want one for leave-breakpoints-inserted mode, which is a bigger change, but this patch should only affect GDB internals. > +static void > +restore_show_memory_breakpoints (void *arg) > +{ > + show_memory_breakpoints = (int)arg; > +} This will fail with -Werror on a 64-bit host. That leaves the attached patch. Tested on x86_64-linux, no regressions. How's it look? I deleted read_memory_nobpt entirely. -- Daniel Jacobowitz CodeSourcery 2008-03-10 Vladimir Prus Daniel Jacobowitz * 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. Index: Makefile.in =================================================================== RCS file: /cvs/src/src/gdb/Makefile.in,v retrieving revision 1.987 diff -u -p -r1.987 Makefile.in --- Makefile.in 5 Mar 2008 17:21:10 -0000 1.987 +++ Makefile.in 10 Mar 2008 20:21:45 -0000 @@ -2873,7 +2873,7 @@ symtab.o: symtab.c $(defs_h) $(symtab_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: alpha-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/alpha-tdep.c,v retrieving revision 1.182 diff -u -p -r1.182 alpha-tdep.c --- alpha-tdep.c 20 Feb 2008 15:45:20 -0000 1.182 +++ alpha-tdep.c 10 Mar 2008 20:21:45 -0000 @@ -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: alphanbsd-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/alphanbsd-tdep.c,v retrieving revision 1.36 diff -u -p -r1.36 alphanbsd-tdep.c --- alphanbsd-tdep.c 1 Jan 2008 22:53:09 -0000 1.36 +++ alphanbsd-tdep.c 10 Mar 2008 20:21:45 -0000 @@ -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: breakpoint.c =================================================================== RCS file: /cvs/src/src/gdb/breakpoint.c,v retrieving revision 1.305 diff -u -p -r1.305 breakpoint.c --- breakpoint.c 3 Mar 2008 13:24:12 -0000 1.305 +++ breakpoint.c 10 Mar 2008 20:21:46 -0000 @@ -702,25 +702,16 @@ commands_from_control_command (char *arg error (_("No breakpoint number %d."), bnum); } -/* 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, gd 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); } @@ -4299,7 +4266,7 @@ set_raw_breakpoint (struct symtab_and_li /* 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: breakpoint.h =================================================================== RCS file: /cvs/src/src/gdb/breakpoint.h,v retrieving revision 1.66 diff -u -p -r1.66 breakpoint.h --- breakpoint.h 3 Mar 2008 13:24:12 -0000 1.66 +++ breakpoint.h 10 Mar 2008 20:21:46 -0000 @@ -859,4 +859,9 @@ extern int deprecated_remove_raw_breakpo 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: frame.c =================================================================== RCS file: /cvs/src/src/gdb/frame.c,v retrieving revision 1.237 diff -u -p -r1.237 frame.c --- frame.c 28 Feb 2008 16:24:24 -0000 1.237 +++ frame.c 10 Mar 2008 20:21:46 -0000 @@ -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: frv-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/frv-tdep.c,v retrieving revision 1.118 diff -u -p -r1.118 frv-tdep.c --- frv-tdep.c 11 Jan 2008 13:19:59 -0000 1.118 +++ frv-tdep.c 10 Mar 2008 20:21:46 -0000 @@ -449,7 +449,7 @@ frv_adjust_breakpoint_address (struct gd 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: gdbcore.h =================================================================== RCS file: /cvs/src/src/gdb/gdbcore.h,v retrieving revision 1.28 diff -u -p -r1.28 gdbcore.h --- gdbcore.h 1 Jan 2008 22:53:10 -0000 1.28 +++ gdbcore.h 10 Mar 2008 20:21:46 -0000 @@ -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: hppa-linux-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/hppa-linux-tdep.c,v retrieving revision 1.27 diff -u -p -r1.27 hppa-linux-tdep.c --- hppa-linux-tdep.c 18 Feb 2008 16:11:21 -0000 1.27 +++ hppa-linux-tdep.c 10 Mar 2008 20:21:46 -0000 @@ -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: hppa-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/hppa-tdep.c,v retrieving revision 1.247 diff -u -p -r1.247 hppa-tdep.c --- hppa-tdep.c 18 Feb 2008 16:11:21 -0000 1.247 +++ hppa-tdep.c 10 Mar 2008 20:21:47 -0000 @@ -545,7 +545,7 @@ hppa_in_function_epilogue_p (struct gdba 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 i { 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: i386-linux-nat.c =================================================================== RCS file: /cvs/src/src/gdb/i386-linux-nat.c,v retrieving revision 1.86 diff -u -p -r1.86 i386-linux-nat.c --- i386-linux-nat.c 1 Mar 2008 04:39:36 -0000 1.86 +++ i386-linux-nat.c 10 Mar 2008 20:21:47 -0000 @@ -770,7 +770,7 @@ i386_linux_resume (ptid_t ptid, int step 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: i386-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/i386-tdep.c,v retrieving revision 1.250 diff -u -p -r1.250 i386-tdep.c --- i386-tdep.c 26 Feb 2008 22:23:45 -0000 1.250 +++ i386-tdep.c 10 Mar 2008 20:21:47 -0000 @@ -352,7 +352,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; @@ -418,12 +418,12 @@ i386_analyze_struct_return (CORE_ADDR 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; @@ -462,7 +462,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) { @@ -549,7 +549,7 @@ i386_match_insn (CORE_ADDR pc, struct i3 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++) { @@ -562,7 +562,7 @@ i386_match_insn (CORE_ADDR pc, struct i3 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]) @@ -640,7 +640,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) { @@ -649,7 +649,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'. @@ -665,11 +665,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; } } @@ -693,7 +693,7 @@ i386_analyze_frame_setup (CORE_ADDR pc, if (limit <= pc) return limit; - read_memory_nobpt (pc, &op, 1); + target_read_memory (pc, &op, 1); if (op == 0x55) /* pushl %ebp */ { @@ -728,7 +728,7 @@ i386_analyze_frame_setup (CORE_ADDR pc, 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) @@ -762,7 +762,7 @@ i386_analyze_frame_setup (CORE_ADDR pc, 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. */ @@ -818,7 +818,7 @@ i386_analyze_register_saves (CORE_ADDR p 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; @@ -908,7 +908,7 @@ i386_skip_prologue (struct gdbarch *gdba 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; } @@ -916,7 +916,7 @@ i386_skip_prologue (struct gdbarch *gdba { int delta = 6; - read_memory_nobpt (pc + delta, &op, 1); + target_read_memory (pc + delta, &op, 1); if (op == 0x89) /* movl %ebx, x(%ebp) */ { @@ -929,7 +929,7 @@ i386_skip_prologue (struct gdbarch *gdba else /* Unexpected instruction. */ delta = 0; - read_memory_nobpt (pc + delta, &op, 1); + target_read_memory (pc + delta, &op, 1); } /* addl y,%ebx */ Index: m68klinux-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/m68klinux-tdep.c,v retrieving revision 1.27 diff -u -p -r1.27 m68klinux-tdep.c --- m68klinux-tdep.c 1 Jan 2008 22:53:12 -0000 1.27 +++ m68klinux-tdep.c 10 Mar 2008 20:21:47 -0000 @@ -69,7 +69,7 @@ m68k_linux_pc_in_sigtramp (CORE_ADDR pc, 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: mips-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/mips-tdep.c,v retrieving revision 1.469 diff -u -p -r1.469 mips-tdep.c --- mips-tdep.c 20 Feb 2008 14:34:43 -0000 1.469 +++ mips-tdep.c 10 Mar 2008 20:21:47 -0000 @@ -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: mn10300-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/mn10300-tdep.c,v retrieving revision 1.154 diff -u -p -r1.154 mn10300-tdep.c --- mn10300-tdep.c 5 Feb 2008 16:20:20 -0000 1.154 +++ mn10300-tdep.c 10 Mar 2008 20:21:47 -0000 @@ -620,7 +620,7 @@ mn10300_analyze_prologue (struct gdbarch 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 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: ppc-linux-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/ppc-linux-tdep.c,v retrieving revision 1.94 diff -u -p -r1.94 ppc-linux-tdep.c --- ppc-linux-tdep.c 20 Feb 2008 14:31:40 -0000 1.94 +++ ppc-linux-tdep.c 10 Mar 2008 20:21:47 -0000 @@ -281,12 +281,15 @@ ppc_linux_memory_remove_breakpoint (stru 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 (stru 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: s390-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/s390-tdep.c,v retrieving revision 1.170 diff -u -p -r1.170 s390-tdep.c --- s390-tdep.c 31 Jan 2008 15:43:32 -0000 1.170 +++ s390-tdep.c 10 Mar 2008 20:21:48 -0000 @@ -503,12 +503,12 @@ s390_readinstruction (bfd_byte instr[], 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 gdba 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 fram 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: sparc-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/sparc-tdep.c,v retrieving revision 1.193 diff -u -p -r1.193 sparc-tdep.c --- sparc-tdep.c 11 Jan 2008 14:43:15 -0000 1.193 +++ sparc-tdep.c 10 Mar 2008 20:21:48 -0000 @@ -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: target.c =================================================================== RCS file: /cvs/src/src/gdb/target.c,v retrieving revision 1.155 diff -u -p -r1.155 target.c --- target.c 28 Feb 2008 16:26:17 -0000 1.155 +++ target.c 10 Mar 2008 20:21:48 -0000 @@ -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 * 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 * 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: target.h =================================================================== RCS file: /cvs/src/src/gdb/target.h,v retrieving revision 1.111 diff -u -p -r1.111 target.h --- target.h 28 Feb 2008 16:26:17 -0000 1.111 +++ target.h 10 Mar 2008 20:21:48 -0000 @@ -1250,6 +1250,11 @@ extern enum target_signal target_signal_ /* 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); + /* Imported from machine dependent code */