kubo39's blog

ただの雑記です。

DMDのDWARFが2019年でまだv3だった

ふと、DMDが生成するデバッグ情報を調べていたところDMDはDWARF v3でデバッグ情報を付与するようだ。

DMDのバージョンは2.089.0を使っている。

$ dmd --version
DMD64 D Compiler v2.089.0
Copyright (C) 1999-2019 by The D Language Foundation, All Rights Reserved written by Walter Bright
  • DWARF v3にあがったときのコミット (2015年)

[dwarf] Bump default debug version to DWARF3 by ibuclaw · Pull Request #4734 · dlang/dmd · GitHub

  • DWARF v4の拡張の定義(2015年)

Add DWARF 4 extensions by ibuclaw · Pull Request #4733 · dlang/dmd · GitHub

上記の変更でv4移行のバージョンが定義されている場合 DW_AT_MIPS_linkage_name ではなく DW_AT_linkage_name を用いるようになっているが、DMD内の定義で enum DWARF_VERSION = 3 と固定されているので DW_AT_MIPS_linkage_name が生成されている。

$ LANG=C objdump --dwarf=info helloworld| grep linkage_name| ddemangle
    <75>   DW_AT_MIPS_linkage_name: _Dmain
    <ce>   DW_AT_MIPS_linkage_name: main
    <77a>   DW_AT_MIPS_linkage_name: @safe void std.stdio.writeln!(immutable(char)[]).writeln(immutable(char)[])
    <89e>   DW_AT_MIPS_linkage_name: @safe void std.stdio.File.LockingTextWriter.put!(immutable(char)[]).put(scope immutable(char)[])
    <9c6>   DW_AT_MIPS_linkage_name: pure nothrow @nogc @safe const(char)[] std.stdio.File.LockingTextWriter.put!(immutable(char)[]).put(scope immutable(char)[]).__dgliteral2()
    <a7a>   DW_AT_MIPS_linkage_name: nothrow @nogc @trusted ulong std.stdio.trustedFwrite!(char).trustedFwrite(shared(core.stdc.stdio._IO_FILE)*, const(char[]))
    <b4d>   DW_AT_MIPS_linkage_name: @safe int std.exception.enforce!(std.exception.ErrnoException).enforce!(int).enforce(int, lazy const(char)[], immutable(char)[], ulong)
    <c34>   DW_AT_MIPS_linkage_name: @safe void std.exception.bailOut!(std.exception.ErrnoException).bailOut(immutable(char)[], ulong, scope const(char)[])
    <cdf>   DW_AT_MIPS_linkage_name: pure nothrow @property @safe immutable(char)[] object.idup!(const(char)).idup(const(char)[])
    <d71>   DW_AT_MIPS_linkage_name: pure nothrow @trusted immutable(char)[] object._trustedDup!(const(char), immutable(char))._trustedDup(const(char)[])
    <e2d>   DW_AT_MIPS_linkage_name: pure nothrow immutable(char)[] object._dup!(const(char), immutable(char))._dup(const(char)[])
    <f45>   DW_AT_MIPS_linkage_name: pure nothrow @nogc @safe void object._doPostblit!(immutable(char))._doPostblit(immutable(char)[])
    <100d>   DW_AT_MIPS_linkage_name: pure nothrow @nogc @trusted void delegate(ref immutable(char)) pure nothrow @nogc @safe object._getPostblit!(immutable(char))._getPostblit()
    <10a2>   DW_AT_MIPS_linkage_name: @safe void std.stdio.File.LockingTextWriter.put!(immutable(char)).put(immutable(char))
    <115a>   DW_AT_MIPS_linkage_name: nothrow @nogc @trusted int std.stdio.File.LockingTextWriter.put!(immutable(char)).put(immutable(char)).trustedFPUTC(int, core.stdc.stdio._IO_FILE*)
    <124d>   DW_AT_MIPS_linkage_name: nothrow @nogc @trusted int std.stdio.File.LockingTextWriter.put!(immutable(char)).put(immutable(char)).trustedFPUTWC(dchar, core.stdc.stdio._IO_FILE*)
    <131d>   DW_AT_MIPS_linkage_name: @safe void std.stdio.File.LockingTextWriter.put!(char).put(char)
    <13c6>   DW_AT_MIPS_linkage_name: nothrow @nogc @trusted int std.stdio.File.LockingTextWriter.put!(char).put(char).trustedFPUTC(int, core.stdc.stdio._IO_FILE*)
    <14a1>   DW_AT_MIPS_linkage_name: nothrow @nogc @trusted int std.stdio.File.LockingTextWriter.put!(char).put(char).trustedFPUTWC(dchar, core.stdc.stdio._IO_FILE*)
    <3410>   DW_AT_linkage_name: (indirect string, offset: 0x120): __register_atfork

__register_atforkDW_AT_linkage_name と出てきているが、これはDMDとは関連がない。

<1><340f>: Abbrev Number: 60 (DW_TAG_subprogram)
    <3410>   DW_AT_external    : 1
    <3410>   DW_AT_declaration : 1
    <3410>   DW_AT_linkage_name: (indirect string, offset: 0x120): __register_atfork
    <3414>   DW_AT_name        : (indirect string, offset: 0x120): __register_atfork
    <3418>   DW_AT_decl_file   : 42
    <3419>   DW_AT_decl_line   : 52