From owner-freebsd-questions@FreeBSD.ORG Wed Jan 16 19:56:38 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 924DD16A417 for ; Wed, 16 Jan 2008 19:56:38 +0000 (UTC) (envelope-from cswiger@mac.com) Received: from mail-out4.apple.com (mail-out4.apple.com [17.254.13.23]) by mx1.freebsd.org (Postfix) with ESMTP id 7865413C455 for ; Wed, 16 Jan 2008 19:56:38 +0000 (UTC) (envelope-from cswiger@mac.com) Received: from relay8.apple.com (relay8.apple.com [17.128.113.38]) by mail-out4.apple.com (Postfix) with ESMTP id 6C8DC1F1DC0A; Wed, 16 Jan 2008 11:56:38 -0800 (PST) Received: from relay8.apple.com (unknown [127.0.0.1]) by relay8.apple.com (Symantec Mail Security) with ESMTP id 579FD402E7; Wed, 16 Jan 2008 11:56:38 -0800 (PST) X-AuditID: 11807126-9cdecbb000005025-13-478e61763108 Received: from cswiger1.apple.com (cswiger1.apple.com [17.214.13.96]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by relay8.apple.com (Apple SCV relay) with ESMTP id 29B5F400DA; Wed, 16 Jan 2008 11:56:38 -0800 (PST) Message-Id: <2C402693-DD71-4B3A-A3C1-3685F8A130E0@mac.com> From: Chuck Swiger To: Arun Paneri In-Reply-To: <771039.36759.qm@web90405.mail.mud.yahoo.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v915) Date: Wed, 16 Jan 2008 11:56:36 -0800 References: <771039.36759.qm@web90405.mail.mud.yahoo.com> X-Mailer: Apple Mail (2.915) X-Brightmail-Tracker: AAAAAA== Cc: FreeBSD User , freebsd-questions@freebsd.org Subject: Re: Pls help: regarding gdb internals X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Jan 2008 19:56:38 -0000 On Jan 16, 2008, at 10:58 AM, Arun Paneri wrote: > 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'm not familiar with the document you mentioned, but the canonical documentation for GDB is available via "info gdb". > 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? Binary objects such as executable programs, shared libraries, etc contain symbol tables; GDB does a quick load of this symbol data to identify all of the sources of symbols for the program, and then will look up the details when needed. > Does it start creating stack frames as we give command "run" or > before even that? The program being debugged does not exist as a process until you run it, so there isn't an address space or stack until then. When the target program is run, it creates it's own stack frames according to the local architecture's machine calling conventions. > I am basically interested to know about creation of frames and how > does gdb read them back when we give "backtrace" command? Well, the calling conventions are different for every particular CPU architecture; but if you want to see the code that GDB uses, start with: /usr/src/contrib/gdb/gdb/frame-base.c /usr/src/contrib/gdb/gdb/frame-base.h /usr/src/contrib/gdb/gdb/frame-unwind.c /usr/src/contrib/gdb/gdb/frame-unwind.h /usr/src/contrib/gdb/gdb/frame.c /usr/src/contrib/gdb/gdb/frame.h ...but I suspect that something like these two articles are closer to what you are looking for: http://en.wikipedia.org/wiki/Calling_convention http://en.wikipedia.org/wiki/X86_calling_conventions -- -Chuck