diff options
author | nealsid <nealsid@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2008-04-25 00:37:19 +0000 |
---|---|---|
committer | nealsid <nealsid@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2008-04-25 00:37:19 +0000 |
commit | 4c39c138fe2a68206c2143d7401a113a1c4b130b (patch) | |
tree | 3fce0e66f9fafc93cfc16c5db17458222cbf832a /src/client | |
parent | Add one more parameter to the ClientDumpRequestCallback in crash generation s... (diff) | |
download | breakpad-4c39c138fe2a68206c2143d7401a113a1c4b130b.tar.xz |
Issue 258: Added test cases for ReadTaskMemory, reorganized project file, renamed filenames inside comments
git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@263 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/mac/handler/breakpad_nlist_test.cc | 81 | ||||
-rw-r--r-- | src/client/mac/handler/breakpad_nlist_test.h | 43 | ||||
-rw-r--r-- | src/client/mac/handler/dynamic_images.cc | 34 | ||||
-rw-r--r-- | src/client/mac/handler/dynamic_images.h | 5 | ||||
-rw-r--r-- | src/client/mac/handler/minidump_generator.cc | 9 | ||||
-rw-r--r-- | src/client/mac/handler/minidump_test.xcodeproj/project.pbxproj | 213 | ||||
-rw-r--r-- | src/client/mac/handler/minidump_tests32-Info.plist (renamed from src/client/mac/handler/minidump_tests-Info.plist) | 2 | ||||
-rw-r--r-- | src/client/mac/handler/minidump_tests64-Info.plist | 22 | ||||
-rw-r--r-- | src/client/mac/handler/testcases/DynamicImagesTests.cc | 48 | ||||
-rw-r--r-- | src/client/mac/handler/testcases/DynamicImagesTests.h | 19 | ||||
-rw-r--r-- | src/client/mac/handler/testcases/breakpad_nlist_test.cc | 81 | ||||
-rw-r--r-- | src/client/mac/handler/testcases/breakpad_nlist_test.h | 29 |
12 files changed, 429 insertions, 157 deletions
diff --git a/src/client/mac/handler/breakpad_nlist_test.cc b/src/client/mac/handler/breakpad_nlist_test.cc index d0dd2f6a..e69de29b 100644 --- a/src/client/mac/handler/breakpad_nlist_test.cc +++ b/src/client/mac/handler/breakpad_nlist_test.cc @@ -1,81 +0,0 @@ -/* - * BreakpadNlistTest.cpp - * minidump_test - * - * Created by Neal Sidhwaney on 4/13/08. - * Copyright 2008 Google Inc. All rights reserved. - * - */ - -#include "breakpad_nlist_test.h" -#include <mach-o/nlist.h> -#include "breakpad_nlist_64.h" - -BreakpadNlistTest test1(TEST_INVOCATION(BreakpadNlistTest, CompareToNM)); - -BreakpadNlistTest::BreakpadNlistTest(TestInvocation *invocation) - : TestCase(invocation) { -} - - -BreakpadNlistTest::~BreakpadNlistTest() { -} - -void BreakpadNlistTest::CompareToNM() { -#if TARGET_CPU_X86_64 - system("/usr/bin/nm -arch x86_64 /usr/lib/dyld > /tmp/dyld-namelist.txt"); -#elif TARGET_CPU_PPC64 - system("/usr/bin/nm -arch ppc64 /usr/lib/dyld > /tmp/dyld-namelist.txt"); -#endif - - FILE *fd = fopen("/tmp/dyld-namelist.txt","rt"); - - char oneNMAddr[30]; - char symbolType; - char symbolName[500]; - while(!feof(fd)) { - fscanf(fd,"%s %c %s",oneNMAddr, &symbolType, symbolName); - breakpad_nlist symbolList[2]; - breakpad_nlist &list = symbolList[0]; - - memset(symbolList,0, sizeof(breakpad_nlist)*2); - const char *symbolNames[2]; - symbolNames[0] = (const char*)symbolName; - symbolNames[1] = "\0"; - breakpad_nlist_64("/usr/lib/dyld",&list, symbolNames); - uint64_t nmAddr = strtol(oneNMAddr,NULL,16); - if(!IsSymbolMoreThanOnceInDyld(symbolName)) { - CPTAssert(nmAddr == symbolList[0].n_value); - } - } - - fclose(fd); -} - -bool BreakpadNlistTest::IsSymbolMoreThanOnceInDyld(const char *symbolName) { - //These are the symbols that occur more than once when nm dumps - // the symbol table of /usr/lib/dyld. Our nlist program returns - // the first address because it's doing a search so we need to exclude - // these from causing the test to fail - const char *multipleSymbols[] = { - "__Z41__static_initialization_and_destruction_0ii", - "___tcf_0", - "___tcf_1", - "_read_encoded_value_with_base", - "_read_sleb128", - "_read_uleb128", - "\0"}; - - bool found = false; - - for(int i = 0; multipleSymbols[i][0]; i++) { - if(!strcmp(multipleSymbols[i],symbolName)) { - found = true; - break; - } - - } - - return found; - -} diff --git a/src/client/mac/handler/breakpad_nlist_test.h b/src/client/mac/handler/breakpad_nlist_test.h index c778a9b3..e69de29b 100644 --- a/src/client/mac/handler/breakpad_nlist_test.h +++ b/src/client/mac/handler/breakpad_nlist_test.h @@ -1,43 +0,0 @@ -/* - * BreakpadNlistTest.h - * minidump_test - * - * Created by Neal Sidhwaney on 4/13/08. - * Copyright 2008 Google Inc. All rights reserved. - * - */ - -#include <CPlusTest/CPlusTest.h> - -/* -__Z41__static_initialization_and_destruction_0ii -__Z41__static_initialization_and_destruction_0ii -__Z41__static_initialization_and_destruction_0ii -___tcf_0 -___tcf_0 -___tcf_0 -___tcf_1 -_read_encoded_value_with_base -_read_sleb128 -_read_uleb128 - -*/ - -class BreakpadNlistTest : public TestCase { -private: - - // nm dumps multiple addresses for the same symbol in - // /usr/lib/dyld. So we track those so we don't report failures - // in mismatches between what our nlist returns and what nm has - // for the duplicate symbols. - bool IsSymbolMoreThanOnceInDyld(const char *symbolName); - -public: - BreakpadNlistTest(TestInvocation* invocation); - virtual ~BreakpadNlistTest(); - - - /* This test case runs nm on /usr/lib/dyld and then compares the - output of every symbol to what our nlist implementation returns */ - void CompareToNM(); -}; diff --git a/src/client/mac/handler/dynamic_images.cc b/src/client/mac/handler/dynamic_images.cc index 0d63d5a7..d48c2f6b 100644 --- a/src/client/mac/handler/dynamic_images.cc +++ b/src/client/mac/handler/dynamic_images.cc @@ -31,9 +31,9 @@ extern "C" { // needed to compile on Leopard #include <mach-o/nlist.h> #include <stdlib.h> #include <stdio.h> - #include "breakpad_nlist_64.h" } +#include "breakpad_nlist_64.h" #include <dlfcn.h> #include <mach/mach_vm.h> #include <algorithm> @@ -128,7 +128,8 @@ static void* ReadTaskString(task_port_t target_task, mach_vm_size_t size_to_read = size_to_end > kMaxStringLength ? kMaxStringLength : size_to_end; - return ReadTaskMemory(target_task, address, size_to_read); + kern_return_t kr; + return ReadTaskMemory(target_task, address, size_to_read, &kr); } return NULL; @@ -139,7 +140,8 @@ static void* ReadTaskString(task_port_t target_task, // and should be freed by the caller. void* ReadTaskMemory(task_port_t target_task, const void* address, - size_t length) { + size_t length, + kern_return_t *kr) { void* result = NULL; int systemPageSize = getpagesize(); @@ -155,12 +157,19 @@ void* ReadTaskMemory(task_port_t target_task, uint8_t* local_start; uint32_t local_length; - kern_return_t r = mach_vm_read(target_task, - page_address, - page_size, - reinterpret_cast<vm_offset_t*>(&local_start), - &local_length); + kern_return_t r; + r = mach_vm_read(target_task, + page_address, + page_size, + reinterpret_cast<vm_offset_t*>(&local_start), + &local_length); + + + if(kr != NULL) { + *kr = r; + } + if (r == KERN_SUCCESS) { result = malloc(length); if (result != NULL) { @@ -289,6 +298,7 @@ void DynamicImages::ReadImageInfoForTask() { void *imageList = GetDyldAllImageInfosPointer(); if (imageList) { + kern_return_t kr; // Read the structure inside of dyld that contains information about // loaded images. We're reading from the desired task's address space. @@ -298,7 +308,7 @@ void DynamicImages::ReadImageInfoForTask() { dyld_all_image_infos *dyldInfo = reinterpret_cast<dyld_all_image_infos*> (ReadTaskMemory(task_, reinterpret_cast<void*>(imageList), - sizeof(dyld_all_image_infos))); + sizeof(dyld_all_image_infos), &kr)); if (dyldInfo) { // number of loaded images @@ -309,7 +319,7 @@ void DynamicImages::ReadImageInfoForTask() { dyld_image_info *infoArray = reinterpret_cast<dyld_image_info*> (ReadTaskMemory(task_, dyldInfo->infoArray, - count*sizeof(dyld_image_info))); + count*sizeof(dyld_image_info), &kr)); image_list_.reserve(count); @@ -320,7 +330,7 @@ void DynamicImages::ReadImageInfoForTask() { breakpad_mach_header *header = reinterpret_cast<breakpad_mach_header*> (ReadTaskMemory(task_, info.load_address_, - sizeof(breakpad_mach_header))); + sizeof(breakpad_mach_header), &kr)); if (!header) break; // bail on this dynamic image @@ -334,7 +344,7 @@ void DynamicImages::ReadImageInfoForTask() { free(header); header = reinterpret_cast<breakpad_mach_header*> - (ReadTaskMemory(task_, info.load_address_, header_size)); + (ReadTaskMemory(task_, info.load_address_, header_size, &kr)); // Read the file name from the task's memory space. char *file_path = NULL; diff --git a/src/client/mac/handler/dynamic_images.h b/src/client/mac/handler/dynamic_images.h index f8e68110..5764280b 100644 --- a/src/client/mac/handler/dynamic_images.h +++ b/src/client/mac/handler/dynamic_images.h @@ -303,7 +303,10 @@ class DynamicImages { // Returns a malloced block containing the contents of memory at a particular // location in another task. -void* ReadTaskMemory(task_port_t target_task, const void* address, size_t len); +void* ReadTaskMemory(task_port_t target_task, + const void* address, + size_t len, + kern_return_t *kr); } // namespace google_breakpad diff --git a/src/client/mac/handler/minidump_generator.cc b/src/client/mac/handler/minidump_generator.cc index 1bc4407c..996940fb 100644 --- a/src/client/mac/handler/minidump_generator.cc +++ b/src/client/mac/handler/minidump_generator.cc @@ -268,9 +268,16 @@ bool MinidumpGenerator::WriteStackFromStartAddress( bool result; if (dynamic_images_) { + kern_return_t kr; + void *stack_memory = ReadTaskMemory(crashing_task_, (void*)start_addr, - size); + size, + &kr); + + if(stack_memory == NULL) { + return false; + } result = memory.Copy(stack_memory, size); free(stack_memory); diff --git a/src/client/mac/handler/minidump_test.xcodeproj/project.pbxproj b/src/client/mac/handler/minidump_test.xcodeproj/project.pbxproj index 8e3e9567..5b9b7d25 100644 --- a/src/client/mac/handler/minidump_test.xcodeproj/project.pbxproj +++ b/src/client/mac/handler/minidump_test.xcodeproj/project.pbxproj @@ -51,6 +51,10 @@ D2F651210BEF975400920385 /* macho_walker.cc in Sources */ = {isa = PBXBuildFile; fileRef = D2F6510C0BEF94EB00920385 /* macho_walker.cc */; }; F982089C0DB3280D0017AECA /* breakpad_nlist_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = F982089B0DB3280D0017AECA /* breakpad_nlist_test.cc */; }; F98208A30DB32CAE0017AECA /* breakpad_nlist_64.cc in Sources */ = {isa = PBXBuildFile; fileRef = F98208A10DB32CAE0017AECA /* breakpad_nlist_64.cc */; }; + F9AE5B390DBFDBDB00505983 /* dynamic_images.cc in Sources */ = {isa = PBXBuildFile; fileRef = D2F651070BEF949A00920385 /* dynamic_images.cc */; }; + F9AE5B3A0DBFDBDB00505983 /* DynamicImagesTests.cc in Sources */ = {isa = PBXBuildFile; fileRef = F9C5A4210DB82DD800209C76 /* DynamicImagesTests.cc */; }; + F9B34E870DBC1E1600306484 /* dynamic_images.cc in Sources */ = {isa = PBXBuildFile; fileRef = D2F651070BEF949A00920385 /* dynamic_images.cc */; }; + F9C5A4220DB82DD800209C76 /* DynamicImagesTests.cc in Sources */ = {isa = PBXBuildFile; fileRef = F9C5A4210DB82DD800209C76 /* DynamicImagesTests.cc */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -112,8 +116,12 @@ F982089B0DB3280D0017AECA /* breakpad_nlist_test.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = breakpad_nlist_test.cc; sourceTree = "<group>"; }; F98208A10DB32CAE0017AECA /* breakpad_nlist_64.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = breakpad_nlist_64.cc; sourceTree = "<group>"; }; F98208A20DB32CAE0017AECA /* breakpad_nlist_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = breakpad_nlist_64.h; sourceTree = "<group>"; }; - F9AE19B50DB040E300C98454 /* minidump_tests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "minidump_tests-Info.plist"; sourceTree = "<group>"; }; - F9AE19C30DB04A9500C98454 /* minidump_tests.cptest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = minidump_tests.cptest; sourceTree = BUILT_PRODUCTS_DIR; }; + F9AE19B50DB040E300C98454 /* minidump_tests32-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "minidump_tests32-Info.plist"; sourceTree = "<group>"; }; + F9AE19C30DB04A9500C98454 /* minidump_tests64.cptest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = minidump_tests64.cptest; sourceTree = BUILT_PRODUCTS_DIR; }; + F9AE5B330DBFDBA300505983 /* minidump_tests32.cptest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = minidump_tests32.cptest; sourceTree = BUILT_PRODUCTS_DIR; }; + F9AE5B340DBFDBA300505983 /* minidump_tests64-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "minidump_tests64-Info.plist"; sourceTree = "<group>"; }; + F9C5A4200DB82DD800209C76 /* DynamicImagesTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DynamicImagesTests.h; sourceTree = "<group>"; }; + F9C5A4210DB82DD800209C76 /* DynamicImagesTests.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DynamicImagesTests.cc; sourceTree = "<group>"; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -147,6 +155,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + F9AE5B300DBFDBA300505983 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -165,13 +180,13 @@ D2F650FD0BEF947200920385 /* macho_id.h */, D2F650FE0BEF947200920385 /* macho_utilities.cc */, D2F650FF0BEF947200920385 /* macho_utilities.h */, + F9C5A41F0DB82DB000209C76 /* testcases */, 9BD82C040B0133420055103E /* Breakpad */, 08FB7795FE84155DC02AAC07 /* Source */, 9B37CEEA0AF98EB600FA4BD4 /* Frameworks */, 1AB674ADFE9D54B511CA2CBB /* Products */, - F9AE19B50DB040E300C98454 /* minidump_tests-Info.plist */, - F982089A0DB3280D0017AECA /* breakpad_nlist_test.h */, - F982089B0DB3280D0017AECA /* breakpad_nlist_test.cc */, + F9AE19B50DB040E300C98454 /* minidump_tests32-Info.plist */, + F9AE5B340DBFDBA300505983 /* minidump_tests64-Info.plist */, ); name = MinidumpWriter; sourceTree = "<group>"; @@ -192,7 +207,8 @@ 8DD76F6C0486A84900D96B5E /* generator_test */, 9BD82A9B0B00267E0055103E /* handler_test */, 9B7CA84E0B1297F200CD3A1D /* unit_test */, - F9AE19C30DB04A9500C98454 /* minidump_tests.cptest */, + F9AE19C30DB04A9500C98454 /* minidump_tests64.cptest */, + F9AE5B330DBFDBA300505983 /* minidump_tests32.cptest */, ); name = Products; sourceTree = "<group>"; @@ -225,6 +241,17 @@ name = Breakpad; sourceTree = "<group>"; }; + F9C5A41F0DB82DB000209C76 /* testcases */ = { + isa = PBXGroup; + children = ( + F982089A0DB3280D0017AECA /* breakpad_nlist_test.h */, + F982089B0DB3280D0017AECA /* breakpad_nlist_test.cc */, + F9C5A4200DB82DD800209C76 /* DynamicImagesTests.h */, + F9C5A4210DB82DD800209C76 /* DynamicImagesTests.cc */, + ); + path = testcases; + sourceTree = "<group>"; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -278,9 +305,9 @@ productReference = 9BD82A9B0B00267E0055103E /* handler_test */; productType = "com.apple.product-type.tool"; }; - F9AE19C20DB04A9500C98454 /* minidump_tests */ = { + F9AE19C20DB04A9500C98454 /* minidump_tests64 */ = { isa = PBXNativeTarget; - buildConfigurationList = F9AE19C70DB04AA200C98454 /* Build configuration list for PBXNativeTarget "minidump_tests" */; + buildConfigurationList = F9AE19C70DB04AA200C98454 /* Build configuration list for PBXNativeTarget "minidump_tests64" */; buildPhases = ( F9AE19BE0DB04A9500C98454 /* Resources */, F9AE19BF0DB04A9500C98454 /* Sources */, @@ -291,9 +318,27 @@ ); dependencies = ( ); - name = minidump_tests; + name = minidump_tests64; productName = minidump_tests; - productReference = F9AE19C30DB04A9500C98454 /* minidump_tests.cptest */; + productReference = F9AE19C30DB04A9500C98454 /* minidump_tests64.cptest */; + productType = "com.apple.product-type.bundle"; + }; + F9AE5B320DBFDBA300505983 /* minidump_tests32 */ = { + isa = PBXNativeTarget; + buildConfigurationList = F9AE5B380DBFDBA300505983 /* Build configuration list for PBXNativeTarget "minidump_tests32" */; + buildPhases = ( + F9AE5B2E0DBFDBA300505983 /* Resources */, + F9AE5B2F0DBFDBA300505983 /* Sources */, + F9AE5B300DBFDBA300505983 /* Frameworks */, + F9AE5B310DBFDBA300505983 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = minidump_tests32; + productName = Untitled; + productReference = F9AE5B330DBFDBA300505983 /* minidump_tests32.cptest */; productType = "com.apple.product-type.bundle"; }; /* End PBXNativeTarget section */ @@ -311,7 +356,8 @@ 8DD76F620486A84900D96B5E /* generator_test */, 9BD82A9A0B00267E0055103E /* handler_test */, 9B7CA84D0B1297F200CD3A1D /* unit_test */, - F9AE19C20DB04A9500C98454 /* minidump_tests */, + F9AE19C20DB04A9500C98454 /* minidump_tests64 */, + F9AE5B320DBFDBA300505983 /* minidump_tests32 */, ); }; /* End PBXProject section */ @@ -324,6 +370,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + F9AE5B2E0DBFDBA300505983 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ @@ -340,6 +393,19 @@ shellPath = /bin/sh; shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n# Run gcov on the framework getting tested\nif [ \"${CONFIGURATION}\" = 'Coverage' ];\nthen\n FRAMEWORK_NAME=minidump_tests\n FRAMEWORK_OBJ_DIR=${OBJROOT}/${PROJECT_NAME}.build/${CONFIGURATION}/${FRAMEWORK_NAME}.build/Objects-normal/${NATIVE_ARCH_ACTUAL}\n mkdir -p coverage\n pushd coverage\n echo find ${OBJROOT} -name *.gcda -exec gcov -o ${FRAMEWORK_OBJ_DIR} {} \\;\n find ${OBJROOT} -name *.gcda -exec gcov -o ${FRAMEWORK_OBJ_DIR} {} \\;\n popd\nfi "; }; + F9AE5B310DBFDBA300505983 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -396,8 +462,19 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + F9B34E870DBC1E1600306484 /* dynamic_images.cc in Sources */, F982089C0DB3280D0017AECA /* breakpad_nlist_test.cc in Sources */, F98208A30DB32CAE0017AECA /* breakpad_nlist_64.cc in Sources */, + F9C5A4220DB82DD800209C76 /* DynamicImagesTests.cc in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + F9AE5B2F0DBFDBA300505983 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + F9AE5B390DBFDBDB00505983 /* dynamic_images.cc in Sources */, + F9AE5B3A0DBFDBDB00505983 /* DynamicImagesTests.cc in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -616,7 +693,7 @@ GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Carbon.framework/Headers/Carbon.h"; - INFOPLIST_FILE = "minidump_tests-Info.plist"; + INFOPLIST_FILE = "minidump_tests64-Info.plist"; INSTALL_PATH = "$(USER_LIBRARY_DIR)/Bundles"; MACOSX_DEPLOYMENT_TARGET = 10.5; OTHER_LDFLAGS = ( @@ -627,8 +704,9 @@ "-lgcov", ); PREBINDING = NO; - PRODUCT_NAME = minidump_tests; + PRODUCT_NAME = minidump_tests64; SDKROOT = /Developer/SDKs/MacOSX10.5.sdk; + USER_HEADER_SEARCH_PATHS = "../../../**"; WRAPPER_EXTENSION = cptest; }; name = Coverage; @@ -648,7 +726,7 @@ GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Carbon.framework/Headers/Carbon.h"; - INFOPLIST_FILE = "minidump_tests-Info.plist"; + INFOPLIST_FILE = "minidump_tests64-Info.plist"; INSTALL_PATH = "$(USER_LIBRARY_DIR)/Bundles"; MACOSX_DEPLOYMENT_TARGET = 10.5; OTHER_LDFLAGS = ( @@ -658,8 +736,9 @@ CPlusTest, ); PREBINDING = NO; - PRODUCT_NAME = minidump_tests; + PRODUCT_NAME = minidump_tests64; SDKROOT = /Developer/SDKs/MacOSX10.5.sdk; + USER_HEADER_SEARCH_PATHS = "../../../**"; WRAPPER_EXTENSION = cptest; }; name = Debug; @@ -678,7 +757,7 @@ GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Carbon.framework/Headers/Carbon.h"; - INFOPLIST_FILE = "minidump_tests-Info.plist"; + INFOPLIST_FILE = "minidump_tests64-Info.plist"; INSTALL_PATH = "$(USER_LIBRARY_DIR)/Bundles"; MACOSX_DEPLOYMENT_TARGET = 10.5; OTHER_LDFLAGS = ( @@ -688,8 +767,96 @@ CPlusTest, ); PREBINDING = NO; - PRODUCT_NAME = minidump_tests; + PRODUCT_NAME = minidump_tests64; SDKROOT = /Developer/SDKs/MacOSX10.5.sdk; + USER_HEADER_SEARCH_PATHS = "../../../**"; + WRAPPER_EXTENSION = cptest; + ZERO_LINK = NO; + }; + name = Release; + }; + F9AE5B350DBFDBA300505983 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = ( + "$(NATIVE_ARCH)", + ppc, + ); + COPY_PHASE_STRIP = NO; + FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks"; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_FIX_AND_CONTINUE = NO; + GCC_MODEL_TUNING = G5; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Carbon.framework/Headers/Carbon.h"; + INFOPLIST_FILE = "minidump_tests32-Info.plist"; + INSTALL_PATH = "$(USER_LIBRARY_DIR)/Bundles"; + OTHER_LDFLAGS = ( + "-framework", + Carbon, + "-framework", + CPlusTest, + ); + PREBINDING = NO; + PRODUCT_NAME = minidump_tests32; + USER_HEADER_SEARCH_PATHS = "../../../**"; + WRAPPER_EXTENSION = cptest; + }; + name = Debug; + }; + F9AE5B360DBFDBA300505983 /* Coverage */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = ( + "$(NATIVE_ARCH)", + ppc, + ); + FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks"; + GCC_ENABLE_FIX_AND_CONTINUE = NO; + GCC_MODEL_TUNING = G5; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Carbon.framework/Headers/Carbon.h"; + INFOPLIST_FILE = "minidump_tests32-Info.plist"; + INSTALL_PATH = "$(USER_LIBRARY_DIR)/Bundles"; + OTHER_LDFLAGS = ( + "-framework", + Carbon, + "-framework", + CPlusTest, + ); + PREBINDING = NO; + PRODUCT_NAME = minidump_tests32; + USER_HEADER_SEARCH_PATHS = "../../../**"; + WRAPPER_EXTENSION = cptest; + }; + name = Coverage; + }; + F9AE5B370DBFDBA300505983 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = ( + "$(NATIVE_ARCH)", + ppc, + ); + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks"; + GCC_ENABLE_FIX_AND_CONTINUE = NO; + GCC_MODEL_TUNING = G5; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Carbon.framework/Headers/Carbon.h"; + INFOPLIST_FILE = "minidump_tests32-Info.plist"; + INSTALL_PATH = "$(USER_LIBRARY_DIR)/Bundles"; + OTHER_LDFLAGS = ( + "-framework", + Carbon, + "-framework", + CPlusTest, + ); + PREBINDING = NO; + PRODUCT_NAME = minidump_tests32; + USER_HEADER_SEARCH_PATHS = "../../../**"; WRAPPER_EXTENSION = cptest; ZERO_LINK = NO; }; @@ -738,7 +905,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - F9AE19C70DB04AA200C98454 /* Build configuration list for PBXNativeTarget "minidump_tests" */ = { + F9AE19C70DB04AA200C98454 /* Build configuration list for PBXNativeTarget "minidump_tests64" */ = { isa = XCConfigurationList; buildConfigurations = ( F9AE19C40DB04A9500C98454 /* Debug */, @@ -748,6 +915,16 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + F9AE5B380DBFDBA300505983 /* Build configuration list for PBXNativeTarget "minidump_tests32" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + F9AE5B350DBFDBA300505983 /* Debug */, + F9AE5B360DBFDBA300505983 /* Coverage */, + F9AE5B370DBFDBA300505983 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ }; rootObject = 08FB7793FE84155DC02AAC07 /* Project object */; diff --git a/src/client/mac/handler/minidump_tests-Info.plist b/src/client/mac/handler/minidump_tests32-Info.plist index 909bbe22..921ebf35 100644 --- a/src/client/mac/handler/minidump_tests-Info.plist +++ b/src/client/mac/handler/minidump_tests32-Info.plist @@ -7,7 +7,7 @@ <key>CFBundleExecutable</key> <string>${EXECUTABLE_NAME}</string> <key>CFBundleIdentifier</key> - <string>com.google.breakpad.minidump_tests</string> + <string>com.google.breakpad.minidump_tests32</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundlePackageType</key> diff --git a/src/client/mac/handler/minidump_tests64-Info.plist b/src/client/mac/handler/minidump_tests64-Info.plist new file mode 100644 index 00000000..acfbd309 --- /dev/null +++ b/src/client/mac/handler/minidump_tests64-Info.plist @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleExecutable</key> + <string>${EXECUTABLE_NAME}</string> + <key>CFBundleIdentifier</key> + <string>com.google.breakpad.minidump_tests64</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundlePackageType</key> + <string>BNDL</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>1.0</string> + <key>CSResourcesFileMapped</key> + <string>yes</string> +</dict> +</plist> diff --git a/src/client/mac/handler/testcases/DynamicImagesTests.cc b/src/client/mac/handler/testcases/DynamicImagesTests.cc new file mode 100644 index 00000000..15976a25 --- /dev/null +++ b/src/client/mac/handler/testcases/DynamicImagesTests.cc @@ -0,0 +1,48 @@ +/* + * DynamicImagesTests.cpp + * minidump_test + * + * Created by Neal Sidhwaney on 4/17/08. + * Copyright 2008 Google Inc. All rights reserved. + * + */ + +#include "DynamicImagesTests.h" +#include "dynamic_images.h" + +DynamicImagesTests test2(TEST_INVOCATION(DynamicImagesTests, ReadTaskMemoryTest)); + +DynamicImagesTests::DynamicImagesTests(TestInvocation *invocation) + : TestCase(invocation) +{ +} + + +DynamicImagesTests::~DynamicImagesTests() +{ +} + +void DynamicImagesTests::ReadTaskMemoryTest() +{ + kern_return_t kr; + + // pick test2 as a symbol we know to be valid to read + // anything will work, really + void *addr = (void*)&test2; + + void *buf; + fprintf(stderr, "reading 0x%p\n",addr); + buf = google_breakpad::ReadTaskMemory(mach_task_self(), + addr, + getpagesize(), + &kr); + + CPTAssert(kr == KERN_SUCCESS); + + CPTAssert(buf != NULL); + + CPTAssert(0 == memcmp(buf,(const void*)addr,getpagesize())); + + free(buf); + +} diff --git a/src/client/mac/handler/testcases/DynamicImagesTests.h b/src/client/mac/handler/testcases/DynamicImagesTests.h new file mode 100644 index 00000000..fd88fad8 --- /dev/null +++ b/src/client/mac/handler/testcases/DynamicImagesTests.h @@ -0,0 +1,19 @@ +/* + * DynamicImagesTests.h + * minidump_test + * + * Created by Neal Sidhwaney on 4/17/08. + * Copyright 2008 Google Inc. All rights reserved. + * + */ + +#include <CPlusTest/CPlusTest.h> + + +class DynamicImagesTests : public TestCase { +public: + DynamicImagesTests(TestInvocation* invocation); + virtual ~DynamicImagesTests(); + + void ReadTaskMemoryTest(); +}; diff --git a/src/client/mac/handler/testcases/breakpad_nlist_test.cc b/src/client/mac/handler/testcases/breakpad_nlist_test.cc new file mode 100644 index 00000000..990739dc --- /dev/null +++ b/src/client/mac/handler/testcases/breakpad_nlist_test.cc @@ -0,0 +1,81 @@ +/* + * breakpad_nlist_test.cc + * minidump_test + * + * Created by Neal Sidhwaney on 4/13/08. + * Copyright 2008 Google Inc. All rights reserved. + * + */ + +#include "breakpad_nlist_test.h" +#include <mach-o/nlist.h> +#include "breakpad_nlist_64.h" + +BreakpadNlistTest test1(TEST_INVOCATION(BreakpadNlistTest, CompareToNM)); + +BreakpadNlistTest::BreakpadNlistTest(TestInvocation *invocation) + : TestCase(invocation) { +} + + +BreakpadNlistTest::~BreakpadNlistTest() { +} + +void BreakpadNlistTest::CompareToNM() { +#if TARGET_CPU_X86_64 + system("/usr/bin/nm -arch x86_64 /usr/lib/dyld > /tmp/dyld-namelist.txt"); +#elif TARGET_CPU_PPC64 + system("/usr/bin/nm -arch ppc64 /usr/lib/dyld > /tmp/dyld-namelist.txt"); +#endif + + FILE *fd = fopen("/tmp/dyld-namelist.txt","rt"); + + char oneNMAddr[30]; + char symbolType; + char symbolName[500]; + while(!feof(fd)) { + fscanf(fd,"%s %c %s",oneNMAddr, &symbolType, symbolName); + breakpad_nlist symbolList[2]; + breakpad_nlist &list = symbolList[0]; + + memset(symbolList,0, sizeof(breakpad_nlist)*2); + const char *symbolNames[2]; + symbolNames[0] = (const char*)symbolName; + symbolNames[1] = "\0"; + breakpad_nlist_64("/usr/lib/dyld",&list, symbolNames); + uint64_t nmAddr = strtol(oneNMAddr,NULL,16); + if(!IsSymbolMoreThanOnceInDyld(symbolName)) { + CPTAssert(nmAddr == symbolList[0].n_value); + } + } + + fclose(fd); +} + +bool BreakpadNlistTest::IsSymbolMoreThanOnceInDyld(const char *symbolName) { + //These are the symbols that occur more than once when nm dumps + // the symbol table of /usr/lib/dyld. Our nlist program returns + // the first address because it's doing a search so we need to exclude + // these from causing the test to fail + const char *multipleSymbols[] = { + "__Z41__static_initialization_and_destruction_0ii", + "___tcf_0", + "___tcf_1", + "_read_encoded_value_with_base", + "_read_sleb128", + "_read_uleb128", + "\0"}; + + bool found = false; + + for(int i = 0; multipleSymbols[i][0]; i++) { + if(!strcmp(multipleSymbols[i],symbolName)) { + found = true; + break; + } + + } + + return found; + +} diff --git a/src/client/mac/handler/testcases/breakpad_nlist_test.h b/src/client/mac/handler/testcases/breakpad_nlist_test.h new file mode 100644 index 00000000..f2416e38 --- /dev/null +++ b/src/client/mac/handler/testcases/breakpad_nlist_test.h @@ -0,0 +1,29 @@ +/* + * breakpad_nlist_test.h + * minidump_test + * + * Created by Neal Sidhwaney on 4/13/08. + * Copyright 2008 Google Inc. All rights reserved. + * + */ + +#include <CPlusTest/CPlusTest.h> + +class BreakpadNlistTest : public TestCase { +private: + + // nm dumps multiple addresses for the same symbol in + // /usr/lib/dyld. So we track those so we don't report failures + // in mismatches between what our nlist returns and what nm has + // for the duplicate symbols. + bool IsSymbolMoreThanOnceInDyld(const char *symbolName); + +public: + BreakpadNlistTest(TestInvocation* invocation); + virtual ~BreakpadNlistTest(); + + + /* This test case runs nm on /usr/lib/dyld and then compares the + output of every symbol to what our nlist implementation returns */ + void CompareToNM(); +}; |