Add support for reading annotation objects in Crashpad modules

At the moment, the Minidump class only supports reading simple and
list annotations from Crashpad minidumps. This change adds support
for reading annotation objects stored in Crashpad modules
(MDRawModuleCrashpadInfo) and exposes them via a new getter in
MinidumpCrashpadInfo.

Change-Id: I033fc4a4fdff5901babc2472e0150f79af56b830
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/4195756
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
This commit is contained in:
Zaid Elkurdi 2023-01-25 15:56:36 -08:00 committed by Joshua Peraza
parent 2c86c995b4
commit a4f148b7a5
5 changed files with 155 additions and 0 deletions

View file

@ -1189,10 +1189,21 @@ class MinidumpLinuxMapsList : public MinidumpStream {
// at the time the minidump was generated.
class MinidumpCrashpadInfo : public MinidumpStream {
public:
struct AnnotationObject {
uint16_t type;
std::string name;
std::vector<uint8_t> value;
};
const MDRawCrashpadInfo* crashpad_info() const {
return valid_ ? &crashpad_info_ : NULL;
}
const std::vector<std::vector<AnnotationObject>>*
GetModuleCrashpadInfoAnnotationObjects() const {
return valid_ ? &module_crashpad_info_annotation_objects_ : NULL;
}
// Print a human-readable representation of the object to stdout.
void Print();
@ -1211,6 +1222,9 @@ class MinidumpCrashpadInfo : public MinidumpStream {
std::vector<std::vector<std::string>> module_crashpad_info_list_annotations_;
std::vector<std::map<std::string, std::string>>
module_crashpad_info_simple_annotations_;
std::vector<std::vector<AnnotationObject>>
module_crashpad_info_annotation_objects_;
std::map<std::string, std::string> simple_annotations_;
};
@ -1320,6 +1334,10 @@ class Minidump {
off_t offset,
std::map<std::string, std::string>* simple_string_dictionary);
bool ReadCrashpadAnnotationsList(
off_t offset,
std::vector<MinidumpCrashpadInfo::AnnotationObject>* annotations_list);
// SeekToStreamType positions the file at the beginning of a stream
// identified by stream_type, and informs the caller of the stream's
// length by setting *stream_length. Because stream_map maps each stream