Skip to content

Debugging

Dave Parker edited this page Apr 22, 2019 · 1 revision

Debugging the C++ parts of PRISM is tricky because it is accessed from Java through JNI. Here are some instructions to do this with lldb on Mac OS X. This assumes you are in the prism subdirectory (where you run make).

  • First, make sure debug symbols have been added to the C++ libraries:
make clean
make DEBUG=-g
  • Take a local copy of the lldb executable (because recent versions of OS X do not allow DYLD_LIBRARY_PATH, which is needed to run PRISM, to be passed to executables in protected locations):
cp /usr/bin/lldb .
  • Run PRISM as follows. This makes the prism executable call Java through ./lldb -- rather than directly.
PRISM_DEBUG=./lldb PRISM_DEBUG_ARG=-- bin/prism mymodel.nm mymodel.props ...
  • Once lldb has been started, type run to start the executable. If you're tracking down a segfault (or similar), the debugger will stop when this happens. You will probably need to type c a few times to skip over some the Java signals. Here's a typical run:
$ PRISM_DEBUG=./lldb PRISM_DEBUG_ARG=-- bin/prism ../prism-examples/dice/dice.pm 
# (lldb) target create "/Library/Java/JavaVirtualMachines/jdk1.8.0_74.jdk/Contents/Home/bin/java"
# Current executable set to '/Library/Java/JavaVirtualMachines/jdk1.8.0_74.jdk/Contents/Home/bin/java' (x86_64).
# (lldb) settings set -- target.run-args  "-d64" "-Xmx1g" "-Xss4M" "-Xdock:icon=/Users/dxp/prism/prism/etc/icons/p64.png" "-Xdock:name=PRISM" "-Djava.awt.headless=true" "-Djava.library.path=/Users/dxp/prism/prism/lib" "-classpath" "/Users/dxp/prism/prism/lib/prism.jar:/Users/dxp/prism/prism/classes:/Users/dxp/prism/prism:/Users/dxp/prism/prism/lib/pepa.zip:/Users/dxp/prism/prism/lib/*" "prism.PrismCL" "../prism-examples/dice/dice.pm"
(lldb) run
# Process 96821 launched: '/Library/Java/JavaVirtualMachines/jdk1.8.0_74.jdk/Contents/Home/bin/java' (x86_64)
# Process 96821 stopped
# * thread #5: tid = 0x3c8e45, 0x00000001048002b4, stop reason = signal SIGSEGV
#     frame #0: 0x00000001048002b4
# ->  0x1048002b4: movl   (%rsi), %eax
#     0x1048002b6: leaq   0xf8(%rbp), %rsi
#     0x1048002bd: vmovdqu %ymm0, (%rsi)
#     0x1048002c1: vmovdqu %ymm7, 0x20(%rsi)
(lldb) c
# Process 96821 resuming
# Process 96821 stopped
# * thread #25: tid = 0x3c8e6d, 0x0000000104a16135, name = 'Java: Image Fetcher 0', stop reason = signal SIGSEGV
#     frame #0: 0x0000000104a16135
# ->  0x104a16135: movl   0xc(%rdx), %r10d
#     0x104a16139: movl   0xc(%r12,%r10,8), %ebx
#     0x104a1613e: movl   0x10(%rsi), %r8d
#     0x104a16142: movl   0xc(%r12,%r8,8), %r11d
(lldb) c
# Process 96821 resuming
# Process 96821 stopped
# * thread #25: tid = 0x3c8e6d, 0x0000000104a090f5, name = 'Java: Image Fetcher 0', stop reason = signal SIGSEGV
#     frame #0: 0x0000000104a090f5
# ->  0x104a090f5: movl   0xc(%rdx), %r10d
#     0x104a090f9: movl   0xc(%r12,%r10,8), %ebx
#     0x104a090fe: movl   0x10(%rsi), %r8d
#     0x104a09102: movl   0xc(%r12,%r8,8), %r11d
(lldb) c
# Process 96821 resuming
# PRISM
# =====
# ...

Clone this wiki locally