@@ -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)
120111DWORD 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----------------------------------------------------------------------------------------------*/
210191void 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 {
0 commit comments