gdb: disable ghc's rts timer and disable signal handlers
authorBernhard Urban <lewurm@gmail.com>
Tue, 17 Jul 2012 18:27:06 +0000 (20:27 +0200)
committerBernhard Urban <lewurm@gmail.com>
Tue, 17 Jul 2012 18:27:06 +0000 (20:27 +0200)
debugging jitted code is nice again (as it was with 6.12.*)

.gdbcmds [new file with mode: 0644]
HACKING
Makefile
Mate/MethodPool.hs

diff --git a/.gdbcmds b/.gdbcmds
new file mode 100644 (file)
index 0000000..f40cd9e
--- /dev/null
+++ b/.gdbcmds
@@ -0,0 +1,3 @@
+handle SIGILL nostop
+handle SIGSEGV nostop
+run
diff --git a/HACKING b/HACKING
index 2d12341320f1498ce2cca2659ff63c37d33865cb..c70e19460291d17828bed41b7f06b43fe007c0f7 100644 (file)
--- a/HACKING
+++ b/HACKING
@@ -1,11 +1,19 @@
 for testing with a release build, use
 $ make tests/Fib
 
 for testing with a release build, use
 $ make tests/Fib
 
+
 for testing a release build against OpenJDK output, use
 $ make tests/Fib.test
 
 for testing a release build against OpenJDK output, use
 $ make tests/Fib.test
 
+
 for testing with a debug build, use
 $ DBGFLAGS='-DDBG_JIT -DDBG_BB' make tests/Fib.dbg
 
 `make clean' is needed if you change $DBGFLAGS.
 for all available flags, see `debug.h'.
 for testing with a debug build, use
 $ DBGFLAGS='-DDBG_JIT -DDBG_BB' make tests/Fib.dbg
 
 `make clean' is needed if you change $DBGFLAGS.
 for all available flags, see `debug.h'.
+
+
+for debugging with gdb, modify Mate/MethodPool.hs and make a debug build with at
+least -DDBG_JIT enabled, then use
+$ make tests/Fib.gdb
+and follow the instructions in the source file.
index c3fc8e8466172a3c219f58c16508ca9a90a02e5e..cd0e887209a88be9fbdbc39a696c29faf0d5f59a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -15,7 +15,7 @@ O_STATIC_FILES = $(shell ls $(B_STATIC)/Mate/*.o) $(wildcard $(B_STATIC)/ffi/*.o
 PACKAGES_ := bytestring harpy hs-java plugins
 PACKAGES := $(addprefix -package ,$(PACKAGES_))
 
 PACKAGES_ := bytestring harpy hs-java plugins
 PACKAGES := $(addprefix -package ,$(PACKAGES_))
 
-GHC_OPT := -I. -Wall -O0 -fno-warn-unused-do-bind
+GHC_OPT := -I. -Wall -O0 -fno-warn-unused-do-bind -rtsopts
 GHC_LD := -optl-Xlinker -optl-x
 
 
 GHC_LD := -optl-Xlinker -optl-x
 
 
@@ -58,6 +58,9 @@ mate.static: Mate.hs ffi/trap.c $(HS_FILES) $(HS_BOOT) ffi/native.o $(CLASS_FILE
 %.dbg: %.class mate.dbg
        ./mate.dbg $(basename $<)
 
 %.dbg: %.class mate.dbg
        ./mate.dbg $(basename $<)
 
+%.gdb: %.class mate.dbg
+       gdb -x .gdbcmds -q --args mate.dbg $(basename $<) +RTS -V0 --install-signal-handlers=no
+
 ifeq (${DBGFLAGS},)
 DEBUGFLAGS = -DDBG_JIT -DDBG_MP
 else
 ifeq (${DBGFLAGS},)
 DEBUGFLAGS = -DDBG_JIT -DDBG_MP
 else
index f7038f3b1e1afdaa640d274ba1c5e2c39a4a954c..1403eaea045745436919ce5c90755c0bd283722c 100644 (file)
@@ -146,11 +146,12 @@ compileBB hmap methodinfo = do
   mapM_ (printfJit "%s\n" . showAtt) (snd right)
   printfJit "\n\n"
   -- UNCOMMENT NEXT LINES FOR GDB FUN
   mapM_ (printfJit "%s\n" . showAtt) (snd right)
   printfJit "\n\n"
   -- UNCOMMENT NEXT LINES FOR GDB FUN
-  --if (toString $ methName methodinfo) == "thejavamethodIwant2debug"
-  --  then getLine
-  --  else return "foo"
-  -- (1) start it with `gdb ./mate' and then `run <classfile>'
-  -- (2) on getLine, press ctrl+c
+  -- if (toString $ methName methodinfo) == "thejavamethodIwant2debug"
+  --   then putStrLn "press CTRL+C now for setting a breakpoint. then `c' and ENTER for continue" >> getLine
+  --   else return "foo"
+  -- (1) build a debug build (see HACKING) and execute `make tests/Fib.gdb'
+  --     for example, where the suffix is important
+  -- (2) on getLine, press CTRL+C
   -- (3) `br *0x<addr>'; obtain the address from the disasm above
   -- (4) `cont' and press enter
   return $ fromIntegral $ ptrToIntPtr entry
   -- (3) `br *0x<addr>'; obtain the address from the disasm above
   -- (4) `cont' and press enter
   return $ fromIntegral $ ptrToIntPtr entry