Skip to content

Add --trace=plugin=<name> scoped plugin tracing - #1718

Open
Troy Curtiss (tcurtiss) wants to merge 5 commits into
qualcomm:mainfrom
tcurtiss:main_traceplugin
Open

Add --trace=plugin=<name> scoped plugin tracing#1718
Troy Curtiss (tcurtiss) wants to merge 5 commits into
qualcomm:mainfrom
tcurtiss:main_traceplugin

Conversation

@tcurtiss

Copy link
Copy Markdown

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)

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>
Comment thread lib/Script/Plugin.cpp Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should perhaps use Plugin::isTraced() here as well.

Comment thread lib/Script/Plugin.cpp Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use Plugin::isTraced() here as well.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants