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