Bug 572417 - Release mouse capture in flash subclass after mouse events get delivered...
[mozilla-central.git] / xpcom / glue / IntentionalCrash.h
blobd2768a63a6ef8fc008d8279cb975042703fb2d82
1 #include <string>
2 #include <sstream>
3 #include <stdlib.h>
4 #include <stdio.h>
6 #ifdef XP_WIN
7 #include <process.h>
8 #define getpid _getpid
9 #else
10 #include <unistd.h>
11 #endif
13 #ifndef mozilla_IntentionalCrash_h
14 #define mozilla_IntentionalCrash_h
16 namespace mozilla {
18 inline void
19 NoteIntentionalCrash(const char* processType)
21 char* f = getenv("XPCOM_MEM_BLOAT_LOG");
22 fprintf(stderr, "XPCOM_MEM_BLOAT_LOG: %s\n", f);
23 if (!f)
24 return;
26 std::string bloatLog(f);
28 bool hasExt = false;
29 if (bloatLog.size() >= 4 &&
30 0 == bloatLog.compare(bloatLog.size() - 4, 4, ".log", 4)) {
31 hasExt = true;
32 bloatLog.erase(bloatLog.size() - 4, 4);
35 std::ostringstream bloatName;
36 bloatName << bloatLog << "_" << processType << "_pid" << getpid();
37 if (hasExt)
38 bloatName << ".log";
40 fprintf(stderr, "Writing to log: %s\n", bloatName.str().c_str());
42 FILE* processfd = fopen(bloatName.str().c_str(), "a");
43 fprintf(processfd, "==> process %d will purposefully crash\n", getpid());
44 fclose(processfd);
47 } // namespace mozilla
49 #endif // mozilla_IntentionalCrash_h