Xcode的控制台调试命令

摘要:
恭喜你,这时Xcode会自动输出最后的一次调用堆栈。bt显示所有的调用栈帧。continue继续执行正在调试的程序。该命令用在程序由于处理信号或断点而导致停止运行时。fileFILE装载指定的可执行文件进行调试。helpNAME显示指定命令的帮助信息。infobreak显示当前断点清单,包括到达断点处的次数等。infoprog显示被调试程序的执行状态。kill终止正被调试的程序。

XCode4.0以后,编译器换成了LLVM 编译器 2.0

与以前相比,更加强大:
1.LLVM 编译器是下一带开源的编译技术.完全支持C, Objective-C, 和 C++.
2.LLVM 速度比 GCC快两倍,建立的程序也会运行的更快. 因为它更好的利用现代的芯片的结构.
3.LLVM和Xcode 4完全的整合在一起.包括关键字高亮,代码完整性等全都是由LLVM语法分析器来分析的. 这样可以在编辑的时候就可以很好的了解你的代码.

编译器进化之后,控制台调试命令前缀,也由原来的gdb更改成了lldb,所以当你看到控制台没有gdb而出现lldb的时候,不用惊慌,因为我们以前常用的调试命令依然可以使用:

使用前提:

1.既然是调试命令,理所当然的,程序模式应该选择Debug模式。

2.在Debug模式下,如果你的程序在运行中崩溃(Crash)掉,那么恭喜你,使用lldb调试的机会来了。

符合以上两个条件之后,控制台(即日志输出窗口All Output)会自动打出一个(lldb)命令,你在其后输入bt,回车。

恭喜你,这时Xcode会自动输出最后的一次调用堆栈。如下:


  1. *thread#1:tid=0x1f03,0x0132edeeCoreFoundation`___forwarding___+206,stopreason=EXC_BREAKPOINT(code=EXC_I386_BPT,subcode=0x0)
  2. frame#0:0x0132edeeCoreFoundation`___forwarding___+206
  3. frame#1:0x0132ecb2CoreFoundation`_CF_forwarding_prep_0+50
  4. frame#2:0x00002e60testMVC`-[ViewCtrl2touchesBegan:withEvent:]+128atViewCtrl2.m:40
  5. frame#3:0x013c9e99CoreFoundation`-[NSObjectperformSelector:withObject:withObject:]+73
  6. frame#4:0x000ffc49UIKit`forwardTouchMethod+268
  7. frame#5:0x000ffb38UIKit`-[UIRespondertouchesBegan:withEvent:]+30
  8. frame#6:0x0003a2cfUIKit`-[UIWindow_sendTouchesForEvent:]+272
  9. frame#7:0x0003a5e6UIKit`-[UIWindowsendEvent:]+273
  10. frame#8:0x00020dc4UIKit`-[UIApplicationsendEvent:]+464
  11. frame#9:0x00014634UIKit`_UIApplicationHandleEvent+8196
  12. frame#10:0x012b2ef5GraphicsServices`PurpleEventCallback+1274
  13. frame#11:0x0139c195CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__+53
  14. frame#12:0x01300ff2CoreFoundation`__CFRunLoopDoSource1+146
  15. frame#13:0x012ff8daCoreFoundation`__CFRunLoopRun+2218
  16. frame#14:0x012fed84CoreFoundation`CFRunLoopRunSpecific+212
  17. frame#15:0x012fec9bCoreFoundation`CFRunLoopRunInMode+123
  18. frame#16:0x012b17d8GraphicsServices`GSEventRunModal+190
  19. frame#17:0x012b188aGraphicsServices`GSEventRun+103
  20. frame#18:0x00012626UIKit`UIApplicationMain+1163
  21. frame#19:0x000026fatestMVC`main+170atmain.m:16
  22. frame#20:0x00002645testMVC`start+53

当然还有其他的命令(和gdb命令通用):


  1. 命令解释
  2. breakNUM在指定的行上设置断点。
  3. bt显示所有的调用栈帧。该命令可用来显示函数的调用顺序。
  4. clear删除设置在特定源文件、特定行上的断点。其用法为:clearFILENAME:NUM。
  5. continue继续执行正在调试的程序。该命令用在程序由于处理信号或断点而导致停止运行时。
  6. displayEXPR每次程序停止后显示表达式的值。表达式由程序定义的变量组成。
  7. fileFILE装载指定的可执行文件进行调试。
  8. helpNAME显示指定命令的帮助信息。
  9. infobreak显示当前断点清单,包括到达断点处的次数等。
  10. infofiles显示被调试文件的详细信息。
  11. infofunc显示所有的函数名称。
  12. infolocal显示当函数中的局部变量信息。
  13. infoprog显示被调试程序的执行状态。
  14. infovar显示所有的全局和静态变量名称。
  15. kill终止正被调试的程序。
  16. list显示源代码段。
  17. make在不退出gdb的情况下运行make工具。
  18. next在不单步执行进入其他函数的情况下,向前执行一行源代码。
  19. printEXPR显示表达式EXPR的值。
  20. print-object打印一个对象
  21. print(int)name打印一个类型
  22. print-object[artistdescription]调用一个函数
  23. setartist=@"test"设置变量值
  24. whatis查看变理的数据类型

