NOTE iOS DebugcodewithXCode4-查看运行堆栈_Peter xcode 堆栈

首先,XCode使用GDB进行调试。

当我们设置了断点的时候,在XCode中没有直接能够看到运行堆栈的方法。

为了看到,需要分以下几步:

1.Menu->Product->EditSchema->Run->Arguments

2.在Arguments页面中设置4个环境变量:

NSZombieEnabled=YES

MallocStackLogging=YES

MallocStackLoggingNoCompact=YES

NSDebugEnabled=YES

点击OK完成编辑

3.启动程序(直到运行到断点或者程序遇到崩溃消息)

在日志窗口能够看到如下日志:

2012-04-15 23:19:41.051 otest[3021:7803] ***-[CFDictionary release]: message sent to deallocated instance0x1cdde90
(gdb)

从这个日志可以看到两个内容,一个是程序的pid是3021,另一个是出现问题的对象实例的内存地址为0x1cdde90。接下来就可以利用这两个内容查看堆栈信息了。

4.打开Shell

运行命令:

malloc_history30210x1cdde90

执行结果如下:

xxxxxxxx:~ xxxxxxxx$ malloc_history 2793 0x93425a0

malloc_history Report Version: 2.0

Process: otest [2793]

Path:/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/Developer/usr/bin/otest

Load Address: 0x1000

Identifier: otest Version: ??? (???)

Code Type: X86 (Native)

Parent Process: gdb-i386-apple-darwin [2785]

Date/Time: 2012-04-15 23:06:08.424 +0800

OS Version: Mac OS X 10.7 (11A511)

Report Version: 7

ALLOC 0x93424c0-0x9342607 [size=328]: thread_ad2b02c0 |0x1f31 |0x1f8d | 0x2203 | 0x25be | 0x231c | +[NSObjectperformSelector:withObject:] | +[SenTestProbe runTests:] |+[SenTestProbe specifiedTestSuite] | +[SenTestSuitetestSuiteForBundlePath:] | +[SenTestSuite suiteForBundleCache] |+[SenTestSuite updateCache] | +[SenTestCase(Suite)defaultTestSuite] | +[SenTestSuite testSuiteForTestCaseClass:] |+[SenTestCase testInvocations] |+[NSObject(SenTestRuntimeUtilities) senAllInstanceInvocations] |+[NSObject(SenTestRuntimeUtilities) senAllInstanceInvocations] |+[NSObject(SenTestRuntimeUtilities) senAllInstanceInvocations] |+[NSObject(SenTestRuntimeUtilities) senAllInstanceInvocations] |+[NSObject(SenTestRuntimeUtilities) senInstanceInvocations] |-[SenTestInvocationEnumerator allObjects] |-[SenTestInvocationEnumerator nextObject] | +[NSInvocationinvocationWithMethodSignature:] | calloc | malloc_zone_calloc

----

FREE 0x93424c0-0x9342607 [size=328]: thread_ad2b02c0 |0x1f31 |0x1f8d | 0x2203 | 0x25be | 0x231c | +[NSObjectperformSelector:withObject:] | +[SenTestProbe runTests:] |+[SenTestProbe specifiedTestSuite] | -[NSAutoreleasePool drain] |_CFAutoreleasePoolPop | (anonymousnamespace)::AutoreleasePoolPage::pop(void*) | objc_release |_objc_rootRelease | -[__NSArrayM dealloc] | CFRelease |_objc_rootRelease | -[NSInvocation dealloc] | free ALLOC0x9342550-0x93425db [size=140]: thread_ad2b02c0 |0x1f31 | 0x1f8d |0x2203 | 0x25be | 0x231c | +[NSObject performSelector:withObject:]| +[SenTestProbe runTests:] | -[SenTest run] | -[SenTestSuiteperformTest:] | -[SenTest run] | -[SenTestSuite performTest:] |-[SenTest run] | -[SenTestCase performTest:] | -[SenTestCaseinvokeTest] | -[NSInvocation invoke] | __invoking___ |-[BankSvcTests testBankService] | NSLog | NSLogv | _CFLogvEx |__CFLogCString | CFCalendarCreateWithIdentifier |__CFCalendarCreateUCalendar | ucal_open |icu::Calendar::createInstance(icu::TimeZone*, icu::Localeconst&, UErrorCode&) |icu::GregorianCalendar::GregorianCalendar(icu::Localeconst&, UErrorCode&) |icu::Calendar::Calendar(icu::TimeZone*, icu::Localeconst&, UErrorCode&) |icu::Calendar::setWeekData(icu::Locale const&, charconst*, UErrorCode&) | ures_openDirect | malloc |malloc_zone_malloc

