Adrian McCarthy | c96516f | 2015-08-03 23:01:51 +0000 | [diff] [blame] | 1 | //===-- 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 | |
| 20 | struct ThreadData; |
| 21 | |
| 22 | class ProcessWinMiniDump : public lldb_private::Process |
| 23 | { |
| 24 | public: |
| 25 | static lldb::ProcessSP |
Zachary Turner | 7529df9 | 2015-09-01 20:02:29 +0000 | [diff] [blame] | 26 | CreateInstance (lldb::TargetSP target_sp, |
Adrian McCarthy | c96516f | 2015-08-03 23:01:51 +0000 | [diff] [blame] | 27 | 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 Turner | 7529df9 | 2015-09-01 20:02:29 +0000 | [diff] [blame] | 42 | ProcessWinMiniDump(lldb::TargetSP target_sp, |
Adrian McCarthy | c96516f | 2015-08-03 23:01:51 +0000 | [diff] [blame] | 43 | lldb_private::Listener &listener, |
| 44 | const lldb_private::FileSpec &core_file); |
| 45 | |
| 46 | virtual |
| 47 | ~ProcessWinMiniDump(); |
| 48 | |
| 49 | bool |
Zachary Turner | 7529df9 | 2015-09-01 20:02:29 +0000 | [diff] [blame] | 50 | CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) override; |
Adrian McCarthy | c96516f | 2015-08-03 23:01:51 +0000 | [diff] [blame] | 51 | |
| 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 McCarthy | 6c3d03c | 2015-09-01 16:59:31 +0000 | [diff] [blame] | 73 | bool |
| 74 | WarnBeforeDetach () const override; |
| 75 | |
Adrian McCarthy | c96516f | 2015-08-03 23:01:51 +0000 | [diff] [blame] | 76 | 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 | |
| 88 | protected: |
| 89 | void |
| 90 | Clear(); |
| 91 | |
| 92 | bool |
| 93 | UpdateThreadList(lldb_private::ThreadList &old_thread_list, |
| 94 | lldb_private::ThreadList &new_thread_list) override; |
| 95 | |
| 96 | private: |
Adrian McCarthy | 6c3d03c | 2015-09-01 16:59:31 +0000 | [diff] [blame] | 97 | // 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 McCarthy | c96516f | 2015-08-03 23:01:51 +0000 | [diff] [blame] | 110 | lldb_private::Error |
| 111 | MapMiniDumpIntoMemory(const char *file); |
| 112 | |
| 113 | lldb_private::ArchSpec |
| 114 | DetermineArchitecture(); |
| 115 | |
Adrian McCarthy | 61ede15 | 2015-08-19 20:43:22 +0000 | [diff] [blame] | 116 | void |
| 117 | ReadExceptionRecord(); |
| 118 | |
Adrian McCarthy | 23d14b6 | 2015-08-28 14:42:03 +0000 | [diff] [blame] | 119 | void |
Adrian McCarthy | ab59a0f | 2015-09-17 20:52:29 +0000 | [diff] [blame] | 120 | ReadMiscInfo(); |
| 121 | |
| 122 | void |
Adrian McCarthy | 23d14b6 | 2015-08-28 14:42:03 +0000 | [diff] [blame] | 123 | ReadModuleList(); |
| 124 | |
Adrian McCarthy | 61ede15 | 2015-08-19 20:43:22 +0000 | [diff] [blame] | 125 | // 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 McCarthy | 6c3d03c | 2015-09-01 16:59:31 +0000 | [diff] [blame] | 129 | FindDumpStream(unsigned stream_number, size_t *size_out) const; |
Adrian McCarthy | 61ede15 | 2015-08-19 20:43:22 +0000 | [diff] [blame] | 130 | |
Adrian McCarthy | c96516f | 2015-08-03 23:01:51 +0000 | [diff] [blame] | 131 | // 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_ |