
[ moved to glasgow-haskell-users@haskell.org ]
I am using Green Card to make some FFI modules with GHC, but sometimes it segfaults in the middle of nowhere, leaving no sensible stack trace in gdb.
I wonder what is the proper way to debug FFI modules written in C? Trying to add a "-g" flag doesn't seem help at all...
You should be able to debug the normal C code using gdb. If the crash happens somewhere in Haskell code, then gdb is of less use (unless you happen to know the details of GHC's execution model). It sounds like in your case the crash is happening somewhere in Haskell. There are a few possible approaches: - If it is a callback into Haskell that is crashing, you should be able to use gdb to find which call into Haskell is the culprit, which might give you some clues. - use Debug.Trace.trace in the Haskell code to narrow down the bug. Ugly, but very useful. - Robert Ennals is working on a debugger for GHC as part of his speculative evaluation work. It's very much a work in progress though, and I haven't tried it myself yet. It's in ghc/utils/hs-debug on the speceval_2 branch of CVS. Cheers, Simon
participants (1)
-
Simon Marlow