2022-09-06 19:14:07 -04:00
|
|
|
|
// Copyright 2014 The Crashpad Authors
|
2014-10-07 17:27:11 -04:00
|
|
|
|
//
|
|
|
|
|
// 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.
|
|
|
|
|
|
2014-10-20 12:11:14 -04:00
|
|
|
|
#ifndef CRASHPAD_MINIDUMP_TEST_MINIDUMP_CONTEXT_TEST_UTIL_H_
|
|
|
|
|
#define CRASHPAD_MINIDUMP_TEST_MINIDUMP_CONTEXT_TEST_UTIL_H_
|
2014-10-07 17:27:11 -04:00
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
|
|
#include "minidump/minidump_context.h"
|
|
|
|
|
|
|
|
|
|
namespace crashpad {
|
|
|
|
|
namespace test {
|
|
|
|
|
|
|
|
|
|
//! \brief Initializes a context structure for testing.
|
|
|
|
|
//!
|
2014-11-03 17:43:39 -05:00
|
|
|
|
//! Initialization is compatible with the initialization used by CPUContext test
|
|
|
|
|
//! initialization functions such as InitializeCPUContextX86() and
|
|
|
|
|
//! InitializeCPUContextX86_64() for identical \a seed values.
|
|
|
|
|
//!
|
2014-10-07 17:27:11 -04:00
|
|
|
|
//! \param[out] context The structure to initialize.
|
|
|
|
|
//! \param[in] seed The seed value. Initializing two context structures of the
|
|
|
|
|
//! same type with identical seed values should produce identical context
|
|
|
|
|
//! structures. Initialization with a different seed value should produce
|
|
|
|
|
//! a different context structure. If \a seed is `0`, \a context is zeroed
|
|
|
|
|
//! out entirely except for the flags field, which will identify the context
|
2014-11-03 17:43:39 -05:00
|
|
|
|
//! type. If \a seed is nonzero, \a context will be populated entirely with
|
2014-10-07 17:27:11 -04:00
|
|
|
|
//! nonzero values.
|
|
|
|
|
//!
|
|
|
|
|
//! \{
|
|
|
|
|
void InitializeMinidumpContextX86(MinidumpContextX86* context, uint32_t seed);
|
|
|
|
|
void InitializeMinidumpContextAMD64(MinidumpContextAMD64* context,
|
|
|
|
|
uint32_t seed);
|
2018-01-30 12:41:09 -08:00
|
|
|
|
void InitializeMinidumpContextARM(MinidumpContextARM* context, uint32_t seed);
|
|
|
|
|
void InitializeMinidumpContextARM64(MinidumpContextARM64* context,
|
|
|
|
|
uint32_t seed);
|
2018-07-10 11:17:22 +02:00
|
|
|
|
void InitializeMinidumpContextMIPS(MinidumpContextMIPS* context, uint32_t seed);
|
|
|
|
|
void InitializeMinidumpContextMIPS64(MinidumpContextMIPS* context,
|
|
|
|
|
uint32_t seed);
|
2023-06-08 21:08:54 +00:00
|
|
|
|
void InitializeMinidumpContextRISCV64(MinidumpContextRISCV64* context,
|
|
|
|
|
uint32_t seed);
|
2014-10-07 17:27:11 -04:00
|
|
|
|
//! \}
|
|
|
|
|
|
2020-05-06 20:39:19 -04:00
|
|
|
|
//! \brief Verifies, via Google Test assertions, that a context structure
|
|
|
|
|
//! contains expected values.
|
2014-10-07 17:27:11 -04:00
|
|
|
|
//!
|
|
|
|
|
//! \param[in] expect_seed The seed value used to initialize a context
|
|
|
|
|
//! structure. This is the seed value used with
|
|
|
|
|
//! InitializeMinidumpContext*().
|
|
|
|
|
//! \param[in] observed The context structure to check. All fields of this
|
|
|
|
|
//! structure will be compared against the expected context structure, one
|
|
|
|
|
//! initialized with \a expect_seed.
|
2014-11-03 17:43:39 -05:00
|
|
|
|
//! \param[in] snapshot If `true`, compare \a observed to a context structure
|
|
|
|
|
//! expected to be produced from a CPUContext snapshot. If `false`, compare
|
|
|
|
|
//! \a observed to a native minidump context structure. CPUContext snapshot
|
|
|
|
|
//! structures may carry different sets of data than native minidump context
|
|
|
|
|
//! structures in meaningless ways. When `true`, fields not found in
|
|
|
|
|
//! CPUContext structures are expected to be `0`. When `false`, all fields
|
|
|
|
|
//! are compared. This makes it possible to test both that these fields are
|
|
|
|
|
//! passed through correctly by the native minidump writer and are zeroed
|
|
|
|
|
//! out when creating a minidump context structure from a CPUContext
|
|
|
|
|
//! structure.
|
2014-10-07 17:27:11 -04:00
|
|
|
|
//! \{
|
2014-11-03 17:43:39 -05:00
|
|
|
|
void ExpectMinidumpContextX86(
|
|
|
|
|
uint32_t expect_seed, const MinidumpContextX86* observed, bool snapshot);
|
|
|
|
|
void ExpectMinidumpContextAMD64(
|
|
|
|
|
uint32_t expect_seed, const MinidumpContextAMD64* observed, bool snapshot);
|
2018-01-30 12:41:09 -08:00
|
|
|
|
void ExpectMinidumpContextARM(uint32_t expect_seed,
|
|
|
|
|
const MinidumpContextARM* observed,
|
|
|
|
|
bool snapshot);
|
|
|
|
|
void ExpectMinidumpContextARM64(uint32_t expect_seed,
|
|
|
|
|
const MinidumpContextARM64* observed,
|
|
|
|
|
bool snapshot);
|
2018-07-10 11:17:22 +02:00
|
|
|
|
void ExpectMinidumpContextMIPS(uint32_t expect_seed,
|
|
|
|
|
const MinidumpContextMIPS* observed,
|
|
|
|
|
bool snapshot);
|
|
|
|
|
void ExpectMinidumpContextMIPS64(uint32_t expect_seed,
|
|
|
|
|
const MinidumpContextMIPS64* observed,
|
|
|
|
|
bool snapshot);
|
2023-06-08 21:08:54 +00:00
|
|
|
|
void ExpectMinidumpContextRISCV64(uint32_t expect_seed,
|
|
|
|
|
const MinidumpContextRISCV64* observed,
|
|
|
|
|
bool snapshot);
|
2014-10-07 17:27:11 -04:00
|
|
|
|
//! \}
|
|
|
|
|
|
|
|
|
|
} // namespace test
|
|
|
|
|
} // namespace crashpad
|
|
|
|
|
|
2014-10-20 12:11:14 -04:00
|
|
|
|
#endif // CRASHPAD_MINIDUMP_TEST_MINIDUMP_CONTEXT_TEST_UTIL_H_
|