OSDev.org

The Place to Start for Operating System Developers
It is currently Mon Apr 22, 2024 11:29 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Qemu vs Bochs+gdb vs Bochs internal debugger
PostPosted: Fri Sep 14, 2012 5:29 pm 
Offline
Member
Member

Joined: Tue Dec 13, 2011 4:11 pm
Posts: 103
Hi all,

I'm working on setting up bochs on my Mac. From macports it works fine, but it doesn't have gdb stub or an internal debugger, and it's giving some problems compiling. I reckon I can fix it, but before I spend a lot of time working on that, what is the best option for debugging my OS:
- Bochs with gdb stub
- Bochs internal debugger
- Qemu

I've never used Qemu before, I've used both Bochs with gdb and internal debugger, but only briefly. What do you prefer and why?
I've read somewhere that Bochs GDB stub doesn't work with SMP. Is that true? Would that impact your decision?

Thanks in advance


Top
 Profile  
 
 Post subject: Re: Qemu vs Bochs+gdb vs Bochs internal debugger
PostPosted: Fri Sep 14, 2012 10:38 pm 
Offline
Member
Member
User avatar

Joined: Thu Aug 11, 2005 11:00 pm
Posts: 1110
Location: Tartu, Estonia
I'm mainly using Bochs and its internal debugger for debugging my OS, so I can mainly comment on this one. Most important for me is that it shows lots of CPU internal information (descriptor tables, page tables, segment registers (including their shadowed parts), TLBs) and also information on several devices using the Bochs param tree. Displaying of this information together with other commands can be automated, so I can write automated tests and dump the results into a log file. (Most of the time I just do things like "set a breakpoint at x, run, dump register contents (and some other relevant information), quit".)

GDB is certainly a great debugger and it's usable with both QEMU and Bochs (with GDB stub). Unfortunately it has some problems with switching between 32 and 64 bit mode and crashes when I try to debug my 64 bit kernel, so for me it's rather usesless for kernel debugging... This problem used to persist for quite a long time, so it may or may not be fixed in the meantime.

_________________
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS


Top
 Profile  
 
 Post subject: Re: Qemu vs Bochs+gdb vs Bochs internal debugger
PostPosted: Sun Sep 16, 2012 9:05 am 
Offline
Member
Member

Joined: Tue Dec 13, 2011 4:11 pm
Posts: 103
Thanks for your reply!

Is there anybody else who can share their opinion? One opinion is very useful, but the more the better!


Top
 Profile  
 
 Post subject: Re: Qemu vs Bochs+gdb vs Bochs internal debugger
PostPosted: Sun Sep 16, 2012 3:27 pm 
Offline
Member
Member
User avatar

Joined: Tue Feb 08, 2011 1:58 pm
Posts: 496
I also use bochs on mac, and I use it's internal debugger. The latest source compiles with apple's gcc toolchain out of the box, no problems. I've configured it with
Code:
./configure --with-x11 --enable-x86-64 --enable-smp --enable-3dnow --enable-ne2000 --enable-pci --enable-usb --enable-usb-ohci --enable-usb-xhci --enable-configurable-msrs --enable-disasm --enable-x86-debugger --enable-cpu-level=5 --enable-debugger --disable-debugger-gui --enable-es1370 --enable-sb16 --enable-idle-hack --disable-largefile --enable-fast-function-calls --enable-repeat-speedups --enable-cdrom --disable-iodebug

(Maybe not the best, but good for me. It worth mentioning that enabling iodebug will slow down simulation considerably)

As for it's debugger: first I was not satisfied with it at all, so I upgraded it a little bit to give more information on 64 bit structures (ist in 64 mode idt and such). I've already posted a diff somewhere on this forum, I'm sure you can find it. With this little patch and the "xchg bx,bx" hack it've became so powerful, that I never think of using anything else for debugging.


Top
 Profile  
 
 Post subject: Re: Qemu vs Bochs+gdb vs Bochs internal debugger
PostPosted: Mon Sep 17, 2012 1:37 am 
Offline
Member
Member
User avatar

Joined: Wed Dec 01, 2010 3:41 am
Posts: 1761
Location: Hong Kong
qemu come out of the box from apt-get or darwin port, and is pretty convenient.
However, qemu is simulator aimed at performance and it sometime will "work" even you do not do things properly - things that bite you later when you test on bochs or real hardware.

Bottom line, I keep both bochs and qemu as test platform - as it cost nothing, the more the better.


Top
 Profile  
 
 Post subject: Re: Qemu vs Bochs+gdb vs Bochs internal debugger
PostPosted: Mon Sep 17, 2012 3:21 am 
Offline
Member
Member
User avatar

Joined: Sat Jul 30, 2011 10:07 am
Posts: 374
Location: Wrocław/Racibórz, Poland
Quote:
qemu come out of the box from apt-get
AFAIK, in Debian's repos, it's still <1.0. In Ubuntu <12.04's, it's still <1.0; in Mint <13's, it's still <1.0.

On most systems, or at least on those that aren't completely up-to-date (and, sadly, there are people staying away from updating their OSes), I would advise against getting it from distro's repos.

_________________
Reaver Project :: Repository :: Ohloh project page
<klange> This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.
<drake1> as long as the lock is read and modified by atomic operations


Top
 Profile  
 
 Post subject: Re: Qemu vs Bochs+gdb vs Bochs internal debugger
PostPosted: Mon Sep 17, 2012 4:00 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
qemu has a pretty epic history of stability issues, of which the notorious incompatibility with GCC4. There have been quite a few breaks with backwards-compatibility, and while my gentoo already offers 1.1.1, 0.11 is still the "stable" default. Probably not in the least because quite a few distro maintainers are scared of the flamefests that typically follow substituting one bug with the other.

For most purposes, even the old versions of qemu work fine but just like the odd hardware vendors it needs a bit of special casing. Which in turn makes it an excellent second tier emulator :wink:

At any rate, that's just a few of the reasons for why I would recommend Bochs over qemu any day.

_________________
"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 ]


Top
 Profile  
 
 Post subject: Re: Qemu vs Bochs+gdb vs Bochs internal debugger
PostPosted: Mon Sep 17, 2012 4:29 am 
Offline
Member
Member
User avatar

Joined: Tue Jul 10, 2007 5:27 am
Posts: 2935
Location: York, United Kingdom
Quote:
(and, sadly, there are people staying away from updating their OSes),


Mainly because every time I dist-upgrade ubuntu manages to break something fundamental. Last time it shat all over the kernel and refused to boot.

_________________
Horizon - a framework and language for SAS-OS development
Project 'Pedigree'
Practical x86 OSDev tutorials


Top
 Profile  
 
 Post subject: Re: Qemu vs Bochs+gdb vs Bochs internal debugger
PostPosted: Mon Sep 17, 2012 4:51 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
JamesM wrote:
Mainly because every time I dist-upgrade ubuntu manages to break something fundamental. Last time it shat all over the kernel and refused to boot.
+1 here. On my way to 12.04 LTS it decided to go pass the wrong root= to the kernel.

_________________
"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 ]


Top
 Profile  
 
 Post subject: Re: Qemu vs Bochs+gdb vs Bochs internal debugger
PostPosted: Mon Sep 17, 2012 5:39 am 
Offline
Member
Member
User avatar

Joined: Sat Jul 30, 2011 10:07 am
Posts: 374
Location: Wrocław/Racibórz, Poland
JamesM wrote:
Quote:
(and, sadly, there are people staying away from updating their OSes),


Mainly because every time I dist-upgrade ubuntu manages to break something fundamental. Last time it shat all over the kernel and refused to boot.

That's why I always do full re-install; with 20Mbps Internet connection redownloading everything is quite quick and painless, and compiling those few things (like kdevelop or bochs) doesn't take that long; sometimes, it is as easy as linking and installing everything, without recompilation, as I keep everything* on /home and don't have to really bother with it.

* as in: downloaded and compiled sources

_________________
Reaver Project :: Repository :: Ohloh project page
<klange> This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.
<drake1> as long as the lock is read and modified by atomic operations


Top
 Profile  
 
 Post subject: Re: Qemu vs Bochs+gdb vs Bochs internal debugger
PostPosted: Mon Sep 17, 2012 8:57 am 
Offline
Member
Member

Joined: Tue Dec 13, 2011 4:11 pm
Posts: 103
Thanks guys! Bochs internal debugger it is ;-).


Top
 Profile  
 
 Post subject: Re: Qemu vs Bochs+gdb vs Bochs internal debugger
PostPosted: Tue Sep 18, 2012 5:29 am 
Offline
Member
Member

Joined: Sun Feb 01, 2009 6:11 am
Posts: 1070
Location: Germany
Combuster wrote:
qemu has a pretty epic history of stability issues, of which the notorious incompatibility with GCC4. There have been quite a few breaks with backwards-compatibility...

The dependency on gcc 3.x was fixed with 0.10, in early 2009. Are you sure that history really matters for a user today?

What kind of backwards compatibility do you mean?

Quote:
...and while my gentoo already offers 1.1.1, 0.11 is still the "stable" default.

Ouch. I don't think this is a good idea of the Gentoo maintainers. :?

Quote:
At any rate, that's just a few of the reasons for why I would recommend Bochs over qemu any day.

And I would do the opposite, because bochs is just too slow, and because I hate config files. Good that everyone has his own taste. :)

_________________
Developer of tyndur - community OS of Lowlevel (German)


Top
 Profile  
 
 Post subject: Re: Qemu vs Bochs+gdb vs Bochs internal debugger
PostPosted: Mon Oct 05, 2015 2:22 am 
Offline
User avatar

Joined: Wed Dec 17, 2008 11:22 am
Posts: 8
Thank you for this question - I also think, that you should prefer Bochs, even if you want to debug bootloader code. I've read many Internet Articles about Qemu+GDB bootloader debugging and it seems that Qemu have a problem in debugging bootloader-code from an raw image file. It seems that Qemu can only debug EFI-Files. Don't ask me if it is or not, i've not tested it. Please correct me, if there is an error.

So i have 2 questions about it :
- Is Qemu able to debug 16-Bit bootloader code ? I ask because i think that Qemu doesn't have an internal debugger like Bochs
- I start Bochs with debugger and always have to manually set a breakpoint to specific memory places, like 0x7C00. Is there an "automatically" way to say Bochs when it starts, that it has to set an breakpoint at 0x7C00? Maybe in some kind of script ?

Greetings,
bsc


Top
 Profile  
 
 Post subject: Re: Qemu vs Bochs+gdb vs Bochs internal debugger
PostPosted: Mon Oct 05, 2015 3:21 am 
Offline
Member
Member

Joined: Sun Feb 01, 2009 6:11 am
Posts: 1070
Location: Germany
That's really more a question about gdb than about qemu. As far as I know, debugging 16 bit code works fine per se, it's just that gdb gets confused with mode switches. So you need to make sure that you start debugging while you are already in the right processor mode if you want all gdb output to make sense. The qemu monitor itself doesn't have problems with mode switching, so you can always get correct register dumps, memory dumps and such.

_________________
Developer of tyndur - community OS of Lowlevel (German)


Top
 Profile  
 
 Post subject: Re: Qemu vs Bochs+gdb vs Bochs internal debugger
PostPosted: Mon Oct 05, 2015 5:59 am 
Offline
User avatar

Joined: Wed Dec 17, 2008 11:22 am
Posts: 8
Quote:
So you need to make sure that you start debugging while you are already in the right processor mode if you want all gdb output to make sense
So GDB only have problems if you change your processor mode, for example switching 16-32Bit, switching Real-/Protected Mode, is this correct ?
Quote:
The qemu monitor itself doesn't have problems with mode switching, so you can always get correct register dumps, memory dumps and such.
Only to make sure, that I understood you:
You need GDB for debugging in QEMU. Or is there another way for debugging/setting breakpoints in QEMU ?
(Sorry but I don't know much about QEMU :wink: )


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 16 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group