is their a half-decent way to debug an OS

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
earlz

is their a half-decent way to debug an OS

Post by earlz »

I would really like a debugging method in my OS and I heard that gbd supports external debugging through comports.. but how exactly does that work

and please don't tell me "just use bochs built-in debugger!" as it is really an ultra weak debugger
shell

Re:is their a half-decent way to debug an OS

Post by shell »

Run your os on a different virtual machine. Not very hard, now is it?
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re:is their a half-decent way to debug an OS

Post by Brendan »

Hi,
Jordan3 wrote:I would really like a debugging method in my OS and I heard that gbd supports external debugging through comports.. but how exactly does that work
In general, there's a "stub" in the code being developed which acts like a client for GDB. GDB and this client use a special protocol to talk to each other. For details of this protocol, try some of these sites (or Google): I'd also want to look at the files distributed with GDB - apparently it contains "pre-made" stubs and one is called "i386-stub.c".

BTW I've ever used GDB for OS development, so I'm not sure what problems you're likely to encounter - most of us use emulators and/or "printf debugging"...


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
earlz

Re:is their a half-decent way to debug an OS

Post by earlz »

I've been using printf and assert debugging but it would be really nifty to be able to see your lines of code..

meh... I might even attempt to create some sort of simple debugger specially for an OS and use through com ports or lpt ports
omin0us

Re:is their a half-decent way to debug an OS

Post by omin0us »

I use bochs for all my debugging. i have to build configurations that i switch between. one with the built in debugger enabled, that i use for low level debugging. stepping 1 instruction at a time and examining registers and stack values.

i also have a bochs build with remote gdb stub enabled. and then i can compile my kernel with symbols. run it in bochs. and connect with gdb
and debug my kernel line by line.

i can write up a little tutorial if you are interested in how to set that up.
bluecode

Re:is their a half-decent way to debug an OS

Post by bluecode »

omin0us, I'm also interested in a tutorial, since I'm currently only using prints and the internal bochs debugger.
viki
Posts: 14
Joined: Tue May 08, 2007 11:57 am
Location: Poland

Post by viki »

Omin0us mayby the best way is not to create whole tutor at once but step by step. Actually I can't itch for it.
inpherno
Posts: 4
Joined: Sun Jul 15, 2007 2:32 am

Post by inpherno »

I use this: http://fabrice.bellard.free.fr/qemu/
this: http://sourceware.org/gdb/
and this: http://sourceware.org/insight/

It all works nicely together and I can step through my code while viewing the C code and ASM. It's also got a memory viewer, so you can see if things are being written to memory correctly.

All you need to do is run qemu with -S -s in the command line, then connect with insight via remote debugging.
User avatar
AndrewAPrice
Member
Member
Posts: 2309
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Post by AndrewAPrice »

inpherno wrote:I use this: http://fabrice.bellard.free.fr/qemu/
this: http://sourceware.org/gdb/
and this: http://sourceware.org/insight/

It all works nicely together and I can step through my code while viewing the C code and ASM. It's also got a memory viewer, so you can see if things are being written to memory correctly.

All you need to do is run qemu with -S -s in the command line, then connect with insight via remote debugging.
Cool! I use qemu too. Now I can use something similar to the MC++ debugger for my OS 8) (in the MC++ debugger you can stop your code at any point)..

A cool feature with MC++ is when you're using managed C++ (which I try to steer away from since not everyone has .Net installed and your program takes 10 seconds to start and uses up 20MB of memory for no apparent reason) you can pause your code at any time, make some changes, then click continue (and wait a few seconds for their just-in-time compiler to do its thing).
My OS is Perception.
Post Reply