Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix some crash cases #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion DataController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ -(void)replaceColoumnAtIndex:(NSUInteger)index withString:(NSString *)str
//-----------------------------------------------------------------------------
- (void)writeString:(NSString *)str toFile:(FILE *)pFile
{
fwrite(CSTRING(str), [str length] + 1, 1, pFile);
if(str){
fwrite(CSTRING(str), [str length] + 1, 1, pFile);
}
}

//-----------------------------------------------------------------------------
Expand Down
47 changes: 25 additions & 22 deletions Document.mm
Original file line number Diff line number Diff line change
Expand Up @@ -448,28 +448,31 @@ - (void)handleDataTableChanged:(NSNotification *)notification
//----------------------------------------------------------------------------
- (void)handleThreadStateChanged:(NSNotification *)notification
{
if ([notification object] == dataController)
{
NSString * threadState = [[notification userInfo] objectForKey:MVStatusUserInfoKey];
if ([threadState isEqualToString:MVStatusTaskStarted] == YES)
{
if (OSAtomicIncrement32(&threadCount) == 1)
{
[progressIndicator setUsesThreadedAnimation:YES];
[progressIndicator startAnimation:nil];
[stopButton setHidden:NO];
}
}
else if ([threadState isEqualToString:MVStatusTaskTerminated] == YES)
{
if (OSAtomicDecrement32(&threadCount) == 0)
{
[progressIndicator stopAnimation:nil];
[statusText setStringValue:@""];
[stopButton setHidden:YES];
}
}
}
dispatch_async(dispatch_get_main_queue(), ^{
if ([notification object] == dataController)
{
NSString * threadState = [[notification userInfo] objectForKey:MVStatusUserInfoKey];
if ([threadState isEqualToString:MVStatusTaskStarted] == YES)
{
if (OSAtomicIncrement32(&threadCount) == 1)
{
[progressIndicator setUsesThreadedAnimation:YES];
[progressIndicator startAnimation:nil];
[stopButton setHidden:NO];
}
}
else if ([threadState isEqualToString:MVStatusTaskTerminated] == YES)
{
if (OSAtomicDecrement32(&threadCount) == 0)
{
[progressIndicator stopAnimation:nil];
[statusText setStringValue:@""];
[stopButton setHidden:YES];
}
}
}
});

}

//----------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<plist version="1.0">
<dict>
<key>CFBuildDate</key>
<string>Thu Apr 23 12:18:08 WEST 2015</string>
<string>Thu Mar 21 20:13:01 CST 2019</string>
<key>CFBuildNumber</key>
<string>9121</string>
<string>9132</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDocumentTypes</key>
Expand Down Expand Up @@ -44,7 +44,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>9121</string>
<string>9132</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.developer-tools</string>
<key>LSMinimumSystemVersion</key>
Expand Down
41 changes: 25 additions & 16 deletions LinkEdit.mm
Original file line number Diff line number Diff line change
Expand Up @@ -827,9 +827,10 @@ - (MVNode *) createSymbolsNode:parent
nameToStore = (nameToStore != nil
? [nameToStore stringByAppendingFormat:@"(%@)", symbolName]
: [NSString stringWithFormat:@"0x%X (%@)", nlist->n_value, symbolName]);

[symbolNames setObject:nameToStore
forKey:[NSNumber numberWithUnsignedLong:nlist->n_value]];
if(nameToStore){
[symbolNames setObject:nameToStore
forKey:[NSNumber numberWithUnsignedLong:nlist->n_value]];
}
}
}
else
Expand All @@ -841,8 +842,10 @@ - (MVNode *) createSymbolsNode:parent

// fill in lookup table with undefined sybols (key equals (-1) * index)
uint32_t key = *symbols.begin() - nlist - 1;
[symbolNames setObject:symbolName
forKey:[NSNumber numberWithUnsignedLong:key]];
if(symbolName){
[symbolNames setObject:symbolName
forKey:[NSNumber numberWithUnsignedLong:key]];
}
}

[node.details setAttributesFromRowIndex:bookmark:MVMetaDataAttributeName,symbolName,
Expand Down Expand Up @@ -991,9 +994,10 @@ - (MVNode *) createSymbols64Node:parent
nameToStore = (nameToStore != nil
? [nameToStore stringByAppendingFormat:@"(%@)", symbolName]
: [NSString stringWithFormat:@"0x%qX (%@)", nlist_64->n_value, symbolName]);

[symbolNames setObject:nameToStore
forKey:[NSNumber numberWithUnsignedLongLong:nlist_64->n_value]];
if(nameToStore){
[symbolNames setObject:nameToStore
forKey:[NSNumber numberWithUnsignedLongLong:nlist_64->n_value]];
}
}
}
else
Expand All @@ -1005,8 +1009,10 @@ - (MVNode *) createSymbols64Node:parent

// fill in lookup table with undefined sybols (key equals (-1) * index)
uint64_t key = *symbols_64.begin() - nlist_64 - 1;
[symbolNames setObject:symbolName
forKey:[NSNumber numberWithUnsignedLongLong:key]];
if(symbolName){
[symbolNames setObject:symbolName
forKey:[NSNumber numberWithUnsignedLongLong:key]];
}
}

[node.details setAttributesFromRowIndex:bookmark:MVMetaDataAttributeName,symbolName,
Expand Down Expand Up @@ -1174,10 +1180,11 @@ - (MVNode *) createISymbolsNode:parent
symbolName = [NSString stringWithFormat:@"[0x%X->LOCAL ABSOLUTE]",indirectAddress];
}
}

// fill in lookup table with special indirect sybols
[symbolNames setObject:symbolName
forKey:[NSNumber numberWithUnsignedLong:indirectAddress]];
if(symbolName){
// fill in lookup table with special indirect sybols
[symbolNames setObject:symbolName
forKey:[NSNumber numberWithUnsignedLong:indirectAddress]];
}
}

[node.details appendRow:@"":@"":@"Section"
Expand Down Expand Up @@ -1303,9 +1310,11 @@ - (MVNode *) createISymbols64Node:parent
}
}

if(symbolName){
// fill in lookup table with special indirect sybols
[symbolNames setObject:symbolName
forKey:[NSNumber numberWithUnsignedLongLong:indirectAddress]];
[symbolNames setObject:symbolName
forKey:[NSNumber numberWithUnsignedLongLong:indirectAddress]];
}
}

[node.details appendRow:@"":@"":@"Section"
Expand Down
10 changes: 8 additions & 2 deletions machoview.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
005039762243B5A20012A68C /* libc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 005039752243B5A20012A68C /* libc++.tbd */; };
256AC3DA0F4B6AC300CF3369 /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 256AC3D90F4B6AC300CF3369 /* AppController.mm */; };
3C0ADEB0169CD42600DA428E /* README in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3CE90DFC11F6107600543402 /* README */; };
3C0F958411F6589D0070A2FE /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 3C0F957E11F6589D0070A2FE /* InfoPlist.strings */; };
Expand Down Expand Up @@ -77,6 +78,7 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
005039752243B5A20012A68C /* libc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libc++.tbd"; path = "usr/lib/libc++.tbd"; sourceTree = SDKROOT; };
13E42FB307B3F0F600E4EEF1 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = "<absolute>"; };
256AC3D80F4B6AC300CF3369 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = "<group>"; };
256AC3D90F4B6AC300CF3369 /* AppController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppController.mm; sourceTree = "<group>"; };
Expand Down Expand Up @@ -216,6 +218,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
005039762243B5A20012A68C /* libc++.tbd in Frameworks */,
3CC0022211F64A45000F7A3D /* Cocoa.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -337,6 +340,7 @@
29B97323FDCFA39411CA2CEA /* Frameworks */ = {
isa = PBXGroup;
children = (
005039752243B5A20012A68C /* libc++.tbd */,
7B5E71E319B6829F00843CCE /* libcapstone.a */,
1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */,
1058C7A2FEA54F0111CA2CBB /* Other Frameworks */,
Expand Down Expand Up @@ -686,6 +690,7 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES;
COMBINE_HIDPI_IMAGES = YES;
CONFIGURATION_TEMP_DIR = "$(inherited)";
Expand Down Expand Up @@ -726,7 +731,7 @@
);
PRIVATE_HEADERS_FOLDER_PATH = "";
PRODUCT_NAME = MachOView;
SDKROOT = macosx10.9;
SDKROOT = macosx;
USER_HEADER_SEARCH_PATHS = "";
VALID_ARCHS = "$(inherited)";
VERSIONING_SYSTEM = "";
Expand All @@ -738,6 +743,7 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES;
COMBINE_HIDPI_IMAGES = YES;
CONFIGURATION_TEMP_DIR = "$(inherited)";
Expand Down Expand Up @@ -781,7 +787,7 @@
);
PRIVATE_HEADERS_FOLDER_PATH = "";
PRODUCT_NAME = MachOView;
SDKROOT = macosx10.9;
SDKROOT = macosx;
SKIP_INSTALL = NO;
USER_HEADER_SEARCH_PATHS = "";
VALID_ARCHS = "$(inherited)";
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?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>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8D1107260486CEB800E47090"
BuildableName = "MachOView.app"
BlueprintName = "MachOView"
ReferencedContainer = "container:machoview.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8D1107260486CEB800E47090"
BuildableName = "MachOView.app"
BlueprintName = "MachOView"
ReferencedContainer = "container:machoview.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8D1107260486CEB800E47090"
BuildableName = "MachOView.app"
BlueprintName = "MachOView"
ReferencedContainer = "container:machoview.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8D1107260486CEB800E47090"
BuildableName = "MachOView.app"
BlueprintName = "MachOView"
ReferencedContainer = "container:machoview.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -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>SchemeUserState</key>
<dict>
<key>MachOView.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>8D1107260486CEB800E47090</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>