----

FREE 0x9342550-0x93425db [size=140]: thread_ad2b02c0 |0x1f31 |0x1f8d | 0x2203 | 0x25be | 0x231c | +[NSObjectperformSelector:withObject:] | +[SenTestProbe runTests:] |-[SenTest run] | -[SenTestSuite performTest:] | -[SenTest run] |-[SenTestSuite performTest:] | -[SenTest run] | -[SenTestCaseperformTest:] | -[SenTestCase invokeTest] | -[NSInvocation invoke]| __invoking___ | -[BankSvcTests testBankService] | NSLog | NSLogv| _CFLogvEx | __CFLogCString | CFCalendarCreateWithIdentifier |__CFCalendarCreateUCalendar | ucal_open |icu::Calendar::createInstance(icu::TimeZone*, icu::Localeconst&, UErrorCode&) |icu::GregorianCalendar::GregorianCalendar(icu::Localeconst&, UErrorCode&) |icu::Calendar::Calendar(icu::TimeZone*, icu::Localeconst&, UErrorCode&) |icu::Calendar::setWeekData(icu::Locale const&, charconst*, UErrorCode&) | 0x825435 | free ALLOC0x9342550-0x93425db [size=140]: thread_ad2b02c0 |0x1f31 | 0x1f8d |0x2203 | 0x25be | 0x231c | +[NSObject performSelector:withObject:]| +[SenTestProbe runTests:] | -[SenTest run] | -[SenTestSuiteperformTest:] | -[SenTest run] | -[SenTestSuite performTest:] |-[SenTest run] | -[SenTestCase performTest:] | -[SenTestCaseinvokeTest] | -[NSInvocation invoke] | __invoking___ |-[BankSvcTests testBankService] | NSLog | NSLogv | _CFLogvEx |__CFLogCString | CFCalendarCreateWithIdentifier |ucal_setGregorianChange |icu::GregorianCalendar::setGregorianChange(double,UErrorCode&) |icu::GregorianCalendar::GregorianCalendar(icu::TimeZoneconst&, UErrorCode&) |icu::Calendar::Calendar(icu::TimeZone const&,icu::Locale const&, UErrorCode&) |icu::Calendar::setWeekData(icu::Locale const&, charconst*, UErrorCode&) | ures_openDirect | malloc |malloc_zone_malloc

----

FREE 0x9342550-0x93425db [size=140]: thread_ad2b02c0 |0x1f31 |0x1f8d | 0x2203 | 0x25be | 0x231c | +[NSObjectperformSelector:withObject:] | +[SenTestProbe runTests:] |-[SenTest run] | -[SenTestSuite performTest:] | -[SenTest run] |-[SenTestSuite performTest:] | -[SenTest run] | -[SenTestCaseperformTest:] | -[SenTestCase invokeTest] | -[NSInvocation invoke]| __invoking___ | -[BankSvcTests testBankService] | NSLog | NSLogv| _CFLogvEx | __CFLogCString | CFCalendarCreateWithIdentifier |ucal_setGregorianChange |icu::GregorianCalendar::setGregorianChange(double,UErrorCode&) |icu::GregorianCalendar::GregorianCalendar(icu::TimeZoneconst&, UErrorCode&) |icu::Calendar::Calendar(icu::TimeZone const&,icu::Locale const&, UErrorCode&) |icu::Calendar::setWeekData(icu::Locale const&, charconst*, UErrorCode&) | 0x825435 | free ALLOC0x9342550-0x93425db [size=140]: thread_ad2b02c0 |0x1f31 | 0x1f8d |0x2203 | 0x25be | 0x231c | +[NSObject performSelector:withObject:]| +[SenTestProbe runTests:] | -[SenTest run] | -[SenTestSuiteperformTest:] | -[SenTest run] | -[SenTestSuite performTest:] |-[SenTest run] | -[SenTestCase performTest:] | -[SenTestCaseinvokeTest] | -[NSInvocation invoke] | __invoking___ |-[BankSvcTests testBankService] | NSLog | NSLogv | _CFLogvEx |__CFLogCString | CFCalendarCreateWithIdentifier |__CFCalendarCreateUCalendar | ucal_open |icu::Calendar::createInstance(icu::TimeZone*, icu::Localeconst&, UErrorCode&) |icu::GregorianCalendar::GregorianCalendar(icu::Localeconst&, UErrorCode&) |icu::Calendar::Calendar(icu::TimeZone*, icu::Localeconst&, UErrorCode&) |icu::Calendar::setWeekData(icu::Locale const&, charconst*, UErrorCode&) | 0x88429c | 0x884244 |ures_getByKeyWithFallback | 0x826cc2 | malloc |malloc_zone_malloc

