blob: a7f35b46946aa8395b71b1e768133d7529757232 [file] [log] [blame]
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +00001//===-- ProcessMinidump.cpp -------------------------------------*- C++ -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +00006//
7//===----------------------------------------------------------------------===//
8
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +00009#include "ProcessMinidump.h"
Jonas Devlieghere796ac802019-02-11 23:13:08 +000010
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +000011#include "ThreadMinidump.h"
12
Greg Clayton48a28c12018-12-18 00:50:11 +000013#include "lldb/Core/DumpDataExtractor.h"
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +000014#include "lldb/Core/Module.h"
15#include "lldb/Core/ModuleSpec.h"
16#include "lldb/Core/PluginManager.h"
17#include "lldb/Core/Section.h"
Greg Clayton48a28c12018-12-18 00:50:11 +000018#include "lldb/Interpreter/CommandInterpreter.h"
19#include "lldb/Interpreter/CommandObject.h"
20#include "lldb/Interpreter/CommandObjectMultiword.h"
21#include "lldb/Interpreter/CommandReturnObject.h"
22#include "lldb/Interpreter/OptionArgParser.h"
23#include "lldb/Interpreter/OptionGroupBoolean.h"
Leonard Mosescu40b832e2018-08-23 21:34:33 +000024#include "lldb/Target/JITLoaderList.h"
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +000025#include "lldb/Target/MemoryRegionInfo.h"
Leonard Mosescu47196a22018-04-18 23:10:46 +000026#include "lldb/Target/SectionLoadList.h"
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +000027#include "lldb/Target/Target.h"
28#include "lldb/Target/UnixSignals.h"
29#include "lldb/Utility/LLDBAssert.h"
Zachary Turner6f9e6902017-03-03 20:56:28 +000030#include "lldb/Utility/Log.h"
Pavel Labathd821c992018-08-07 11:07:21 +000031#include "lldb/Utility/State.h"
Pavel Labathf2ffb472019-03-26 13:23:01 +000032#include "llvm/BinaryFormat/Magic.h"
Zachary Turner3f4a4b32017-02-24 18:56:49 +000033#include "llvm/Support/MemoryBuffer.h"
Kamil Rytarowskic5f28e22017-02-06 17:55:02 +000034#include "llvm/Support/Threading.h"
35
Greg Clayton19c8f392018-08-06 16:56:10 +000036#include "Plugins/Process/Utility/StopInfoMachException.h"
Leonard Mosescu0d057902019-01-07 17:55:42 +000037
Jonas Devlieghere796ac802019-02-11 23:13:08 +000038#include <memory>
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +000039
Leonard Mosescu47196a22018-04-18 23:10:46 +000040using namespace lldb;
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +000041using namespace lldb_private;
42using namespace minidump;
43
Pavel Labathee7ceac2019-03-27 10:54:10 +000044namespace {
45
46/// A minimal ObjectFile implementation providing a dummy object file for the
47/// cases when the real module binary is not available. This allows the module
48/// to show up in "image list" and symbols to be added to it.
49class PlaceholderObjectFile : public ObjectFile {
Leonard Mosescu47196a22018-04-18 23:10:46 +000050public:
Pavel Labathee7ceac2019-03-27 10:54:10 +000051 PlaceholderObjectFile(const lldb::ModuleSP &module_sp,
52 const ModuleSpec &module_spec, lldb::offset_t base,
53 lldb::offset_t size)
54 : ObjectFile(module_sp, &module_spec.GetFileSpec(), /*file_offset*/ 0,
55 /*length*/ 0, /*data_sp*/ nullptr, /*data_offset*/ 0),
56 m_arch(module_spec.GetArchitecture()), m_uuid(module_spec.GetUUID()),
57 m_base(base), m_size(size) {
58 m_symtab_up = llvm::make_unique<Symtab>(this);
Leonard Mosescu9fecd372018-05-02 20:06:17 +000059 }
Leonard Mosescu47196a22018-04-18 23:10:46 +000060
Pavel Labathee7ceac2019-03-27 10:54:10 +000061 ConstString GetPluginName() override { return ConstString("placeholder"); }
62 uint32_t GetPluginVersion() override { return 1; }
63 bool ParseHeader() override { return true; }
64 Type CalculateType() override { return eTypeUnknown; }
65 Strata CalculateStrata() override { return eStrataUnknown; }
66 uint32_t GetDependentModules(FileSpecList &file_list) override { return 0; }
67 bool IsExecutable() const override { return false; }
68 ArchSpec GetArchitecture() override { return m_arch; }
69 UUID GetUUID() override { return m_uuid; }
70 Symtab *GetSymtab() override { return m_symtab_up.get(); }
71 bool IsStripped() override { return true; }
72 ByteOrder GetByteOrder() const override { return m_arch.GetByteOrder(); }
73
74 uint32_t GetAddressByteSize() const override {
75 return m_arch.GetAddressByteSize();
76 }
77
78 Address GetBaseAddress() override {
79 return Address(m_sections_up->GetSectionAtIndex(0), 0);
80 }
81
82 void CreateSections(SectionList &unified_section_list) override {
83 m_sections_up = llvm::make_unique<SectionList>();
84 auto section_sp = std::make_shared<Section>(
85 GetModule(), this, /*sect_id*/ 0, ConstString(".module_image"),
86 eSectionTypeOther, m_base, m_size, /*file_offset*/ 0, /*file_size*/ 0,
87 /*log2align*/ 0, /*flags*/ 0);
88 section_sp->SetPermissions(ePermissionsReadable | ePermissionsExecutable);
89 m_sections_up->AddSection(section_sp);
90 unified_section_list.AddSection(std::move(section_sp));
91 }
92
93 bool SetLoadAddress(Target &target, addr_t value,
94 bool value_is_offset) override {
95 assert(!value_is_offset);
96 assert(value == m_base);
97
98 // Create sections if they haven't been created already.
99 GetModule()->GetSectionList();
100 assert(m_sections_up->GetNumSections(0) == 1);
101
Leonard Mosescu47196a22018-04-18 23:10:46 +0000102 target.GetSectionLoadList().SetSectionLoadAddress(
Pavel Labathee7ceac2019-03-27 10:54:10 +0000103 m_sections_up->GetSectionAtIndex(0), m_base);
104 return true;
Leonard Mosescu47196a22018-04-18 23:10:46 +0000105 }
106
Pavel Labathee7ceac2019-03-27 10:54:10 +0000107 void Dump(Stream *s) override {
108 s->Format("Placeholder object file for {0} loaded at [{1:x}-{2:x})\n",
109 GetFileSpec(), m_base, m_base + m_size);
Pavel Labath95e29762019-02-19 13:52:31 +0000110 }
Pavel Labathee7ceac2019-03-27 10:54:10 +0000111
112private:
113 ArchSpec m_arch;
114 UUID m_uuid;
115 lldb::offset_t m_base;
116 lldb::offset_t m_size;
Leonard Mosescu47196a22018-04-18 23:10:46 +0000117};
Pavel Labathee7ceac2019-03-27 10:54:10 +0000118} // namespace
Leonard Mosescu47196a22018-04-18 23:10:46 +0000119
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000120ConstString ProcessMinidump::GetPluginNameStatic() {
121 static ConstString g_name("minidump");
122 return g_name;
123}
124
125const char *ProcessMinidump::GetPluginDescriptionStatic() {
126 return "Minidump plug-in.";
127}
128
129lldb::ProcessSP ProcessMinidump::CreateInstance(lldb::TargetSP target_sp,
130 lldb::ListenerSP listener_sp,
131 const FileSpec *crash_file) {
132 if (!crash_file)
133 return nullptr;
134
135 lldb::ProcessSP process_sp;
136 // Read enough data for the Minidump header
Pavel Labathf2ffb472019-03-26 13:23:01 +0000137 constexpr size_t header_size = sizeof(Header);
Jonas Devlieghere87e403a2018-11-12 21:24:50 +0000138 auto DataPtr = FileSystem::Instance().CreateDataBuffer(crash_file->GetPath(),
139 header_size, 0);
Zachary Turner3f4a4b32017-02-24 18:56:49 +0000140 if (!DataPtr)
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000141 return nullptr;
142
Leonard Mosescu2ae3ec32018-07-12 17:27:18 +0000143 lldbassert(DataPtr->GetByteSize() == header_size);
Pavel Labathf2ffb472019-03-26 13:23:01 +0000144 if (identify_magic(toStringRef(DataPtr->GetData())) != llvm::file_magic::minidump)
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000145 return nullptr;
146
Jonas Devlieghere87e403a2018-11-12 21:24:50 +0000147 auto AllData =
148 FileSystem::Instance().CreateDataBuffer(crash_file->GetPath(), -1, 0);
Zachary Turner3f4a4b32017-02-24 18:56:49 +0000149 if (!AllData)
150 return nullptr;
151
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000152 return std::make_shared<ProcessMinidump>(target_sp, listener_sp, *crash_file,
Pavel Labathab86d3d2019-02-22 13:36:01 +0000153 std::move(AllData));
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000154}
155
156bool ProcessMinidump::CanDebug(lldb::TargetSP target_sp,
157 bool plugin_specified_by_name) {
158 return true;
159}
160
161ProcessMinidump::ProcessMinidump(lldb::TargetSP target_sp,
162 lldb::ListenerSP listener_sp,
163 const FileSpec &core_file,
Pavel Labathab86d3d2019-02-22 13:36:01 +0000164 DataBufferSP core_data)
165 : Process(target_sp, listener_sp), m_core_file(core_file),
166 m_core_data(std::move(core_data)), m_is_wow64(false) {}
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000167
168ProcessMinidump::~ProcessMinidump() {
169 Clear();
Adrian Prantl05097242018-04-30 16:49:04 +0000170 // We need to call finalize on the process before destroying ourselves to
171 // make sure all of the broadcaster cleanup goes as planned. If we destruct
172 // this class, then Process::~Process() might have problems trying to fully
173 // destroy the broadcaster.
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000174 Finalize();
175}
176
177void ProcessMinidump::Initialize() {
Kamil Rytarowskic5f28e22017-02-06 17:55:02 +0000178 static llvm::once_flag g_once_flag;
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000179
Kamil Rytarowskic5f28e22017-02-06 17:55:02 +0000180 llvm::call_once(g_once_flag, []() {
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000181 PluginManager::RegisterPlugin(GetPluginNameStatic(),
182 GetPluginDescriptionStatic(),
183 ProcessMinidump::CreateInstance);
184 });
185}
186
187void ProcessMinidump::Terminate() {
188 PluginManager::UnregisterPlugin(ProcessMinidump::CreateInstance);
189}
190
Zachary Turner97206d52017-05-12 04:51:55 +0000191Status ProcessMinidump::DoLoadCore() {
Pavel Labathab86d3d2019-02-22 13:36:01 +0000192 auto expected_parser = MinidumpParser::Create(m_core_data);
193 if (!expected_parser)
194 return Status(expected_parser.takeError());
195 m_minidump_parser = std::move(*expected_parser);
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000196
Pavel Labathab86d3d2019-02-22 13:36:01 +0000197 Status error;
Leonard Mosescu2ae3ec32018-07-12 17:27:18 +0000198
199 // Do we support the minidump's architecture?
200 ArchSpec arch = GetArchitecture();
201 switch (arch.GetMachine()) {
202 case llvm::Triple::x86:
203 case llvm::Triple::x86_64:
Greg Clayton19c8f392018-08-06 16:56:10 +0000204 case llvm::Triple::arm:
205 case llvm::Triple::aarch64:
206 // Any supported architectures must be listed here and also supported in
207 // ThreadMinidump::CreateRegisterContextForFrame().
Leonard Mosescu2ae3ec32018-07-12 17:27:18 +0000208 break;
Leonard Mosescu2ae3ec32018-07-12 17:27:18 +0000209 default:
210 error.SetErrorStringWithFormat("unsupported minidump architecture: %s",
211 arch.GetArchitectureName());
212 return error;
213 }
Greg Clayton19c8f392018-08-06 16:56:10 +0000214 GetTarget().SetArchitecture(arch, true /*set_platform*/);
Leonard Mosescu2ae3ec32018-07-12 17:27:18 +0000215
Pavel Labathab86d3d2019-02-22 13:36:01 +0000216 m_thread_list = m_minidump_parser->GetThreads();
217 m_active_exception = m_minidump_parser->GetExceptionStream();
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000218 ReadModuleList();
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000219
Pavel Labathab86d3d2019-02-22 13:36:01 +0000220 llvm::Optional<lldb::pid_t> pid = m_minidump_parser->GetPid();
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000221 if (!pid) {
222 error.SetErrorString("failed to parse PID");
223 return error;
224 }
225 SetID(pid.getValue());
226
227 return error;
228}
229
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000230ConstString ProcessMinidump::GetPluginName() { return GetPluginNameStatic(); }
231
232uint32_t ProcessMinidump::GetPluginVersion() { return 1; }
233
Zachary Turner97206d52017-05-12 04:51:55 +0000234Status ProcessMinidump::DoDestroy() { return Status(); }
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000235
236void ProcessMinidump::RefreshStateAfterStop() {
237 if (!m_active_exception)
238 return;
239
240 if (m_active_exception->exception_record.exception_code ==
241 MinidumpException::DumpRequested) {
242 return;
243 }
244
245 lldb::StopInfoSP stop_info;
246 lldb::ThreadSP stop_thread;
247
248 Process::m_thread_list.SetSelectedThreadByID(m_active_exception->thread_id);
249 stop_thread = Process::m_thread_list.GetSelectedThread();
250 ArchSpec arch = GetArchitecture();
251
252 if (arch.GetTriple().getOS() == llvm::Triple::Linux) {
253 stop_info = StopInfo::CreateStopReasonWithSignal(
254 *stop_thread, m_active_exception->exception_record.exception_code);
Greg Clayton19c8f392018-08-06 16:56:10 +0000255 } else if (arch.GetTriple().getVendor() == llvm::Triple::Apple) {
256 stop_info = StopInfoMachException::CreateStopReasonWithMachException(
257 *stop_thread, m_active_exception->exception_record.exception_code, 2,
258 m_active_exception->exception_record.exception_flags,
259 m_active_exception->exception_record.exception_address, 0);
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000260 } else {
261 std::string desc;
262 llvm::raw_string_ostream desc_stream(desc);
263 desc_stream << "Exception "
264 << llvm::format_hex(
265 m_active_exception->exception_record.exception_code, 8)
266 << " encountered at address "
267 << llvm::format_hex(
268 m_active_exception->exception_record.exception_address,
269 8);
270 stop_info = StopInfo::CreateStopReasonWithException(
271 *stop_thread, desc_stream.str().c_str());
272 }
273
274 stop_thread->SetStopInfo(stop_info);
275}
276
277bool ProcessMinidump::IsAlive() { return true; }
278
279bool ProcessMinidump::WarnBeforeDetach() const { return false; }
280
281size_t ProcessMinidump::ReadMemory(lldb::addr_t addr, void *buf, size_t size,
Zachary Turner97206d52017-05-12 04:51:55 +0000282 Status &error) {
Adrian Prantl05097242018-04-30 16:49:04 +0000283 // Don't allow the caching that lldb_private::Process::ReadMemory does since
284 // we have it all cached in our dump file anyway.
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000285 return DoReadMemory(addr, buf, size, error);
286}
287
288size_t ProcessMinidump::DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
Zachary Turner97206d52017-05-12 04:51:55 +0000289 Status &error) {
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000290
Pavel Labathab86d3d2019-02-22 13:36:01 +0000291 llvm::ArrayRef<uint8_t> mem = m_minidump_parser->GetMemory(addr, size);
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000292 if (mem.empty()) {
293 error.SetErrorString("could not parse memory info");
294 return 0;
295 }
296
297 std::memcpy(buf, mem.data(), mem.size());
298 return mem.size();
299}
300
301ArchSpec ProcessMinidump::GetArchitecture() {
302 if (!m_is_wow64) {
Pavel Labathab86d3d2019-02-22 13:36:01 +0000303 return m_minidump_parser->GetArchitecture();
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000304 }
305
306 llvm::Triple triple;
307 triple.setVendor(llvm::Triple::VendorType::UnknownVendor);
308 triple.setArch(llvm::Triple::ArchType::x86);
309 triple.setOS(llvm::Triple::OSType::Win32);
310 return ArchSpec(triple);
311}
312
Zachary Turner97206d52017-05-12 04:51:55 +0000313Status ProcessMinidump::GetMemoryRegionInfo(lldb::addr_t load_addr,
314 MemoryRegionInfo &range_info) {
Pavel Labathab86d3d2019-02-22 13:36:01 +0000315 range_info = m_minidump_parser->GetMemoryRegionInfo(load_addr);
Greg Clayton026e1bf2018-12-14 19:36:01 +0000316 return Status();
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000317}
318
Tatyana Krasnukha92e5e362018-12-20 15:05:43 +0000319Status ProcessMinidump::GetMemoryRegions(
320 lldb_private::MemoryRegionInfos &region_list) {
Pavel Labathab86d3d2019-02-22 13:36:01 +0000321 region_list = m_minidump_parser->GetMemoryRegions();
Tatyana Krasnukha92e5e362018-12-20 15:05:43 +0000322 return Status();
323}
324
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000325void ProcessMinidump::Clear() { Process::m_thread_list.Clear(); }
326
Dimitar Vlahovski5a19c0c2016-11-01 15:48:24 +0000327bool ProcessMinidump::UpdateThreadList(ThreadList &old_thread_list,
328 ThreadList &new_thread_list) {
Leonard Mosescu0d057902019-01-07 17:55:42 +0000329 for (const MinidumpThread& thread : m_thread_list) {
Pavel Labathf2ffb472019-03-26 13:23:01 +0000330 LocationDescriptor context_location = thread.thread_context;
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000331
Leonard Mosescu0d057902019-01-07 17:55:42 +0000332 // If the minidump contains an exception context, use it
333 if (m_active_exception != nullptr &&
334 m_active_exception->thread_id == thread.thread_id) {
335 context_location = m_active_exception->thread_context;
336 }
337
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000338 llvm::ArrayRef<uint8_t> context;
339 if (!m_is_wow64)
Pavel Labathab86d3d2019-02-22 13:36:01 +0000340 context = m_minidump_parser->GetThreadContext(context_location);
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000341 else
Pavel Labathab86d3d2019-02-22 13:36:01 +0000342 context = m_minidump_parser->GetThreadContextWow64(thread);
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000343
Leonard Mosescu0d057902019-01-07 17:55:42 +0000344 lldb::ThreadSP thread_sp(new ThreadMinidump(*this, thread, context));
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000345 new_thread_list.AddThread(thread_sp);
346 }
347 return new_thread_list.GetSize(false) > 0;
348}
349
350void ProcessMinidump::ReadModuleList() {
351 std::vector<const MinidumpModule *> filtered_modules =
Pavel Labathab86d3d2019-02-22 13:36:01 +0000352 m_minidump_parser->GetFilteredModuleList();
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000353
354 for (auto module : filtered_modules) {
355 llvm::Optional<std::string> name =
Pavel Labathab86d3d2019-02-22 13:36:01 +0000356 m_minidump_parser->GetMinidumpString(module->module_name_rva);
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000357
358 if (!name)
359 continue;
360
Adrian Prantl1b5310c2019-04-02 22:03:22 +0000361 Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_MODULES));
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000362 if (log) {
Pavel Labatheaa419c2016-11-02 10:29:47 +0000363 log->Printf("ProcessMinidump::%s found module: name: %s %#010" PRIx64
364 "-%#010" PRIx64 " size: %" PRIu32,
365 __FUNCTION__, name.getValue().c_str(),
366 uint64_t(module->base_of_image),
367 module->base_of_image + module->size_of_image,
368 uint32_t(module->size_of_image));
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000369 }
370
371 // check if the process is wow64 - a 32 bit windows process running on a
372 // 64 bit windows
373 if (llvm::StringRef(name.getValue()).endswith_lower("wow64.dll")) {
374 m_is_wow64 = true;
375 }
376
Pavel Labathab86d3d2019-02-22 13:36:01 +0000377 const auto uuid = m_minidump_parser->GetModuleUUID(module);
Jonas Devlieghere8f3be7a2018-11-01 21:05:36 +0000378 auto file_spec = FileSpec(name.getValue(), GetArchitecture().GetTriple());
379 FileSystem::Instance().Resolve(file_spec);
Leonard Mosescu9fecd372018-05-02 20:06:17 +0000380 ModuleSpec module_spec(file_spec, uuid);
Pavel Labathee7ceac2019-03-27 10:54:10 +0000381 module_spec.GetArchitecture() = GetArchitecture();
Zachary Turner97206d52017-05-12 04:51:55 +0000382 Status error;
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000383 lldb::ModuleSP module_sp = GetTarget().GetSharedModule(module_spec, &error);
Adrian Prantl1b5310c2019-04-02 22:03:22 +0000384 if (!module_sp || error.Fail()) {
Adrian Prantl05097242018-04-30 16:49:04 +0000385 // We failed to locate a matching local object file. Fortunately, the
386 // minidump format encodes enough information about each module's memory
387 // range to allow us to create placeholder modules.
Leonard Mosescu47196a22018-04-18 23:10:46 +0000388 //
389 // This enables most LLDB functionality involving address-to-module
390 // translations (ex. identifing the module for a stack frame PC) and
391 // modules/sections commands (ex. target modules list, ...)
Leonard Mosescu9ba51572018-08-07 18:00:30 +0000392 if (log) {
393 log->Printf("Unable to locate the matching object file, creating a "
394 "placeholder module for: %s",
395 name.getValue().c_str());
396 }
397
Pavel Labathee7ceac2019-03-27 10:54:10 +0000398 module_sp = Module::CreateModuleFromObjectFile<PlaceholderObjectFile>(
399 module_spec, module->base_of_image, module->size_of_image);
Leonard Mosescu47196a22018-04-18 23:10:46 +0000400 GetTarget().GetImages().Append(module_sp);
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000401 }
402
Adrian Prantl1b5310c2019-04-02 22:03:22 +0000403 if (log) {
404 log->Printf("ProcessMinidump::%s load module: name: %s", __FUNCTION__,
405 name.getValue().c_str());
406 }
407
Dimitar Vlahovski7b18dd42016-10-31 15:35:18 +0000408 bool load_addr_changed = false;
409 module_sp->SetLoadAddress(GetTarget(), module->base_of_image, false,
410 load_addr_changed);
411 }
412}
Dimitar Vlahovski5a19c0c2016-11-01 15:48:24 +0000413
414bool ProcessMinidump::GetProcessInfo(ProcessInstanceInfo &info) {
415 info.Clear();
416 info.SetProcessID(GetID());
417 info.SetArchitecture(GetArchitecture());
418 lldb::ModuleSP module_sp = GetTarget().GetExecutableModule();
419 if (module_sp) {
420 const bool add_exe_file_as_first_arg = false;
421 info.SetExecutableFile(GetTarget().GetExecutableModule()->GetFileSpec(),
422 add_exe_file_as_first_arg);
423 }
424 return true;
425}
Leonard Mosescu40b832e2018-08-23 21:34:33 +0000426
427// For minidumps there's no runtime generated code so we don't need JITLoader(s)
428// Avoiding them will also speed up minidump loading since JITLoaders normally
429// try to set up symbolic breakpoints, which in turn may force loading more
430// debug information than needed.
431JITLoaderList &ProcessMinidump::GetJITLoaders() {
Jonas Devlieghered5b44032019-02-13 06:25:41 +0000432 if (!m_jit_loaders_up) {
433 m_jit_loaders_up = llvm::make_unique<JITLoaderList>();
Leonard Mosescu40b832e2018-08-23 21:34:33 +0000434 }
Jonas Devlieghered5b44032019-02-13 06:25:41 +0000435 return *m_jit_loaders_up;
Leonard Mosescu40b832e2018-08-23 21:34:33 +0000436}
Greg Clayton48a28c12018-12-18 00:50:11 +0000437
438#define INIT_BOOL(VAR, LONG, SHORT, DESC) \
439 VAR(LLDB_OPT_SET_1, false, LONG, SHORT, DESC, false, true)
440#define APPEND_OPT(VAR) \
441 m_option_group.Append(&VAR, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1)
442
443class CommandObjectProcessMinidumpDump : public CommandObjectParsed {
444private:
445 OptionGroupOptions m_option_group;
446 OptionGroupBoolean m_dump_all;
447 OptionGroupBoolean m_dump_directory;
448 OptionGroupBoolean m_dump_linux_cpuinfo;
449 OptionGroupBoolean m_dump_linux_proc_status;
450 OptionGroupBoolean m_dump_linux_lsb_release;
451 OptionGroupBoolean m_dump_linux_cmdline;
452 OptionGroupBoolean m_dump_linux_environ;
453 OptionGroupBoolean m_dump_linux_auxv;
454 OptionGroupBoolean m_dump_linux_maps;
455 OptionGroupBoolean m_dump_linux_proc_stat;
456 OptionGroupBoolean m_dump_linux_proc_uptime;
457 OptionGroupBoolean m_dump_linux_proc_fd;
458 OptionGroupBoolean m_dump_linux_all;
Greg Claytoncc6ec692019-02-19 21:48:34 +0000459 OptionGroupBoolean m_fb_app_data;
460 OptionGroupBoolean m_fb_build_id;
461 OptionGroupBoolean m_fb_version;
462 OptionGroupBoolean m_fb_java_stack;
463 OptionGroupBoolean m_fb_dalvik;
464 OptionGroupBoolean m_fb_unwind;
465 OptionGroupBoolean m_fb_error_log;
466 OptionGroupBoolean m_fb_app_state;
467 OptionGroupBoolean m_fb_abort;
468 OptionGroupBoolean m_fb_thread;
469 OptionGroupBoolean m_fb_logcat;
470 OptionGroupBoolean m_fb_all;
Greg Clayton48a28c12018-12-18 00:50:11 +0000471
472 void SetDefaultOptionsIfNoneAreSet() {
473 if (m_dump_all.GetOptionValue().GetCurrentValue() ||
474 m_dump_linux_all.GetOptionValue().GetCurrentValue() ||
Greg Claytoncc6ec692019-02-19 21:48:34 +0000475 m_fb_all.GetOptionValue().GetCurrentValue() ||
Greg Clayton48a28c12018-12-18 00:50:11 +0000476 m_dump_directory.GetOptionValue().GetCurrentValue() ||
477 m_dump_linux_cpuinfo.GetOptionValue().GetCurrentValue() ||
478 m_dump_linux_proc_status.GetOptionValue().GetCurrentValue() ||
479 m_dump_linux_lsb_release.GetOptionValue().GetCurrentValue() ||
480 m_dump_linux_cmdline.GetOptionValue().GetCurrentValue() ||
481 m_dump_linux_environ.GetOptionValue().GetCurrentValue() ||
482 m_dump_linux_auxv.GetOptionValue().GetCurrentValue() ||
483 m_dump_linux_maps.GetOptionValue().GetCurrentValue() ||
484 m_dump_linux_proc_stat.GetOptionValue().GetCurrentValue() ||
485 m_dump_linux_proc_uptime.GetOptionValue().GetCurrentValue() ||
Greg Claytoncc6ec692019-02-19 21:48:34 +0000486 m_dump_linux_proc_fd.GetOptionValue().GetCurrentValue() ||
487 m_fb_app_data.GetOptionValue().GetCurrentValue() ||
488 m_fb_build_id.GetOptionValue().GetCurrentValue() ||
489 m_fb_version.GetOptionValue().GetCurrentValue() ||
490 m_fb_java_stack.GetOptionValue().GetCurrentValue() ||
491 m_fb_dalvik.GetOptionValue().GetCurrentValue() ||
492 m_fb_unwind.GetOptionValue().GetCurrentValue() ||
493 m_fb_error_log.GetOptionValue().GetCurrentValue() ||
494 m_fb_app_state.GetOptionValue().GetCurrentValue() ||
495 m_fb_abort.GetOptionValue().GetCurrentValue() ||
496 m_fb_thread.GetOptionValue().GetCurrentValue() ||
497 m_fb_logcat.GetOptionValue().GetCurrentValue())
Greg Clayton48a28c12018-12-18 00:50:11 +0000498 return;
499 // If no options were set, then dump everything
500 m_dump_all.GetOptionValue().SetCurrentValue(true);
501 }
502 bool DumpAll() const {
503 return m_dump_all.GetOptionValue().GetCurrentValue();
504 }
505 bool DumpDirectory() const {
506 return DumpAll() ||
507 m_dump_directory.GetOptionValue().GetCurrentValue();
508 }
509 bool DumpLinux() const {
510 return DumpAll() || m_dump_linux_all.GetOptionValue().GetCurrentValue();
511 }
512 bool DumpLinuxCPUInfo() const {
513 return DumpLinux() ||
514 m_dump_linux_cpuinfo.GetOptionValue().GetCurrentValue();
515 }
516 bool DumpLinuxProcStatus() const {
517 return DumpLinux() ||
518 m_dump_linux_proc_status.GetOptionValue().GetCurrentValue();
519 }
520 bool DumpLinuxProcStat() const {
521 return DumpLinux() ||
522 m_dump_linux_proc_stat.GetOptionValue().GetCurrentValue();
523 }
524 bool DumpLinuxLSBRelease() const {
525 return DumpLinux() ||
526 m_dump_linux_lsb_release.GetOptionValue().GetCurrentValue();
527 }
528 bool DumpLinuxCMDLine() const {
529 return DumpLinux() ||
530 m_dump_linux_cmdline.GetOptionValue().GetCurrentValue();
531 }
532 bool DumpLinuxEnviron() const {
533 return DumpLinux() ||
534 m_dump_linux_environ.GetOptionValue().GetCurrentValue();
535 }
536 bool DumpLinuxAuxv() const {
537 return DumpLinux() ||
538 m_dump_linux_auxv.GetOptionValue().GetCurrentValue();
539 }
540 bool DumpLinuxMaps() const {
541 return DumpLinux() ||
542 m_dump_linux_maps.GetOptionValue().GetCurrentValue();
543 }
544 bool DumpLinuxProcUptime() const {
545 return DumpLinux() ||
546 m_dump_linux_proc_uptime.GetOptionValue().GetCurrentValue();
547 }
548 bool DumpLinuxProcFD() const {
549 return DumpLinux() ||
550 m_dump_linux_proc_fd.GetOptionValue().GetCurrentValue();
551 }
Greg Claytoncc6ec692019-02-19 21:48:34 +0000552 bool DumpFacebook() const {
553 return DumpAll() || m_fb_all.GetOptionValue().GetCurrentValue();
554 }
555 bool DumpFacebookAppData() const {
556 return DumpFacebook() || m_fb_app_data.GetOptionValue().GetCurrentValue();
557 }
558 bool DumpFacebookBuildID() const {
559 return DumpFacebook() || m_fb_build_id.GetOptionValue().GetCurrentValue();
560 }
561 bool DumpFacebookVersionName() const {
562 return DumpFacebook() || m_fb_version.GetOptionValue().GetCurrentValue();
563 }
564 bool DumpFacebookJavaStack() const {
565 return DumpFacebook() || m_fb_java_stack.GetOptionValue().GetCurrentValue();
566 }
567 bool DumpFacebookDalvikInfo() const {
568 return DumpFacebook() || m_fb_dalvik.GetOptionValue().GetCurrentValue();
569 }
570 bool DumpFacebookUnwindSymbols() const {
571 return DumpFacebook() || m_fb_unwind.GetOptionValue().GetCurrentValue();
572 }
573 bool DumpFacebookErrorLog() const {
574 return DumpFacebook() || m_fb_error_log.GetOptionValue().GetCurrentValue();
575 }
576 bool DumpFacebookAppStateLog() const {
577 return DumpFacebook() || m_fb_app_state.GetOptionValue().GetCurrentValue();
578 }
579 bool DumpFacebookAbortReason() const {
580 return DumpFacebook() || m_fb_abort.GetOptionValue().GetCurrentValue();
581 }
582 bool DumpFacebookThreadName() const {
583 return DumpFacebook() || m_fb_thread.GetOptionValue().GetCurrentValue();
584 }
585 bool DumpFacebookLogcat() const {
586 return DumpFacebook() || m_fb_logcat.GetOptionValue().GetCurrentValue();
587 }
Greg Clayton48a28c12018-12-18 00:50:11 +0000588public:
589
590 CommandObjectProcessMinidumpDump(CommandInterpreter &interpreter)
591 : CommandObjectParsed(interpreter, "process plugin dump",
592 "Dump information from the minidump file.", NULL),
593 m_option_group(),
594 INIT_BOOL(m_dump_all, "all", 'a',
595 "Dump the everything in the minidump."),
596 INIT_BOOL(m_dump_directory, "directory", 'd',
597 "Dump the minidump directory map."),
598 INIT_BOOL(m_dump_linux_cpuinfo, "cpuinfo", 'C',
599 "Dump linux /proc/cpuinfo."),
600 INIT_BOOL(m_dump_linux_proc_status, "status", 's',
601 "Dump linux /proc/<pid>/status."),
602 INIT_BOOL(m_dump_linux_lsb_release, "lsb-release", 'r',
603 "Dump linux /etc/lsb-release."),
604 INIT_BOOL(m_dump_linux_cmdline, "cmdline", 'c',
605 "Dump linux /proc/<pid>/cmdline."),
606 INIT_BOOL(m_dump_linux_environ, "environ", 'e',
607 "Dump linux /proc/<pid>/environ."),
608 INIT_BOOL(m_dump_linux_auxv, "auxv", 'x',
609 "Dump linux /proc/<pid>/auxv."),
610 INIT_BOOL(m_dump_linux_maps, "maps", 'm',
611 "Dump linux /proc/<pid>/maps."),
612 INIT_BOOL(m_dump_linux_proc_stat, "stat", 'S',
613 "Dump linux /proc/<pid>/stat."),
614 INIT_BOOL(m_dump_linux_proc_uptime, "uptime", 'u',
615 "Dump linux process uptime."),
616 INIT_BOOL(m_dump_linux_proc_fd, "fd", 'f',
617 "Dump linux /proc/<pid>/fd."),
618 INIT_BOOL(m_dump_linux_all, "linux", 'l',
Greg Claytoncc6ec692019-02-19 21:48:34 +0000619 "Dump all linux streams."),
620 INIT_BOOL(m_fb_app_data, "fb-app-data", 1,
621 "Dump Facebook application custom data."),
622 INIT_BOOL(m_fb_build_id, "fb-build-id", 2,
623 "Dump the Facebook build ID."),
624 INIT_BOOL(m_fb_version, "fb-version", 3,
625 "Dump Facebook application version string."),
626 INIT_BOOL(m_fb_java_stack, "fb-java-stack", 4,
627 "Dump Facebook java stack."),
628 INIT_BOOL(m_fb_dalvik, "fb-dalvik-info", 5,
629 "Dump Facebook Dalvik info."),
630 INIT_BOOL(m_fb_unwind, "fb-unwind-symbols", 6,
631 "Dump Facebook unwind symbols."),
632 INIT_BOOL(m_fb_error_log, "fb-error-log", 7,
633 "Dump Facebook error log."),
634 INIT_BOOL(m_fb_app_state, "fb-app-state-log", 8,
635 "Dump Facebook java stack."),
636 INIT_BOOL(m_fb_abort, "fb-abort-reason", 9,
637 "Dump Facebook abort reason."),
638 INIT_BOOL(m_fb_thread, "fb-thread-name", 10,
639 "Dump Facebook thread name."),
640 INIT_BOOL(m_fb_logcat, "fb-logcat", 11,
641 "Dump Facebook logcat."),
642 INIT_BOOL(m_fb_all, "facebook", 12, "Dump all Facebook streams.") {
Greg Clayton48a28c12018-12-18 00:50:11 +0000643 APPEND_OPT(m_dump_all);
644 APPEND_OPT(m_dump_directory);
645 APPEND_OPT(m_dump_linux_cpuinfo);
646 APPEND_OPT(m_dump_linux_proc_status);
647 APPEND_OPT(m_dump_linux_lsb_release);
648 APPEND_OPT(m_dump_linux_cmdline);
649 APPEND_OPT(m_dump_linux_environ);
650 APPEND_OPT(m_dump_linux_auxv);
651 APPEND_OPT(m_dump_linux_maps);
652 APPEND_OPT(m_dump_linux_proc_stat);
653 APPEND_OPT(m_dump_linux_proc_uptime);
654 APPEND_OPT(m_dump_linux_proc_fd);
655 APPEND_OPT(m_dump_linux_all);
Greg Claytoncc6ec692019-02-19 21:48:34 +0000656 APPEND_OPT(m_fb_app_data);
657 APPEND_OPT(m_fb_build_id);
658 APPEND_OPT(m_fb_version);
659 APPEND_OPT(m_fb_java_stack);
660 APPEND_OPT(m_fb_dalvik);
661 APPEND_OPT(m_fb_unwind);
662 APPEND_OPT(m_fb_error_log);
663 APPEND_OPT(m_fb_app_state);
664 APPEND_OPT(m_fb_abort);
665 APPEND_OPT(m_fb_thread);
666 APPEND_OPT(m_fb_logcat);
667 APPEND_OPT(m_fb_all);
Greg Clayton48a28c12018-12-18 00:50:11 +0000668 m_option_group.Finalize();
669 }
Leonard Mosescu0d057902019-01-07 17:55:42 +0000670
Greg Clayton48a28c12018-12-18 00:50:11 +0000671 ~CommandObjectProcessMinidumpDump() {}
Leonard Mosescu0d057902019-01-07 17:55:42 +0000672
Greg Clayton48a28c12018-12-18 00:50:11 +0000673 Options *GetOptions() override { return &m_option_group; }
674
675 bool DoExecute(Args &command, CommandReturnObject &result) override {
676 const size_t argc = command.GetArgumentCount();
677 if (argc > 0) {
678 result.AppendErrorWithFormat("'%s' take no arguments, only options",
679 m_cmd_name.c_str());
680 result.SetStatus(eReturnStatusFailed);
681 return false;
682 }
683 SetDefaultOptionsIfNoneAreSet();
Leonard Mosescu0d057902019-01-07 17:55:42 +0000684
Greg Clayton48a28c12018-12-18 00:50:11 +0000685 ProcessMinidump *process = static_cast<ProcessMinidump *>(
686 m_interpreter.GetExecutionContext().GetProcessPtr());
687 result.SetStatus(eReturnStatusSuccessFinishResult);
688 Stream &s = result.GetOutputStream();
Pavel Labathab86d3d2019-02-22 13:36:01 +0000689 MinidumpParser &minidump = *process->m_minidump_parser;
Greg Clayton48a28c12018-12-18 00:50:11 +0000690 if (DumpDirectory()) {
Pavel Labathd2b48882019-03-25 14:09:27 +0000691 s.Printf("RVA SIZE TYPE StreamType\n");
Greg Clayton48a28c12018-12-18 00:50:11 +0000692 s.Printf("---------- ---------- ---------- --------------------------\n");
693 for (const auto &pair: minidump.GetDirectoryMap())
Pavel Labathf2ffb472019-03-26 13:23:01 +0000694 s.Printf("0x%8.8x 0x%8.8x 0x%8.8x %s\n", (uint32_t)pair.second.RVA,
695 (uint32_t)pair.second.DataSize, (unsigned)pair.first,
Greg Clayton48a28c12018-12-18 00:50:11 +0000696 MinidumpParser::GetStreamTypeAsString(pair.first).data());
697 s.Printf("\n");
698 }
Pavel Labathd2b48882019-03-25 14:09:27 +0000699 auto DumpTextStream = [&](StreamType stream_type,
Pavel Labath796984d2018-12-27 09:44:32 +0000700 llvm::StringRef label) -> void {
Greg Clayton48a28c12018-12-18 00:50:11 +0000701 auto bytes = minidump.GetStream(stream_type);
702 if (!bytes.empty()) {
703 if (label.empty())
Pavel Labathf2ffb472019-03-26 13:23:01 +0000704 label = MinidumpParser::GetStreamTypeAsString(stream_type);
Greg Clayton48a28c12018-12-18 00:50:11 +0000705 s.Printf("%s:\n%s\n\n", label.data(), bytes.data());
706 }
707 };
Pavel Labathd2b48882019-03-25 14:09:27 +0000708 auto DumpBinaryStream = [&](StreamType stream_type,
Pavel Labath796984d2018-12-27 09:44:32 +0000709 llvm::StringRef label) -> void {
Greg Clayton48a28c12018-12-18 00:50:11 +0000710 auto bytes = minidump.GetStream(stream_type);
711 if (!bytes.empty()) {
712 if (label.empty())
Pavel Labathf2ffb472019-03-26 13:23:01 +0000713 label = MinidumpParser::GetStreamTypeAsString(stream_type);
Greg Clayton48a28c12018-12-18 00:50:11 +0000714 s.Printf("%s:\n", label.data());
715 DataExtractor data(bytes.data(), bytes.size(), eByteOrderLittle,
716 process->GetAddressByteSize());
717 DumpDataExtractor(data, &s, 0, lldb::eFormatBytesWithASCII, 1,
718 bytes.size(), 16, 0, 0, 0);
719 s.Printf("\n\n");
720 }
721 };
722
723 if (DumpLinuxCPUInfo())
Pavel Labathd2b48882019-03-25 14:09:27 +0000724 DumpTextStream(StreamType::LinuxCPUInfo, "/proc/cpuinfo");
Greg Clayton48a28c12018-12-18 00:50:11 +0000725 if (DumpLinuxProcStatus())
Pavel Labathd2b48882019-03-25 14:09:27 +0000726 DumpTextStream(StreamType::LinuxProcStatus, "/proc/PID/status");
Greg Clayton48a28c12018-12-18 00:50:11 +0000727 if (DumpLinuxLSBRelease())
Pavel Labathd2b48882019-03-25 14:09:27 +0000728 DumpTextStream(StreamType::LinuxLSBRelease, "/etc/lsb-release");
Greg Clayton48a28c12018-12-18 00:50:11 +0000729 if (DumpLinuxCMDLine())
Pavel Labathd2b48882019-03-25 14:09:27 +0000730 DumpTextStream(StreamType::LinuxCMDLine, "/proc/PID/cmdline");
Greg Clayton48a28c12018-12-18 00:50:11 +0000731 if (DumpLinuxEnviron())
Pavel Labathd2b48882019-03-25 14:09:27 +0000732 DumpTextStream(StreamType::LinuxEnviron, "/proc/PID/environ");
Greg Clayton48a28c12018-12-18 00:50:11 +0000733 if (DumpLinuxAuxv())
Pavel Labathd2b48882019-03-25 14:09:27 +0000734 DumpBinaryStream(StreamType::LinuxAuxv, "/proc/PID/auxv");
Greg Clayton48a28c12018-12-18 00:50:11 +0000735 if (DumpLinuxMaps())
Pavel Labathd2b48882019-03-25 14:09:27 +0000736 DumpTextStream(StreamType::LinuxMaps, "/proc/PID/maps");
Greg Clayton48a28c12018-12-18 00:50:11 +0000737 if (DumpLinuxProcStat())
Pavel Labathd2b48882019-03-25 14:09:27 +0000738 DumpTextStream(StreamType::LinuxProcStat, "/proc/PID/stat");
Greg Clayton48a28c12018-12-18 00:50:11 +0000739 if (DumpLinuxProcUptime())
Pavel Labathd2b48882019-03-25 14:09:27 +0000740 DumpTextStream(StreamType::LinuxProcUptime, "uptime");
Greg Clayton48a28c12018-12-18 00:50:11 +0000741 if (DumpLinuxProcFD())
Pavel Labathd2b48882019-03-25 14:09:27 +0000742 DumpTextStream(StreamType::LinuxProcFD, "/proc/PID/fd");
Greg Claytoncc6ec692019-02-19 21:48:34 +0000743 if (DumpFacebookAppData())
Pavel Labathd2b48882019-03-25 14:09:27 +0000744 DumpTextStream(StreamType::FacebookAppCustomData,
Greg Claytoncc6ec692019-02-19 21:48:34 +0000745 "Facebook App Data");
746 if (DumpFacebookBuildID()) {
Pavel Labathd2b48882019-03-25 14:09:27 +0000747 auto bytes = minidump.GetStream(StreamType::FacebookBuildID);
Greg Claytoncc6ec692019-02-19 21:48:34 +0000748 if (bytes.size() >= 4) {
749 DataExtractor data(bytes.data(), bytes.size(), eByteOrderLittle,
750 process->GetAddressByteSize());
751 lldb::offset_t offset = 0;
752 uint32_t build_id = data.GetU32(&offset);
753 s.Printf("Facebook Build ID:\n");
754 s.Printf("%u\n", build_id);
755 s.Printf("\n");
756 }
757 }
758 if (DumpFacebookVersionName())
Pavel Labathd2b48882019-03-25 14:09:27 +0000759 DumpTextStream(StreamType::FacebookAppVersionName,
Greg Claytoncc6ec692019-02-19 21:48:34 +0000760 "Facebook Version String");
761 if (DumpFacebookJavaStack())
Pavel Labathd2b48882019-03-25 14:09:27 +0000762 DumpTextStream(StreamType::FacebookJavaStack,
Greg Claytoncc6ec692019-02-19 21:48:34 +0000763 "Facebook Java Stack");
764 if (DumpFacebookDalvikInfo())
Pavel Labathd2b48882019-03-25 14:09:27 +0000765 DumpTextStream(StreamType::FacebookDalvikInfo,
Greg Claytoncc6ec692019-02-19 21:48:34 +0000766 "Facebook Dalvik Info");
767 if (DumpFacebookUnwindSymbols())
Pavel Labathd2b48882019-03-25 14:09:27 +0000768 DumpBinaryStream(StreamType::FacebookUnwindSymbols,
Greg Claytoncc6ec692019-02-19 21:48:34 +0000769 "Facebook Unwind Symbols Bytes");
770 if (DumpFacebookErrorLog())
Pavel Labathd2b48882019-03-25 14:09:27 +0000771 DumpTextStream(StreamType::FacebookDumpErrorLog,
Greg Claytoncc6ec692019-02-19 21:48:34 +0000772 "Facebook Error Log");
773 if (DumpFacebookAppStateLog())
Pavel Labathd2b48882019-03-25 14:09:27 +0000774 DumpTextStream(StreamType::FacebookAppStateLog,
Greg Claytoncc6ec692019-02-19 21:48:34 +0000775 "Faceook Application State Log");
776 if (DumpFacebookAbortReason())
Pavel Labathd2b48882019-03-25 14:09:27 +0000777 DumpTextStream(StreamType::FacebookAbortReason,
Greg Claytoncc6ec692019-02-19 21:48:34 +0000778 "Facebook Abort Reason");
779 if (DumpFacebookThreadName())
Pavel Labathd2b48882019-03-25 14:09:27 +0000780 DumpTextStream(StreamType::FacebookThreadName,
Greg Claytoncc6ec692019-02-19 21:48:34 +0000781 "Facebook Thread Name");
782 if (DumpFacebookLogcat())
Pavel Labathd2b48882019-03-25 14:09:27 +0000783 DumpTextStream(StreamType::FacebookLogcat,
Greg Claytoncc6ec692019-02-19 21:48:34 +0000784 "Facebook Logcat");
Greg Clayton48a28c12018-12-18 00:50:11 +0000785 return true;
786 }
787};
788
789class CommandObjectMultiwordProcessMinidump : public CommandObjectMultiword {
790public:
791 CommandObjectMultiwordProcessMinidump(CommandInterpreter &interpreter)
792 : CommandObjectMultiword(interpreter, "process plugin",
793 "Commands for operating on a ProcessMinidump process.",
794 "process plugin <subcommand> [<subcommand-options>]") {
795 LoadSubCommand("dump",
796 CommandObjectSP(new CommandObjectProcessMinidumpDump(interpreter)));
797 }
Leonard Mosescu0d057902019-01-07 17:55:42 +0000798
Greg Clayton48a28c12018-12-18 00:50:11 +0000799 ~CommandObjectMultiwordProcessMinidump() {}
800};
801
802CommandObject *ProcessMinidump::GetPluginCommandObject() {
803 if (!m_command_sp)
Jonas Devlieghere796ac802019-02-11 23:13:08 +0000804 m_command_sp = std::make_shared<CommandObjectMultiwordProcessMinidump>(
805 GetTarget().GetDebugger().GetCommandInterpreter());
Greg Clayton48a28c12018-12-18 00:50:11 +0000806 return m_command_sp.get();
807}