Page 1 of 1

How to use symbols in bochs?

Posted: Mon Feb 25, 2013 9:10 pm
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?

Re: How to use symbols in bochs?

Posted: Wed Feb 27, 2013 1:04 am
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.

Re: How to use symbols in bochs?

Posted: Wed Feb 27, 2013 4:23 am
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.

Re: How to use symbols in bochs?

Posted: Sat Mar 23, 2013 9:38 pm
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?

Re: How to use symbols in bochs?

Posted: Sat Mar 23, 2013 10:59 pm
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.

Re: How to use symbols in bochs?

Posted: Sun Mar 24, 2013 5:57 am
by dozniak
something like this is useful:

Code: Select all

#!/bin/sh
nm $1 | grep " T " | awk '{ print $1" "$3 }' > $1.sym

Re: How to use symbols in bochs?

Posted: Tue Mar 26, 2013 11:20 am
by lcjuanpa
Thanks a lot dozniak =D>

Maybe my question should be more explanatory (of course I read the manual linked by combuster).

Re: How to use symbols in bochs?

Posted: Tue Mar 26, 2013 12:10 pm
by Combuster
Reading then deliberately ignoring everything the manual said doesn't count - see the comments above.

Re: How to use symbols in bochs?

Posted: Tue Mar 26, 2013 1:05 pm
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.