/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
if (iFind != m_allRTTI.end())
pRTTI = static_cast<ExceptionTypeInfoWrapper*>(iFind->second); else
{
OString aRawName(OUStringToOString(toRTTIname(rUNOname), RTL_TEXTENCODING_ASCII_US)); // Wrap new ExceptionTypeInfo in ExceptionTypeInfoWrapper to preserve length info
pRTTI = new (std::malloc(sizeof(ExceptionTypeInfoWrapper) + aRawName.getLength()))
ExceptionTypeInfoWrapper(nullptr, aRawName.getStr());
void msvc_raiseException(uno_Any* pUnoExc, uno_Mapping* pUno2Cpp)
{ // no ctor/dtor in here: this leads to dtors called twice upon RaiseException()! // thus this obj file will be compiled without opt, so no inlining of // ExceptionInfos::getRaiseInfo()
// Destruct uno exception
::uno_any_destruct(pUnoExc, nullptr);
TYPELIB_DANGER_RELEASE(pTD);
// last point to release anything not affected by stack unwinding
RaiseException(MSVC_EH_MAGIC_CODE, EXCEPTION_NONCONTINUABLE, MSVC_EH_PARAMETERS, arFilterArgs);
std::abort();
}
// This function does the same check as __CxxDetectRethrow from msvcrt (see its // crt/src/vcruntime/mgdframe.cpp). But it does not alter the global state, i.e. it does not // increment __ProcessingThrow, and so does not break following exception handling. We rely on the // definition of EHExceptionRecord, PER_IS_MSVC_EH and PER_PTHROW, that are current as of msvcrt // 2017 (14.14.26428). staticbool DetectRethrow(void* ppExcept)
{ struct EHExceptionRecord
{
DWORD ExceptionCode;
DWORD ExceptionFlags; struct _EXCEPTION_RECORD* ExceptionRecord;
PVOID ExceptionAddress;
DWORD NumberParameters; #if MSVC_EH_PARAMETERS == 3 struct EHParameters #else struct alignas(8) #endif
{
DWORD magicNumber;
PVOID pExceptionObject;
PVOID pThrowInfo; #if MSVC_EH_PARAMETERS == 4
PVOID pThrowImageBase; #endif
} params;
};
if (rethrow && pRecord == pPointers->ExceptionRecord)
pRecord = *reinterpret_cast<EXCEPTION_RECORD**>(__current_exception());
// Rethrow: handle only C++ exceptions: if (pRecord == nullptr || pRecord->ExceptionCode != MSVC_EH_MAGIC_CODE) return EXCEPTION_CONTINUE_SEARCH;
if (pRecord->NumberParameters == MSVC_EH_PARAMETERS #if MSVC_EH_PARAMETERS == 4
&& pRecord->ExceptionInformation[0] == MSVC_EH_MAGIC_PARAM #endif
&& pRecord->ExceptionInformation[1] != 0 && pRecord->ExceptionInformation[2] != 0 #if MSVC_EH_PARAMETERS == 4
&& pRecord->ExceptionInformation[3] != 0 #endif
)
{ // ExceptionInformation[1] is the address of the thrown object // (or the address of a pointer to it, in most cases when it // is a C++ class, obviously).
// [2] is the pThrowInfo pointer
RaiseInfo* pInfo = reinterpret_cast<RaiseInfo*>(pRecord->ExceptionInformation[2]);
#if MSVC_EH_PARAMETERS == 3
ULONG_PTR base = 0;
DWORD* types = reinterpret_cast<DWORD*>(pInfo->_types); #else // [3] is the image base address which is added the 32-bit // rva_t fields in throwinfo to get actual 64-bit addresses
ULONG_PTR base = pRecord->ExceptionInformation[3];
DWORD* types = reinterpret_cast<DWORD*>(base + pInfo->_types); #endif if (types != nullptr && types[0] != 0 && types[1] != 0)
{
ExceptionType* et = reinterpret_cast<ExceptionType*>(base + types[1]); if (et->_pTypeInfo != 0)
{
OUString aRTTIname(OStringToOUString( reinterpret_cast<ExceptionTypeInfo*>(base + et->_pTypeInfo)->m_d_name,
RTL_TEXTENCODING_ASCII_US));
OUString aUNOname(toUNOname(aRTTIname));
typelib_TypeDescription* pExcTD = nullptr;
typelib_typedescription_getByName(&pExcTD, aUNOname.pData); if (pExcTD == nullptr)
{
OUString sMsg = "[mscx_uno bridge error] UNO type of C++ exception unknown: \""
+ aUNOname + "\", RTTI-name=\"" + aRTTIname + "\"!";
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.