From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14068 invoked by alias); 23 Jun 2004 05:03:22 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 14060 invoked from network); 23 Jun 2004 05:03:22 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 23 Jun 2004 05:03:22 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i5N53Le1005430 for ; Wed, 23 Jun 2004 01:03:21 -0400 Received: from zenia.home.redhat.com (porkchop.devel.redhat.com [172.16.58.2]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i5N53J006194; Wed, 23 Jun 2004 01:03:20 -0400 To: Tao Zhang Cc: Michael Elizabeth Chastain , gdb@sources.redhat.com Subject: Re: Debug code in data section in gdb References: <20040622210556.3556C4B104@berman.michael-chastain.com> From: Jim Blandy Date: Wed, 23 Jun 2004 05:03:00 -0000 In-Reply-To: Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2004-06/txt/msg00231.txt.bz2 Tao Zhang writes: > Yeah, I understand GDB will modify the code at the address of a > breakpoint. I can break the program just before the execution jump to the > code copied from somewhere. Then I set a breakpoint at the beginning of > the copied code. It still won't work. Another thing is I see the code is > same as the original code. My question is whether I can see the GDB modified > instruction by disassemble the memory ? When and How gdb modifies the > instruction? GDB inserts breakpoints just before resuming the inferior (debuggee) and removes them all each time the inferior stops. When you disassemble, the inferior is stopped, so you won't see GDB's breakpoint. You said your inferior was running "without an OS", so I assume you're communicating with it via the GDB remote protocol. Have you tried "set debug remote 1" to see exactly what GDB and your inferior are saying to each other? In particular, you should be able to see GDB writing the breakpoint instruction, after reading the original contents, and then restoring the original contents when the inferior stops.