# RUN: %lldb -c %p/Inputs/dump-content.dmp -o 'process plugin dump -u' | FileCheck --check-prefix=CHECKUP %s
# RUN: %lldb -c %p/Inputs/dump-content.dmp -o 'process plugin dump --fd' | FileCheck --check-prefix=CHECKFD %s
# RUN: %lldb -c %p/Inputs/dump-content.dmp -o 'process plugin dump -f' | FileCheck --check-prefix=CHECKFD %s
-# CHECKDIR: RVA SIZE TYPE MinidumpStreamType
+# CHECKDIR: RVA SIZE TYPE StreamType
# CHECKDIR-NEXT: ---------- ---------- ---------- --------------------------
# CHECKDIR-NEXT: 0x000000b0 0x00000038 0x00000007 SystemInfo
# CHECKDIR-NEXT: 0x0000015d 0x0000001b 0x47670007 LinuxEnviron
# RUN: %lldb -c %p/Inputs/fb-dump-content.dmp \
# RUN: -o 'process plugin dump --fb-logcat' | \
# RUN: FileCheck --check-prefix=CHECK-LOGCAT %s
-# CHECK-DIR: RVA SIZE TYPE MinidumpStreamType
+# CHECK-DIR: RVA SIZE TYPE StreamType
# CHECK-DIR-NEXT: ---------- ---------- ---------- --------------------------
# CHECK-DIR-NEXT: 0x0000010c 0x00000013 0xfacecb00 FacebookDumpErrorLog
# CHECK-DIR-NEXT: 0x0000011f 0x00000015 0xfacee000 FacebookThreadName
lldbPluginProcessUtility
lldbPluginProcessElfCore
LINK_COMPONENTS
+ BinaryFormat
Support
)
}
llvm::ArrayRef<uint8_t>
-MinidumpParser::GetStream(MinidumpStreamType stream_type) {
+MinidumpParser::GetStream(StreamType stream_type) {
auto iter = m_directory_map.find(static_cast<uint32_t>(stream_type));
if (iter == m_directory_map.end())
return {};
}
llvm::ArrayRef<MinidumpThread> MinidumpParser::GetThreads() {
- llvm::ArrayRef<uint8_t> data = GetStream(MinidumpStreamType::ThreadList);
+ llvm::ArrayRef<uint8_t> data = GetStream(StreamType::ThreadList);
if (data.size() == 0)
return llvm::None;
}
const MinidumpSystemInfo *MinidumpParser::GetSystemInfo() {
- llvm::ArrayRef<uint8_t> data = GetStream(MinidumpStreamType::SystemInfo);
+ llvm::ArrayRef<uint8_t> data = GetStream(StreamType::SystemInfo);
if (data.size() == 0)
return nullptr;
llvm::Triple triple;
triple.setVendor(llvm::Triple::VendorType::UnknownVendor);
- const MinidumpCPUArchitecture arch = static_cast<MinidumpCPUArchitecture>(
+ auto arch = static_cast<ProcessorArchitecture>(
static_cast<uint32_t>(system_info->processor_arch));
switch (arch) {
- case MinidumpCPUArchitecture::X86:
+ case ProcessorArchitecture::X86:
triple.setArch(llvm::Triple::ArchType::x86);
break;
- case MinidumpCPUArchitecture::AMD64:
+ case ProcessorArchitecture::AMD64:
triple.setArch(llvm::Triple::ArchType::x86_64);
break;
- case MinidumpCPUArchitecture::ARM:
+ case ProcessorArchitecture::ARM:
triple.setArch(llvm::Triple::ArchType::arm);
break;
- case MinidumpCPUArchitecture::ARM64:
+ case ProcessorArchitecture::ARM64:
triple.setArch(llvm::Triple::ArchType::aarch64);
break;
default:
break;
}
- const MinidumpOSPlatform os = static_cast<MinidumpOSPlatform>(
- static_cast<uint32_t>(system_info->platform_id));
+ auto os =
+ static_cast<OSPlatform>(static_cast<uint32_t>(system_info->platform_id));
// TODO add all of the OSes that Minidump/breakpad distinguishes?
switch (os) {
- case MinidumpOSPlatform::Win32S:
- case MinidumpOSPlatform::Win32Windows:
- case MinidumpOSPlatform::Win32NT:
- case MinidumpOSPlatform::Win32CE:
+ case OSPlatform::Win32S:
+ case OSPlatform::Win32Windows:
+ case OSPlatform::Win32NT:
+ case OSPlatform::Win32CE:
triple.setOS(llvm::Triple::OSType::Win32);
break;
- case MinidumpOSPlatform::Linux:
+ case OSPlatform::Linux:
triple.setOS(llvm::Triple::OSType::Linux);
break;
- case MinidumpOSPlatform::MacOSX:
+ case OSPlatform::MacOSX:
triple.setOS(llvm::Triple::OSType::MacOSX);
triple.setVendor(llvm::Triple::Apple);
break;
- case MinidumpOSPlatform::IOS:
+ case OSPlatform::IOS:
triple.setOS(llvm::Triple::OSType::IOS);
triple.setVendor(llvm::Triple::Apple);
break;
- case MinidumpOSPlatform::Android:
+ case OSPlatform::Android:
triple.setOS(llvm::Triple::OSType::Linux);
triple.setEnvironment(llvm::Triple::EnvironmentType::Android);
break;
}
const MinidumpMiscInfo *MinidumpParser::GetMiscInfo() {
- llvm::ArrayRef<uint8_t> data = GetStream(MinidumpStreamType::MiscInfo);
+ llvm::ArrayRef<uint8_t> data = GetStream(StreamType::MiscInfo);
if (data.size() == 0)
return nullptr;
}
llvm::Optional<LinuxProcStatus> MinidumpParser::GetLinuxProcStatus() {
- llvm::ArrayRef<uint8_t> data = GetStream(MinidumpStreamType::LinuxProcStatus);
+ llvm::ArrayRef<uint8_t> data = GetStream(StreamType::LinuxProcStatus);
if (data.size() == 0)
return llvm::None;
}
llvm::ArrayRef<MinidumpModule> MinidumpParser::GetModuleList() {
- llvm::ArrayRef<uint8_t> data = GetStream(MinidumpStreamType::ModuleList);
+ llvm::ArrayRef<uint8_t> data = GetStream(StreamType::ModuleList);
if (data.size() == 0)
return {};
}
const MinidumpExceptionStream *MinidumpParser::GetExceptionStream() {
- llvm::ArrayRef<uint8_t> data = GetStream(MinidumpStreamType::Exception);
+ llvm::ArrayRef<uint8_t> data = GetStream(StreamType::Exception);
if (data.size() == 0)
return nullptr;
llvm::Optional<minidump::Range>
MinidumpParser::FindMemoryRange(lldb::addr_t addr) {
- llvm::ArrayRef<uint8_t> data = GetStream(MinidumpStreamType::MemoryList);
- llvm::ArrayRef<uint8_t> data64 = GetStream(MinidumpStreamType::Memory64List);
+ llvm::ArrayRef<uint8_t> data = GetStream(StreamType::MemoryList);
+ llvm::ArrayRef<uint8_t> data64 = GetStream(StreamType::Memory64List);
if (data.empty() && data64.empty())
return llvm::None;
static bool
CreateRegionsCacheFromLinuxMaps(MinidumpParser &parser,
std::vector<MemoryRegionInfo> ®ions) {
- auto data = parser.GetStream(MinidumpStreamType::LinuxMaps);
+ auto data = parser.GetStream(StreamType::LinuxMaps);
if (data.empty())
return false;
ParseLinuxMapRegions(llvm::toStringRef(data),
static bool
CreateRegionsCacheFromMemoryInfoList(MinidumpParser &parser,
std::vector<MemoryRegionInfo> ®ions) {
- auto data = parser.GetStream(MinidumpStreamType::MemoryInfoList);
+ auto data = parser.GetStream(StreamType::MemoryInfoList);
if (data.empty())
return false;
auto mem_info_list = MinidumpMemoryInfo::ParseMemoryInfoList(data);
static bool
CreateRegionsCacheFromMemoryList(MinidumpParser &parser,
std::vector<MemoryRegionInfo> ®ions) {
- auto data = parser.GetStream(MinidumpStreamType::MemoryList);
+ auto data = parser.GetStream(StreamType::MemoryList);
if (data.empty())
return false;
auto memory_list = MinidumpMemoryDescriptor::ParseMemoryList(data);
CreateRegionsCacheFromMemory64List(MinidumpParser &parser,
std::vector<MemoryRegionInfo> ®ions) {
llvm::ArrayRef<uint8_t> data =
- parser.GetStream(MinidumpStreamType::Memory64List);
+ parser.GetStream(StreamType::Memory64List);
if (data.empty())
return false;
llvm::ArrayRef<MinidumpMemoryDescriptor64> memory64_list;
return m_regions;
}
-#define ENUM_TO_CSTR(ST) case (uint32_t)MinidumpStreamType::ST: return #ST
+#define ENUM_TO_CSTR(ST) case (uint32_t)StreamType::ST: return #ST
llvm::StringRef
MinidumpParser::GetStreamTypeAsString(uint32_t stream_type) {
switch (stream_type) {
ENUM_TO_CSTR(Unused);
- ENUM_TO_CSTR(Reserved0);
- ENUM_TO_CSTR(Reserved1);
ENUM_TO_CSTR(ThreadList);
ENUM_TO_CSTR(ModuleList);
ENUM_TO_CSTR(MemoryList);
llvm::ArrayRef<uint8_t> GetData();
- llvm::ArrayRef<uint8_t> GetStream(MinidumpStreamType stream_type);
+ llvm::ArrayRef<uint8_t> GetStream(StreamType stream_type);
llvm::Optional<std::string> GetMinidumpString(uint32_t rva);
const MinidumpHeader *header = nullptr;
Status error = consumeObject(data, header);
- const MinidumpHeaderConstants signature =
- static_cast<MinidumpHeaderConstants>(
- static_cast<uint32_t>(header->signature));
- const MinidumpHeaderConstants version = static_cast<MinidumpHeaderConstants>(
- static_cast<uint32_t>(header->version) & 0x0000ffff);
+ uint32_t signature = header->signature;
+ uint32_t version = header->version & 0x0000ffff;
// the high 16 bits of the version field are implementation specific
- if (error.Fail() || signature != MinidumpHeaderConstants::Signature ||
- version != MinidumpHeaderConstants::Version)
+ if (error.Fail() || signature != Header::MagicSignature ||
+ version != Header::MagicVersion)
return nullptr;
return header;
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/BinaryFormat/Minidump.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/Endian.h"
namespace minidump {
-LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
-
-enum class MinidumpHeaderConstants : uint32_t {
- Signature = 0x504d444d, // 'PMDM'
- Version = 0x0000a793, // 42899
- LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ Signature)
+using namespace llvm::minidump;
-};
+LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
enum class CvSignature : uint32_t {
Pdb70 = 0x53445352, // RSDS
static_assert(sizeof(CvRecordPdb70) == 20,
"sizeof CvRecordPdb70 is not correct!");
-// Reference:
-// https://msdn.microsoft.com/en-us/library/windows/desktop/ms680394.aspx
-enum class MinidumpStreamType : uint32_t {
- Unused = 0,
- Reserved0 = 1,
- Reserved1 = 2,
- ThreadList = 3,
- ModuleList = 4,
- MemoryList = 5,
- Exception = 6,
- SystemInfo = 7,
- ThreadExList = 8,
- Memory64List = 9,
- CommentA = 10,
- CommentW = 11,
- HandleData = 12,
- FunctionTable = 13,
- UnloadedModuleList = 14,
- MiscInfo = 15,
- MemoryInfoList = 16,
- ThreadInfoList = 17,
- HandleOperationList = 18,
- Token = 19,
- JavascriptData = 20,
- SystemMemoryInfo = 21,
- ProcessVMCounters = 22,
- LastReserved = 0x0000ffff,
-
- /* Breakpad extension types. 0x4767 = "Gg" */
- BreakpadInfo = 0x47670001,
- AssertionInfo = 0x47670002,
- /* These are additional minidump stream values which are specific to
- * the linux breakpad implementation. */
- LinuxCPUInfo = 0x47670003, /* /proc/cpuinfo */
- LinuxProcStatus = 0x47670004, /* /proc/$x/status */
- LinuxLSBRelease = 0x47670005, /* /etc/lsb-release */
- LinuxCMDLine = 0x47670006, /* /proc/$x/cmdline */
- LinuxEnviron = 0x47670007, /* /proc/$x/environ */
- LinuxAuxv = 0x47670008, /* /proc/$x/auxv */
- LinuxMaps = 0x47670009, /* /proc/$x/maps */
- LinuxDSODebug = 0x4767000A,
- LinuxProcStat = 0x4767000B, /* /proc/$x/stat */
- LinuxProcUptime = 0x4767000C, /* uptime */
- LinuxProcFD = 0x4767000D, /* /proc/$x/fb */
- FacebookAppCustomData = 0xFACECAFA,
- FacebookBuildID = 0xFACECAFB,
- FacebookAppVersionName = 0xFACECAFC,
- FacebookJavaStack = 0xFACECAFD,
- FacebookDalvikInfo = 0xFACECAFE,
- FacebookUnwindSymbols = 0xFACECAFF,
- FacebookDumpErrorLog = 0xFACECB00,
- FacebookAppStateLog = 0xFACECCCC,
- FacebookAbortReason = 0xFACEDEAD,
- FacebookThreadName = 0xFACEE000,
- FacebookLogcat = 0xFACE1CA7,
-
-};
-
-// for MinidumpSystemInfo.processor_arch
-enum class MinidumpCPUArchitecture : uint16_t {
- X86 = 0, /* PROCESSOR_ARCHITECTURE_INTEL */
- MIPS = 1, /* PROCESSOR_ARCHITECTURE_MIPS */
- Alpha = 2, /* PROCESSOR_ARCHITECTURE_ALPHA */
- PPC = 3, /* PROCESSOR_ARCHITECTURE_PPC */
- SHX = 4, /* PROCESSOR_ARCHITECTURE_SHX (Super-H) */
- ARM = 5, /* PROCESSOR_ARCHITECTURE_ARM */
- IA64 = 6, /* PROCESSOR_ARCHITECTURE_IA64 */
- Alpha64 = 7, /* PROCESSOR_ARCHITECTURE_ALPHA64 */
- MSIL = 8, /* PROCESSOR_ARCHITECTURE_MSIL
- * (Microsoft Intermediate Language) */
- AMD64 = 9, /* PROCESSOR_ARCHITECTURE_AMD64 */
- X86Win64 = 10, /* PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 (WoW64) */
- SPARC = 0x8001, /* Breakpad-defined value for SPARC */
- PPC64 = 0x8002, /* Breakpad-defined value for PPC64 */
- ARM64 = 0x8003, /* Breakpad-defined value for ARM64 */
- MIPS64 = 0x8004, /* Breakpad-defined value for MIPS64 */
- Unknown = 0xffff /* PROCESSOR_ARCHITECTURE_UNKNOWN */
-};
-
-// for MinidumpSystemInfo.platform_id
-enum class MinidumpOSPlatform : uint32_t {
- Win32S = 0, /* VER_PLATFORM_WIN32s (Windows 3.1) */
- Win32Windows = 1, /* VER_PLATFORM_WIN32_WINDOWS (Windows 95-98-Me) */
- Win32NT = 2, /* VER_PLATFORM_WIN32_NT (Windows NT, 2000+) */
- Win32CE = 3, /* VER_PLATFORM_WIN32_CE, VER_PLATFORM_WIN32_HH
- * (Windows CE, Windows Mobile, "Handheld") */
-
- /* The following values are Breakpad-defined. */
- Unix = 0x8000, /* Generic Unix-ish */
- MacOSX = 0x8101, /* Mac OS X/Darwin */
- IOS = 0x8102, /* iOS */
- Linux = 0x8201, /* Linux */
- Solaris = 0x8202, /* Solaris */
- Android = 0x8203, /* Android */
- PS3 = 0x8204, /* PS3 */
- NaCl = 0x8205 /* Native Client (NaCl) */
-};
-
-// For MinidumpCPUInfo.arm_cpu_info.elf_hwcaps.
-// This matches the Linux kernel definitions from <asm/hwcaps.h>
-enum class MinidumpPCPUInformationARMElfHwCaps : uint32_t {
- SWP = (1 << 0),
- Half = (1 << 1),
- Thumb = (1 << 2),
- _26BIT = (1 << 3),
- FastMult = (1 << 4),
- FPA = (1 << 5),
- VFP = (1 << 6),
- EDSP = (1 << 7),
- Java = (1 << 8),
- IWMMXT = (1 << 9),
- Crunch = (1 << 10),
- ThumbEE = (1 << 11),
- Neon = (1 << 12),
- VFPv3 = (1 << 13),
- VFPv3D16 = (1 << 14),
- TLS = (1 << 15),
- VFPv4 = (1 << 16),
- IDIVA = (1 << 17),
- IDIVT = (1 << 18),
- LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ IDIVT)
-};
-
enum class MinidumpMiscInfoFlags : uint32_t {
ProcessID = (1 << 0),
ProcessTimes = (1 << 1),
Stream &s = result.GetOutputStream();
MinidumpParser &minidump = *process->m_minidump_parser;
if (DumpDirectory()) {
- s.Printf("RVA SIZE TYPE MinidumpStreamType\n");
+ s.Printf("RVA SIZE TYPE StreamType\n");
s.Printf("---------- ---------- ---------- --------------------------\n");
for (const auto &pair: minidump.GetDirectoryMap())
s.Printf("0x%8.8x 0x%8.8x 0x%8.8x %s\n", (uint32_t)pair.second.rva,
MinidumpParser::GetStreamTypeAsString(pair.first).data());
s.Printf("\n");
}
- auto DumpTextStream = [&](MinidumpStreamType stream_type,
+ auto DumpTextStream = [&](StreamType stream_type,
llvm::StringRef label) -> void {
auto bytes = minidump.GetStream(stream_type);
if (!bytes.empty()) {
s.Printf("%s:\n%s\n\n", label.data(), bytes.data());
}
};
- auto DumpBinaryStream = [&](MinidumpStreamType stream_type,
+ auto DumpBinaryStream = [&](StreamType stream_type,
llvm::StringRef label) -> void {
auto bytes = minidump.GetStream(stream_type);
if (!bytes.empty()) {
};
if (DumpLinuxCPUInfo())
- DumpTextStream(MinidumpStreamType::LinuxCPUInfo, "/proc/cpuinfo");
+ DumpTextStream(StreamType::LinuxCPUInfo, "/proc/cpuinfo");
if (DumpLinuxProcStatus())
- DumpTextStream(MinidumpStreamType::LinuxProcStatus, "/proc/PID/status");
+ DumpTextStream(StreamType::LinuxProcStatus, "/proc/PID/status");
if (DumpLinuxLSBRelease())
- DumpTextStream(MinidumpStreamType::LinuxLSBRelease, "/etc/lsb-release");
+ DumpTextStream(StreamType::LinuxLSBRelease, "/etc/lsb-release");
if (DumpLinuxCMDLine())
- DumpTextStream(MinidumpStreamType::LinuxCMDLine, "/proc/PID/cmdline");
+ DumpTextStream(StreamType::LinuxCMDLine, "/proc/PID/cmdline");
if (DumpLinuxEnviron())
- DumpTextStream(MinidumpStreamType::LinuxEnviron, "/proc/PID/environ");
+ DumpTextStream(StreamType::LinuxEnviron, "/proc/PID/environ");
if (DumpLinuxAuxv())
- DumpBinaryStream(MinidumpStreamType::LinuxAuxv, "/proc/PID/auxv");
+ DumpBinaryStream(StreamType::LinuxAuxv, "/proc/PID/auxv");
if (DumpLinuxMaps())
- DumpTextStream(MinidumpStreamType::LinuxMaps, "/proc/PID/maps");
+ DumpTextStream(StreamType::LinuxMaps, "/proc/PID/maps");
if (DumpLinuxProcStat())
- DumpTextStream(MinidumpStreamType::LinuxProcStat, "/proc/PID/stat");
+ DumpTextStream(StreamType::LinuxProcStat, "/proc/PID/stat");
if (DumpLinuxProcUptime())
- DumpTextStream(MinidumpStreamType::LinuxProcUptime, "uptime");
+ DumpTextStream(StreamType::LinuxProcUptime, "uptime");
if (DumpLinuxProcFD())
- DumpTextStream(MinidumpStreamType::LinuxProcFD, "/proc/PID/fd");
+ DumpTextStream(StreamType::LinuxProcFD, "/proc/PID/fd");
if (DumpFacebookAppData())
- DumpTextStream(MinidumpStreamType::FacebookAppCustomData,
+ DumpTextStream(StreamType::FacebookAppCustomData,
"Facebook App Data");
if (DumpFacebookBuildID()) {
- auto bytes = minidump.GetStream(MinidumpStreamType::FacebookBuildID);
+ auto bytes = minidump.GetStream(StreamType::FacebookBuildID);
if (bytes.size() >= 4) {
DataExtractor data(bytes.data(), bytes.size(), eByteOrderLittle,
process->GetAddressByteSize());
}
}
if (DumpFacebookVersionName())
- DumpTextStream(MinidumpStreamType::FacebookAppVersionName,
+ DumpTextStream(StreamType::FacebookAppVersionName,
"Facebook Version String");
if (DumpFacebookJavaStack())
- DumpTextStream(MinidumpStreamType::FacebookJavaStack,
+ DumpTextStream(StreamType::FacebookJavaStack,
"Facebook Java Stack");
if (DumpFacebookDalvikInfo())
- DumpTextStream(MinidumpStreamType::FacebookDalvikInfo,
+ DumpTextStream(StreamType::FacebookDalvikInfo,
"Facebook Dalvik Info");
if (DumpFacebookUnwindSymbols())
- DumpBinaryStream(MinidumpStreamType::FacebookUnwindSymbols,
+ DumpBinaryStream(StreamType::FacebookUnwindSymbols,
"Facebook Unwind Symbols Bytes");
if (DumpFacebookErrorLog())
- DumpTextStream(MinidumpStreamType::FacebookDumpErrorLog,
+ DumpTextStream(StreamType::FacebookDumpErrorLog,
"Facebook Error Log");
if (DumpFacebookAppStateLog())
- DumpTextStream(MinidumpStreamType::FacebookAppStateLog,
+ DumpTextStream(StreamType::FacebookAppStateLog,
"Faceook Application State Log");
if (DumpFacebookAbortReason())
- DumpTextStream(MinidumpStreamType::FacebookAbortReason,
+ DumpTextStream(StreamType::FacebookAbortReason,
"Facebook Abort Reason");
if (DumpFacebookThreadName())
- DumpTextStream(MinidumpStreamType::FacebookThreadName,
+ DumpTextStream(StreamType::FacebookThreadName,
"Facebook Thread Name");
if (DumpFacebookLogcat())
- DumpTextStream(MinidumpStreamType::FacebookLogcat,
+ DumpTextStream(StreamType::FacebookLogcat,
"Facebook Logcat");
return true;
}