Skip to content
This repository has been archived by the owner on Jan 6, 2022. It is now read-only.

Debugging the emitted DWARF binaries

Nat! edited this page Oct 14, 2019 · 3 revisions

Linux

This dumps all these DW_AT_ tags:

readelf --debug-dump=info <object|executable>

In the debugger

log enable dwarf all

Example

Compile this with mulle-clang -g -O0 -c x.m

static const struct mulle_clang_objccompilerinfo
{
   unsigned int   load_version;
   unsigned int   runtime_version;
} __mulle_objc_objccompilerinfo =
{
   16, // @mulle-objc@ load version must match
   0   // 0 to not emit __load_mulle_objc
};

@interface NSObject
@end

@interface Hello : NSObject
@end

@implementation Hello : NSObject
@end

Run this into readelf --debug-dump=info x.o:

Contents of the .debug_info section:

  Compilation Unit @ offset 0x0:
   Length:        0x34 (32-bit)
   Version:       4
   Abbrev Offset: 0x0
   Pointer Size:  8
 <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <c>   DW_AT_producer    : (indirect string, offset: 0x0): mulle-clang 9.0.0.0 (runtime-load-version: 16) clang version 9.0.0 (gitolite.mulle-kybernetik.com:mulle-clang 586e71b26d23b4e715c2e05247787e1daaedf73d) (based on LLVM 9.0.0)
    <10>   DW_AT_language    : 16	(Objective C)
    <12>   DW_AT_name        : (indirect string, offset: 0xae): x.m
    <16>   DW_AT_stmt_list   : 0x0
    <1a>   DW_AT_comp_dir    : (indirect string, offset: 0xb2): /usr/local/llvm/srcL/research
 <1><1e>: Abbrev Number: 2 (DW_TAG_structure_type)
    <1f>   DW_AT_APPLE_objc_complete_type: 1
    <1f>   DW_AT_name        : (indirect string, offset: 0xd9): Hello
    <23>   DW_AT_byte_size   : 0
    <24>   DW_AT_decl_file   : 1
    <25>   DW_AT_decl_line   : 15
    <26>   DW_AT_APPLE_runtime_class: 16
 <2><27>: Abbrev Number: 3 (DW_TAG_inheritance)
    <28>   DW_AT_type        : <0x2e>
    <2c>   DW_AT_data_member_location: 0
 <2><2d>: Abbrev Number: 0
 <1><2e>: Abbrev Number: 4 (DW_TAG_structure_type)
    <2f>   DW_AT_name        : (indirect string, offset: 0xd0): NSObject
    <33>   DW_AT_byte_size   : 0
    <34>   DW_AT_decl_file   : 1
    <35>   DW_AT_decl_line   : 12
    <36>   DW_AT_APPLE_runtime_class: 16
 <1><37>: Abbrev Number: 0

Notice the absence of DW_AT_APPLE_objc_complete_type: in NSObject, which is significant for a "forward" declared class.