Bug 714286 - Cycle collection log should be written to a place where the process can write to, and the name of the file should be printed to the error console; r=mccr8

This commit is contained in:
Ehsan Akhgari 2012-01-01 17:34:00 -05:00
Родитель e930085622
Коммит 33bd17221a
1 изменённых файлов: 16 добавлений и 2 удалений

Просмотреть файл

@ -156,6 +156,7 @@
#include "nsIJSRuntimeService.h"
#include "nsIMemoryReporter.h"
#include "xpcpublic.h"
#include "nsXPCOMPrivate.h"
#include <stdio.h>
#include <string.h>
#ifdef WIN32
@ -1386,10 +1387,23 @@ public:
NS_IMETHOD Begin()
{
char name[255];
sprintf(name, "cc-edges-%d.%d.log", ++gLogCounter, base::GetCurrentProcId());
char name[MAXPATHLEN] = {'\0'};
tmpnam(name);
char *lastSlash = strrchr(name, XPCOM_FILE_PATH_SEPARATOR[0]);
if (lastSlash) {
*lastSlash = '\0';
}
sprintf(name, "%s%scc-edges-%d.%d.log", name,
XPCOM_FILE_PATH_SEPARATOR,
++gLogCounter, base::GetCurrentProcId());
mStream = fopen(name, "w");
nsCOMPtr<nsIConsoleService> cs =
do_GetService(NS_CONSOLESERVICE_CONTRACTID);
if (cs) {
cs->LogStringMessage(NS_ConvertUTF8toUTF16(name).get());
}
return mStream ? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHOD NoteRefCountedObject(PRUint64 aAddress, PRUint32 refCount,