[LLVMdev] Compile units in debugging intrinsics / globals
richard.smith at antixlabs.com
Wed Apr 23 09:37:51 PDT 2008
I have a question about the llvm debugging records, especially wrt compile
In the non-LLVM sense, a compile unit is essentially everything contained
within a single .o file, and it is derived from one or more source and
header files. Included in a compile unit are functions and global data.
Dwarf records refer to compile units in the same way: a compile unit record
has children which define subprograms and variables, and definitions of
types used with these.
In the LLVM sense, there is a compile unit record for _every_ source file.
The globals in the llvm.metadata section and debug intrisics reference the
appropriate compile unit record to indicate where in source the item they
are describing appears.
By the time the llvm linker has finished its work all the functions and
global data, along with their debugging records, may be rearranged and I
want to pull them all together into the appropriate Dwarf compile units. To
do that I can look at the (llvm) compile unit records but this only works
when all are defined in the same source file. If data or a function is
defined in an included file then they appear to be in a different compile
Suppose I have the following source:
int fn1(void) ...
int fn2(void) ...
then fn1, along with all the base types etc appear to be in compile unit
"file1", the variable a appears to be in compile unit "file2" (and there are
no basic types in file2, so int is not defined), and fn2 appears to be in
compile unit "file3". My dwarf records are therefore incorrect, appearing
TAG_subprogram "fn1" ...
TAG_base_type "int" ...
TAG_variable "a" ...
TAG_subprogram "fn2" ...
When, in fact, these compile units "file2" and "file3" are bogus and
everything should be part of compile_unit "file1".
My question is: can I tell that these three (llvm) compile units are in fact
components of the single (non-LLVM) compile unit? Or is there some other way
I should be determining which (non-LLVM) compile unit the records are part
Antix Labs Ltd
400 Thames Valley Park Drive, Reading, Berkshire, RG6 1PT
Tel.: +44 (0) 118 357 0 357
More information about the llvm-dev