----

FREE 0x9342550-0x93425db [size=140]: thread_ad2b02c0 |0x1f31 |0x1f8d | 0x2203 | 0x25be | 0x231c | +[NSObjectperformSelector:withObject:] | +[SenTestProbe runTests:] |-[SenTest run] | -[SenTestSuite performTest:] | -[SenTest run] |-[SenTestSuite performTest:] | -[SenTest run] | -[SenTestCaseperformTest:] | -[SenTestCase invokeTest] | -[NSInvocation invoke]| __invoking___ | -[BankSvcTests testBankService] | NSLog | NSLogv| _CFLogvEx | __CFLogCString | CFCalendarCreateWithIdentifier |__CFCalendarCreateUCalendar | ucal_open |icu::Calendar::createInstance(icu::TimeZone*, icu::Localeconst&, UErrorCode&) |icu::GregorianCalendar::GregorianCalendar(icu::Localeconst&, UErrorCode&) |icu::Calendar::Calendar(icu::TimeZone*, icu::Localeconst&, UErrorCode&) |icu::Calendar::setWeekData(icu::Locale const&, charconst*, UErrorCode&) | 0x884141 | 0x825435 | freeALLOC 0x9342550-0x93425cf [size=128]: thread_ad2b02c0 |0x1f31 |0x1f8d | 0x2203 | 0x25be | 0x231c | +[NSObjectperformSelector:withObject:] | +[SenTestProbe runTests:] |-[SenTest run] | -[SenTestSuite performTest:] | -[SenTest run] |-[SenTestSuite performTest:] | -[SenTest run] | -[SenTestCaseperformTest:] | -[SenTestCaseRun start] | -[SenTestRunpostNotificationName:] | -[SenTestRunpostNotificationName:userInfo:] | -[NSNotificationCenterpostNotificationName:object:userInfo:] | _CFXNotificationPost |___CFXNotificationPost_block_invoke_0 | __57-[NSNotificationCenteraddObserver:selector:name:object:]_block_invoke_0 | +[SenTestLogtestCaseDidStart:] | +[SenTestLog testLogWithFormat:] |+[SenTestLog testLogWithFormat:arguments:] | -[NSStringinitWithFormat:arguments:] | -[NSPlaceholderStringinitWithFormat:locale:arguments:] |_CFStringCreateWithFormatAndArgumentsAux |__CFStringAppendFormatCore | _NSDescriptionWithLocaleFunc |-[SenTestCase description] | -[SenTestCase name] | +[NSStringstringWithFormat:] | -[NSPlaceholderStringinitWithFormat:locale:arguments:] |_CFStringCreateWithFormatAndArgumentsAux |__CFStringAppendFormatCore | __CFStringAppendBytes |__CFStringChangeSizeMultiple | CFAllocatorAllocate |__CFAllocatorSystemAllocate | malloc_zone_malloc

----

