
Is there a way to compile the RTS so that the names of data constructors are retained?
My memory from a long, long time ago is that we had a debugging mode which used libbfd to get symbol names and some GHC-demangling code to turn those back into names like the user typed in.
Yes, we still have that code, but it doesn't get much use - gdb can map addresses back to symbol names. I think I always intended to beef this up using a proper hash table for the address->symbol mapping, but never got around to it. Alternatively, if you compile for profiling, then info tables contain some extra information including the constructor name for contructors.
It looks like Printer.c has some hooks for printing data structures, is it feasible to make a primitive that allows Haskell code to call into this? I'm thinking in particular of calling something like printClosure() from Haskell code.
If it's a global symbol, you should be able to access it form the ffi.
If you want to traverse data structures the way you can using the HugsInternals library, you might want to tweak the code a little to provide a similar semantics/ API. Basically, all you have to do is take the C code and split it into handy bits.
This is a nice idea - we'll be happy to incorporate the changes. Cheers, Simon