From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19856 invoked by alias); 16 Jan 2008 22:07:15 -0000 Received: (qmail 19847 invoked by uid 22791); 16 Jan 2008 22:07:14 -0000 X-Spam-Check-By: sourceware.org Received: from bluesmobile.specifix.com (HELO bluesmobile.specifix.com) (216.129.118.140) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 16 Jan 2008 22:06:57 +0000 Received: from [127.0.0.1] (bluesmobile.specifix.com [216.129.118.140]) by bluesmobile.specifix.com (Postfix) with ESMTP id 6723D3C939; Wed, 16 Jan 2008 14:06:55 -0800 (PST) Subject: Re: Pls help: regarding gdb internals From: Michael Snyder To: Arun Paneri Cc: gdb@sourceware.org In-Reply-To: <550693.17540.qm@web90408.mail.mud.yahoo.com> References: <550693.17540.qm@web90408.mail.mud.yahoo.com> Content-Type: text/plain Date: Wed, 16 Jan 2008 22:07:00 -0000 Message-Id: <1200521215.3263.59.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.10.3 (2.10.3-4.fc7) Content-Transfer-Encoding: 7bit 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-01/txt/msg00132.txt.bz2 On Wed, 2008-01-16 at 11:59 -0800, Arun Paneri wrote: > Hi All, > > I am new to gdb code and trying to learn more things. i need help regarding gdb internals. > > Can anyone write few lines about how does gdb internally works. > I went to "Gdb internals guide" but couldn't find much information > specifically which i am looking for. I want information like > when we give command > "$gdb test.exe" > then how internaly it works. Does it start reading symbols > and start making symbol table with this command ? Yes. > Does it start creating stack frames as we give command "run" or before even that with "$gdb test.exe"? No, and no. Before you "run" a program, there are no stack frames. But gdb does not start constructing its internal stack frame representation until the program STOPS, eg. at a breakpoint or after executing a "step". > I am basically interested to know about creation of frames and how does gdb read them back when we give "backtrace" command? For performance reasons, gdb tries to construct its stack frame data lazily -- it postpones the work whenever possible. So, in general, whenever the program stops, gdb will construct one (and hopefully only one) stack frame -- the one for the function in which the program stopped. If you give the "up" command, gdb will construct the next (one) stack frame. If you ask for "backtrace 10" it will construct the next ten stack frames. And if you ask for a full backtrace, gdb will construct as many stack frames as it can find. > > I am not sure but i think to creat a frame it calls _initialize_stack (void) No. That function is the initializer for the "stack.c" module. It is called when gdb starts up, and just initializes the infrastructure for stack manipulation. > and from this it calls fun_command(char *arg, int from_tty) then parse_frame_specification(char *frame_exp) & then create_new_frame(CORE_ADDR addr, CORE_ADDR pc) function. Start with the function "get_prev_frame", and work your way up (and down) from there.