mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-15 11:33:32 +01:00
creport: minor reformatting/fixes
This commit is contained in:
parent
40c6733de3
commit
2181adb82b
@ -301,7 +301,7 @@ namespace ams::creport {
|
||||
}
|
||||
|
||||
void CrashReport::SaveToFile(ScopedFile &file) {
|
||||
file.WriteFormat("Atmosphère Crash Report (v1.5):\n");
|
||||
file.WriteFormat(u8"Atmosphère Crash Report (v1.5):\n");
|
||||
file.WriteFormat("Result: 0x%X (2%03d-%04d)\n\n", this->result.GetValue(), this->result.GetModule(), this->result.GetDescription());
|
||||
|
||||
/* Process Info. */
|
||||
@ -360,7 +360,7 @@ namespace ams::creport {
|
||||
this->module_list.SaveToFile(file);
|
||||
|
||||
/* Thread Info. */
|
||||
file.WriteFormat("\nThread Report:\n");
|
||||
file.WriteFormat("Thread Report:\n");
|
||||
this->thread_list.SaveToFile(file);
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ namespace ams::creport {
|
||||
if (std::strcmp(this->modules[i].name, "") != 0) {
|
||||
file.WriteFormat(" Name: %s\n", module.name);
|
||||
}
|
||||
file.DumpMemory(" Build Id: ", module.build_id, sizeof(module.build_id));
|
||||
file.DumpMemory(" Build Id: ", &module.build_id[0], sizeof(module.build_id));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,10 @@ namespace ams::creport {
|
||||
|
||||
}
|
||||
|
||||
void ScopedFile::WriteString(const char *str) {
|
||||
this->Write(str, std::strlen(str));
|
||||
}
|
||||
|
||||
void ScopedFile::WriteFormat(const char *fmt, ...) {
|
||||
/* Acquire exclusive access to the format buffer. */
|
||||
std::scoped_lock lk(g_format_lock);
|
||||
@ -40,13 +44,13 @@ namespace ams::creport {
|
||||
}
|
||||
|
||||
/* Write data. */
|
||||
this->Write(g_format_buffer, std::strlen(g_format_buffer));
|
||||
this->WriteString(g_format_buffer);
|
||||
}
|
||||
|
||||
void ScopedFile::DumpMemory(const char *prefix, const void *data, size_t size) {
|
||||
const u8 *data_u8 = reinterpret_cast<const u8 *>(data);
|
||||
const int prefix_len = std::strlen(prefix);
|
||||
size_t offset = 0;
|
||||
size_t data_ofs = 0;
|
||||
size_t remaining = size;
|
||||
bool first = true;
|
||||
|
||||
@ -63,14 +67,14 @@ namespace ams::creport {
|
||||
|
||||
/* Dump up to 0x20 of hex memory. */
|
||||
{
|
||||
char hex[MaximumLineLength * 2 + 2];
|
||||
char hex[MaximumLineLength * 2 + 2] = {};
|
||||
for (size_t i = 0; i < cur_size; i++) {
|
||||
std::snprintf(hex + i * 2, 3, "%02X", data_u8[offset++]);
|
||||
std::snprintf(hex + i * 2, 3, "%02X", data_u8[data_ofs++]);
|
||||
}
|
||||
hex[cur_size * 2 + 0] = '\n';
|
||||
hex[cur_size * 2 + 1] = '\x00';
|
||||
|
||||
this->Write(hex, std::strlen(hex));
|
||||
this->WriteString(hex);
|
||||
}
|
||||
|
||||
/* Continue. */
|
||||
@ -85,7 +89,7 @@ namespace ams::creport {
|
||||
}
|
||||
|
||||
/* Advance, if we write successfully. */
|
||||
if (R_SUCCEEDED(fs::WriteFile(this->file, this->offset, g_format_buffer, size, fs::WriteOption::Flush))) {
|
||||
if (R_SUCCEEDED(fs::WriteFile(this->file, this->offset, data, size, fs::WriteOption::Flush))) {
|
||||
this->offset += size;
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ namespace ams::creport {
|
||||
return this->opened;
|
||||
}
|
||||
|
||||
void WriteString(const char *str);
|
||||
void WriteFormat(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
|
||||
void DumpMemory(const char *prefix, const void *data, size_t size);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user