Skip to content

Instantly share code, notes, and snippets.

@alt-romes
Created March 9, 2026 16:09
Show Gist options
  • Select an option

  • Save alt-romes/7d0eddbf3dc842b01c7bb17db72d97bc to your computer and use it in GitHub Desktop.

Select an option

Save alt-romes/7d0eddbf3dc842b01c7bb17db72d97bc to your computer and use it in GitHub Desktop.
Running C debugger on extra C sources in Haskell program
#include <stdio.h>
void do_c_thing(int x) {
printf("Hello there from C! %d\n", x);
}
module Main where
foreign import ccall unsafe "do_c_thing" do_c_thing :: Int -> IO ()
main = do
do_c_thing 5
$ ghc Main.hs extra.c -g -optc-g
$ lldb -- ./Main
(lldb) target create "./Main"
Current executable set to '<PATH>/Main' (arm64).
(lldb) b do_c_thing
Breakpoint 1: where = Main`do_c_thing + 16 at extra.c:3:40, address = 0x000000010000bcfc
(lldb) run
Process 34598 launched: '<PATH>/Main' (arm64)
Process 34598 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x000000010000bcfc Main`do_c_thing(x=5) at extra.c:3:40
1 #include <stdio.h>
2 void do_c_thing(int x) {
-> 3 printf("Hello there from C! %d\n", x);
4 }
Target 0: (Main) stopped.
(lldb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment