Skip to content

[native] Remove unused debugger, netlink, and bundle logging - #13001

Merged
simonrozsival merged 3 commits into
mainfrom
simonrozsival-remove-debugger-logging
Oct 5, 2026
Merged

simonrozsival merged 3 commits into
mainfrom
simonrozsival-remove-debugger-logging

Conversation

@simonrozsival

@simonrozsival simonrozsival commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

The debugger, netlink, and bundle runtime logging categories have no native logging call sites or managed consumers. debug.dotnet.log still accepts the first two, and the documentation advertises messages they cannot produce; bundle is already absent from the parser but retains unused infrastructure.

Remove the debugger and netlink tokens from the parser shared by the CoreCLR and NativeAOT hosts, all three internal managed enum entries and unused getters, native enum entries and log-tag constants, and stale documentation references. No bundle parser or documentation change is needed because neither advertises that category in the main-based checkout. This PR targets main and contains no JNI reference tracing migration or native startup-cleanup stack changes.

Bits 2 (debugger), 7 (bundle), and 9 (netlink) remain reserved in both enums. Category-name table indexes 3, 8, and 10 remain explicitly reserved as *none*. Every other native/managed category value and category-name index, including the error slot, is unchanged. Active categories, actual application bundle/assembly-store/packaging and OS networking/netlink functionality, debugger support, diagnostic ports, and deployment/build targets are untouched.

Validation (rerun after adding the bundle removal):

  • Passed: NDK Clang C++23 syntax checks of the actual shared parser and log implementation for arm64-v8a, armeabi-v7a, x86_64, and x86, using the NativeAOT compile definition:
    set -e
    for target in aarch64-linux-android24 armv7a-linux-androideabi24 x86_64-linux-android24 i686-linux-android24; do
      /Users/simon/android-toolchain/ndk/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target="$target" -std=c++23 -fsyntax-only -DXA_HOST_NATIVEAOT -Isrc/native/nativeaot/include -Isrc/native/clr/include -Isrc/native/common/include -Iexternal/Java.Interop/src/java-interop src/native/clr/runtime-base/logger.cc src/native/clr/shared/log_functions.cc
      printf 'PASS: shared logger syntax for %s\n' "$target"
    done
    All four targets passed without compiler diagnostics. These are shared-source syntax checks, not a complete CoreCLR or SDK build.
  • Passed: focused source audit against the branch's main-based baseline: remaining native/managed enum values and log-tag strings/indexes are unchanged; bits 2/7/9 and indexes 3/8/10 are reserved without shifting the error slot; parser changes only remove debugger/netlink, and bundle was never a token in this checkout; only the three unused getters are removed; repository-wide search finds no removed-category constants/getters/parser tokens/docs. Active parser tokens and network documentation remain.
  • Passed: git diff --check before committing and git diff --check origin/main...HEAD after committing.
  • Not run: full SDK builds and on-device suites; there is no locally built Android SDK in this checkout. No new test framework or helper-only tests were added for these unused-category removals.
  • No associated issue.
Exact source-audit command (passed all four checks)
python3 - <<'PY'
from pathlib import Path
import re
import subprocess

base = subprocess.check_output(['git', 'merge-base', 'HEAD', 'origin/main'], text=True).strip()
def read(path, original=False):
    return subprocess.check_output(['git', 'show', f'{base}:{path}'], text=True) if original else Path(path).read_text()
def values(text):
    return {name: 0 if shift is None else 1 << int(shift) for name, shift in
            ((m[1], m[2]) for m in re.finditer(r'^\s*(\w+)\s*=\s*(?:0|1\s*<<\s*(\d+))\s*,', text, re.M))}
for path, removed in [('external/Java.Interop/src/java-interop/java-interop-logger.h', ['LOG_DEBUGGER', 'LOG_BUNDLE', 'LOG_NETLINK']),
                      ('src/Mono.Android/Android.Runtime/LogCategories.cs', ['Debugger', 'Bundle', 'Netlink'])]:
    expected = values(read(path, True))
    assert [expected.pop(name) for name in removed] == [4, 128, 512]
    assert values(read(path)) == expected
    assert all(f'Bit {bit} is reserved' in read(path) for bit in [2, 7, 9])
