From: "Satendra..." <satendra.pratap@gmail.com>
To: kceiwH <kceiwh@gmail.com>
Cc: gdb@sourceware.org
Subject: Re: How GDB knows a breakpoint is hit?
Date: Wed, 19 Aug 2009 19:13:00 -0000 [thread overview]
Message-ID: <27a6661f0908190937vc7323d5ubeea8682b61220d5@mail.gmail.com> (raw)
In-Reply-To: <84D22DD1-F4AD-4985-A0EC-AF3B53774D10@gmail.com>
whenever you put a breakpoint at some address using GDB then GDB
replaces instruction at
that address with a trap, illegal divide, or some other instruction
that will cause an exception.
So when it's encountered, GDB will take the exception and stop the program.
Before you browse the code, go through
http://sourceware.org/gdb/current/onlinedocs/gdbint_toc.html
once.
-Satendra
On 19/08/2009, kceiwH <kceiwh@gmail.com> wrote:
> Hi,
>
> I wonder how GDB knows it should stop the inferior when a breakpoint
> is hit. I try to read the code but only to find how GDB creates a
> breakpoint. I thought GDB might change some instructions of inferior
> so that when the inferior executes the modified instructions, GDB
> should know. But what the function "create_breakpoint" does is to add
> a breakpoint to the list "breakpoint_chain". It is not what I thought.
> So I am confused. Does GDB monitor each instruction of the inferior
> and check whether there is a breakpoint and stop the inferior before
> the instruction is executed? If so, how GDB monitor the inferior? And
> it will be too slow. Could anybody tell how GDB handle it and plus the
> codes. Thanks in advance.
>
> Regards,
>
> Mao
>
next prev parent reply other threads:[~2009-08-19 16:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-19 15:52 kceiwH
2009-08-19 19:13 ` Satendra... [this message]
2009-08-19 22:11 ` Andreas Schwab
2009-08-20 2:21 ` kceiwH
2009-08-20 6:54 ` Hui Zhu
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=27a6661f0908190937vc7323d5ubeea8682b61220d5@mail.gmail.com \
--to=satendra.pratap@gmail.com \
--cc=gdb@sourceware.org \
--cc=kceiwh@gmail.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