mirror of
https://github.com/chromium/crashpad.git
synced 2024-12-27 15:32:10 +08:00
Reset CrashpadInfo after CrashpadInfoReader tests
In preference to (the reverted) https://chromium-review.googlesource.com/c/crashpad/crashpad/+/923178 this does not share implementation with the tests in snapshot/crashpad_info_client_options_test.cc. This is not done because those tests use faked CrashpadInfo structures that are intentionally differently sized than the current defintion of CrashpadInfo, meaning that the scoped reset could overwrite past the end of the structure. Not resetting these was causing CrashpadInfoClientOptions tests to fail on Fuchsia, because dlclose() [legally] doesn't do anything, so modifying the current binaries CrashpadInfo caused the expected values from child .sos to be ignored. That could be worked around in that test too, but it's probably better to clean up the global state in this test anyway. Bug: crashpad:196 Change-Id: Ia3f81f1d5872b5ef7d543fcc68b56af4c0b6ca0a Reviewed-on: https://chromium-review.googlesource.com/923561 Reviewed-by: Joshua Peraza <jperaza@chromium.org> Commit-Queue: Scott Graham <scottmg@chromium.org>
This commit is contained in:
parent
f9d160ffc6
commit
6798ba912e
@ -17,6 +17,8 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
#include "client/annotation_list.h"
|
#include "client/annotation_list.h"
|
||||||
#include "client/crashpad_info.h"
|
#include "client/crashpad_info.h"
|
||||||
@ -43,10 +45,32 @@ constexpr TriState kGatherIndirectlyReferencedMemory = TriState::kUnset;
|
|||||||
|
|
||||||
constexpr uint32_t kIndirectlyReferencedMemoryCap = 42;
|
constexpr uint32_t kIndirectlyReferencedMemoryCap = 42;
|
||||||
|
|
||||||
|
class ScopedUnsetCrashpadInfo {
|
||||||
|
public:
|
||||||
|
explicit ScopedUnsetCrashpadInfo(CrashpadInfo* crashpad_info)
|
||||||
|
: crashpad_info_(crashpad_info) {}
|
||||||
|
|
||||||
|
~ScopedUnsetCrashpadInfo() {
|
||||||
|
crashpad_info_->set_crashpad_handler_behavior(TriState::kUnset);
|
||||||
|
crashpad_info_->set_system_crash_reporter_forwarding(TriState::kUnset);
|
||||||
|
crashpad_info_->set_gather_indirectly_referenced_memory(TriState::kUnset,
|
||||||
|
0);
|
||||||
|
crashpad_info_->set_extra_memory_ranges(nullptr);
|
||||||
|
crashpad_info_->set_simple_annotations(nullptr);
|
||||||
|
crashpad_info_->set_annotations_list(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CrashpadInfo* crashpad_info_;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(ScopedUnsetCrashpadInfo);
|
||||||
|
};
|
||||||
|
|
||||||
class CrashpadInfoTestDataSetup {
|
class CrashpadInfoTestDataSetup {
|
||||||
public:
|
public:
|
||||||
CrashpadInfoTestDataSetup() {
|
CrashpadInfoTestDataSetup() {
|
||||||
CrashpadInfo* info = CrashpadInfo::GetCrashpadInfo();
|
CrashpadInfo* info = CrashpadInfo::GetCrashpadInfo();
|
||||||
|
unset_.reset(new ScopedUnsetCrashpadInfo(info));
|
||||||
|
|
||||||
info->set_extra_memory_ranges(&extra_memory_);
|
info->set_extra_memory_ranges(&extra_memory_);
|
||||||
info->set_simple_annotations(&simple_annotations_);
|
info->set_simple_annotations(&simple_annotations_);
|
||||||
@ -69,6 +93,7 @@ class CrashpadInfoTestDataSetup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::unique_ptr<ScopedUnsetCrashpadInfo> unset_;
|
||||||
SimpleAddressRangeBag extra_memory_;
|
SimpleAddressRangeBag extra_memory_;
|
||||||
SimpleStringDictionary simple_annotations_;
|
SimpleStringDictionary simple_annotations_;
|
||||||
AnnotationList annotation_list_;
|
AnnotationList annotation_list_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user