Exemple #1
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;
}
Exemple #2
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 #3
0
//---------------------------------------------------------------------------
//	@function:
//		CException::Raise
//
//	@doc:
//		Actual point where an exception is thrown; encapsulated in a function 
//		(a) to facilitate debugging, i.e. function to set a breakpoint
//		(b) to allow for additional debugging tools such as stack dumps etc.
//			at a later point in time
//
//---------------------------------------------------------------------------
void
CException::Raise
	(
	const CHAR *szFilename,
	ULONG ulLine,
	ULONG ulMajor,
	ULONG ulMinor,
	...
	)
{
	// manufacture actual exception object
	CException exc(ulMajor, ulMinor, szFilename, ulLine);
	
	// during bootstrap there's no context object otherwise, record
	// all details in the context object
	if (NULL != ITask::PtskSelf())
	{
		CErrorContext *perrctxt = CTask::PtskSelf()->PerrctxtConvert();

		VA_LIST valist;
		VA_START(valist, ulMinor);

		perrctxt->Record(exc, valist);

		VA_END(valist);

		perrctxt->Serialize();
	}

	Raise(exc);
}
Exemple #4
0
//---------------------------------------------------------------------------
//	@function:
//		CMiniDumperTest::CSerializableStack::Serialize
//
//	@doc:
//		Serialize object to passed stream
//
//---------------------------------------------------------------------------
void
CMiniDumperTest::CSerializableStack::Serialize
	(
	COstream& oos
	)
{
	WCHAR wszStackBuffer[GPOS_MINIDUMP_BUF_SIZE];
	CWStringStatic wstr(wszStackBuffer, GPOS_ARRAY_SIZE(wszStackBuffer));

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

	CErrorContext *perrctxt = CTask::Self()->ConvertErrCtxt();
	perrctxt->GetStackDescriptor()->AppendTrace(&wstr);

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

	oos << wstr.GetBuffer();
}
// Check parameter access path well formed for leaf elements
bool CInstanceConfigurableElement::checkPathExhausted(CPathNavigator& pathNavigator, CErrorContext& errorContext)
{
    std::string* pStrChildName = pathNavigator.next();

    if (pStrChildName) {

        // Should be leaf element
        errorContext.setError("Path not found: " + pathNavigator.getCurrentPath());

        return false;
    }
    return true;
}
//---------------------------------------------------------------------------
//	@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;
}