Debug C and Python

Written on November 22, 2025

2 min. read
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Start debugger 
==============

C:
clang -g sum.c -o sum
lldb sum

Py:
python3 -m pdb sum.py

|-----------------------|----------------|--------------|
| Action                | LLDB           | PDB          |
|-----------------------|----------------|--------------|
| Run program           | run / r        | run          |
| Continue after break  | continue / c   | continue / c |
| Step over line        | next / n       | next / n     |
| Step into function    | step / s       | step / s     |
| Step out of function  | finish         | return       |
| Set breakpoint (line) | b sum.c:12     | b 12         |
| Set breakpoint (func) | b main         | b myfunc     |
| List breakpoints      | br list        | b            |
| Delete breakpoint     | br del 1       | cl 1         |
| Show current source   | list / l       | l / ll       |
| Print variable        | p x            | p x          |
| Pretty print          | po x           | pp x         |
| Show local variables  | frame variable | locals()     |
| Show function args    | frame variable | args         |
| Backtrace / stack     | bt             | where / w    |
| Move up stack frame   | up             | up           |
| Move down stack frame | down           | down         |
| Modify variable       | expr x = 10    | x = 10       |
| Watch variable        | watch x        | display x    |
| Remove watch          | watch del 1    | undisplay 1  |
| Evaluate expression   | expr 2+2       | p 2+2        |
| Run until line        | thread until 5 | until 5      |
| Quit debugger         | quit / q       | quit / q     |
| Conditional           | b sum.c:12     |              |   
|   breakpoint          | -c 'x > 5'     | b 12, x>5    |
| Disassemble           | disassemble    | import dis;  |
|                       |                | dis.dis(func)|
|-----------------------|----------------|--------------|