Profile cover photo
Profile photo
Nathan Howell
About
Nathan's posts

Post has attachment
I recently released a Protocol Buffers package that works with GHC.Generics. It's come along pretty far since the prototype I blogged about last spring, but it's useable despite a few rough edges.

Post has attachment
Something I've wondered for a while now... could the Cabal description language be replaced with an equivalent embedded DSL?

Post has attachment
I've been considering a few options to (hopefully) make Protocol Buffers easier to use from Haskell...

http://breaks.for.alienz.org/blog/2012/05/20/generics-and-protocol-buffers/

A little GHC hacking on an extended train ride home this evening... working on adding symbols for all the STG registers. BaseReg is functioning now, and the StgRegTable definition comes out of the C headers as it should.


$ gdb /tmp/dwarf
GNU gdb (GDB) 7.3.1

Reading symbols from /private/tmp/dwarf...Reading symbols from /private/tmp/dwarf.dSYM/Contents/Resources/DWARF/dwarf...done.
done.

(gdb) break dwarf.hs:2
Breakpoint 1 at 0x1000013da: file /tmp/dwarf.hs, line 2. (3 locations)

(gdb) run
Starting program: /private/tmp/dwarf

Breakpoint 1, Main_main1_info (Base_Arg=0x1003dcb98) at /tmp/dwarf.hs:2
2 main = putStrLn "ok"

(gdb) print Main_main1_info
$1 = {void (struct StgRegTable_ *)} 0x1000014b0 <Main_main1_info>

(gdb) info address Base_Arg
Symbol "Base_Arg" is multi-location:
Range 0x1000014b0-0x1000014bc: a complex DWARF expression:
1: DW_OP_reg13 [$r13]

(gdb) print Base_Arg->rCurrentTSO
$2 = (struct StgTSO_ *) 0x101205390

(gdb) print Base_Arg->rCurrentTSO->cap->in_haskell
$3 = rtsTrue

Post has attachment
I hacked together a little example of how clang can be used to write (very much unsupported!) external primops for GHC in C/C++... for those very special occasions when unboxed Haskell and C-- just don't cut it.

Note: This particular example hasn't been thoroughly tested and should only be used for personal amusement. It probably won't even run on your computer.

I feel like we're finally getting somewhere with this stack walking business.

(gdb) where
#0 Main_main_info () at dwarf.hs:2
#1 0x00000001001b439c in s2xo_info () at libraries/base/GHC/Base.lhs:620
#2 0x0000000000000000 in ?? ()

(gdb) frame 0
#0 Main_main_info () at dwarf.hs:2
2 main = return ()

(gdb) frame 1
#1 0x00000001001b439c in s2xo_info () at libraries/base/GHC/Base.lhs:620
620 bindIO (IO m) k = IO $ \ s -> case m s of (# new_s, a #) -> unIO (k a) new_s

(gdb) info frame
Stack level 1, frame at 0x7fff5fbfae90:
rip = 0x1001b439c in s2xo_info (libraries/base/GHC/Base.lhs:620); saved rip 0x0
called by frame at 0x7fff5fbfae98, caller of frame at 0x7fff5fbfae80
source language unknown.
Arglist at 0x7fff5fbfae78, args:
Locals at 0x7fff5fbfae78, Previous frame's sp is 0x7fff5fbfae90
Saved registers:
rip at 0x7fff5fbfae88
Wait while more posts are being loaded