One caveat is that Eric (& I can't really disagree) would rather like to kill off some of the old DWARF support to keep our codebase simple - so if there's any way you can upgrade those tools to cope with modern DWARF, that'd be really nice.<br>
<br>But for the specific issue of stmt_list and sec_offset, so far as I can tell this is not reproducible with ToT Clang/LLVM. I get:<div><br></div><div>echo "int main(void) { return 0; }" | clang-tot -gdwarf-2 -S -x c - -o - <br>
</div><div><br><div>        .byte   16                      # DW_AT_stmt_list</div><div>        .byte   6                       # DW_FORM_data4</div><br>And the code in LLVM looks like it does the right thing here, choosing the form based on DWARF version.</div>
<br><div>On Fri Jan 03 2014 at 8:26:06 AM, Dimitry Andric <<a href="mailto:dimitry@andric.com">dimitry@andric.com</a>> wrote:</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 03 Jan 2014, at 02:30, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<br>
> Author: dblaikie<br>
> Date: Thu Jan  2 19:30:05 2014<br>
> New Revision: 198389<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=198389&view=rev" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project?rev=198389&view=rev</a><br>
> Log:<br>
> Revert "Reverting r193835 due to weirdness with Go..."<br>
><br>
> The cgo problem was that it wants dwarf2 which doesn't support direct<br>
> constant encoding of the location. So let's add support for dwarf2<br>
> encoding (using a location expression) of data member locations.<br>
><br>
> This reverts commit r198385.<br>
<br>
Hi David,<br>
<br>
This solves at least one problem that I encountered when importing clang 3.4 into FreeBSD 11.  Some of our kernel tools for DTrace support require dwarf 2, so we compile with -gdwarf-2.  Applying a slightly modified form of this commit to my copy of clang 3.4 makes it work partially.<br>

<br>
Though even with -gdwarf-2, clang still outputs DW_FORM_sec_offset attribute forms, which apparently are DWARF4 only.  The DWARF4 spec says, under "Changes from Version 3 to Version 4": "Add a new attribute form for section offsets, DW_FORM_sec_offset, to replace the use of DW_FORM_data4 and DW_FORM_data8 for section offsets."<br>

<br>
For example, if you compile an "int main(void) { return 0; }" program with -gdwarf-2 -S, the resulting .debug_abbrev section has:<br>
<br>
        .section        .debug_abbrev,"",@progbits<br>
.L.debug_abbrev_begin:<br>
        .byte   1                       # Abbreviation Code<br>
        .byte   17                      # DW_TAG_compile_unit<br>
        .byte   1                       # DW_CHILDREN_yes<br>
        .byte   37                      # DW_AT_producer<br>
        .byte   14                      # DW_FORM_strp<br>
        .byte   19                      # DW_AT_language<br>
        .byte   5                       # DW_FORM_data2<br>
        .byte   3                       # DW_AT_name<br>
        .byte   14                      # DW_FORM_strp<br>
        .byte   17                      # DW_AT_low_pc<br>
        .byte   1                       # DW_FORM_addr<br>
        .byte   16                      # DW_AT_stmt_list<br>
        .byte   23                      # DW_FORM_sec_offset   <=== DWARF4?<br>
        .byte   27                      # DW_AT_comp_dir<br>
        .byte   14                      # DW_FORM_strp<br>
        .byte   0                       # EOM(1)<br>
        .byte   0                       # EOM(2)<br>
        .byte   2                       # Abbreviation Code<br>
        .byte   46                      # DW_TAG_subprogram<br>
        .byte   0                       # DW_CHILDREN_no<br>
        .byte   3                       # DW_AT_name<br>
        .byte   14                      # DW_FORM_strp<br>
        .byte   58                      # DW_AT_decl_file<br>
        .byte   11                      # DW_FORM_data1<br>
        .byte   59                      # DW_AT_decl_line<br>
        .byte   11                      # DW_FORM_data1<br>
        .byte   39                      # DW_AT_prototyped<br>
        .byte   12                      # DW_FORM_flag<br>
        .byte   73                      # DW_AT_type<br>
        .byte   19                      # DW_FORM_ref4<br>
        .byte   63                      # DW_AT_external<br>
        .byte   12                      # DW_FORM_flag<br>
        .byte   17                      # DW_AT_low_pc<br>
        .byte   1                       # DW_FORM_addr<br>
        .byte   18                      # DW_AT_high_pc<br>
        .byte   1                       # DW_FORM_addr<br>
        .byte   64                      # DW_AT_frame_base<br>
        .byte   10                      # DW_FORM_block1<br>
        .byte   0                       # EOM(1)<br>
        .byte   0                       # EOM(2)<br>
        .byte   3                       # Abbreviation Code<br>
        .byte   36                      # DW_TAG_base_type<br>
        .byte   0                       # DW_CHILDREN_no<br>
        .byte   3                       # DW_AT_name<br>
        .byte   14                      # DW_FORM_strp<br>
        .byte   62                      # DW_AT_encoding<br>
        .byte   11                      # DW_FORM_data1<br>
        .byte   11                      # DW_AT_byte_size<br>
        .byte   11                      # DW_FORM_data1<br>
        .byte   0                       # EOM(1)<br>
        .byte   0                       # EOM(2)<br>
        .byte   0                       # EOM(3)<br>
.L.debug_abbrev_end:<br>
<br>
-Dimitry<br>
<br>
</blockquote>