RFR: 7903627: Add an option to emit tracing calls to generated bindings

Maurizio Cimadamore mcimadamore at openjdk.org
Mon Jan 15 18:31:23 UTC 2024


This PR tweaks the generated code to introduce a `TRACE_DOWNCALL` boolean flag in the generated code. This flag is initialized with the value of the runtime property `jextract.trace.downcalls`, and allows the generated code to print the value of arguments passed to downcalls. This can be useful when debugging.

Note: while generally the output provided is similar to that of `strace`, we have decided not to print the result value for now. That is because to do that, we'd need to first print the argument values (before the native call takes place) and then come back and print the result value (after the native call has returned). But this idiom would lead to messy output when multiple threads are used.

In `strace`, this is handled by buffering output, and only emitting something when the system call returns - but this is not an option here, as the tracing support is mostly intended to be used when diagnosing application crashes, in which case the native call never returns.

-------------

Commit messages:
 - Update README.md
 - Fix whitespaces
 - s/property/flag
 - Add newline
 - Further improve text
 - Improve text
 - Update readme
 - Initial push

Changes: https://git.openjdk.org/jextract/pull/176/files
 Webrev: https://webrevs.openjdk.org/?repo=jextract&pr=176&range=00
  Issue: https://bugs.openjdk.org/browse/CODETOOLS-7903627
  Stats: 66 lines in 3 files changed: 60 ins; 3 del; 3 mod
  Patch: https://git.openjdk.org/jextract/pull/176.diff
  Fetch: git fetch https://git.openjdk.org/jextract.git pull/176/head:pull/176

PR: https://git.openjdk.org/jextract/pull/176


More information about the jextract-dev mailing list