From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18832 invoked by alias); 20 Aug 2009 06:53:00 -0000 Received: (qmail 18824 invoked by uid 22791); 20 Aug 2009 06:52:59 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-px0-f194.google.com (HELO mail-px0-f194.google.com) (209.85.216.194) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 20 Aug 2009 06:52:50 +0000 Received: by pxi32 with SMTP id 32so2744080pxi.25 for ; Wed, 19 Aug 2009 23:52:48 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.4.16 with SMTP id 16mr1405004wfd.88.1250751168213; Wed, 19 Aug 2009 23:52:48 -0700 (PDT) In-Reply-To: <84D22DD1-F4AD-4985-A0EC-AF3B53774D10@gmail.com> References: <84D22DD1-F4AD-4985-A0EC-AF3B53774D10@gmail.com> From: Hui Zhu Date: Thu, 20 Aug 2009 06:54:00 -0000 Message-ID: Subject: Re: How GDB knows a breakpoint is hit? To: kceiwH Cc: gdb@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2009-08/txt/msg00194.txt.bz2 I think you can read the code around function bpstat_what. Hui On Wed, Aug 19, 2009 at 23:28, kceiwH wrote: > > Hi, > > I wonder how GDB knows it should stop the inferior when a breakpoint is h= it. 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 in= ferior executes the modified instructions, GDB should know. But what the fu= nction "create_breakpoint" does is to add a breakpoint to the list "breakpo= int_chain". It is not what I thought. So I am confused. Does GDB monitor ea= ch instruction of the inferior and check whether there is a breakpoint and = stop the inferior before the instruction is executed? If so, how GDB monito= r the inferior? And it will be too slow. Could anybody tell how GDB handle = it and plus the codes. Thanks in advance. > > Regards, > > Mao