mirror of
https://github.com/chromium/crashpad.git
synced 2024-12-27 07:14:10 +08:00
Revert "Reset CrashpadInfo after CrashpadInfoReader tests"
This reverts commit 4717300fa4cefadeabef64346ba65aa8759d43b8. Reason for revert: When used in with the size-testing fake CrashpadInfo's, this can overwrite past the end of them. Original change's description: > Reset CrashpadInfo after CrashpadInfoReader tests > > 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: Ia8119ac7c554bea81e8373e2547faf192c629122 > Reviewed-on: https://chromium-review.googlesource.com/923178 > Commit-Queue: Scott Graham <scottmg@chromium.org> > Reviewed-by: Joshua Peraza <jperaza@chromium.org> TBR=scottmg@chromium.org,jperaza@chromium.org Change-Id: Ia6d8db1ba24c82bb9346210ac8b66d80f42a6925 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: crashpad:196 Reviewed-on: https://chromium-review.googlesource.com/923541 Reviewed-by: Scott Graham <scottmg@chromium.org> Commit-Queue: Scott Graham <scottmg@chromium.org>
This commit is contained in:
parent
4717300fa4
commit
f9d160ffc6
@ -23,7 +23,6 @@
|
|||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "test/errors.h"
|
#include "test/errors.h"
|
||||||
#include "test/scoped_module_handle.h"
|
#include "test/scoped_module_handle.h"
|
||||||
#include "test/scoped_unset_crashpad_info.h"
|
|
||||||
#include "test/test_paths.h"
|
#include "test/test_paths.h"
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
@ -58,6 +57,25 @@ TEST(CrashpadInfoClientOptions, TriStateFromCrashpadInfo) {
|
|||||||
TriState::kUnset);
|
TriState::kUnset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ScopedUnsetCrashpadInfoOptions {
|
||||||
|
public:
|
||||||
|
explicit ScopedUnsetCrashpadInfoOptions(CrashpadInfo* crashpad_info)
|
||||||
|
: crashpad_info_(crashpad_info) {
|
||||||
|
}
|
||||||
|
|
||||||
|
~ScopedUnsetCrashpadInfoOptions() {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CrashpadInfo* crashpad_info_;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(ScopedUnsetCrashpadInfoOptions);
|
||||||
|
};
|
||||||
|
|
||||||
CrashpadInfoClientOptions SelfProcessSnapshotAndGetCrashpadOptions() {
|
CrashpadInfoClientOptions SelfProcessSnapshotAndGetCrashpadOptions() {
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
ProcessSnapshotMac process_snapshot;
|
ProcessSnapshotMac process_snapshot;
|
||||||
@ -91,7 +109,7 @@ TEST(CrashpadInfoClientOptions, OneModule) {
|
|||||||
ASSERT_TRUE(crashpad_info);
|
ASSERT_TRUE(crashpad_info);
|
||||||
|
|
||||||
{
|
{
|
||||||
ScopedUnsetCrashpadInfo unset(crashpad_info);
|
ScopedUnsetCrashpadInfoOptions unset(crashpad_info);
|
||||||
|
|
||||||
crashpad_info->set_crashpad_handler_behavior(TriState::kEnabled);
|
crashpad_info->set_crashpad_handler_behavior(TriState::kEnabled);
|
||||||
|
|
||||||
@ -103,7 +121,7 @@ TEST(CrashpadInfoClientOptions, OneModule) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
ScopedUnsetCrashpadInfo unset(crashpad_info);
|
ScopedUnsetCrashpadInfoOptions unset(crashpad_info);
|
||||||
|
|
||||||
crashpad_info->set_system_crash_reporter_forwarding(TriState::kDisabled);
|
crashpad_info->set_system_crash_reporter_forwarding(TriState::kDisabled);
|
||||||
|
|
||||||
@ -115,7 +133,7 @@ TEST(CrashpadInfoClientOptions, OneModule) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
ScopedUnsetCrashpadInfo unset(crashpad_info);
|
ScopedUnsetCrashpadInfoOptions unset(crashpad_info);
|
||||||
|
|
||||||
crashpad_info->set_gather_indirectly_referenced_memory(TriState::kEnabled,
|
crashpad_info->set_gather_indirectly_referenced_memory(TriState::kEnabled,
|
||||||
1234);
|
1234);
|
||||||
@ -170,8 +188,8 @@ TEST(CrashpadInfoClientOptions, TwoModules) {
|
|||||||
ASSERT_TRUE(remote_crashpad_info);
|
ASSERT_TRUE(remote_crashpad_info);
|
||||||
|
|
||||||
{
|
{
|
||||||
ScopedUnsetCrashpadInfo unset_local(local_crashpad_info);
|
ScopedUnsetCrashpadInfoOptions unset_local(local_crashpad_info);
|
||||||
ScopedUnsetCrashpadInfo unset_remote(remote_crashpad_info);
|
ScopedUnsetCrashpadInfoOptions unset_remote(remote_crashpad_info);
|
||||||
|
|
||||||
// When only one module sets a value, it applies to the entire process.
|
// When only one module sets a value, it applies to the entire process.
|
||||||
remote_crashpad_info->set_crashpad_handler_behavior(TriState::kEnabled);
|
remote_crashpad_info->set_crashpad_handler_behavior(TriState::kEnabled);
|
||||||
@ -193,8 +211,8 @@ TEST(CrashpadInfoClientOptions, TwoModules) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
ScopedUnsetCrashpadInfo unset_local(local_crashpad_info);
|
ScopedUnsetCrashpadInfoOptions unset_local(local_crashpad_info);
|
||||||
ScopedUnsetCrashpadInfo unset_remote(remote_crashpad_info);
|
ScopedUnsetCrashpadInfoOptions unset_remote(remote_crashpad_info);
|
||||||
|
|
||||||
// When only one module sets a value, it applies to the entire process.
|
// When only one module sets a value, it applies to the entire process.
|
||||||
remote_crashpad_info->set_system_crash_reporter_forwarding(
|
remote_crashpad_info->set_system_crash_reporter_forwarding(
|
||||||
@ -263,7 +281,7 @@ TEST_P(CrashpadInfoSizes_ClientOptions, DifferentlySizedStruct) {
|
|||||||
ASSERT_TRUE(remote_crashpad_info);
|
ASSERT_TRUE(remote_crashpad_info);
|
||||||
|
|
||||||
{
|
{
|
||||||
ScopedUnsetCrashpadInfo unset_remote(remote_crashpad_info);
|
ScopedUnsetCrashpadInfoOptions unset_remote(remote_crashpad_info);
|
||||||
|
|
||||||
// Make sure that a change in the remote structure can be read back out,
|
// Make sure that a change in the remote structure can be read back out,
|
||||||
// even though it’s a different size.
|
// even though it’s a different size.
|
||||||
@ -278,7 +296,7 @@ TEST_P(CrashpadInfoSizes_ClientOptions, DifferentlySizedStruct) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
ScopedUnsetCrashpadInfo unset_remote(remote_crashpad_info);
|
ScopedUnsetCrashpadInfoOptions unset_remote(remote_crashpad_info);
|
||||||
|
|
||||||
// Make sure that the portion of the remote structure lying beyond its
|
// Make sure that the portion of the remote structure lying beyond its
|
||||||
// declared size reads as zero.
|
// declared size reads as zero.
|
||||||
|
@ -14,8 +14,6 @@
|
|||||||
|
|
||||||
#include "snapshot/crashpad_types/crashpad_info_reader.h"
|
#include "snapshot/crashpad_types/crashpad_info_reader.h"
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
@ -27,7 +25,6 @@
|
|||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "test/multiprocess_exec.h"
|
#include "test/multiprocess_exec.h"
|
||||||
#include "test/process_type.h"
|
#include "test/process_type.h"
|
||||||
#include "test/scoped_unset_crashpad_info.h"
|
|
||||||
#include "util/file/file_io.h"
|
#include "util/file/file_io.h"
|
||||||
#include "util/misc/from_pointer_cast.h"
|
#include "util/misc/from_pointer_cast.h"
|
||||||
#include "util/process/process_memory_native.h"
|
#include "util/process/process_memory_native.h"
|
||||||
@ -50,7 +47,6 @@ 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_);
|
||||||
@ -73,7 +69,6 @@ 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_;
|
||||||
|
@ -40,7 +40,6 @@ static_library("test") {
|
|||||||
"scoped_module_handle.h",
|
"scoped_module_handle.h",
|
||||||
"scoped_temp_dir.cc",
|
"scoped_temp_dir.cc",
|
||||||
"scoped_temp_dir.h",
|
"scoped_temp_dir.h",
|
||||||
"scoped_unset_crashpad_info.h",
|
|
||||||
"test_paths.cc",
|
"test_paths.cc",
|
||||||
"test_paths.h",
|
"test_paths.h",
|
||||||
]
|
]
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
// Copyright 2018 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_TEST_SCOPED_UNSET_CRASHPAD_INFO_H_
|
|
||||||
#define CRASHPAD_TEST_SCOPED_UNSET_CRASHPAD_INFO_H_
|
|
||||||
|
|
||||||
#include "base/macros.h"
|
|
||||||
#include "client/crashpad_info.h"
|
|
||||||
|
|
||||||
namespace crashpad {
|
|
||||||
namespace test {
|
|
||||||
|
|
||||||
//! \brief Resets members of CrashpadInfo to default state when destroyed.
|
|
||||||
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);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace test
|
|
||||||
} // namespace crashpad
|
|
||||||
|
|
||||||
#endif // CRASHPAD_TEST_SCOPED_UNSET_CRASHPAD_INFO_H_
|
|
@ -71,7 +71,6 @@
|
|||||||
'scoped_temp_dir.h',
|
'scoped_temp_dir.h',
|
||||||
'scoped_temp_dir_posix.cc',
|
'scoped_temp_dir_posix.cc',
|
||||||
'scoped_temp_dir_win.cc',
|
'scoped_temp_dir_win.cc',
|
||||||
'scoped_unset_crashpad_info.h',
|
|
||||||
'test_paths.cc',
|
'test_paths.cc',
|
||||||
'test_paths.h',
|
'test_paths.h',
|
||||||
'win/child_launcher.cc',
|
'win/child_launcher.cc',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user