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