blob: 7555a03c54185c9bb7f7ea8df313156071c90056 [file] [log] [blame]
Adrian McCarthyc96516f2015-08-03 23:01:51 +00001//===-- ProcessWinMiniDump.h ------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef liblldb_ProcessWinMiniDump_h_
11#define liblldb_ProcessWinMiniDump_h_
12
13#include <list>
14#include <vector>
15
16#include "lldb/Core/ConstString.h"
17#include "lldb/Core/Error.h"
18#include "lldb/Target/Process.h"
19
20struct ThreadData;
21
22class ProcessWinMiniDump : public lldb_private::Process
23{
24public:
25 static lldb::ProcessSP
Zachary Turner7529df92015-09-01 20:02:29 +000026 CreateInstance (lldb::TargetSP target_sp,
Adrian McCarthyc96516f2015-08-03 23:01:51 +000027 lldb_private::Listener &listener,
28 const lldb_private::FileSpec *crash_file_path);
29
30 static void
31 Initialize();
32
33 static void
34 Terminate();
35
36 static lldb_private::ConstString
37 GetPluginNameStatic();
38
39 static const char *
40 GetPluginDescriptionStatic();
41
Zachary Turner7529df92015-09-01 20:02:29 +000042 ProcessWinMiniDump(lldb::TargetSP target_sp,
Adrian McCarthyc96516f2015-08-03 23:01:51 +000043 lldb_private::Listener &listener,
44 const lldb_private::FileSpec &core_file);
45
46 virtual
47 ~ProcessWinMiniDump();
48
49 bool
Zachary Turner7529df92015-09-01 20:02:29 +000050 CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) override;
Adrian McCarthyc96516f2015-08-03 23:01:51 +000051
52 lldb_private::Error
53 DoLoadCore() override;
54
55 lldb_private::DynamicLoader *
56 GetDynamicLoader() override;
57
58 lldb_private::ConstString
59 GetPluginName() override;
60
61 uint32_t
62 GetPluginVersion() override;
63
64 lldb_private::Error
65 DoDestroy() override;
66
67 void
68 RefreshStateAfterStop() override;
69
70 bool
71 IsAlive() override;
72
Adrian McCarthy6c3d03c2015-09-01 16:59:31 +000073 bool
74 WarnBeforeDetach () const override;
75
Adrian McCarthyc96516f2015-08-03 23:01:51 +000076 size_t
77 ReadMemory(lldb::addr_t addr, void *buf, size_t size, lldb_private::Error &error) override;
78
79 size_t
80 DoReadMemory(lldb::addr_t addr, void *buf, size_t size, lldb_private::Error &error) override;
81
82 lldb::addr_t
83 GetImageInfoAddress() override;
84
85 lldb_private::ArchSpec
86 GetArchitecture();
87
88protected:
89 void
90 Clear();
91
92 bool
93 UpdateThreadList(lldb_private::ThreadList &old_thread_list,
94 lldb_private::ThreadList &new_thread_list) override;
95
96private:
Adrian McCarthy6c3d03c2015-09-01 16:59:31 +000097 // Describes a range of memory captured in the mini dump.
98 struct Range {
99 lldb::addr_t start; // virtual address of the beginning of the range
100 size_t size; // size of the range in bytes
101 const uint8_t *ptr; // absolute pointer to the first byte of the range
102 };
103
104 // If the mini dump has a memory range that contains the desired address, it
105 // returns true with the details of the range in *range_out. Otherwise, it
106 // returns false.
107 bool
108 FindMemoryRange(lldb::addr_t addr, Range *range_out) const;
109
Adrian McCarthyc96516f2015-08-03 23:01:51 +0000110 lldb_private::Error
111 MapMiniDumpIntoMemory(const char *file);
112
113 lldb_private::ArchSpec
114 DetermineArchitecture();
115
Adrian McCarthy61ede152015-08-19 20:43:22 +0000116 void
117 ReadExceptionRecord();
118
Adrian McCarthy23d14b62015-08-28 14:42:03 +0000119 void
Adrian McCarthyab59a0f2015-09-17 20:52:29 +0000120 ReadMiscInfo();
121
122 void
Adrian McCarthy23d14b62015-08-28 14:42:03 +0000123 ReadModuleList();
124
Adrian McCarthy61ede152015-08-19 20:43:22 +0000125 // A thin wrapper around WinAPI's MiniDumpReadDumpStream to avoid redundant
126 // checks. If there's a failure (e.g., if the requested stream doesn't exist),
127 // the function returns nullptr and sets *size_out to 0.
128 void *
Adrian McCarthy6c3d03c2015-09-01 16:59:31 +0000129 FindDumpStream(unsigned stream_number, size_t *size_out) const;
Adrian McCarthy61ede152015-08-19 20:43:22 +0000130
Adrian McCarthyc96516f2015-08-03 23:01:51 +0000131 // Isolate the data to keep Windows-specific types out of this header. Can't
132 // use the typical pimpl idiom because the implementation of this class also
133 // needs access to public and protected members of the base class.
134 class Data;
135 std::unique_ptr<Data> m_data_up;
136};
137
138#endif // liblldb_ProcessWinMiniDump_h_