From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32158 invoked by alias); 19 Aug 2009 15:28:31 -0000 Received: (qmail 32148 invoked by uid 22791); 19 Aug 2009 15:28:30 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from qw-out-1920.google.com (HELO qw-out-1920.google.com) (74.125.92.145) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 19 Aug 2009 15:28:23 +0000 Received: by qw-out-1920.google.com with SMTP id 5so2332854qwf.24 for ; Wed, 19 Aug 2009 08:28:21 -0700 (PDT) Received: by 10.224.33.129 with SMTP id h1mr6511010qad.213.1250695700874; Wed, 19 Aug 2009 08:28:20 -0700 (PDT) Received: from dyn-209-2-225-148.dyn.columbia.edu (dyn-209-2-225-148.dyn.columbia.edu [209.2.225.148]) by mx.google.com with ESMTPS id 5sm209866qwg.40.2009.08.19.08.28.19 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 19 Aug 2009 08:28:20 -0700 (PDT) Message-Id: <84D22DD1-F4AD-4985-A0EC-AF3B53774D10@gmail.com> From: kceiwH To: gdb@sourceware.org Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v936) Subject: How GDB knows a breakpoint is hit? Date: Wed, 19 Aug 2009 15:52:00 -0000 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/msg00174.txt.bz2 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