<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi Josh,<div><br><div><div>On Dec 4, 2011, at 9:33 PM, Josh Matthews wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>I'm working on generating debug information for Rust, and I'm<br>currently stumped on how to generate DWARF output via LLVM that will<br>correctly represent this (eg. when exiting from foo2(), I'd like to<br>see "Value returns is $1 = 5"). I'm generating debug metadata nodes<br>directly instead of using DIBuilder since it doesn't seem to<br>encapsulate situations like this. </div></blockquote><div><br></div><div>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 <a href="http://llvm.org/docs/SourceLevelDebugging.html#format_composite_type">http://llvm.org/docs/SourceLevelDebugging.html#format_composite_type</a>) is return type. </div><div><br></div><div>Let's say you have </div><div><br></div><div><div><font class="Apple-style-span" face="Monaco" style="font-size: 11px;">     1<span class="Apple-tab-span" style="white-space:pre">      </span></font></div><div><font class="Apple-style-span" face="Monaco" style="font-size: 11px;">     2<span class="Apple-tab-span" style="white-space:pre"> </span>int foo() {</font></div><div><font class="Apple-style-span" face="Monaco" style="font-size: 11px;">     3<span class="Apple-tab-span" style="white-space:pre">      </span>  char c = 'a';</font></div><div><font class="Apple-style-span" face="Monaco" style="font-size: 11px;">     4<span class="Apple-tab-span" style="white-space:pre">     </span>  return 42;</font></div><div><font class="Apple-style-span" face="Monaco" style="font-size: 11px;">     5<span class="Apple-tab-span" style="white-space:pre">        </span>}</font></div><div><br></div><div>Try generating following metadata nodes (I am not including all of them here) to describe 'char' as the return type of function 'foo'.</div><div><br></div><div><div><font class="Apple-style-span" face="Monaco" style="font-size: 11px;">!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\</font></div><div><font class="Apple-style-span" face="Monaco" style="font-size: 11px;">alse, i32 ()* @foo, null, null} ; [ DW_TAG_subprogram ]</font></div></div><div><font class="Apple-style-span" face="Monaco" style="font-size: 11px;"><br></font></div><div><div><font class="Apple-style-span" face="Monaco" style="font-size: 11px;">!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 ]                </font></div></div><div><font class="Apple-style-span" face="Monaco" style="font-size: 11px;"><br></font></div><div><div><font class="Apple-style-span" face="Monaco" style="font-size: 11px;">!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 ]                                                    </font></div></div><div><br></div><div>Next, when you generate metadata nodes for arguments, slide argument numbers by 1. (<a href="http://llvm.org/docs/SourceLevelDebugging.html#format_variables">http://llvm.org/docs/SourceLevelDebugging.html#format_variables</a>)</div><div><br></div><div>I have not tried this myself, but I hope it helps.</div><div>-</div><div>Devang</div><div><br></div></div></div><br></div></body></html>