Haskell: C debug function imported via FFI

I am importing some things into Haskell via FFI and would like to be able to debug them using lldb. For example, I might have the following Haskell file (test.hs):

main = do
   foo
   return()

foreign import ccall "foo" foo :: IO ()

      

And the following C file (ctest.c):

#include <stdio.h>

void foo(){
    printf("test\n");
}

      

I can compile this with ghc test.hs ctest.c

. If I run the executable through LLDB I can set a breakpoint at foo

, however it only gives me the assembly code, like:

test`foo: ->  
0x1000019e0 <+0>: pushq  %rbp
0x1000019e1 <+1>: movq   %rsp, %rbp
0x1000019e4 <+4>: subq   $0x10, %rsp
0x1000019e8 <+8>: leaq   0x33eb31(%rip), %rdi      ; "test\n"

      

Is there a way to tell GHC to compile the C file I import via FFI with -g

so that I can get debug symbols?

+3


source to share


1 answer


GHC provides an interface for passing parameters to many internals, including the C compiler. The option you are looking for is optc

.

For example, you can write ghc -optc -g Main

.



You can see a list of all these options here .

+5


source







All Articles