GUI Debugger Discovery

Programming, for all ages and all languages.
Post Reply
User avatar
Octacone
Member
Member
Posts: 1134
Joined: Fri Aug 07, 2015 6:13 am

GUI Debugger Discovery

Post by Octacone »

I just wanted to share something really really interesting. I found out that Bochs has this really helpful GUI debugger. It can dump GDT, IDT, stack, page table, memory addresses. Very useful tool for somebody who knows how to use it. It is much simpler to use this GUI debugger than any other textual one.

Here is an example of what it can be used for:
GDT debugging:
[Picture 1: GDT loaded by GRUB]
Image
[Picture 2: a custom proper GDT]
Image

How to activate it:
Open your Bochs configuration file and paste this:

Code: Select all

display_library: sdl, options=gui_debug
magic_break: enabled=1
By doing this you will automatically get this screen every time you run your OS In Bochs. Also by enabling so called magic break your OS will automatically stop and let you debug. You need to do

Code: Select all

xchg bx, bx
in order to insert a breakpoint. (Assembly file)

i created this topic to show how amazed I was when I discovered it. This will make me stop hating debugging so much. :)
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
matt11235
Member
Member
Posts: 286
Joined: Tue Aug 02, 2016 1:52 pm
Location: East Riding of Yorkshire, UK

Re: GUI Debugger Discovery

Post by matt11235 »

octacone wrote:This will make me stop hating debugging so much
You could have used gdb --tui with QEMU or something else too, it makes it a lot easier to use.

Also you didn't do a very good job of blurring out your code in the images, my eyesight is very poor and I can still make out most of the text :wink:
com.sun.java.swing.plaf.nimbus.InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonWindowNotFocusedState
Compiler Development Forum
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania
Contact:

Re: GUI Debugger Discovery

Post by Love4Boobies »

The Bochs GUI debugger was originally contributed by one of our members, bewing. Him and Stanislav (one of the two maintainers of Bochs and also a member of the forum) got into a disagreement so bewing stopped contributing and started working on his own emulator, ReBochs, which was supposed to be a faster Bochs with a less messy implementation. As far as I know, he is still working on it but development is rather slow so it's not a suitable replacement.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
iansjack
Member
Member
Posts: 4604
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: GUI Debugger Discovery

Post by iansjack »

matt11235 wrote:You could have used gdb --tui with QEMU or something else too, it makes it a lot easier to use.
gdb has the distinct advantage that you can debug at C source-code level as well as assembler level. And it has a very rich set of commands; a little difficult to get to grips with and learn, but well worth the effort.
User avatar
matt11235
Member
Member
Posts: 286
Joined: Tue Aug 02, 2016 1:52 pm
Location: East Riding of Yorkshire, UK

Re: GUI Debugger Discovery

Post by matt11235 »

iansjack wrote:
matt11235 wrote:You could have used gdb --tui with QEMU or something else too, it makes it a lot easier to use.
gdb has the distinct advantage that you can debug at C source-code level as well as assembler level. And it has a very rich set of commands; a little difficult to get to grips with and learn, but well worth the effort.
The learning curve isn't too bad, there are only a few commands to learn and it's well worth the time.
com.sun.java.swing.plaf.nimbus.InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonWindowNotFocusedState
Compiler Development Forum
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania
Contact:

Re: GUI Debugger Discovery

Post by Love4Boobies »

I don't know why you're bringing GDB up. The OP specifically mentioned what the Bochs debugger is useful for---things that GDB can't do.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
iansjack
Member
Member
Posts: 4604
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: GUI Debugger Discovery

Post by iansjack »

I didn't see anything mentioned that gdb can't handle.

Anyway, what's your problem with additional, related information?
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania
Contact:

Re: GUI Debugger Discovery

Post by Love4Boobies »

GDB doesn't know anything about CPU data structres such as descriptor tables, page tables, etc. The TUI version of GDB was mentioned as an alternative but it's really meant to solve a different problem.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: GUI Debugger Discovery

Post by Solar »

Love4Boobies wrote:GDB doesn't know anything about CPU data structres such as descriptor tables, page tables, etc.
If GDB runs in ring 0, like it does for DJGPP, it can display those structures. If GDB doesn't run in ring 0, you'd have to provide a syscall for reading those data structures -- which GDB in turn could use.
Every good solution is obvious once you've found it.
User avatar
iansjack
Member
Member
Posts: 4604
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: GUI Debugger Discovery

Post by iansjack »

Let's not forget that qemu has it's own monitor. A combination of this with gdb is a very powerful tool.
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania
Contact:

Re: GUI Debugger Discovery

Post by Love4Boobies »

Interesting, I didn't know that. However, it still can't handle things like interrupts and other low-level things (some CPU-related, some not) even if it can display those structures.

There is no need to make a case about GDB being useful for systems debugging, I readily acknowledge that. You don't even need QEMU's monitor for it to be useful. In fact, I think it's way more useful than the Bochs debugger but the latter is useful for a different set of problems, still.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
Sik
Member
Member
Posts: 251
Joined: Wed Aug 17, 2016 4:55 am

Re: GUI Debugger Discovery

Post by Sik »

Or for that matter, act like one should stick to a single debugging tool and nothing else (which is how things seem to be worded here). I lost track of how many times gdb turned out to be utter trash for debugging my problems, and sometimes I resort to multiple tools to see what's going on.
User avatar
iansjack
Member
Member
Posts: 4604
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: GUI Debugger Discovery

Post by iansjack »

Most of the posts here seem to be suggesting multiple tools rather than just the built-in Boch's debugger. Makes sense to me.
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania
Contact:

Re: GUI Debugger Discovery

Post by Love4Boobies »

Maybe I should have gone the extra mile do explain that's my opinion as well from the beginning. :)
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
Post Reply