From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Fez7b-0002iI-AI for mharc-grub-devel@gnu.org; Sat, 13 May 2006 14:45:47 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Fez7a-0002ht-07 for grub-devel@gnu.org; Sat, 13 May 2006 14:45:46 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Fez7X-0002gC-MY for grub-devel@gnu.org; Sat, 13 May 2006 14:45:45 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Fez7X-0002g5-G1 for grub-devel@gnu.org; Sat, 13 May 2006 14:45:43 -0400 Received: from [24.25.9.103] (helo=ms-smtp-04.southeast.rr.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1Fez9Y-00008q-Lu for grub-devel@gnu.org; Sat, 13 May 2006 14:47:48 -0400 Received: from [192.168.16.101] (cpe-065-188-140-187.triad.res.rr.com [65.188.140.187]) by ms-smtp-04.southeast.rr.com (8.13.6/8.13.6) with ESMTP id k4DIjfH6003238 for ; Sat, 13 May 2006 14:45:41 -0400 (EDT) Message-ID: <44662951.2050600@xacks.com> Date: Sat, 13 May 2006 14:45:37 -0400 From: devShadow User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 To: The development of GRUB 2 References: <20060512132007.GA88582@meta.morph.sk> In-Reply-To: <20060512132007.GA88582@meta.morph.sk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Symantec AntiVirus Scan Engine Subject: Re: 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: Sat, 13 May 2006 18:45:46 -0000 Hi, thanks for the help with debugging modules. I have a module that I created and still need a little assistance in getting gdb to break in my module's grub_cmd_*. I am able to connect to QEMU with gdb and when I load the module, gdb loads the symbol table for my module. But, when I set a breakpoint at the address of the first operation in my module, gdb doesn't break when I execute the command in GRUB. If it has something to do with the aliases you mention at the bottom of your message, could you elaborate a little more or direct me in the right direction? Thanks David Johnson Lubomir Kundrak wrote: > 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. >