[LLVMdev] Debug Information

Török Edwin edwintorok at gmail.com
Sat Oct 11 00:37:22 PDT 2008


On 2008-10-11 00:34, Evan Cheng wrote:
> On Oct 10, 2008, at 1:43 PM, John Criswell wrote:
>
>   
>> Dear All,
>>
>> Are there a set of libraries for easily manipulating the LLVM debug
>> information?  For example, given an Instruction *, is there an  
>> interface
>> that will find the nearest llvm.dbg.stoppoint(), or given an alloca,  
>> is
>> there an interface for getting its source level information by tracing
>> it to a llvm.dbg.declare()?
>>
>> As far as I know, no such utility interfaces exist.  While I can  
>> role my
>> own, I'd like to avoid re-inventing the wheel if such interfaces  
>> already
>> exit.
>>     
>
> I am not aware of any existing or current work in this area.
>   

I wrote such a class a while ago, given an Instruction*, or a Value* it
returns a struct containing
file:line, original variable name, original type; and in some simple
cases it is able to pretty-print array references as well:

For example consider this snippet:

call void @llvm.dbg.declare({ }* %i2, { }* bitcast
(%llvm.dbg.variable.type* @llvm.dbg.variable13 to { }*))
call void @llvm.dbg.stoppoint(i32 11, i32 0, { }* bitcast
(%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
%0 = load %struct.test** %x_addr, align 8        ; <%struct.test*> [#uses=1]
%1 = getelementptr %struct.test* %0, i32 0, i32 0        ; <[10 x i8]*>
[#uses=1]
%2 = getelementptr [10 x i8]* %1, i32 0, i64 10        ; <i8*> [#uses=1]

%2 is pretty-printed as: variable x.buffer[10] (in
gep-struct-field-overflow.c:8)

I could update this class to LLVM TOT, and post it here for discussion.

Best regards,
--Edwin



More information about the llvm-dev mailing list