[squeak-dev] Debugging FFI Calls
eliot.miranda at gmail.com
Mon Aug 27 21:36:28 UTC 2018
the latest VMs support a new facility which catches and reports
exceptions during FFI calls as primitive failures. That means that if you
have the relevant support code loaded (described below) and depending on
dialect, you write your FFI interface method to contain an error code, or
you're using the UnifiedFFI which uses invokeWithArguments:, then any
exception that occurs during the FFI call will be caught and reported to
use with the error code bound to an instance of ExceptionInFFICall, which
contains a platform-specific error code and the pc at which it occurred.
To use this facility you'll need to download a VM built yesterday or later
(it should be derived from VMMaker.oscog-eem.2435 or later), or build your
own from the tip of the Cog branch in opensmalltalk/vm. You'll then need
to update the image code to install ExceptionInFFICall appropriately:
in Pharo6 load SLICE 22367
in Squeak load the latest FFI code from source.squeak.org/FFI and update
your image from trunk
in Cuis, you'll need to adapt these changes to Cuis (sorry!!)
There are two command-line flags to override the default behavior.
[-]-failonffiexception causes the handling to be applied to all FFI calls,
so if a method doesn't contain an error, you'll just see a primitive
failure, and if ExceptionInFFICall is not installed you'll see only an
error number in the call's error code.
[-]-nofailonffiexception ignores exceptions during FFI calls, hence
defaulting to the old behavior of crashing the VM (which may be useful if
one is using a low-level debugger to debug the VM and/or external code).
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Squeak-dev