Add --trace=plugin=<name> scoped plugin tracing - #1718
Open
Troy Curtiss (tcurtiss) wants to merge 5 commits into
Open
Add --trace=plugin=<name> scoped plugin tracing#1718Troy Curtiss (tcurtiss) wants to merge 5 commits into
Troy Curtiss (tcurtiss) wants to merge 5 commits into
Conversation
Troy Curtiss (tcurtiss)
requested review from
Parth (parth-07) and
Shankar Easwaran (quic-seaswara)
as code owners
August 17, 2026 07:07
Extend --trace=<category>[=<name>] (mirroring symbol=/section=/reloc=) to plugins, so an individual plugin's diagnostics can be enabled without tracing every plugin. GeneralOptions::tracePlugin() checks an exact-string/regex allowlist populated by the new plugin=<name> case, falling back to "trace everything" for the pre-existing bare --trace=plugin. Plugin::isTraced() wraps this check and replaces every tracePlugins()-gated call site in Plugin.cpp, PluginManager.cpp, and GNULDBackend::RunPluginsAndProcessHelper with per-plugin gating via O->prolog().getPlugin()->isTraced(). (cherry picked from commit b4b7af1) Signed-off-by: Troy Curtiss <trcurtiss@gmail.com>
Troy Curtiss (tcurtiss)
force-pushed
the
main_traceplugin
branch
from
August 19, 2026 04:18
3cb88c2 to
d7cd55a
Compare
Contributor
There was a problem hiding this comment.
We should perhaps use Plugin::isTraced() here as well.
Contributor
There was a problem hiding this comment.
We should use Plugin::isTraced() here as well.
There was a problem hiding this comment.
Added the isTraced() to the plugin load/unload as noted above.
Added a plugin API isTraced() , so that plugins could also gate their tracing information for ALL entrypoints into the linker plugin (e.g. Init/Destroy)
Lastly, added unit tests for everything and ran clang-format on the changes to-date.
Plugin::loadPlugin and Plugin::unload gated their "Loaded/Unloaded Library" diagnostics on DiagnosticPrinter::tracePlugins(), which only checks the coarse --trace=plugin flag and ignores plugin-name scoping. As a result, --trace=plugin=<name> would still print load/unload messages for every plugin library, not just the named one, unlike every other diagnostic in this file which is gated on Plugin::isTraced(). Thread the calling plugin's isTraced() state through loadPlugin/unload (both static methods with no Plugin instance of their own) so these two diagnostics respect the same scoping as the rest of the plugin trace output. Signed-off-by: Troy Curtiss <trcurtiss@gmail.com>
Plugin authors can query --verbose state via LinkerWrapper::isVerbose(), but had no equivalent way to query whether their own plugin is being traced (--trace=plugin or --trace=plugin=<name>) from within most hooks. Only Run(bool Trace) receives trace state as an explicit parameter; every other hook (Init, Destroy, VisitSections, the ActBefore* hooks, etc.) has no visibility into it. Add isTraced(), mirroring isVerbose(), delegating to the owning Plugin::isTraced() so plugins can gate their own diagnostics consistently with the scoping the linker itself already applies. Signed-off-by: Troy Curtiss <trcurtiss@gmail.com>
Covers GeneralOptions::tracePlugin()'s bare vs. scoped --trace=plugin matching (including regex and cumulative scopes) and verifies Plugin::isTraced()/LinkerWrapper::isTraced() delegate to it correctly. Signed-off-by: Troy Curtiss <trcurtiss@gmail.com>
Signed-off-by: Troy Curtiss <trcurtiss@gmail.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.
Extend --trace=[=] (mirroring symbol=/section=/reloc=) to plugins, so an individual plugin's diagnostics can be enabled without tracing every plugin. GeneralOptions::tracePlugin() checks an exact-string/regex allowlist populated by the new plugin= case, falling back to "trace everything" for the pre-existing bare --trace=plugin.
Plugin::isTraced() wraps this check and replaces every tracePlugins()-gated call site in Plugin.cpp, PluginManager.cpp, and GNULDBackend::RunPluginsAndProcessHelper with per-plugin gating via O->prolog().getPlugin()->isTraced().
(cherry picked from commit b4b7af1)