-
Notifications
You must be signed in to change notification settings - Fork 0
/
dsym-find.c
49 lines (39 loc) · 1.91 KB
/
dsym-find.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* lldb and gdb both use the DebugSymbols framework to find dSYM files.
// /Users/jrmuizel/src/lldb/source/Host/macosx/Symbols.cpp
// DBGCopyFullDSYMURLForUUID
// DBGCopyDSYMURLForUUID
// https://github.com/eightcien/lldb/blob/211925ad15468061135882005efd9d17e9ce8193/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
/* atos uses CoreSymbolication which uses DebugSymbols
U _DBGCopyDSYMPropertyLists
U _DBGCopyFullDSYMURLForUUID
U _DBGCopyFullDSYMURLForUUIDWithOptions
*/
/* get the UUID from a binary with llvm-objdump -macho -private-headers [binary]
cmd LC_UUID
cmdsize 24
uuid 20D9F286-538F-3A12-98E0-91379CB90844
*/
#include <CoreFoundation/CoreFoundation.h>
CFURLRef DBGCopyFullDSYMURLForUUID(CFUUIDRef uuid, CFURLRef exec_url);
CFDictionaryRef DBGCopyDSYMPropertyLists(CFURLRef dsym_url);
int main(int argc, char **argv) {
if (argc < 2) {
printf("usage: dsym-find executable uuid\n");
printf("get the UUID from a binary with llvm-objdump -macho -private-headers [binary]\n");
exit(1);
}
char *path = argv[1];
CFURLRef url = CFURLCreateFromFileSystemRepresentation(
NULL, (const UInt8 *)path, strlen(path),
FALSE
);
CFUUIDRef uuid = CFUUIDCreateFromString(kCFAllocatorDefault, CFStringCreateWithCString(kCFAllocatorDefault, argv[2], kCFStringEncodingMacRoman));
CFURLRef dsym_url = DBGCopyFullDSYMURLForUUID(uuid, url);
if (dsym_url) {
char dsym_path[PATH_MAX];
CFURLGetFileSystemRepresentation(dsym_url, true, dsym_path, sizeof(dsym_path) - 1);
printf("path: %s\n", dsym_path);
} else {
printf("dsym not found\n");
}
}