mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Add time and app version to crash report
This commit is contained in:
parent
1470fd3f9f
commit
848a84e3f5
5 changed files with 93 additions and 23 deletions
|
@ -125,6 +125,7 @@
|
|||
<ItemGroup>
|
||||
<ClInclude Include="Bookmarks.h" />
|
||||
<ClInclude Include="Devtools\Client.h" />
|
||||
<ClInclude Include="ServoControl\Crash.h" />
|
||||
<ClInclude Include="ServoControl\Keys.h" />
|
||||
<ClInclude Include="strutils.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
|
@ -974,6 +975,7 @@
|
|||
<DependentUpon>BrowserPage.xaml</DependentUpon>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
|
||||
<ClCompile Include="ServoControl\Crash.cpp" />
|
||||
<ClCompile Include="ServoControl\OpenGLES.cpp" />
|
||||
<ClCompile Include="ServoControl\Servo.cpp" />
|
||||
<ClCompile Include="ServoControl\ServoControl.cpp" />
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
<Filter>Devtools</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Bookmarks.cpp" />
|
||||
<ClCompile Include="ServoControl\Crash.cpp">
|
||||
<Filter>ServoControl</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="pch.h" />
|
||||
|
@ -48,6 +51,9 @@
|
|||
<Filter>ServoControl</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Bookmarks.h" />
|
||||
<ClInclude Include="ServoControl\Crash.h">
|
||||
<Filter>ServoControl</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="Assets\Wide310x150Logo.scale-200.png">
|
||||
|
|
60
support/hololens/ServoApp/ServoControl/Crash.cpp
Normal file
60
support/hololens/ServoApp/ServoControl/Crash.cpp
Normal file
|
@ -0,0 +1,60 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "pch.h"
|
||||
#include "Crash.h"
|
||||
#include <chrono>
|
||||
#include <ctime>
|
||||
#include "Servo.h"
|
||||
|
||||
namespace winrt::servo {
|
||||
|
||||
using namespace Windows::Storage;
|
||||
|
||||
void WriteSection(StorageFile const &file, hstring section, hstring content) {
|
||||
hstring title{format(L"\r\n--- %s ---\r\n", section.c_str())};
|
||||
FileIO::AppendTextAsync(file, title).get();
|
||||
FileIO::AppendTextAsync(file, content).get();
|
||||
}
|
||||
|
||||
void WriteCrashReport(hstring contentBacktrack, hstring contentUrl) {
|
||||
// Making all sync operations sync, as we are crashing.
|
||||
auto storageFolder = ApplicationData::Current().LocalFolder();
|
||||
auto fd = storageFolder
|
||||
.CreateFileAsync(L"crash-report.txt",
|
||||
CreationCollisionOption::ReplaceExisting)
|
||||
.get();
|
||||
FileIO::WriteTextAsync(fd, L"").get();
|
||||
|
||||
// Stdout
|
||||
auto stdout_txt = storageFolder.GetFileAsync(L"stdout.txt").get();
|
||||
auto contentStdout = FileIO::ReadTextAsync(stdout_txt).get();
|
||||
|
||||
// Crash time
|
||||
char cTime[70];
|
||||
auto crash_time = std::chrono::system_clock::now();
|
||||
auto now_c = std::chrono::system_clock::to_time_t(crash_time);
|
||||
std::tm now_tm;
|
||||
localtime_s(&now_tm, &now_c);
|
||||
strftime(cTime, sizeof cTime, "%FT%T%z", &now_tm);
|
||||
auto contentTime = char2hstring(cTime);
|
||||
|
||||
// App + servo version
|
||||
auto pkg = winrt::Windows::ApplicationModel::Package::Current();
|
||||
auto v = pkg.Id().Version();
|
||||
auto servo_version = char2hstring(capi::servo_version());
|
||||
hstring contentVersion{format(L"%i.%i.%i.%i (%s)", v.Major, v.Minor, v.Build,
|
||||
v.Revision, servo_version.c_str())};
|
||||
|
||||
WriteSection(fd, L"CUSTOM MESSAGE",
|
||||
L"Feel free to add details here before reporting");
|
||||
WriteSection(fd, L"CURRENT URL (remove if sensitive)", contentUrl);
|
||||
WriteSection(fd, L"CRASH TIME", contentTime);
|
||||
WriteSection(fd, L"VERSION", contentVersion);
|
||||
WriteSection(fd, L"BACKTRACE", contentBacktrack);
|
||||
WriteSection(fd, L"STDOUT", contentStdout);
|
||||
FileIO::AppendTextAsync(fd, L"\r\n").get();
|
||||
}
|
||||
|
||||
} // namespace winrt::servo
|
15
support/hololens/ServoApp/ServoControl/Crash.h
Normal file
15
support/hololens/ServoApp/ServoControl/Crash.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "pch.h"
|
||||
#include "strutils.h"
|
||||
|
||||
namespace winrt::servo {
|
||||
|
||||
void WriteCrashReport(hstring backtrace, hstring url);
|
||||
|
||||
} // namespace winrt::servo
|
|
@ -1,5 +1,10 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "pch.h"
|
||||
#include "Servo.h"
|
||||
#include "Crash.h"
|
||||
#include <EGL/egl.h>
|
||||
#include "../DefaultUrl.h"
|
||||
|
||||
|
@ -27,7 +32,10 @@ void on_url_changed(const char *curl) {
|
|||
sServo->Delegate().OnServoURLChanged(url);
|
||||
}
|
||||
|
||||
void wakeup() { sServo->Delegate().WakeUp(); }
|
||||
void wakeup() {
|
||||
if (sServo != nullptr)
|
||||
sServo->Delegate().WakeUp();
|
||||
}
|
||||
|
||||
bool on_allow_navigation(const char *url) {
|
||||
return sServo->Delegate().OnServoAllowNavigation(char2hstring(url));
|
||||
|
@ -47,28 +55,7 @@ void on_panic(const char *cbacktrace) {
|
|||
auto backtrace = char2hstring(cbacktrace);
|
||||
|
||||
try {
|
||||
// Making all sync operations sync, as we are crashing.
|
||||
auto storageFolder = ApplicationData::Current().LocalFolder();
|
||||
auto stdout_txt = storageFolder.GetFileAsync(L"stdout.txt").get();
|
||||
auto crash_txt =
|
||||
storageFolder
|
||||
.CreateFileAsync(L"crash-report.txt",
|
||||
CreationCollisionOption::ReplaceExisting)
|
||||
.get();
|
||||
auto out = FileIO::ReadTextAsync(stdout_txt).get();
|
||||
FileIO::WriteTextAsync(crash_txt, L"--- CUSTOM MESSAGE ---\r\n").get();
|
||||
FileIO::AppendTextAsync(crash_txt,
|
||||
L"Feel free to add details here before reporting")
|
||||
.get();
|
||||
FileIO::AppendTextAsync(
|
||||
crash_txt, L"\r\n--- CURRENT URL (remove if sensitive) ---\r\n")
|
||||
.get();
|
||||
FileIO::AppendTextAsync(crash_txt, sServo->CurrentUrl()).get();
|
||||
FileIO::AppendTextAsync(crash_txt, L"\r\n--- BACKTRACE ---\r\n").get();
|
||||
FileIO::AppendTextAsync(crash_txt, backtrace).get();
|
||||
FileIO::AppendTextAsync(crash_txt, L"\r\n--- STDOUT ---\r\n").get();
|
||||
FileIO::AppendTextAsync(crash_txt, out).get();
|
||||
FileIO::AppendTextAsync(crash_txt, L"\r\n").get();
|
||||
WriteCrashReport(backtrace, sServo->CurrentUrl());
|
||||
} catch (...) {
|
||||
log(L"Failed to log panic to crash report");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue