OSDev.org

The Place to Start for Operating System Developers
It is currently Sun Jul 22, 2018 10:34 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: separate debugging symbols
PostPosted: Sun Oct 22, 2006 5:28 pm 
Offline

Joined: Sun Oct 22, 2006 4:51 pm
Posts: 1
On the "How do I use a debugger with my OS" page, in the "Use gdb with Qemu" section, there is:
Quote:
But thats not all, you can compile your source code under gcc with debuging symbols using "-g". This will add all the debuging symbols in the kernel image itself (Thus making it bigger ). I think there is a way to make this symbol file seperate, if so, please let me know.

While I haven't worked in kernel space yet, I know how to do this in userland (and it's probably the same):

Compile the program in two steps. When creating the object file, add debugging information. When linking, keep it in the debug version and remove it from the standard one:
Code:
gcc -g -c program.c -o program.o
gcc program.o -o program.dbg
gcc program.o -s -o program

If you want, you can remove the code from program.dbg, only keeping the debugging information (this is not necessary):
Code:
strip program.dbg --only-keep-debug

If you prefer compiling in one step, you may do the following instead:
Code:
gcc -g program.c -o program
strip program --only-keep-debug -o program.dbg
strip program


On to starting gdb. If you would like to use the symbol file from the beginning, you could use:
Code:
gdb --exec program --symbols program.dbg

If you want to load it later or manually, start "gdb program" and at the (gdb) prompt, type
Code:
add-symbol-file program.dbg


Hope that helps.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


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