@@ -53,6 +53,7 @@ void *SymbolReader::coreclrLib;
53
53
ResolveSequencePointDelegate SymbolReader::resolveSequencePointDelegate;
54
54
LoadSymbolsForModuleDelegate SymbolReader::loadSymbolsForModuleDelegate;
55
55
GetLocalVariableName SymbolReader::getLocalVariableNameDelegate;
56
+ GetLineByILOffsetDelegate SymbolReader::getLineByILOffsetDelegate;
56
57
#endif // !FEATURE_PAL
57
58
58
59
const char * const CorElementTypeName[ELEMENT_TYPE_MAX]=
@@ -5579,8 +5580,6 @@ NoOutputHolder::~NoOutputHolder()
5579
5580
// Code to support mapping RVAs to managed code line numbers.
5580
5581
//
5581
5582
5582
- #ifndef FEATURE_PAL
5583
-
5584
5583
//
5585
5584
// This function retrieves ImageInfo related to the module
5586
5585
// containing the addressed passed in "Base".
@@ -5715,8 +5714,10 @@ GetMethodInstanceTokenAndScope(
5715
5714
{
5716
5715
return Status;
5717
5716
}
5717
+ #ifndef FEATURE_PAL
5718
5718
5719
5719
Status = FindClrModuleImage (Module, Image);
5720
+ #endif // FEATURE_PAL
5720
5721
5721
5722
Module->Release ();
5722
5723
return Status;
@@ -5852,8 +5853,6 @@ ConvertNativeToIlOffset(
5852
5853
return Status;
5853
5854
}
5854
5855
5855
- #endif // FEATURE_PAL
5856
-
5857
5856
// Based on a native offset, passed in the first argument this function
5858
5857
// identifies the corresponding source file name and line number.
5859
5858
HRESULT
@@ -5866,7 +5865,6 @@ GetLineByOffset(
5866
5865
HRESULT hr = S_OK;
5867
5866
ULONG64 displacement = 0 ;
5868
5867
5869
- #ifndef FEATURE_PAL
5870
5868
// first let's try it the hard way, this will work with the public debuggers
5871
5869
{
5872
5870
ImageInfo Image = {0 };
@@ -5875,12 +5873,14 @@ GetLineByOffset(
5875
5873
ULONG32 MethodOffs;
5876
5874
ULONG64 IlOffset;
5877
5875
5876
+ #ifndef FEATURE_PAL
5878
5877
ToRelease<IDebugSymbols3> spSym3 (NULL );
5879
5878
if (FAILED (g_ExtSymbols->QueryInterface (__uuidof (IDebugSymbols3), (void **)&spSym3)))
5880
5879
{
5881
5880
hr = E_FAIL;
5882
5881
goto fallback;
5883
5882
}
5883
+ #endif // !FEATURE_PAL
5884
5884
5885
5885
// find the image, method token and IL offset that correspond
5886
5886
// to "Offset"
@@ -5889,6 +5889,8 @@ GetLineByOffset(
5889
5889
{
5890
5890
goto fallback;
5891
5891
}
5892
+
5893
+ #ifndef FEATURE_PAL
5892
5894
modBase = Image.modBase ;
5893
5895
DEBUG_MODULE_AND_ID id;
5894
5896
DEBUG_SYMBOL_ENTRY symInfo;
@@ -5900,7 +5902,11 @@ GetLineByOffset(
5900
5902
}
5901
5903
5902
5904
IlOffset = symInfo.Offset + MethodOffs;
5903
-
5905
+ #else
5906
+ // Source lines with 0xFEEFEE markers are filtered out on the managed side.
5907
+ const String &moduleName = ModuleNameFromIP (TO_CDADDR (Offset));
5908
+ return SymbolReader::GetLineByILOffset (moduleName.c_str (), MethodToken, MethodOffs, pLinenum, lpszFileName, cbFileName);
5909
+ #endif // !FEATURE_PAL
5904
5910
//
5905
5911
// Source maps for managed code can end
5906
5912
// up with special 0xFEEFEE markers that
@@ -5936,7 +5942,6 @@ GetLineByOffset(
5936
5942
}
5937
5943
5938
5944
fallback:
5939
- #endif // FEATURE_PAL
5940
5945
return g_ExtSymbols->GetLineByOffset (
5941
5946
Offset,
5942
5947
pLinenum,
@@ -6291,6 +6296,44 @@ HRESULT SymbolReader::LoadCoreCLR()
6291
6296
IfFailRet (CreateDelegate (hostHandle, domainId, SymbolReaderDllName,
6292
6297
SymbolReaderClassName, " GetLocalVariableName" ,
6293
6298
(void **)&getLocalVariableNameDelegate));
6299
+ IfFailRet (CreateDelegate (hostHandle, domainId, SymbolReaderDllName,
6300
+ SymbolReaderClassName, " GetLineByILOffset" ,
6301
+ (void **)&getLineByILOffsetDelegate));
6302
+ return Status;
6303
+ }
6304
+ HRESULT SymbolReader::GetLineByILOffset (__in_z const char * szModuleName, mdMethodDef MethodToken,
6305
+ ULONG64 IlOffset, ___out ULONG *pLinenum,
6306
+ __out_ecount (cbFileName) LPSTR lpszFileName,
6307
+ ___in ULONG cbFileName)
6308
+ {
6309
+ HRESULT Status = S_OK;
6310
+
6311
+ if (getLineByILOffsetDelegate == nullptr )
6312
+ {
6313
+ Status = SymbolReader::LoadCoreCLR ();
6314
+ }
6315
+ if (Status != S_OK)
6316
+ {
6317
+ return Status;
6318
+ }
6319
+ BSTR wszFileName = SysAllocStringLen (0 , cbFileName);
6320
+ if (wszFileName == nullptr )
6321
+ {
6322
+ return E_OUTOFMEMORY;
6323
+ }
6324
+ if (SUCCEEDED (getLineByILOffsetDelegate (szModuleName, MethodToken, IlOffset, pLinenum, &wszFileName)))
6325
+ {
6326
+ WideCharToMultiByte (CP_ACP, 0 , wszFileName, (int ) (_wcslen (wszFileName) + 1 ),
6327
+ lpszFileName, cbFileName, NULL , NULL );
6328
+ if (*pLinenum == 0 )
6329
+ {
6330
+ *pLinenum = -1 ;
6331
+ Status = E_FAIL;
6332
+ }
6333
+
6334
+ }
6335
+ SysFreeString (wszFileName);
6336
+
6294
6337
return Status;
6295
6338
}
6296
6339
#endif // FEATURE_PAL
@@ -6674,6 +6717,30 @@ WString GetFrameFromAddress(TADDR frameAddr, IXCLRDataStackWalk *pStackWalk, BOO
6674
6717
return frameOutput;
6675
6718
}
6676
6719
6720
+ String ModuleNameFromIP (CLRDATA_ADDRESS ip)
6721
+ {
6722
+ CLRDATA_ADDRESS mdesc = 0 ;
6723
+ if (SUCCEEDED (g_sos->GetMethodDescPtrFromIP (ip, &mdesc)))
6724
+ {
6725
+ DacpMethodDescData mdescData;
6726
+ DacpModuleData moduleData;
6727
+ if (SUCCEEDED (mdescData.Request (g_sos, mdesc)))
6728
+ {
6729
+ if (SUCCEEDED (moduleData.Request (g_sos, mdescData.ModulePtr )))
6730
+ {
6731
+ ArrayHolder<WCHAR> wszModuleName = new WCHAR[MAX_LONGPATH+1 ];
6732
+ if (SUCCEEDED (g_sos->GetPEFileName (moduleData.File , MAX_LONGPATH, wszModuleName, NULL )))
6733
+ {
6734
+ ArrayHolder<char > szModuleName = new char [MAX_LONGPATH+1 ];
6735
+ WideCharToMultiByte (CP_ACP, 0 , wszModuleName, (int ) (_wcslen (wszModuleName) + 1 ), szModuleName, mdNameLen, NULL , NULL );
6736
+ return szModuleName.GetPtr ();
6737
+ }
6738
+ }
6739
+ }
6740
+ }
6741
+ return " " ;
6742
+ }
6743
+
6677
6744
WString MethodNameFromIP (CLRDATA_ADDRESS ip, BOOL bSuppressLines, BOOL bAssemblyName, BOOL bDisplacement)
6678
6745
{
6679
6746
ULONG linenum;
0 commit comments