how to get paths to files compiled by rdmd in resulting binary

Timothee Cour thelastmammoth at gmail.com
Tue Mar 26 14:10:29 PDT 2013


I wrote a stacktrace tool that shows a nice stacktrace upon error,
with file names, demangled D symbols and (sometimes) line numbers. It
works on OSX and linux and uses execlp behind the hoods.

Problem:

for some silly reason I can only get stack trace info of the form:
D5main28main_auxFZi (in main2) (main2.d:41)
whereas I want the full path to main2.d

Is there a RELIABLE way to extract the paths from a binary compiled by
dmd/rdmd?'

right now I have to do the following:
strings /Users/timothee/git_clone/timg/build/arch/osx/dev/compile_rdmd2|grep
$path_to_source_root
then I have to demangle
demangle D5main28main_auxFZi


                int main2.main_aux()

then I have to pattern match 'main2.main_aux' into the list of paths
from strings.
That's silly and error prone, since dmd should have all the info to
produce better debugging info, such as line numbers for each symbol
more reliably, and mapping between modules and paths, etc.
Again, modules and paths are not always directly inferable (eg :
different include paths with same base names ; or modules whose name
doesn't match file name)

So, is there a better way to reliably infer exact path+line for a
given stackframe and symbol, and if not, can dmd produce this info
(say when -g or -gextended is set)

Thanks,
Timothee Cour


More information about the Digitalmars-d-learn mailing list