Debugger commands:

apropos -- Find a list of debugger commands related to a particular

word/subject.

breakpoint -- A set of commands for operating on breakpoints. Also see

_regexp-break.

command -- A set of commands for managing or customizing the

debugger commands.

disassemble -- Disassemble bytes in the current function, or elsewhere

in the executable program as specified by the user.

expression -- Evaluate an expression (ObjC++ or Swift) in the current

program context, using user defined variables and

variables currently in scope.

frame -- A set of commands for operating on the current thread's

frames.

gdb-remote -- Connect to a remote GDB server. If no hostname is

provided, localhost is assumed.

gui -- Switch into the curses based GUI mode.

help -- Show a list of all debugger commands, or give details

about specific commands.

kdp-remote -- Connect to a remote KDP server. udp port 41139 is the

default port number.

log -- A set of commands for operating on logs.

memory -- A set of commands for operating on memory.

platform -- A set of commands to manage and create platforms.

plugin -- A set of commands for managing or customizing plugin

commands.

process -- A set of commands for operating on a process.

quit -- Quit out of the LLDB debugger.

register -- A set of commands to access thread registers.

script -- Pass an expression to the script interpreter for

evaluation and return the results. Drop into the

interactive interpreter if no expression is given.

settings -- A set of commands for manipulating internal settable

debugger variables.

source -- A set of commands for accessing source file information

target -- A set of commands for operating on debugger targets.

thread -- A set of commands for operating on one or more threads

within a running process.

type -- A set of commands for operating on the type system

version -- Show version of LLDB debugger.

watchpoint -- A set of commands for operating on watchpoints.

Current command abbreviations (type 'help command alias' for more info):

add-dsym -- ('target symbols add') Add a debug symbol file to one of the

target's current modules by specifying a path to a debug symbols

file, or using the options to specify a module to download

symbols for.

attach -- ('_regexp-attach') Attach to a process id if in decimal,

otherwise treat the argument as a process name to attach to.

b -- ('_regexp-break') Set a breakpoint using a regular expression

to specify the location, where <linenum> is in decimal and

<address> is in hex.

bt -- ('_regexp-bt') Show a backtrace. An optional argument is

accepted; if that argument is a number, it specifies the number

of frames to display. If that argument is 'all', full

backtraces of all threads are displayed.

c -- ('process continue') Continue execution of all threads in the

current process.

call -- ('expression --') Evaluate an expression (ObjC++ or Swift) in

the current program context, using user defined variables and

variables currently in scope.

continue -- ('process continue') Continue execution of all threads in the

current process.

detach -- ('process detach') Detach from the current process being

debugged.

di -- ('disassemble') Disassemble bytes in the current function, or

elsewhere in the executable program as specified by the user.

dis -- ('disassemble') Disassemble bytes in the current function, or

elsewhere in the executable program as specified by the user.

display -- ('_regexp-display') Add an expression evaluation stop-hook.

down -- ('_regexp-down') Go down "n" frames in the stack (1 frame by

default).

env -- ('_regexp-env') Implements a shortcut to viewing and setting

environment variables.

exit -- ('quit') Quit out of the LLDB debugger.

f -- ('frame select') Select a frame by index from within the

current thread and make it the current frame.

file -- ('target create') Create a target using the argument as the

main executable.

finish -- ('thread step-out') Finish executing the function of the

currently selected frame and return to its call site in

specified thread (current thread, if none specified).

image -- ('target modules') A set of commands for accessing information

for one or more target modules.

j -- ('_regexp-jump') Sets the program counter to a new address.

jump -- ('_regexp-jump') Sets the program counter to a new address.

kill -- ('process kill') Terminate the current process being debugged.

l -- ('_regexp-list') Implements the GDB 'list' command in all of

its forms except FILE:FUNCTION and maps them to the appropriate

'source list' commands.

list -- ('_regexp-list') Implements the GDB 'list' command in all of

its forms except FILE:FUNCTION and maps them to the appropriate

'source list' commands.

n -- ('thread step-over') Source level single step in specified

thread (current thread, if none specified), stepping over calls.

next -- ('thread step-over') Source level single step in specified

thread (current thread, if none specified), stepping over calls.

nexti -- ('thread step-inst-over') Single step one instruction in

