[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 087df89 2/4: Remove an ancient demonstration
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 087df89 2/4: Remove an ancient demonstration of a MinGW dw2 EH issue |
Date: |
Sun, 10 Sep 2017 18:17:13 -0400 (EDT) |
branch: master
commit 087df89b66c975f69edbc3b2f99f1c31b236697f
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Remove an ancient demonstration of a MinGW dw2 EH issue
Removed several files, added in 2005 and untouched since, that served
only to demonstrate that throwing C++ exceptions across DLL boundaries
is incompatible with the dwarf exception-handling model. That is no
longer news, and now requires no demonstration.
---
gwc/app.cpp | 92 -------------------------------------------------------------
gwc/app.hpp | 5 ----
gwc/dll.cpp | 83 -------------------------------------------------------
gwc/dll.hpp | 10 -------
4 files changed, 190 deletions(-)
diff --git a/gwc/app.cpp b/gwc/app.cpp
deleted file mode 100644
index f01fb1f..0000000
--- a/gwc/app.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-// g++ app.cpp dll.dll
-
-#define EXPORT_IMPORT __declspec(dllimport)
-#include "app.hpp"
-#include "dll.hpp"
-
-#include <exception>
-#include <iostream>
-#include <ostream>
-#include <stdexcept>
-
-void report_exception_in_app()
-{
- std::cout << " Rethrowing in app" << std::endl;
- try {throw;}
- catch(std::exception const& e)
- {std::cout << " Caught in app: " << e.what() << std::endl;}
- catch(...)
- {std::cout << " Caught in app: unknown exception " << std::endl;}
-}
-
-void throw_from_app()
-{
- throw std::runtime_error("Exception from app.");
-}
-
-/////////////////////////////////
-// In this module, any use of //
-// report_exception_in_dll() //
-// causes an abend. //
-/////////////////////////////////
-
-// OK: Thrown from app, reported in app.
-void test_a_aa()
-{
- std::cout << __FUNCTION__ << std::endl;
- try {throw_from_app();}
- catch(...) {report_exception_in_app();}
-}
-
-// OK: Thrown from dll, reported in app.
-void test_a_da()
-{
- std::cout << __FUNCTION__ << std::endl;
- try {throw_from_dll();}
- catch(...) {report_exception_in_app();}
-}
-
-// FAILS: Thrown from app, reported in dll.
-void test_a_ad()
-{
- std::cout << __FUNCTION__ << std::endl;
- try {throw_from_app();}
- catch(...)
- {
- std::cout << " This will fail..." << std::endl;
- report_exception_in_dll();
- std::cout << "SURPRISE: this line was reached." << std::endl;
- }
-}
-
-// FAILS: Thrown from dll, reported in dll.
-void test_a_dd()
-{
- std::cout << __FUNCTION__ << std::endl;
- try {throw_from_dll();}
- catch(...)
- {
- std::cout << " This will fail..." << std::endl;
- report_exception_in_dll();
- std::cout << "SURPRISE: this line was reached." << std::endl;
- }
-}
-
-// An app mustn't invoke a dll function that rethrows the current exception.
-// An dll mustn't invoke an app function that rethrows the current exception.
-
-int main()
-{
- set_callbacks(report_exception_in_app, throw_from_app);
-
- test_a_aa();
- test_a_da();
-// test_a_ad(); // FAILS
-// test_a_dd(); // FAILS
-
-// test_d_aa(); // FAILS
-// test_d_da(); // FAILS
- test_d_ad();
- test_d_dd();
-}
-
diff --git a/gwc/app.hpp b/gwc/app.hpp
deleted file mode 100644
index d02b96b..0000000
--- a/gwc/app.hpp
+++ /dev/null
@@ -1,5 +0,0 @@
-#ifndef app_hpp
-#define app_hpp
-void throw_from_app();
-void report_exception_in_app();
-#endif // app.hpp
diff --git a/gwc/dll.cpp b/gwc/dll.cpp
deleted file mode 100644
index 7a69128..0000000
--- a/gwc/dll.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-// g++ --shared dll.cpp -o dll.dll
-
-#define EXPORT_IMPORT __declspec(dllexport)
-#include "app.hpp"
-#include "dll.hpp"
-
-#include <exception>
-#include <iostream>
-#include <ostream>
-#include <stdexcept>
-
-void EXPORT_IMPORT report_exception_in_dll()
-{
- std::cout << " Rethrowing in dll" << std::endl;
- try {throw;}
- catch(std::exception const& e)
- {std::cout << " Caught in dll: " << e.what() << std::endl;}
- catch(...)
- {std::cout << " Caught in dll: unknown exception " << std::endl;}
-}
-
-void EXPORT_IMPORT throw_from_dll()
-{
- throw std::runtime_error("Exception from dll.");
-}
-
-void (*throw_from_app_via_callback)();
-void (*report_exception_in_app_via_callback)();
-
-void EXPORT_IMPORT set_callbacks(void (*f)(), void (*g)())
-{
- report_exception_in_app_via_callback = f;
- throw_from_app_via_callback = g;
-}
-
-//////////////////////////////////////////////
-// In this module, any use of //
-// report_exception_in_app_via_callback() //
-// causes an abend. //
-//////////////////////////////////////////////
-
-// FAILS: Thrown from app, reported in app.
-void EXPORT_IMPORT test_d_aa()
-{
- std::cout << __FUNCTION__ << std::endl;
- try {throw_from_app_via_callback();}
- catch(...)
- {
- std::cout << " This will fail..." << std::endl;
- report_exception_in_app_via_callback();
- std::cout << "SURPRISE: this line was reached." << std::endl;
- }
-}
-
-// FAILS: Thrown from dll, reported in app.
-void EXPORT_IMPORT test_d_da()
-{
- std::cout << __FUNCTION__ << std::endl;
- try {throw_from_dll();}
- catch(...)
- {
- std::cout << " This will fail..." << std::endl;
- report_exception_in_app_via_callback();
- std::cout << "SURPRISE: this line was reached." << std::endl;
- }
-}
-
-// OK: Thrown from app, reported in dll.
-void EXPORT_IMPORT test_d_ad()
-{
- std::cout << __FUNCTION__ << std::endl;
- try {throw_from_app_via_callback();}
- catch(...) {report_exception_in_dll();}
-}
-
-// OK: Thrown from dll, reported in dll.
-void EXPORT_IMPORT test_d_dd()
-{
- std::cout << __FUNCTION__ << std::endl;
- try {throw_from_dll();}
- catch(...) {report_exception_in_dll();}
-}
-
diff --git a/gwc/dll.hpp b/gwc/dll.hpp
deleted file mode 100644
index 6fc4fd1..0000000
--- a/gwc/dll.hpp
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef dll_hpp
-#define dll_hpp
-void EXPORT_IMPORT throw_from_dll();
-void EXPORT_IMPORT report_exception_in_dll();
-void EXPORT_IMPORT set_callbacks(void (*)(), void (*)());
-void EXPORT_IMPORT test_d_aa();
-void EXPORT_IMPORT test_d_da();
-void EXPORT_IMPORT test_d_ad();
-void EXPORT_IMPORT test_d_dd();
-#endif // dll.hpp