print('PASS: remaining native/managed enum values are unchanged; bits 2, 7, and 9 are reserved')
path = 'src/native/clr/shared/log_functions.cc'
constants_path = 'src/native/clr/include/constants.hh'
def names(original=False):
    table = re.search(r'log_names\s*=\s*\{(.*?)\};', read(path, original), re.S)[1]
    definitions = dict(re.findall(r'(LOG_CATEGORY_NAME_\w+)\s*\{\s*"([^"]+)"\s*\}', read(constants_path, original)))
    return [definitions[name] for name in re.findall(r'Constants::(LOG_CATEGORY_NAME_\w+)', table)]
expected = names(True)
assert len(expected) == 12
for index in [3, 8, 10]:
    expected[index] = '*none*'
assert names() == expected
assert expected[11] == '*error*'
assert read(path).count('Reserved for the removed') == 3
print('PASS: name indexes 3, 8, and 10 are reserved; all other tags and error index remain unchanged')
path = 'src/native/clr/runtime-base/logger.cc'
def tokens(original=False):
    return re.findall(r'set_category \("([^"]+)",\s*param,\s*param_length,\s*(LOG_\w+)', read(path, original))
assert tokens() == [pair for pair in tokens(True) if pair[0] not in ['debugger', 'netlink']]
assert not any(pair[0] == 'bundle' for pair in tokens(True))
assert ('network', 'LOG_NET') in tokens()
assert read(path) == subprocess.check_output(['git', 'show', f'HEAD:{path}'], text=True)
for path in ['src/native/clr/runtime-base/CMakeLists.txt', 'src/native/nativeaot/host/CMakeLists.txt']:
    assert 'logger.cc' in read(path)
print('PASS: bundle was never a parser token; parser unchanged by this extension and active categories remain')
path = 'src/Mono.Android/Android.Runtime/Logger.cs'
def getters(original=False):
    return re.findall(r'internal static bool (Log\w+)', read(path, original))
assert getters() == [name for name in getters(True) if name not in ['LogDebugger', 'LogBundle', 'LogNetlink']]
pattern = r'LOG_(DEBUGGER|BUNDLE|NETLINK)|Log(Debugger|Bundle|Netlink)|LogCategories\.(Debugger|Bundle|Netlink)|LOG_CATEGORY_NAME_MONODROID_(DEBUG|BUNDLE|NETLINK)|monodroid-(debug|bundle|netlink)([^[:alnum:]-]|$)|set_category \("(debugger|bundle|netlink)"|debug\.dotnet\.log.*(debugger|bundle|netlink)|^\* `(debugger|bundle|netlink)`'
result = subprocess.run(['git', 'grep', '-n', '-E', pattern, '--', '.'], capture_output=True, text=True)
assert result.returncode == 1, result.stdout + result.stderr
assert '* `network` logs native network activity.' in read('Documentation/workflow/SystemProperties.md')
print('PASS: no removed category constants/getters/parser tokens/docs remain; network docs remain')
PY

Pull Request
title and
description
should follow the
commit-messages.md workflow documentation, and in particular should include:

  • Useful description of why the change is necessary.
  • Links to issues fixed
  • Unit tests

The debugger runtime logging category has no native logging call sites
or managed consumers.  Remove its parser token, internal category
entries, unused getter, native log tag, and documentation examples.

Reserve bit 2 and its category-name table position so all remaining
native and managed logging category values and indexes stay unchanged.
Actual debugger support and runtime diagnostics are unaffected.

Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 5, 2026 07:54

Copilot AI left a comment

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.

Copilot review overview

🟢 Approval recommended

The removal is complete, preserves enum and tag-table compatibility, and leaves no remaining category references.

Review effort: Balanced
Findings: None

What changed in this PR

Removes the unused debugger logging category while preserving logging bit values and tag indexes.

Changes:

  • Removes debugger parsing, enum members, constants, and managed accessors.
  • Reserves bit 2 and the corresponding native log-name index.
  • Updates logging documentation and examples.
File Description
src/​native/​clr/​shared/​log_functions.cc Preserves the removed category’s tag-table slot.
src/​native/​clr/​runtime-base/​logger.cc Stops accepting the debugger category.
src/​native/​clr/​include/​constants.hh Removes the unused debugger log tag.
src/​Mono.Android/​Android.Runtime/​Logger.cs Removes the unused managed getter.
src/​Mono.Android/​Android.Runtime/​LogCategories.cs Reserves bit 2 while preserving later values.
external/​Java.Interop/​src/​java-interop/​java-interop-logger.h Mirrors the managed enum layout.
Documentation/​workflow/​SystemProperties.md Removes the unsupported category documentation.
Documentation/​workflow/​DevelopmentTips.md Updates the logging example.

