General Issues

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
Uranium
Posts: 16
Joined: Fri Jul 04, 2008 8:00 am

General Issues

Post by Uranium »

I was into OS Development a couple of months ago then with college etc... I drifted away from it.

Anyway more to the point, using Bran's Kernel Development tutorial I attempted to build the base of a simple operating system for examining the media on drives.

It all compiles fine without warning but when I load up QEMU bugger all happens, apart from QEMU freezing and then "Not Responding". When I tried loading it up on an old computer (I'm talking was running Windows 95), it just rebooted after GRUB had loaded it.

I've attached the source tree etc... to the post, if someone could have a quick look through it and see if they can spot something that would be great.

Cheers guys.

http://www.filefactory.com/file/80bafc/n/MediaOS_zip
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: General Issues

Post by Combuster »

Have you at least tried Bochs? It will usually give you a more descriptive error than "lockup" or "reboot", together with the location of the error
"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 ]
Uranium
Posts: 16
Joined: Fri Jul 04, 2008 8:00 am

Re: General Issues

Post by Uranium »

Solved it, one of the issues was that I wasn't using -std-vga as a QEMU parameter and the other was that I accidently defined word as "unsigned int" instead of "unsigned short".

Kill me now =p
User avatar
Walling
Member
Member
Posts: 158
Joined: Mon Dec 04, 2006 6:06 am
Location: Berlin, Germany

Re: General Issues

Post by Walling »

Okay, you solved the problem. :) But do you know you can connect GDB to QEMU to debug your kernel? It is really nice. If you compile your kernel with debugging symbols GDB can single-step in your ASM/C/C++ code with the source code lines shown. You can set breakpoints on functions and you can access/change variables. I have a linker script with debugging symbols if you're interested.
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: General Issues

Post by Troy Martin »

@Uranium: *BLAM* *BLAM* *BLAM*

@Walling: Don't those symbols make the kernel bigger, or are they in a different file? (I'm all asm here, makes coding easier.)
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
User avatar
Walling
Member
Member
Posts: 158
Joined: Mon Dec 04, 2006 6:06 am
Location: Berlin, Germany

Re: General Issues

Post by Walling »

Troy Martin wrote:@Walling: Don't those symbols make the kernel bigger, or are they in a different file? (I'm all asm here, makes coding easier.)
Yes. What I do is to make two versions of the kernel. I make the one with debugging symbols, and then I strip away the symbols (but the internal addresses remain the same). The stripped version is the one GRUB gets to load. The other one I pass to GDB, like this:

Code: Select all

# ... make boot.iso with kernel-debug-stripped.elf ...
# qemu -boot d -cdrom boot.iso -s -S &
# gdb --quiet --se=kernel-debug-with-symbols.elf
(gdb) target remote :1234
Remote debugging using :1234
0x0000fff0 in ?? ()
(gdb) b multiboot_entry
Breakpoint 1 at 0x100030: file src/multiboot_entry.asm, line 66.
(gdb) c
Continuing.

Breakpoint 1, multiboot_entry () at src/multiboot_entry.asm:66
66	    mov   esp, stack_top
Current language:  auto; currently asm
(gdb) 
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: General Issues

Post by Solar »

Some googling came up with this command sequence to get a seperate symbol file for your executable:

Code: Select all

objcopy --only-keep-debug <in-executable> <out-symbol-file>
objcopy --add-gnu-debuglink=<out-symbol-file> <in-executable>
strip --strip-debug <in-executable>
Every good solution is obvious once you've found it.
User avatar
Walling
Member
Member
Posts: 158
Joined: Mon Dec 04, 2006 6:06 am
Location: Berlin, Germany

Re: General Issues

Post by Walling »

Solar wrote:Some googling came up with this command sequence to get a seperate symbol file for your executable
Nice. I tried it and it works, but the second objcopy doesn't seem to add anything. I also use this objcopy to strip away all information and only keep .text, .data and .bss sections:

Code: Select all

objcopy -j.text -j.data -j.bss -S <in-file> <out-file completely stripped>
I don't need to relocate the kernel, so I discard all symbols with -S. It becomes smaller (25%). And can I be sure that any Multiboot compliant boot loader obey the LOAD flag of ELF sections and doesn't load the debugging sections? The debugging sections have a load address of 0x0. It would overwrite the IVT table.
Post Reply