Repository navigation
Fix TryGetSymbol on iOS, tvOS and Mac Catalyst - #136361
Merged
Merged
Conversation
dotnet#135734 only compiles the Mach-O/ELF symbol readers in dbgutil under HOST_OSX. Apple mobile hosts define HOST_APPLE but not HOST_OSX, so TryGetSymbol always returns false there. The DAC can't find its data table (CreateDacDbiInterface fails with CORDBG_E_MISSING_DEBUGGER_EXPORTS), and the cDAC can't find DotNetRuntimeContractDescriptor. In-app debugging silently never attaches. Use HOST_APPLE for the reader guards and for the inc/llvm include directory. Validated on iossimulator-arm64: Debugger.Break stops and stepping works again. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 4 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
thaystg
approved these changes
Oct 23, 2026
steveisok
enabled auto-merge (squash)
October 23, 2026 19:14
Member
Author
|
/ba-g Unrelated known issues |
steveisok
added a commit
that referenced
this pull request
Oct 23, 2026
…rames (#136362) Independent of #136361 in code, but end-to-end testing on iOS needs #136361, otherwise in-app debugging never attaches. ## Summary With the cDAC as the in-app `IDacDbiInterface` on CoreCLR iOS, where Debug app code runs on the interpreter, the debugger never reported `Debugger.Break`. Two cDAC divergences from the native DAC cause this, one per commit. ### 1. Map entry point to code start when finding a native code version `CodeVersions_1.GetSpecificNativeCodeVersion` compared the MethodDesc native code slot with the code-block start. For interpreted methods the slot holds an `InterpreterPrecode` and the code block starts at the bytecode, so the two never matched. - `GetNativeCodeVersionForIP` returned an invalid handle. - `DebugInfo_1.GetMethodVarInfo` threw "No NativeCodeVersion found for native code …" (`0x80131509`). - `GetNativeCodeSequencePointsAndVarInfo` failed, the DBI abandoned the frame, and the stop was dropped. The fix maps the default and explicit versions' native code through `IExecutionManager.GetDiagnosticCodeStartFromEntryPoint` before comparing. That's the helper #135430 added for `GetMethodVarInfo`; it covers interpreter precodes and portable entry points. It matches the native DAC's `GetInterpreterCodeFromEntryPointIfPresent(NativeCodeVersion::GetNativeCode())` pattern. #135430 alone isn't enough, because the throw happens before its offset mapping. Tests and docs: - `CodeVersionsTests.GetNativeCodeVersion_Interpreted_MapsPrecodeToBytecode` (4 architectures). - The mock `AddCodeBlock` gets a default identity `GetDiagnosticCodeStartFromEntryPoint`. - `CodeVersions.md` pseudo-code updated. ### 2. Compute caller SP for interpreted frames like the native code manager `StackWalk_1.CallerStackPointer` backs `GetRuntimeFramePointer` on caller-SP architectures such as ARM64, and `GetFuncletRootId` (`fpParentOrSelf`). It always ran the OS unwinder, which has no unwind info for bytecode, so `fp`/`fpParentOrSelf` came back as the frame's own SP. For interpreter code it now uses the new `FrameHelpers.InterpreterCallerStackPointer`, which returns: - the parent `InterpMethodContextFrame`, including the zeroed root frame (`ip == NULL`) of an interpreter activation, or - the owning `InterpreterFrame` when there is no parent. This is the SP that native `VirtualUnwindInterpreterCallFrame` (eetwain.cpp) gives the caller context. The walker's own unwind path (`Next`) is unchanged. Tests and docs: - `StackWalkTests.CallerStackPointer_InterpretedFrame_IsParentInterpMethodContextFrame` and `StackWalkTests.CallerStackPointer_InterpretedFrameWithRootParent_IsRootFrameAddress`. - `StackWalk.md` updated. ## Validation - Unit tests (`Microsoft.Diagnostics.DataContractReader.Tests`): - **3,406/3,406** pass after commit 1, and **3,408/3,408** after commit 2. - Each new test fails without its own commit's product change and passes with it. - `Microsoft.Diagnostics.DataContractReader.Usage.Tests`: 4/4 after each commit. - **iOS Simulator** (iossimulator-arm64, interpreted Debug app, VS Code .NET MAUI F5 flow, `DOTNET_ENABLE_CDAC=1`, with #136361 applied): - `Debugger.Break` stops, and stepping, Locals and caller inspection all work. - A diagnosis-only trace compared each cDAC result with the legacy DAC for the same calls during the whole workflow: - `GetNativeCodeSequencePointsAndVarInfo`: **8/8 calls match** in HRESULT, variable count and sequence-point count; - `GetStackWalkCurrentFrameInfo`: **0 mismatches in 975 compared frame fields** (including `fp`, `fpParentOrSelf`, method token and MethodDesc, native start and offset, and context) across 288 frames, covering every frame token in the session. - Without these commits, the same scenario never reports `Debugger.Break`. --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.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.
Summary
#135734 ("Make TryGetSymbol cross-os") moved
TryGetSymbolintosrc/coreclr/debug/dbgutil/symbol.cpp. The new dispatcher and the Mach-O and ELFreaders are compiled only under
and
dbgutil/CMakeLists.txtadds the in-treeinc/llvminclude directory(for
ELF.h) only forCLR_CMAKE_HOST_WIN32 OR CLR_CMAKE_HOST_OSX.Apple mobile hosts (iOS, tvOS, Mac Catalyst) define
HOST_APPLE, plusHOST_IOS,HOST_TVOSorHOST_MACCATALYST, but notHOST_OSX(
eng/native/configurecompiler.cmake). On those hostsTryGetSymbolcompilesto
return false. Before #135734,machoreader.cpp(withTryGetSymbol) wasbuilt for every
CLR_CMAKE_TARGET_APPLE.Consequences for in-app debugging on Apple mobile, where the DBI and DAC run in
the app process:
GetDacTableAddresscan't find the DAC table export.CordbProcess::Init→CreateDacDbiInterfacefails withCORDBG_E_MISSING_DEBUGGER_EXPORTS(0x80131C4F), soDebugActiveProcessfails and no debugger events are ever raised.Debugger.Break()is a no-op, and the debugger UI shows nothing. The HRESULTisn't surfaced to the user by the IDE.
DotNetRuntimeContractDescriptor(
di/process.cpp,daccess.cpp,enummem.cpp) also fail, so the cDAC can'tbe located either.
Change
Use
HOST_APPLEinstead ofHOST_OSX:symbol.cpp(×2),machoreader.cpp,elfreader.cpp;inc/llvminclude directory indbgutil/CMakeLists.txt. Withoutit,
elfreader.h's#include <ELF.h>(already chosen forHOST_APPLE)fails to compile once the guards are widened.
5 lines across 4 files; no behavior change for Windows, Linux or macOS hosts.
Alternative for reviewers: a broader guard such as
!defined(HOST_WASM) && (defined(HOST_WINDOWS) || defined(HOST_UNIX))would alsocover non-Linux Unix hosts (for example FreeBSD and Haiku), which today also hit
the
return falsefallback for the contract-descriptor lookup. That would needthe include directory and
elfreader.h's<ELF.h>vs<elf.h>selectionchecked for those hosts. This PR keeps the minimal Apple-only change.
Validation
./build.sh clr+clr.runtime+libs+packs -os iossimulator -arch arm64 -cross -c Release,with
-cmakeargs "-DCMAKE_CXX_FLAGS=-Wno-error=#warnings". That argument isan unrelated local workaround for Xcode 27's libc++
#warningabout the13.0 minimum under main's
-Werror.TryGetMachOSymbol)..NET MAUI F5 flow, remote debugger host and target) stops at
Debugger.Breakand steps again. Before the fix, the attach failedsilently, with
0x80131C4FfromCordbProcess::Initconfirmed by lldb onthe in-app DBI.