-
-
Notifications
You must be signed in to change notification settings - Fork 284
Expand file tree
/
Copy pathmacho.d
More file actions
58 lines (48 loc) · 1.42 KB
/
macho.d
File metadata and controls
58 lines (48 loc) · 1.42 KB
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
50
51
52
53
54
55
56
57
58
/**
* This module extracts debug info from the currently running Mach-O executable.
*
* Copyright: Copyright Jacob Carlborg 2018.
* License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Authors: Jacob Carlborg
* Source: $(DRUNTIMESRC core/internal/backtrace/macho.d)
*/
module core.internal.backtrace.macho;
version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;
version (Darwin):
import core.stdc.config : c_ulong;
import core.stdc.stdlib : free;
import core.internal.macho.dl;
import core.internal.macho.io;
struct Image {
SharedObject self;
SharedObject debugObj;
this(SharedObject self) {
this.self = self;
this.debugObj = self;
if (!self.hasSection("__DWARF", "__debug_line")) {
auto dsymPath = getDsymDefaultPath();
this.debugObj = SharedObject.fromFile(dsymPath.ptr);
}
}
T processDebugLineSectionData(T)(scope T delegate(const(ubyte)[]) processor) {
return processor(debugObj.getSection("__DWARF", "__debug_line"));
}
static Image openSelf() {
return Image(SharedObject.thisExecutable());
}
@property bool isValid() {
return self.isValid;
}
@property size_t baseAddress() {
if (debugObj.slide == -1)
return self.slide;
return 0;
}
}