Set, List and Delete Breakpoints in LLDB
Set LLDB breakpoints by function, file and line, address or regex, then list, disable, delete, make them conditional or one-shot, and attach commands to them.

A breakpoint tells the debugger where to take control of your program. LLDB has a rich breakpoint system, and its commands follow the same noun-verb grammar as everything else: breakpoint set, breakpoint list, breakpoint delete, breakpoint modify. The long forms look verbose beside GDB's break, but each option is named, so a command reads like a sentence, and the short aliases (b, br) cover the common cases. This post goes through the ways to name a place, how to see and manage what you have set, how to make a breakpoint conditional, ignore its first hits or remove itself after one, and how to run commands when it fires. LLDB 21 on x86-64 Linux with Clang 21 is the reference; macOS output is the same apart from paths and addresses.
The program
Two source files, so there are file names to use.
#ifndef STATS_H
#define STATS_H
int clamp(int value, int low, int high);
int total(const int *values, int count);
#endif#include "stats.h"
int clamp(int value, int low, int high)
{
if (value < low)
return low;
if (value > high)
return high;
return value;
}
int total(const int *values, int count)
{
int sum = 0;
for (int i = 0; i < count; i++)
sum += clamp(values[i], 0, 100);
return sum;
}#include <stdio.h>
#include "stats.h"
int main(void)
{
int readings[] = {12, 250, 37, -5, 90};
int count = sizeof readings / sizeof readings[0];
int sum = total(readings, count);
printf("total = %d\n", sum);
return 0;
}Clamping 250 to 100 and -5 to 0 gives 12 + 100 + 37 + 0 + 90 = 239. Build with Clang and start LLDB.
clang -g -O0 -Wall -Wextra -o stats main.c stats.c
lldb --no-lldbinit ./statsBreak on a function
(lldb) breakpoint set --name clamp
Breakpoint 1: where = stats`clamp + 19 at stats.c:5:9, address = 0x0000000000001139The short forms are b clamp and br s -n clamp. LLDB reports the breakpoint number, where it is as function plus offset, the file, line and column, and the address. -n is the short option for --name. If more than one function has the name, LLDB creates one breakpoint with several locations and says 2 locations.
You can also break on a method, a selector or a regular expression.
(lldb) breakpoint set --func-regex '^c.*p$'
Breakpoint 2: where = stats`clamp + 19 at stats.c:5:9, address = 0x0000000000001139
(lldb) breakpoint set --method push_back--func-regex (-r) matches function names, which is useful for a family of functions with a common prefix. --method and --selector are for C++ and Objective-C.
Break on a file and line
(lldb) breakpoint set --file stats.c --line 16
Breakpoint 3: where = stats`total + 51 at stats.c:16:15, address = 0x0000000000001167
(lldb) b stats.c:16
Breakpoint 4: where = stats`total + 51 at stats.c:16:15, address = 0x0000000000001167The short form b FILE:LINE is the same and the one you will type. Line 16 is sum += clamp(values[i], 0, 100);. As in GDB, a line with no code is moved to the next line that has some, and LLDB tells you where it landed, so read the reply. A bare b 16 uses the file of the current frame, or the file with main if there is none. The column is part of the location in recent LLDB; two statements on one line can have separate breakpoints with --column.
Break on an address
(lldb) breakpoint set --address 0x1139
Breakpoint 5: address = stats[0x0000000000001139]An address given before the program runs is an offset in the executable file, and LLDB shows it in the module[address] form until the program loads and the location resolves. Use --shlib stats to say which module an address belongs to when several are loaded.
List breakpoints
(lldb) breakpoint list
Current breakpoints:
1: name = 'clamp', locations = 1
1.1: where = stats`clamp + 19 at stats.c:5:9, address = 0x0000000000001139, unresolved, hit count = 0
3: file = '/home/dev/stats.c', line = 16, exact_match = 0, locations = 1
3.1: where = stats`total + 51 at stats.c:16:15, address = 0x0000000000001167, unresolved, hit count = 0This output is shortened. Each breakpoint is a number with one or more locations numbered N.1, N.2. The word unresolved before the program runs means the address is not yet a live address; after run it becomes resolved. The hit count tells how many times each location fired, which is useful to see which one is actually used. breakpoint list --brief or -b prints one line each, and br l -f adds full detail.
Disable, enable and delete
Commands take breakpoint numbers, locations such as 1.1, or ranges like 3-5.
(lldb) breakpoint disable 2 4
2 breakpoints disabled.
(lldb) breakpoint enable 2
1 breakpoints enabled.
(lldb) breakpoint delete 4
1 breakpoints deleted; 3 breakpoint locations disabled.The odd wording in the last line, 3 breakpoint locations disabled, is LLDB counting locations that were disabled earlier. With no argument, breakpoint delete removes everything after a confirmation prompt, and breakpoint delete -f skips the prompt. Disable a breakpoint rather than deleting when you will want it again. breakpoint clear --file stats.c --line 16 removes by location, which is handy when you have forgotten the number.
Conditions, ignore counts and one-shots
A condition is an expression, in the language of the code, that has to be true for the breakpoint to stop. Set it when creating the breakpoint with -c, or add it later with breakpoint modify.
(lldb) breakpoint set --name clamp --condition 'value > 100'
Breakpoint 6: where = stats`clamp + 19 at stats.c:5:9, address = 0x0000000000001139
(lldb) run
Process 51203 launched: '/home/dev/stats' (x86_64)
Process 51203 stopped
* thread #1, name = 'stats', stop reason = breakpoint 6.1
frame #0: 0x0000555555555139 stats`clamp(value=250, low=0, high=100) at stats.c:5:9
2
3 int clamp(int value, int low, int high)
4 {
-> 5 if (value < low)
6 return low;
7 if (value > high)
8 return high;The stop shows value=250, the only call where the condition held. To change or clear the condition use breakpoint modify -c 'value < 0' 6 and breakpoint modify -c '' 6.
--ignore-count, -i, tells LLDB to let the first N hits pass.
(lldb) breakpoint modify -i 3 1And --one-shot, -o, makes the breakpoint delete itself after the first stop, which is GDB's tbreak.
(lldb) breakpoint set --name total --one-shot true
Breakpoint 7: where = stats`total + 17 at stats.c:14:9, address = 0x0000000000001157Conditions cost a stop on every hit, because LLDB evaluates the expression in the debugger after halting the process, as GDB does. Use them for rare conditions, and not on a function hit a million times.
Commands on a breakpoint
breakpoint command add attaches commands to run when the breakpoint hits. LLDB reads lines until DONE.
(lldb) breakpoint command add 6
Enter your debugger command(s). Type 'DONE' to end.
> frame variable value
> continue
> DONEWith these two commands the breakpoint logs value and carries on, like a GDB commands list ending in continue. For many hits, add --auto-continue to the breakpoint instead of ending with continue, which is more robust: breakpoint modify --auto-continue true 6. LLDB stops running the command list at the first command that resumes the process, as GDB does, so put continue last or use the flag. For a quiet trace, a breakpoint can also be set with a silent flag in scripts, --silent.
In an -o batch invocation, the equivalent is breakpoint command add -o 'frame variable value' 6, with the command as a one-line option.
lldb --no-lldbinit -b \
-o "breakpoint set --name clamp" \
-o "breakpoint command add -o 'frame variable value' 1" \
-o "breakpoint modify --auto-continue true 1" \
-o run ./stats(lldb) target create "./stats"
Current executable set to '/home/dev/stats' (x86_64).
(lldb) breakpoint set --name clamp
Breakpoint 1: where = stats`clamp + 19 at stats.c:5:9, address = 0x0000000000001139
(lldb) breakpoint command add -o 'frame variable value' 1
(lldb) breakpoint modify --auto-continue true 1
(lldb) run
Process 51310 launched: '/home/dev/stats' (x86_64)
(int) value = 12
(int) value = 250
(int) value = 37
(int) value = -5
(int) value = 90
total = 239
Process 51310 exited with status = 0 (0x00000000)The batch log shows the five calls and the values passed to clamp, then the program's own output and the exit status. LLDB prints the stop report for each stop only when the breakpoint does not auto-continue, so the trace is clean.
Names and groups
Breakpoints can carry names. breakpoint name add -N parse 1 3 tags breakpoints 1 and 3 with the name parse, and breakpoint disable parse then acts on the whole group. That is how you manage a set of breakpoints for one subsystem. breakpoint write -f bps.json saves all breakpoints to a file and breakpoint read -f bps.json loads them in another session, so a debugging setup survives a restart. LLDB does not keep breakpoints between sessions by itself.
Settings that change breakpoint behaviour
settings set target.breakpoint-use-avoid-list false lets you break in system functions that LLDB normally avoids when stepping. settings set target.skip-prologue false stops function breakpoints on the first instruction instead of after the prologue. settings set breakpoints.use-shlib-cache true is unrelated housekeeping. The two that matter for a first week are the prologue setting, for when you want to see arguments in registers, and target.process.stop-on-sharedlibrary-events, which stops each time a library loads and is the tool for debugging loader problems.


