From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1FeXZ3-0000cZ-RW for mharc-grub-devel@gnu.org; Fri, 12 May 2006 09:20:17 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FeXZ2-0000c3-9m for grub-devel@gnu.org; Fri, 12 May 2006 09:20:16 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FeXYz-0000bP-UQ for grub-devel@gnu.org; Fri, 12 May 2006 09:20:15 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FeXYz-0000bM-Mo for grub-devel@gnu.org; Fri, 12 May 2006 09:20:13 -0400 Received: from [147.175.55.175] (helo=meta.morph.sk) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FeXaj-0004iM-Sg for grub-devel@gnu.org; Fri, 12 May 2006 09:22:02 -0400 Received: by meta.morph.sk (Postfix, from userid 1018) id 35A55731; Fri, 12 May 2006 15:20:07 +0200 (CEST) Date: Fri, 12 May 2006 15:20:07 +0200 From: Lubomir Kundrak To: grub-devel@gnu.org Message-ID: <20060512132007.GA88582@meta.morph.sk> Mail-Followup-To: Lubomir Kundrak , grub-devel@gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.1i Subject: Debugging GRUB2 with GDB and QEMU X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 May 2006 13:20:16 -0000 I wrote some GDB macros that might be helpful for people that want to debug GRUB 2 modules with QEMU. [1] [1] http://NetBSD.sk/~lkundrak/misc/grub2-gdb/ The file genmk.rb.diff is a patch to makefile-generator script, that makes the build system leave output files with debugging information. Of course, one has have ruby interpreter to regenerate the makefiles and compile GRUB with -g afterwards. Second file is .gdbinit, the GDB initialization file. It is commented, so there is no need to describe it here. It basically passes the information extracted from list headed by grub_dl_head to the perl script, gmodule.pl, and loads its output. It also sets a breakpoint whose command list contains macro for loading proper symbol file each time a module is loaded. (I know the work could be done without the help of a Perl script, but it would be far more complicated, I guess) Another note worth mentioning is that you'll probably want to add aliases for some functions, so that all gdb facilities will work correctly. You will at least want to define the symbol 'main' for backtraces to stop at the right place. Some facilities also want the function 'malloc' to be defined. So, you'll probably have to add something like .globl main main = codestart to assembly language sources or malloc() __attribute__ ((alias("grub_malloc"))); to C files. I hope this will be useful to at least some of you. Best regards! Lubo. -- o Lubomir Kundrak *O* , http://skosi.org/~lkundrak/ (_) SKOSI -- Slovak OpenSource Initiative