LLDB  mainline
ProcessMinidump.cpp
Go to the documentation of this file.
1 //===-- ProcessMinidump.cpp -----------------------------------------------===//
2 //
3 // 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
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "ProcessMinidump.h"
10 
11 #include "ThreadMinidump.h"
12 
14 #include "lldb/Core/Module.h"
15 #include "lldb/Core/ModuleSpec.h"
17 #include "lldb/Core/Section.h"
27 #include "lldb/Target/Target.h"
30 #include "lldb/Utility/LLDBLog.h"
31 #include "lldb/Utility/Log.h"
32 #include "lldb/Utility/State.h"
33 #include "llvm/BinaryFormat/Magic.h"
34 #include "llvm/Support/MemoryBuffer.h"
35 #include "llvm/Support/Threading.h"
36 
38 
39 #include <memory>
40 
41 using namespace lldb;
42 using namespace lldb_private;
43 using namespace minidump;
44 
46 
47 namespace {
48 
49 /// A minimal ObjectFile implementation providing a dummy object file for the
50 /// cases when the real module binary is not available. This allows the module
51 /// to show up in "image list" and symbols to be added to it.
52 class PlaceholderObjectFile : public ObjectFile {
53 public:
54  PlaceholderObjectFile(const lldb::ModuleSP &module_sp,
55  const ModuleSpec &module_spec, lldb::addr_t base,
56  lldb::addr_t size)
57  : ObjectFile(module_sp, &module_spec.GetFileSpec(), /*file_offset*/ 0,
58  /*length*/ 0, /*data_sp*/ nullptr, /*data_offset*/ 0),
59  m_arch(module_spec.GetArchitecture()), m_uuid(module_spec.GetUUID()),
60  m_base(base), m_size(size) {
61  m_symtab_up = std::make_unique<Symtab>(this);
62  }
63 
64  static ConstString GetStaticPluginName() {
65  return ConstString("placeholder");
66  }
67  llvm::StringRef GetPluginName() override {
68  return GetStaticPluginName().GetStringRef();
69  }
70  bool ParseHeader() override { return true; }
71  Type CalculateType() override { return eTypeUnknown; }
72  Strata CalculateStrata() override { return eStrataUnknown; }
73  uint32_t GetDependentModules(FileSpecList &file_list) override { return 0; }
74  bool IsExecutable() const override { return false; }
75  ArchSpec GetArchitecture() override { return m_arch; }
76  UUID GetUUID() override { return m_uuid; }
77  void ParseSymtab(lldb_private::Symtab &symtab) override {}
78  bool IsStripped() override { return true; }
79  ByteOrder GetByteOrder() const override { return m_arch.GetByteOrder(); }
80 
81  uint32_t GetAddressByteSize() const override {
82  return m_arch.GetAddressByteSize();
83  }
84 
85  Address GetBaseAddress() override {
86  return Address(m_sections_up->GetSectionAtIndex(0), 0);
87  }
88 
89  void CreateSections(SectionList &unified_section_list) override {
90  m_sections_up = std::make_unique<SectionList>();
91  auto section_sp = std::make_shared<Section>(
92  GetModule(), this, /*sect_id*/ 0, ConstString(".module_image"),
93  eSectionTypeOther, m_base, m_size, /*file_offset*/ 0, /*file_size*/ 0,
94  /*log2align*/ 0, /*flags*/ 0);
95  section_sp->SetPermissions(ePermissionsReadable | ePermissionsExecutable);
96  m_sections_up->AddSection(section_sp);
97  unified_section_list.AddSection(std::move(section_sp));
98  }
99 
100  bool SetLoadAddress(Target &target, addr_t value,
101  bool value_is_offset) override {
102  assert(!value_is_offset);
103  assert(value == m_base);
104 
105  // Create sections if they haven't been created already.
106  GetModule()->GetSectionList();
107  assert(m_sections_up->GetNumSections(0) == 1);
108 
110  m_sections_up->GetSectionAtIndex(0), m_base);
111  return true;
112  }
113 
114  void Dump(Stream *s) override {
115  s->Format("Placeholder object file for {0} loaded at [{1:x}-{2:x})\n",
116  GetFileSpec(), m_base, m_base + m_size);
117  }
118 
119  lldb::addr_t GetBaseImageAddress() const { return m_base; }
120 private:
121  ArchSpec m_arch;
122  UUID m_uuid;
123  lldb::addr_t m_base;
124  lldb::addr_t m_size;
125 };
126 
127 /// Duplicate the HashElfTextSection() from the breakpad sources.
128 ///
129 /// Breakpad, a Google crash log reporting tool suite, creates minidump files
130 /// for many different architectures. When using Breakpad to create ELF
131 /// minidumps, it will check for a GNU build ID when creating a minidump file
132 /// and if one doesn't exist in the file, it will say the UUID of the file is a
133 /// checksum of up to the first 4096 bytes of the .text section. Facebook also
134 /// uses breakpad and modified this hash to avoid collisions so we can
135 /// calculate and check for this as well.
136 ///
137 /// The breakpad code might end up hashing up to 15 bytes that immediately
138 /// follow the .text section in the file, so this code must do exactly what it
139 /// does so we can get an exact match for the UUID.
140 ///
141 /// \param[in] module_sp The module to grab the .text section from.
142 ///
143 /// \param[in,out] breakpad_uuid A vector that will receive the calculated
144 /// breakpad .text hash.
145 ///
146 /// \param[in,out] facebook_uuid A vector that will receive the calculated
147 /// facebook .text hash.
148 ///
149 void HashElfTextSection(ModuleSP module_sp, std::vector<uint8_t> &breakpad_uuid,
150  std::vector<uint8_t> &facebook_uuid) {
151  SectionList *sect_list = module_sp->GetSectionList();
152  if (sect_list == nullptr)
153  return;
154  SectionSP sect_sp = sect_list->FindSectionByName(ConstString(".text"));
155  if (!sect_sp)
156  return;
157  constexpr size_t kMDGUIDSize = 16;
158  constexpr size_t kBreakpadPageSize = 4096;
159  // The breakpad code has a bug where it might access beyond the end of a
160  // .text section by up to 15 bytes, so we must ensure we round up to the
161  // next kMDGUIDSize byte boundary.
162  DataExtractor data;
163  const size_t text_size = sect_sp->GetFileSize();
164  const size_t read_size = std::min<size_t>(
165  llvm::alignTo(text_size, kMDGUIDSize), kBreakpadPageSize);
166  sect_sp->GetObjectFile()->GetData(sect_sp->GetFileOffset(), read_size, data);
167 
168  breakpad_uuid.assign(kMDGUIDSize, 0);
169  facebook_uuid.assign(kMDGUIDSize, 0);
170 
171  // The only difference between the breakpad hash and the facebook hash is the
172  // hashing of the text section size into the hash prior to hashing the .text
173  // contents.
174  for (size_t i = 0; i < kMDGUIDSize; i++)
175  facebook_uuid[i] ^= text_size % 255;
176 
177  // This code carefully duplicates how the hash was created in Breakpad
178  // sources, including the error where it might has an extra 15 bytes past the
179  // end of the .text section if the .text section is less than a page size in
180  // length.
181  const uint8_t *ptr = data.GetDataStart();
182  const uint8_t *ptr_end = data.GetDataEnd();
183  while (ptr < ptr_end) {
184  for (unsigned i = 0; i < kMDGUIDSize; i++) {
185  breakpad_uuid[i] ^= ptr[i];
186  facebook_uuid[i] ^= ptr[i];
187  }
188  ptr += kMDGUIDSize;
189  }
190 }
191 
192 } // namespace
193 
194 llvm::StringRef ProcessMinidump::GetPluginDescriptionStatic() {
195  return "Minidump plug-in.";
196 }
197 
198 lldb::ProcessSP ProcessMinidump::CreateInstance(lldb::TargetSP target_sp,
199  lldb::ListenerSP listener_sp,
200  const FileSpec *crash_file,
201  bool can_connect) {
202  if (!crash_file || can_connect)
203  return nullptr;
204 
205  lldb::ProcessSP process_sp;
206  // Read enough data for the Minidump header
207  constexpr size_t header_size = sizeof(Header);
208  auto DataPtr = FileSystem::Instance().CreateDataBuffer(crash_file->GetPath(),
209  header_size, 0);
210  if (!DataPtr)
211  return nullptr;
212 
213  lldbassert(DataPtr->GetByteSize() == header_size);
214  if (identify_magic(toStringRef(DataPtr->GetData())) != llvm::file_magic::minidump)
215  return nullptr;
216 
217  auto AllData =
218  FileSystem::Instance().CreateDataBuffer(crash_file->GetPath(), -1, 0);
219  if (!AllData)
220  return nullptr;
221 
222  return std::make_shared<ProcessMinidump>(target_sp, listener_sp, *crash_file,
223  std::move(AllData));
224 }
225 
226 bool ProcessMinidump::CanDebug(lldb::TargetSP target_sp,
227  bool plugin_specified_by_name) {
228  return true;
229 }
230 
231 ProcessMinidump::ProcessMinidump(lldb::TargetSP target_sp,
232  lldb::ListenerSP listener_sp,
233  const FileSpec &core_file,
234  DataBufferSP core_data)
235  : PostMortemProcess(target_sp, listener_sp), m_core_file(core_file),
236  m_core_data(std::move(core_data)), m_active_exception(nullptr),
237  m_is_wow64(false) {}
238 
240  Clear();
241  // We need to call finalize on the process before destroying ourselves to
242  // make sure all of the broadcaster cleanup goes as planned. If we destruct
243  // this class, then Process::~Process() might have problems trying to fully
244  // destroy the broadcaster.
245  Finalize();
246 }
247 
249  static llvm::once_flag g_once_flag;
250 
251  llvm::call_once(g_once_flag, []() {
255  });
256 }
257 
260 }
261 
263  auto expected_parser = MinidumpParser::Create(m_core_data);
264  if (!expected_parser)
265  return Status(expected_parser.takeError());
266  m_minidump_parser = std::move(*expected_parser);
267 
268  Status error;
269 
270  // Do we support the minidump's architecture?
271  ArchSpec arch = GetArchitecture();
272  switch (arch.GetMachine()) {
273  case llvm::Triple::x86:
274  case llvm::Triple::x86_64:
275  case llvm::Triple::arm:
276  case llvm::Triple::aarch64:
277  // Any supported architectures must be listed here and also supported in
278  // ThreadMinidump::CreateRegisterContextForFrame().
279  break;
280  default:
281  error.SetErrorStringWithFormat("unsupported minidump architecture: %s",
282  arch.GetArchitectureName());
283  return error;
284  }
285  GetTarget().SetArchitecture(arch, true /*set_platform*/);
286 
287  m_thread_list = m_minidump_parser->GetThreads();
288  m_active_exception = m_minidump_parser->GetExceptionStream();
289 
291 
292  ReadModuleList();
293  if (ModuleSP module = GetTarget().GetExecutableModule())
294  GetTarget().MergeArchitecture(module->GetArchitecture());
295  llvm::Optional<lldb::pid_t> pid = m_minidump_parser->GetPid();
296  if (!pid) {
297  Debugger::ReportWarning("unable to retrieve process ID from minidump file, "
298  "setting process ID to 1",
299  GetTarget().GetDebugger().GetID());
300  pid = 1;
301  }
302  SetID(*pid);
303 
304  return error;
305 }
306 
308 
310 
311  if (!m_active_exception)
312  return;
313 
314  constexpr uint32_t BreakpadDumpRequested = 0xFFFFFFFF;
315  if (m_active_exception->ExceptionRecord.ExceptionCode ==
316  BreakpadDumpRequested) {
317  // This "ExceptionCode" value is a sentinel that is sometimes used
318  // when generating a dump for a process that hasn't crashed.
319 
320  // TODO: The definition and use of this "dump requested" constant
321  // in Breakpad are actually Linux-specific, and for similar use
322  // cases on Mac/Windows it defines different constants, referring
323  // to them as "simulated" exceptions; consider moving this check
324  // down to the OS-specific paths and checking each OS for its own
325  // constant.
326  return;
327  }
328 
329  lldb::StopInfoSP stop_info;
330  lldb::ThreadSP stop_thread;
331 
334  ArchSpec arch = GetArchitecture();
335 
336  if (arch.GetTriple().getOS() == llvm::Triple::Linux) {
337  uint32_t signo = m_active_exception->ExceptionRecord.ExceptionCode;
338 
339  if (signo == 0) {
340  // No stop.
341  return;
342  }
343 
345  *stop_thread, signo);
346  } else if (arch.GetTriple().getVendor() == llvm::Triple::Apple) {
348  *stop_thread, m_active_exception->ExceptionRecord.ExceptionCode, 2,
349  m_active_exception->ExceptionRecord.ExceptionFlags,
350  m_active_exception->ExceptionRecord.ExceptionAddress, 0);
351  } else {
352  std::string desc;
353  llvm::raw_string_ostream desc_stream(desc);
354  desc_stream << "Exception "
355  << llvm::format_hex(
356  m_active_exception->ExceptionRecord.ExceptionCode, 8)
357  << " encountered at address "
358  << llvm::format_hex(
359  m_active_exception->ExceptionRecord.ExceptionAddress, 8);
361  *stop_thread, desc_stream.str().c_str());
362  }
363 
364  stop_thread->SetStopInfo(stop_info);
365 }
366 
367 bool ProcessMinidump::IsAlive() { return true; }
368 
369 bool ProcessMinidump::WarnBeforeDetach() const { return false; }
370 
371 size_t ProcessMinidump::ReadMemory(lldb::addr_t addr, void *buf, size_t size,
372  Status &error) {
373  // Don't allow the caching that lldb_private::Process::ReadMemory does since
374  // we have it all cached in our dump file anyway.
375  return DoReadMemory(addr, buf, size, error);
376 }
377 
378 size_t ProcessMinidump::DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
379  Status &error) {
380 
381  llvm::ArrayRef<uint8_t> mem = m_minidump_parser->GetMemory(addr, size);
382  if (mem.empty()) {
383  error.SetErrorString("could not parse memory info");
384  return 0;
385  }
386 
387  std::memcpy(buf, mem.data(), mem.size());
388  return mem.size();
389 }
390 
392  if (!m_is_wow64) {
393  return m_minidump_parser->GetArchitecture();
394  }
395 
396  llvm::Triple triple;
397  triple.setVendor(llvm::Triple::VendorType::UnknownVendor);
398  triple.setArch(llvm::Triple::ArchType::x86);
399  triple.setOS(llvm::Triple::OSType::Win32);
400  return ArchSpec(triple);
401 }
402 
404  if (m_memory_regions)
405  return;
406  m_memory_regions.emplace();
407  bool is_complete;
408  std::tie(*m_memory_regions, is_complete) =
409  m_minidump_parser->BuildMemoryRegions();
410 
411  if (is_complete)
412  return;
413 
414  MemoryRegionInfos to_add;
415  ModuleList &modules = GetTarget().GetImages();
417  modules.ForEach([&](const ModuleSP &module_sp) {
418  SectionList *sections = module_sp->GetSectionList();
419  for (size_t i = 0; i < sections->GetSize(); ++i) {
420  SectionSP section_sp = sections->GetSectionAtIndex(i);
421  addr_t load_addr = load_list.GetSectionLoadAddress(section_sp);
422  if (load_addr == LLDB_INVALID_ADDRESS)
423  continue;
424  MemoryRegionInfo::RangeType section_range(load_addr,
425  section_sp->GetByteSize());
426  MemoryRegionInfo region =
428  if (region.GetMapped() != MemoryRegionInfo::eYes &&
429  region.GetRange().GetRangeBase() <= section_range.GetRangeBase() &&
430  section_range.GetRangeEnd() <= region.GetRange().GetRangeEnd()) {
431  to_add.emplace_back();
432  to_add.back().GetRange() = section_range;
433  to_add.back().SetLLDBPermissions(section_sp->GetPermissions());
434  to_add.back().SetMapped(MemoryRegionInfo::eYes);
435  to_add.back().SetName(module_sp->GetFileSpec().GetPath().c_str());
436  }
437  }
438  return true;
439  });
440  m_memory_regions->insert(m_memory_regions->end(), to_add.begin(),
441  to_add.end());
442  llvm::sort(*m_memory_regions);
443 }
444 
446  MemoryRegionInfo &region) {
449  return Status();
450 }
451 
454  region_list = *m_memory_regions;
455  return Status();
456 }
457 
459 
461  ThreadList &new_thread_list) {
462  for (const minidump::Thread &thread : m_thread_list) {
463  LocationDescriptor context_location = thread.Context;
464 
465  // If the minidump contains an exception context, use it
466  if (m_active_exception != nullptr &&
467  m_active_exception->ThreadId == thread.ThreadId) {
468  context_location = m_active_exception->ThreadContext;
469  }
470 
471  llvm::ArrayRef<uint8_t> context;
472  if (!m_is_wow64)
473  context = m_minidump_parser->GetThreadContext(context_location);
474  else
475  context = m_minidump_parser->GetThreadContextWow64(thread);
476 
477  lldb::ThreadSP thread_sp(new ThreadMinidump(*this, thread, context));
478  new_thread_list.AddThread(thread_sp);
479  }
480  return new_thread_list.GetSize(false) > 0;
481 }
482 
484  llvm::StringRef name,
485  ModuleSpec module_spec) {
487  Status error;
488 
489  ModuleSP module_sp =
490  GetTarget().GetOrCreateModule(module_spec, true /* notify */, &error);
491  if (!module_sp)
492  return module_sp;
493  // We consider the module to be a match if the minidump UUID is a
494  // prefix of the actual UUID, or if either of the UUIDs are empty.
495  const auto dmp_bytes = minidump_uuid.GetBytes();
496  const auto mod_bytes = module_sp->GetUUID().GetBytes();
497  const bool match = dmp_bytes.empty() || mod_bytes.empty() ||
498  mod_bytes.take_front(dmp_bytes.size()) == dmp_bytes;
499  if (match) {
500  LLDB_LOG(log, "Partial uuid match for {0}.", name);
501  return module_sp;
502  }
503 
504  // Breakpad generates minindump files, and if there is no GNU build
505  // ID in the binary, it will calculate a UUID by hashing first 4096
506  // bytes of the .text section and using that as the UUID for a module
507  // in the minidump. Facebook uses a modified breakpad client that
508  // uses a slightly modified this hash to avoid collisions. Check for
509  // UUIDs from the minindump that match these cases and accept the
510  // module we find if they do match.
511  std::vector<uint8_t> breakpad_uuid;
512  std::vector<uint8_t> facebook_uuid;
513  HashElfTextSection(module_sp, breakpad_uuid, facebook_uuid);
514  if (dmp_bytes == llvm::ArrayRef<uint8_t>(breakpad_uuid)) {
515  LLDB_LOG(log, "Breakpad .text hash match for {0}.", name);
516  return module_sp;
517  }
518  if (dmp_bytes == llvm::ArrayRef<uint8_t>(facebook_uuid)) {
519  LLDB_LOG(log, "Facebook .text hash match for {0}.", name);
520  return module_sp;
521  }
522  // The UUID wasn't a partial match and didn't match the .text hash
523  // so remove the module from the target, we will need to create a
524  // placeholder object file.
525  GetTarget().GetImages().Remove(module_sp);
526  module_sp.reset();
527  return module_sp;
528 }
529 
531  std::vector<const minidump::Module *> filtered_modules =
532  m_minidump_parser->GetFilteredModuleList();
533 
535 
536  for (auto module : filtered_modules) {
537  std::string name = cantFail(m_minidump_parser->GetMinidumpFile().getString(
538  module->ModuleNameRVA));
539  const uint64_t load_addr = module->BaseOfImage;
540  const uint64_t load_size = module->SizeOfImage;
541  LLDB_LOG(log, "found module: name: {0} {1:x10}-{2:x10} size: {3}", name,
542  load_addr, load_addr + load_size, load_size);
543 
544  // check if the process is wow64 - a 32 bit windows process running on a
545  // 64 bit windows
546  if (llvm::StringRef(name).endswith_insensitive("wow64.dll")) {
547  m_is_wow64 = true;
548  }
549 
550  const auto uuid = m_minidump_parser->GetModuleUUID(module);
551  auto file_spec = FileSpec(name, GetArchitecture().GetTriple());
552  ModuleSpec module_spec(file_spec, uuid);
553  module_spec.GetArchitecture() = GetArchitecture();
554  Status error;
555  // Try and find a module with a full UUID that matches. This function will
556  // add the module to the target if it finds one.
557  lldb::ModuleSP module_sp = GetTarget().GetOrCreateModule(module_spec,
558  true /* notify */, &error);
559  if (module_sp) {
560  LLDB_LOG(log, "Full uuid match for {0}.", name);
561  } else {
562  // We couldn't find a module with an exactly-matching UUID. Sometimes
563  // a minidump UUID is only a partial match or is a hash. So try again
564  // without specifying the UUID, then again without specifying the
565  // directory if that fails. This will allow us to find modules with
566  // partial matches or hash UUIDs in user-provided sysroots or search
567  // directories (target.exec-search-paths).
568  ModuleSpec partial_module_spec = module_spec;
569  partial_module_spec.GetUUID().Clear();
570  module_sp = GetOrCreateModule(uuid, name, partial_module_spec);
571  if (!module_sp) {
572  partial_module_spec.GetFileSpec().ClearDirectory();
573  module_sp = GetOrCreateModule(uuid, name, partial_module_spec);
574  }
575  }
576  if (module_sp) {
577  // Watch out for place holder modules that have different paths, but the
578  // same UUID. If the base address is different, create a new module. If
579  // we don't then we will end up setting the load address of a different
580  // PlaceholderObjectFile and an assertion will fire.
581  auto *objfile = module_sp->GetObjectFile();
582  if (objfile &&
583  objfile->GetPluginName() ==
584  PlaceholderObjectFile::GetStaticPluginName().GetStringRef()) {
585  if (((PlaceholderObjectFile *)objfile)->GetBaseImageAddress() !=
586  load_addr)
587  module_sp.reset();
588  }
589  }
590  if (!module_sp) {
591  // We failed to locate a matching local object file. Fortunately, the
592  // minidump format encodes enough information about each module's memory
593  // range to allow us to create placeholder modules.
594  //
595  // This enables most LLDB functionality involving address-to-module
596  // translations (ex. identifing the module for a stack frame PC) and
597  // modules/sections commands (ex. target modules list, ...)
598  LLDB_LOG(log,
599  "Unable to locate the matching object file, creating a "
600  "placeholder module for: {0}",
601  name);
602 
603  module_sp = Module::CreateModuleFromObjectFile<PlaceholderObjectFile>(
604  module_spec, load_addr, load_size);
605  GetTarget().GetImages().Append(module_sp, true /* notify */);
606  }
607 
608  bool load_addr_changed = false;
609  module_sp->SetLoadAddress(GetTarget(), load_addr, false,
610  load_addr_changed);
611  }
612 }
613 
615  info.Clear();
616  info.SetProcessID(GetID());
618  lldb::ModuleSP module_sp = GetTarget().GetExecutableModule();
619  if (module_sp) {
620  const bool add_exe_file_as_first_arg = false;
621  info.SetExecutableFile(GetTarget().GetExecutableModule()->GetFileSpec(),
622  add_exe_file_as_first_arg);
623  }
624  return true;
625 }
626 
627 // For minidumps there's no runtime generated code so we don't need JITLoader(s)
628 // Avoiding them will also speed up minidump loading since JITLoaders normally
629 // try to set up symbolic breakpoints, which in turn may force loading more
630 // debug information than needed.
632  if (!m_jit_loaders_up) {
633  m_jit_loaders_up = std::make_unique<JITLoaderList>();
634  }
635  return *m_jit_loaders_up;
636 }
637 
638 #define INIT_BOOL(VAR, LONG, SHORT, DESC) \
639  VAR(LLDB_OPT_SET_1, false, LONG, SHORT, DESC, false, true)
640 #define APPEND_OPT(VAR) \
641  m_option_group.Append(&VAR, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1)
642 
644 private:
671 
673  if (m_dump_all.GetOptionValue().GetCurrentValue() ||
674  m_dump_linux_all.GetOptionValue().GetCurrentValue() ||
675  m_fb_all.GetOptionValue().GetCurrentValue() ||
676  m_dump_directory.GetOptionValue().GetCurrentValue() ||
677  m_dump_linux_cpuinfo.GetOptionValue().GetCurrentValue() ||
678  m_dump_linux_proc_status.GetOptionValue().GetCurrentValue() ||
679  m_dump_linux_lsb_release.GetOptionValue().GetCurrentValue() ||
680  m_dump_linux_cmdline.GetOptionValue().GetCurrentValue() ||
681  m_dump_linux_environ.GetOptionValue().GetCurrentValue() ||
682  m_dump_linux_auxv.GetOptionValue().GetCurrentValue() ||
683  m_dump_linux_maps.GetOptionValue().GetCurrentValue() ||
684  m_dump_linux_proc_stat.GetOptionValue().GetCurrentValue() ||
685  m_dump_linux_proc_uptime.GetOptionValue().GetCurrentValue() ||
686  m_dump_linux_proc_fd.GetOptionValue().GetCurrentValue() ||
687  m_fb_app_data.GetOptionValue().GetCurrentValue() ||
688  m_fb_build_id.GetOptionValue().GetCurrentValue() ||
689  m_fb_version.GetOptionValue().GetCurrentValue() ||
690  m_fb_java_stack.GetOptionValue().GetCurrentValue() ||
691  m_fb_dalvik.GetOptionValue().GetCurrentValue() ||
692  m_fb_unwind.GetOptionValue().GetCurrentValue() ||
693  m_fb_error_log.GetOptionValue().GetCurrentValue() ||
694  m_fb_app_state.GetOptionValue().GetCurrentValue() ||
695  m_fb_abort.GetOptionValue().GetCurrentValue() ||
696  m_fb_thread.GetOptionValue().GetCurrentValue() ||
697  m_fb_logcat.GetOptionValue().GetCurrentValue())
698  return;
699  // If no options were set, then dump everything
700  m_dump_all.GetOptionValue().SetCurrentValue(true);
701  }
702  bool DumpAll() const {
703  return m_dump_all.GetOptionValue().GetCurrentValue();
704  }
705  bool DumpDirectory() const {
706  return DumpAll() ||
707  m_dump_directory.GetOptionValue().GetCurrentValue();
708  }
709  bool DumpLinux() const {
710  return DumpAll() || m_dump_linux_all.GetOptionValue().GetCurrentValue();
711  }
712  bool DumpLinuxCPUInfo() const {
713  return DumpLinux() ||
714  m_dump_linux_cpuinfo.GetOptionValue().GetCurrentValue();
715  }
716  bool DumpLinuxProcStatus() const {
717  return DumpLinux() ||
718  m_dump_linux_proc_status.GetOptionValue().GetCurrentValue();
719  }
720  bool DumpLinuxProcStat() const {
721  return DumpLinux() ||
722  m_dump_linux_proc_stat.GetOptionValue().GetCurrentValue();
723  }
724  bool DumpLinuxLSBRelease() const {
725  return DumpLinux() ||
726  m_dump_linux_lsb_release.GetOptionValue().GetCurrentValue();
727  }
728  bool DumpLinuxCMDLine() const {
729  return DumpLinux() ||
730  m_dump_linux_cmdline.GetOptionValue().GetCurrentValue();
731  }
732  bool DumpLinuxEnviron() const {
733  return DumpLinux() ||
734  m_dump_linux_environ.GetOptionValue().GetCurrentValue();
735  }
736  bool DumpLinuxAuxv() const {
737  return DumpLinux() ||
738  m_dump_linux_auxv.GetOptionValue().GetCurrentValue();
739  }
740  bool DumpLinuxMaps() const {
741  return DumpLinux() ||
742  m_dump_linux_maps.GetOptionValue().GetCurrentValue();
743  }
744  bool DumpLinuxProcUptime() const {
745  return DumpLinux() ||
746  m_dump_linux_proc_uptime.GetOptionValue().GetCurrentValue();
747  }
748  bool DumpLinuxProcFD() const {
749  return DumpLinux() ||
750  m_dump_linux_proc_fd.GetOptionValue().GetCurrentValue();
751  }
752  bool DumpFacebook() const {
753  return DumpAll() || m_fb_all.GetOptionValue().GetCurrentValue();
754  }
755  bool DumpFacebookAppData() const {
756  return DumpFacebook() || m_fb_app_data.GetOptionValue().GetCurrentValue();
757  }
758  bool DumpFacebookBuildID() const {
759  return DumpFacebook() || m_fb_build_id.GetOptionValue().GetCurrentValue();
760  }
761  bool DumpFacebookVersionName() const {
762  return DumpFacebook() || m_fb_version.GetOptionValue().GetCurrentValue();
763  }
764  bool DumpFacebookJavaStack() const {
765  return DumpFacebook() || m_fb_java_stack.GetOptionValue().GetCurrentValue();
766  }
767  bool DumpFacebookDalvikInfo() const {
768  return DumpFacebook() || m_fb_dalvik.GetOptionValue().GetCurrentValue();
769  }
771  return DumpFacebook() || m_fb_unwind.GetOptionValue().GetCurrentValue();
772  }
773  bool DumpFacebookErrorLog() const {
774  return DumpFacebook() || m_fb_error_log.GetOptionValue().GetCurrentValue();
775  }
776  bool DumpFacebookAppStateLog() const {
777  return DumpFacebook() || m_fb_app_state.GetOptionValue().GetCurrentValue();
778  }
779  bool DumpFacebookAbortReason() const {
780  return DumpFacebook() || m_fb_abort.GetOptionValue().GetCurrentValue();
781  }
782  bool DumpFacebookThreadName() const {
783  return DumpFacebook() || m_fb_thread.GetOptionValue().GetCurrentValue();
784  }
785  bool DumpFacebookLogcat() const {
786  return DumpFacebook() || m_fb_logcat.GetOptionValue().GetCurrentValue();
787  }
788 public:
790  : CommandObjectParsed(interpreter, "process plugin dump",
791  "Dump information from the minidump file.", nullptr),
792  m_option_group(),
793  INIT_BOOL(m_dump_all, "all", 'a',
794  "Dump the everything in the minidump."),
795  INIT_BOOL(m_dump_directory, "directory", 'd',
796  "Dump the minidump directory map."),
797  INIT_BOOL(m_dump_linux_cpuinfo, "cpuinfo", 'C',
798  "Dump linux /proc/cpuinfo."),
799  INIT_BOOL(m_dump_linux_proc_status, "status", 's',
800  "Dump linux /proc/<pid>/status."),
801  INIT_BOOL(m_dump_linux_lsb_release, "lsb-release", 'r',
802  "Dump linux /etc/lsb-release."),
803  INIT_BOOL(m_dump_linux_cmdline, "cmdline", 'c',
804  "Dump linux /proc/<pid>/cmdline."),
805  INIT_BOOL(m_dump_linux_environ, "environ", 'e',
806  "Dump linux /proc/<pid>/environ."),
807  INIT_BOOL(m_dump_linux_auxv, "auxv", 'x',
808  "Dump linux /proc/<pid>/auxv."),
809  INIT_BOOL(m_dump_linux_maps, "maps", 'm',
810  "Dump linux /proc/<pid>/maps."),
811  INIT_BOOL(m_dump_linux_proc_stat, "stat", 'S',
812  "Dump linux /proc/<pid>/stat."),
813  INIT_BOOL(m_dump_linux_proc_uptime, "uptime", 'u',
814  "Dump linux process uptime."),
815  INIT_BOOL(m_dump_linux_proc_fd, "fd", 'f',
816  "Dump linux /proc/<pid>/fd."),
817  INIT_BOOL(m_dump_linux_all, "linux", 'l',
818  "Dump all linux streams."),
819  INIT_BOOL(m_fb_app_data, "fb-app-data", 1,
820  "Dump Facebook application custom data."),
821  INIT_BOOL(m_fb_build_id, "fb-build-id", 2,
822  "Dump the Facebook build ID."),
823  INIT_BOOL(m_fb_version, "fb-version", 3,
824  "Dump Facebook application version string."),
825  INIT_BOOL(m_fb_java_stack, "fb-java-stack", 4,
826  "Dump Facebook java stack."),
827  INIT_BOOL(m_fb_dalvik, "fb-dalvik-info", 5,
828  "Dump Facebook Dalvik info."),
829  INIT_BOOL(m_fb_unwind, "fb-unwind-symbols", 6,
830  "Dump Facebook unwind symbols."),
831  INIT_BOOL(m_fb_error_log, "fb-error-log", 7,
832  "Dump Facebook error log."),
833  INIT_BOOL(m_fb_app_state, "fb-app-state-log", 8,
834  "Dump Facebook java stack."),
835  INIT_BOOL(m_fb_abort, "fb-abort-reason", 9,
836  "Dump Facebook abort reason."),
837  INIT_BOOL(m_fb_thread, "fb-thread-name", 10,
838  "Dump Facebook thread name."),
839  INIT_BOOL(m_fb_logcat, "fb-logcat", 11,
840  "Dump Facebook logcat."),
841  INIT_BOOL(m_fb_all, "facebook", 12, "Dump all Facebook streams.") {
842  APPEND_OPT(m_dump_all);
843  APPEND_OPT(m_dump_directory);
844  APPEND_OPT(m_dump_linux_cpuinfo);
845  APPEND_OPT(m_dump_linux_proc_status);
846  APPEND_OPT(m_dump_linux_lsb_release);
847  APPEND_OPT(m_dump_linux_cmdline);
848  APPEND_OPT(m_dump_linux_environ);
849  APPEND_OPT(m_dump_linux_auxv);
850  APPEND_OPT(m_dump_linux_maps);
851  APPEND_OPT(m_dump_linux_proc_stat);
852  APPEND_OPT(m_dump_linux_proc_uptime);
853  APPEND_OPT(m_dump_linux_proc_fd);
854  APPEND_OPT(m_dump_linux_all);
855  APPEND_OPT(m_fb_app_data);
856  APPEND_OPT(m_fb_build_id);
857  APPEND_OPT(m_fb_version);
858  APPEND_OPT(m_fb_java_stack);
859  APPEND_OPT(m_fb_dalvik);
860  APPEND_OPT(m_fb_unwind);
861  APPEND_OPT(m_fb_error_log);
862  APPEND_OPT(m_fb_app_state);
863  APPEND_OPT(m_fb_abort);
864  APPEND_OPT(m_fb_thread);
865  APPEND_OPT(m_fb_logcat);
866  APPEND_OPT(m_fb_all);
867  m_option_group.Finalize();
868  }
869 
870  ~CommandObjectProcessMinidumpDump() override = default;
871 
872  Options *GetOptions() override { return &m_option_group; }
873 
874  bool DoExecute(Args &command, CommandReturnObject &result) override {
875  const size_t argc = command.GetArgumentCount();
876  if (argc > 0) {
877  result.AppendErrorWithFormat("'%s' take no arguments, only options",
878  m_cmd_name.c_str());
879  return false;
880  }
881  SetDefaultOptionsIfNoneAreSet();
882 
883  ProcessMinidump *process = static_cast<ProcessMinidump *>(
884  m_interpreter.GetExecutionContext().GetProcessPtr());
886  Stream &s = result.GetOutputStream();
887  MinidumpParser &minidump = *process->m_minidump_parser;
888  if (DumpDirectory()) {
889  s.Printf("RVA SIZE TYPE StreamType\n");
890  s.Printf("---------- ---------- ---------- --------------------------\n");
891  for (const auto &stream_desc : minidump.GetMinidumpFile().streams())
892  s.Printf(
893  "0x%8.8x 0x%8.8x 0x%8.8x %s\n", (uint32_t)stream_desc.Location.RVA,
894  (uint32_t)stream_desc.Location.DataSize,
895  (unsigned)(StreamType)stream_desc.Type,
896  MinidumpParser::GetStreamTypeAsString(stream_desc.Type).data());
897  s.Printf("\n");
898  }
899  auto DumpTextStream = [&](StreamType stream_type,
900  llvm::StringRef label) -> void {
901  auto bytes = minidump.GetStream(stream_type);
902  if (!bytes.empty()) {
903  if (label.empty())
904  label = MinidumpParser::GetStreamTypeAsString(stream_type);
905  s.Printf("%s:\n%s\n\n", label.data(), bytes.data());
906  }
907  };
908  auto DumpBinaryStream = [&](StreamType stream_type,
909  llvm::StringRef label) -> void {
910  auto bytes = minidump.GetStream(stream_type);
911  if (!bytes.empty()) {
912  if (label.empty())
913  label = MinidumpParser::GetStreamTypeAsString(stream_type);
914  s.Printf("%s:\n", label.data());
915  DataExtractor data(bytes.data(), bytes.size(), eByteOrderLittle,
916  process->GetAddressByteSize());
918  bytes.size(), 16, 0, 0, 0);
919  s.Printf("\n\n");
920  }
921  };
922 
923  if (DumpLinuxCPUInfo())
924  DumpTextStream(StreamType::LinuxCPUInfo, "/proc/cpuinfo");
925  if (DumpLinuxProcStatus())
926  DumpTextStream(StreamType::LinuxProcStatus, "/proc/PID/status");
927  if (DumpLinuxLSBRelease())
928  DumpTextStream(StreamType::LinuxLSBRelease, "/etc/lsb-release");
929  if (DumpLinuxCMDLine())
930  DumpTextStream(StreamType::LinuxCMDLine, "/proc/PID/cmdline");
931  if (DumpLinuxEnviron())
932  DumpTextStream(StreamType::LinuxEnviron, "/proc/PID/environ");
933  if (DumpLinuxAuxv())
934  DumpBinaryStream(StreamType::LinuxAuxv, "/proc/PID/auxv");
935  if (DumpLinuxMaps())
936  DumpTextStream(StreamType::LinuxMaps, "/proc/PID/maps");
937  if (DumpLinuxProcStat())
938  DumpTextStream(StreamType::LinuxProcStat, "/proc/PID/stat");
939  if (DumpLinuxProcUptime())
940  DumpTextStream(StreamType::LinuxProcUptime, "uptime");
941  if (DumpLinuxProcFD())
942  DumpTextStream(StreamType::LinuxProcFD, "/proc/PID/fd");
943  if (DumpFacebookAppData())
944  DumpTextStream(StreamType::FacebookAppCustomData,
945  "Facebook App Data");
946  if (DumpFacebookBuildID()) {
947  auto bytes = minidump.GetStream(StreamType::FacebookBuildID);
948  if (bytes.size() >= 4) {
949  DataExtractor data(bytes.data(), bytes.size(), eByteOrderLittle,
950  process->GetAddressByteSize());
951  lldb::offset_t offset = 0;
952  uint32_t build_id = data.GetU32(&offset);
953  s.Printf("Facebook Build ID:\n");
954  s.Printf("%u\n", build_id);
955  s.Printf("\n");
956  }
957  }
958  if (DumpFacebookVersionName())
959  DumpTextStream(StreamType::FacebookAppVersionName,
960  "Facebook Version String");
961  if (DumpFacebookJavaStack())
962  DumpTextStream(StreamType::FacebookJavaStack,
963  "Facebook Java Stack");
964  if (DumpFacebookDalvikInfo())
965  DumpTextStream(StreamType::FacebookDalvikInfo,
966  "Facebook Dalvik Info");
967  if (DumpFacebookUnwindSymbols())
968  DumpBinaryStream(StreamType::FacebookUnwindSymbols,
969  "Facebook Unwind Symbols Bytes");
970  if (DumpFacebookErrorLog())
971  DumpTextStream(StreamType::FacebookDumpErrorLog,
972  "Facebook Error Log");
973  if (DumpFacebookAppStateLog())
974  DumpTextStream(StreamType::FacebookAppStateLog,
975  "Faceook Application State Log");
976  if (DumpFacebookAbortReason())
977  DumpTextStream(StreamType::FacebookAbortReason,
978  "Facebook Abort Reason");
979  if (DumpFacebookThreadName())
980  DumpTextStream(StreamType::FacebookThreadName,
981  "Facebook Thread Name");
982  if (DumpFacebookLogcat())
983  DumpTextStream(StreamType::FacebookLogcat,
984  "Facebook Logcat");
985  return true;
986  }
987 };
988 
990 public:
992  : CommandObjectMultiword(interpreter, "process plugin",
993  "Commands for operating on a ProcessMinidump process.",
994  "process plugin <subcommand> [<subcommand-options>]") {
995  LoadSubCommand("dump",
996  CommandObjectSP(new CommandObjectProcessMinidumpDump(interpreter)));
997  }
998 
999  ~CommandObjectMultiwordProcessMinidump() override = default;
1000 };
1001 
1003  if (!m_command_sp)
1004  m_command_sp = std::make_shared<CommandObjectMultiwordProcessMinidump>(
1005  GetTarget().GetDebugger().GetCommandInterpreter());
1006  return m_command_sp.get();
1007 }
lldb_private::SectionLoadList::SetSectionLoadAddress
bool SetSectionLoadAddress(const lldb::SectionSP &section_sp, lldb::addr_t load_addr, bool warn_multiple=false)
Definition: SectionLoadList.cpp:64
ThreadMinidump.h
lldb_private::Stream::Format
void Format(const char *format, Args &&... args)
Definition: Stream.h:309
lldb_private::CommandObjectParsed
Definition: CommandObject.h:390
lldb_private::ProcessInstanceInfo
Definition: ProcessInfo.h:106
lldb_private::UUID
Definition: UUID.h:23
CommandObjectProcessMinidumpDump::DumpFacebookLogcat
bool DumpFacebookLogcat() const
Definition: ProcessMinidump.cpp:785
lldb_private::Range::GetRangeBase
BaseType GetRangeBase() const
Definition: RangeMap.h:46
lldb_private::SectionList::FindSectionByName
lldb::SectionSP FindSectionByName(ConstString section_dstr) const
Definition: Section.cpp:546
CommandObjectMultiwordProcessMinidump::CommandObjectMultiwordProcessMinidump
CommandObjectMultiwordProcessMinidump(CommandInterpreter &interpreter)
Definition: ProcessMinidump.cpp:991
lldb_private::minidump::ProcessMinidump::m_memory_regions
llvm::Optional< MemoryRegionInfos > m_memory_regions
Definition: ProcessMinidump.h:116
lldb_private::OptionValueBoolean::SetCurrentValue
void SetCurrentValue(bool value)
Definition: OptionValueBoolean.h:74
lldb_private::ArchSpec
Definition: ArchSpec.h:32
lldb_private::minidump::ThreadMinidump
Definition: ThreadMinidump.h:21
CommandObjectProcessMinidumpDump::DumpLinuxCMDLine
bool DumpLinuxCMDLine() const
Definition: ProcessMinidump.cpp:728
lldb_private::Process::m_thread_list
ThreadList m_thread_list
The threads for this process as the user will see them.
Definition: Process.h:2878
lldb_private::ProcessInfo::SetExecutableFile
void SetExecutableFile(const FileSpec &exe_file, bool add_exe_file_as_first_arg)
Definition: ProcessInfo.cpp:60
lldb_private::minidump::ProcessMinidump::GetPluginCommandObject
CommandObject * GetPluginCommandObject() override
Return a multi-word command object that can be used to expose plug-in specific commands.
Definition: ProcessMinidump.cpp:1002
lldb_private::ProcessInfo::SetArchitecture
void SetArchitecture(const ArchSpec &arch)
Definition: ProcessInfo.h:64
CommandObjectProcessMinidumpDump::DumpFacebookAppStateLog
bool DumpFacebookAppStateLog() const
Definition: ProcessMinidump.cpp:776
lldb_private::Debugger::ReportWarning
static void ReportWarning(std::string message, llvm::Optional< lldb::user_id_t > debugger_id=llvm::None, std::once_flag *once=nullptr)
Report warning events.
Definition: Debugger.cpp:1378
lldb_private::JITLoaderList
Definition: JITLoaderList.h:22
lldb_private::ArchSpec::GetMachine
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
Definition: ArchSpec.cpp:678
lldb_private::minidump::ProcessMinidump::RefreshStateAfterStop
void RefreshStateAfterStop() override
Currently called as part of ShouldStop.
Definition: ProcessMinidump.cpp:309
ModuleSpec.h
CommandObjectProcessMinidumpDump::GetOptions
Options * GetOptions() override
Definition: ProcessMinidump.cpp:872
lldb_private::ProcessInstanceInfo::Clear
void Clear()
Definition: ProcessInfo.h:114
lldb_private::minidump::ProcessMinidump::Initialize
static void Initialize()
Definition: ProcessMinidump.cpp:248
lldb_private::minidump::ProcessMinidump::GetPluginDescriptionStatic
static llvm::StringRef GetPluginDescriptionStatic()
Definition: ProcessMinidump.cpp:194
CommandObjectProcessMinidumpDump::m_dump_linux_proc_stat
OptionGroupBoolean m_dump_linux_proc_stat
Definition: ProcessMinidump.cpp:655
lldb_private::minidump::ProcessMinidump::GetPluginNameStatic
static llvm::StringRef GetPluginNameStatic()
Definition: ProcessMinidump.h:40
lldb_private::Target::GetOrCreateModule
lldb::ModuleSP GetOrCreateModule(const ModuleSpec &module_spec, bool notify, Status *error_ptr=nullptr)
Find a binary on the system and return its Module, or return an existing Module that is already in th...
Definition: Target.cpp:2082
CommandObjectProcessMinidumpDump::DumpLinuxProcStat
bool DumpLinuxProcStat() const
Definition: ProcessMinidump.cpp:720
CommandObjectProcessMinidumpDump::DumpLinuxProcUptime
bool DumpLinuxProcUptime() const
Definition: ProcessMinidump.cpp:744
StopInfoMachException.h
lldb_private::minidump::ProcessMinidump::GetJITLoaders
JITLoaderList & GetJITLoaders() override
Definition: ProcessMinidump.cpp:631
CommandObjectProcessMinidumpDump::m_fb_thread
OptionGroupBoolean m_fb_thread
Definition: ProcessMinidump.cpp:668
CommandObjectProcessMinidumpDump::DumpLinuxLSBRelease
bool DumpLinuxLSBRelease() const
Definition: ProcessMinidump.cpp:724
CommandObjectProcessMinidumpDump::CommandObjectProcessMinidumpDump
CommandObjectProcessMinidumpDump(CommandInterpreter &interpreter)
Definition: ProcessMinidump.cpp:789
lldb_private::SectionList::GetSize
size_t GetSize() const
Definition: Section.h:74
lldb_private::Target::GetExecutableModule
lldb::ModuleSP GetExecutableModule()
Gets the module for the main executable.
Definition: Target.cpp:1371
CommandObjectProcessMinidumpDump::m_dump_all
OptionGroupBoolean m_dump_all
Definition: ProcessMinidump.cpp:646
lldb_private::OptionGroupOptions
Definition: Options.h:255
CommandObjectProcessMinidumpDump::m_dump_linux_proc_status
OptionGroupBoolean m_dump_linux_proc_status
Definition: ProcessMinidump.cpp:649
Module.h
CommandObjectProcessMinidumpDump::m_dump_linux_all
OptionGroupBoolean m_dump_linux_all
Definition: ProcessMinidump.cpp:658
CommandObjectProcessMinidumpDump::m_fb_all
OptionGroupBoolean m_fb_all
Definition: ProcessMinidump.cpp:670
CommandObjectProcessMinidumpDump::m_fb_java_stack
OptionGroupBoolean m_fb_java_stack
Definition: ProcessMinidump.cpp:662
lldb_private::Process::GetTarget
Target & GetTarget()
Get the target object pointer for this module.
Definition: Process.h:1219
lldb_private::StopInfo::CreateStopReasonWithSignal
static lldb::StopInfoSP CreateStopReasonWithSignal(Thread &thread, int signo, const char *description=nullptr)
Definition: StopInfo.cpp:1375
CommandObjectProcessMinidumpDump::DumpFacebookAppData
bool DumpFacebookAppData() const
Definition: ProcessMinidump.cpp:755
CommandObjectProcessMinidumpDump::DumpAll
bool DumpAll() const
Definition: ProcessMinidump.cpp:702
CommandObjectProcessMinidumpDump::m_dump_linux_lsb_release
OptionGroupBoolean m_dump_linux_lsb_release
Definition: ProcessMinidump.cpp:650
lldb_private::minidump::ProcessMinidump::BuildMemoryRegions
void BuildMemoryRegions()
Definition: ProcessMinidump.cpp:403
OptionArgParser.h
SectionLoadList.h
lldb_private::minidump::ProcessMinidump::DoGetMemoryRegionInfo
Status DoGetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info) override
DoGetMemoryRegionInfo is called by GetMemoryRegionInfo after it has removed non address bits from loa...
Definition: ProcessMinidump.cpp:445
lldb_private::SectionList
Definition: Section.h:34
lldb::offset_t
uint64_t offset_t
Definition: lldb-types.h:87
lldb_private::MemoryRegionInfo
Definition: MemoryRegionInfo.h:21
lldb_private::ProcessInfo::SetProcessID
void SetProcessID(lldb::pid_t pid)
Definition: ProcessInfo.h:68
lldb_private::minidump::ProcessMinidump::GetOrCreateModule
lldb::ModuleSP GetOrCreateModule(lldb_private::UUID minidump_uuid, llvm::StringRef name, lldb_private::ModuleSpec module_spec)
Definition: ProcessMinidump.cpp:483
CommandObjectProcessMinidumpDump::m_dump_linux_proc_fd
OptionGroupBoolean m_dump_linux_proc_fd
Definition: ProcessMinidump.cpp:657
lldb_private::Stream
Definition: Stream.h:28
lldb_private::Process::SetID
void SetID(lldb::pid_t new_pid)
Sets the stored pid.
Definition: Process.h:531
lldb_private::Args
Definition: Args.h:33
lldb::eFormatBytesWithASCII
@ eFormatBytesWithASCII
Definition: lldb-enumerations.h:162
lldb_private::ArchSpec::GetTriple
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition: ArchSpec.h:463
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
CommandObjectProcessMinidumpDump::DumpLinuxAuxv
bool DumpLinuxAuxv() const
Definition: ProcessMinidump.cpp:736
lldb_private::OptionValueBoolean::GetCurrentValue
bool GetCurrentValue() const
Definition: OptionValueBoolean.h:70
CommandObjectProcessMinidumpDump::m_dump_linux_cpuinfo
OptionGroupBoolean m_dump_linux_cpuinfo
Definition: ProcessMinidump.cpp:648
CommandReturnObject.h
lldb_private::DumpDataExtractor
lldb::offset_t DumpDataExtractor(const DataExtractor &DE, Stream *s, lldb::offset_t offset, lldb::Format item_format, size_t item_byte_size, size_t item_count, size_t num_per_line, uint64_t base_addr, uint32_t item_bit_size, uint32_t item_bit_offset, ExecutionContextScope *exe_scope=nullptr, bool show_memory_tags=false)
Dumps item_count objects into the stream s.
Definition: DumpDataExtractor.cpp:342
lldb_private::Target
Definition: Target.h:469
Section.h
lldb_private::minidump::ProcessMinidump::GetMemoryRegions
Status GetMemoryRegions(lldb_private::MemoryRegionInfos &region_list) override
Obtain all the mapped memory regions within this process.
Definition: ProcessMinidump.cpp:452
lldb_private::Target::GetImages
const ModuleList & GetImages() const
Get accessor for the images for this process.
Definition: Target.h:947
APPEND_OPT
#define APPEND_OPT(VAR)
Definition: ProcessMinidump.cpp:640
lldb_private::minidump::ProcessMinidump::m_core_data
lldb::DataBufferSP m_core_data
Definition: ProcessMinidump.h:111
Target.h
lldb_private::ModuleSpec::GetUUID
UUID & GetUUID()
Definition: ModuleSpec.h:99
lldb_private::minidump::ProcessMinidump::~ProcessMinidump
~ProcessMinidump() override
Definition: ProcessMinidump.cpp:239
lldb_private::SectionList::AddSection
size_t AddSection(const lldb::SectionSP &section_sp)
Definition: Section.cpp:469
lldb_private::FileSpec
Definition: FileSpec.h:55
lldb_private::ThreadList::Clear
void Clear()
Definition: ThreadList.cpp:471
lldb_private::CommandObjectMultiword
Definition: CommandObjectMultiword.h:19
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::SectionLoadList::GetSectionLoadAddress
lldb::addr_t GetSectionLoadAddress(const lldb::SectionSP &section_sp) const
Definition: SectionLoadList.cpp:50
lldb_private::ThreadList::SetSelectedThreadByID
bool SetSelectedThreadByID(lldb::tid_t tid, bool notify=false)
Definition: ThreadList.cpp:696
CommandObjectProcessMinidumpDump::DumpFacebook
bool DumpFacebook() const
Definition: ProcessMinidump.cpp:752
lldb_private::Options
Definition: Options.h:57
CommandObjectProcessMinidumpDump::DumpLinuxCPUInfo
bool DumpLinuxCPUInfo() const
Definition: ProcessMinidump.cpp:712
CommandObjectProcessMinidumpDump::DumpLinuxEnviron
bool DumpLinuxEnviron() const
Definition: ProcessMinidump.cpp:732
LLDBAssert.h
lldb_private::PluginManager::UnregisterPlugin
static bool UnregisterPlugin(ABICreateInstance create_callback)
Definition: PluginManager.cpp:293
lldb_private::ModuleList::Remove
bool Remove(const lldb::ModuleSP &module_sp, bool notify=true)
Remove a module from the module list.
lldb_private::minidump::MinidumpParser::GetStream
llvm::ArrayRef< uint8_t > GetStream(StreamType stream_type)
Definition: MinidumpParser.cpp:47
lldb_private::DataExtractor
Definition: DataExtractor.h:48
lldb_private::ModuleList
Definition: ModuleList.h:82
Log.h
CommandObjectProcessMinidumpDump
Definition: ProcessMinidump.cpp:643
MemoryRegionInfo.h
UnixSignals.h
lldb_private::minidump::MinidumpParser::GetStreamTypeAsString
static llvm::StringRef GetStreamTypeAsString(StreamType stream_type)
Definition: MinidumpParser.cpp:633
lldb_private::DataExtractor::GetDataEnd
const uint8_t * GetDataEnd() const
Get the data end pointer.
Definition: DataExtractor.h:406
lldb_private::minidump::MinidumpParser
Definition: MinidumpParser.h:50
lldb_private::CommandReturnObject::SetStatus
void SetStatus(lldb::ReturnStatus status)
Definition: CommandReturnObject.cpp:127
lldb_private::minidump::ProcessMinidump
Definition: ProcessMinidump.h:29
lldb_private::minidump::ProcessMinidump::Clear
void Clear()
Definition: ProcessMinidump.cpp:458
CommandObjectProcessMinidumpDump::m_fb_logcat
OptionGroupBoolean m_fb_logcat
Definition: ProcessMinidump.cpp:669
lldb_private::minidump::MinidumpParser::GetMinidumpFile
llvm::object::MinidumpFile & GetMinidumpFile()
Definition: MinidumpParser.h:97
lldb_private::MemoryRegionInfo::eYes
@ eYes
Definition: MemoryRegionInfo.h:25
lldb_private::MemoryRegionInfos
Definition: MemoryRegionInfo.h:172
lldb_private::CommandReturnObject::GetOutputStream
Stream & GetOutputStream()
Definition: CommandReturnObject.h:46
lldb_private::Process::Finalize
virtual void Finalize()
This object is about to be destroyed, do any necessary cleanup.
Definition: Process.cpp:512
CommandObjectProcessMinidumpDump::m_dump_linux_proc_uptime
OptionGroupBoolean m_dump_linux_proc_uptime
Definition: ProcessMinidump.cpp:656
CommandObjectProcessMinidumpDump::DumpFacebookErrorLog
bool DumpFacebookErrorLog() const
Definition: ProcessMinidump.cpp:773
lldb_private::DataExtractor::GetDataStart
const uint8_t * GetDataStart() const
Get the data start pointer.
Definition: DataExtractor.h:422
lldb_private::Process::GetAddressByteSize
uint32_t GetAddressByteSize() const
Definition: Process.cpp:3366
lldb_private::ThreadList
Definition: ThreadList.h:26
lldb_private::ConstString
Definition: ConstString.h:39
lldb_private::minidump::ProcessMinidump::CreateInstance
static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const FileSpec *crash_file_path, bool can_connect)
Definition: ProcessMinidump.cpp:198
lldb_private::PostMortemProcess
Definition: PostMortemProcess.h:23
lldb_private::OptionGroupOptions::Finalize
void Finalize()
Definition: Options.cpp:784
CommandObjectProcessMinidumpDump::m_fb_app_data
OptionGroupBoolean m_fb_app_data
Definition: ProcessMinidump.cpp:659
lldb_private::SectionList::GetSectionAtIndex
lldb::SectionSP GetSectionAtIndex(size_t idx) const
Definition: Section.cpp:538
lldb_private::Range< lldb::addr_t, lldb::addr_t >
lldb_private::CommandInterpreter
Definition: CommandInterpreter.h:214
JITLoaderList.h
CommandObjectMultiword.h
lldb_private::ModuleList::ForEach
void ForEach(std::function< bool(const lldb::ModuleSP &module_sp)> const &callback) const
Definition: ModuleList.cpp:1067
CommandObjectProcessMinidumpDump::DumpFacebookDalvikInfo
bool DumpFacebookDalvikInfo() const
Definition: ProcessMinidump.cpp:767
lldb_private::minidump::ProcessMinidump::m_is_wow64
bool m_is_wow64
Definition: ProcessMinidump.h:115
CommandObjectProcessMinidumpDump::m_fb_dalvik
OptionGroupBoolean m_fb_dalvik
Definition: ProcessMinidump.cpp:663
lldb_private::SectionLoadList
Definition: SectionLoadList.h:22
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::Process::SetUnixSignals
void SetUnixSignals(lldb::UnixSignalsSP &&signals_sp)
Definition: Process.cpp:3352
CommandObjectProcessMinidumpDump::m_dump_linux_environ
OptionGroupBoolean m_dump_linux_environ
Definition: ProcessMinidump.cpp:652
DumpDataExtractor.h
CommandObjectProcessMinidumpDump::DumpFacebookUnwindSymbols
bool DumpFacebookUnwindSymbols() const
Definition: ProcessMinidump.cpp:770
CommandObjectProcessMinidumpDump::m_fb_version
OptionGroupBoolean m_fb_version
Definition: ProcessMinidump.cpp:661
lldb_private::CommandObject
Definition: CommandObject.h:68
lldb_private::minidump::ProcessMinidump::m_thread_list
llvm::ArrayRef< minidump::Thread > m_thread_list
Definition: ProcessMinidump.h:112
CommandObjectProcessMinidumpDump::DumpFacebookBuildID
bool DumpFacebookBuildID() const
Definition: ProcessMinidump.cpp:758
lldb_private::UUID::Clear
void Clear()
Definition: UUID.h:62
lldb_private::minidump::ProcessMinidump::DoDestroy
Status DoDestroy() override
Definition: ProcessMinidump.cpp:307
lldb::eSectionTypeOther
@ eSectionTypeOther
Definition: lldb-enumerations.h:704
lldb_private::minidump::ProcessMinidump::m_minidump_parser
llvm::Optional< MinidumpParser > m_minidump_parser
Definition: ProcessMinidump.h:90
lldb_private::minidump::ProcessMinidump::DoReadMemory
size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size, Status &error) override
Actually do the reading of memory from a process.
Definition: ProcessMinidump.cpp:378
CommandObjectProcessMinidumpDump::m_dump_directory
OptionGroupBoolean m_dump_directory
Definition: ProcessMinidump.cpp:647
lldbassert
#define lldbassert(x)
Definition: LLDBAssert.h:15
lldb_private::ModuleSpec::GetFileSpec
FileSpec & GetFileSpec()
Definition: ModuleSpec.h:53
lldb_private::ModuleSpec
Definition: ModuleSpec.h:27
lldb_private::OptionGroupBoolean
Definition: OptionGroupBoolean.h:18
lldb_private::Status
Definition: Status.h:44
lldb_private::FileSpec::ClearDirectory
void ClearDirectory()
Clear the directory in this object.
Definition: FileSpec.cpp:357
lldb_private::ArchSpec::GetArchitectureName
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
Definition: ArchSpec.cpp:547
CommandObjectProcessMinidumpDump::DumpLinux
bool DumpLinux() const
Definition: ProcessMinidump.cpp:709
lldb_private::Symtab
Definition: Symtab.h:22
lldb_private::CommandReturnObject
Definition: CommandReturnObject.h:26
uint32_t
lldb_private::LLDBLog::DynamicLoader
@ DynamicLoader
lldb_private::minidump::ProcessMinidump::DoUpdateThreadList
bool DoUpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) override
Update the thread list following process plug-in's specific logic.
Definition: ProcessMinidump.cpp:460
CommandObject.h
lldb::eReturnStatusSuccessFinishResult
@ eReturnStatusSuccessFinishResult
Definition: lldb-enumerations.h:262
lldb_private::minidump::ProcessMinidump::GetArchitecture
ArchSpec GetArchitecture()
Definition: ProcessMinidump.cpp:391
lldb_private::Address
Definition: Address.h:59
lldb_private::minidump::ProcessMinidump::ReadMemory
size_t ReadMemory(lldb::addr_t addr, void *buf, size_t size, Status &error) override
Read of memory from a process.
Definition: ProcessMinidump.cpp:371
lldb_private::OptionGroupBoolean::GetOptionValue
OptionValueBoolean & GetOptionValue()
Definition: OptionGroupBoolean.h:39
lldb_private::minidump::ProcessMinidump::m_command_sp
lldb::CommandObjectSP m_command_sp
Definition: ProcessMinidump.h:114
lldb_private::Type
Definition: Type.h:66
lldb_private::minidump::ProcessMinidump::DoLoadCore
Status DoLoadCore() override
Definition: ProcessMinidump.cpp:262
lldb_private::ThreadList::GetSize
uint32_t GetSize(bool can_update=true)
Definition: ThreadList.cpp:83
lldb_private::minidump::ProcessMinidump::WarnBeforeDetach
bool WarnBeforeDetach() const override
Before lldb detaches from a process, it warns the user that they are about to lose their debug sessio...
Definition: ProcessMinidump.cpp:369
lldb_private::minidump::ProcessMinidump::ReadModuleList
void ReadModuleList()
Definition: ProcessMinidump.cpp:530
CommandObjectProcessMinidumpDump::DumpDirectory
bool DumpDirectory() const
Definition: ProcessMinidump.cpp:705
CommandObjectProcessMinidumpDump::DumpFacebookVersionName
bool DumpFacebookVersionName() const
Definition: ProcessMinidump.cpp:761
lldb_private::DataExtractor::GetU32
uint32_t GetU32(lldb::offset_t *offset_ptr) const
Extract a uint32_t value from *offset_ptr.
Definition: DataExtractor.cpp:425
PluginManager.h
lldb_private::Target::GetSectionLoadList
SectionLoadList & GetSectionLoadList()
Definition: Target.h:1102
CommandObjectProcessMinidumpDump::DumpLinuxProcStatus
bool DumpLinuxProcStatus() const
Definition: ProcessMinidump.cpp:716
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:74
lldb_private::ModuleSpec::GetArchitecture
ArchSpec & GetArchitecture()
Definition: ModuleSpec.h:89
LLDB_LOG
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
Definition: Log.h:337
CommandObjectProcessMinidumpDump::m_fb_unwind
OptionGroupBoolean m_fb_unwind
Definition: ProcessMinidump.cpp:664
lldb_private::Stream::Printf
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
lldb_private::Process::GetID
lldb::pid_t GetID() const
Returns the pid of the process or LLDB_INVALID_PROCESS_ID if there is no known pid.
Definition: Process.h:526
CommandObjectProcessMinidumpDump::m_dump_linux_maps
OptionGroupBoolean m_dump_linux_maps
Definition: ProcessMinidump.cpp:654
lldb_private::minidump::ProcessMinidump::m_active_exception
const minidump::ExceptionStream * m_active_exception
Definition: ProcessMinidump.h:113
lldb_private::MemoryRegionInfo::GetRange
RangeType & GetRange()
Definition: MemoryRegionInfo.h:38
lldb_private::minidump::ProcessMinidump::GetProcessInfo
bool GetProcessInfo(ProcessInstanceInfo &info) override
Definition: ProcessMinidump.cpp:614
lldb_private::CommandReturnObject::AppendErrorWithFormat
void AppendErrorWithFormat(const char *format,...) __attribute__((format(printf
Definition: CommandReturnObject.cpp:46
lldb_private::PluginManager::RegisterPlugin
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
Definition: PluginManager.cpp:287
CommandObjectProcessMinidumpDump::DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override
Definition: ProcessMinidump.cpp:874
lldb_private::minidump::ProcessMinidump::Terminate
static void Terminate()
Definition: ProcessMinidump.cpp:258
lldb_private::StopInfoMachException::CreateStopReasonWithMachException
static lldb::StopInfoSP CreateStopReasonWithMachException(Thread &thread, uint32_t exc_type, uint32_t exc_data_count, uint64_t exc_code, uint64_t exc_sub_code, uint64_t exc_sub_sub_code, bool pc_already_adjusted=true, bool adjust_pc_if_needed=false)
Definition: StopInfoMachException.cpp:597
CommandObjectProcessMinidumpDump::DumpFacebookAbortReason
bool DumpFacebookAbortReason() const
Definition: ProcessMinidump.cpp:779
CommandObjectProcessMinidumpDump::m_fb_app_state
OptionGroupBoolean m_fb_app_state
Definition: ProcessMinidump.cpp:666
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
CommandObjectProcessMinidumpDump::m_dump_linux_auxv
OptionGroupBoolean m_dump_linux_auxv
Definition: ProcessMinidump.cpp:653
lldb_private::minidump::MinidumpParser::GetMemoryRegionInfo
static MemoryRegionInfo GetMemoryRegionInfo(const MemoryRegionInfos &regions, lldb::addr_t load_addr)
Definition: MinidumpParser.cpp:686
CommandObjectProcessMinidumpDump::m_fb_abort
OptionGroupBoolean m_fb_abort
Definition: ProcessMinidump.cpp:667
CommandObjectProcessMinidumpDump::DumpLinuxMaps
bool DumpLinuxMaps() const
Definition: ProcessMinidump.cpp:740
lldb_private::minidump::MinidumpParser::Create
static llvm::Expected< MinidumpParser > Create(const lldb::DataBufferSP &data_buf_sp)
Definition: MinidumpParser.cpp:29
CommandObjectProcessMinidumpDump::DumpLinuxProcFD
bool DumpLinuxProcFD() const
Definition: ProcessMinidump.cpp:748
CommandObjectProcessMinidumpDump::m_dump_linux_cmdline
OptionGroupBoolean m_dump_linux_cmdline
Definition: ProcessMinidump.cpp:651
CommandInterpreter.h
State.h
lldb_private::ThreadCollection::AddThread
void AddThread(const lldb::ThreadSP &thread_sp)
Definition: ThreadCollection.cpp:24
OptionGroupBoolean.h
CommandObjectProcessMinidumpDump::SetDefaultOptionsIfNoneAreSet
void SetDefaultOptionsIfNoneAreSet()
Definition: ProcessMinidump.cpp:672
LLDB_PLUGIN_DEFINE
#define LLDB_PLUGIN_DEFINE(PluginName)
Definition: PluginManager.h:31
CommandObjectProcessMinidumpDump::DumpFacebookJavaStack
bool DumpFacebookJavaStack() const
Definition: ProcessMinidump.cpp:764
lldb_private::Log
Definition: Log.h:115
lldb_private::minidump::ProcessMinidump::IsAlive
bool IsAlive() override
Check if a process is still alive.
Definition: ProcessMinidump.cpp:367
DumpDirectory
static void DumpDirectory(Stream &strm, const FileSpec *file_spec_ptr, uint32_t width)
Definition: CommandObjectTarget.cpp:1347
CommandObjectMultiwordProcessMinidump
Definition: ProcessMinidump.cpp:989
lldb_private::GetLog
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:309
lldb_private::FileSpec::GetPath
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition: FileSpec.cpp:364
lldb_private::ThreadList::GetSelectedThread
lldb::ThreadSP GetSelectedThread()
Definition: ThreadList.cpp:684
ProcessMinidump.h
lldb_private::StopInfo::CreateStopReasonWithException
static lldb::StopInfoSP CreateStopReasonWithException(Thread &thread, const char *description)
Definition: StopInfo.cpp:1392
lldb::eByteOrderLittle
@ eByteOrderLittle
Definition: lldb-enumerations.h:143
lldb_private::Args::GetArgumentCount
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
Definition: Args.h:116
CommandObjectProcessMinidumpDump::m_option_group
OptionGroupOptions m_option_group
Definition: ProcessMinidump.cpp:645
lldb_private::MemoryRegionInfo::GetMapped
OptionalBool GetMapped() const
Definition: MemoryRegionInfo.h:52
lldb
Definition: SBAddress.h:15
CommandObjectProcessMinidumpDump::DumpFacebookThreadName
bool DumpFacebookThreadName() const
Definition: ProcessMinidump.cpp:782
INIT_BOOL
#define INIT_BOOL(VAR, LONG, SHORT, DESC)
Definition: ProcessMinidump.cpp:638
lldb_private::UUID::GetBytes
llvm::ArrayRef< uint8_t > GetBytes() const
Definition: UUID.h:66
LLDBLog.h
CommandObjectProcessMinidumpDump::m_fb_error_log
OptionGroupBoolean m_fb_error_log
Definition: ProcessMinidump.cpp:665
lldb_private::ObjectFile
Definition: ObjectFile.h:60
lldb_private::ModuleList::Append
void Append(const lldb::ModuleSP &module_sp, bool notify=true)
Append a module to the module list.
lldb_private::Target::SetArchitecture
bool SetArchitecture(const ArchSpec &arch_spec, bool set_platform=false, bool merge=true)
Set the architecture for this target.
Definition: Target.cpp:1487
lldb::ByteOrder
ByteOrder
Byte ordering definitions.
Definition: lldb-enumerations.h:139
lldb_private::Target::MergeArchitecture
bool MergeArchitecture(const ArchSpec &arch_spec)
Definition: Target.cpp:1582
lldb_private::UnixSignals::Create
static lldb::UnixSignalsSP Create(const ArchSpec &arch)
Definition: UnixSignals.cpp:32
CommandObjectProcessMinidumpDump::m_fb_build_id
OptionGroupBoolean m_fb_build_id
Definition: ProcessMinidump.cpp:660
lldb_private::Process::m_jit_loaders_up
lldb::JITLoaderListUP m_jit_loaders_up
Definition: Process.h:2903
lldb_private::Range::GetRangeEnd
BaseType GetRangeEnd() const
Definition: RangeMap.h:78