summaryrefslogtreecommitdiff
path: root/bridges
diff options
context:
space:
mode:
authorDavid Ostrovsky <david@ostrovsky.org>2015-09-10 23:03:39 +0200
committerDavid Ostrovsky <david@ostrovsky.org>2015-09-12 09:17:15 +0000
commit1aad95eb96bb0e9416a608b8a0416bd7d46b1cab (patch)
tree370117f45196d8a5835dee2079018ca908ca9caa /bridges
parent074d4b236266bf2934ea637da6c9bf4f18da4d0a (diff)
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@libreoffice.org> Reviewed-by: David Ostrovsky <david@ostrovsky.org>
Diffstat (limited to 'bridges')
-rw-r--r--bridges/inc/bridges/cpp_uno/shared/except.hxx41
-rw-r--r--bridges/source/cpp_uno/msvc_win32_intel/except.cxx7
-rw-r--r--bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx13
3 files changed, 53 insertions, 8 deletions
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 000000000000..fcb455297bf2
--- /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 48e538335d94..6aaf8c2c8f4f 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 f543236a6891..d5d6d0e27606 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
);
}