public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "jan.kratochvil at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/15299] Verify breakpoint bytes when removing the breakpoint
Date: Mon, 25 Mar 2013 12:22:00 -0000	[thread overview]
Message-ID: <bug-15299-4717-t6WcpV4NPf@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-15299-4717@http.sourceware.org/bugzilla/>

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.


  parent reply	other threads:[~2013-03-25 12:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-24  8:15 [Bug gdb/15299] New: Error memory write when debugging self-modifying code SztfG at yandex dot ru
2013-03-24  8:51 ` [Bug gdb/15299] Verify breakpoint bytes when removing the breakpoint jan.kratochvil at redhat dot com
2013-03-24  9:15 ` SztfG at yandex dot ru
2013-03-24  9:25 ` jan.kratochvil at redhat dot com
2013-03-24  9:56 ` SztfG at yandex dot ru
2013-03-24 11:13 ` jan.kratochvil at redhat dot com
2013-03-24 13:45 ` SztfG at yandex dot ru
2013-03-24 17:07 ` SztfG at yandex dot ru
2013-03-25 12:12 ` SztfG at yandex dot ru
2013-03-25 12:22 ` jan.kratochvil at redhat dot com [this message]
2013-03-25 21:46 ` SztfG at yandex dot ru
2013-03-27 18:28 ` jan.kratochvil at redhat dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-15299-4717-t6WcpV4NPf@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).