| Index: chrome/test/data/nacl/nonsfi/libc_free.c
|
| diff --git a/chrome/test/data/nacl/nonsfi/libc_free.c b/chrome/test/data/nacl/nonsfi/libc_free.c
|
| index ff3aef032a3e10a55bccddc65b00d5bee4b359af..5acf918dd3aea8383e4d99ad8de91d2d1874b06d 100644
|
| --- a/chrome/test/data/nacl/nonsfi/libc_free.c
|
| +++ b/chrome/test/data/nacl/nonsfi/libc_free.c
|
| @@ -20,6 +20,7 @@
|
| #include "ppapi/nacl_irt/public/irt_ppapi.h"
|
|
|
| static struct nacl_irt_basic __libnacl_irt_basic;
|
| +static struct nacl_irt_exception_handling __libnacl_irt_exception_handling;
|
| static struct nacl_irt_random __libnacl_irt_random;
|
| static TYPE_nacl_irt_query __nacl_irt_query;
|
| static struct PPP_Instance_1_0 ppp_instance;
|
| @@ -188,6 +189,36 @@ static void TestRandom(PP_Instance instance) {
|
| PostStringMessage(instance, "randomsuccess");
|
| }
|
|
|
| +static PP_Instance g_instance_for_exception_handler = -1;
|
| +static void MyNaClExceptionHandler(struct NaClExceptionContext *context) {
|
| + // TODO verify that I have a stack that is set by altstack.
|
| +
|
| + PostStringMessage(g_instance_for_exception_handler, "exceptionsuccess");
|
| +
|
| + // Wait until I get killed by testing infrastructure to give chance
|
| + // to PostMessage to finish asynchronously notifying javascript
|
| + // instead of crashing immediately. Doing ppb_console.Log() seems
|
| + // to also do the job, take your pick.
|
| + while(1) {
|
| + __libnacl_irt_basic.sched_yield();
|
| + }
|
| +}
|
| +
|
| +static void TestException(PP_Instance instance) {
|
| + // Exception Handling.
|
| + g_instance_for_exception_handler = instance;
|
| + if (__libnacl_irt_exception_handling.exception_handler(
|
| + MyNaClExceptionHandler, NULL)) {
|
| + PostStringMessage(instance, "Error on registering exception");
|
| + return;
|
| + }
|
| +
|
| + // Crash myself here to invoke the crash handler.
|
| + *(char*)0 = 0;
|
| +
|
| + PostStringMessage(instance, "I think I should have crashed already.");
|
| +}
|
| +
|
| // Handle message from javascript, javascript side will tell me what
|
| // kind of test it wants, and I will respond accordingly.
|
| static void HandleMessage(PP_Instance instance, struct PP_Var message) {
|
| @@ -204,6 +235,8 @@ static void HandleMessage(PP_Instance instance, struct PP_Var message) {
|
| ppb_messaging->PostMessage(instance, message);
|
| } else if (!my_strncmp("random", message_string, message_len)) {
|
| TestRandom(instance);
|
| + } else if (!my_strncmp("exception", message_string, message_len)) {
|
| + TestException(instance);
|
| } else {
|
| // Unknown message came.
|
| PostStringMessage(instance, "Unknown message type");
|
| @@ -215,6 +248,7 @@ void _start(uintptr_t info[]) {
|
| grok_auxv(auxv);
|
| DO_QUERY(NACL_IRT_BASIC_v0_1, __libnacl_irt_basic);
|
| DO_QUERY(NACL_IRT_RANDOM_v0_1, __libnacl_irt_random);
|
| + DO_QUERY(NACL_IRT_EXCEPTION_HANDLING_v0_1, __libnacl_irt_exception_handling);
|
|
|
| struct nacl_irt_ppapihook ppapihook;
|
| DO_QUERY(NACL_IRT_PPAPIHOOK_v0_1, ppapihook);
|
|
|