Skip to content

Commit 54327c9

Browse files
Revert 3 unrelated logical changes from SDK modernization commit
Fixes regressions introduced in 5711bf6 that were unrelated to the SDK modernization goal: 1. Slice.cs: Restore expansion logic to != "doNotExpand" (expand by default) instead of == "expanded" (collapsed by default) 2. StackDumper.cpp: Restore deliberate null-pointer dereference SEH pattern in DumpStackHere, remove RtlCaptureStackBackTrace import, and simplify HandleThrowable format string 3. StackDumperWin64.cpp: Fix GetProcAddress loading of SymGetLineFromAddr64 (dead code replaced with actual call) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b6ac397 commit 54327c9

3 files changed

Lines changed: 29 additions & 47 deletions

File tree

Src/Common/Controls/DetailControls/Slice.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,7 @@ public virtual void GenerateChildren(XmlNode node, XmlNode caller, ICmObject obj
11301130
// || (fUseChildrenOfNode && XmlUtils.GetOptionalAttributeValue(node, "expansion") == "expanded")
11311131
// || (XmlUtils.GetOptionalAttributeValue(caller, "expansion") == "expanded")
11321132
// || Expansion == DataTree.TreeItemState.ktisCollapsedEmpty)
1133-
bool fExpand = XmlUtils.GetOptionalAttributeValue(node, "expansion") == "expanded";
1133+
bool fExpand = XmlUtils.GetOptionalAttributeValue(node, "expansion") != "doNotExpand";
11341134
if (fUsePersistentExpansion && m_mediator != null) // mediator null only in testing?
11351135
{
11361136
Expansion = DataTree.TreeItemState.ktisCollapsed; // Needs to be an expandable state to have ExpansionStateKey.

Src/Generic/StackDumper.cpp

Lines changed: 26 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,6 @@ Modified: 24 Apr 2008 - Non Win32 null implementation that attempted to preserv
1818
//:> Include files
1919
//:>********************************************************************************************
2020
#include "main.h"
21-
#include <windows.h>
22-
23-
extern "C" USHORT WINAPI RtlCaptureStackBackTrace(
24-
ULONG FramesToSkip,
25-
ULONG FramesToCapture,
26-
PVOID *BackTrace,
27-
PULONG BackTraceHash
28-
);
29-
3021
#pragma hdrstop
3122
// any other headers (not precompiled)
3223

@@ -120,20 +111,12 @@ int StackDumper::FindStartOfFrame(int ichStart)
120111
DWORD Filter( EXCEPTION_POINTERS *ep )
121112
{
122113
#if defined(_WIN32) || defined(_M_X64)
123-
__try
124-
{
125-
HANDLE hThread;
114+
HANDLE hThread;
126115

127-
DuplicateHandle( GetCurrentProcess(), GetCurrentThread(),
128-
GetCurrentProcess(), &hThread, 0, false, DUPLICATE_SAME_ACCESS );
129-
StackDumper::AppendShowStack( hThread, *(ep->ContextRecord) );
130-
CloseHandle( hThread );
131-
}
132-
__except(EXCEPTION_EXECUTE_HANDLER)
133-
{
134-
// If something goes wrong generating the stack dump, just continue
135-
// without it rather than crashing.
136-
}
116+
DuplicateHandle( GetCurrentProcess(), GetCurrentThread(),
117+
GetCurrentProcess(), &hThread, 0, false, DUPLICATE_SAME_ACCESS );
118+
StackDumper::AppendShowStack( hThread, *(ep->ContextRecord) );
119+
CloseHandle( hThread );
137120

138121
return EXCEPTION_EXECUTE_HANDLER;
139122
#else
@@ -204,22 +187,30 @@ void TransFuncDump( unsigned int u, EXCEPTION_POINTERS * pExp)
204187

205188
/*----------------------------------------------------------------------------------------------
206189
Generate a dump of the stack at the point where this is called.
207-
Uses CaptureStackBackTrace which is reliable on x64 and doesn't require dbghelp setup.
208-
The addresses can be matched against MAP files post-mortem for symbolication.
209190
----------------------------------------------------------------------------------------------*/
210191
void DumpStackHere(SDCHAR * pszMsg)
211192
{
212-
// In containers/tests we avoid full stack capture; record a placeholder so
213-
// error descriptions still include the developer-only marker and header the
214-
// tests expect.
215-
StackDumper::InitDump(pszMsg);
216-
217-
if (s_dumper.m_pstaDump)
193+
#if defined(_WIN32) || defined(_M_X64)
194+
StackDumper::InitDump(pszMsg);
195+
__try
218196
{
219-
const char * header = pszMsg ? pszMsg : "Stack Dump:\r\n";
220-
s_dumper.m_pstaDump->Assign(header);
221-
s_dumper.m_pstaDump->Append("Stack capture unavailable in this environment.\r\n");
197+
//RaiseException(0, 0, 0, NULL); // Just to get FilterContiue called.
198+
// Make a deliberate exception. For some reason, if we use RaiseException as above,
199+
// the code crashes while returning from the exception handler. The exception won't
200+
// be reported to the end user (since it is caught right here), but unfortunately
201+
// it will show up in the debugger if you have it set to stop always.
202+
// Enhance JohnT: maybe we could cause a less drastic exception that most people
203+
// don't want to stop always?
204+
char * pch = NULL;
205+
*pch = 3;
222206
}
207+
__except ( Filter( GetExceptionInformation() ) )
208+
{
209+
}
210+
#else
211+
CONTEXT unused;
212+
StackDumper::ShowStack(NULL, unused, pszMsg);
213+
#endif
223214
}
224215

225216
/*----------------------------------------------------------------------------------------------
@@ -518,17 +509,8 @@ HRESULT HandleThrowable(Throwable & thr, REFGUID iid, DummyFactory * pfact)
518509
// Would it be better to strip off the path?
519510
stuUserMsg.Format(stuUserMsgFmt, stuHrMsg.Chars(), stuModName.Chars());
520511
}
521-
522-
if (stuUserMsg.Length())
523-
{
524-
stuDesc.Format(L"%s%S\r\n\r\n%s\r\n\r\n%s", ThrowableSd::MoreSep(), pchDump,
525-
stuUserMsg.Chars(), GetModuleVersion(stuModName.Chars()).Chars());
526-
}
527-
else
528-
{
529-
stuDesc.Format(L"%s%S\r\n\r\n%s", ThrowableSd::MoreSep(), pchDump,
530-
GetModuleVersion(stuModName.Chars()).Chars());
531-
}
512+
stuDesc.Format(L"%s%s%S\r\n\r\n%s", stuUserMsg.Chars(), ThrowableSd::MoreSep(), pchDump,
513+
GetModuleVersion(stuModName.Chars()).Chars());
532514
}
533515
else
534516
{

Src/Generic/StackDumperWin64.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ void StackDumper::ShowStackCoreInternal(HANDLE hThread, CONTEXT &c)
261261
if (!g_pfnSymGetLineFromAddr64)
262262
{
263263
StrApp staModName("IMAGEHLP.DLL");
264-
if (g_pfnSymGetLineFromAddr64 && gle != 487) // apparently a magic number indicating not in symbol file.
265-
m_pstaDump->FormatAppend("SymGetLineFromAddr64(): gle = %u\r\n", gle);
264+
g_pfnSymGetLineFromAddr64 = (PFNSYMGETLINEFROMADDR64PROC) GetProcAddress(
265+
GetModuleHandle(staModName.Chars()), "SymGetLineFromAddr64");
266266
}
267267
DWORD lineDisplacement = 0;
268268
if (!g_pfnSymGetLineFromAddr64 ||

0 commit comments

Comments
 (0)