specified thread (current thread, if none specified), stepping

over calls.

ni -- ('thread step-inst-over') Single step one instruction in

specified thread (current thread, if none specified), stepping

over calls.

p -- ('expression --') Evaluate an expression (ObjC++ or Swift) in

the current program context, using user defined variables and

variables currently in scope.

po -- ('expression -O -- ') Evaluate an expression (ObjC++ or Swift)

in the current program context, using user defined variables and

variables currently in scope.

print -- ('expression --') Evaluate an expression (ObjC++ or Swift) in

the current program context, using user defined variables and

variables currently in scope.

q -- ('quit') Quit out of the LLDB debugger.

r -- ('process launch -c /bin/sh --') Launch the executable in the

debugger.

rbreak -- ('breakpoint set -r %1') Sets a breakpoint or set of

breakpoints in the executable.

repl -- ('expression -r -- ') Evaluate an expression (ObjC++ or Swift)

in the current program context, using user defined variables and

variables currently in scope.

run -- ('process launch -c /bin/sh --') Launch the executable in the

debugger.

s -- ('thread step-in') Source level single step in specified thread

(current thread, if none specified).

si -- ('thread step-inst') Single step one instruction in specified

thread (current thread, if none specified).

step -- ('thread step-in') Source level single step in specified thread

(current thread, if none specified).

stepi -- ('thread step-inst') Single step one instruction in specified

thread (current thread, if none specified).

t -- ('thread select') Select a thread as the currently active

thread.

tbreak -- ('_regexp-tbreak') Set a one shot breakpoint using a regular

expression to specify the location, where <linenum> is in

decimal and <address> is in hex.

undisplay -- ('_regexp-undisplay') Remove an expression evaluation

stop-hook.

up -- ('_regexp-up') Go up "n" frames in the stack (1 frame by

default).

x -- ('memory read') Read from the memory of the process being

debugged.

For more information on any command, type 'help <command-name>'.

使用lldb调试工具,实在是查找crash的一大利器啊,很是方便!

免责声明:文章转载自《Xcode的控制台调试命令》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇DEDECMS后台模板修改浅析SpringSecurity的方法级安全管控下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

Makefile 使用总结

1. Makefile 简介 Makefile 是和 make 命令一起配合使用的. 很多大型项目的编译都是通过 Makefile 来组织的, 如果没有 Makefile, 那很多项目中各种库和代码之间的依赖关系不知会多复杂. Makefile的组织流程的能力如此之强, 不仅可以用来编译项目, 还可以用来组织我们平时的一些日常操作. 这个需要大家发挥自己的...

利用xcode生成的app生成可以在iphone和itouch上运行的ipa安装包

在编译好的真机版目录下的.app文件,至于生成真机可以运行的app的方法,有两种方式,一种是交99美元获得一个证书,另外一种是破解的方式,在此不再详述,本文假设你已经生成了真机上可以运行的app包了(app包实际上是一个文件夹) 假设此安装包的名称是 hello.app,点击右键,选择 显示包内容,这样就可以打开这个hello.app文件夹了,在此文件夹中...

sed-文本处理

sed 命令 sed是一种流编辑器,它是文本处理中非常中的工具,能够完美的配合正则表达式使用,功能不同凡响。处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”(pattern space),接着用sed命令处理缓冲区中的内容,处理完成后,把缓冲区的内容送往屏幕。接着处理下一行,这样不断重复,直到文件末尾。文件内容并没有 改变,除非你使用重定向存储输...

vs 中 vim vax 快捷键

高效率移动 在插入模式之外 基本上来说,你应该尽可能少的呆在插入模式里面,因为在插入模式里面VIM就像一个“哑巴”编辑器一样。很多新手都会一直呆在插入模式里面,因为这样易于使用。但VIM的强大之处在于他的命令行模式!你会发现,在你越来越了解VIM之后,你就会花越来越少的时间使用插入模式了。 使用 h,j,k,l 使用VIM高效率编辑的第一步,就是放弃使用...

nonebot 源码阅读笔记

前言 nonebot 是一个 QQ 消息机器人框架,它的一些实现机制,值得参考。 nonebot NoneBot 初始化(配置加载) 阅读 nonebot 文档,第一个示例如下: import nonebot if __name__ == '__main__': nonebot.init() nonebot.load_builtin_pl...

Window Services的调试和非托管dll的引用及其他一些注意问题

一个asp.net项目,客户提出需求,需要增加即时短信提醒功能;因为项目中使用到GPRS模块做无线通讯,还可以用作发送短信,就用了这个GPRS模块发短信提醒;这个即时短信提醒功能,计划用window services实现;然后修改表结构,开始window services的代码编写。代码编写完成后,开始调试。测试时才发现,window services测试...