debugging kernel 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
vjain20
Member
Member
Posts: 73
Joined: Wed Apr 04, 2012 9:12 pm

debugging kernel with bochs

Post by vjain20 »

Hi,

I am following the JamesM tutorial for writing an OS. I want to debug the kernel
but when I add the debug option (-g) to the Makefile and compile and run the new binary with bochs it keeps on restarting.
I added the -g option to both CFLAGS and ASFLAGS (for nasm). Normally (without -g flag) the kernel would just print
'Hello world' and then spin in infinite loop. Please help.


- Thanks
- Thanks
Vaibhav jain
User avatar
turdus
Member
Member
Posts: 496
Joined: Tue Feb 08, 2011 1:58 pm

Re: debugging kernel with bochs

Post by turdus »

I'm not sure where you're using -g. For compiling bochs it's unecessary (because it's not bochs you want to debug), and as for your kernel you should be able to debug without it. You won't see the name of the interrupted function (and the source file with line number), just a couple hex numbers, but it should work. If you want symbol names to be imported, you have to specify debug_symbols in bochsrc:
http://bochs.sourceforge.net/doc/docboo ... ml#AEN1986
vjain20
Member
Member
Posts: 73
Joined: Wed Apr 04, 2012 9:12 pm

Re: debugging kernel with bochs

Post by vjain20 »

Thanks for replying! I should have mentioned that I am trying to debug the kernel using
gdb through remote debugging. For that I will have to compile it using -g option.
So I compiled it and then before actually trying to debug it I just executed(booted) the same binary with
bochs but it kept on restarting.
- Thanks
Vaibhav jain
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Re: debugging kernel with bochs

Post by bubach »

Why not just use Bochs internal debugger? Or at least use it to debug your debugger issues. ;)
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
vjain20
Member
Member
Posts: 73
Joined: Wed Apr 04, 2012 9:12 pm

Re: debugging kernel with bochs

Post by vjain20 »

I will try to use the internal debugger.Actually I tried remote debugging with qemu some time ago and it worked fine
so I went for remote debugging with bochs. Could you please tell how can I get the debug symbols file of my kernel for use with internal debugger ?

Thanks
Vaibhav
- Thanks
Vaibhav jain
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Re: debugging kernel with bochs

Post by bubach »

I have no idea, but fortunately I learned how to Google at an early age. I'll send you an invoice for my services later.
http://www.cs.umd.edu/~hollings/cs412/s02/debugger.html wrote:load-symbols [global] filename [offset]
Load symbols from file filename. If the global keyword is added, then the the symbols will be visible in all contexts for which symbols have not been loaded. Offset (default is 0) is added to every symbol entry. The symbols are loaded in the current (executing) context.

The symbol file consists of zero or more lines of the format "%x %s".
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
Post Reply