Debug Information

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.

Thanks in advance.

-- John T.

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.

Evan

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

Török Edwin wrote:

[snip]
  
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:
  

This sounds like exactly what I need. I'd be very interested in having this code. If you post it to llvmdev, I can take a look at it and, if it fits my needs, update it to TOT for you.

At this point, I can either use your code or roll my own. It sounds like updating yours would be faster and more generally useful to the LLVM community.

-- John T.