LLDB mainline
MinidumpTypes.h
Go to the documentation of this file.
1//===-- MinidumpTypes.h -----------------------------------------*- C++ -*-===//
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#ifndef LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_MINIDUMPTYPES_H
10#define LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_MINIDUMPTYPES_H
11
12#include "lldb/Utility/Status.h"
13
14#include "llvm/ADT/ArrayRef.h"
15#include "llvm/ADT/BitmaskEnum.h"
16#include "llvm/ADT/SmallVector.h"
17#include "llvm/ADT/StringRef.h"
18#include "llvm/BinaryFormat/Minidump.h"
19#include "llvm/Support/ConvertUTF.h"
20#include "llvm/Support/Endian.h"
21#include <optional>
22
23// C includes
24// C++ includes
25
26// Reference:
27// https://msdn.microsoft.com/en-us/library/windows/desktop/ms679293(v=vs.85).aspx
28// https://chromium.googlesource.com/breakpad/breakpad/
29
30namespace lldb_private {
31
32namespace minidump {
33
34using namespace llvm::minidump;
35
37
38enum class CvSignature : uint32_t {
39 Pdb70 = 0x53445352, // RSDS
40 ElfBuildId = 0x4270454c, // BpEL (Breakpad/Crashpad minidumps)
41};
42
43enum class MinidumpMiscInfoFlags : uint32_t {
44 ProcessID = (1 << 0),
45 ProcessTimes = (1 << 1),
46 LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ ProcessTimes)
47};
48
49template <typename T>
50Status consumeObject(llvm::ArrayRef<uint8_t> &Buffer, const T *&Object) {
51 if (Buffer.size() < sizeof(T))
52 return Status::FromErrorString("Insufficient buffer!");
53
54 Object = reinterpret_cast<const T *>(Buffer.data());
55 Buffer = Buffer.drop_front(sizeof(T));
56 return Status();
57}
58
60 llvm::support::ulittle64_t start_of_memory_range;
61 llvm::support::ulittle64_t data_size;
62};
63static_assert(sizeof(MinidumpMemoryDescriptor64) == 16,
64 "sizeof MinidumpMemoryDescriptor64 is not correct!");
65
66// TODO misc2, misc3 ?
67// Reference:
68// https://msdn.microsoft.com/en-us/library/windows/desktop/ms680389(v=vs.85).aspx
70 llvm::support::ulittle32_t size;
71 // flags1 represents what info in the struct is valid
72 llvm::support::ulittle32_t flags1;
73 llvm::support::ulittle32_t process_id;
74 llvm::support::ulittle32_t process_create_time;
75 llvm::support::ulittle32_t process_user_time;
76 llvm::support::ulittle32_t process_kernel_time;
77
78 static const MinidumpMiscInfo *Parse(llvm::ArrayRef<uint8_t> &data);
79
80 std::optional<lldb::pid_t> GetPid() const;
81};
82static_assert(sizeof(MinidumpMiscInfo) == 24,
83 "sizeof MinidumpMiscInfo is not correct!");
84
85// The /proc/pid/status is saved as an ascii string in the file
87public:
88 llvm::StringRef proc_status;
90
91 static std::optional<LinuxProcStatus> Parse(llvm::ArrayRef<uint8_t> &data);
92
93 lldb::pid_t GetPid() const;
94
95private:
96 LinuxProcStatus() = default;
97};
98
99} // namespace minidump
100} // namespace lldb_private
101#endif // LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_MINIDUMPTYPES_H
An error handling class.
Definition: Status.h:118
static Status FromErrorString(const char *str)
Definition: Status.h:141
static std::optional< LinuxProcStatus > Parse(llvm::ArrayRef< uint8_t > &data)
Status consumeObject(llvm::ArrayRef< uint8_t > &Buffer, const T *&Object)
Definition: MinidumpTypes.h:50
A class that represents a running process on the host machine.
uint64_t pid_t
Definition: lldb-types.h:83
llvm::support::ulittle32_t process_kernel_time
Definition: MinidumpTypes.h:76
llvm::support::ulittle32_t process_id
Definition: MinidumpTypes.h:73
llvm::support::ulittle32_t process_user_time
Definition: MinidumpTypes.h:75
llvm::support::ulittle32_t flags1
Definition: MinidumpTypes.h:72
llvm::support::ulittle32_t size
Definition: MinidumpTypes.h:70
static const MinidumpMiscInfo * Parse(llvm::ArrayRef< uint8_t > &data)
llvm::support::ulittle32_t process_create_time
Definition: MinidumpTypes.h:74
std::optional< lldb::pid_t > GetPid() const