mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1172157 - Save malformed profile JSON to file to help debug. (r=BenWa)
This commit is contained in:
parent
0bd78f32c5
commit
58b59acb1b
@ -220,8 +220,33 @@ JSObject* TableTicker::ToJSObject(JSContext *aCx, float aSinceTime)
|
||||
{
|
||||
UniquePtr<char[]> buf = ToJSON(aSinceTime);
|
||||
NS_ConvertUTF8toUTF16 js_string(nsDependentCString(buf.get()));
|
||||
MOZ_ALWAYS_TRUE(JS_ParseJSON(aCx, static_cast<const char16_t*>(js_string.get()),
|
||||
js_string.Length(), &val));
|
||||
bool rv = JS_ParseJSON(aCx, static_cast<const char16_t*>(js_string.get()),
|
||||
js_string.Length(), &val);
|
||||
if (!rv) {
|
||||
#ifdef NIGHTLY_BUILD
|
||||
// XXXshu: Temporary code to help debug malformed JSON. See bug 1172157.
|
||||
nsCOMPtr<nsIFile> path;
|
||||
nsresult rv = NS_GetSpecialDirectory("TmpD", getter_AddRefs(path));
|
||||
if (!NS_FAILED(rv)) {
|
||||
rv = path->Append(NS_LITERAL_STRING("bad-profile.json"));
|
||||
if (!NS_FAILED(rv)) {
|
||||
nsCString cpath;
|
||||
rv = path->GetNativePath(cpath);
|
||||
if (!NS_FAILED(rv)) {
|
||||
std::ofstream stream;
|
||||
stream.open(cpath.get());
|
||||
if (stream.is_open()) {
|
||||
stream << buf.get();
|
||||
stream.close();
|
||||
printf_stderr("Malformed profiler JSON dumped to %s! "
|
||||
"Please upload to https://bugzil.la/1172157\n",
|
||||
cpath.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return &val.toObject();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user