1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_IntentionalCrash_h
8 #define mozilla_IntentionalCrash_h
17 # define getpid _getpid
24 inline void NoteIntentionalCrash(const char* aProcessType
) {
25 // In opt builds we don't actually have the leak checking enabled, and the
26 // sandbox doesn't allow writing to this path, so we just disable this
27 // function's behaviour.
29 char* f
= getenv("XPCOM_MEM_BLOAT_LOG");
34 fprintf(stderr
, "XPCOM_MEM_BLOAT_LOG: %s\n", f
);
36 std::ostringstream bloatName
;
37 std::string
processType(aProcessType
);
38 if (!processType
.compare("default")) {
41 std::string
bloatLog(f
);
44 if (bloatLog
.size() >= 4 &&
45 bloatLog
.compare(bloatLog
.size() - 4, 4, ".log", 4) == 0) {
47 bloatLog
.erase(bloatLog
.size() - 4, 4);
50 bloatName
<< bloatLog
<< "_" << processType
<< "_pid" << getpid();
56 fprintf(stderr
, "Writing to log: %s\n", bloatName
.str().c_str());
58 FILE* processfd
= fopen(bloatName
.str().c_str(), "a");
60 fprintf(processfd
, "==> process %d will purposefully crash\n", getpid());
66 } // namespace mozilla
68 #endif // mozilla_IntentionalCrash_h