Add endpoint option to trace-plugin target property#2589
Open
Add endpoint option to trace-plugin target property#2589
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for configuring an optional trace-plugin endpoint via the trace-plugin target property, so generated C code can pass the endpoint to the runtime trace plugin through an environment variable.
Changes:
- Extend
trace-plugindictionary schema to accept an optionalendpointfield. - Emit
setenv("TRACE_PLUGIN_ENDPOINT", ...)early in generated C entrypoints when an endpoint is configured. - Conditionally include
<stdlib.h>in generated C includes to supportsetenv().
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| core/src/main/java/org/lflang/target/property/TracePluginProperty.java | Adds endpoint to the trace-plugin dictionary spec and AST (de)serialization. |
| core/src/main/java/org/lflang/generator/c/CPreambleGenerator.java | Conditionally includes <stdlib.h> when tracing is enabled and an endpoint is provided. |
| core/src/main/java/org/lflang/generator/c/CMainFunctionGenerator.java | Generates setenv("TRACE_PLUGIN_ENDPOINT", ...) statements in generated main()/setup(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
core/src/main/java/org/lflang/generator/c/CMainFunctionGenerator.java
Outdated
Show resolved
Hide resolved
Use StringUtil.addDoubleQuotes() to properly escape the endpoint value in the generated C string literal, preventing potential code injection. Add #ifdef _WIN32 guard to use _putenv_s on Windows instead of the POSIX-only setenv. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
endpointfield to thetrace-plugintarget propertysetenv("TRACE_PLUGIN_ENDPOINT", "<url>", 1)inmain()beforelf_reactor_c_main(). The environment variable gets read by the trace plugin at runtime, allowing it to stream data to the right destination.Usage
Test plan
endpointspecified, verify the environment variable is set🤖 Generated with Claude Code. Edited with ❤️ by @lsk567.