Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4267)

Unified Diff: chrome/test/data/nacl/crash/nonsfi_crash_via_signal_handler.cc

Issue 230413002: NonSFI NaCl: Plumb Exception IRT enough for breakpad. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/nacl/crash/nonsfi_crash_via_signal_handler.cc
diff --git a/chrome/test/data/nacl/crash/nonsfi_crash_via_signal_handler.cc b/chrome/test/data/nacl/crash/nonsfi_crash_via_signal_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..18ebefa3a4a5366f98f73128637dd511c1c6b619
--- /dev/null
+++ b/chrome/test/data/nacl/crash/nonsfi_crash_via_signal_handler.cc
@@ -0,0 +1,47 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
Mark Seaborn 2014/04/23 03:49:50 Could you name this file after the interface it te
Junichi Uekawa 2014/04/23 07:56:15 Done.
+#include <sched.h>
+#include <unistd.h>
+
+#include "native_client/src/include/nacl/nacl_exception.h"
+#include "native_client/src/shared/platform/nacl_check.h"
Mark Seaborn 2014/04/23 03:49:50 I don't think you use this?
Junichi Uekawa 2014/04/23 07:56:15 Done.
+#include "ppapi/native_client/tests/ppapi_test_lib/test_interface.h"
+
+namespace {
+
+static void MyNaClExceptionHandler(struct NaClExceptionContext *context) {
+ printf("--- MyNaClExceptionHandler\n");
+ TEST_PASSED;
+ // Wait for the javascript to realize that we have succeeded. If we
+ // exit from here we shall crash and it's hard to distinguish that
Mark Seaborn 2014/04/23 03:49:50 You could exit using setjmp()/longjmp() to exit fr
Junichi Uekawa 2014/04/23 07:56:15 Done.
+ // crash from a complete failure to register a fault handler.
+ while (1) {
+ sched_yield();
+ }
+}
+
+void CrashViaSignalHandler() {
+ printf("--- CrashViaSignalHandler\n");
+
+ int retval = nacl_exception_set_handler(MyNaClExceptionHandler);
+ if (retval != 0) {
+ printf("Unexpected return value from nacl_exception_set_handler: %d\n",
+ retval);
+ TEST_FAILED;
+ return;
+ }
+ CRASH;
Mark Seaborn 2014/04/23 03:49:50 I think it would be better to use __builtin_trap()
Junichi Uekawa 2014/04/23 07:56:15 It seemed to me that CRASH is more consistent with
+}
+
+} // namespace
+
+void SetupTests() {
+ RegisterTest("CrashViaSignalHandler", CrashViaSignalHandler);
+}
+
+void SetupPluginInterfaces() {
+
Mark Seaborn 2014/04/23 03:49:50 Nit: remove empty line at start of function
Junichi Uekawa 2014/04/23 07:56:15 Done.
+ // none
Mark Seaborn 2014/04/23 03:49:50 Nit: maybe remove this? Empty functions aren't us
Junichi Uekawa 2014/04/23 07:56:15 Done.
+}
« no previous file with comments | « no previous file | chrome/test/data/nacl/crash/nonsfi_crash_via_signal_handler.html » ('j') | chrome/test/nacl/nacl_browsertest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698