creport: dump tls/name on crash (closes #310)
This commit is contained in:
@@ -13,12 +13,13 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <switch.h>
|
||||
#include <stratosphere.hpp>
|
||||
#include <cstdio>
|
||||
#include <map>
|
||||
|
||||
#include "creport_debug_types.hpp"
|
||||
#include "creport_thread_info.hpp"
|
||||
@@ -29,63 +30,67 @@ class CrashReport {
|
||||
Handle debug_handle = INVALID_HANDLE;
|
||||
bool has_extra_info;
|
||||
Result result = ResultCreportIncompleteReport;
|
||||
|
||||
/* Attach Process Info. */
|
||||
|
||||
/* Attach Process Info. */
|
||||
AttachProcessInfo process_info{};
|
||||
u64 dying_message_address = 0;
|
||||
u64 dying_message_size = 0;
|
||||
u8 dying_message[0x1000]{};
|
||||
|
||||
|
||||
static_assert(sizeof(dying_message) == 0x1000, "Incorrect definition for dying message!");
|
||||
|
||||
|
||||
/* Exception Info. */
|
||||
ExceptionInfo exception_info{};
|
||||
u64 crashed_thread_id = 0;
|
||||
ThreadInfo crashed_thread_info;
|
||||
|
||||
|
||||
/* Extra Info. */
|
||||
CodeList code_list;
|
||||
ThreadList thread_list;
|
||||
|
||||
|
||||
/* Meta, used for building list. */
|
||||
std::map<u64, u64> thread_tls_map;
|
||||
|
||||
public:
|
||||
void BuildReport(u64 pid, bool has_extra_info);
|
||||
FatalContext *GetFatalContext();
|
||||
void SaveReport();
|
||||
|
||||
|
||||
bool IsAddressReadable(u64 address, u64 size, MemoryInfo *mi = NULL);
|
||||
|
||||
|
||||
static void Memdump(FILE *f, const char *prefix, const void *data, size_t size);
|
||||
|
||||
|
||||
Result GetResult() {
|
||||
return this->result;
|
||||
}
|
||||
|
||||
|
||||
bool WasSuccessful() {
|
||||
return this->result != ResultCreportIncompleteReport;
|
||||
}
|
||||
|
||||
|
||||
bool OpenProcess(u64 pid) {
|
||||
return R_SUCCEEDED(svcDebugActiveProcess(&debug_handle, pid));
|
||||
}
|
||||
|
||||
|
||||
bool IsOpen() {
|
||||
return this->debug_handle != INVALID_HANDLE;
|
||||
}
|
||||
|
||||
|
||||
void Close() {
|
||||
if (IsOpen()) {
|
||||
svcCloseHandle(debug_handle);
|
||||
debug_handle = INVALID_HANDLE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool IsApplication() {
|
||||
return (process_info.flags & 0x40) != 0;
|
||||
}
|
||||
|
||||
|
||||
bool Is64Bit() {
|
||||
return (process_info.flags & 0x01) != 0;
|
||||
}
|
||||
|
||||
|
||||
bool IsUserBreak() {
|
||||
return this->exception_info.type == DebugExceptionType::UserBreak;
|
||||
}
|
||||
@@ -94,9 +99,10 @@ class CrashReport {
|
||||
void ProcessDyingMessage();
|
||||
void HandleAttachProcess(DebugEventInfo &d);
|
||||
void HandleException(DebugEventInfo &d);
|
||||
|
||||
void HandleAttachThread(DebugEventInfo &d);
|
||||
|
||||
void SaveToFile(FILE *f);
|
||||
|
||||
|
||||
void EnsureReportDirectories();
|
||||
bool GetCurrentTime(u64 *out);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user