From bcae4d94d58cd730b4045b3514a0ed0345245537 Mon Sep 17 00:00:00 2001 From: Mark Mentovai Date: Fri, 17 Oct 2014 13:41:45 -0400 Subject: [PATCH] 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 --- snapshot/{ => mac}/cpu_context_mac.cc | 2 +- snapshot/{ => mac}/cpu_context_mac.h | 6 +- snapshot/{ => mac}/cpu_context_mac_test.cc | 2 +- snapshot/{ => mac}/exception_snapshot_mac.cc | 6 +- snapshot/{ => mac}/exception_snapshot_mac.h | 6 +- {util => snapshot}/mac/mach_o_image_reader.cc | 12 +- {util => snapshot}/mac/mach_o_image_reader.h | 10 +- .../mac/mach_o_image_reader_test.cc | 8 +- .../mac/mach_o_image_segment_reader.cc | 11 +- .../mac/mach_o_image_segment_reader.h | 8 +- .../mac/mach_o_image_segment_reader_test.cc | 2 +- .../mac/mach_o_image_symbol_table_reader.cc | 9 +- .../mac/mach_o_image_symbol_table_reader.h | 12 +- snapshot/{ => mac}/memory_snapshot_mac.cc | 2 +- snapshot/{ => mac}/memory_snapshot_mac.h | 8 +- {util => snapshot}/mac/process_reader.cc | 6 +- {util => snapshot}/mac/process_reader.h | 6 +- {util => snapshot}/mac/process_reader_test.cc | 4 +- {util => snapshot}/mac/process_types.cc | 12 +- {util => snapshot}/mac/process_types.h | 14 +- .../mac/process_types/all.proctype | 12 +- .../crashreporterclient.proctype | 4 +- .../mac/process_types/custom.cc | 6 +- .../mac/process_types/dyld_images.proctype | 8 +- .../mac/process_types/flavors.h | 7 +- .../mac/process_types/internal.h | 14 +- .../mac/process_types/loader.proctype | 4 +- .../mac/process_types/nlist.proctype | 4 +- {util => snapshot}/mac/process_types/traits.h | 4 +- {util => snapshot}/mac/process_types_test.cc | 2 +- snapshot/{ => mac}/system_snapshot_mac.cc | 4 +- snapshot/{ => mac}/system_snapshot_mac.h | 6 +- .../{ => mac}/system_snapshot_mac_test.cc | 4 +- snapshot/{ => mac}/thread_snapshot_mac.cc | 6 +- snapshot/{ => mac}/thread_snapshot_mac.h | 8 +- snapshot/snapshot.gyp | 47 +++-- util/mac/checked_mach_address_range.cc | 9 +- util/mac/checked_mach_address_range.h | 19 +- util/mac/checked_mach_address_range_test.cc | 170 +++++++++--------- util/util.gyp | 23 --- 40 files changed, 252 insertions(+), 255 deletions(-) rename snapshot/{ => mac}/cpu_context_mac.cc (99%) rename snapshot/{ => mac}/cpu_context_mac.h (97%) rename snapshot/{ => mac}/cpu_context_mac_test.cc (99%) rename snapshot/{ => mac}/exception_snapshot_mac.cc (97%) rename snapshot/{ => mac}/exception_snapshot_mac.h (94%) rename {util => snapshot}/mac/mach_o_image_reader.cc (98%) rename {util => snapshot}/mac/mach_o_image_reader.h (98%) rename {util => snapshot}/mac/mach_o_image_reader_test.cc (99%) rename {util => snapshot}/mac/mach_o_image_segment_reader.cc (96%) rename {util => snapshot}/mac/mach_o_image_segment_reader.h (98%) rename {util => snapshot}/mac/mach_o_image_segment_reader_test.cc (99%) rename {util => snapshot}/mac/mach_o_image_symbol_table_reader.cc (97%) rename {util => snapshot}/mac/mach_o_image_symbol_table_reader.h (94%) rename snapshot/{ => mac}/memory_snapshot_mac.cc (97%) rename snapshot/{ => mac}/memory_snapshot_mac.h (91%) rename {util => snapshot}/mac/process_reader.cc (99%) rename {util => snapshot}/mac/process_reader.h (98%) rename {util => snapshot}/mac/process_reader_test.cc (99%) rename {util => snapshot}/mac/process_types.cc (97%) rename {util => snapshot}/mac/process_types.h (96%) rename {util => snapshot}/mac/process_types/all.proctype (67%) rename {util => snapshot}/mac/process_types/crashreporterclient.proctype (92%) rename {util => snapshot}/mac/process_types/custom.cc (96%) rename {util => snapshot}/mac/process_types/dyld_images.proctype (92%) rename {util => snapshot}/mac/process_types/flavors.h (77%) rename {util => snapshot}/mac/process_types/internal.h (73%) rename {util => snapshot}/mac/process_types/loader.proctype (97%) rename {util => snapshot}/mac/process_types/nlist.proctype (89%) rename {util => snapshot}/mac/process_types/traits.h (93%) rename {util => snapshot}/mac/process_types_test.cc (99%) rename snapshot/{ => mac}/system_snapshot_mac.cc (99%) rename snapshot/{ => mac}/system_snapshot_mac.h (95%) rename snapshot/{ => mac}/system_snapshot_mac_test.cc (98%) rename snapshot/{ => mac}/thread_snapshot_mac.cc (96%) rename snapshot/{ => mac}/thread_snapshot_mac.h (92%) diff --git a/snapshot/cpu_context_mac.cc b/snapshot/mac/cpu_context_mac.cc similarity index 99% rename from snapshot/cpu_context_mac.cc rename to snapshot/mac/cpu_context_mac.cc index 04b9f03d..a6270869 100644 --- a/snapshot/cpu_context_mac.cc +++ b/snapshot/mac/cpu_context_mac.cc @@ -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 diff --git a/snapshot/cpu_context_mac.h b/snapshot/mac/cpu_context_mac.h similarity index 97% rename from snapshot/cpu_context_mac.h rename to snapshot/mac/cpu_context_mac.h index 2435b790..d8086378 100644 --- a/snapshot/cpu_context_mac.h +++ b/snapshot/mac/cpu_context_mac.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 @@ -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_ diff --git a/snapshot/cpu_context_mac_test.cc b/snapshot/mac/cpu_context_mac_test.cc similarity index 99% rename from snapshot/cpu_context_mac_test.cc rename to snapshot/mac/cpu_context_mac_test.cc index 9084898d..844c9f6e 100644 --- a/snapshot/cpu_context_mac_test.cc +++ b/snapshot/mac/cpu_context_mac_test.cc @@ -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 diff --git a/snapshot/exception_snapshot_mac.cc b/snapshot/mac/exception_snapshot_mac.cc similarity index 97% rename from snapshot/exception_snapshot_mac.cc rename to snapshot/mac/exception_snapshot_mac.cc index 2a67ea95..95d8c620 100644 --- a/snapshot/exception_snapshot_mac.cc +++ b/snapshot/mac/exception_snapshot_mac.cc @@ -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" diff --git a/snapshot/exception_snapshot_mac.h b/snapshot/mac/exception_snapshot_mac.h similarity index 94% rename from snapshot/exception_snapshot_mac.h rename to snapshot/mac/exception_snapshot_mac.h index f0fc8e67..51df8224 100644 --- a/snapshot/exception_snapshot_mac.h +++ b/snapshot/mac/exception_snapshot_mac.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 #include @@ -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_ diff --git a/util/mac/mach_o_image_reader.cc b/snapshot/mac/mach_o_image_reader.cc similarity index 98% rename from util/mac/mach_o_image_reader.cc rename to snapshot/mac/mach_o_image_reader.cc index f911ec67..65dd3946 100644 --- a/util/mac/mach_o_image_reader.cc +++ b/snapshot/mac/mach_o_image_reader.cc @@ -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 #include @@ -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())) { diff --git a/util/mac/mach_o_image_reader.h b/snapshot/mac/mach_o_image_reader.h similarity index 98% rename from util/mac/mach_o_image_reader.h rename to snapshot/mac/mach_o_image_reader.h index ad396111..f89e9e94 100644 --- a/util/mac/mach_o_image_reader.h +++ b/snapshot/mac/mach_o_image_reader.h @@ -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 #include @@ -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_ diff --git a/util/mac/mach_o_image_reader_test.cc b/snapshot/mac/mach_o_image_reader_test.cc similarity index 99% rename from util/mac/mach_o_image_reader_test.cc rename to snapshot/mac/mach_o_image_reader_test.cc index b7485dca..57dc28ed 100644 --- a/util/mac/mach_o_image_reader_test.cc +++ b/snapshot/mac/mach_o_image_reader_test.cc @@ -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 #include @@ -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" diff --git a/util/mac/mach_o_image_segment_reader.cc b/snapshot/mac/mach_o_image_segment_reader.cc similarity index 96% rename from util/mac/mach_o_image_segment_reader.cc rename to snapshot/mac/mach_o_image_segment_reader.cc index 58f85063..69782229 100644 --- a/util/mac/mach_o_image_segment_reader.cc +++ b/snapshot/mac/mach_o_image_segment_reader.cc @@ -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 #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", diff --git a/util/mac/mach_o_image_segment_reader.h b/snapshot/mac/mach_o_image_segment_reader.h similarity index 98% rename from util/mac/mach_o_image_segment_reader.h rename to snapshot/mac/mach_o_image_segment_reader.h index 2f5c57e0..16b0fe33 100644 --- a/util/mac/mach_o_image_segment_reader.h +++ b/snapshot/mac/mach_o_image_segment_reader.h @@ -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 #include @@ -24,7 +24,7 @@ #include #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_ diff --git a/util/mac/mach_o_image_segment_reader_test.cc b/snapshot/mac/mach_o_image_segment_reader_test.cc similarity index 99% rename from util/mac/mach_o_image_segment_reader_test.cc rename to snapshot/mac/mach_o_image_segment_reader_test.cc index d0e706f8..bf375af2 100644 --- a/util/mac/mach_o_image_segment_reader_test.cc +++ b/snapshot/mac/mach_o_image_segment_reader_test.cc @@ -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 diff --git a/util/mac/mach_o_image_symbol_table_reader.cc b/snapshot/mac/mach_o_image_symbol_table_reader.cc similarity index 97% rename from util/mac/mach_o_image_symbol_table_reader.cc rename to snapshot/mac/mach_o_image_symbol_table_reader.cc index 8db0109c..ff264471 100644 --- a/util/mac/mach_o_image_symbol_table_reader.cc +++ b/snapshot/mac/mach_o_image_symbol_table_reader.cc @@ -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 #include @@ -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, diff --git a/util/mac/mach_o_image_symbol_table_reader.h b/snapshot/mac/mach_o_image_symbol_table_reader.h similarity index 94% rename from util/mac/mach_o_image_symbol_table_reader.h rename to snapshot/mac/mach_o_image_symbol_table_reader.h index 58741593..5970be5c 100644 --- a/util/mac/mach_o_image_symbol_table_reader.h +++ b/snapshot/mac/mach_o_image_symbol_table_reader.h @@ -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 #include -#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_ diff --git a/snapshot/memory_snapshot_mac.cc b/snapshot/mac/memory_snapshot_mac.cc similarity index 97% rename from snapshot/memory_snapshot_mac.cc rename to snapshot/mac/memory_snapshot_mac.cc index ee038377..ce6b7bcb 100644 --- a/snapshot/memory_snapshot_mac.cc +++ b/snapshot/mac/memory_snapshot_mac.cc @@ -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" diff --git a/snapshot/memory_snapshot_mac.h b/snapshot/mac/memory_snapshot_mac.h similarity index 91% rename from snapshot/memory_snapshot_mac.h rename to snapshot/mac/memory_snapshot_mac.h index 6754b421..618cd1f7 100644 --- a/snapshot/memory_snapshot_mac.h +++ b/snapshot/mac/memory_snapshot_mac.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 #include #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_ diff --git a/util/mac/process_reader.cc b/snapshot/mac/process_reader.cc similarity index 99% rename from util/mac/process_reader.cc rename to snapshot/mac/process_reader.cc index c142080b..444af86e 100644 --- a/util/mac/process_reader.cc +++ b/snapshot/mac/process_reader.cc @@ -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 #include @@ -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 { diff --git a/util/mac/process_reader.h b/snapshot/mac/process_reader.h similarity index 98% rename from util/mac/process_reader.h rename to snapshot/mac/process_reader.h index db38b528..f8e64181 100644 --- a/util/mac/process_reader.h +++ b/snapshot/mac/process_reader.h @@ -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 #include @@ -226,4 +226,4 @@ class ProcessReader { } // namespace crashpad -#endif // CRASHPAD_UTIL_MAC_PROCESS_READER_H_ +#endif // CRASHPAD_SNAPSHOT_MAC_PROCESS_READER_H_ diff --git a/util/mac/process_reader_test.cc b/snapshot/mac/process_reader_test.cc similarity index 99% rename from util/mac/process_reader_test.cc rename to snapshot/mac/process_reader_test.cc index d33ebbf3..5a556f20 100644 --- a/util/mac/process_reader_test.cc +++ b/snapshot/mac/process_reader_test.cc @@ -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 #include @@ -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" diff --git a/util/mac/process_types.cc b/snapshot/mac/process_types.cc similarity index 97% rename from util/mac/process_types.cc rename to snapshot/mac/process_types.cc index e7e858bf..5bb0496a 100644 --- a/util/mac/process_types.cc +++ b/snapshot/mac/process_types.cc @@ -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 #include #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* 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* 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* 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* 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 diff --git a/util/mac/process_types.h b/snapshot/mac/process_types.h similarity index 96% rename from util/mac/process_types.h rename to snapshot/mac/process_types.h index 00e08030..4915169b 100644 --- a/util/mac/process_types.h +++ b/snapshot/mac/process_types.h @@ -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 #include @@ -21,7 +21,7 @@ #include #include -#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_ diff --git a/util/mac/process_types/all.proctype b/snapshot/mac/process_types/all.proctype similarity index 67% rename from util/mac/process_types/all.proctype rename to snapshot/mac/process_types/all.proctype index 8191bb22..8c6e9d90 100644 --- a/util/mac/process_types/all.proctype +++ b/snapshot/mac/process_types/all.proctype @@ -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" diff --git a/util/mac/process_types/crashreporterclient.proctype b/snapshot/mac/process_types/crashreporterclient.proctype similarity index 92% rename from util/mac/process_types/crashreporterclient.proctype rename to snapshot/mac/process_types/crashreporterclient.proctype index d604a32c..7d83c233 100644 --- a/util/mac/process_types/crashreporterclient.proctype +++ b/snapshot/mac/process_types/crashreporterclient.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 diff --git a/util/mac/process_types/custom.cc b/snapshot/mac/process_types/custom.cc similarity index 96% rename from util/mac/process_types/custom.cc rename to snapshot/mac/process_types/custom.cc index 1de19ff9..49553cf9 100644 --- a/util/mac/process_types/custom.cc +++ b/snapshot/mac/process_types/custom.cc @@ -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 -#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::ReadInto( mach_vm_address_t, \ dyld_all_image_infos*); -#include "util/mac/process_types/flavors.h" +#include "snapshot/mac/process_types/flavors.h" #undef PROCESS_TYPE_FLAVOR_TRAITS diff --git a/util/mac/process_types/dyld_images.proctype b/snapshot/mac/process_types/dyld_images.proctype similarity index 92% rename from util/mac/process_types/dyld_images.proctype rename to snapshot/mac/process_types/dyld_images.proctype index 643f54c0..de59a86c 100644 --- a/util/mac/process_types/dyld_images.proctype +++ b/snapshot/mac/process_types/dyld_images.proctype @@ -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. diff --git a/util/mac/process_types/flavors.h b/snapshot/mac/process_types/flavors.h similarity index 77% rename from util/mac/process_types/flavors.h rename to snapshot/mac/process_types/flavors.h index 36849955..01ab2bd7 100644 --- a/util/mac/process_types/flavors.h +++ b/snapshot/mac/process_types/flavors.h @@ -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) diff --git a/util/mac/process_types/internal.h b/snapshot/mac/process_types/internal.h similarity index 73% rename from util/mac/process_types/internal.h rename to snapshot/mac/process_types/internal.h index 60b2cc36..fd956574 100644 --- a/util/mac/process_types/internal.h +++ b/snapshot/mac/process_types/internal.h @@ -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_ diff --git a/util/mac/process_types/loader.proctype b/snapshot/mac/process_types/loader.proctype similarity index 97% rename from util/mac/process_types/loader.proctype rename to snapshot/mac/process_types/loader.proctype index db82e6b6..177e6f72 100644 --- a/util/mac/process_types/loader.proctype +++ b/snapshot/mac/process_types/loader.proctype @@ -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 diff --git a/util/mac/process_types/nlist.proctype b/snapshot/mac/process_types/nlist.proctype similarity index 89% rename from util/mac/process_types/nlist.proctype rename to snapshot/mac/process_types/nlist.proctype index ca2b0014..c8989139 100644 --- a/util/mac/process_types/nlist.proctype +++ b/snapshot/mac/process_types/nlist.proctype @@ -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) diff --git a/util/mac/process_types/traits.h b/snapshot/mac/process_types/traits.h similarity index 93% rename from util/mac/process_types/traits.h rename to snapshot/mac/process_types/traits.h index 4706573d..6eac49ad 100644 --- a/util/mac/process_types/traits.h +++ b/snapshot/mac/process_types/traits.h @@ -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 diff --git a/util/mac/process_types_test.cc b/snapshot/mac/process_types_test.cc similarity index 99% rename from util/mac/process_types_test.cc rename to snapshot/mac/process_types_test.cc index 93ecc2aa..3333fd6a 100644 --- a/util/mac/process_types_test.cc +++ b/snapshot/mac/process_types_test.cc @@ -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 #include diff --git a/snapshot/system_snapshot_mac.cc b/snapshot/mac/system_snapshot_mac.cc similarity index 99% rename from snapshot/system_snapshot_mac.cc rename to snapshot/mac/system_snapshot_mac.cc index 2f6e6985..185372dd 100644 --- a/snapshot/system_snapshot_mac.cc +++ b/snapshot/mac/system_snapshot_mac.cc @@ -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 #include @@ -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 { diff --git a/snapshot/system_snapshot_mac.h b/snapshot/mac/system_snapshot_mac.h similarity index 95% rename from snapshot/system_snapshot_mac.h rename to snapshot/mac/system_snapshot_mac.h index 3eadc372..b364688f 100644 --- a/snapshot/system_snapshot_mac.h +++ b/snapshot/mac/system_snapshot_mac.h @@ -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 @@ -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_ diff --git a/snapshot/system_snapshot_mac_test.cc b/snapshot/mac/system_snapshot_mac_test.cc similarity index 98% rename from snapshot/system_snapshot_mac_test.cc rename to snapshot/mac/system_snapshot_mac_test.cc index f7f1652c..b69ccac2 100644 --- a/snapshot/system_snapshot_mac_test.cc +++ b/snapshot/mac/system_snapshot_mac_test.cc @@ -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 #include @@ -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 { diff --git a/snapshot/thread_snapshot_mac.cc b/snapshot/mac/thread_snapshot_mac.cc similarity index 96% rename from snapshot/thread_snapshot_mac.cc rename to snapshot/mac/thread_snapshot_mac.cc index 71de1fc2..0b7607ca 100644 --- a/snapshot/thread_snapshot_mac.cc +++ b/snapshot/mac/thread_snapshot_mac.cc @@ -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 { diff --git a/snapshot/thread_snapshot_mac.h b/snapshot/mac/thread_snapshot_mac.h similarity index 92% rename from snapshot/thread_snapshot_mac.h rename to snapshot/mac/thread_snapshot_mac.h index b9982093..1a9634aa 100644 --- a/snapshot/thread_snapshot_mac.h +++ b/snapshot/mac/thread_snapshot_mac.h @@ -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 #include @@ -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_ diff --git a/snapshot/snapshot.gyp b/snapshot/snapshot.gyp index 4140c841..4fa34c93 100644 --- a/snapshot/snapshot.gyp +++ b/snapshot/snapshot.gyp @@ -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', ], }, ], diff --git a/util/mac/checked_mach_address_range.cc b/util/mac/checked_mach_address_range.cc index 0f153a4d..5fdabe36 100644 --- a/util/mac/checked_mach_address_range.cc +++ b/util/mac/checked_mach_address_range.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; diff --git a/util/mac/checked_mach_address_range.h b/util/mac/checked_mach_address_range.h index ac310c1e..717bb8d9 100644 --- a/util/mac/checked_mach_address_range.h +++ b/util/mac/checked_mach_address_range.h @@ -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. diff --git a/util/mac/checked_mach_address_range_test.cc b/util/mac/checked_mach_address_range_test.cc index b0f36c3d..702715d0 100644 --- a/util/mac/checked_mach_address_range_test.cc +++ b/util/mac/checked_mach_address_range_test.cc @@ -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()) { - 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)); - } + 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,27 +229,26 @@ 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); - EXPECT_FALSE(parent_range_64.ContainsRange(child_range_64)); + CheckedMachAddressRange parent_range_64(true, 0x100000000, 0x1000); + ASSERT_TRUE(parent_range_64.IsValid()); - child_range_64.SetRange(&process_reader, 0x100000000, 2); - EXPECT_TRUE(parent_range_64.ContainsRange(child_range_64)); + CheckedMachAddressRange child_range_64(true, 0xffffffff, 2); + EXPECT_FALSE(parent_range_64.ContainsRange(child_range_64)); - child_range_64.SetRange(&process_reader, 0x100000ffe, 2); - EXPECT_TRUE(parent_range_64.ContainsRange(child_range_64)); + child_range_64.SetRange(true, 0x100000000, 2); + EXPECT_TRUE(parent_range_64.ContainsRange(child_range_64)); - child_range_64.SetRange(&process_reader, 0x100000fff, 2); - EXPECT_FALSE(parent_range_64.ContainsRange(child_range_64)); - } + child_range_64.SetRange(true, 0x100000ffe, 2); + EXPECT_TRUE(parent_range_64.ContainsRange(child_range_64)); + + child_range_64.SetRange(true, 0x100000fff, 2); + EXPECT_FALSE(parent_range_64.ContainsRange(child_range_64)); } } // namespace diff --git a/util/util.gyp b/util/util.gyp index c0fb13b3..f6c5dcff 100644 --- a/util/util.gyp +++ b/util/util.gyp @@ -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',