From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17816 invoked by alias); 19 Feb 2008 21:41:44 -0000 Received: (qmail 17808 invoked by uid 22791); 19 Feb 2008 21:41:43 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.33.17) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 19 Feb 2008 21:41:13 +0000 Received: from zps37.corp.google.com (zps37.corp.google.com [172.25.146.37]) by smtp-out.google.com with ESMTP id m1JLf1c6028239 for ; Tue, 19 Feb 2008 21:41:02 GMT Received: from wr-out-0506.google.com (wri60.prod.google.com [10.54.9.60]) by zps37.corp.google.com with ESMTP id m1JLdVjM008000 for ; Tue, 19 Feb 2008 13:41:01 -0800 Received: by wr-out-0506.google.com with SMTP id 60so2396628wri.8 for ; Tue, 19 Feb 2008 13:41:00 -0800 (PST) Received: by 10.114.80.4 with SMTP id d4mr980646wab.44.1203457260734; Tue, 19 Feb 2008 13:41:00 -0800 (PST) Received: by 10.115.107.7 with HTTP; Tue, 19 Feb 2008 13:41:00 -0800 (PST) Message-ID: Date: Tue, 19 Feb 2008 21:50:00 -0000 From: "Doug Evans" To: "Michael Snyder" Subject: Re: How do you debug gdb? Cc: "Ray Hurst" , gdb@sources.redhat.com In-Reply-To: <1203449896.19253.165.camel@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <1203449896.19253.165.camel@localhost.localdomain> 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: 2008-02/txt/msg00147.txt.bz2 On Feb 19, 2008 11:38 AM, Michael Snyder wrote: > > On Sun, 2008-02-17 at 20:00 -0800, Ray Hurst wrote: > > It seemed that this question was better suited for the development group > > than in the general group. > > > > How do you debug gdb? > > > > In other words, if I have a problem with gdb itself how do I go about > > debugging the issue? > > It's a little counter intuitive, but just as you compile GCC > with GCC, you also debug GDB with GDB. > > After all, GDB is just a program... > > If you do it in the build directory, you will find that > there is already some infrastructure in place. See the > existing file ".gdbinit", which sets some breakpoints > and changes the prompt. > > Changing the prompt is perhaps the number one > most important thing to do --- that way you can > tell by looking at the prompt whether you are > talking to the gdb-being-debugged or to the > gdb-doing-the-debugging. A couple more things that mighn't be immediately clear. If you're in the child gdb (the prompt is "(gdb) ") and you want to get to the parent gdb, and you're using .gdbinit in the build directory, then you just type "i". To get back to the child gdb, continue. As in (gdb) i (top-gdb) c (gdb) Another useful thing is to rebuild gdb with -O0 if not done already. bash$ cd obj/gdb bash$ make clean bash$ make CFLAGS=-g bash$ gdb ./gdb [...] (top-gdb) Generally there's no need to debug bfd/etc. but one could rebuild those too as necessary.