2011-10-22 10:31:42 +08:00
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html xmlns = "http://www.w3.org/1999/xhtml" >
< head >
< meta http-equiv = "Content-Type" content = "text/html; charset=iso-8859-1" / >
< link href = "style.css" rel = "stylesheet" type = "text/css" / >
2011-12-08 06:09:43 +08:00
< title > LLDB to GDB Command Map< / title >
2011-10-22 10:31:42 +08:00
< / head >
< body >
< div class = "www_title" >
The < strong > LLDB< / strong > Debugger
< / div >
2011-10-25 09:28:31 +08:00
2011-10-22 10:31:42 +08:00
< div id = "container" >
2011-10-25 09:28:31 +08:00
< div id = "content" >
2011-10-22 10:31:42 +08:00
<!-- #include virtual="sidebar.incl" -->
2011-10-25 09:28:31 +08:00
< div id = "middle" >
< div class = "post" >
2012-10-05 13:31:01 +08:00
< h1 class = "postheader" > GDB to LLDB Command Map< / h1 >
2011-10-25 09:28:31 +08:00
< div class = "post" >
2012-10-05 12:28:33 +08:00
< p > Below is a table of GDB commands with the LLDB counterparts.
2012-05-15 05:39:38 +08:00
The built in GDB-compatibility aliases in LLDB are also
2012-10-05 12:28:33 +08:00
listed. The full lldb command names are often long, but any
2012-10-05 12:29:13 +08:00
unique short form can be used. Instead of "< b > breakpoint set< / b > ",
"< b > br se< / b > " is also acceptable.< / p >
2011-10-22 10:31:42 +08:00
< / div >
2011-10-25 09:28:31 +08:00
< div class = "postfooter" > < / div >
2011-10-22 10:31:42 +08:00
2011-10-25 09:28:31 +08:00
< h1 class = "postheader" > Execution Commands< / h1 >
< div class = "post" >
2011-10-22 10:31:42 +08:00
< p >
2011-10-25 09:28:31 +08:00
< table class = "stats" width = "620" cellspacing = "0" >
2011-10-22 10:31:42 +08:00
< tr >
< td class = "hed" width = "50%" > GDB< / td >
2012-10-05 12:26:06 +08:00
< td class = "hed" width = "50%" > LLDB< / td >
2011-10-22 10:31:42 +08:00
< / tr >
< tr > < td class = "header" colspan = "2" > Launch a process no arguments.< / td > < / tr >
2012-10-05 12:26:06 +08:00
< td class = "content" >
< b > (gdb)< / b > run< br >
< b > (gdb)< / b > r
< / td >
2011-10-22 10:31:42 +08:00
< td class = "content" >
< b > (lldb)< / b > process launch< br >
< b > (lldb)< / b > run< br >
< b > (lldb)< / b > r
< / td >
< / tr >
2011-10-25 09:28:31 +08:00
2011-10-22 10:31:42 +08:00
< tr > < td class = "header" colspan = "2" > Launch a process with arguments < code > < args> < / code > .< / td > < / tr >
< td class = "content" >
< b > (gdb)< / b > run < args> < br >
< b > (gdb)< / b > r < args>
< / td >
2012-10-05 12:26:06 +08:00
< td class = "content" >
< b > (lldb)< / b > process launch -- < args> < br >
< b > (lldb)< / b > r < args>
< / td >
2011-10-22 10:31:42 +08:00
< / tr >
< tr > < td class = "header" colspan = "2" > Launch a process for with arguments < b > < code > a.out 1 2 3< / code > < / b > without having to supply the args every time.< / td > < / tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > %< / b > gdb --args a.out 1 2 3< br >
< b > (gdb)< / b > run< br >
2011-10-22 10:31:42 +08:00
...< br >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > run< br >
2011-10-22 10:31:42 +08:00
...< br >
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > %< / b > lldb -- a.out 1 2 3< br >
< b > (lldb)< / b > run< br >
2011-10-22 10:31:42 +08:00
...< br >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > run< br >
2011-10-22 10:31:42 +08:00
...< br >
< / td >
< / tr >
2013-07-27 07:20:05 +08:00
< tr > < td class = "header" colspan = "2" > Or:< / td > < / tr >
< td class = "content" >
< b > (gdb)< / b > set args 1 2 3< br >
< b > (gdb)< / b > run< br >
...< br >
< b > (gdb)< / b > run< br >
...< br >
< / td >
< td class = "content" >
< b > (lldb)< / b > settings set target.run-args 1 2 3< br >
< b > (lldb)< / b > run< br >
...< br >
< b > (lldb)< / b > run< br >
...< br >
< / td >
< / tr >
2011-10-22 10:31:42 +08:00
< tr > < td class = "header" colspan = "2" > Launch a process with arguments in new terminal window (Mac OS X only).< / td > < / tr >
< td class = "content" >
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > process launch --tty -- < args> < br >
< b > (lldb)< / b > pro la -t -- < args> < br >
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Launch a process with arguments in existing terminal < cope > /dev/ttys006< / code > (Mac OS X only).< / td > < / tr >
< td class = "content" >
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > process launch --tty=/dev/ttys006 -- < args> < br >
< b > (lldb)< / b > pro la -t/dev/ttys006 -- < args> < br >
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
2012-12-07 06:10:27 +08:00
< tr > < td class = "header" colspan = "2" > Set environment variables for process before launching.< / td > < / tr >
< td class = "content" >
< b > (gdb)< / b > set env DEBUG 1< br >
< / td >
< td class = "content" >
< b > (lldb)< / b > settings set target.env-vars DEBUG=1< br >
< b > (lldb)< / b > set se target.env-vars DEBUG=1< br >
2013-02-13 02:54:34 +08:00
< b > (lldb)< / b > env DEBUG=1< br >
2012-12-07 06:10:27 +08:00
< / td >
< / tr >
2013-07-27 07:20:05 +08:00
< tr > < td class = "header" colspan = "2" > Show the arguments that will be or were passed to the program when run.< / td > < / tr >
< td class = "content" >
< b > (gdb)< / b > show args< br >
Argument list to give program being debugged when it is started is " 1 2 3& quot.< br >
< / td >
< td class = "content" >
< b > (lldb)< / b > settings show target.run-args< br >
target.run-args (array of strings) =< br >
[0]: " 1" < br >
[1]: " 2" < br >
[2]: " 3" < br >
< / td >
< / tr >
2012-12-07 06:10:27 +08:00
< tr > < td class = "header" colspan = "2" > Set environment variables for process and launch process in one command.< / td > < / tr >
< td class = "content" >
< / td >
< td class = "content" >
< b > (lldb)< / b > process launch -v DEBUG=1< br >
< / td >
< / tr >
2011-10-22 10:31:42 +08:00
< tr > < td class = "header" colspan = "2" > Attach to a process with process ID 123.< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > attach 123
2011-10-22 10:31:42 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > process attach --pid 123< br >
< b > (lldb)< / b > attach -p 123
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Attach to a process named "a.out".< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > attach a.out
2011-10-22 10:31:42 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > process attach --name a.out< br >
< b > (lldb)< / b > pro at -n a.out
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Wait for a process named "a.out" to launch and attach.< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > attach -waitfor a.out
2011-10-22 10:31:42 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > process attach --name a.out --waitfor< br >
< b > (lldb)< / b > pro at -n a.out -w
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
2012-09-27 06:42:25 +08:00
< tr > < td class = "header" colspan = "2" > Attach to a remote gdb protocol server running on system "eorgadd", port 8000.< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > target remote eorgadd:8000
2012-09-27 06:42:25 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > gdb-remote eorgadd:8000
2012-09-27 06:42:25 +08:00
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Attach to a remote gdb protocol server running on the local system, port 8000.< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > target remote localhost:8000
2012-09-27 06:42:25 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > gdb-remote 8000
2012-09-27 06:42:25 +08:00
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Attach to a Darwin kernel in kdp mode on system "eorgadd".< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > kdp-reattach eorgadd
2012-09-27 06:42:25 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > kdp-remote eorgadd
2012-09-27 06:42:25 +08:00
< / td >
< / tr >
2011-10-22 10:31:42 +08:00
< tr > < td class = "header" colspan = "2" > Do a source level single step in the currently selected thread.< / td > < / tr >
< tr >
2012-10-05 12:26:06 +08:00
< td class = "content" >
< b > (gdb)< / b > step< br >
< b > (gdb)< / b > s
< / td >
2011-10-22 10:31:42 +08:00
< td class = "content" >
< b > (lldb)< / b > thread step-in< br >
< b > (lldb)< / b > step< br >
< b > (lldb)< / b > s
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Do a source level single step over in the currently selected thread.< / td > < / tr >
< tr >
2012-10-05 12:26:06 +08:00
< td class = "content" >
< b > (gdb)< / b > next< br >
< b > (gdb)< / b > n
< / td >
2011-10-22 10:31:42 +08:00
< td class = "content" >
< b > (lldb)< / b > thread step-over< br >
< b > (lldb)< / b > next< br >
< b > (lldb)< / b > n< br >
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Do an instruction level single step in the currently selected thread.< / td > < / tr >
< tr >
< td class = "content" >
< b > (gdb)< / b > stepi< br >
< b > (gdb)< / b > si
< / td >
2012-10-05 12:26:06 +08:00
< td class = "content" >
< b > (lldb)< / b > thread step-inst< br >
< b > (lldb)< / b > si< br >
< / td >
2011-10-22 10:31:42 +08:00
< / tr >
< tr > < td class = "header" colspan = "2" > Do an instruction level single step over in the currently selected thread.< / td > < / tr >
< tr >
< td class = "content" >
< b > (gdb)< / b > nexti< br >
< b > (gdb)< / b > ni
< / td >
2012-10-05 12:26:06 +08:00
< td class = "content" >
< b > (lldb)< / b > thread step-inst-over< br >
< b > (lldb)< / b > ni
< / td >
2011-10-22 10:31:42 +08:00
< / tr >
< tr > < td class = "header" colspan = "2" > Step out of the currently selected frame.< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > finish< br >
2011-10-22 10:31:42 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > thread step-out< br >
< b > (lldb)< / b > finish< br >
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
2013-02-21 07:38:37 +08:00
< tr > < td class = "header" colspan = "2" > Return immediately from the currently selected frame, with an optional return value.< / td > < / tr >
< tr >
< td class = "content" >
< b > (gdb)< / b > return < RETURN EXPRESSION> < br >
< / td >
< td class = "content" >
< b > (lldb)< / b > thread return < RETURN EXPRESSION> < br >
< / td >
< / tr >
2011-10-22 10:31:42 +08:00
< tr > < td class = "header" colspan = "2" > Backtrace and disassemble every time you stop.< / td > < / tr >
< tr >
2012-10-05 12:26:06 +08:00
< td class = "content" >
< / td >
< td class = "content" >
2011-10-22 10:31:42 +08:00
< b > (lldb)< / b > target stop-hook add< br >
Enter your stop hook command(s). Type 'DONE' to end.< br >
> bt< br >
> disassemble --pc< br >
> DONE< br >
Stop hook #1 added.< br >
< / td >
< / tr >
< / table >
< p >
< / div >
2011-10-25 09:28:31 +08:00
< div class = "postfooter" > < / div >
2011-10-22 10:31:42 +08:00
2011-10-25 09:28:31 +08:00
< h1 class = "postheader" > Breakpoint Commands< / h1 >
< div class = "post" >
2011-10-22 10:31:42 +08:00
< p >
2011-10-25 09:28:31 +08:00
< table class = "stats" width = "620" cellspacing = "0" >
2011-10-22 10:31:42 +08:00
< tr >
< td class = "hed" width = "50%" > GDB< / td >
2012-10-05 12:26:06 +08:00
< td class = "hed" width = "50%" > LLDB< / td >
2011-10-22 10:31:42 +08:00
< / tr >
< tr > < td class = "header" colspan = "2" > Set a breakpoint at all functions named < b > main< / b > .< / td > < / tr >
< tr >
2012-10-05 12:26:06 +08:00
< td class = "content" >
< b > (gdb)< / b > break main
< / td >
2011-10-22 10:31:42 +08:00
< td class = "content" >
< b > (lldb)< / b > breakpoint set --name main< br >
< b > (lldb)< / b > br s -n main< br >
< b > (lldb)< / b > b main
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Set a breakpoint in file < b > test.c< / b > at line < b > 12< / b > .< / td > < / tr >
< tr >
2012-10-05 12:26:06 +08:00
< td class = "content" >
< b > (gdb)< / b > break test.c:12
< / td >
2011-10-22 10:31:42 +08:00
< td class = "content" >
< b > (lldb)< / b > breakpoint set --file test.c --line 12< br >
2011-10-25 09:28:31 +08:00
< b > (lldb)< / b > br s -f test.c -l 12< br >
2011-10-22 10:31:42 +08:00
< b > (lldb)< / b > b test.c:12
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Set a breakpoint at all C++ methods whose basename is < b > main< / b > .< / td > < / tr >
< tr >
< td class = "content" >
2011-10-25 09:28:31 +08:00
< b > (gdb)< / b > break main< br >
2011-10-22 10:31:42 +08:00
< i > (Hope that there are no C funtions named < b > main< / b > )< / i > .
< / td >
2012-10-05 12:26:06 +08:00
< td class = "content" >
< b > (lldb)< / b > breakpoint set --method main< br >
< b > (lldb)< / b > br s -M main< br >
< / td >
2011-10-22 10:31:42 +08:00
< / tr >
2012-02-16 10:10:58 +08:00
< tr > < td class = "header" colspan = "2" > Set a breakpoint at and object C function: < b > -[NSString stringWithFormat:]< / b > .< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > break -[NSString stringWithFormat:]< br >
2012-02-16 10:10:58 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > breakpoint set --name "-[NSString stringWithFormat:]"< br >
< b > (lldb)< / b > b -[NSString stringWithFormat:]< br >
2012-02-16 10:10:58 +08:00
< / td >
< / tr >
2011-10-22 10:31:42 +08:00
< tr > < td class = "header" colspan = "2" > Set a breakpoint at all Objective C methods whose selector is < b > count< / b > .< / td > < / tr >
< tr >
< td class = "content" >
2011-10-25 09:28:31 +08:00
< b > (gdb)< / b > break count< br >
2011-10-22 10:31:42 +08:00
< i > (Hope that there are no C or C++ funtions named < b > count< / b > )< / i > .
< / td >
2012-10-05 12:26:06 +08:00
< td class = "content" >
< b > (lldb)< / b > breakpoint set --selector count< br >
< b > (lldb)< / b > br s -S count< br >
< / td >
2011-10-22 10:31:42 +08:00
< / tr >
2012-10-19 05:54:05 +08:00
< tr > < td class = "header" colspan = "2" > Set a breakpoint by regular expression on function name.< / td > < / tr >
< tr >
< td class = "content" >
< b > (gdb)< / b > rbreak regular-expression< br >
< / td >
< td class = "content" >
2012-12-19 08:15:34 +08:00
< b > (lldb)< / b > breakpoint set --func-regex regular-expression< br >
2012-10-19 05:54:05 +08:00
< b > (lldb)< / b > br s -r regular-expression< br >
< / td >
< / tr >
2013-02-15 03:17:49 +08:00
< tr > < td class = "header" colspan = "2" > Ensure that breakpoints by file and line work for #included .c/.cpp/.m files.< / td > < / tr >
< tr >
< td class = "content" >
< b > (gdb)< / b > b foo.c:12< br >
< / td >
< td class = "content" >
< b > (lldb)< / b > settings set target.inline-breakpoint-strategy always< br >
< b > (lldb)< / b > br s -f foo.c -l 12< br >
< / td >
< / tr >
2012-10-19 05:54:05 +08:00
< tr > < td class = "header" colspan = "2" > Set a breakpoint by regular expression on source file contents.< / td > < / tr >
< tr >
< td class = "content" >
< b > (gdb)< / b > shell grep -e -n pattern source-file< br >
< b > (gdb)< / b > break source-file:CopyLineNumbers< br >
< / td >
< td class = "content" >
< b > (lldb)< / b > breakpoint set --source-pattern regular-expression --file SourceFile< br >
< b > (lldb)< / b > br s -p regular-expression -f file< br >
< / td >
< / tr >
2011-10-22 10:31:42 +08:00
2012-01-05 05:20:39 +08:00
< tr > < td class = "header" colspan = "2" > List all breakpoints.< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > info break< br >
2012-01-05 05:20:39 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > breakpoint list< br >
< b > (lldb)< / b > br l< br >
2012-01-05 05:20:39 +08:00
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Delete a breakpoint.< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > delete 1< br >
2012-01-05 05:20:39 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > breakpoint delete 1< br >
< b > (lldb)< / b > br del 1< br >
2012-01-05 05:20:39 +08:00
< / td >
< / tr >
2011-10-22 10:31:42 +08:00
< / table >
< p >
< / div >
2012-03-16 08:44:02 +08:00
< div class = "postfooter" > < / div >
2011-10-22 10:31:42 +08:00
2012-03-16 08:44:02 +08:00
< h1 class = "postheader" > Watchpoint Commands< / h1 >
< div class = "post" >
< p >
< table class = "stats" width = "620" cellspacing = "0" >
< tr >
< td class = "hed" width = "50%" > GDB< / td >
2012-10-05 12:26:06 +08:00
< td class = "hed" width = "50%" > LLDB< / td >
2012-03-16 08:44:02 +08:00
< / tr >
< tr > < td class = "header" colspan = "2" > Set a watchpoint on a variable when it is written to.< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > watch global_var
2012-03-16 08:44:02 +08:00
< / td >
< td class = "content" >
2012-10-06 04:25:53 +08:00
< b > (lldb)< / b > watchpoint set variable global_var< br >
< b > (lldb)< / b > wa s v global_var< br >
2012-03-16 08:44:02 +08:00
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Set a watchpoint on a memory location when it is written into. The size of the region to watch for defaults to the pointer size if no '-x byte_size' is specified.
This command takes raw input, evaluated as an expression returning an unsigned integer pointing to the start of the region, after the '--' option terminator.< / td > < / tr >
< tr >
2012-10-05 12:26:06 +08:00
< td class = "content" >
< b > (gdb)< / b > watch -location g_char_ptr
< / td >
2012-03-16 08:44:02 +08:00
< td class = "content" >
2012-10-06 04:28:11 +08:00
< b > (lldb)< / b > watchpoint set expression -- my_ptr< br >
2012-10-06 04:25:53 +08:00
< b > (lldb)< / b > wa s e -- my_ptr< br >
2012-03-16 08:44:02 +08:00
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Set a condition on a watchpoint< / b > .< / td > < / tr >
< tr >
2012-10-05 12:26:06 +08:00
< td class = "content" >
< / td >
< td class = "content" >
2012-10-06 04:28:11 +08:00
< b > (lldb)< / b > watch set var global< br >
2012-03-16 08:44:02 +08:00
< b > (lldb)< / b > watchpoint modify -c '(global==5)'< br >
< b > (lldb)< / b > c< br >
...< br >
< b > (lldb)< / b > bt< br >
* thread #1: tid = 0x1c03, 0x0000000100000ef5 a.out`modify + 21 at main.cpp:16, stop reason = watchpoint 1< br >
frame #0: 0x0000000100000ef5 a.out`modify + 21 at main.cpp:16< br >
frame #1: 0x0000000100000eac a.out`main + 108 at main.cpp:25< br >
frame #2: 0x00007fff8ac9c7e1 libdyld.dylib`start + 1< br >
< b > (lldb)< / b > frame var global< br >
(int32_t) global = 5< br >
< / td >
< / tr >
2011-10-25 09:28:31 +08:00
2012-03-16 08:44:02 +08:00
< tr > < td class = "header" colspan = "2" > List all watchpoints.< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > info break< br >
2012-03-16 08:44:02 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > watchpoint list< br >
< b > (lldb)< / b > watch l< br >
2012-03-16 08:44:02 +08:00
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Delete a watchpoint.< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > delete 1< br >
2012-03-16 08:44:02 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > watchpoint delete 1< br >
< b > (lldb)< / b > watch del 1< br >
2012-03-16 08:44:02 +08:00
< / td >
< / tr >
< / table >
< p >
< / div >
< div class = "postfooter" > < / div >
2011-10-25 09:28:31 +08:00
< h1 class = "postheader" > Examining Variables< / h1 >
< div class = "post" >
2011-10-22 10:31:42 +08:00
< p >
2011-10-25 09:28:31 +08:00
< table class = "stats" width = "620" cellspacing = "0" >
2011-10-22 10:31:42 +08:00
< tr >
< td class = "hed" width = "50%" > GDB< / td >
2012-10-05 12:26:06 +08:00
< td class = "hed" width = "50%" > LLDB< / td >
2011-10-22 10:31:42 +08:00
< / tr >
< tr > < td class = "header" colspan = "2" > Show the arguments and local variables for the current frame.< / td > < / tr >
< tr >
< td class = "content" >
< b > (gdb)< / b > info args< br >
and< br >
< b > (gdb)< / b > info locals< br >
< / td >
2012-10-05 12:26:06 +08:00
< td class = "content" >
< b > (lldb)< / b > frame variable< br >
2012-10-06 04:25:53 +08:00
< b > (lldb)< / b > fr v< br >
2012-10-05 12:26:06 +08:00
< / td >
2011-10-22 10:31:42 +08:00
< / tr >
2011-10-25 09:28:31 +08:00
< tr > < td class = "header" colspan = "2" > Show the local variables for the current frame.< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > info locals< br >
2011-10-25 09:28:31 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > frame variable --no-args< br >
< b > (lldb)< / b > fr v -a< br >
2011-10-25 09:28:31 +08:00
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Show the contents of local variable "bar".< / td > < / tr >
< tr >
2012-10-05 12:26:06 +08:00
< td class = "content" >
< b > (gdb)< / b > p bar< br >
< / td >
2011-10-25 09:28:31 +08:00
< td class = "content" >
< b > (lldb)< / b > frame variable bar < br >
< b > (lldb)< / b > fr v bar < br >
< b > (lldb)< / b > p bar < br >
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Show the contents of local variable "bar" formatted as hex.< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > p/x bar< br >
2011-10-25 09:28:31 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > frame variable --format x bar < br >
< b > (lldb)< / b > fr v -f x bar < br >
2011-10-25 09:28:31 +08:00
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Show the contents of global variable "baz".< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > p baz< br >
2011-10-25 09:28:31 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > target variable baz < br >
< b > (lldb)< / b > ta v baz < br >
2011-10-25 09:28:31 +08:00
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Show the global/static variables defined in the current source file.< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
n/a< br >
2011-10-25 09:28:31 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > target variable < br >
< b > (lldb)< / b > ta v < br >
2011-10-25 09:28:31 +08:00
< / td >
< / tr >
2011-10-25 09:28:56 +08:00
< tr > < td class = "header" colspan = "2" > Display a the variable "argc" and "argv" every time you stop.< / td > < / tr >
2011-10-25 09:28:31 +08:00
< tr >
2012-10-05 12:26:06 +08:00
< td class = "content" >
< b > (gdb)< / b > display argc< br >
< b > (gdb)< / b > display argv< br >
< / td >
2011-10-25 09:28:31 +08:00
< td class = "content" >
< b > (lldb)< / b > target stop-hook add --one-liner "frame variable argc argv"< br >
< b > (lldb)< / b > ta st a -o "fr v argc argv"< br >
< b > (lldb)< / b > display argc< br >
< b > (lldb)< / b > display argv< br >
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Display a the variable "argc" and "argv" only when you stop in the function named < b > main< / b > .< / td > < / tr >
< tr >
2012-10-05 12:26:06 +08:00
< td class = "content" >
< / td >
< td class = "content" >
2011-10-25 09:28:31 +08:00
< b > (lldb)< / b > target stop-hook add --name main --one-liner "frame variable argc argv"< br >
< b > (lldb)< / b > ta st a -n main -o "fr v argc argv"< br >
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Display the variable "*this" only when you stop in c class named < b > MyClass< / b > .< / td > < / tr >
< tr >
2012-10-05 12:26:06 +08:00
< td class = "content" >
< / td >
< td class = "content" >
2011-10-25 09:28:31 +08:00
< b > (lldb)< / b > target stop-hook add --classname MyClass --one-liner "frame variable *this"< br >
< b > (lldb)< / b > ta st a -c MyClass -o "fr v *this"< br >
< / td >
< / tr >
< / table >
< p >
< / div >
2012-08-25 06:56:40 +08:00
< h1 class = "postheader" > Evaluating expressions< / h1 >
< div class = "post" >
< p >
< table class = "stats" width = "620" cellspacing = "0" >
< tr >
< td class = "hed" width = "50%" > GDB< / td >
2012-10-05 12:26:06 +08:00
< td class = "hed" width = "50%" > LLDB< / td >
2012-08-25 06:56:40 +08:00
< / tr >
< tr > < td class = "header" colspan = "2" > Evaluating a generalized expression in the current frame.< / td > < / tr >
< tr >
< td class = "content" >
< b > (gdb)< / b > print (int) printf ("Print nine: %d.", 4 + 5)< br >
or if you don't want to see void returns: < br >
< b > (gdb)< / b > call (int) printf ("Print nine: %d.", 4 + 5)< br >
< / td >
2012-10-05 12:26:06 +08:00
< td class = "content" >
< b > (lldb)< / b > expr (int) printf ("Print nine: %d.", 4 + 5)< br >
or using the print alias:< br >
< b > (lldb)< / b > print (int) printf ("Print nine: %d.", 4 + 5)< br >
< / td >
2012-10-26 01:35:53 +08:00
< / tr >
< tr > < td class = "header" colspan = "2" > Creating and assigning a value to a convenience variable.< / td > < / tr >
< tr >
< td class = "content" >
< b > (gdb)< / b > set $foo = 5< br >
< b > (gdb)< / b > set variable $foo = 5< br >
or using the print command < br >
< b > (gdb)< / b > print $foo = 5< br >
or using the call command < br >
< b > (gdb)< / b > call $foo = 5< br >
and if you want to specify the type of the variable:
< b > (gdb)< / b > set $foo = (unsigned int) 5< br >
< / td >
< td class = "content" >
In lldb you evaluate a variable declaration expression as you would write it in C:< br >
< b > (lldb)< / b > expr unsigned int $foo = 5< br >
< / td >
2012-08-25 06:56:40 +08:00
< / tr >
< tr > < td class = "header" colspan = "2" > Printing the ObjC "description" of an object.< / td > < / tr >
< tr >
2012-10-05 12:26:06 +08:00
< td class = "content" >
< b > (gdb)< / b > po [SomeClass returnAnObject]< br >
< / td >
2012-08-25 06:56:40 +08:00
< td class = "content" >
< b > (lldb)< / b > expr -o -- [SomeClass returnAnObject]< br >
or using the po alias:< br >
< b > (lldb)< / b > po [SomeClass returnAnObject]< br >
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Print the dynamic type of the result of an expression.< / td > < / tr >
< tr >
2012-10-05 12:26:06 +08:00
< td class = "content" >
< b > (gdb)< / b > set print object 1< br >
< b > (gdb)< / b > p someCPPObjectPtrOrReference< br >
only works for C++ objects.< br >
< / td >
2012-08-25 06:56:40 +08:00
< td class = "content" >
< b > (lldb)< / b > expr -d 1 -- [SomeClass returnAnObject]< br >
< b > (lldb)< / b > expr -d 1 -- someCPPObjectPtrOrReference< br >
or set dynamic type printing to be the default:
< b > (lldb)< / b > settings set target.prefer-dynamic run-target< br >
< / td >
< / tr >
2012-11-16 03:13:33 +08:00
< tr > < td class = "header" colspan = "2" > Calling a function so you can stop at a breakpoint in the function.< / td > < / tr >
< tr >
< td class = "content" >
< b > (gdb)< / b > set unwindonsignal 0< br >
< b > (gdb)< / b > p function_with_a_breakpoint()< br >
< / td >
< td class = "content" >
2013-01-15 10:57:33 +08:00
< b > (lldb)< / b > expr -i 0 -- function_with_a_breakpoint()< br >
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Calling a function that crashes, and stopping when the function crashes.< / td > < / tr >
< tr >
< td class = "content" >
< b > (gdb)< / b > set unwindonsignal 0< br >
< b > (gdb)< / b > p function_which_crashes()< br >
< / td >
< td class = "content" >
< b > (lldb)< / b > expr -u 0 -- function_which_crashes()< br >
2012-11-16 03:13:33 +08:00
< / td >
< / tr >
2012-08-25 06:56:40 +08:00
< / table >
< p >
< / div >
2011-10-25 09:28:31 +08:00
< h1 class = "postheader" > Examining Thread State< / h1 >
< div class = "post" >
< p >
< table class = "stats" width = "620" cellspacing = "0" >
< tr >
< td class = "hed" width = "50%" > GDB< / td >
2012-10-05 12:26:06 +08:00
< td class = "hed" width = "50%" > LLDB< / td >
2011-10-25 09:28:31 +08:00
< / tr >
2011-10-22 10:31:42 +08:00
< tr > < td class = "header" colspan = "2" > Show the stack backtrace for the current thread.< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > bt< br >
2011-10-22 10:31:42 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > thread backtrace< br >
< b > (lldb)< / b > bt< br >
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Show the stack backtraces for all threads.< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > thread apply all bt
2011-10-22 10:31:42 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > thread backtrace all< br >
< b > (lldb)< / b > bt all
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
2012-10-27 07:56:03 +08:00
< tr > < td class = "header" colspan = "2" > Backtrace the first five frames of the current thread.< / td > < / tr >
2012-10-27 07:52:49 +08:00
< tr >
< td class = "content" >
< b > (gdb)< / b > bt 5
< / td >
< td class = "content" >
< b > (lldb)< / b > thread backtrace -c 5< br >
2012-10-27 07:56:03 +08:00
< b > (lldb)< / b > bt 5 (< i > lldb-169 and later< / i > )< br >
< b > (lldb)< / b > bt -c 5 (< i > lldb-168 and earlier< / i > )
2012-10-27 07:52:49 +08:00
< / td >
< / tr >
2011-10-22 10:31:42 +08:00
< tr > < td class = "header" colspan = "2" > Select a different stack frame by index for the current thread.< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > frame 12
2011-10-22 10:31:42 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > frame select 12< br >
2012-10-06 04:25:53 +08:00
< b > (lldb)< / b > fr s 12< br >
< b > (lldb)< / b > f 12< br >
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
2012-03-22 02:14:37 +08:00
< tr > < td class = "header" colspan = "2" > List information about the currently selected frame in the current thread.< / td > < / tr >
< tr >
< td class = "content" >
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > frame info< br >
2012-03-22 02:14:37 +08:00
< / td >
< / tr >
2011-10-22 10:31:42 +08:00
< tr > < td class = "header" colspan = "2" > Select the stack frame that called the current stack frame.< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > up
2011-10-22 10:31:42 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > up< br >
< b > (lldb)< / b > frame select --relative=1< br >
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Select the stack frame that is called by the current stack frame.< / td > < / tr >
< tr >
2012-10-05 12:26:06 +08:00
< td class = "content" >
< b > (gdb)< / b > down
< / td >
2011-10-22 10:31:42 +08:00
< td class = "content" >
< b > (lldb)< / b > down< br >
< b > (lldb)< / b > frame select --relative=-1< br >
2011-10-25 09:28:31 +08:00
< b > (lldb)< / b > fr s -r-1< br >
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Select a different stack frame using a relative offset.< / td > < / tr >
< tr >
2012-10-05 12:26:06 +08:00
< td class = "content" >
< b > (gdb)< / b > up 2< br >
< b > (gdb)< / b > down 3< br >
< / td >
2011-10-22 10:31:42 +08:00
< td class = "content" >
< b > (lldb)< / b > frame select --relative 2< br >
2011-10-25 09:28:31 +08:00
< b > (lldb)< / b > fr s -r2< br >
2011-10-22 10:31:42 +08:00
< br >
< b > (lldb)< / b > frame select --relative -3< br >
2011-10-25 09:28:31 +08:00
< b > (lldb)< / b > fr s -r-3< br >
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Show the general purpose registers for the current thread.< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > info registers< br >
2011-10-22 10:31:42 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > register read< br >
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
2012-10-18 04:58:52 +08:00
< tr > < td class = "header" colspan = "2" > Write a new decimal value '123' to the current thread register 'rax'.< / td > < / tr >
< tr >
< td class = "content" >
< b > (gdb)< / b > p $rax = 123< br >
< / td >
< td class = "content" >
< b > (lldb)< / b > register write rax 123< br >
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Skip 8 bytes ahead of the current program counter (instruction pointer). Note that we use backticks to evaluate an expression and insert the scalar result in LLDB.< / td > < / tr >
< tr >
< td class = "content" >
< b > (gdb)< / b > jump *$pc+8< br >
< / td >
< td class = "content" >
< b > (lldb)< / b > register write pc `$pc+8`< br >
< / td >
< / tr >
2011-10-25 09:28:31 +08:00
< tr > < td class = "header" colspan = "2" > Show the general purpose registers for the current thread formatted as < b > signed decimal< / b > . LLDB tries to use
the same format characters as < b > printf(3)< / b > when possible. Type "help format" to see the full list of format specifiers.< / td > < / tr >
2011-10-22 10:31:42 +08:00
< tr >
2012-10-05 12:26:06 +08:00
< td class = "content" >
< / td >
2011-10-22 10:31:42 +08:00
< td class = "content" >
< b > (lldb)< / b > register read --format i< br >
2011-10-25 09:28:31 +08:00
< b > (lldb)< / b > re r -f i< br >
2012-02-16 10:10:58 +08:00
< br >
< i > LLDB now supports the GDB shorthand format syntax but there can't be space after the command:< / i > < br >
< b > (lldb)< / b > register read/d< br >
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Show all registers in all register sets for the current thread.< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > info all-registers< br >
2011-10-22 10:31:42 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > register read --all< br >
< b > (lldb)< / b > re r -a< br >
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Show the values for the registers named "rax", "rsp" and "rbp" in the current thread.< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > info all-registers rax rsp rbp< br >
2011-10-22 10:31:42 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > register read rax rsp rbp< br >
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Show the values for the register named "rax" in the current thread formatted as < b > binary< / b > .< / td > < / tr >
< tr >
2012-10-05 12:26:06 +08:00
< td class = "content" >
< b > (gdb)< / b > p/t $rax< br >
< / td >
2011-10-22 10:31:42 +08:00
< td class = "content" >
< b > (lldb)< / b > register read --format binary rax< br >
2011-10-25 09:28:31 +08:00
< b > (lldb)< / b > re r -f b rax< br >
2012-02-16 10:10:58 +08:00
< br >
< i > LLDB now supports the GDB shorthand format syntax but there can't be space after the command:< / i > < br >
< b > (lldb)< / b > register read/t rax< br >
< b > (lldb)< / b > p/t $rax< br >
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Read memory from address 0xbffff3c0 and show 4 hex uint32_t values.< / td > < / tr >
< tr >
2012-10-05 12:26:06 +08:00
< td class = "content" >
< b > (gdb)< / b > x/4xw 0xbffff3c0< br >
< / td >
2011-10-22 10:31:42 +08:00
< td class = "content" >
< b > (lldb)< / b > memory read --size 4 --format x --count 4 0xbffff3c0< br >
2011-10-25 09:28:31 +08:00
< b > (lldb)< / b > me r -s4 -fx -c4 0xbffff3c0< br >
2011-10-22 10:31:42 +08:00
< b > (lldb)< / b > x -s4 -fx -c4 0xbffff3c0< br >
2012-02-16 10:10:58 +08:00
< br >
< i > LLDB now supports the GDB shorthand format syntax but there can't be space after the command:< / i > < br >
< b > (lldb)< / b > memory read/4xw 0xbffff3c0< br >
< b > (lldb)< / b > x/4xw 0xbffff3c0< br >
< b > (lldb)< / b > memory read --gdb-format 4xw 0xbffff3c0< br >
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
2012-02-16 10:10:58 +08:00
< tr > < td class = "header" colspan = "2" > Read memory starting at the expression "argv[0]".< / td > < / tr >
< tr >
2012-10-05 12:26:06 +08:00
< td class = "content" >
< b > (gdb)< / b > x argv[0]< br >
< / td >
2012-02-16 10:10:58 +08:00
< td class = "content" >
< b > (lldb)< / b > memory read `argv[0]`< br >
< i > < b > NOTE:< / b > any command can inline a scalar expression result (as long as the target is stopped) using backticks around any expression:< / i > < br >
< b > (lldb)< / b > memory read --size `sizeof(int)` `argv[0]`< br >
< / td >
< / tr >
2011-10-22 10:31:42 +08:00
< tr > < td class = "header" colspan = "2" > Read 512 bytes of memory from address 0xbffff3c0 and save results to a local file as < b > text< / b > .< / td > < / tr >
< tr >
< td class = "content" >
< b > (gdb)< / b > set logging on< br >
< b > (gdb)< / b > set logging file /tmp/mem.txt< br >
< b > (gdb)< / b > x/512bx 0xbffff3c0< br >
< b > (gdb)< / b > set logging off< br >
< / td >
2012-10-05 12:26:06 +08:00
< td class = "content" >
< b > (lldb)< / b > memory read --outfile /tmp/mem.txt --count 512 0xbffff3c0< br >
< b > (lldb)< / b > me r -o/tmp/mem.txt -c512 0xbffff3c0< br >
< b > (lldb)< / b > x/512bx -o/tmp/mem.txt 0xbffff3c0< br >
< / td >
2011-10-22 10:31:42 +08:00
< / tr >
< tr > < td class = "header" colspan = "2" > Save binary memory data starting at 0x1000 and ending at 0x2000 to a file.< / td > < / tr >
< tr >
2012-10-05 12:26:06 +08:00
< td class = "content" >
< b > (gdb)< / b > dump memory /tmp/mem.bin 0x1000 0x2000
< / td >
< td class = "content" >
2011-10-22 10:31:42 +08:00
< b > (lldb)< / b > memory read --outfile /tmp/mem.bin --binary 0x1000 0x1200< br >
2011-10-25 09:28:31 +08:00
< b > (lldb)< / b > me r -o /tmp/mem.bin -b 0x1000 0x1200< br >
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
2012-11-20 01:47:29 +08:00
< tr > < td class = "header" colspan = "2" > Get information about a specific heap allocation (available on Mac OS X only).< / td > < / tr >
< tr >
< td class = "content" >
< b > (gdb)< / b > info malloc 0x10010d680
< / td >
< td class = "content" >
2013-05-09 05:39:19 +08:00
< b > (lldb)< / b > command script import lldb.macosx.heap< br >
2012-11-20 01:47:29 +08:00
< b > (lldb)< / b > process launch --environment MallocStackLogging=1 -- [ARGS]< br >
< b > (lldb)< / b > malloc_info --stack-history 0x10010d680< br >
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Get information about a specific heap allocation and cast the result to any dynamic type that can be deduced (available on Mac OS X only)< / td > < / tr >
< tr >
< td class = "content" >
< / td >
< td class = "content" >
2013-05-09 05:39:19 +08:00
< b > (lldb)< / b > command script import lldb.macosx.heap< br >
2012-11-20 01:47:29 +08:00
< b > (lldb)< / b > malloc_info --type 0x10010d680< br >
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Find all heap blocks that contain a pointer specified by an expression EXPR (available on Mac OS X only).< / td > < / tr >
< tr >
< td class = "content" >
< / td >
< td class = "content" >
2013-05-09 05:39:19 +08:00
< b > (lldb)< / b > command script import lldb.macosx.heap< br >
2012-11-20 01:47:29 +08:00
< b > (lldb)< / b > ptr_refs EXPR < br >
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Find all heap blocks that contain a C string anywhere in the block (available on Mac OS X only).< / td > < / tr >
< tr >
< td class = "content" >
< / td >
< td class = "content" >
2013-05-09 05:39:19 +08:00
< b > (lldb)< / b > command script import lldb.macosx.heap< br >
2012-11-20 01:47:29 +08:00
< b > (lldb)< / b > cstr_refs CSTRING< br >
< / td >
< / tr >
2011-10-22 10:31:42 +08:00
< tr > < td class = "header" colspan = "2" > Disassemble the current function for the current frame.< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > disassemble
2011-10-22 10:31:42 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > disassemble --frame< br >
< b > (lldb)< / b > di -f
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Disassemble any functions named < b > main< / b > .< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > disassemble main
2011-10-22 10:31:42 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > disassemble --name main< br >
< b > (lldb)< / b > di -n main
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Disassemble an address range.< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > disassemble 0x1eb8 0x1ec3
2011-10-22 10:31:42 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > disassemble --start-address 0x1eb8 --end-address 0x1ec3< br >
< b > (lldb)< / b > di -s 0x1eb8 -e 0x1ec3< br >
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Disassemble 20 instructions from a given address.< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > x/20i 0x1eb8
2011-10-22 10:31:42 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > disassemble --start-address 0x1eb8 --count 20< br >
< b > (lldb)< / b > di -s 0x1eb8 -c 20< br >
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Show mixed source and disassembly for the current function for the current frame.< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
n/a
2011-10-22 10:31:42 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > disassemble --frame --mixed< br >
< b > (lldb)< / b > di -f -m
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Disassemble the current function for the current frame and show the opcode bytes.< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
n/a
2011-10-22 10:31:42 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > disassemble --frame --bytes< br >
< b > (lldb)< / b > di -f -b
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Disassemble the current source line for the current frame.< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
n/a
2011-10-22 10:31:42 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > disassemble --line< br >
< b > (lldb)< / b > di -l
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
< / table >
< p >
< / div >
2011-10-25 09:28:31 +08:00
< div class = "postfooter" > < / div >
2011-10-22 10:31:42 +08:00
2011-10-25 09:28:31 +08:00
< h1 class = "postheader" > Executable and Shared Library Query Commands< / h1 >
< div class = "post" >
2011-10-22 10:31:42 +08:00
< p >
2011-10-25 09:28:31 +08:00
< table class = "stats" width = "620" cellspacing = "0" >
2011-10-22 10:31:42 +08:00
< tr >
< td class = "hed" width = "50%" > GDB< / td >
2012-10-05 12:26:06 +08:00
< td class = "hed" width = "50%" > LLDB< / td >
2011-10-22 10:31:42 +08:00
< / tr >
< tr > < td class = "header" colspan = "2" > List the main executable and all dependent shared libraries.< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > info shared< br >
2011-10-22 10:31:42 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > image list< br >
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
2012-10-20 03:52:12 +08:00
< tr > < td class = "header" colspan = "2" > Look up information for a raw address in the executable or any shared libraries.< / td > < / tr >
2011-10-22 10:31:42 +08:00
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > info symbol 0x1ec4< br >
2011-10-22 10:31:42 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > image lookup --address 0x1ec4< br >
< b > (lldb)< / b > im loo -a 0x1ec4< br >
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
2013-04-19 06:03:01 +08:00
< tr > < td class = "header" colspan = "2" > Look up functions matching a regular expression in a binary.< / td > < / tr >
< tr >
< td class = "content" >
< b > (gdb)< / b > info function < FUNC_REGEX> < br >
< / td >
< td class = "content" >
This one finds debug symbols:< br >
< b > (lldb)< / b > image lookup -r -n < FUNC_REGEX> < br > < br >
This one finds non-debug symbols:< br >
< b > (lldb)< / b > image lookup -r -s < FUNC_REGEX> < br > < br >
Provide a list of binaries as arguments to limit the search.
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Find full souce line information.< / td > < / tr >
< tr >
< td class = "content" >
< b > (gdb)< / b > info line 0x1ec4< br >
< / td >
< td class = "content" >
This one is a bit messy at present. Do:< br > < br >
< b > (lldb)< / b > image lookup -v --address 0x1ec4< br > < br >
and look for the LineEntry line, which will have the full source path and
line range information.< br >
< / td >
< / tr >
2013-05-14 02:30:58 +08:00
< tr > < td class = "header" colspan = "2" > Look up information for an address in < b > a.out< / b > only.< / td > < / tr >
2011-10-22 10:31:42 +08:00
< tr >
< td class = "content" >
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > image lookup --address 0x1ec4 a.out< br >
< b > (lldb)< / b > im loo -a 0x1ec4 a.out< br >
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
2012-10-20 03:52:12 +08:00
< tr > < td class = "header" colspan = "2" > Look up information for for a type < code > Point< / code > by name.< / td > < / tr >
2011-10-22 10:31:42 +08:00
< tr >
< td class = "content" >
2012-10-20 03:52:12 +08:00
< b > (gdb)< / b > ptype Point< br >
2011-10-22 10:31:42 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > image lookup --type Point< br >
< b > (lldb)< / b > im loo -t Point< br >
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Dump all sections from the main executable and any shared libraries.< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > maintenance info sections< br >
2011-10-22 10:31:42 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > image dump sections< br >
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Dump all sections in the < b > a.out< / b > module.< / td > < / tr >
< tr >
< td class = "content" >
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > image dump sections a.out< br >
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Dump all symbols from the main executable and any shared libraries.< / td > < / tr >
< tr >
< td class = "content" >
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > image dump symtab< br >
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Dump all symbols in < b > a.out< / b > and < b > liba.so< / b > .< / td > < / tr >
< tr >
< td class = "content" >
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > image dump symtab a.out liba.so< br >
2011-10-22 10:31:42 +08:00
< / td >
< / tr >
< / table >
< p >
< / div >
2012-05-12 02:01:15 +08:00
< div class = "postfooter" > < / div >
< h1 class = "postheader" > Miscellaneous< / h1 >
< div class = "post" >
< p >
< table class = "stats" width = "620" cellspacing = "0" >
< tr >
< td class = "hed" width = "50%" > GDB< / td >
2012-10-05 12:26:06 +08:00
< td class = "hed" width = "50%" > LLDB< / td >
2012-05-12 02:01:15 +08:00
< / tr >
< tr > < td class = "header" colspan = "2" > Echo text to the screen.< / td > < / tr >
< tr >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (gdb)< / b > echo Here is some text\n< br >
2012-05-12 02:01:15 +08:00
< / td >
< td class = "content" >
2012-10-05 12:26:06 +08:00
< b > (lldb)< / b > script print " Here is some text" < br >
2012-05-12 02:01:15 +08:00
< / td >
< / tr >
2012-10-26 12:38:09 +08:00
< tr > < td class = "header" colspan = "2" > Remap source file pathnames for the debug session. If your source files are no longer located in the same location as when the program was built --- maybe the program was built on a different computer --- you need to tell the debugger how to find the sources at their local file path instead of the build system's file path.< / td > < / tr >
< tr >
< td class = "content" >
< b > (gdb)< / b > set pathname-substitutions /buildbot/path /my/path< br >
< / td >
< td class = "content" >
< b > (lldb)< / b > settings set target.source-map /buildbot/path /my/path< br >
< / td >
< / tr >
< tr > < td class = "header" colspan = "2" > Supply a catchall directory to search for source files in.< / td > < / tr >
< tr >
< td class = "content" >
< b > (gdb)< / b > directory /my/path< br >
< / td >
< td class = "content" >
2013-06-25 03:37:49 +08:00
(< i > No equivalent command - use the source-map instead.)< br >
2012-10-26 12:38:09 +08:00
< / td >
< / tr >
2012-05-12 02:01:15 +08:00
< / table >
< p >
< / div >
2011-10-25 09:28:31 +08:00
< div class = "postfooter" > < / div >
2011-10-22 10:31:42 +08:00
< p >
2011-10-25 09:28:31 +08:00
2011-10-22 10:31:42 +08:00
< / div >
2011-10-25 09:28:31 +08:00
< / div >
< / div >
2011-10-22 10:31:42 +08:00
< / div >
< / body >
< / html >