[Libreoffice-commits] core.git: bridges/inc bridges/source
David Ostrovsky
david at ostrovsky.org
Sat Sep 12 02:17:39 PDT 2015
bridges/inc/bridges/cpp_uno/shared/except.hxx | 41 ++++++++++++++++++++
bridges/source/cpp_uno/msvc_win32_intel/except.cxx | 7 ++-
bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx | 13 ++----
3 files changed, 53 insertions(+), 8 deletions(-)
New commits:
commit 1aad95eb96bb0e9416a608b8a0416bd7d46b1cab
Author: David Ostrovsky <david at ostrovsky.org>
Date: Thu Sep 10 23:03:39 2015 +0200
Actually fix uno bridge on MSVC 14.0
VC runtime was substantially refactored on MSVC 14.0. Among other,
_tiddata structure defined in crt/src/mtdll.h was replaced with
__vcrt_getptd defined in crt/src/vcruntime/vcruntime_internal.h.
All members before
unsigned long _NLG_dwCode
were removed, so that the approach to access the member
void * _tpxcptinfoptrs; /* ptr to exception info pointers */
with __pxcptinfoptrs() and compute the offset to the _curexception
member of _tiddata doesn't work on MSVC 14.0.
As of MSVC 14.0 __vcrt_getptd symbol isn't exported but Microsoft
have introduced methods to access current exception, current exception
context and processing throw (the later can be accessed through C++17
std::unhandled_exceptions() that was made available in MSVC 14.0):
* __current_exception()
* __current_exception_context()
* __processing_throw() aka std::unhandled_exceptions()
Make use of __current_exception() which we can hope will be maintained
going forward.
Change-Id: Ibfffa5fba62d6928328ac976cb1b24937277363e
Reviewed-on: https://gerrit.libreoffice.org/18475
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: David Ostrovsky <david at ostrovsky.org>
diff --git a/bridges/inc/bridges/cpp_uno/shared/except.hxx b/bridges/inc/bridges/cpp_uno/shared/except.hxx
new file mode 100644
index 0000000..fcb4552
--- /dev/null
+++ b/bridges/inc/bridges/cpp_uno/shared/except.hxx
@@ -0,0 +1,41 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_BRIDGES_INC_BRIDGES_CPP_UNO_SHARED_EXCEPT_HXX
+#define INCLUDED_BRIDGES_INC_BRIDGES_CPP_UNO_SHARED_EXCEPT_HXX
+
+#if _MSC_VER >= 1900 // VC 2015 (and later?)
+// extern "C" void** __cdecl __current_exception()
+// is defined in MSVS14.0/VC/crt/src/vcruntime/frame.cpp:
+// return &__vcrt_getptd()->_curexception;
+//
+// __vcrt_getptd is defined in vcruntime_internal.h:
+//typedef struct __vcrt_ptd
+//{
+// // C++ Exception Handling (EH) state
+// unsigned long _NLG_dwCode; // Required by NLG routines
+//[...]
+//void* _curexception; // current exception
+//[...]
+extern "C" void** __current_exception();
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/bridges/source/cpp_uno/msvc_win32_intel/except.cxx b/bridges/source/cpp_uno/msvc_win32_intel/except.cxx
index 48e5383..6aaf8c2 100644
--- a/bridges/source/cpp_uno/msvc_win32_intel/except.cxx
+++ b/bridges/source/cpp_uno/msvc_win32_intel/except.cxx
@@ -32,6 +32,7 @@
#include "com/sun/star/uno/Any.hxx"
#include <unordered_map>
#include "msci.hxx"
+#include "bridges/cpp_uno/shared/except.hxx"
#pragma pack(push, 8)
@@ -493,8 +494,11 @@ int msci_filterCppException(
if (rethrow && pRecord == pPointers->ExceptionRecord)
{
- // hack to get msvcrt internal _curexception field:
pRecord = *reinterpret_cast< EXCEPTION_RECORD ** >(
+#if _MSC_VER >= 1900 // VC 2015 (and later?)
+ __current_exception()
+#else
+ // hack to get msvcrt internal _curexception field:
reinterpret_cast< char * >( __pxcptinfoptrs() ) +
// as long as we don't demand msvcr source as build prerequisite
// (->platform sdk), we have to code those offsets here.
@@ -503,6 +507,7 @@ int msci_filterCppException(
// offsetof (_tiddata, _curexception) -
// offsetof (_tiddata, _tpxcptinfoptrs):
0x28 // msvcr80.dll (and later?)
+#endif
);
}
// rethrow: handle only C++ exceptions:
diff --git a/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx b/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx
index f543236..d5d6d0e 100644
--- a/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx
+++ b/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx
@@ -250,6 +250,7 @@ void
#include "com/sun/star/uno/Any.hxx"
#include <unordered_map>
#include "mscx.hxx"
+#include "bridges/cpp_uno/shared/except.hxx"
#pragma pack(push, 8)
@@ -866,8 +867,11 @@ int mscx_filterCppException(
if (rethrow && pRecord == pPointers->ExceptionRecord)
{
- // Hack to get msvcrt internal _curexception field:
pRecord = *reinterpret_cast< EXCEPTION_RECORD ** >(
+#if _MSC_VER >= 1900 // VC 2015 (and later?)
+ __current_exception()
+#else
+ // Hack to get msvcrt internal _curexception field
reinterpret_cast< char * >( __pxcptinfoptrs() ) +
// As long as we don't demand MSVCR source as build prerequisite,
// we have to code those offsets here.
@@ -875,12 +879,7 @@ int mscx_filterCppException(
// MSVS9/crt/src/mtdll.h:
// offsetof (_tiddata, _curexception) -
// offsetof (_tiddata, _tpxcptinfoptrs):
-#if _MSC_VER <= 1900 // VC 2015
- //
- // See dev-tools/uno/uno_exception_offset
- 0x48 // msvcr90.dll
-#else
- error, please find value for this compiler version
+ 0x48
#endif
);
}
More information about the Libreoffice-commits
mailing list