Skip to content

Commit 80f7aca

Browse files
[clr-interp] More minimal tweak for enabling debug stack walking (#119129)
- This just enables the StubPrecode::GetMethodDesc api, as well as ExecutionManager::GetCodeMethodDesc - It is enough for !clrstack to work correctly
1 parent 778d54c commit 80f7aca

File tree

3 files changed

+44
-3
lines changed

3 files changed

+44
-3
lines changed

src/coreclr/vm/codeman.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5060,7 +5060,26 @@ MethodDesc * ExecutionManager::GetCodeMethodDesc(PCODE currentPC)
50605060
}
50615061
CONTRACTL_END
50625062

5063-
EECodeInfo codeInfo(currentPC);
5063+
ExecutionManager::ScanFlag scanFlag = ExecutionManager::GetScanFlags();
5064+
#ifdef FEATURE_INTERPRETER
5065+
RangeSection * pRS = ExecutionManager::FindCodeRange(currentPC, scanFlag);
5066+
if (pRS == NULL)
5067+
return NULL;
5068+
5069+
if (pRS->_flags & RangeSection::RANGE_SECTION_RANGELIST)
5070+
{
5071+
if (pRS->_pRangeList->GetCodeBlockKind() == STUB_CODE_BLOCK_STUBPRECODE)
5072+
{
5073+
PTR_StubPrecode pStubPrecode = dac_cast<PTR_StubPrecode>(PCODEToPINSTR(currentPC));
5074+
if (pStubPrecode->GetType() == PRECODE_INTERPRETER)
5075+
{
5076+
return dac_cast<PTR_MethodDesc>(pStubPrecode->GetMethodDesc());
5077+
}
5078+
}
5079+
}
5080+
#endif // FEATURE_INTERPRETER
5081+
5082+
EECodeInfo codeInfo(currentPC, scanFlag);
50645083
if (!codeInfo.IsValid())
50655084
return NULL;
50665085
return codeInfo.GetMethodDesc();

src/coreclr/vm/codeman.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2878,6 +2878,11 @@ class EECodeInfo
28782878
Init(codeAddress);
28792879
}
28802880

2881+
EECodeInfo(PCODE codeAddress, ExecutionManager::ScanFlag scanFlag)
2882+
{
2883+
Init(codeAddress, scanFlag);
2884+
}
2885+
28812886
// Explicit initialization
28822887
void Init(PCODE codeAddress);
28832888
void Init(PCODE codeAddress, ExecutionManager::ScanFlag scanFlag);

src/coreclr/vm/precode.h

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ struct ThisPtrRetBufPrecode;
8484
typedef DPTR(class UMEntryThunk) PTR_UMEntryThunk;
8585
#define PRECODE_UMENTRY_THUNK_VALUE 0x7 // Define the value here and not in UMEntryThunk to avoid circular dependency with the dllimportcallback.h header
8686

87+
#ifdef FEATURE_INTERPRETER
88+
struct InterpreterPrecode;
89+
90+
typedef DPTR(InterpreterPrecode) PTR_InterpreterPrecode;
91+
#endif
92+
8793
// Regular precode
8894
struct StubPrecode
8995
{
@@ -122,6 +128,10 @@ struct StubPrecode
122128
ThisPtrRetBufPrecode* AsThisPtrRetBufPrecode();
123129
#endif // HAS_THISPTR_RETBUF_PRECODE
124130

131+
#ifdef FEATURE_INTERPRETER
132+
PTR_InterpreterPrecode AsInterpreterPrecode();
133+
#endif // FEATURE_INTERPRETER
134+
125135
#ifndef DACCESS_COMPILE
126136
void SetSecretParam(TADDR secretParam)
127137
{
@@ -340,7 +350,13 @@ struct InterpreterPrecode
340350
TADDR GetMethodDesc();
341351
};
342352

343-
typedef DPTR(InterpreterPrecode) PTR_InterpreterPrecode;
353+
inline PTR_InterpreterPrecode StubPrecode::AsInterpreterPrecode()
354+
{
355+
LIMITED_METHOD_CONTRACT;
356+
SUPPORTS_DAC;
357+
358+
return dac_cast<PTR_InterpreterPrecode>(this);
359+
}
344360

345361
#endif // FEATURE_INTERPRETER
346362

@@ -509,10 +525,11 @@ inline TADDR StubPrecode::GetMethodDesc()
509525
case PRECODE_PINVOKE_IMPORT:
510526
return GetSecretParam();
511527

512-
case PRECODE_UMENTRY_THUNK:
513528
#ifdef FEATURE_INTERPRETER
514529
case PRECODE_INTERPRETER:
530+
return AsInterpreterPrecode()->GetMethodDesc();
515531
#endif // FEATURE_INTERPRETER
532+
case PRECODE_UMENTRY_THUNK:
516533
#ifdef FEATURE_STUBPRECODE_DYNAMIC_HELPERS
517534
case PRECODE_DYNAMIC_HELPERS:
518535
#endif // FEATURE_STUBPRECODE_DYNAMIC_HELPERS

0 commit comments

Comments
 (0)