
Hi, As I don't know anything about Haskell, can I make a stupid question: Is there any method to create debug symbols for a Haskell program, and is it possible to debug with gdb? Thanks!

On Tue, Apr 12, 2011 at 11:59 PM, Svante Signell
Hi,
As I don't know anything about Haskell, can I make a stupid question: Is there any method to create debug symbols for a Haskell program, and is it possible to debug with gdb?
You can run gdb on a Haskell program, but it's unlikely you'll learn anything useful unless you're a compiler writer trying to debug your compiler or runtime system. ghci (the interactive version of GHC) has a built-in debugger that may be the closest thing to what you're used to with gdb. There is also a small cottage industry of debuggers that are more tailored to the process of debugging a functional program. Cheers, Tim -- Tim Chevalier * http://cs.pdx.edu/~tjc/ * Often in error, never in doubt "an intelligent person fights for lost causes,realizing that others are merely effects" -- E.E. Cummings

On 13 April 2011 07:59, Svante Signell
As I don't know anything about Haskell, can I make a stupid question: Is there any method to create debug symbols for a Haskell program, and is it possible to debug with gdb?
You cannot create debug symbols. Things that are possible: 1. You may use the -debug flag to GHC to link with the debug RTS, which has full debugging information for GDB. Note that this only lets you debug the *RTS*, not any of the code you wrote 2. Use GDB to debug your Haskell code without giving it any symbols or understanding of the Haskell calling conventions. This is very difficult. Information on this is on the GHC wiki: http://hackage.haskell.org/trac/ghc/wiki/Debugging/CompiledCode?redirectedfr... 3. Use the GHCi debugger, which does actually work surprisingly well: http://www.haskell.org/ghc/docs/7.0.3/html/users_guide/ghci-debugger.html Cheers, Max

Max and Tim, Thank you for your replies, continuation below. On Wed, 2011-04-13 at 08:27 +0100, Max Bolingbroke wrote:
On 13 April 2011 07:59, Svante Signell
wrote: As I don't know anything about Haskell, can I make a stupid question: Is there any method to create debug symbols for a Haskell program, and is it possible to debug with gdb?
You cannot create debug symbols. Things that are possible:
1. You may use the -debug flag to GHC to link with the debug RTS, which has full debugging information for GDB. Note that this only lets you debug the *RTS*, not any of the code you wrote
2. Use GDB to debug your Haskell code without giving it any symbols or understanding of the Haskell calling conventions. This is very difficult. Information on this is on the GHC wiki: http://hackage.haskell.org/trac/ghc/wiki/Debugging/CompiledCode?redirectedfr...
3. Use the GHCi debugger, which does actually work surprisingly well: http://www.haskell.org/ghc/docs/7.0.3/html/users_guide/ghci-debugger.html
The problem is that I'm trying to bootstrap ghc to 6.10.1 using 6.8.2 under Debian GNU/Hurd. Yes, I know these packages are old but so far we only have a working 6.8.2 version and 6.10.1 is the latest version not requiring 6.10 to bootstrap. Cross-compiling is another, not yet tested, alternative. The problem is that the configure step hangs when compiling the random library, and I've tried a lot of settings, the hang is at the same place. A stripped down call is: cd libraries/random: ../cabal-bin /usr/bin/ghc6 ../bootstrapping.conf configure --verbose=3 --with-compiler =../../ghc/stage1-inplace/ghc --with-hc-pkg=../../utils/ghc-pkg/install-inplace/bin/ghc-pkg Configuring random-1.0.0.1... Creating dist (and its parents) ("../../ghc/stage1-inplace/ghc",["--numeric-version"]) ../../ghc/stage1-inplace/ghc is version 6.10.1 ("../../utils/ghc-pkg/install-inplace/bin/ghc-pkg",["--version"]) ../../utils/ghc-pkg/install-inplace/bin/ghc-pkg is version 6.10.1 ("../../ghc/stage1-inplace/ghc",["--supported-languages"]) Reading installed packages... ("../../utils/ghc-pkg/install-inplace/bin/ghc-pkg",["dump","--global"]) ^C <- hang here! The last part of the gdb backtrace shows: #5 0x011d4ce0 in __libc_read (fd=DWARF-2 expression error: DW_OP_reg operations must be used either alone or in conjuction with DW_OP_piece or DW_OP_bit_piece. ) at ../sysdeps/mach/hurd/read.c:27 #6 0x084919c8 in s9qJ_ret () #7 0x0861f842 in StgRun () #8 0x087c44e0 in ?? () I assume the calling program is cabal-bin, but no debug symbols are available. (I have debug versions of libc/gnumach/hurd installed). Setting a breakpoint in the calling program does not seem to be possible. Any hints?

Hello Svante, I have a few recommendations, places where I'd check: 1. Consult the arguments passed to read() usign GDB (your libc has debugging symbols) and see if they are obviously wrong. It seems more plausible that they are something that would be right for Linux, but not so right for Hurd. 2. Take the source code for ghc-pkg, and start adding debug prints, checking to see if the print is triggered or not (it will be useful if you can figure out what command you can run to just recompile ghc-pkg). See if you can reduce the program to a minimal one that still hangs. 3. Compile GHC with the flag -ddump-stg, and pipe all of this output to a file. With any luck, the block s9qJ will have been present during this stage, at which point you can use it to trace back to a file. Note that due to lazy evaluation, s9qJ is probably /not/ actually the culprit, which is why I recommend doing (2) first; it's a lot easier to wade around smaller bits of code. Another recommendation is to bootstrap 6.8.3. (the last 6.8 release) first, before attempting 6.10.1. Edward
participants (4)
-
Edward Z. Yang
-
Max Bolingbroke
-
Svante Signell
-
Tim Chevalier