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

Jorn Vernee jvernee at openjdk.org
Mon Jan 15 18:31:24 UTC 2024


On Mon, 15 Jan 2024 17:52:00 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> 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.

Maybe we should bump copyright years as well.

README.md line 185:

> 183: passed to native calls can be printed on the standard output.
> 184: 
> 185: To enable the tracing support, just pass set the `-Djextract.trace.downcalls=true` flag to the launcher used to start the application.

Suggestion:

To enable the tracing support, just pass the `-Djextract.trace.downcalls=true` flag to the launcher used to start the application.

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

Marked as reviewed by jvernee (Committer).

PR Review: https://git.openjdk.org/jextract/pull/176#pullrequestreview-1822101993
PR Review Comment: https://git.openjdk.org/jextract/pull/176#discussion_r1452642746


More information about the jextract-dev mailing list