-
Notifications
You must be signed in to change notification settings - Fork 4.6k
/
dumpwritermacho.h
51 lines (45 loc) · 1.36 KB
/
dumpwritermacho.h
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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
struct ThreadCommand
{
thread_command command;
uint32_t gpflavor;
uint32_t gpcount;
#if defined(__x86_64__)
x86_thread_state64_t gpregisters;
#elif defined(__aarch64__)
arm_thread_state64_t gpregisters;
#endif
uint32_t fpflavor;
uint32_t fpcount;
#if defined(__x86_64__)
x86_float_state64_t fpregisters;
#elif defined(__aarch64__)
arm_neon_state64_t fpregisters;
#endif
};
class DumpWriter
{
private:
int m_fd;
CrashInfo& m_crashInfo;
std::vector<segment_command_64> m_segmentLoadCommands;
std::vector<ThreadCommand> m_threadLoadCommands;
BYTE m_tempBuffer[0x4000];
// no public copy constructor
DumpWriter(const DumpWriter&) = delete;
void operator=(const DumpWriter&) = delete;
public:
DumpWriter(CrashInfo& crashInfo);
virtual ~DumpWriter();
bool OpenDump(const char* dumpFileName);
bool WriteDump();
static bool WriteData(int fd, const void* buffer, size_t length);
private:
bool WriteDiagInfo(size_t size);
void BuildSegmentLoadCommands();
void BuildThreadLoadCommands();
bool WriteHeader(uint64_t* pFileOffset);
bool WriteSegments();
bool WriteData(const void* buffer, size_t length) { return WriteData(m_fd, buffer, length); }
};