Exemple #1
0
//---------------------------------------------------------------------------
//	@function:
//		CException::Reraise
//
//	@doc:
//		Throw/rethrow interface to reraise an already caught exc;
//		Wrapper that asserts there is a pending error;
//
//---------------------------------------------------------------------------
void
CException::Reraise
	(
	CException exc,
	BOOL fPropagate
	)
{
	if (NULL != ITask::PtskSelf())
	{
		CErrorContext *perrctxt = CTask::PtskSelf()->PerrctxtConvert();
		GPOS_ASSERT(perrctxt->FPending());

		perrctxt->SetRethrow();

		// serialize registered objects when current task propagates
		// an exception thrown by a child task
		if (fPropagate)
		{
			perrctxt->Psd()->BackTrace();
			perrctxt->Serialize();
		}
	}

	Raise(exc);
}
Exemple #2
0
//---------------------------------------------------------------------------
//	@function:
//		CMiniDumperTest::CSerializableStack::UlpSerialize
//
//	@doc:
//		Serialize object to passed buffer
//
//---------------------------------------------------------------------------
ULONG_PTR
CMiniDumperTest::CSerializableStack::UlpSerialize
	(
	WCHAR *wszEntry,
	ULONG_PTR ulpAllocSize
	)
{
	WCHAR wszStackBuffer[GPOS_MINIDUMP_BUF_SIZE];
	CWStringStatic wstr(wszStackBuffer, GPOS_ARRAY_SIZE(wszStackBuffer));

	wstr.AppendFormat(GPOS_WSZ_LIT("<STACK_TRACE>\n"));

	CErrorContext *perrctxt = CTask::PtskSelf()->PerrctxtConvert();
	perrctxt->Psd()->AppendTrace(&wstr);

	wstr.AppendFormat(GPOS_WSZ_LIT("</STACK_TRACE>\n"));

	ULONG_PTR ulpSize = std::min
		(
		(ULONG_PTR) wstr.UlLength(),
		ulpAllocSize
		);

	(void) clib::PvMemCpy
		(
		(BYTE *) wszEntry,
		(BYTE *) wszStackBuffer,
		ulpSize * GPOS_SIZEOF(WCHAR)
		);

	return ulpSize;
}
//---------------------------------------------------------------------------
//	@function:
//		CSerializableStackTrace::Serialize
//
//	@doc:
//		Serialize contents into provided stream
//
//---------------------------------------------------------------------------
void
CSerializableStackTrace::Serialize
	(
	COstream& oos
	)
{
	if (!ITask::PtskSelf()->FPendingExc())
	{
		// no pending exception: no need to serialize stack trace
		return;
	}
	WCHAR wszStackBuffer[GPOPT_MINIDUMP_BUF_SIZE];
	CWStringStatic str(wszStackBuffer, GPOS_ARRAY_SIZE(wszStackBuffer));

	str.AppendFormat(CDXLSections::m_wszStackTraceHeader);

	CErrorContext *perrctxt = CTask::PtskSelf()->PerrctxtConvert();
	perrctxt->Psd()->AppendTrace(&str);

	str.AppendFormat(CDXLSections::m_wszStackTraceFooter);

	oos << wszStackBuffer;
}