diff --git a/src/SOS/SOS.UnitTests/Scripts/SimpleThrow.script b/src/SOS/SOS.UnitTests/Scripts/SimpleThrow.script index 278a45f3da..c2bf379c88 100644 --- a/src/SOS/SOS.UnitTests/Scripts/SimpleThrow.script +++ b/src/SOS/SOS.UnitTests/Scripts/SimpleThrow.script @@ -33,6 +33,18 @@ VERIFY:\s+\s+\s+[Ss]imple[Tt]hrow.*!(\$0_)?UserObject\.UseObject VERIFY:\s+\s+\s+[Ss]imple[Tt]hrow.*!(\$0_)?Simple\.Main.*\+0x\s+ VERIFY:HResult:\s+80131509 +SOSCOMMAND:PrintException -lines +VERIFY:Exception object:\s+\s+ +VERIFY:Exception type:\s+System\.InvalidOperationException\s+ +VERIFY:Message:\s+(|Throwing an invalid operation\.\.\.\.)\s+ +VERIFY:InnerException:\s+\s+ +VERIFY:StackTrace\s+\(generated\):\s+ +VERIFY:\s+SP\s+IP\s+Function\s+ +VERIFY:\s+\s+\s+[Ss]imple[Tt]hrow.*!(\$0_)?UserObject\.UseObject.*\+0x\s* +VERIFY:\[.*[\\|/]Debuggees[\\|/](dotnet.+[\\|/])?SimpleThrow[\\|/]UserObject\.cs @ 16\s*\]\s* +VERIFY:\s+\s+\s+[Ss]imple[Tt]hrow.*!(\$0_)?Simple\.Main.*\+0x\s+ +VERIFY:\[.*[\\|/]Debuggees[\\|/](dotnet.+[\\|/])?SimpleThrow[\\|/]SimpleThrow\.cs @ 9\s*\]\s* + # Verify that Threads (clrthreads) works IFDEF:DOTNETDUMP SOSCOMMAND:clrthreads @@ -54,6 +66,6 @@ SOSCOMMAND:ClrStack VERIFY:.*OS Thread Id:\s+0x\s+.* VERIFY:\s+Child\s+SP\s+IP\s+Call Site\s+ VERIFY:\s+\s+\s+(\*\*\* WARNING: Unable to verify checksum for SimpleThrow.exe\s*)?UserObject\.UseObject.*\s+ -VERIFY:[.*[\\|/]Debuggees[\\|/](dotnet.+[\\|/])?SimpleThrow[\\|/]UserObject\.cs @ 18\s*\] +VERIFY:[.*[\\|/]Debuggees[\\|/](dotnet.+[\\|/])?SimpleThrow[\\|/]UserObject\.cs @ 16\s*\] VERIFY:\s+\s+\s+Simple\.Main\(\)\s+ VERIFY:[.*[\\|/]Debuggees[\\|/](dotnet.+[\\|/])?SimpleThrow[\\|/]SimpleThrow\.cs @ 9\s*\] diff --git a/src/SOS/Strike/runtime.cpp b/src/SOS/Strike/runtime.cpp index cafe21bd1c..04d48bfa09 100644 --- a/src/SOS/Strike/runtime.cpp +++ b/src/SOS/Strike/runtime.cpp @@ -85,8 +85,16 @@ HRESULT Runtime::CreateInstance(bool isDesktop, Runtime **ppRuntime) } if (SUCCEEDED(hr)) { - *ppRuntime = new Runtime(isDesktop, moduleIndex, moduleAddress, moduleSize); - OnUnloadTask::Register(CleanupRuntimes); + if (moduleSize > 0) + { + *ppRuntime = new Runtime(isDesktop, moduleIndex, moduleAddress, moduleSize); + OnUnloadTask::Register(CleanupRuntimes); + } + else + { + ExtOut("Runtime (%s) module size == 0\n", runtimeModuleName); + hr = E_INVALIDARG; + } } } return hr; diff --git a/src/SOS/Strike/strike.cpp b/src/SOS/Strike/strike.cpp index 27814e649a..76a754529c 100644 --- a/src/SOS/Strike/strike.cpp +++ b/src/SOS/Strike/strike.cpp @@ -2464,7 +2464,8 @@ size_t FormatGeneratedException (DWORD_PTR dataPtr, WCHAR filename[MAX_LONGPATH] = W(""); ULONG linenum = 0; if (bLineNumbers && - SUCCEEDED(GetLineByOffset(TO_CDADDR(ste.ip), &linenum, filename, _countof(filename)))) + // Adjust the ip for leaf node frames + SUCCEEDED(GetLineByOffset(TO_CDADDR(i == 0 ? ste.ip - 1 : ste.ip), &linenum, filename, _countof(filename)))) { swprintf_s(wszLineBuffer, _countof(wszLineBuffer), W(" %s [%s @ %d]\n"), so.String(), filename, linenum); } @@ -13481,7 +13482,9 @@ class ClrStackImpl TableOutput out(3, POINTERSIZE_HEX, AlignRight); out.WriteRow("Child SP", "IP", "Call Site"); - + + int frameNumber = 0; + int internalFrames = 0; do { if (IsInterrupt()) @@ -13516,6 +13519,8 @@ class ClrStackImpl // Print the method/Frame info if (SUCCEEDED(frameDataResult) && FrameData.frameAddr) { + internalFrames++; + // Skip the instruction pointer because it doesn't really mean anything for method frames out.WriteColumn(1, bFull ? String("") : NativePtr(ip)); @@ -13534,8 +13539,11 @@ class ClrStackImpl } else { + frameNumber++; + out.WriteColumn(1, InstructionPtr(ip)); - out.WriteColumn(2, MethodNameFromIP(ip, bSuppressLines, bFull, bFull)); + // To get the correct line number, the ip needs to be adjusted for leaf frames. + out.WriteColumn(2, MethodNameFromIP(frameNumber == 1 && internalFrames > 0 ? ip - 1 : ip, bSuppressLines, bFull, bFull)); // Print out gc references. refCount will be zero if bGC is false (or if we // failed to fetch gc reference information).