How to get source file name from its executable via plan9port db(1) unility?

77 Views Asked by At

Moving to plan9port utilites I can't get used of src utility for executables (for scripts it works fine). It refers to db(1) to get a source file-name from executable in the following way:

% echo 'main?z' | db $1 | <some staff>

where $1 is an executable program name and main?z a special instruction to db(1) debugger to print the file-name with function main.

But in my version of linux (Ubuntu) it doesn't works. db(1) do not produce a file-name, - it just prints the name of procedure: main() and no sources info.

I've tried to compile with 9c -n (I think -n prevents compiler from stripping the code) with no luck.

1

There are 1 best solutions below

0
On

DWARF-2 is the key:

$ 9c -gdwarf-2 wc.c -o wc.o
$ 9l wc.o -o wc
$ echo 'p9main?z' | db wc
wc: linux 386 executable
no dt_debug section
p9main?                 p9main() /home/egor/plan9port/src/cmd/wc.c:21