Rename Crash() to IntentionalCrash() so that automation can grep for it. Make it non-static, and add trailing instructions to it so that it isn't inlined nor tail-called away in crash reports.
authorBenjamin Smedberg <benjamin@smedbergs.us>
Mon, 25 Jan 2010 17:26:23 -0500
changeset 46580 d75295d1fd14f3f05603330b513f9eabe4a7a74a
parent 46579 76bf173816e84d230652bb88d39f2d9f20b1be8a
child 46581 d87a958aab73dcb4998f334bce6b22092113f7cf
push idunknown
push userunknown
push dateunknown
milestone1.9.3a1pre
Rename Crash() to IntentionalCrash() so that automation can grep for it. Make it non-static, and add trailing instructions to it so that it isn't inlined nor tail-called away in crash reports.
modules/plugin/test/testplugin/nptest.cpp
--- a/modules/plugin/test/testplugin/nptest.cpp
+++ b/modules/plugin/test/testplugin/nptest.cpp
@@ -59,18 +59,20 @@
 #define PLUGIN_VERSION     "1.0.0.0"
 
 #define ARRAY_LENGTH(a) (sizeof(a)/sizeof(a[0]))
 
 //
 // Intentional crash
 //
 
-static void
-Crash()
+int gCrashCount = 0;
+
+void
+IntentionalCrash()
 {
   char* bloatLog = getenv("XPCOM_MEM_BLOAT_LOG");
   if (bloatLog) {
     char* logExt = strstr(bloatLog, ".log");
     if (logExt) {
       bloatLog[strlen(bloatLog) - strlen(logExt)] = '\0';
     }
     ostringstream bloatName;
@@ -79,16 +81,17 @@ Crash()
       bloatName << ".log";
     }
     FILE* processfd = fopen(bloatName.str().c_str(), "a");
     fprintf(processfd, "==> process %d will purposefully crash\n", getpid());
     fclose(processfd);
   }
   void (*funcptr)() = NULL;
   funcptr(); // Crash calling null function pointer
+  ++gCrashCount;
 }
 
 //
 // static data
 //
 
 static NPNetscapeFuncs* sBrowserFuncs = NULL;
 static NPClass sNPClass;
@@ -670,17 +673,17 @@ NPP_New(NPMIMEType pluginType, NPP insta
       }
       if (range.length()) addRange(instanceData, range.c_str());
     }
     if (strcmp(argn[i], "newstream") == 0 &&
         strcmp(argv[i], "true") == 0) {
       instanceData->npnNewStream = true;
     }
     if (strcmp(argn[i], "newcrash") == 0) {
-      Crash();
+      IntentionalCrash();
     }
   }
 
   if (!browserSupportsWindowless || !pluginSupportsWindowlessMode()) {
     requestWindow = true;
   } else if (!pluginSupportsWindowMode()) {
     requestWindow = false;
   }
@@ -753,17 +756,17 @@ NPP_New(NPMIMEType pluginType, NPP insta
 
 NPError
 NPP_Destroy(NPP instance, NPSavedData** save)
 {
   printf("NPP_Destroy\n");
   InstanceData* instanceData = (InstanceData*)(instance->pdata);
 
   if (instanceData->crashOnDestroy)
-    Crash();
+    IntentionalCrash();
 
   if (instanceData->streamBuf) {
     free(instanceData->streamBuf);
   }
   if (instanceData->fileBuf) {
     free(instanceData->fileBuf);
   }
 
@@ -2096,17 +2099,17 @@ streamTest(NPObject* npobj, const NPVari
   }
 
   return true;
 }
 
 static bool
 crashPlugin(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
 {
-  Crash();
+  IntentionalCrash();
   VOID_TO_NPVARIANT(*result);
   return true;
 }
 
 static bool
 crashOnDestroy(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
 {
   NPP npp = static_cast<TestNPObject*>(npobj)->npp;