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 #9 from SztfG at yandex dot ru 2013-03-25 21:46:36 UTC ---
Created attachment 6948
  --> http://sourceware.org/bugzilla/attachment.cgi?id=6948
testing GDB

(In reply to comment #8)
> (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.
> 
Yes, this is good idea if memory write check is enough, but how can it help if
the program read from software breakpoint address (integrity check)?
What happens if instruction under breakpoint "wants" read or overwrite himself?
I'll check it. I'm going to read the GDB Internals Manual and try to do
something

> 
> > 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.
It behaves differently. If GDB step into another breakpoint, then it rewrite
breakpoints. See attached. Why?

-- 
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]