how can i debug a os with bochs?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
j8long
Posts: 12
Joined: Wed Jun 09, 2010 8:13 am

how can i debug a os with bochs?

Post by j8long »

i download the bochs souce.i want to know which option to configure,so i can debug it.
i've already install grub in a floppy image, but i don't know how to debug my kernel?
i did search how to solve it but it didn't work.
does anyone help me?how did you debug your kernel?
im a newbie.
:-)
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: how can i debug a os with bochs?

Post by bewing »

Are you going to be running the bochs on Linux, or on Windows?

First you need to "configure" the bochs download. Then you will need to compile it. Then you install it somewhere. Then you edit the .bochsrc file to tell it the name of your floppy image file. Then you run it, and it should pop up a couple of screens that show you a pretend computer booting your OS.
j8long
Posts: 12
Joined: Wed Jun 09, 2010 8:13 am

Re: how can i debug a os with bochs?

Post by j8long »

bewing wrote:Are you going to be running the bochs on Linux, or on Windows?

First you need to "configure" the bochs download. Then you will need to compile it. Then you install it somewhere. Then you edit the .bochsrc file to tell it the name of your floppy image file. Then you run it, and it should pop up a couple of screens that show you a pretend computer booting your OS.
i know that.i use ubuntu now.
my problem is how to debug my kernel code.
do i need to run gcc with '-g' and ./configure --enable-gdb-stub ?
i did it before,but i can not see the asm code,just the c code.
when is use bochs in windows there is a bochsrgdb can step asm code one bye one.
what does i need to do under linux?
:-)
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: how can i debug a os with bochs?

Post by bewing »

bochs does not work very well with the gdb stub. You can try it, but I think you will have problems.
If you really want to know how to use bochs with gdb, say so and I will go and dig out my notes.

I think the easiest thing to do is:
./configure --target=pentium \
--enable-all-optimizations \
--enable-cpu-level=6 \
--enable-disasm \
--enable-debugger \
--enable-debugger-gui \
--enable-pci \
--enable-vbe \
--disable-readline \
--with-x \
--enable-cpp

And then in the .bochsrc file, you say:
display_library: x, options="gui_debug"

And that gets the local graphical debugger running, so you can singlestep the asm.

Alternately, you can get my "rebochs" program. It does all the same things, but faster. You can get it at http://www.quokforge.org/projects/rebochs/files
It is much easier to set up than bochs.
stlw
Member
Member
Posts: 357
Joined: Fri Apr 04, 2008 6:43 am
Contact:

Re: how can i debug a os with bochs?

Post by stlw »

Alternately, you can get my "rebochs" program. It does all the same things, but faster. You can get it at http://www.quokforge.org/projects/rebochs/files
It is much easier to set up than bochs.
Is rebochs is able to boot WinXP for example ?
I am still wondering if "faster" means "faster to configure" or not. Without running any simple benchmark you won't know.
My estimations show that rebochs should be 2x-3x slower than similarly configured Bochs. Might be I am wrong, but I can't check it.

Stanislav
stlw
Member
Member
Posts: 357
Joined: Fri Apr 04, 2008 6:43 am
Contact:

Re: how can i debug a os with bochs?

Post by stlw »

bewing wrote:I think the easiest thing to do is:
./configure --target=pentium \
--enable-all-optimizations \
--enable-cpu-level=6 \
--enable-disasm \
--enable-debugger \
--enable-debugger-gui \
--enable-pci \
--enable-vbe \
--disable-readline \
--with-x \
--enable-cpp

And then in the .bochsrc file, you say:
display_library: x, options="gui_debug"
vbe option is deprecated in latest svn tree and should not be used anymore.

--enable-cpp option definitelly won't do anything good together with --with-x. The option would rename all the source .cc file to .cpp to help old crappy microsoft compilers (like Visual Studio 6.0). Any today Visual Studio works well without this option.
If you need x86-64 support add --enable-x86-64.

Stanislav
j8long
Posts: 12
Joined: Wed Jun 09, 2010 8:13 am

Re: how can i debug a os with bochs?

Post by j8long »

i'll try it out,thks
j8long
Posts: 12
Joined: Wed Jun 09, 2010 8:13 am

Re: how can i debug a os with bochs?

Post by j8long »

i add this line
display_library:x, options="gui_debug"
in bochsrc.but when i input bochs -f bochsrc
something is wrong with it.
Unknow x11 option "gui_debug"
what should i do?
stlw
Member
Member
Posts: 357
Joined: Fri Apr 04, 2008 6:43 am
Contact:

Re: how can i debug a os with bochs?

Post by stlw »

j8long wrote:i add this line
display_library:x, options="gui_debug"
in bochsrc.but when i input bochs -f bochsrc
something is wrong with it.
Unknow x11 option "gui_debug"
what should i do?
Start reading manuals instead :)
If you use win32, display_library:x is not a good option for you.

Stanislav
j8long
Posts: 12
Joined: Wed Jun 09, 2010 8:13 am

Re: how can i debug a os with bochs?

Post by j8long »

stlw wrote:
j8long wrote:i add this line
display_library:x, options="gui_debug"
in bochsrc.but when i input bochs -f bochsrc
something is wrong with it.
Unknow x11 option "gui_debug"
what should i do?
Start reading manuals instead :)
If you use win32, display_library:x is not a good option for you.

Stanislav
im using ubuntu.
i'll triy it out
stlw
Member
Member
Posts: 357
Joined: Fri Apr 04, 2008 6:43 am
Contact:

Re: how can i debug a os with bochs?

Post by stlw »

im using ubuntu.
i'll triy it out
Make sure you use Bochs with GUI debugger. Latest releast is always a best good option.

Stanislav
j8long
Posts: 12
Joined: Wed Jun 09, 2010 8:13 am

Re: how can i debug a os with bochs?

Post by j8long »

stlw wrote:
im using ubuntu.
i'll triy it out
Make sure you use Bochs with GUI debugger. Latest releast is always a best good option.

Stanislav
it doesnt work
Tosi
Member
Member
Posts: 255
Joined: Tue Jun 15, 2010 9:27 am
Location: Flyover State, United States
Contact:

Re: how can i debug a os with bochs?

Post by Tosi »

Read the manual.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: how can i debug a os with bochs?

Post by Combuster »

"does not work" is never a valid description.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
j8long
Posts: 12
Joined: Wed Jun 09, 2010 8:13 am

Re: how can i debug a os with bochs?

Post by j8long »

Combuster wrote:"does not work" is never a valid description.
it works now.
maybe some options of bochs is not supported .
i typed

Code: Select all

./configure --enable-debugger --enable-disasm
:-)
Post Reply