mirror of
https://github.com/chromium/crashpad.git
synced 2024-12-27 15:32:10 +08:00
Create snapshot/mac and move some files from snapshot and util to there.
TEST=snapshot_test, util_test CheckedMachAddressRange.* R=rsesek@chromium.org Review URL: https://codereview.chromium.org/666483002
This commit is contained in:
parent
dd9cf1b367
commit
bcae4d94d5
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "snapshot/cpu_context_mac.h"
|
||||
#include "snapshot/mac/cpu_context_mac.h"
|
||||
|
||||
#include <string.h>
|
||||
|
@ -12,8 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef CRASHPAD_SNAPSHOT_SNAPSHOT_CPU_CONTEXT_MAC_H_
|
||||
#define CRASHPAD_SNAPSHOT_SNAPSHOT_CPU_CONTEXT_MAC_H_
|
||||
#ifndef CRASHPAD_SNAPSHOT_MAC_SNAPSHOT_CPU_CONTEXT_MAC_H_
|
||||
#define CRASHPAD_SNAPSHOT_MAC_SNAPSHOT_CPU_CONTEXT_MAC_H_
|
||||
|
||||
#include <mach/mach.h>
|
||||
|
||||
@ -112,4 +112,4 @@ void InitializeCPUContextX86_64(CPUContextX86_64* context,
|
||||
} // namespace internal
|
||||
} // namespace crashpad
|
||||
|
||||
#endif // CRASHPAD_SNAPSHOT_SNAPSHOT_CPU_CONTEXT_MAC_H_
|
||||
#endif // CRASHPAD_SNAPSHOT_MAC_SNAPSHOT_CPU_CONTEXT_MAC_H_
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "snapshot/cpu_context_mac.h"
|
||||
#include "snapshot/mac/cpu_context_mac.h"
|
||||
|
||||
#include <mach/mach.h>
|
||||
|
@ -12,12 +12,12 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "snapshot/exception_snapshot_mac.h"
|
||||
#include "snapshot/mac/exception_snapshot_mac.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "snapshot/cpu_context_mac.h"
|
||||
#include "util/mac/process_reader.h"
|
||||
#include "snapshot/mac/cpu_context_mac.h"
|
||||
#include "snapshot/mac/process_reader.h"
|
||||
#include "util/mach/exc_server_variants.h"
|
||||
#include "util/numeric/safe_assignment.h"
|
||||
|
@ -12,8 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef CRASHPAD_SNAPSHOT_EXCEPTION_SNAPSHOT_MAC_H_
|
||||
#define CRASHPAD_SNAPSHOT_EXCEPTION_SNAPSHOT_MAC_H_
|
||||
#ifndef CRASHPAD_SNAPSHOT_MAC_EXCEPTION_SNAPSHOT_MAC_H_
|
||||
#define CRASHPAD_SNAPSHOT_MAC_EXCEPTION_SNAPSHOT_MAC_H_
|
||||
|
||||
#include <mach/mach.h>
|
||||
#include <stdint.h>
|
||||
@ -88,4 +88,4 @@ class ExceptionSnapshotMac final : public ExceptionSnapshot {
|
||||
} // namespace internal
|
||||
} // namespace crashpad
|
||||
|
||||
#endif // CRASHPAD_SNAPSHOT_EXCEPTION_SNAPSHOT_MAC_H_
|
||||
#endif // CRASHPAD_SNAPSHOT_MAC_EXCEPTION_SNAPSHOT_MAC_H_
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "util/mac/mach_o_image_reader.h"
|
||||
#include "snapshot/mac/mach_o_image_reader.h"
|
||||
|
||||
#include <mach-o/loader.h>
|
||||
#include <mach-o/nlist.h>
|
||||
@ -23,10 +23,10 @@
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "snapshot/mac/mach_o_image_segment_reader.h"
|
||||
#include "snapshot/mac/mach_o_image_symbol_table_reader.h"
|
||||
#include "snapshot/mac/process_reader.h"
|
||||
#include "util/mac/checked_mach_address_range.h"
|
||||
#include "util/mac/mach_o_image_segment_reader.h"
|
||||
#include "util/mac/mach_o_image_symbol_table_reader.h"
|
||||
#include "util/mac/process_reader.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@ -267,7 +267,7 @@ bool MachOImageReader::Initialize(ProcessReader* process_reader,
|
||||
mach_vm_address_t slid_segment_address = segment->Address();
|
||||
mach_vm_size_t slid_segment_size = segment->Size();
|
||||
CheckedMachAddressRange slid_segment_range(
|
||||
process_reader_, slid_segment_address, slid_segment_size);
|
||||
process_reader_->Is64Bit(), slid_segment_address, slid_segment_size);
|
||||
if (!slid_segment_range.IsValid()) {
|
||||
LOG(WARNING) << base::StringPrintf(
|
||||
"invalid slid segment range 0x%llx + 0x%llx, "
|
||||
@ -415,7 +415,7 @@ bool MachOImageReader::LookUpExternalDefinedSymbol(
|
||||
// to slide. In non-PIE executables, __mh_execute_header is an absolute
|
||||
// symbol.
|
||||
CheckedMachAddressRange section_range(
|
||||
process_reader_, section_address, section->size);
|
||||
process_reader_->Is64Bit(), section_address, section->size);
|
||||
if (!section_range.ContainsValue(slid_value) &&
|
||||
!(symbol_info->section == 1 && segment->Name() == SEG_TEXT &&
|
||||
slid_value == Address())) {
|
@ -12,8 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef CRASHPAD_UTIL_MAC_MACH_O_IMAGE_READER_H_
|
||||
#define CRASHPAD_UTIL_MAC_MACH_O_IMAGE_READER_H_
|
||||
#ifndef CRASHPAD_SNAPSHOT_MAC_MACH_O_IMAGE_READER_H_
|
||||
#define CRASHPAD_SNAPSHOT_MAC_MACH_O_IMAGE_READER_H_
|
||||
|
||||
#include <mach/mach.h>
|
||||
#include <stdint.h>
|
||||
@ -23,10 +23,10 @@
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "snapshot/mac/process_types.h"
|
||||
#include "util/misc/initialization_state_dcheck.h"
|
||||
#include "util/misc/uuid.h"
|
||||
#include "util/stdlib/pointer_container.h"
|
||||
#include "util/mac/process_types.h"
|
||||
|
||||
namespace crashpad {
|
||||
|
||||
@ -54,7 +54,7 @@ class MachOImageReader {
|
||||
//! where the `mach_header` or `mach_header_64` at the beginning of the
|
||||
//! image to be read is located. This address can be determined by reading
|
||||
//! the remote process’ dyld information (see
|
||||
//! util/mac/process_types/dyld_images.proctype).
|
||||
//! snapshot/mac/process_types/dyld_images.proctype).
|
||||
//! \param[in] name The module’s name, a string to be used in logged messages.
|
||||
//! This string is for diagnostic purposes only, and may be empty.
|
||||
//!
|
||||
@ -340,4 +340,4 @@ class MachOImageReader {
|
||||
|
||||
} // namespace crashpad
|
||||
|
||||
#endif // CRASHPAD_UTIL_MAC_MACH_O_IMAGE_READER_H_
|
||||
#endif // CRASHPAD_SNAPSHOT_MAC_MACH_O_IMAGE_READER_H_
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "util/mac/mach_o_image_reader.h"
|
||||
#include "snapshot/mac/mach_o_image_reader.h"
|
||||
|
||||
#include <AvailabilityMacros.h>
|
||||
#include <dlfcn.h>
|
||||
@ -27,9 +27,9 @@
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "build/build_config.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "util/mac/mach_o_image_segment_reader.h"
|
||||
#include "util/mac/process_reader.h"
|
||||
#include "util/mac/process_types.h"
|
||||
#include "snapshot/mac/mach_o_image_segment_reader.h"
|
||||
#include "snapshot/mac/process_reader.h"
|
||||
#include "snapshot/mac/process_types.h"
|
||||
#include "util/misc/uuid.h"
|
||||
#include "util/test/mac/dyld.h"
|
||||
|
@ -12,14 +12,14 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "util/mac/mach_o_image_segment_reader.h"
|
||||
#include "snapshot/mac/mach_o_image_segment_reader.h"
|
||||
|
||||
#include <mach-o/loader.h>
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "snapshot/mac/process_reader.h"
|
||||
#include "util/mac/checked_mach_address_range.h"
|
||||
#include "util/mac/process_reader.h"
|
||||
#include "util/stdlib/strnlen.h"
|
||||
|
||||
namespace crashpad {
|
||||
@ -79,8 +79,9 @@ bool MachOImageSegmentReader::Initialize(ProcessReader* process_reader,
|
||||
|
||||
// This checks the unslid segment range. The slid range (as loaded into
|
||||
// memory) will be checked later by MachOImageReader.
|
||||
CheckedMachAddressRange segment_range(
|
||||
process_reader, segment_command_.vmaddr, segment_command_.vmsize);
|
||||
CheckedMachAddressRange segment_range(process_reader->Is64Bit(),
|
||||
segment_command_.vmaddr,
|
||||
segment_command_.vmsize);
|
||||
if (!segment_range.IsValid()) {
|
||||
LOG(WARNING) << base::StringPrintf("invalid segment range 0x%llx + 0x%llx",
|
||||
segment_command_.vmaddr,
|
||||
@ -120,7 +121,7 @@ bool MachOImageSegmentReader::Initialize(ProcessReader* process_reader,
|
||||
}
|
||||
|
||||
CheckedMachAddressRange section_range(
|
||||
process_reader, section.addr, section.size);
|
||||
process_reader->Is64Bit(), section.addr, section.size);
|
||||
if (!section_range.IsValid()) {
|
||||
LOG(WARNING) << base::StringPrintf(
|
||||
"invalid section range 0x%llx + 0x%llx",
|
@ -12,8 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef CRASHPAD_UTIL_MAC_MACH_O_IMAGE_SEGMENT_READER_H_
|
||||
#define CRASHPAD_UTIL_MAC_MACH_O_IMAGE_SEGMENT_READER_H_
|
||||
#ifndef CRASHPAD_SNAPSHOT_MAC_MACH_O_IMAGE_SEGMENT_READER_H_
|
||||
#define CRASHPAD_SNAPSHOT_MAC_MACH_O_IMAGE_SEGMENT_READER_H_
|
||||
|
||||
#include <mach/mach.h>
|
||||
#include <stdint.h>
|
||||
@ -24,7 +24,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "util/mac/process_types.h"
|
||||
#include "snapshot/mac/process_types.h"
|
||||
#include "util/misc/initialization_state_dcheck.h"
|
||||
|
||||
namespace crashpad {
|
||||
@ -252,4 +252,4 @@ class MachOImageSegmentReader {
|
||||
|
||||
} // namespace crashpad
|
||||
|
||||
#endif // CRASHPAD_UTIL_MAC_MACH_O_IMAGE_SEGMENT_READER_H_
|
||||
#endif // CRASHPAD_SNAPSHOT_MAC_MACH_O_IMAGE_SEGMENT_READER_H_
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "util/mac/mach_o_image_segment_reader.h"
|
||||
#include "snapshot/mac/mach_o_image_segment_reader.h"
|
||||
|
||||
#include <mach-o/loader.h>
|
||||
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "util/mac/mach_o_image_symbol_table_reader.h"
|
||||
#include "snapshot/mac/mach_o_image_symbol_table_reader.h"
|
||||
|
||||
#include <mach-o/loader.h>
|
||||
#include <mach-o/nlist.h>
|
||||
@ -43,8 +43,9 @@ class MachOImageSymbolTableReaderInitializer {
|
||||
linkedit_range_(),
|
||||
process_reader_(process_reader),
|
||||
linkedit_segment_(linkedit_segment) {
|
||||
linkedit_range_.SetRange(
|
||||
process_reader_, linkedit_segment->Address(), linkedit_segment->Size());
|
||||
linkedit_range_.SetRange(process_reader_->Is64Bit(),
|
||||
linkedit_segment->Address(),
|
||||
linkedit_segment->Size());
|
||||
DCHECK(linkedit_range_.IsValid());
|
||||
}
|
||||
|
||||
@ -198,7 +199,7 @@ class MachOImageSymbolTableReaderInitializer {
|
||||
bool IsInLinkEditSegment(mach_vm_address_t address,
|
||||
mach_vm_size_t size,
|
||||
const char* tag) const {
|
||||
CheckedMachAddressRange subrange(process_reader_, address, size);
|
||||
CheckedMachAddressRange subrange(process_reader_->Is64Bit(), address, size);
|
||||
if (!subrange.IsValid()) {
|
||||
LOG(WARNING) << base::StringPrintf("invalid %s range (0x%llx + 0x%llx)",
|
||||
tag,
|
@ -12,8 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef CRASHPAD_UTIL_MAC_MACH_O_IMAGE_SYMBOL_TABLE_READER_H_
|
||||
#define CRASHPAD_UTIL_MAC_MACH_O_IMAGE_SYMBOL_TABLE_READER_H_
|
||||
#ifndef CRASHPAD_SNAPSHOT_MAC_MACH_O_IMAGE_SYMBOL_TABLE_READER_H_
|
||||
#define CRASHPAD_SNAPSHOT_MAC_MACH_O_IMAGE_SYMBOL_TABLE_READER_H_
|
||||
|
||||
#include "base/basictypes.h"
|
||||
|
||||
@ -23,9 +23,9 @@
|
||||
#include <mach/mach.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "util/mac/mach_o_image_segment_reader.h"
|
||||
#include "util/mac/process_reader.h"
|
||||
#include "util/mac/process_types.h"
|
||||
#include "snapshot/mac/mach_o_image_segment_reader.h"
|
||||
#include "snapshot/mac/process_reader.h"
|
||||
#include "snapshot/mac/process_types.h"
|
||||
#include "util/misc/initialization_state_dcheck.h"
|
||||
|
||||
namespace crashpad {
|
||||
@ -132,4 +132,4 @@ class MachOImageSymbolTableReader {
|
||||
|
||||
} // namespace crashpad
|
||||
|
||||
#endif // CRASHPAD_UTIL_MAC_MACH_O_IMAGE_SYMBOL_TABLE_READER_H_
|
||||
#endif // CRASHPAD_SNAPSHOT_MAC_MACH_O_IMAGE_SYMBOL_TABLE_READER_H_
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "snapshot/memory_snapshot_mac.h"
|
||||
#include "snapshot/mac/memory_snapshot_mac.h"
|
||||
|
||||
#include "util/mach/task_memory.h"
|
||||
|
@ -12,15 +12,15 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef CRASHPAD_SNAPSHOT_MEMORY_SNAPSHOT_MAC_H_
|
||||
#define CRASHPAD_SNAPSHOT_MEMORY_SNAPSHOT_MAC_H_
|
||||
#ifndef CRASHPAD_SNAPSHOT_MAC_MEMORY_SNAPSHOT_MAC_H_
|
||||
#define CRASHPAD_SNAPSHOT_MAC_MEMORY_SNAPSHOT_MAC_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "snapshot/mac/process_reader.h"
|
||||
#include "snapshot/memory_snapshot.h"
|
||||
#include "util/mac/process_reader.h"
|
||||
#include "util/misc/initialization_state_dcheck.h"
|
||||
|
||||
namespace crashpad {
|
||||
@ -65,4 +65,4 @@ class MemorySnapshotMac final : public MemorySnapshot {
|
||||
} // namespace internal
|
||||
} // namespace crashpad
|
||||
|
||||
#endif // CRASHPAD_SNAPSHOT_MEMORY_SNAPSHOT_MAC_H_
|
||||
#endif // CRASHPAD_SNAPSHOT_MAC_MEMORY_SNAPSHOT_MAC_H_
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "util/mac/process_reader.h"
|
||||
#include "snapshot/mac/process_reader.h"
|
||||
|
||||
#include <AvailabilityMacros.h>
|
||||
#include <mach/mach_vm.h>
|
||||
@ -25,8 +25,8 @@
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/mac/scoped_mach_vm.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "util/mac/mach_o_image_reader.h"
|
||||
#include "util/mac/process_types.h"
|
||||
#include "snapshot/mac/mach_o_image_reader.h"
|
||||
#include "snapshot/mac/process_types.h"
|
||||
#include "util/misc/scoped_forbid_return.h"
|
||||
|
||||
namespace {
|
@ -12,8 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef CRASHPAD_UTIL_MAC_PROCESS_READER_H_
|
||||
#define CRASHPAD_UTIL_MAC_PROCESS_READER_H_
|
||||
#ifndef CRASHPAD_SNAPSHOT_MAC_PROCESS_READER_H_
|
||||
#define CRASHPAD_SNAPSHOT_MAC_PROCESS_READER_H_
|
||||
|
||||
#include <mach/mach.h>
|
||||
#include <sys/sysctl.h>
|
||||
@ -226,4 +226,4 @@ class ProcessReader {
|
||||
|
||||
} // namespace crashpad
|
||||
|
||||
#endif // CRASHPAD_UTIL_MAC_PROCESS_READER_H_
|
||||
#endif // CRASHPAD_SNAPSHOT_MAC_PROCESS_READER_H_
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "util/mac/process_reader.h"
|
||||
#include "snapshot/mac/process_reader.h"
|
||||
|
||||
#include <mach-o/dyld.h>
|
||||
#include <mach-o/dyld_images.h>
|
||||
@ -30,8 +30,8 @@
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "build/build_config.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "snapshot/mac/mach_o_image_reader.h"
|
||||
#include "util/file/fd_io.h"
|
||||
#include "util/mac/mach_o_image_reader.h"
|
||||
#include "util/mach/mach_extensions.h"
|
||||
#include "util/stdlib/pointer_container.h"
|
||||
#include "util/synchronization/semaphore.h"
|
@ -12,13 +12,13 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "util/mac/process_types.h"
|
||||
#include "snapshot/mac/process_types.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <uuid/uuid.h>
|
||||
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "util/mac/process_types/internal.h"
|
||||
#include "snapshot/mac/process_types/internal.h"
|
||||
#include "util/mach/task_memory.h"
|
||||
|
||||
namespace crashpad {
|
||||
@ -135,7 +135,7 @@ inline void Assign<uuid_t, uuid_t>(uuid_t* destination, const uuid_t& source) {
|
||||
} /* namespace process_types */ \
|
||||
} /* namespace crashpad */
|
||||
|
||||
#include "util/mac/process_types/all.proctype"
|
||||
#include "snapshot/mac/process_types/all.proctype"
|
||||
|
||||
#undef PROCESS_TYPE_STRUCT_BEGIN
|
||||
#undef PROCESS_TYPE_STRUCT_MEMBER
|
||||
@ -147,7 +147,7 @@ inline void Assign<uuid_t, uuid_t>(uuid_t* destination, const uuid_t& source) {
|
||||
// remote process. This is separated from other method implementations because
|
||||
// some types may wish to provide custom readers. This can be done by guarding
|
||||
// such types’ proctype definitions against this macro and providing custom
|
||||
// implementations in util/mac/process_types/custom.cc.
|
||||
// implementations in snapshot/mac/process_types/custom.cc.
|
||||
#define PROCESS_TYPE_STRUCT_IMPLEMENT_INTERNAL_READ_INTO 1
|
||||
|
||||
#define PROCESS_TYPE_STRUCT_BEGIN(struct_name) \
|
||||
@ -170,7 +170,7 @@ inline void Assign<uuid_t, uuid_t>(uuid_t* destination, const uuid_t& source) {
|
||||
|
||||
#define PROCESS_TYPE_STRUCT_END(struct_name)
|
||||
|
||||
#include "util/mac/process_types/all.proctype"
|
||||
#include "snapshot/mac/process_types/all.proctype"
|
||||
|
||||
#undef PROCESS_TYPE_STRUCT_BEGIN
|
||||
#undef PROCESS_TYPE_STRUCT_MEMBER
|
||||
@ -236,7 +236,7 @@ inline void Assign<uuid_t, uuid_t>(uuid_t* destination, const uuid_t& source) {
|
||||
|
||||
#define PROCESS_TYPE_STRUCT_END(struct_name)
|
||||
|
||||
#include "util/mac/process_types/all.proctype"
|
||||
#include "snapshot/mac/process_types/all.proctype"
|
||||
|
||||
#undef PROCESS_TYPE_STRUCT_BEGIN
|
||||
#undef PROCESS_TYPE_STRUCT_MEMBER
|
@ -12,8 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef CRASHPAD_UTIL_MAC_PROCESS_TYPES_H_
|
||||
#define CRASHPAD_UTIL_MAC_PROCESS_TYPES_H_
|
||||
#ifndef CRASHPAD_SNAPSHOT_MAC_PROCESS_TYPES_H_
|
||||
#define CRASHPAD_SNAPSHOT_MAC_PROCESS_TYPES_H_
|
||||
|
||||
#include <mach/mach.h>
|
||||
#include <mach-o/dyld_images.h>
|
||||
@ -21,7 +21,7 @@
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "util/mac/process_reader.h"
|
||||
#include "snapshot/mac/process_reader.h"
|
||||
|
||||
namespace crashpad {
|
||||
namespace process_types {
|
||||
@ -38,7 +38,7 @@ typedef uint32_t Reserved64Only64;
|
||||
} // namespace process_types
|
||||
} // namespace crashpad
|
||||
|
||||
#include "util/mac/process_types/traits.h"
|
||||
#include "snapshot/mac/process_types/traits.h"
|
||||
|
||||
// Creates the traits type crashpad::process_types::internal::TraitsGeneric.
|
||||
DECLARE_PROCESS_TYPE_TRAITS_CLASS(Generic, 64)
|
||||
@ -111,7 +111,7 @@ DECLARE_PROCESS_TYPE_TRAITS_CLASS(Generic, 64)
|
||||
} /* namespace process_types */ \
|
||||
} /* namespace crashpad */
|
||||
|
||||
#include "util/mac/process_types/all.proctype"
|
||||
#include "snapshot/mac/process_types/all.proctype"
|
||||
|
||||
#undef PROCESS_TYPE_STRUCT_BEGIN
|
||||
#undef PROCESS_TYPE_STRUCT_MEMBER
|
||||
@ -173,11 +173,11 @@ DECLARE_PROCESS_TYPE_TRAITS_CLASS(Generic, 64)
|
||||
} /* namespace process_types */ \
|
||||
} /* namespace crashpad */
|
||||
|
||||
#include "util/mac/process_types/all.proctype"
|
||||
#include "snapshot/mac/process_types/all.proctype"
|
||||
|
||||
#undef PROCESS_TYPE_STRUCT_BEGIN
|
||||
#undef PROCESS_TYPE_STRUCT_MEMBER
|
||||
#undef PROCESS_TYPE_STRUCT_END
|
||||
#undef PROCESS_TYPE_STRUCT_DECLARE_INTERNAL
|
||||
|
||||
#endif // CRASHPAD_UTIL_MAC_PROCESS_TYPES_H_
|
||||
#endif // CRASHPAD_SNAPSHOT_MAC_PROCESS_TYPES_H_
|
@ -15,11 +15,11 @@
|
||||
// This file is intended to be included multiple times in the same translation
|
||||
// unit, so #include guards are intentionally absent.
|
||||
//
|
||||
// This file is included by util/mac/process_types.h and
|
||||
// util/mac/process_types.cc to produce process type struct definitions and
|
||||
// This file is included by snapshot/mac/process_types.h and
|
||||
// snapshot/mac/process_types.cc to produce process type struct definitions and
|
||||
// accessors.
|
||||
|
||||
#include "util/mac/process_types/crashreporterclient.proctype"
|
||||
#include "util/mac/process_types/dyld_images.proctype"
|
||||
#include "util/mac/process_types/loader.proctype"
|
||||
#include "util/mac/process_types/nlist.proctype"
|
||||
#include "snapshot/mac/process_types/crashreporterclient.proctype"
|
||||
#include "snapshot/mac/process_types/dyld_images.proctype"
|
||||
#include "snapshot/mac/process_types/loader.proctype"
|
||||
#include "snapshot/mac/process_types/nlist.proctype"
|
@ -21,8 +21,8 @@
|
||||
// This file is intended to be included multiple times in the same translation
|
||||
// unit, so #include guards are intentionally absent.
|
||||
//
|
||||
// This file is included by util/mac/process_types.h and
|
||||
// util/mac/process_types.cc to produce process type struct definitions and
|
||||
// This file is included by snapshot/mac/process_types.h and
|
||||
// snapshot/mac/process_types.cc to produce process type struct definitions and
|
||||
// accessors.
|
||||
|
||||
// Client Mach-O images will contain a __DATA,__crash_info section formatted
|
@ -12,11 +12,11 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "util/mac/process_types.h"
|
||||
#include "snapshot/mac/process_types.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "util/mac/process_types/internal.h"
|
||||
#include "snapshot/mac/process_types/internal.h"
|
||||
#include "util/mach/task_memory.h"
|
||||
|
||||
namespace crashpad {
|
||||
@ -86,7 +86,7 @@ bool dyld_all_image_infos<Traits>::ReadInto(
|
||||
mach_vm_address_t, \
|
||||
dyld_all_image_infos<Traits##lp_bits>*);
|
||||
|
||||
#include "util/mac/process_types/flavors.h"
|
||||
#include "snapshot/mac/process_types/flavors.h"
|
||||
|
||||
#undef PROCESS_TYPE_FLAVOR_TRAITS
|
||||
|
@ -17,8 +17,8 @@
|
||||
// This file is intended to be included multiple times in the same translation
|
||||
// unit, so #include guards are intentionally absent.
|
||||
//
|
||||
// This file is included by util/mac/process_types.h and
|
||||
// util/mac/process_types.cc to produce process type struct definitions and
|
||||
// This file is included by snapshot/mac/process_types.h and
|
||||
// snapshot/mac/process_types.cc to produce process type struct definitions and
|
||||
// accessors.
|
||||
|
||||
PROCESS_TYPE_STRUCT_BEGIN(dyld_image_info)
|
||||
@ -35,8 +35,8 @@ PROCESS_TYPE_STRUCT_END(dyld_uuid_info)
|
||||
// dyld_all_image_infos is variable-length. Its length dictated by its |version|
|
||||
// field which is always present. A custom implementation of the flavored
|
||||
// ReadSpecificInto function that understands how to map this field to the
|
||||
// structure’s actual size is provided in util/mac/process_types/custom.cc. No
|
||||
// implementation of ReadArrayInto is provided because dyld_all_image_infos
|
||||
// structure’s actual size is provided in snapshot/mac/process_types/custom.cc.
|
||||
// No implementation of ReadArrayInto is provided because dyld_all_image_infos
|
||||
// structs are singletons in a process and are never present in arrays, so the
|
||||
// functionality is unnecessary.
|
||||
|
@ -15,9 +15,10 @@
|
||||
// This file is intended to be included multiple times in the same translation
|
||||
// unit, so #include guards are intentionally absent.
|
||||
//
|
||||
// This file is included by util/mac/process_types/internal.h to produce process
|
||||
// type flavor traits class declarations and by util/mac/process_types/custom.cc
|
||||
// to provide explicit instantiation of flavored implementations.
|
||||
// This file is included by snapshot/mac/process_types/internal.h to produce
|
||||
// process type flavor traits class declarations and by
|
||||
// snapshot/mac/process_types/custom.cc to provide explicit instantiation of
|
||||
// flavored implementations.
|
||||
|
||||
PROCESS_TYPE_FLAVOR_TRAITS(32)
|
||||
PROCESS_TYPE_FLAVOR_TRAITS(64)
|
@ -12,25 +12,25 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef CRASHPAD_UTIL_MAC_PROCESS_TYPES_INTERNAL_H_
|
||||
#define CRASHPAD_UTIL_MAC_PROCESS_TYPES_INTERNAL_H_
|
||||
#ifndef CRASHPAD_SNAPSHOT_MAC_PROCESS_TYPES_INTERNAL_H_
|
||||
#define CRASHPAD_SNAPSHOT_MAC_PROCESS_TYPES_INTERNAL_H_
|
||||
|
||||
#include "util/mac/process_types.h"
|
||||
#include "snapshot/mac/process_types.h"
|
||||
|
||||
// Declare Traits32 and Traits64, flavor-specific traits classes. These are
|
||||
// private traits classes not for use outside of process type internals.
|
||||
// TraitsGeneric is declared in util/mac/process_types.h.
|
||||
// TraitsGeneric is declared in snapshot/mac/process_types.h.
|
||||
|
||||
#include "util/mac/process_types/traits.h"
|
||||
#include "snapshot/mac/process_types/traits.h"
|
||||
|
||||
#define PROCESS_TYPE_FLAVOR_TRAITS(lp_bits) \
|
||||
DECLARE_PROCESS_TYPE_TRAITS_CLASS( \
|
||||
lp_bits, lp_bits, __attribute__((aligned(lp_bits / 8))))
|
||||
|
||||
#include "util/mac/process_types/flavors.h"
|
||||
#include "snapshot/mac/process_types/flavors.h"
|
||||
|
||||
#undef PROCESS_TYPE_FLAVOR_TRAITS
|
||||
|
||||
#undef DECLARE_PROCESS_TYPE_TRAITS_CLASS
|
||||
|
||||
#endif // CRASHPAD_UTIL_MAC_PROCESS_TYPES_INTERNAL_H_
|
||||
#endif // CRASHPAD_SNAPSHOT_MAC_PROCESS_TYPES_INTERNAL_H_
|
@ -17,8 +17,8 @@
|
||||
// This file is intended to be included multiple times in the same translation
|
||||
// unit, so #include guards are intentionally absent.
|
||||
//
|
||||
// This file is included by util/mac/process_types.h and
|
||||
// util/mac/process_types.cc to produce process type struct definitions and
|
||||
// This file is included by snapshot/mac/process_types.h and
|
||||
// snapshot/mac/process_types.cc to produce process type struct definitions and
|
||||
// accessors.
|
||||
|
||||
PROCESS_TYPE_STRUCT_BEGIN(mach_header) // 64-bit: mach_header_64
|
@ -17,8 +17,8 @@
|
||||
// This file is intended to be included multiple times in the same translation
|
||||
// unit, so #include guards are intentionally absent.
|
||||
//
|
||||
// This file is included by util/mac/process_types.h and
|
||||
// util/mac/process_types.cc to produce process type struct definitions and
|
||||
// This file is included by snapshot/mac/process_types.h and
|
||||
// snapshot/mac/process_types.cc to produce process type struct definitions and
|
||||
// accessors.
|
||||
|
||||
PROCESS_TYPE_STRUCT_BEGIN(nlist)
|
@ -15,8 +15,8 @@
|
||||
// This file is intended to be included multiple times in the same translation
|
||||
// unit, so #include guards are intentionally absent.
|
||||
//
|
||||
// This file is included by util/mac/process_types.h and
|
||||
// util/mac/process_types/internal.h to produce traits class definitions.
|
||||
// This file is included by snapshot/mac/process_types.h and
|
||||
// snapshot/mac/process_types/internal.h to produce traits class definitions.
|
||||
|
||||
// Things that #include this file should #undef
|
||||
// DECLARE_PROCESS_TYPE_TRAITS_CLASS before #including this file again and after
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "util/mac/process_types.h"
|
||||
#include "snapshot/mac/process_types.h"
|
||||
|
||||
#include <AvailabilityMacros.h>
|
||||
#include <mach/mach.h>
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "snapshot/system_snapshot_mac.h"
|
||||
#include "snapshot/mac/system_snapshot_mac.h"
|
||||
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/types.h>
|
||||
@ -23,8 +23,8 @@
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "build/build_config.h"
|
||||
#include "snapshot/cpu_context.h"
|
||||
#include "snapshot/mac/process_reader.h"
|
||||
#include "util/mac/mac_util.h"
|
||||
#include "util/mac/process_reader.h"
|
||||
#include "util/numeric/in_range_cast.h"
|
||||
|
||||
namespace crashpad {
|
@ -12,8 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef CRASHPAD_SNAPSHOT_SYSTEM_SNAPSHOT_MAC_H_
|
||||
#define CRASHPAD_SNAPSHOT_SYSTEM_SNAPSHOT_MAC_H_
|
||||
#ifndef CRASHPAD_SNAPSHOT_MAC_SYSTEM_SNAPSHOT_MAC_H_
|
||||
#define CRASHPAD_SNAPSHOT_MAC_SYSTEM_SNAPSHOT_MAC_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@ -98,4 +98,4 @@ class SystemSnapshotMac final : public SystemSnapshot {
|
||||
} // namespace internal
|
||||
} // namespace crashpad
|
||||
|
||||
#endif // CRASHPAD_SNAPSHOT_SYSTEM_SNAPSHOT_MAC_H_
|
||||
#endif // CRASHPAD_SNAPSHOT_MAC_SYSTEM_SNAPSHOT_MAC_H_
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "snapshot/system_snapshot_mac.h"
|
||||
#include "snapshot/mac/system_snapshot_mac.h"
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
@ -21,8 +21,8 @@
|
||||
|
||||
#include "build/build_config.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "snapshot/mac/process_reader.h"
|
||||
#include "util/mac/mac_util.h"
|
||||
#include "util/mac/process_reader.h"
|
||||
#include "util/test/errors.h"
|
||||
|
||||
namespace crashpad {
|
@ -12,11 +12,11 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "snapshot/thread_snapshot_mac.h"
|
||||
#include "snapshot/mac/thread_snapshot_mac.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "snapshot/cpu_context_mac.h"
|
||||
#include "util/mac/process_reader.h"
|
||||
#include "snapshot/mac/cpu_context_mac.h"
|
||||
#include "snapshot/mac/process_reader.h"
|
||||
|
||||
namespace crashpad {
|
||||
namespace internal {
|
@ -12,8 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef CRASHPAD_SNAPSHOT_THREAD_SNAPSHOT_MAC_H_
|
||||
#define CRASHPAD_SNAPSHOT_THREAD_SNAPSHOT_MAC_H_
|
||||
#ifndef CRASHPAD_SNAPSHOT_MAC_THREAD_SNAPSHOT_MAC_H_
|
||||
#define CRASHPAD_SNAPSHOT_MAC_THREAD_SNAPSHOT_MAC_H_
|
||||
|
||||
#include <mach/mach.h>
|
||||
#include <stdint.h>
|
||||
@ -21,8 +21,8 @@
|
||||
#include "base/basictypes.h"
|
||||
#include "build/build_config.h"
|
||||
#include "snapshot/cpu_context.h"
|
||||
#include "snapshot/mac/memory_snapshot_mac.h"
|
||||
#include "snapshot/memory_snapshot.h"
|
||||
#include "snapshot/memory_snapshot_mac.h"
|
||||
#include "snapshot/thread_snapshot.h"
|
||||
#include "util/misc/initialization_state_dcheck.h"
|
||||
|
||||
@ -82,4 +82,4 @@ class ThreadSnapshotMac final : public ThreadSnapshot {
|
||||
} // namespace internal
|
||||
} // namespace crashpad
|
||||
|
||||
#endif // CRASHPAD_SNAPSHOT_THREAD_SNAPSHOT_MAC_H_
|
||||
#endif // CRASHPAD_SNAPSHOT_MAC_THREAD_SNAPSHOT_MAC_H_
|
@ -29,22 +29,41 @@
|
||||
'cpu_architecture.h',
|
||||
'cpu_context.cc',
|
||||
'cpu_context.h',
|
||||
'cpu_context_mac.cc',
|
||||
'cpu_context_mac.h',
|
||||
'exception_snapshot.h',
|
||||
'exception_snapshot_mac.cc',
|
||||
'exception_snapshot_mac.h',
|
||||
'mac/cpu_context_mac.cc',
|
||||
'mac/cpu_context_mac.h',
|
||||
'mac/exception_snapshot_mac.cc',
|
||||
'mac/exception_snapshot_mac.h',
|
||||
'mac/mach_o_image_reader.cc',
|
||||
'mac/mach_o_image_reader.h',
|
||||
'mac/mach_o_image_segment_reader.cc',
|
||||
'mac/mach_o_image_segment_reader.h',
|
||||
'mac/mach_o_image_symbol_table_reader.cc',
|
||||
'mac/mach_o_image_symbol_table_reader.h',
|
||||
'mac/memory_snapshot_mac.cc',
|
||||
'mac/memory_snapshot_mac.h',
|
||||
'mac/process_reader.cc',
|
||||
'mac/process_reader.h',
|
||||
'mac/process_types.cc',
|
||||
'mac/process_types.h',
|
||||
'mac/process_types/all.proctype',
|
||||
'mac/process_types/crashreporterclient.proctype',
|
||||
'mac/process_types/custom.cc',
|
||||
'mac/process_types/dyld_images.proctype',
|
||||
'mac/process_types/flavors.h',
|
||||
'mac/process_types/internal.h',
|
||||
'mac/process_types/loader.proctype',
|
||||
'mac/process_types/nlist.proctype',
|
||||
'mac/process_types/traits.h',
|
||||
'mac/system_snapshot_mac.cc',
|
||||
'mac/system_snapshot_mac.h',
|
||||
'mac/thread_snapshot_mac.cc',
|
||||
'mac/thread_snapshot_mac.h',
|
||||
'memory_snapshot.h',
|
||||
'memory_snapshot_mac.cc',
|
||||
'memory_snapshot_mac.h',
|
||||
'module_snapshot.h',
|
||||
'process_snapshot.h',
|
||||
'system_snapshot.h',
|
||||
'system_snapshot_mac.cc',
|
||||
'system_snapshot_mac.h',
|
||||
'thread_snapshot.h',
|
||||
'thread_snapshot_mac.cc',
|
||||
'thread_snapshot_mac.h',
|
||||
],
|
||||
},
|
||||
{
|
||||
@ -63,8 +82,12 @@
|
||||
'..',
|
||||
],
|
||||
'sources': [
|
||||
'cpu_context_mac_test.cc',
|
||||
'system_snapshot_mac_test.cc',
|
||||
'mac/cpu_context_mac_test.cc',
|
||||
'mac/mach_o_image_reader_test.cc',
|
||||
'mac/mach_o_image_segment_reader_test.cc',
|
||||
'mac/process_reader_test.cc',
|
||||
'mac/process_types_test.cc',
|
||||
'mac/system_snapshot_mac_test.cc',
|
||||
],
|
||||
},
|
||||
],
|
||||
|
@ -16,7 +16,6 @@
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/numerics/safe_conversions.h"
|
||||
#include "util/mac/process_reader.h"
|
||||
|
||||
namespace crashpad {
|
||||
|
||||
@ -25,16 +24,16 @@ CheckedMachAddressRange::CheckedMachAddressRange()
|
||||
}
|
||||
|
||||
CheckedMachAddressRange::CheckedMachAddressRange(
|
||||
const ProcessReader* process_reader,
|
||||
bool is_64_bit,
|
||||
mach_vm_address_t base,
|
||||
mach_vm_size_t size) {
|
||||
SetRange(process_reader, base, size);
|
||||
SetRange(is_64_bit, base, size);
|
||||
}
|
||||
|
||||
void CheckedMachAddressRange::SetRange(const ProcessReader* process_reader,
|
||||
void CheckedMachAddressRange::SetRange(bool is_64_bit,
|
||||
mach_vm_address_t base,
|
||||
mach_vm_size_t size) {
|
||||
is_64_bit_ = process_reader->Is64Bit();
|
||||
is_64_bit_ = is_64_bit;
|
||||
if (is_64_bit_) {
|
||||
range_64_.SetRange(base, size);
|
||||
range_ok_ = true;
|
||||
|
@ -21,14 +21,12 @@
|
||||
|
||||
namespace crashpad {
|
||||
|
||||
class ProcessReader;
|
||||
|
||||
//! \brief Ensures that a range, composed of a base and a size, does not
|
||||
//! overflow the pointer type of the process it describes a range in.
|
||||
//!
|
||||
//! This class checks bases of type `mach_vm_address_t` and sizes of type
|
||||
//! `mach_vm_address_t` against a process whose pointer type can be determined
|
||||
//! from its ProcessReader.
|
||||
//! `mach_vm_address_t` against a process whose pointer type is either 32 or 64
|
||||
//! bits wide.
|
||||
//!
|
||||
//! Aside from varying the overall range on the basis of a process’ pointer type
|
||||
//! width, this class functions very similarly to CheckedRange.
|
||||
@ -43,19 +41,18 @@ class CheckedMachAddressRange {
|
||||
//! \brief Initializes a range.
|
||||
//!
|
||||
//! See SetRange().
|
||||
CheckedMachAddressRange(const ProcessReader* process_reader,
|
||||
CheckedMachAddressRange(bool is_64_bit,
|
||||
mach_vm_address_t base,
|
||||
mach_vm_size_t size);
|
||||
|
||||
//! \brief Sets a range’s fields.
|
||||
//!
|
||||
//! \param[in] process_reader The ProcessReader that can read the process that
|
||||
//! \a base is a pointer to.
|
||||
//! \param[in] is_64_bit `true` if \a base and \a size refer to addresses in a
|
||||
//! 64-bit process; `false` if they refer to addresses in a 32-bit
|
||||
//! process.
|
||||
//! \param[in] base The range’s base address.
|
||||
//! \param[in] size The range’s size.
|
||||
void SetRange(const ProcessReader* process_reader,
|
||||
mach_vm_address_t base,
|
||||
mach_vm_size_t size);
|
||||
void SetRange(bool is_64_bit, mach_vm_address_t base, mach_vm_size_t size);
|
||||
|
||||
//! \brief The range’s base address.
|
||||
mach_vm_address_t Base() const;
|
||||
@ -100,7 +97,7 @@ class CheckedMachAddressRange {
|
||||
//! containing address range’s end.
|
||||
//!
|
||||
//! This method should only be called on two CheckedMachAddressRange objects
|
||||
//! sharing the same ProcessReader.
|
||||
//! representing address ranges in the same process.
|
||||
//!
|
||||
//! This method must only be called if IsValid() would return `true` for both
|
||||
//! CheckedMachAddressRange objects involved.
|
||||
|
@ -22,63 +22,70 @@
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "build/build_config.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "util/mac/process_reader.h"
|
||||
|
||||
namespace crashpad {
|
||||
namespace test {
|
||||
namespace {
|
||||
|
||||
#if defined(ARCH_CPU_64_BITS)
|
||||
const bool kValid64Invalid32 = true;
|
||||
#else
|
||||
const bool kValid64Invalid32 = false;
|
||||
#endif
|
||||
enum Validity {
|
||||
kInvalid = false,
|
||||
kValid,
|
||||
kValid64Invalid32,
|
||||
};
|
||||
|
||||
bool ExpectationForValidity32(Validity validity) {
|
||||
return validity == kValid;
|
||||
}
|
||||
|
||||
bool ExpectationForValidity64(Validity validity) {
|
||||
return validity == kValid || validity == kValid64Invalid32;
|
||||
}
|
||||
|
||||
TEST(CheckedMachAddressRange, IsValid) {
|
||||
const struct TestData {
|
||||
mach_vm_address_t base;
|
||||
mach_vm_size_t size;
|
||||
bool valid;
|
||||
Validity validity;
|
||||
} kTestData[] = {
|
||||
{0, 0, true},
|
||||
{0, 1, true},
|
||||
{0, 2, true},
|
||||
{0, 0x7fffffff, true},
|
||||
{0, 0x80000000, true},
|
||||
{0, 0xfffffffe, true},
|
||||
{0, 0xffffffff, true},
|
||||
{0, 0, kValid},
|
||||
{0, 1, kValid},
|
||||
{0, 2, kValid},
|
||||
{0, 0x7fffffff, kValid},
|
||||
{0, 0x80000000, kValid},
|
||||
{0, 0xfffffffe, kValid},
|
||||
{0, 0xffffffff, kValid},
|
||||
{0, 0xffffffffffffffff, kValid64Invalid32},
|
||||
{1, 0, true},
|
||||
{1, 1, true},
|
||||
{1, 2, true},
|
||||
{1, 0x7fffffff, true},
|
||||
{1, 0x80000000, true},
|
||||
{1, 0xfffffffe, true},
|
||||
{1, 0, kValid},
|
||||
{1, 1, kValid},
|
||||
{1, 2, kValid},
|
||||
{1, 0x7fffffff, kValid},
|
||||
{1, 0x80000000, kValid},
|
||||
{1, 0xfffffffe, kValid},
|
||||
{1, 0xffffffff, kValid64Invalid32},
|
||||
{1, 0xfffffffffffffffe, kValid64Invalid32},
|
||||
{1, 0xffffffffffffffff, false},
|
||||
{0x7fffffff, 0, true},
|
||||
{0x7fffffff, 1, true},
|
||||
{0x7fffffff, 2, true},
|
||||
{0x7fffffff, 0x7fffffff, true},
|
||||
{0x7fffffff, 0x80000000, true},
|
||||
{1, 0xffffffffffffffff, kInvalid},
|
||||
{0x7fffffff, 0, kValid},
|
||||
{0x7fffffff, 1, kValid},
|
||||
{0x7fffffff, 2, kValid},
|
||||
{0x7fffffff, 0x7fffffff, kValid},
|
||||
{0x7fffffff, 0x80000000, kValid},
|
||||
{0x7fffffff, 0xfffffffe, kValid64Invalid32},
|
||||
{0x7fffffff, 0xffffffff, kValid64Invalid32},
|
||||
{0x80000000, 0, true},
|
||||
{0x80000000, 1, true},
|
||||
{0x80000000, 2, true},
|
||||
{0x80000000, 0x7fffffff, true},
|
||||
{0x80000000, 0, kValid},
|
||||
{0x80000000, 1, kValid},
|
||||
{0x80000000, 2, kValid},
|
||||
{0x80000000, 0x7fffffff, kValid},
|
||||
{0x80000000, 0x80000000, kValid64Invalid32},
|
||||
{0x80000000, 0xfffffffe, kValid64Invalid32},
|
||||
{0x80000000, 0xffffffff, kValid64Invalid32},
|
||||
{0xfffffffe, 0, true},
|
||||
{0xfffffffe, 1, true},
|
||||
{0xfffffffe, 0, kValid},
|
||||
{0xfffffffe, 1, kValid},
|
||||
{0xfffffffe, 2, kValid64Invalid32},
|
||||
{0xfffffffe, 0x7fffffff, kValid64Invalid32},
|
||||
{0xfffffffe, 0x80000000, kValid64Invalid32},
|
||||
{0xfffffffe, 0xfffffffe, kValid64Invalid32},
|
||||
{0xfffffffe, 0xffffffff, kValid64Invalid32},
|
||||
{0xffffffff, 0, true},
|
||||
{0xffffffff, 0, kValid},
|
||||
{0xffffffff, 1, kValid64Invalid32},
|
||||
{0xffffffff, 2, kValid64Invalid32},
|
||||
{0xffffffff, 0x7fffffff, kValid64Invalid32},
|
||||
@ -90,27 +97,24 @@ TEST(CheckedMachAddressRange, IsValid) {
|
||||
{0x7fffffffffffffff, 2, kValid64Invalid32},
|
||||
{0x7fffffffffffffff, 0x7fffffffffffffff, kValid64Invalid32},
|
||||
{0x7fffffffffffffff, 0x8000000000000000, kValid64Invalid32},
|
||||
{0x7fffffffffffffff, 0x8000000000000001, false},
|
||||
{0x7fffffffffffffff, 0xfffffffffffffffe, false},
|
||||
{0x7fffffffffffffff, 0xffffffffffffffff, false},
|
||||
{0x7fffffffffffffff, 0x8000000000000001, kInvalid},
|
||||
{0x7fffffffffffffff, 0xfffffffffffffffe, kInvalid},
|
||||
{0x7fffffffffffffff, 0xffffffffffffffff, kInvalid},
|
||||
{0x8000000000000000, 0, kValid64Invalid32},
|
||||
{0x8000000000000000, 1, kValid64Invalid32},
|
||||
{0x8000000000000000, 2, kValid64Invalid32},
|
||||
{0x8000000000000000, 0x7fffffffffffffff, kValid64Invalid32},
|
||||
{0x8000000000000000, 0x8000000000000000, false},
|
||||
{0x8000000000000000, 0x8000000000000001, false},
|
||||
{0x8000000000000000, 0xfffffffffffffffe, false},
|
||||
{0x8000000000000000, 0xffffffffffffffff, false},
|
||||
{0x8000000000000000, 0x8000000000000000, kInvalid},
|
||||
{0x8000000000000000, 0x8000000000000001, kInvalid},
|
||||
{0x8000000000000000, 0xfffffffffffffffe, kInvalid},
|
||||
{0x8000000000000000, 0xffffffffffffffff, kInvalid},
|
||||
{0xfffffffffffffffe, 0, kValid64Invalid32},
|
||||
{0xfffffffffffffffe, 1, kValid64Invalid32},
|
||||
{0xfffffffffffffffe, 2, false},
|
||||
{0xfffffffffffffffe, 2, kInvalid},
|
||||
{0xffffffffffffffff, 0, kValid64Invalid32},
|
||||
{0xffffffffffffffff, 1, false},
|
||||
{0xffffffffffffffff, 1, kInvalid},
|
||||
};
|
||||
|
||||
ProcessReader process_reader;
|
||||
ASSERT_TRUE(process_reader.Initialize(mach_task_self()));
|
||||
|
||||
for (size_t index = 0; index < arraysize(kTestData); ++index) {
|
||||
const TestData& testcase = kTestData[index];
|
||||
SCOPED_TRACE(base::StringPrintf("index %zu, base 0x%llx, size 0x%llx",
|
||||
@ -118,16 +122,18 @@ TEST(CheckedMachAddressRange, IsValid) {
|
||||
testcase.base,
|
||||
testcase.size));
|
||||
|
||||
CheckedMachAddressRange range(
|
||||
&process_reader, testcase.base, testcase.size);
|
||||
EXPECT_EQ(testcase.valid, range.IsValid());
|
||||
CheckedMachAddressRange range_32(false, testcase.base, testcase.size);
|
||||
EXPECT_EQ(ExpectationForValidity32(testcase.validity), range_32.IsValid());
|
||||
|
||||
CheckedMachAddressRange range_64(true, testcase.base, testcase.size);
|
||||
EXPECT_EQ(ExpectationForValidity64(testcase.validity), range_64.IsValid());
|
||||
}
|
||||
}
|
||||
|
||||
TEST(CheckedMachAddressRange, ContainsValue) {
|
||||
const struct TestData {
|
||||
mach_vm_address_t value;
|
||||
bool valid;
|
||||
bool expectation;
|
||||
} kTestData[] = {
|
||||
{0, false},
|
||||
{1, false},
|
||||
@ -156,36 +162,32 @@ TEST(CheckedMachAddressRange, ContainsValue) {
|
||||
{0xffffffffffffffff, false},
|
||||
};
|
||||
|
||||
ProcessReader process_reader;
|
||||
ASSERT_TRUE(process_reader.Initialize(mach_task_self()));
|
||||
|
||||
CheckedMachAddressRange parent_range(&process_reader, 0x2000, 0x1000);
|
||||
ASSERT_TRUE(parent_range.IsValid());
|
||||
CheckedMachAddressRange parent_range_32(false, 0x2000, 0x1000);
|
||||
ASSERT_TRUE(parent_range_32.IsValid());
|
||||
|
||||
for (size_t index = 0; index < arraysize(kTestData); ++index) {
|
||||
const TestData& testcase = kTestData[index];
|
||||
SCOPED_TRACE(
|
||||
base::StringPrintf("index %zu, value 0x%llx", index, testcase.value));
|
||||
|
||||
EXPECT_EQ(testcase.valid, parent_range.ContainsValue(testcase.value));
|
||||
EXPECT_EQ(testcase.expectation,
|
||||
parent_range_32.ContainsValue(testcase.value));
|
||||
}
|
||||
|
||||
CheckedMachAddressRange parent_range_64(&process_reader, 0x100000000, 0x1000);
|
||||
ASSERT_EQ(kValid64Invalid32, parent_range_64.IsValid());
|
||||
if (parent_range_64.IsValid()) {
|
||||
CheckedMachAddressRange parent_range_64(true, 0x100000000, 0x1000);
|
||||
ASSERT_TRUE(parent_range_64.IsValid());
|
||||
EXPECT_FALSE(parent_range_64.ContainsValue(0xffffffff));
|
||||
EXPECT_TRUE(parent_range_64.ContainsValue(0x100000000));
|
||||
EXPECT_TRUE(parent_range_64.ContainsValue(0x100000001));
|
||||
EXPECT_TRUE(parent_range_64.ContainsValue(0x100000fff));
|
||||
EXPECT_FALSE(parent_range_64.ContainsValue(0x100001000));
|
||||
}
|
||||
}
|
||||
|
||||
TEST(CheckedMachAddressRange, ContainsRange) {
|
||||
const struct TestData {
|
||||
mach_vm_address_t base;
|
||||
mach_vm_size_t size;
|
||||
bool valid;
|
||||
bool expectation;
|
||||
} kTestData[] = {
|
||||
{0, 0, false},
|
||||
{0, 1, false},
|
||||
@ -217,11 +219,8 @@ TEST(CheckedMachAddressRange, ContainsRange) {
|
||||
{0x3001, 1, false},
|
||||
};
|
||||
|
||||
ProcessReader process_reader;
|
||||
ASSERT_TRUE(process_reader.Initialize(mach_task_self()));
|
||||
|
||||
CheckedMachAddressRange parent_range(&process_reader, 0x2000, 0x1000);
|
||||
ASSERT_TRUE(parent_range.IsValid());
|
||||
CheckedMachAddressRange parent_range_32(false, 0x2000, 0x1000);
|
||||
ASSERT_TRUE(parent_range_32.IsValid());
|
||||
|
||||
for (size_t index = 0; index < arraysize(kTestData); ++index) {
|
||||
const TestData& testcase = kTestData[index];
|
||||
@ -230,28 +229,27 @@ TEST(CheckedMachAddressRange, ContainsRange) {
|
||||
testcase.base,
|
||||
testcase.size));
|
||||
|
||||
CheckedMachAddressRange child_range(
|
||||
&process_reader, testcase.base, testcase.size);
|
||||
ASSERT_TRUE(child_range.IsValid());
|
||||
EXPECT_EQ(testcase.valid, parent_range.ContainsRange(child_range));
|
||||
CheckedMachAddressRange child_range_32(false, testcase.base, testcase.size);
|
||||
ASSERT_TRUE(child_range_32.IsValid());
|
||||
EXPECT_EQ(testcase.expectation,
|
||||
parent_range_32.ContainsRange(child_range_32));
|
||||
}
|
||||
|
||||
CheckedMachAddressRange parent_range_64(&process_reader, 0x100000000, 0x1000);
|
||||
ASSERT_EQ(kValid64Invalid32, parent_range_64.IsValid());
|
||||
if (parent_range_64.IsValid()) {
|
||||
CheckedMachAddressRange child_range_64(&process_reader, 0xffffffff, 2);
|
||||
CheckedMachAddressRange parent_range_64(true, 0x100000000, 0x1000);
|
||||
ASSERT_TRUE(parent_range_64.IsValid());
|
||||
|
||||
CheckedMachAddressRange child_range_64(true, 0xffffffff, 2);
|
||||
EXPECT_FALSE(parent_range_64.ContainsRange(child_range_64));
|
||||
|
||||
child_range_64.SetRange(&process_reader, 0x100000000, 2);
|
||||
child_range_64.SetRange(true, 0x100000000, 2);
|
||||
EXPECT_TRUE(parent_range_64.ContainsRange(child_range_64));
|
||||
|
||||
child_range_64.SetRange(&process_reader, 0x100000ffe, 2);
|
||||
child_range_64.SetRange(true, 0x100000ffe, 2);
|
||||
EXPECT_TRUE(parent_range_64.ContainsRange(child_range_64));
|
||||
|
||||
child_range_64.SetRange(&process_reader, 0x100000fff, 2);
|
||||
child_range_64.SetRange(true, 0x100000fff, 2);
|
||||
EXPECT_FALSE(parent_range_64.ContainsRange(child_range_64));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace test
|
||||
|
@ -38,27 +38,8 @@
|
||||
'mac/launchd.mm',
|
||||
'mac/mac_util.cc',
|
||||
'mac/mac_util.h',
|
||||
'mac/mach_o_image_reader.cc',
|
||||
'mac/mach_o_image_reader.h',
|
||||
'mac/mach_o_image_segment_reader.cc',
|
||||
'mac/mach_o_image_segment_reader.h',
|
||||
'mac/mach_o_image_symbol_table_reader.cc',
|
||||
'mac/mach_o_image_symbol_table_reader.h',
|
||||
'mac/service_management.cc',
|
||||
'mac/service_management.h',
|
||||
'mac/process_reader.cc',
|
||||
'mac/process_reader.h',
|
||||
'mac/process_types.cc',
|
||||
'mac/process_types.h',
|
||||
'mac/process_types/all.proctype',
|
||||
'mac/process_types/crashreporterclient.proctype',
|
||||
'mac/process_types/custom.cc',
|
||||
'mac/process_types/dyld_images.proctype',
|
||||
'mac/process_types/flavors.h',
|
||||
'mac/process_types/internal.h',
|
||||
'mac/process_types/loader.proctype',
|
||||
'mac/process_types/nlist.proctype',
|
||||
'mac/process_types/traits.h',
|
||||
'mach/exc_client_variants.cc',
|
||||
'mach/exc_client_variants.h',
|
||||
'mach/exc_server_variants.cc',
|
||||
@ -216,10 +197,6 @@
|
||||
'mac/checked_mach_address_range_test.cc',
|
||||
'mac/launchd_test.mm',
|
||||
'mac/mac_util_test.mm',
|
||||
'mac/mach_o_image_reader_test.cc',
|
||||
'mac/mach_o_image_segment_reader_test.cc',
|
||||
'mac/process_reader_test.cc',
|
||||
'mac/process_types_test.cc',
|
||||
'mac/service_management_test.mm',
|
||||
'mach/exc_client_variants_test.cc',
|
||||
'mach/exc_server_variants_test.cc',
|
||||
|
Loading…
x
Reference in New Issue
Block a user