[*] Preparing to work on extending the console api and telemetry subsystems

This commit is contained in:
Reece Wilson 2022-01-21 16:26:35 +00:00
parent d23c04b4cd
commit ac467734a0
15 changed files with 99 additions and 36 deletions

View File

@ -38,6 +38,7 @@ namespace Aurora::Telemetry
struct NewBlockBoxEntryStackReport
{
Debug::StackTrace backtrace;
AuUInt32 fenceId;
};
struct NewBlackboxEntryUpdateMapEntry
@ -73,6 +74,7 @@ namespace Aurora::Telemetry
{
NewBlockBoxEntryStackReport stack;
AuString str;
AuUInt32 fenceId;
};
struct NewBlockboxEntryBasicMessage
@ -124,7 +126,9 @@ namespace Aurora::Telemetry
Aurora::HWInfo::CpuInfo cpuInfo;
Aurora::HWInfo::RamStat sysMem;
Aurora::HWInfo::RamStat procMem;
Aurora::HWInfo::RamStat ramMem;
Aurora::HWInfo::RamStat procCommitMem;
Aurora::HWInfo::RamStat procLowerMem;
};
struct NewBlackBoxEntryReportApplication

View File

View File

View File

View File

View File

@ -15,6 +15,8 @@
namespace Aurora::Debug
{
static thread_local AuUInt32 tlsLastBackTrace = 0xFFFFFFFF;
static StackTrace gLastStackTrace;
static AuUInt32 gStackTraceFence;
static AuUInt32 gFenceId;
@ -170,18 +172,19 @@ namespace Aurora::Debug
return tempError;
}
void ReportStackTrace(const StackTrace& trace, const AuString& message)
AuUInt32 ReportStackTrace(const StackTrace& trace, const AuString& message)
{
AU_LOCK_GUARD(gLock);
gLastStackTrace = trace;
gLastExceptionMessage = message;
gStackTraceFence++;
tlsLastBackTrace = gStackTraceFence++;
gFenceId++;
return tlsLastBackTrace;
}
AuUInt32 GetFenceId()
{
return gFenceId;
return gFenceId++;
}
AUKN_SYM AuString GetLastErrorStack()
@ -210,36 +213,54 @@ namespace Aurora::Debug
{
AuUInt32 rng = GetFenceId();
Telemetry::InsertManualFence(rng);
static AuUInt32 cLastFence = 0;
auto cFence = GetCErrorFence();
auto cError = TryGetOrFetchCError();
if ((cError) && (cFence != cLastFence))
Telemetry::BeginBlock();
try
{
LogWarn("Language Error: {} ({})", strerror(*cError), *cError);
cLastFence = cFence;
}
static AuUInt32 osLastFence = 0;
auto osFence = GetOSErrorFence();
auto osError = TryGetOrFetchOSError();
if ((osError) && (osFence != osLastFence))
{
LogWarn("Operating System Error: {} (0x{:x})", osError->second, osError->first);
osLastFence = osFence;
}
Telemetry::InsertManualFence(rng);
Telemetry::InsertManualFence(rng);
static AuUInt32 cLastFence = 0;
auto cFence = GetCErrorFence();
auto cError = TryGetOrFetchCError();
if ((cError) && (cFence != cLastFence))
{
LogWarn("Language Error: {} ({})", strerror(*cError), *cError);
cLastFence = cFence;
}
static AuUInt32 osLastFence = 0;
auto osFence = GetOSErrorFence();
auto osError = TryGetOrFetchOSError();
if ((osError) && (osFence != osLastFence))
{
LogWarn("Operating System Error: {} (0x{:x})", osError->second, osError->first);
osLastFence = osFence;
}
Telemetry::InsertBackTrace(tlsLastBackTrace);
Telemetry::InsertManualFence(rng);
}
catch (...)
{
}
Telemetry::EndBlock();
}
void CheckErrors()
{
AuUInt32 rng = GetFenceId();
Telemetry::InsertManualFence(rng);
TryGetOrFetchCError();
TryGetOrFetchOSError();
Telemetry::InsertManualFence(rng);
Telemetry::BeginBlock();
try
{
Telemetry::InsertManualFence(rng);
TryGetOrFetchCError();
TryGetOrFetchOSError();
Telemetry::InsertBackTrace(tlsLastBackTrace);
Telemetry::InsertManualFence(rng);
}
catch (...)
{
}
Telemetry::EndBlock();
}
AUKN_SYM void _PushError(AuUInt address, EFailureCategory category, const char *msg)
@ -253,11 +274,21 @@ namespace Aurora::Debug
// Cry about it to telemetry with other errors if available
AuUInt32 rng = GetFenceId();
Telemetry::InsertManualFence(rng);
Telemetry::InsertMsgError(error);
TryGetOrFetchCError();
TryGetOrFetchOSError();
Telemetry::InsertManualFence(rng);
Telemetry::BeginBlock();
try
{
Telemetry::InsertManualFence(rng);
Telemetry::InsertMsgError(error);
TryGetOrFetchCError();
TryGetOrFetchOSError();
Telemetry::InsertBackTrace(tlsLastBackTrace);
Telemetry::InsertManualFence(rng);
}
catch (...)
{
}
Telemetry::EndBlock();
// Is anyone listening?
// Print to console if internal

View File

@ -24,7 +24,7 @@ namespace Aurora::Debug
AuOptional<AuUInt32> TryGetOrFetchCError();
void ReportStackTrace(const StackTrace &trace, const AuString &message);
AuUInt32 ReportStackTrace(const StackTrace &trace, const AuString &message);
AuOptional<OSError_t> TryFetchOSError();

View File

@ -326,7 +326,7 @@ namespace Aurora::Debug
}
ReportStackTrace(entry.wincxx.stack.backtrace, entry.wincxx.str);
entry.wincxx.fenceId = ReportStackTrace(entry.wincxx.stack.backtrace, entry.wincxx.str);
#if defined(STAGING) || defined(DEBUG)
bool isInternal = true;

View File

@ -17,6 +17,7 @@ namespace Aurora::Processes
{
static void UnixOpenAsync(const AuString &open)
{
// TODO: mac os is special
if (fork() == 0)
{
setsid();

View File

@ -11,6 +11,18 @@
namespace Aurora::Telemetry
{
static AuThreadPrimitives::CriticalSectionUnique_t gGroupLock;
void BeginBlock()
{
gGroupLock->Lock();
}
void EndBlock()
{
gGroupLock->Unlock();
}
void InsertOSError(const Debug::OSError_t &osError)
{
@ -30,7 +42,12 @@ namespace Aurora::Telemetry
{
}
void InsertBackTrace(AuUInt32 fence)
{
}
void Report(Telemetry::NewBlockboxEntry &entry)
{

View File

@ -12,7 +12,10 @@ namespace Aurora::Telemetry
void InsertOSError(const Debug::OSError_t &osError);
void InsertMsgError(const Debug::LastError &error);
void InsertCError(AuSInt cError);
void BeginBlock();
void EndBlock();
void InsertManualFence(AuUInt32 fence);
void InsertBackTrace(AuUInt32 fence);
void ReportSysInfo();
void Report(Telemetry::NewBlockboxEntry &entry);
void Init();

View File

@ -409,7 +409,14 @@ namespace Aurora::Threading::Threads
this->tlsReferenceThread_ = osThread;
OSAttach();
task_();
try
{
task_();
}
catch (...)
{
SysPushErrorHAL("OS Thread Aborted");
}
Exit(true);
}