ios手动符号表解析

复制代码
//
//  ViewController.m
//  demo
//
//  Created by
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 创建按钮
    UIButton *myButton = [UIButton buttonWithType:UIButtonTypeSystem];
    
    // 设置按钮的标题
    [myButton setTitle:@"点击我" forState:UIControlStateNormal];
    
    // 设置按钮的位置和大小
    myButton.frame = CGRectMake(100, 100, 100, 50); // (x, y, width, height)
    
    // 设置按钮的目标动作(点击事件处理器)
    [myButton addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside];
    
    // 将按钮添加到视图
    [self.view addSubview:myButton];
}

// 定义点击事件处理器
- (void)buttonTapped:(UIButton *)sender {
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths firstObject];
    NSLog(@"Documents Directory: %@", documentsDirectory);
    NSArray *array= @[@"a",@"b",@"c"];
    [array objectAtIndex:5];
    NSLog(@"按钮被点击了!");
}

@end

模拟崩溃数组越界

获取崩溃信息

复制代码
4   demo       0x0000000103164eb2

获取Binary Images:

复制代码
0x103163000 -  0x103166fff hello.demo (1.0) <d202e08b-6dd8-3a73-83c8-e7019fe049b3>

内存地址(Memory Address):内存中每个数据单元的唯一标识符,用于在运行时访问数据,即 0x0000000103164eb2

基地址(Base Address):内存块或内存区域的起始地址,用于表示数据段或代码段的起始位置。即 0x103163000

结束地址(End Address):内存块或内存区域的终止地址,用于表示该内存块的范围。即 0x103166fff

计算偏移量

复制代码
0x0000000103164eb2 - 0x103163000 = 4346760882 - 4346753024 = 7858

获取符号表 路径是 Xcode > Preferences > Locations 下的 Derived Data

复制代码
demo.app.dSYM

解析来根据偏移量 7858 获取符号表中的原始行

复制代码
1e8b	1e9c	-[ViewController buttonTapped:]	ViewController.m:40
1e9c	1ea0	-[ViewController buttonTapped:]	ViewController.m:41
1ea0	1eba	-[ViewController buttonTapped:]	ViewController.m:41
1eba	1ec8	-[ViewController buttonTapped:]	ViewController.m:42

16进制转换10进制展示

复制代码
7819 7835 -[ViewController buttonTapped:]	ViewController.m:40
7836 7839 -[ViewController buttonTapped:]	ViewController.m:41
7840 7865 -[ViewController buttonTapped:]	ViewController.m:41
7866 7879 -[ViewController buttonTapped:]	ViewController.m:42

7858 在 (7866,7879) 这个区间内 为

复制代码
7840 7865 -[ViewController buttonTapped:]	ViewController.m:41

再来看原始代码行号,验证找到的是正确的

解析符号表使用bugly提供的jar执行,即可

复制代码
java_opts=" -Xms512m -Xmx1024m -Dfile.encoding=UTF8 "
jar_path = "buglySymboliOS.jar"
fils_path = "demo.app.dSYM"
output_path = "~/Downloads/ios"
java $java_opts -jar $jar_path -i $file_path -o $output_path -symbol "$@" > /dev/null 2>&1

最后需要符号还原

pip install symbolic==8.3.2

复制代码
from symbolic.demangle import demangle_name

decode = demangle_name(item)
相关推荐
songgeb2 小时前
YYImage Bug:一行之差,正常 JPEG 如何在 iOS 被读成条纹
ios·swift
茶底世界之下9 小时前
阴天花摊不必变暖:用 Awaking 留住花色与湿街
ios·app·产品
Fatbobman(东坡肘子)1 天前
快速消失的硬盘容量 -- 肘子的 Swift 周报 #160
开发语言·人工智能·redis·ios·swiftui·iphone·swift
茶底世界之下1 天前
斜光下的旧自行车:用 Awaking 留一版复古胶片色
ios·app·产品
2501_916008891 天前
iPhone 设备信息查看,用 KeyMob 看型号、序列号、电池健康和 UDID
android·ios·小程序·https·uni-app·iphone·webview
茶底世界之下2 天前
iPhone Duo 适配实战,Awaking 踩过的 8 个坑
ios·swiftui·swift
跨境数据猎手2 天前
HTTP 响应体编码与压缩:识别、解码
网络协议·http·ios
也非非也2 天前
iPhone 中国区 AI 落地:Apple 与阿里千问合作的技术观察
大数据·人工智能·ios·agent·iphone·智子
茶底世界之下2 天前
同一片泳池,清透还是奶油胶片?用 Awaking 做两版成片
ios
2501_916008892 天前
iOS App 图标、启动屏和多语言搭配 方法,上架前使用KXBuild一次做好 App 图标
ide·vscode·ios·objective-c·个人开发·swift·敏捷流程