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会自动输出最后的一次调用堆栈。如下:
当然还有其他的命令(和gdb命令通用):
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的一大利器啊,很是方便!