BSBacktraceLogger
BSBacktraceLogger copied to clipboard
记录线程的调用栈
``` thread_t bs_machThreadFromNSThread(NSThread *nsthread) { char name[256]; mach_msg_type_number_t count; thread_act_array_t list; task_threads(mach_task_self(), &list, &count); NSTimeInterval currentTimestamp = [[NSDate date] timeIntervalSince1970]; NSString *originName = [nsthread name]; [nsthread setName:[NSString stringWithFormat:@"%f", currentTimestamp]]; if...
When using Xcode 13, we may encounter the following problem: ``` Showing All Errors Only Multiple commands produce '/Users/xxx/Library/Developer/Xcode/DerivedData/BsBacktraceLogger-fsnybzqtynwznserpmdtqzimhiux/Build/Products/Debug-iphonesimulator/BSBacktraceLogger.app/Info.plist': 1) Target 'BSBacktraceLogger' (project 'BsBacktraceLogger') has copy command from 'xxx/BSBacktraceLogger/BsBacktraceLogger/Info.plist' to...
在获取堆栈时,有时会出现bs_imageIndexContainingAddress命中不了image,返回成UINT_MAX,,我把对应的address打印出来,内容的长度为16为,一般业务代码为9位 
Skipped building BSBacktraceLogger due to the error: Dependency "BSBacktraceLogger" has no shared framework schemes for any of the platforms: iOS
系统提供的dladdr方法是线程安全的,而代码中的fl_dladdr其实底层调用的也是系统提供的_dyld_get_image_header和_dyld_get_image_name等方法,而这些方法是线程不安全的,经过我本人的实验对比,fl_dladdr返回的symbolbuffer和dladdr返回的结果是一样的,不清楚作者是出于什么样的考虑自己重写了一个fl_dladdr方法。
https://github.com/bestswifter/BSBacktraceLogger/blob/master/BSBacktraceLogger/BSBacktraceLogger.m#L318 untime error: unsigned integer overflow: 20274 - 21786 cannot be represented in type 'unsigned long' for(uint32_t iSym = 0; iSym < symtabCmd->nsyms; iSym++) { // If n_value is 0,...
大神你好.拜读代码和博客,写的都非常详细,对我帮助很大.十分感谢~ 现在有个小问题:代码173行和179行有两次主线程判断,能否解释一下为什么这样做?是有什么特殊的处理吗? 个人理解第一个主线程判断 return 掉以后,第二个判断应该是走不到的. 望解答~ ```objc if ([nsthread isMainThread]) { return (thread_t)main_thread_id; } for (int i = 0; i < count; ++i) { pthread_t pt = pthread_from_mach_thread_np(list[i]); if ([nsthread...