2016-01-14 23:41 UTC+01:00, Tal Lubko <tallubko at
yahoo.com>:>
>
>> -----Original Message-----
>> From: Syslinux [mailto:syslinux-bounces at zytor.com] On Behalf Of
>> Celelibi via Syslinux
>> Sent: Wednesday, January 13, 2016 1:34 PM
>> To: Geert Stappers
>> Cc: syslinux at zytor.com
>> Subject: Re: [syslinux] Debugging with Qemu
>>
>> 2016-01-13 6:26 UTC+01:00, Geert Stappers via Syslinux
>> <syslinux at zytor.com>:
>> > On Wed, Jan 13, 2016 at 01:22:17AM +0100, Celelibi wrote:
>> >> 2016-01-12 22:21 UTC+01:00, Tal Lubko:
>> >> > On Mon, Jan 11, 2016 at 07:20:20PM -0500, Shao Miller
wrote:
>> >> >>
>> >> >> Yes, you can print debug-output from custom builds.
>> >> >>
>> >> >
>> >> > Regarding my other question (debugging).
>> >> > I know it is possible to use prints for debugging.
>> >> > I wonder if there is another way.
>> >>
>> >> In qemu it is possible to have source-level debugging, all you
need
>> >> to know is the address at which the code is loaded to tell gdb
where
>> >> to relocate the debugging symbols.
>> >
>> > Please update
>> > http://www.syslinux.org/wiki/index.php/Development/Debugging
>> > with information how to repeat that.
>>
>> That's already on my todo list. I have also several python scripts
for
>> gdb that I need to clean up and propose for inclusion in the
>> repository.
>>
>
> Hi
>
> I've partially succeeded debugging Syslinux with Qemu.
> I've set a break point at 0x7c00 and did some stepping but I'm not
sure how
> to continue.
> What is the Syslinux "binary"?
> Does it include debug symbols?
> If not, how to build Syslinux with debug symbols?
>
> Thanks,
> Tal
>
Please reply to the mailing list as well.
As I only debugged lpxelinux you may have to fiddle around if you're
using something else, but I guess the big lines are the same.
- Add "-ggdb3 -O0" to GCCWARN in mk/devel.mk.
- I use the following commands in my .gdbinit to load the symbols of
the main file and set the right architecture.
file bios/core/lpxelinux.elf
target remote localhost:1234
#set architecture i8086
set architecture i386
set osabi none
Depending whether you're debugging 16 bits or 32 bits code, you will
need to set the architecture accordingly. You can switch on the fly if
the disass command decode the instructions incorrectly. (At least or
worked for me, I use a 32 bits OS.)
Note that the order is quite important as gdb is pretty annoying with
its "g packet too long" errors. I guess the "set
architecture" has to
appear after the "target" command.
Then if you want the debugging symbols of the COM32 modules things get
a bit trickier, and that's where the python scripts get very useful.
In the main file you have a symbol named modules_head which is a
linked list of struct elf_module. You'll have to load the .elf file
with the add-symbol-file command.
Unfortunately, this command will only load the the .text section at
the precise address given while syslinux load the full ELF file at the
base address module->base_address. But you can give this command all
the sections to load and addresses at which to load them with the
command:
add-symbol-file themodule.elf 0xtextaddress -s .data 0xdataaddress -s
.rodata 0xrodataaddress ...
And you can get the address of the sections in memory by adding the
module base address with the section address found with readelf -S.
And if you want to go even further, you can put a breakpoint at
com32/lib/sys/module/elf_module.c:282 to know when to load a symbol
file and at com32/lib/sys/module/common.c:411 to know when to unload
one.
You can unload a symbol file with remove-symbol-file. I heared this
command can take a filename whose symbols are to be unloaded, but it
never worked for me. I always had to give it "-a 0xtextaddress".
That's it. I guess that's a very short version to get source-level
debugging of syslinux on BIOS in qemu.
Celelibi