From ba1d5b2de899bf6e09702f70c28e85b527bd1ea9 Mon Sep 17 00:00:00 2001 From: Alexandre Teoi Date: Wed, 21 Feb 2018 20:32:46 -0300 Subject: [PATCH] Show the expected stack trace from a rethrown exception. (#16464) * Show the expected stack trace from a rethrown exception. Fix #15780 * Remove now unused methods - StackTraceArray::AppendSkipLast - StackTraceElement::PartiallyEqual - StackTraceElement::PartialAtomicUpdate --- src/vm/clrex.h | 10 ---------- src/vm/excep.cpp | 4 +--- src/vm/object.cpp | 49 ------------------------------------------------- src/vm/object.h | 1 - 4 files changed, 1 insertion(+), 63 deletions(-) diff --git a/src/vm/clrex.h b/src/vm/clrex.h index 12eb702..a550a71 100644 --- a/src/vm/clrex.h +++ b/src/vm/clrex.h @@ -42,16 +42,6 @@ struct StackTraceElement { return !(*this == rhs); } - - bool PartiallyEqual(StackTraceElement const & rhs) const - { - return pFunc == rhs.pFunc; - } - - void PartialAtomicUpdate(StackTraceElement const & rhs) - { - ip = rhs.ip; - } }; class StackTraceInfo diff --git a/src/vm/excep.cpp b/src/vm/excep.cpp index 35a2074..09283f7 100644 --- a/src/vm/excep.cpp +++ b/src/vm/excep.cpp @@ -2428,9 +2428,7 @@ void StackTraceInfo::SaveStackTrace(BOOL bAllowAllocMem, OBJECTHANDLE hThrowable } } - if (bSkipLastElement && gc.stackTrace.Size() != 0) - gc.stackTrace.AppendSkipLast(m_pStackTrace, m_pStackTrace + m_dFrameCount); - else + if (!bSkipLastElement) gc.stackTrace.Append(m_pStackTrace, m_pStackTrace + m_dFrameCount); ////////////////////////////// diff --git a/src/vm/object.cpp b/src/vm/object.cpp index 8659084..374fe19 100644 --- a/src/vm/object.cpp +++ b/src/vm/object.cpp @@ -1970,55 +1970,6 @@ void StackTraceArray::Append(StackTraceElement const * begin, StackTraceElement #endif } -void StackTraceArray::AppendSkipLast(StackTraceElement const * begin, StackTraceElement const * end) -{ - CONTRACTL - { - THROWS; - GC_TRIGGERS; - MODE_COOPERATIVE; - PRECONDITION(IsProtectedByGCFrame((OBJECTREF*)this)); - } - CONTRACTL_END; - - // to skip the last element, we need to replace it with the first element - // from m_pStackTrace and do it atomically if possible, - // otherwise we'll create a copy of the entire array, which is bad for performance, - // and so should not be on the main path - // - - // ensure that only one thread can write to the array - EnsureThreadAffinity(); - - assert(Size() > 0); - - StackTraceElement & last = GetData()[Size() - 1]; - if (last.PartiallyEqual(*begin)) - { - // fast path: atomic update - last.PartialAtomicUpdate(*begin); - - // append the rest - if (end - begin > 1) - Append(begin + 1, end); - } - else - { - // slow path: create a copy and append - StackTraceArray copy; - GCPROTECT_BEGIN(copy); - copy.CopyFrom(*this); - copy.SetSize(copy.Size() - 1); - copy.Append(begin, end); - this->Swap(copy); - GCPROTECT_END(); - } - -#if defined(_DEBUG) - CheckState(); -#endif -} - void StackTraceArray::CheckState() const { CONTRACTL diff --git a/src/vm/object.h b/src/vm/object.h index 3ffbf79..e6e0c02 100644 --- a/src/vm/object.h +++ b/src/vm/object.h @@ -2910,7 +2910,6 @@ public: StackTraceElement & operator[](size_t index); void Append(StackTraceElement const * begin, StackTraceElement const * end); - void AppendSkipLast(StackTraceElement const * begin, StackTraceElement const * end); I1ARRAYREF Get() const { -- 2.7.4