summaryrefslogtreecommitdiff
path: root/indra/llcommon/llcoros.cpp
diff options
context:
space:
mode:
authorAnkur Ahlawat <anchor@lindenlab.com>2018-01-04 00:54:41 -0800
committerAnkur Ahlawat <anchor@lindenlab.com>2018-01-04 00:54:41 -0800
commitd4ce47b09122d1f76601ba402c2b9ad6bb504950 (patch)
tree2f9a4aca02618d53d31ac62625645f89fb30c52f /indra/llcommon/llcoros.cpp
parent93100236ae34eaa9cd3fa314e7e770339c13eba7 (diff)
parent1693ccba58eef676df1f91e50627545ac35bb819 (diff)
Merged lindenlab/viewer-release into default
Diffstat (limited to 'indra/llcommon/llcoros.cpp')
-rw-r--r--indra/llcommon/llcoros.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/indra/llcommon/llcoros.cpp b/indra/llcommon/llcoros.cpp
index 3ffce4810a..934f04287d 100644
--- a/indra/llcommon/llcoros.cpp
+++ b/indra/llcommon/llcoros.cpp
@@ -40,6 +40,10 @@
#include "stringize.h"
#include "llexception.h"
+#if LL_WINDOWS
+#include <excpt.h>
+#endif
+
namespace {
void no_op() {}
} // anonymous namespace
@@ -272,6 +276,43 @@ void LLCoros::setStackSize(S32 stacksize)
mStackSize = stacksize;
}
+#if LL_WINDOWS
+
+static const U32 STATUS_MSC_EXCEPTION = 0xE06D7363; // compiler specific
+
+U32 exception_filter(U32 code, struct _EXCEPTION_POINTERS *exception_infop)
+{
+ if (code == STATUS_MSC_EXCEPTION)
+ {
+ // C++ exception, go on
+ return EXCEPTION_CONTINUE_SEARCH;
+ }
+ else
+ {
+ // handle it
+ return EXCEPTION_EXECUTE_HANDLER;
+ }
+}
+
+void LLCoros::winlevel(const callable_t& callable)
+{
+ __try
+ {
+ callable();
+ }
+ __except (exception_filter(GetExceptionCode(), GetExceptionInformation()))
+ {
+ // convert to C++ styled exception
+ // Note: it might be better to use _se_set_translator
+ // if you want exception to inherit full callstack
+ char integer_string[32];
+ sprintf(integer_string, "SEH, code: %lu\n", GetExceptionCode());
+ throw std::exception(integer_string);
+ }
+}
+
+#endif
+
// Top-level wrapper around caller's coroutine callable. This function accepts
// the coroutine library's implicit coro::self& parameter and saves it, but
// does not pass it down to the caller's callable.
@@ -282,7 +323,11 @@ void LLCoros::toplevel(coro::self& self, CoroData* data, const callable_t& calla
// run the code the caller actually wants in the coroutine
try
{
+#if LL_WINDOWS
+ winlevel(callable);
+#else
callable();
+#endif
}
catch (const LLContinueError&)
{