[prev in list] [next in list] [prev in thread] [next in thread] 

List:       bochs-dev
Subject:    [Bochs-developers] =?gb2312?B?tPC4tDogW0JvY2hzLWRldmVsb3BlcnNdILTwuLQ6IFtCb2Nocy1kZQ==?=
From:       "fenghaitao" <fenghaitao () mprc ! pku ! edu ! cn>
Date:       2004-04-17 8:06:26
Message-ID: 000001c42452$e3e54c30$51c809c0 () mprcgaoyi
[Download RAW message or body]

Gdb and Bochs see the same address. Bochs must load the kernel to the
same address which your kernel image defined. This is done in BIOS.
I have debugged Linux Kernel using GDB.Only when the Kernel enable
MMU,you can use "b symbol" to debug.Before this,you can use "b *offset"
to debug the Kernel.

-----ÓʼþÔ­¼þ-----
·¢¼þÈË: bochs-developers-admin@lists.sourceforge.net
[mailto:bochs-developers-admin@lists.sourceforge.net] ´ú±í Nik Schild
·¢ËÍʱ¼ä: 2004Äê4Ô 16ÈÕ 19:17
ÊÕ¼þÈË: bochs-developers@lists.sourceforge.net
Ö÷Ìâ: Re: [Bochs-developers] ´ð¸´: [Bochs-developers] Can't debug on
bochs

fine, with "si" i can step throught but I'm still not able to get to the
main function of the kernel.
"objdump -D" gives me the same address for main as gdb does. When
setting
a break point to main and then I continue, then the gdb session suddenly
breaks, but not in main. gdb shows the right line of code, but on the
bochs screen I clearly see that not even the bootsector of my kernel
floppy image is reached.
I guess that gdb takes the address out of the kernel object file with
which I start gdb. Thats why the address is correct. But I'm sure that
bochs loads the kernel image to a different place in memory, so that gdb
gets confused.

The process "bochs" together with the loaded kernel image is one process
for Linux and so for gdb. Is that right? When gdb attaches to bochs, how
can gdb know the offset, where the loaded kernel is placed?


fenghaitao wrote:
> In gdb, use "si" command.
> Use "objdump -D" command to dump the kernel image,maybe you will see
> Bochs gets the right address.
> 
> -----ÓʼþÔ­¼þ-----
> ·¢¼þÈË: bochs-developers-admin@lists.sourceforge.net
> [mailto:bochs-developers-admin@lists.sourceforge.net] ´ú±í Nik Schild
> ·¢ËÍʱ¼ä: 2004Äê4Ô 15ÈÕ 20:37
> ÊÕ¼þÈË: bochs-developers@lists.sourceforge.net
> Ö÷Ìâ: [Bochs-developers] Can't debug on bochs
> 
> Hi
> 
> Im somehow unable to debug a small os (chi from:
> http://www.reitshamer.com/source/os_doc.html) I use for education
> purposes.
> 
> I configured bochs the following way:
> ./configure --enable-disasm  --disable-icache --without-x
--without-x11
> --with-term --enable-gdb-stub
> 
> starting bochs (2.1.1):
> bochs -q
> 
> bochs is configured to load a floppy image which contains bootsector,
> loader, kernel starter and kernel.
> 
> starting gdb session. kernel.o contains the kernel (empty main
routine)
> which is compiled with the -g flag:
> 
> gdb kernel.o
> GNU gdb 6.0
> ....
> ...
> ..
> ...
> This GDB was configured as "i386-linux"...
> (gdb) [CPU  ] prefetch: RIP > CS.limit  << PROBLEM 1
> Undefined command: "".  Try "help".
> (gdb) target remote localhost:1234
> Remote debugging using localhost:1234
> 0x0000fff0 in ?? ()
> (gdb)
> 
> now when I use next or step I got the following message:
> (gdb) n
> Cannot find bounds of current function << PROBLEM 2
> (gdb) s
> Cannot find bounds of current function
> (gdb)
> 
> setting break points does not really work:
> (gdb) break main
> Note: breakpoint -2 also set at pc 0xc8. << PROBLEM 3
> Breakpoint 1 at 0xc8: file kernel.c, line 48.
> 
> conuining basically work:
> (gdb) c
> Continuing.
> 
> on the bochs screen I can see the output of the assembler routines of
> the bootsector, and kernel loader.
> 
> when I CTRL-C in gdb I got the following ouput:
> Program received signal 0, Signal 0.
> 0x0000201d in ?? ()
> (gdb)
> 
> (gdb) info break
> Num Type           Disp Enb Address    What
> 1   breakpoint     keep y   0x000000c8 in main at kernel.c:48  <<
> PROBLEM 4
> 
> Beside the various error/warning messages I noticed that the addresses
> are somewhat strange.
> If I do a "nm" on my kernel image I get the following output:
> 
> nm chik
> 0000210c A __bss_start
> 0000210c A _edata
> 0000210c A _end
> 00001000 T _start
> 00001020 T k_clear_screen
> 0000105f T k_printf
> 000010e8 T main
> 0000101d t spin
> 
> the address of main in gdb is 0x000000c8 while in the kernel image it
is
> 0x000010e8. Could this be the problem? When bochs runns my kernel and
> gdb is attached to bochs, how do the addresses of my kernel look to
gdb?
> What do I have to do to step easily through my simple kernel?
> 
> thanks for you help!
> 
> Nik
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: IBM Linux Tutorials
> Free Linux tutorial presented by Daniel Robbins, President and CEO of
> GenToo technologies. Learn everything from fundamentals to system
> administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
> _______________________________________________
> bochs-developers mailing list
> bochs-developers@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/bochs-developers
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: IBM Linux Tutorials
> Free Linux tutorial presented by Daniel Robbins, President and CEO of
> GenToo technologies. Learn everything from fundamentals to system
> administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
> _______________________________________________
> bochs-developers mailing list
> bochs-developers@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/bochs-developers
> 
> 




-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id70&alloc_id638&opÌk
_______________________________________________
bochs-developers mailing list
bochs-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bochs-developers



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id70&alloc_id638&opÌk
_______________________________________________
bochs-developers mailing list
bochs-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bochs-developers

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic