[LLVMdev] Generating DWARF information that pretends an outparam is the return value

Devang Patel dpatel at apple.com
Tue Dec 6 16:18:08 PST 2011


On Dec 6, 2011, at 4:13 PM, Devang Patel wrote:

> Hi Josh,
> 
> On Dec 4, 2011, at 9:33 PM, Josh Matthews wrote:
> 
>> I'm working on generating debug information for Rust, and I'm
>> currently stumped on how to generate DWARF output via LLVM that will
>> correctly represent this (eg. when exiting from foo2(), I'd like to
>> see "Value returns is $1 = 5"). I'm generating debug metadata nodes
>> directly instead of using DIBuilder since it doesn't seem to
>> encapsulate situations like this.
> 
> So, I assume you figured out how to create metadata nodes for TAG_subprogram and corresponding TAG_subroutine_type. If yes, then the zero'th element of array of types you supply (subroutine_type is encoded as composite type, see http://llvm.org/docs/SourceLevelDebugging.html#format_composite_type) is return type. 
> 
> Let's say you have 
> 
>      1	
>      2	int foo() {
>      3	  char c = 'a';
>      4	  return 42;
>      5	}
> 
> Try generating following metadata nodes (I am not including all of them here) to describe 'char' as the return type of function 'foo'.
> 
> !1 = metadata !{i32 589870, i32 0, metadata !2, metadata !"foo", metadata !"foo", metadata !"", metadata !2, i32 2, metadata !3, i1 false, i1 true, i32 0, i32 0, i32 0, i32 0, i1 f\
> alse, i32 ()* @foo, null, null} ; [ DW_TAG_subprogram ]
> 
> !3 = metadata !{i32 589845, metadata !2, metadata !"", metadata !2, i32 0, i64 0, i64 0, i32 0, i32 0, i32 0, metadata !4, i32 0, i32 0} ; [ DW_TAG_subroutine_type ]    


!4 = metadata !{metadata !8}

>            
> 
> !8 = metadata !{i32 589860, metadata !0, metadata !"char", null, i32 0, i64 8, i64 8, i64 0, i32 0, i32 6} ; [ DW_TAG_base_type ]                                                   
> 
> Next, when you generate metadata nodes for arguments, slide argument numbers by 1. (http://llvm.org/docs/SourceLevelDebugging.html#format_variables)
> 
> I have not tried this myself, but I hope it helps.
> -
> Devang
> 
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20111206/40fb522f/attachment.html>


More information about the llvm-dev mailing list