From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19249 invoked by alias); 29 Jan 2012 16:48:43 -0000 Received: (qmail 19241 invoked by uid 22791); 29 Jan 2012 16:48:42 -0000 X-SWARE-Spam-Status: No, hits=-0.9 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-iy0-f169.google.com (HELO mail-iy0-f169.google.com) (209.85.210.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 29 Jan 2012 16:48:31 +0000 Received: by iadk27 with SMTP id k27so5325916iad.0 for ; Sun, 29 Jan 2012 08:48:30 -0800 (PST) MIME-Version: 1.0 Received: by 10.50.135.1 with SMTP id po1mr14542772igb.26.1327855710460; Sun, 29 Jan 2012 08:48:30 -0800 (PST) Received: by 10.231.211.77 with HTTP; Sun, 29 Jan 2012 08:48:30 -0800 (PST) Date: Sun, 29 Jan 2012 16:48:00 -0000 Message-ID: Subject: software breakpoint in gdb From: Xin Tong To: gdb@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 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: 2012-01/txt/msg00108.txt.bz2 Hello I have 2 questions on how software breakpoint is done in gdb. One of the most commonly used feature is breakpoint. Breakpoint can be implemented in two ways, hardware breakpoint and software breakpoint. Hardware breakpoint requires hardware support. Typically, x86 processors come with some debugging register and when a breakpoint is required, the pc of the instruction is stored into the debug register and checked whenever an instruction executes. Software breakpoint, on x86 if no hardware breakpoint register is supported or the machine runs out of hardware registers. It will fall back to software breakpoint. Software breakpoint involves replacing the breakpointed instruction with an interrupt instruction. What if the interrupt instruction is bigger than breakpointed instruction ? Where is the breakpointed instruction kept after it is overwritten by an interrupt instruction in gdb ? Thanks