FREE 0x9342550-0x93425cf [size=128]: thread_ad2b02c0 |0x1f31 |0x1f8d | 0x2203 | 0x25be | 0x231c | +[NSObjectperformSelector:withObject:] | +[SenTestProbe runTests:] |-[SenTest run] | -[SenTestSuite performTest:] | -[SenTest run] |-[SenTestSuite performTest:] | -[SenTest run] | -[SenTestCaseperformTest:] | -[SenTestCaseRun start] | -[SenTestRunpostNotificationName:] | -[SenTestRunpostNotificationName:userInfo:] | -[NSNotificationCenterpostNotificationName:object:userInfo:] | _CFXNotificationPost |___CFXNotificationPost_block_invoke_0 | __57-[NSNotificationCenteraddObserver:selector:name:object:]_block_invoke_0 | +[SenTestLogtestCaseDidStart:] | +[SenTestLog testLogWithFormat:] |+[SenTestLog testLogWithFormat:arguments:] | -[NSStringinitWithFormat:arguments:] | -[NSPlaceholderStringinitWithFormat:locale:arguments:] |_CFStringCreateWithFormatAndArgumentsAux |__CFStringAppendFormatCore | _NSDescriptionWithLocaleFunc |-[SenTestCase description] | -[SenTestCase name] | +[NSStringstringWithFormat:] | -[NSPlaceholderStringinitWithFormat:locale:arguments:] |_CFStringCreateWithFormatAndArgumentsAux | CFRelease |__CFStringDeallocate | CFAllocatorDeallocate |__CFAllocatorSystemDeallocate | malloc_zone_free ALLOC0x93425a0-0x93425cf [size=48]: thread_ad2b02c0 |0x1f31 | 0x1f8d |0x2203 | 0x25be | 0x231c | +[NSObject performSelector:withObject:]| +[SenTestProbe runTests:] | -[SenTest run] | -[SenTestSuiteperformTest:] | -[SenTest run] | -[SenTestSuite performTest:] |-[SenTest run] | -[SenTestCase performTest:] | -[SenTestCaseinvokeTest] | -[NSInvocation invoke] | __invoking___ |-[CurrencySvcTests testCurrencyService] | +[CurrencyServicesharedInstance] | +[CurrencyService sharedInstanceSynch] |-[CurrencyService init] | +[NSMutableDictionarydictionaryWithCapacity:] | -[__NSPlaceholderDictionaryinitWithCapacity:] | CFDictionaryCreateMutable |__CFDictionaryCreateGeneric | CFBasicHashCreate |_CFRuntimeCreateInstance | CFAllocatorAllocate |__CFAllocatorSystemAllocate | malloc_zone_malloc


  

爱华网本文地址 » http://www.aihuau.com/a/25101010/24381.html

更多阅读

Xcode怎么下载 Xcode怎么安装 xcode模拟器安装app

Xcode怎么下载 Xcode怎么安装——简介Xcode 是苹果系统上的集成开发工具,可以为 Mac OS 和 iOS 系统开发新应用。这里苹果的 Mac OS 系统为例,介绍下如何下载安装 Xcode 的操作方法。Xcode怎么下载 Xcode怎么安装——工具/原料Xcode

如何查看cpu温度 如何查看cpu温度xp

如何查看cpu温度——简介电脑运行速度慢又很烫,CPU的温度到底有多高?怎么查看CPU的温度?很简单。如何查看cpu温度——工具/原料360安全卫士网络如何查看cpu温度——方法/步骤如何查看cpu温度 1、软件笔者电脑上的杀毒软件是360,在360

如何查看Windos系统开机启动项 dos开机启动项

????今天我们看一看如何查看Windos系统开机启动项,有很多方法可以查看Windos系统开机启动,各有优缺点。以下我就给大家介绍几个我经常用的方法:????方法1:一般情况下,我们的电脑都装有体检软件,这些软件基本上都有"加速开机"的功能,在这里

XP怎样查看进程的PID 精 根据pid查看进程

PID就是各进程的身份标识,程序一运行系统就会自动分配给进程一个独一无二的PID。进程中止后PID被系统回收,可能会被继续分配给新运行的程序。XP怎样查看进程的PID 精——方法1XP怎样查看进程的PID 精 1、同时按Ctrl+Alt+Del组合键打

运行命令:3 剪贴板查看器

运行命令:[3]剪贴板查看器——简介很多使用Windows操作系统的人都会有这个疑问:什么是剪贴板?复制、黏贴的文字、文件、图片、视频等在哪里?其实,早期的操作系统中是有这个剪贴板查看器的,只是在后来的版本中被微软老东家优化掉了,如何查看

声明:《NOTE iOS DebugcodewithXCode4-查看运行堆栈_Peter xcode 堆栈》为网友那個硪愛你分享!如侵犯到您的合法权益请联系我们删除