构建应用程序时生成的dsym文件的结构。我知道它包含DWARF调试信息,但是什么是dsym文件。我想在其中阅读DWARF信息。
它只是一个只包含调试部分的Mach-O二进制文件吗?如何将它传递给像pyelftool
这样的DWARF解析工具,它读取ELF文件调试部分中的DWARF信息。
我使用objdump -h
打印dsym文件的部分(.dsym文件是一个包,我只是引用包中的二进制文件)
/Users/luna/Desktop/EarList.app.dSYM/Contents/Resources/DWARF/EarList: file format mach-o-i386
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00001738 000026e0 000026e0 00000000 2**4
ALLOC, LOAD, CODE
1 .symbol_stub 00000054 00003e18 00003e18 00000000 2**1
ALLOC, LOAD, CODE
2 __TEXT.__stub_helper 00000098 00003e6c 00003e6c 00000000 2**2
ALLOC, LOAD, READONLY, CODE
3 .const 00000010 00003f08 00003f08 00000000 2**3
ALLOC, LOAD, READONLY, DATA
4 __TEXT.__objc_methname 000007db 00003f18 00003f18 00000000 2**0
ALLOC, LOAD, READONLY, CODE
5 .cstring 000001a9 000046f3 000046f3 00000000 2**0
ALLOC, LOAD, READONLY, DATA
6 __TEXT.__objc_classname 0000003c 0000489c 0000489c 00000000 2**0
ALLOC, LOAD, READONLY, CODE
7 __TEXT.__objc_methtype 0000049d 000048d8 000048d8 00000000 2**0
ALLOC, LOAD, READONLY, CODE
8 __TEXT.__unwind_info 0000007c 00004d75 00004d75 00000000 2**0
ALLOC, LOAD, READONLY, CODE
9 .eh_frame 00000204 00004df8 00004df8 00000000 2**3
ALLOC, LOAD, READONLY, DATA
10 __DATA.__program_vars 00000014 00005000 00005000 00000000 2**2
ALLOC, LOAD, DATA
11 .non_lazy_symbol_pointer 00000008 00005014 00005014 00000000 2**2
ALLOC, LOAD, DATA
12 .lazy_symbol_pointer 00000038 0000501c 0000501c 00000000 2**2
ALLOC, LOAD, DATA
13 __DATA.__objc_classlist 00000008 00005054 00005054 00000000 2**2
ALLOC, LOAD, DATA
14 __DATA.__objc_protolist 00000008 0000505c 0000505c 00000000 2**2
ALLOC, LOAD, DATA
15 __DATA.__objc_imageinfo 00000008 00005064 00005064 00000000 2**2
ALLOC, LOAD, DATA
16 __DATA.__objc_const 00000518 00005070 00005070 00000000 2**3
ALLOC, LOAD, DATA
17 __DATA.__objc_selrefs 00000054 00005588 00005588 00000000 2**2
ALLOC, LOAD, DATA
18 __DATA.__objc_classrefs 00000010 000055dc 000055dc 00000000 2**2
ALLOC, LOAD, DATA
19 __DATA.__objc_superrefs 00000004 000055ec 000055ec 00000000 2**2
ALLOC, LOAD, DATA
20 __DATA.__objc_data 00000050 000055f0 000055f0 00000000 2**2
ALLOC, LOAD, DATA
21 .cfstring 00000290 00005640 00005640 00000000 2**2
ALLOC, LOAD, DATA
22 __DATA.__objc_ivar 00000004 000058d0 000058d0 00000000 2**2
ALLOC, LOAD, DATA
23 .data 00000058 000058d4 000058d4 00000000 2**2
ALLOC, LOAD, DATA
24 __DATA.__common 00000010 0000592c 0000592c 00000000 2**2
ALLOC
25 .debug_abbrev 0000028a 00008000 00008000 00002000 2**0
CONTENTS, DEBUGGING
26 .debug_aranges 000000c0 0000828a 0000828a 0000228a 2**0
CONTENTS, DEBUGGING
27 .debug_info 0000813c 0000834a 0000834a 0000234a 2**0
CONTENTS, DEBUGGING
28 __DWARF.__debug_inlined 00000038 00010486 00010486 0000a486 2**0
CONTENTS, ALLOC, LOAD, DATA
29 .debug_line 00001205 000104be 000104be 0000a4be 2**0
CONTENTS, DEBUGGING
30 .debug_pubnames 0000028e 000116c3 000116c3 0000b6c3 2**0
CONTENTS, DEBUGGING
31 .debug_pubtypes 0000159f 00011951 00011951 0000b951 2**0
CONTENTS, DEBUGGING
32 .debug_str 00005e4f 00012ef0 00012ef0 0000cef0 2**0
CONTENTS, DEBUGGING
33 __DWARF.__apple_names 0000033c 00018d3f 00018d3f 00012d3f 2**0
CONTENTS, ALLOC, LOAD, DATA
34 __DWARF.__apple_types 000016a3 0001907b 0001907b 0001307b 2**0
CONTENTS, ALLOC, LOAD, DATA
35 __DWARF.__apple_namespac 00000024 0001a71e 0001a71e 0001471e 2**0
CONTENTS, ALLOC, LOAD, DATA
36 __DWARF.__apple_objc 00000088 0001a742 0001a742 00014742 2**0
CONTENTS, ALLOC, LOAD, DATA
答案 0 :(得分:1)
在https://pypi.org/project/dwex/处还有一个GUI DWARF Explorer。通过从命令运行pip install dwex
进行安装,然后与dwex
运行。
它支持dSYM捆绑包。在主窗口上拖动一个,然后看树。
答案 1 :(得分:0)
您将能够使用dwarfdump
命令读取DWARF调试信息。
答案 2 :(得分:0)
dSYM确实是一个容器(目录),其中包含仅包含DWARF调试数据的Mach O二进制文件,而且没有代码。
您可以使用filebytes和pyelftools
在Python中进行检查import io
from filebytes.mach_o import MachO
from elftools.dwarf.dwarfinfo import DWARFInfo, DebugSectionDescriptor, DwarfConfig
macho = MachO(filename)
data = {
section.name: DebugSectionDescriptor(io.BytesIO(section.bytes), section.name, None, len(section.bytes), 0)
for loadcmd in macho.loadCommands
if getattr(loadcmd, 'name', None) == '__DWARF'
for section in loadcmd.sections
}
dwarfinfo = DWARFInfo(
config=DwarfConfig(
little_endian=True,
default_address_size=8, # 64 bit
machine_arch='x64',
),
debug_info_sec=data['__debug_info'],
debug_aranges_sec=None,
debug_abbrev_sec=data['__debug_abbrev'],
debug_frame_sec=None,
eh_frame_sec=data['__eh_frame'],
debug_str_sec=data['__debug_str'],
debug_loc_sec=data['__debug_loc'],
debug_ranges_sec=data['__debug_ranges'],
debug_line_sec=data['__debug_line']
)