How to use symbols in bochs?

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
MarkZar
Posts: 13
Joined: Thu Feb 07, 2013 11:53 pm

How to use symbols in bochs?

Post by MarkZar »

When I try to debug my os, I always need to set breakpoint in many place to find the right function that I am goint to debug. Is there any way to let bochs load the symbols? And Is there any way to let gdb/nasm to generate the right symbols? For example, I have two files, kernel.asm will be loaded to 0x0008: 0x9000h, main.c will be loaded to 0x0008:8000h, both in realmode. How can I set the gdb/nasm to generate the right symbols to let bochs to load?
linguofreak
Member
Member
Posts: 510
Joined: Wed Mar 09, 2011 3:55 am

Re: How to use symbols in bochs?

Post by linguofreak »

MarkZar wrote:When I try to debug my os, I always need to set breakpoint in many place to find the right function that I am goint to debug. Is there any way to let bochs load the symbols?
Not that I know of. However, you might want to look up the bochs magic breakpoint, and breakpoints in bochs in general.
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: How to use symbols in bochs?

Post by Combuster »

People, please, learn to read the manual [-X
ldsym [global] filename [offset]

Load symbols from file filename. If the global keyword is added, then the the symbols will be visible in all contexts for which symbols have not been loaded. Offset (default is 0) is added to every symbol entry. The symbols are loaded in the current (executing) context.
"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 ]
lcjuanpa
Posts: 8
Joined: Fri Feb 15, 2013 9:24 pm

Re: How to use symbols in bochs?

Post by lcjuanpa »

Hi everybody.

I have problems to generate the symbol file.
I used next commands to generate and probe them with bochs, but I got the same error:

>$ objcopy --only-keep-debug kernel kernel.sym
and
>$ objcopy --extract-symbol kernel kernel.sym

from internal bochs' debugger I get the next:
<bochs:1> ldsym global "kernel.sym"
kernel.sym:1: syntax error near 'ELF'

I'm using GAS assembler and C, and I have several files in different diretories.

forget I something?
User avatar
Nessphoro
Member
Member
Posts: 308
Joined: Sat Apr 30, 2011 12:50 am

Re: How to use symbols in bochs?

Post by Nessphoro »

lcjuanpa wrote:from internal bochs' debugger I get the next:
<bochs:1> ldsym global "kernel.sym"
kernel.sym:1: syntax error near 'ELF'
From 8.12. Using Bochs internal debugger wrote: The symbol file consists of zero or more lines of the format
"%x %s"
Maybe you should read the document, as Combuster said.
User avatar
dozniak
Member
Member
Posts: 723
Joined: Thu Jul 12, 2012 7:29 am
Location: Tallinn, Estonia

Re: How to use symbols in bochs?

Post by dozniak »

something like this is useful:

Code: Select all

#!/bin/sh
nm $1 | grep " T " | awk '{ print $1" "$3 }' > $1.sym
Learn to read.
lcjuanpa
Posts: 8
Joined: Fri Feb 15, 2013 9:24 pm

Re: How to use symbols in bochs?

Post by lcjuanpa »

Thanks a lot dozniak =D>

Maybe my question should be more explanatory (of course I read the manual linked by combuster).
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: How to use symbols in bochs?

Post by Combuster »

Reading then deliberately ignoring everything the manual said doesn't count - see the comments above.
"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 ]
lcjuanpa
Posts: 8
Joined: Fri Feb 15, 2013 9:24 pm

Re: How to use symbols in bochs?

Post by lcjuanpa »

Just as a comment:

The command:
> $ objcopy --only-keep-debug kernel kernel.sym
generate a binary file and the dozniak's script
#!/bin/sh
nm $1 | grep " T " | awk '{ print $1" "$3 }' > $1.sym
generate a text file.

Maybe in the manual of bochs should be appear that filename is a text file (if I'm not wrong) and "%x %s" represent an address and a symbol.

Sometimes one trust in the result of the tools that one have. Sometimes one doesn't understand the same things in the same way.
Post Reply