[NativeAOT] Migrate shared GC logging to printf#12210
Conversation
Convert the remaining std::format-style GC bridge and logger diagnostics compiled into the NativeAOT host to the canonical printf logging helpers. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 13af6b96-9e20-422c-b3ba-8cba7f1aa5bb
There was a problem hiding this comment.
Pull request overview
This PR continues the NativeAOT printf-style logging migration by converting remaining std::format-style formatted diagnostics in NativeAOT-reachable shared sources (GC bridge paths and reference-log setup) to the log_*f() printf helpers, while preserving existing category gating and null-safe string handling.
Changes:
- Converted GC bridge diagnostics in
bridge-processing.cctolog_*f()with%zuforsize_tand%sviaoptional_string()for nullable class names. - Converted reference-log file open and invalid-path diagnostics in
logger.cctolog_*f()using bounded%.*sformatting forstd::string_view.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/native/clr/runtime-base/logger.cc |
Migrates reference-log file path diagnostics from {} formatting to bounded printf-style logging. |
src/native/clr/host/bridge-processing.cc |
Migrates GC bridge temporary-peer/local-capacity and GC cleanup summary diagnostics to printf-style logging. |
Return static segment error messages as C strings so printf logging can consume them directly without a string_view. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 13af6b96-9e20-422c-b3ba-8cba7f1aa5bb
|
/review |
|
✅ Android PR Reviewer completed successfully! |
There was a problem hiding this comment.
✅ LGTM
Clean, well-scoped continuation of the printf-style native logging migration. I verified the changes independently against the full source before reading the description.
Verification highlights:
bridge-processing.cc—map_capacity,total, andaliveare allsize_t(lines 15, 580–581), so%zuis the correct specifier.optional_string(class_name)returnsconst char*, matching%s. Debug-only gating (#if ...) around the missing-method diagnostics is preserved.logger.cc—pathandfile_kindarestd::string_view; the%.*s+static_cast<int>(len)+.data()pattern is the correct way to print a non-null-terminated view.to_string(file_name.error())now yieldsconst char*, matching%s.strings.hh—to_string(string_segment_error)return-type change fromstd::string_viewtoconst char*has exactly one caller (logger.cc:201), which is updated correctly. No other consumers depend on the oldstring_viewreturn.- All
log_*foverloads used exist inshared/log_functions.hhwith__attribute__((format(printf,...))), so the compiler validates the format strings — mismatches would fail the build. - Message text, categories, punctuation, and control flow are unchanged, as claimed.
CI: dotnet-android completed neutral (not a failure); license/cla passed. No PR-caused failures.
Counts: 0 ❌ · 0 constexpr on to_string). Nice, mechanically-faithful migration.
Generated by Android PR Reviewer for #12210 · 65.9 AIC · ⌖ 12.8 AIC · ⊞ 6.8K
Comment /review to run again
Express the static string-segment error mapping as a compile-time function now that it returns string literals. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 13af6b96-9e20-422c-b3ba-8cba7f1aa5bb
Summary
Continue the printf-style native logging migration by converting the remaining formatted diagnostics in the shared GC bridge and logger setup paths compiled into the NativeAOT host.
Base/dependency: This PR depends on #12148 and targets
dev/simonrozsival/nativeaot-runtime-printf-loggingso the review diff remains limited to this batch. It reuses the canonical shared printf declarations established by #12155.Part of #12139.
Scope
bridge-processing.cc;logger.cc;%slogging;std::format-style logging instantiations from NativeAOT-reachable shared sources.Behavior preservation
size_tvalues use%zu;optional_string();%.*soutput;%swithout an intermediatestd::string_view;Non-goals
std::formatstrings passed toOSBridge::_monodroid_gref_log; those feed a separate file/log pipeline and require a dedicated API design.Validation
dotnet-local.cmd build src\native\native-nativeaot.csproj -p:AndroidSupportedTargetJitAbis=arm64-v8adotnet-local.cmd build src\native\native-clr.csproj -p:AndroidSupportedTargetJitAbis=arm64-v8agit diff --check