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

1、方法的调用链重复问题解决;2、iOS15及以上的系统运行崩溃 修复。 #4

Open
wants to merge 1 commit 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

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

30 changes: 26 additions & 4 deletions Qi_ObjcMsgHook/Qi_ObjcMsgHook.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/* Begin PBXBuildFile section */
9164681BB0A298AD454193ED /* libPods-Qi_ObjcMsgHook.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D47E09EA3AA7D83E2DB7869D /* libPods-Qi_ObjcMsgHook.a */; };
D9DCCA7C2B32C77A00465F0F /* fishhook.c in Sources */ = {isa = PBXBuildFile; fileRef = D9DCCA7A2B32C77A00465F0F /* fishhook.c */; };
F14ED94C23850FF400D35A9D /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F14ED94B23850FF400D35A9D /* AppDelegate.m */; };
F14ED94F23850FF400D35A9D /* SceneDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F14ED94E23850FF400D35A9D /* SceneDelegate.m */; };
F14ED95723850FF500D35A9D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F14ED95623850FF500D35A9D /* Assets.xcassets */; };
Expand All @@ -28,6 +29,8 @@
4976B0886AEEBF116F87F1BF /* Pods-Qi_ObjcMsgHook.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Qi_ObjcMsgHook.debug.xcconfig"; path = "Target Support Files/Pods-Qi_ObjcMsgHook/Pods-Qi_ObjcMsgHook.debug.xcconfig"; sourceTree = "<group>"; };
7D50652F404D4AE35BD9BF75 /* Pods-Qi_ObjcMsgHook.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Qi_ObjcMsgHook.release.xcconfig"; path = "Target Support Files/Pods-Qi_ObjcMsgHook/Pods-Qi_ObjcMsgHook.release.xcconfig"; sourceTree = "<group>"; };
D47E09EA3AA7D83E2DB7869D /* libPods-Qi_ObjcMsgHook.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Qi_ObjcMsgHook.a"; sourceTree = BUILT_PRODUCTS_DIR; };
D9DCCA7A2B32C77A00465F0F /* fishhook.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fishhook.c; sourceTree = "<group>"; };
D9DCCA7B2B32C77A00465F0F /* fishhook.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fishhook.h; sourceTree = "<group>"; };
F14ED94723850FF400D35A9D /* Qi_ObjcMsgHook.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Qi_ObjcMsgHook.app; sourceTree = BUILT_PRODUCTS_DIR; };
F14ED94A23850FF400D35A9D /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
F14ED94B23850FF400D35A9D /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -79,6 +82,15 @@
path = Pods;
sourceTree = "<group>";
};
D9DCCA792B32C77A00465F0F /* fishhook */ = {
isa = PBXGroup;
children = (
D9DCCA7A2B32C77A00465F0F /* fishhook.c */,
D9DCCA7B2B32C77A00465F0F /* fishhook.h */,
);
path = fishhook;
sourceTree = "<group>";
};
F14ED93E23850FF400D35A9D = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -118,6 +130,7 @@
F14ED9632385108800D35A9D /* QiLagMonitor */ = {
isa = PBXGroup;
children = (
D9DCCA792B32C77A00465F0F /* fishhook */,
F14ED9762385193C00D35A9D /* QiLagMonitor.h */,
F14ED9772385193C00D35A9D /* QiLagMonitor.m */,
F14ED964238516FC00D35A9D /* QiCPUMonitor.h */,
Expand Down Expand Up @@ -254,6 +267,7 @@
F14ED94F23850FF400D35A9D /* SceneDelegate.m in Sources */,
F14ED97B2385196500D35A9D /* QiLagDB.m in Sources */,
F14ED9752385184000D35A9D /* QiCallStackModel.m in Sources */,
D9DCCA7C2B32C77A00465F0F /* fishhook.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -386,8 +400,10 @@
baseConfigurationReference = 4976B0886AEEBF116F87F1BF /* Pods-Qi_ObjcMsgHook.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 8ZX24TX624;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = TKRM4J3XJV;
GCC_C_LANGUAGE_STANDARD = gnu99;
INFOPLIST_FILE = Qi_ObjcMsgHook/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -396,6 +412,8 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.qishare.ios.lsq;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = JingxiDev_18;
TARGETED_DEVICE_FAMILY = 1;
};
name = Debug;
Expand All @@ -405,8 +423,10 @@
baseConfigurationReference = 7D50652F404D4AE35BD9BF75 /* Pods-Qi_ObjcMsgHook.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 8ZX24TX624;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = TKRM4J3XJV;
GCC_C_LANGUAGE_STANDARD = gnu99;
INFOPLIST_FILE = Qi_ObjcMsgHook/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -415,6 +435,8 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.qishare.ios.lsq;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = JingxiDev_18;
TARGETED_DEVICE_FAMILY = 1;
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?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>Qi_ObjcMsgHook.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
</dict>
</dict>
</dict>
</plist>
Binary file not shown.
16 changes: 13 additions & 3 deletions Qi_ObjcMsgHook/Qi_ObjcMsgHook/QiLagMonitor/QiCallTrace.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ + (void)appendRecord:(QiCallTraceTimeCostModel *)cost to:(NSMutableString *)mStr
model.isClassMethod = class_isMetaClass(rd->cls);
model.timeCost = (double)rd->time / 1000000.0;
model.callDepth = rd->depth;
model.lr = rd->lr;

if (rd->caller_record != NULL) {
model.callerLr = rd->caller_record->lr;
}

[arr addObject:model];
}
NSUInteger count = arr.count;
Expand All @@ -99,14 +105,18 @@ + (void)appendRecord:(QiCallTraceTimeCostModel *)cost to:(NSMutableString *)mStr
[arr removeObjectAtIndex:i];
//Todo:不需要循环,直接设置下一个,然后判断好边界就行
for (NSUInteger j = i; j < count - 1; j++) {
//下一个深度小的话就开始将后面的递归的往 sub array 里添加
if (arr[j].callDepth + 1 == model.callDepth) {
// 下一个深度小的话就开始将后面的递归的往 sub array 里添加
// ⚠️⚠️ 这里的bug:不能根据 callDepth 来判断,不然所有层级相等的深度,都在一个调用链路中了
// 需要根据调用链路来关联
if (arr[j].lr == model.callerLr) {
NSMutableArray *sub = (NSMutableArray *)arr[j].subCosts;
if (!sub) {
sub = [NSMutableArray new];
arr[j].subCosts = sub;
}
[sub insertObject:model atIndex:0];
if (![sub containsObject:model]) {
[sub addObject:model];
}
}
}
i--;
Expand Down
Loading