public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Marco Molteni <molter@tin.it>
To: gdb@sources.redhat.com
Subject: breakpoint instruction isn't shown in disassemble or examine (x) commands?
Date: Wed, 29 Sep 2004 23:05:00 -0000	[thread overview]
Message-ID: <20040930010335.2fa022b5.molter@tin.it> (raw)

Hi,

I am trying to understand the inner workings of a debugger and I found
a gdb behaviour that puzzles me.

I understand that if I set a software breakpoint (as opposed to
an hw breakpoint), gdb will insert an architecture-dependent instruction
in the .text section that will cause an exception, that will be handled
by gdb.

I am using gdb 6.1.1 on FreeBSD i386, so looking at the gdb source,
the i386 has the breakpoint instruction 0xcc.

I tought of doing something like (in various incantations):

(gdb) disassemble foo
(gdb) break foo
(gdb) disassemble foo

and was expecting of seeing the 0xcc instruction in the output of
the second disassemble command; instead the output is the same
as the first disassemble. Same results with the x command.
It seems that gdb wants to "protect" me from seing that the executable
is changed?

Finally I came up with a function that scans the .text section of
the same program (a sort of very naive debugger detector)
and hex dumps it. I ran the same program with and without
breakpoint and my scan function works as expected: when the breakpoint is
set I see it in the hex dump.

So somehow I have my sanity back, but the question remains: how
can I see the breakpoint instruction from gdb itself?

thanks
marco
-- 
panic("The moon has moved again.");

             reply	other threads:[~2004-09-29 23:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-29 23:05 Marco Molteni [this message]
2004-09-30 14:49 ` Eli Zaretskii
2004-09-30 19:36   ` Marco Molteni
     [not found] <1096526181.3491.ezmlm@sources.redhat.com>
2004-09-30 17:30 ` Jim Ingham
2004-09-30 19:39   ` Marco Molteni
     [not found] <52BBA75459915749B68F93B604B636CD0D421E@neptune.TidalNetworks.net>
2004-09-30 17:56 ` Jim Ingham

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=20040930010335.2fa022b5.molter@tin.it \
    --to=molter@tin.it \
    --cc=gdb@sources.redhat.com \
    /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).