[NativeAOT] Add printf gref logging#12218
Open
jonathanpeppers wants to merge 2 commits into
Open
Conversation
Add an internal printf-style OSBridge path for shared CoreCLR and NativeAOT bridge processing while preserving the existing managed string API and MonoVM behavior. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f05fc3ac-b656-4f49-9b28-4bf39fad49c3
Name the internal printf helper _monodroid_gref_logf to match the surrounding gref logging convention. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f05fc3ac-b656-4f49-9b28-4bf39fad49c3
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an internal printf-style gref logging helper for the shared CoreCLR/NativeAOT GC bridge, and migrates the remaining std::format-based gref messages in bridge-processing.cc to avoid libc++ formatting dependencies while preserving existing gref logging behavior.
Changes:
- Introduce
OSBridge::gref_logf(const char* format, ...)which logs to logcat vialog_writev()and to the gref file viavfprintf(), usingva_copy()for dual-sink consumption. - Replace three
std::formatcall sites insrc/native/clr/host/bridge-processing.ccwithgref_logf()andPRIxPTR-based pointer formatting. - Add
<cinttypes>include to supportPRIxPTR.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/native/clr/include/host/os-bridge.hh | Declares new internal OSBridge::gref_logf() printf-style gref logging API. |
| src/native/clr/host/os-bridge.cc | Implements gref_logf() to write to logcat and the gref file without allocating intermediate strings. |
| src/native/clr/host/bridge-processing.cc | Migrates three gref log messages from std::format to gref_logf() with pointer-width hex output. |
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.
Dependency
Depends on #12211 and targets its
jonathanpeppers-finish-gc-bridge-printfbranch.Part of #12139.
Design
Adds a non-exported printf-style
OSBridge::_monodroid_gref_logf()path for the shared CoreCLR/NativeAOT GC bridge. It formats directly to logcat withlog_writev()and to the gref file withvfprintf(), usingva_copy()so both sinks can consume the arguments without allocating or transferring ownership.The existing exported
_monodroid_gref_log(const char*)entry point, P/Invoke registration, managed callers, and MonoVM implementation remain unchanged.Scope
Migrates only the three intentionally deferred
std::formatcalls insrc/native/clr/host/bridge-processing.ccthat feed the gref file/logcat pipeline.Behavior preservation
Logger::gref_log(),Logger::gref_to_logcat(),LOG_GREF, andgc_spew_enabled()gates and surrounding control flow.0xprefixes withPRIxPTR/uintptr_tso handles retain lowercase pointer-width hexadecimal output, including0x0for null handles.Non-goals
Validation
Prerequisites initialized in the fresh worktree:
dotnet build build-tools\xa-prep-tasks\xa-prep-tasks.csproj -v:minimaldotnet build build-tools\Xamarin.Android.Tools.BootstrapTasks\Xamarin.Android.Tools.BootstrapTasks.csproj -v:minimalgit submodule update --init -- external/libunwindValidation run:
dotnet build src\native\native-nativeaot.csproj -p:AndroidSupportedTargetJitAbis=arm64-v8a -p:AndroidSupportedTargetAotAbis=arm64 -v:minimaldotnet build src\native\native-clr.csproj -p:AndroidSupportedTargetJitAbis=arm64-v8a -p:AndroidSupportedTargetAotAbis=arm64 -v:minimalrg "std::format" src\native\clr\host\bridge-processing.cc(no matches)git diff --checkNo focused existing test target covers this internal
OSBridgeformatting boundary.