This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug gdb/15299] Verify breakpoint bytes when removing the breakpoint


http://sourceware.org/bugzilla/show_bug.cgi?id=15299

--- Comment #8 from Jan Kratochvil <jan.kratochvil at redhat dot com> 2013-03-25 12:22:28 UTC ---
(In reply to comment #7)
> Hmm... Maybe I can write a GDB plugin that doing many "stepi" and checks each
> instruction working with RAM on the subject of whether it is trying to read or
> write from/to position of software breakpoints. And if it do so, plugin
> interrupts this "stepi-check_opcode" loop.

I see it overcomplicated.  Just patch default_memory_remove_breakpoint in
gdb/mem-break.c so that it:
 * Temporarily sets show_memory_breakpoints.
 * Uses target_read_memory to fetch the data from inferior.
 * Compares the read in bytes with what gdbarch_breakpoint_from_pc returns
   and if it does not match it prints some warning and prevents the current
   call of target_write_raw_memory with shadow_contents.
 * Restores show_memory_breakpoints (see make_show_memory_breakpoints_cleanup).

And it should be configurable as it will be a performance hit primarily with
remote targets.

See also several *-tdep.c files using set_gdbarch_memory_remove_breakpoint as
they have something more specific than default_memory_remove_breakpoint.


> Why does my program in assembler
> does not overwrite the bytes of software breakpoint?

 * GDB inserts breakpoint:
   * GDB saves original (old) instruction.
   * GDB writes there breakpoint
 * Your code overwrites the breakpoint by new instruction.
 * GDB removes breakpoint:
   * GDB writes there the original (old) instruction.
     - Your new instruction is lost.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]