Skip to content

bgyu/lldb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

lldb

Most used lldb commands

Starting lldb

lldb a.out

# with args
lldb -- a.out arg1 arg2

(lldb) file a.out

Help

(lldb) help

# help on specific sub commands
(lldb) help breakpoint
(lldb) help watchpoint
(lldb) help source

Running

(lldb) run
# or short style
(lldb) r

Setting breakpoint

# set breakpoint on file main.cpp at line 30
(lldb) breakpoint set -f main.cpp -l 30

# or short style
(lldb) br s -f main.cpp -l 30
# or enen shorter style
(lldb) b main.cpp : 30

# Breakpoints with Symbols
# On a function
(lldb) b square(int)
# On a class method
(lldb) b Demo::demo()
# Inside a namespace
(lldb) b LLDBDemo::add(int)

# List breakpoints
(lldb) br list

# delete breakpoint with number 1, can use `br list` to show all breakpoints first then delete based on number
(lldb) br delete 1

# delete all breakpoints
(lldb) br del

Steping around

# stepping over
(lldb) next
(lldb) n

# stepping into
(lldb) step
(lldb) s

# continue
(lldb) continue
(lldb) c

Print variable contents

# print the content of a
(lldb) print a

# frame variables (local variables)
(lldb) frame variable
(lldb) fr v

Call stack (backtrace)

(lldb) bt

# select frame 2
(lldb) fr select 2

# select top frame 0 (the top of current stack)
(lldb) fr select 0

# switch frame 3, shortcut version
(lldb) f 3

# go back to the current frame
(lldb) fr select

Watch points

Note: program must be running to set watch points

# when variable `a` gets changed, the pragram will stop at where it changed
(lldb) watchpoint set variable a

# you can also monitor read, write or read_write on variable `a`
(lldb) watchpoint set variable -w read | write | read_write

# watch member variable (short version) `obj.m_count`
# w -> watchpoint, s -> set, v -> variable
(lldb) w s v -w read obj.m_count

# delete watchpoint 1
(lldb) watchpoint delete 1

Kill process and exit

# kill current debugging process
(lldb) kill
# quit lldb
(lldb) quit

About

Most used lldb commands

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published