@simonrozsival simonrozsival added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Oct 5, 2026
@simonrozsival

Copy link
Copy Markdown
Member Author

@dalexsoto review

@simonrozsival
simonrozsival enabled auto-merge (squash) October 5, 2026 08:05
The netlink logging category has no remaining log call sites or managed
consumers.  Remove its parser token, internal category entries, unused
getter, native log tag, and documentation alongside debugger logging.

Reserve bit 9 and its category-name table position to preserve the other
native and managed category values and indexes.  Keep the separate
network category and actual OS networking functionality unchanged.

Co-authored-by: Copilot App <[email protected]>
@simonrozsival simonrozsival changed the title [native] Remove unused debugger logging category [native] Remove unused debugger and netlink logging categories Oct 5, 2026
The bundle logging category has no log call sites or managed consumers,
and the shared host parser already does not accept it.  Remove its
native and managed enum entries, unused getter, and native log tag.

Reserve bit 7 and its category-name table position to preserve all other
category values and indexes, including the existing debugger/netlink
reservations.  Application bundles, assembly stores, and packaging are
unaffected.

Co-authored-by: Copilot App <[email protected]>
@simonrozsival simonrozsival changed the title [native] Remove unused debugger and netlink logging categories [native] Remove unused debugger, netlink, and bundle logging Oct 5, 2026

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The unused debugger, bundle, and netlink logging infrastructure is removed without shifting retained masks or tag indexes. Bits 2/7/9 and tag slots 3/8/10 remain reserved, error slot 11 is preserved, and both runtime build/startup paths still reach the shared implementation. The complete eight-file/nine-hunk static review and consumer closure found no remaining high-confidence blocker; network/reference logging, real packaging/assembly stores, OS netlink, debugging and diagnostics remain intact.

The failed MAUI arm64 Full-R2R check was traced to Android package installation (INSTALL_FAILED_INSUFFICIENT_STORAGE / no valid UID) before application or runtime execution, not a logging-source failure. No local build, test or device execution is claimed.

@simonrozsival
simonrozsival merged commit 84bbfae into main Oct 5, 2026
44 checks passed
@simonrozsival
simonrozsival deleted the simonrozsival-remove-debugger-logging branch October 5, 2026 16:00
simonrozsival added a commit that referenced this pull request Oct 7, 2026
The JNI reference logging migration in [#13002](#13002) leaves the native `Logger` class wrapping only startup category parsing. Move that C++ parsing into `HostCommon::init_logging_categories()` in the existing shared host source, inline exact token comparisons directly in initialization, and delete the obsolete wrapper header/source and category helper.

Keep category selection before environment setup and early native diagnostics in both hosts. CoreCLR retains the original call position before assembly-store discovery and `coreclr_initialize`. NativeAOT preserves the current bootstrap: validate the Java VM, obtain the JNI environment and initialize `AppSystemProperties` first, then select logging categories and initialize the host environment. String-view comparisons preserve exact matching, unknown/empty-token behavior and `all` without allocations or modifying property data. No managed parser is introduced.

Replace stale header dependencies with the declarations actually used, remove obsolete CMake source entries, and update NativeAOT MSBuild incremental inputs to track the shared initializer and header while retaining the new NativeAOT runtime-base input glob.

This is the upper layer of native stack 13021, with complete ordered membership [#13002](#13002), [#13003](#13003), targeting `simonrozsival-jni-reference-tracing`, not `main`. No issue is closed. Stack metadata and the lower branch were not modified.

Rebased only the upper cleanup commits from their verified historical lower fork `a125f69b6b52c9bf25128cb1c7094c029a0dbde8` onto the verified new lower head `dd94f74548437df80c6e2291b9b5db4a94a5dde0`, based on current `main` at `1089999735d3565e96cb9b443fdf04387e165350`. Old lower merge history is not retained in the upper-only range. Preserve `main`'s legacy typemap deletions and the now-merged unused debugger/netlink/bundle cleanup from [#13001](#13001): the relocated parser does not reintroduce removed tokens or category declarations. The upper-only diff contains 18 native files (62 insertions, 79 deletions) and no managed/test changes relative to the updated lower layer.
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants