Skip to content

Instantly share code, notes, and snippets.

@mlafeldt
Last active December 8, 2025 19:59
Show Gist options
  • Select an option

  • Save mlafeldt/14fd6d8840e4297621908b78b674d47c to your computer and use it in GitHub Desktop.

Select an option

Save mlafeldt/14fd6d8840e4297621908b78b674d47c to your computer and use it in GitHub Desktop.
How to use lldb with duckdb-go
❯ CGO_CFLAGS="-I$DUCKDB_SRC/src/include"
CGO_LDFLAGS="-L$DUCKDB_SRC/build/debug/src -lduckdb -Wl,-rpath,$DUCKDB_SRC/build/debug/src"
go build -tags "duckdb_use_lib" -gcflags="all=-N -l" -o simple_debug ./examples/simple
# github.com/duckdb/duckdb-go/v2/examples/simple
ld: warning: duplicate -rpath '/Users/mathias/devel/duckdb/duckdb/build/debug/src' ignored
ld: warning: duplicate -rpath '/Users/mathias/devel/duckdb/duckdb/build/debug/src' ignored
ld: warning: ignoring duplicate libraries: '-lduckdb'
❯ lldb ./simple_debug
(lldb) target create "./simple_debug"
Current executable set to '/Users/mathias/devel/duckdb/duckdb-go/simple_debug' (arm64).
(lldb) breakpoint set -n duckdb_connect
Breakpoint 1: where = libduckdb.dylib`::duckdb_connect(duckdb_database, duckdb_connection *) + 36 at duckdb-c.cpp:98:7, address = 0x000000000674afb8
(lldb) run
Process 4775 launched: '/Users/mathias/devel/duckdb/duckdb-go/simple_debug' (arm64)
simple_debug(4775,0x1f9d1e200) malloc: nano zone abandoned due to inability to reserve vm space.
Process 4775 stopped
* thread #5, stop reason = breakpoint 1.1
frame #0: 0x000000012019efb8 libduckdb.dylib`duckdb_connect(database=0x0000602000000b70, out=0x000011400018a008) at duckdb-c.cpp:98:7
95 }
96
97 duckdb_state duckdb_connect(duckdb_database database, duckdb_connection *out) {
-> 98 if (!database || !out) {
99 return DuckDBError;
100 }
101
(lldb) bt
* thread #5, stop reason = breakpoint 1.1
* frame #0: 0x000000012019efb8 libduckdb.dylib`duckdb_connect(database=0x0000602000000b70, out=0x000011400018a008) at duckdb-c.cpp:98:7
frame #1: 0x00000001001c4ba4 simple_debug`_cgo_efc25dea71ac_Cfunc_duckdb_connect + 52
(lldb) c
Process 4775 resuming
2025/12/08 18:21:14 DB opened with access mode read_write
2025/12/08 18:21:14 marc is 99 years old, 1.91 tall, bday on 1970-01-01T00:00:00Z and has awesomeness: true
2025/12/08 18:21:14 macgyver is 70 years old, 1.85 tall, bday on 1951-01-23T00:00:00Z and has awesomeness: true
2025/12/08 18:21:14 Deleted 2 rows
2025/12/08 18:21:14 Starting transaction...
2025/12/08 18:21:14 User Gru was inserted
2025/12/08 18:21:14 Rolling back transaction...
2025/12/08 18:21:14 Couldn't find user Gru
2025/12/08 18:21:14 Kevin is 11 years old, 0.55 tall, bday on 2013-07-06T00:00:00Z and has awesomeness: true
2025/12/08 18:21:14 Bob is 12 years old, 0.73 tall, bday on 2012-11-04T00:00:00Z and has awesomeness: true
2025/12/08 18:21:14 Stuart is 13 years old, 0.66 tall, bday on 2014-02-12T00:00:00Z and has awesomeness: true
Process 4775 exited with status = 0 (0x00000000)
(lldb) ^D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment