Issue 261/262: 64-bit bug fix when iterating through load commands of a 64-bit binary, and added new test case for ReadImageInfoForTask

git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@266 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
nealsid 2008-05-05 18:20:04 +00:00
parent d6f0f92de3
commit 47df365bf8
4 changed files with 21 additions and 140 deletions

View file

@ -210,7 +210,11 @@ void DynamicImage::CalculateMemoryInfo() {
reinterpret_cast<const struct load_command *>(header + 1); reinterpret_cast<const struct load_command *>(header + 1);
for (unsigned int i = 0; cmd && (i < header->ncmds); ++i) { for (unsigned int i = 0; cmd && (i < header->ncmds); ++i) {
#ifdef __LP64__
if (cmd->cmd == LC_SEGMENT_64) {
#else
if (cmd->cmd == LC_SEGMENT) { if (cmd->cmd == LC_SEGMENT) {
#endif
const breakpad_mach_segment_command *seg = const breakpad_mach_segment_command *seg =
reinterpret_cast<const breakpad_mach_segment_command *>(cmd); reinterpret_cast<const breakpad_mach_segment_command *>(cmd);

View file

@ -391,7 +391,7 @@
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh; 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 "; 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_tests64\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 */ = { F9AE5B310DBFDBA300505983 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;
@ -610,107 +610,6 @@
}; };
name = Release; name = Release;
}; };
F996CB8C0DB40AE30089CCC8 /* Coverage */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
OTHER_LDFLAGS = "-lcrypto";
PREBINDING = NO;
SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
};
name = Coverage;
};
F996CB8D0DB40AE30089CCC8 /* Coverage */ = {
isa = XCBuildConfiguration;
buildSettings = {
COPY_PHASE_STRIP = NO;
GCC_CW_ASM_SYNTAX = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_ENABLE_PASCAL_STRINGS = NO;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_THREADSAFE_STATICS = NO;
INSTALL_PATH = "$(HOME)/bin";
PRODUCT_NAME = generator_test;
USER_HEADER_SEARCH_PATHS = "../../../** $(inherited)";
ZERO_LINK = NO;
};
name = Coverage;
};
F996CB8E0DB40AE30089CCC8 /* Coverage */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(NATIVE_ARCH)";
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
INSTALL_PATH = "$(HOME)/bin";
OTHER_CFLAGS = "-Wall";
PREBINDING = NO;
PRODUCT_NAME = handler_test;
USER_HEADER_SEARCH_PATHS = "../../.. $(inherited)";
ZERO_LINK = NO;
};
name = Coverage;
};
F996CB8F0DB40AE30089CCC8 /* Coverage */ = {
isa = XCBuildConfiguration;
buildSettings = {
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
INSTALL_PATH = "$(HOME)/bin";
PREBINDING = NO;
PRODUCT_NAME = unit_test;
USER_HEADER_SEARCH_PATHS = "../../../** $(inherited)";
ZERO_LINK = NO;
};
name = Coverage;
};
F996CB900DB40AE30089CCC8 /* Coverage */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = (
"$(NATIVE_ARCH_64_BIT)",
ppc64,
);
COPY_PHASE_STRIP = NO;
FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks";
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_FIX_AND_CONTINUE = NO;
GCC_GENERATE_TEST_COVERAGE_FILES = YES;
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES;
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_tests64-Info.plist";
INSTALL_PATH = "$(USER_LIBRARY_DIR)/Bundles";
MACOSX_DEPLOYMENT_TARGET = 10.5;
OTHER_LDFLAGS = (
"-framework",
Carbon,
"-framework",
CPlusTest,
"-lgcov",
);
PREBINDING = NO;
PRODUCT_NAME = minidump_tests64;
SDKROOT = /Developer/SDKs/MacOSX10.5.sdk;
USER_HEADER_SEARCH_PATHS = "../../../**";
WRAPPER_EXTENSION = cptest;
};
name = Coverage;
};
F9AE19C40DB04A9500C98454 /* Debug */ = { F9AE19C40DB04A9500C98454 /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
@ -778,10 +677,7 @@
F9AE5B350DBFDBA300505983 /* Debug */ = { F9AE5B350DBFDBA300505983 /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ARCHS = ( ARCHS = "$(NATIVE_ARCH)";
"$(NATIVE_ARCH)",
ppc,
);
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks"; FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks";
GCC_DYNAMIC_NO_PIC = NO; GCC_DYNAMIC_NO_PIC = NO;
@ -805,33 +701,6 @@
}; };
name = Debug; 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 */ = { F9AE5B370DBFDBA300505983 /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
@ -869,7 +738,6 @@
isa = XCConfigurationList; isa = XCConfigurationList;
buildConfigurations = ( buildConfigurations = (
1DEB923208733DC60010E9CD /* Debug */, 1DEB923208733DC60010E9CD /* Debug */,
F996CB8D0DB40AE30089CCC8 /* Coverage */,
1DEB923308733DC60010E9CD /* Release */, 1DEB923308733DC60010E9CD /* Release */,
); );
defaultConfigurationIsVisible = 0; defaultConfigurationIsVisible = 0;
@ -879,7 +747,6 @@
isa = XCConfigurationList; isa = XCConfigurationList;
buildConfigurations = ( buildConfigurations = (
1DEB923608733DC60010E9CD /* Debug */, 1DEB923608733DC60010E9CD /* Debug */,
F996CB8C0DB40AE30089CCC8 /* Coverage */,
1DEB923708733DC60010E9CD /* Release */, 1DEB923708733DC60010E9CD /* Release */,
); );
defaultConfigurationIsVisible = 0; defaultConfigurationIsVisible = 0;
@ -889,7 +756,6 @@
isa = XCConfigurationList; isa = XCConfigurationList;
buildConfigurations = ( buildConfigurations = (
9B7CA8510B12984300CD3A1D /* Debug */, 9B7CA8510B12984300CD3A1D /* Debug */,
F996CB8F0DB40AE30089CCC8 /* Coverage */,
9B7CA8520B12984300CD3A1D /* Release */, 9B7CA8520B12984300CD3A1D /* Release */,
); );
defaultConfigurationIsVisible = 0; defaultConfigurationIsVisible = 0;
@ -899,7 +765,6 @@
isa = XCConfigurationList; isa = XCConfigurationList;
buildConfigurations = ( buildConfigurations = (
9BD82AA70B0026BF0055103E /* Debug */, 9BD82AA70B0026BF0055103E /* Debug */,
F996CB8E0DB40AE30089CCC8 /* Coverage */,
9BD82AA80B0026BF0055103E /* Release */, 9BD82AA80B0026BF0055103E /* Release */,
); );
defaultConfigurationIsVisible = 0; defaultConfigurationIsVisible = 0;
@ -909,7 +774,6 @@
isa = XCConfigurationList; isa = XCConfigurationList;
buildConfigurations = ( buildConfigurations = (
F9AE19C40DB04A9500C98454 /* Debug */, F9AE19C40DB04A9500C98454 /* Debug */,
F996CB900DB40AE30089CCC8 /* Coverage */,
F9AE19C50DB04A9500C98454 /* Release */, F9AE19C50DB04A9500C98454 /* Release */,
); );
defaultConfigurationIsVisible = 0; defaultConfigurationIsVisible = 0;
@ -919,7 +783,6 @@
isa = XCConfigurationList; isa = XCConfigurationList;
buildConfigurations = ( buildConfigurations = (
F9AE5B350DBFDBA300505983 /* Debug */, F9AE5B350DBFDBA300505983 /* Debug */,
F9AE5B360DBFDBA300505983 /* Coverage */,
F9AE5B370DBFDBA300505983 /* Release */, F9AE5B370DBFDBA300505983 /* Release */,
); );
defaultConfigurationIsVisible = 0; defaultConfigurationIsVisible = 0;

View file

@ -39,12 +39,13 @@
DynamicImagesTests test2(TEST_INVOCATION(DynamicImagesTests, DynamicImagesTests test2(TEST_INVOCATION(DynamicImagesTests,
ReadTaskMemoryTest)); ReadTaskMemoryTest));
DynamicImagesTests test3(TEST_INVOCATION(DynamicImagesTests,
ReadLibrariesFromLocalTaskTest));
DynamicImagesTests::DynamicImagesTests(TestInvocation *invocation) DynamicImagesTests::DynamicImagesTests(TestInvocation *invocation)
: TestCase(invocation) { : TestCase(invocation) {
} }
DynamicImagesTests::~DynamicImagesTests() { DynamicImagesTests::~DynamicImagesTests() {
} }
@ -70,3 +71,15 @@ void DynamicImagesTests::ReadTaskMemoryTest() {
free(buf); free(buf);
} }
void DynamicImagesTests::ReadLibrariesFromLocalTaskTest() {
mach_port_t me = mach_task_self();
google_breakpad::DynamicImages *d = new google_breakpad::DynamicImages(me);
fprintf(stderr,"Local task image count: %d\n", d->GetImageCount());
d->TestPrint();
CPTAssert(d->GetImageCount() > 0);
}

View file

@ -46,6 +46,7 @@ class DynamicImagesTests : public TestCase {
virtual ~DynamicImagesTests(); virtual ~DynamicImagesTests();
void ReadTaskMemoryTest(); void ReadTaskMemoryTest();
void ReadLibrariesFromLocalTaskTest();
}; };
#endif /* _CLIENT_MAC_HANDLER_TESTCASES_DYNAMICIMAGESTESTS_H__ */ #endif /* _CLIENT_MAC_HANDLER_TESTCASES_DYNAMICIMAGESTESTS_H__ */