mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 14:06:33 +00:00
All minidump objects now own their all of their children, rather than having them maintain weak pointers and requiring callers to maintain ownership. The only weak object in the entire tree now is the “extra memory” added to a MinidumpMemoryListWriter by its AddExtraMemory() method. Extra memory aliases objects owned elsewhere in the tree, typically by a MinidumpThreadWriter as stack memory. Non-“extra” memory added to a MinidumpMemoryListWriter by its AddMemory() method is strongly owned. Many objects are now deleted through base pointers, and in those cases, the base classes now have public virtual destructors. The ultimate base, MinidumpWritable, is still protected to guard against direct instantiation and deletion, and thus its destructor does not need to be virtual. This updates mini_chromium to eeb3b6a4f020 specifically for that revision, which includes necessary updates to scoped_ptr. It also picks up: eeb3b6a4f020 Update base/move.h and base/memory/scoped_ptr.h to match 67ad2efafaba More porting to Windows be27a006421e AUTHORS: Fix link post-git migration flag day. 05f5b1503230 Add codereview.settings to mini_chromium. a32c2b199811 Beginnings of Windows support in mini_chromium TEST=minidump_test R=rsesek@chromium.org Review URL: https://codereview.chromium.org/674153002
185 lines
7.1 KiB
C++
185 lines
7.1 KiB
C++
// Copyright 2014 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_MINIDUMP_MINIDUMP_SYSTEM_INFO_WRITER_H_
|
|
#define CRASHPAD_MINIDUMP_MINIDUMP_SYSTEM_INFO_WRITER_H_
|
|
|
|
#include <dbghelp.h>
|
|
#include <stdint.h>
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "base/basictypes.h"
|
|
#include "base/memory/scoped_ptr.h"
|
|
#include "minidump/minidump_extensions.h"
|
|
#include "minidump/minidump_stream_writer.h"
|
|
#include "minidump/minidump_writable.h"
|
|
|
|
namespace crashpad {
|
|
|
|
namespace internal {
|
|
class MinidumpUTF16StringWriter;
|
|
} // namespace internal
|
|
|
|
//! \brief The writer for a MINIDUMP_SYSTEM_INFO stream in a minidump file.
|
|
class MinidumpSystemInfoWriter final : public internal::MinidumpStreamWriter {
|
|
public:
|
|
MinidumpSystemInfoWriter();
|
|
~MinidumpSystemInfoWriter() override;
|
|
|
|
//! \brief Sets MINIDUMP_SYSTEM_INFO::ProcessorArchitecture.
|
|
void SetCPUArchitecture(MinidumpCPUArchitecture processor_architecture) {
|
|
system_info_.ProcessorArchitecture = processor_architecture;
|
|
}
|
|
|
|
//! \brief Sets MINIDUMP_SYSTEM_INFO::ProcessorLevel and
|
|
//! MINIDUMP_SYSTEM_INFO::ProcessorRevision.
|
|
void SetCPULevelAndRevision(uint16_t processor_level,
|
|
uint16_t processor_revision) {
|
|
system_info_.ProcessorLevel = processor_level;
|
|
system_info_.ProcessorRevision = processor_revision;
|
|
}
|
|
|
|
//! \brief Sets MINIDUMP_SYSTEM_INFO::NumberOfProcessors.
|
|
void SetCPUCount(uint8_t number_of_processors) {
|
|
system_info_.NumberOfProcessors = number_of_processors;
|
|
}
|
|
|
|
//! \brief Sets MINIDUMP_SYSTEM_INFO::PlatformId.
|
|
void SetOS(MinidumpOS platform_id) { system_info_.PlatformId = platform_id; }
|
|
|
|
//! \brief Sets MINIDUMP_SYSTEM_INFO::ProductType.
|
|
void SetOSType(MinidumpOSType product_type) {
|
|
system_info_.ProductType = product_type;
|
|
}
|
|
|
|
//! \brief Sets MINIDUMP_SYSTEM_INFO::MajorVersion,
|
|
//! MINIDUMP_SYSTEM_INFO::MinorVersion, and
|
|
//! MINIDUMP_SYSTEM_INFO::BuildNumber.
|
|
void SetOSVersion(uint32_t major_version,
|
|
uint32_t minor_version,
|
|
uint32_t build_number) {
|
|
system_info_.MajorVersion = major_version;
|
|
system_info_.MinorVersion = minor_version;
|
|
system_info_.BuildNumber = build_number;
|
|
}
|
|
|
|
//! \brief Arranges for MINIDUMP_SYSTEM_INFO::CSDVersionRva to point to a
|
|
//! MINIDUMP_STRING containing the supplied string.
|
|
//!
|
|
//! This method must be called prior to Freeze(). A CSD version is required
|
|
//! in all MINIDUMP_SYSTEM_INFO streams. An empty string is an acceptable
|
|
//! value.
|
|
void SetCSDVersion(const std::string& csd_version);
|
|
|
|
//! \brief Sets MINIDUMP_SYSTEM_INFO::SuiteMask.
|
|
void SetSuiteMask(uint16_t suite_mask) {
|
|
system_info_.SuiteMask = suite_mask;
|
|
}
|
|
|
|
//! \brief Sets \ref CPU_INFORMATION::VendorId
|
|
//! "MINIDUMP_SYSTEM_INFO::Cpu::X86CpuInfo::VendorId".
|
|
//!
|
|
//! This is only valid if SetCPUArchitecture() has been used to set the CPU
|
|
//! architecture to #kMinidumpCPUArchitectureX86 or
|
|
//! #kMinidumpCPUArchitectureX86Win64.
|
|
//!
|
|
//! \param[in] ebx The first 4 bytes of the CPU vendor string, the value
|
|
//! reported in `cpuid 0` `ebx`.
|
|
//! \param[in] edx The middle 4 bytes of the CPU vendor string, the value
|
|
//! reported in `cpuid 0` `edx`.
|
|
//! \param[in] ecx The last 4 bytes of the CPU vendor string, the value
|
|
//! reported by `cpuid 0` `ecx`.
|
|
//!
|
|
//! \note Do not call this method if SetCPUArchitecture() has been used to set
|
|
//! the CPU architecture to #kMinidumpCPUArchitectureAMD64.
|
|
//!
|
|
//! \sa SetCPUX86VendorString()
|
|
void SetCPUX86Vendor(uint32_t ebx, uint32_t edx, uint32_t ecx);
|
|
|
|
//! \brief Sets \ref CPU_INFORMATION::VendorId
|
|
//! "MINIDUMP_SYSTEM_INFO::Cpu::X86CpuInfo::VendorId".
|
|
//!
|
|
//! This is only valid if SetCPUArchitecture() has been used to set the CPU
|
|
//! architecture to #kMinidumpCPUArchitectureX86 or
|
|
//! #kMinidumpCPUArchitectureX86Win64.
|
|
//!
|
|
//! \param[in] vendor The entire CPU vendor string, which must be exactly 12
|
|
//! bytes long.
|
|
//!
|
|
//! \note Do not call this method if SetCPUArchitecture() has been used to set
|
|
//! the CPU architecture to #kMinidumpCPUArchitectureAMD64.
|
|
//!
|
|
//! \sa SetCPUX86Vendor()
|
|
void SetCPUX86VendorString(const std::string& vendor);
|
|
|
|
//! \brief Sets \ref CPU_INFORMATION::VersionInformation
|
|
//! "MINIDUMP_SYSTEM_INFO::Cpu::X86CpuInfo::VersionInformation" and
|
|
//! \ref CPU_INFORMATION::FeatureInformation
|
|
//! "MINIDUMP_SYSTEM_INFO::Cpu::X86CpuInfo::FeatureInformation".
|
|
//!
|
|
//! This is only valid if SetCPUArchitecture() has been used to set the CPU
|
|
//! architecture to #kMinidumpCPUArchitectureX86 or
|
|
//! #kMinidumpCPUArchitectureX86Win64.
|
|
//!
|
|
//! \note Do not call this method if SetCPUArchitecture() has been used to set
|
|
//! the CPU architecture to #kMinidumpCPUArchitectureAMD64.
|
|
void SetCPUX86VersionAndFeatures(uint32_t version, uint32_t features);
|
|
|
|
//! \brief Sets \ref CPU_INFORMATION::AMDExtendedCpuFeatures
|
|
//! "MINIDUMP_SYSTEM_INFO::Cpu::X86CpuInfo::AMDExtendedCPUFeatures".
|
|
//!
|
|
//! This is only valid if SetCPUArchitecture() has been used to set the CPU
|
|
//! architecture to #kMinidumpCPUArchitectureX86 or
|
|
//! #kMinidumpCPUArchitectureX86Win64, and if SetCPUX86Vendor() or
|
|
//! SetCPUX86VendorString() has been used to set the CPU vendor to
|
|
//! “AuthenticAMD”.
|
|
//!
|
|
//! \note Do not call this method if SetCPUArchitecture() has been used to set
|
|
//! the CPU architecture to #kMinidumpCPUArchitectureAMD64.
|
|
void SetCPUX86AMDExtendedFeatures(uint32_t extended_features);
|
|
|
|
//! \brief Sets \ref CPU_INFORMATION::ProcessorFeatures
|
|
//! "MINIDUMP_SYSTEM_INFO::Cpu::OtherCpuInfo::ProcessorFeatures".
|
|
//!
|
|
//! This is only valid if SetCPUArchitecture() has been used to set the CPU
|
|
//! architecture to an architecture other than #kMinidumpCPUArchitectureX86
|
|
//! or #kMinidumpCPUArchitectureX86Win64.
|
|
//!
|
|
//! \note This method may be called if SetCPUArchitecture() has been used to
|
|
//! set the CPU architecture to #kMinidumpCPUArchitectureAMD64.
|
|
void SetCPUOtherFeatures(uint64_t features_0, uint64_t features_1);
|
|
|
|
protected:
|
|
// MinidumpWritable:
|
|
bool Freeze() override;
|
|
size_t SizeOfObject() override;
|
|
std::vector<MinidumpWritable*> Children() override;
|
|
bool WriteObject(FileWriterInterface* file_writer) override;
|
|
|
|
// MinidumpStreamWriter:
|
|
MinidumpStreamType StreamType() const override;
|
|
|
|
private:
|
|
MINIDUMP_SYSTEM_INFO system_info_;
|
|
scoped_ptr<internal::MinidumpUTF16StringWriter> csd_version_;
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(MinidumpSystemInfoWriter);
|
|
};
|
|
|
|
} // namespace crashpad
|
|
|
|
#endif // CRASHPAD_MINIDUMP_MINIDUMP_SYSTEM_INFO_WRITER_H_
|