crashpad/util/ios/ios_intermediate_dump_reader.h
Justin Cohen 3a7e935a86 ios: Handle partial intermediate dumps and exception contexts.
Testing in beta has shown a few examples of a cropped intermediate dump
still providing useful information, but due to the order intermediate
dump data is written, could be improved.

- Change the order of writing data to the intermediate dump by
increasing the priority of the Exception block from:
 Header / Process / System / Threads/ Modules / Exception
to
 Header / Process / System / Exception / Threads / Modules

- Annotate minidump reports generated from incomplete intermediate
dumps with the key 'crashpad_intermediate_dump_incomplete'.

- Handle partial exception contexts rather than throwing them away.

Change-Id: I543c1d3135c42e5b8e339e498ea0c86002f37ea3
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3294862
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2021-11-22 21:07:13 +00:00

78 lines
2.8 KiB
C++

// Copyright 2021 The Crashpad Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef CRASHPAD_UTIL_IOS_IOS_INTERMEDIATE_DUMP_READER_H_
#define CRASHPAD_UTIL_IOS_IOS_INTERMEDIATE_DUMP_READER_H_
#include "util/ios/ios_intermediate_dump_interface.h"
#include "util/ios/ios_intermediate_dump_map.h"
#include "util/misc/initialization_state_dcheck.h"
namespace crashpad {
namespace internal {
//! \brief The return value for IOSIntermediateDumpReader::Initialize.
enum class IOSIntermediateDumpReaderInitializeResult : int {
//! \brief The intermediate dump was read successfully, initialization
//! succeeded.
kSuccess,
//! \brief The intermediate dump could be loaded, but parsing was incomplete.
//! An attempt to parse the RootMap should still be made, as there may
//! still be valuable information to put into a minidump.
kIncomplete,
//! \brief The intermediate dump could not be loaded, initialization failed.
kFailure,
};
//! \brief Open and parse iOS intermediate dumps.
class IOSIntermediateDumpReader {
public:
IOSIntermediateDumpReader() {}
IOSIntermediateDumpReader(const IOSIntermediateDumpReader&) = delete;
IOSIntermediateDumpReader& operator=(const IOSIntermediateDumpReader&) =
delete;
//! \brief Open and parses \a dump_interface.
//!
//! Will attempt to parse the binary file, similar to a JSON file, using the
//! same format used by IOSIntermediateDumpWriter, resulting in an
//! IOSIntermediateDumpMap
//!
//! \param[in] dump_interface An interface corresponding to an intermediate
//! dump file.
//!
//! \return On success, returns `true`, otherwise returns `false`. Clients may
//! still attempt to parse RootMap, as partial minidumps may still be
//! usable.
IOSIntermediateDumpReaderInitializeResult Initialize(
const IOSIntermediateDumpInterface& dump_interface);
//! \brief Returns an IOSIntermediateDumpMap corresponding to the root of the
//! intermediate dump.
const IOSIntermediateDumpMap* RootMap();
private:
bool Parse(FileReaderInterface* reader, FileOffset file_size);
IOSIntermediateDumpMap intermediate_dump_;
InitializationStateDcheck initialized_;
};
} // namespace internal
} // namespace crashpad
#endif // CRASHPAD_UTIL_IOS_IOS_INTERMEDIATE_DUMP_READER_H_