2008-03-05 09:52:00 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// log.cpp - Extension to find parse Singularity trace log.
|
|
|
|
//
|
2008-11-17 18:29:00 -05:00
|
|
|
// Copyright Microsoft Corporation. All rights reserved.
|
2008-03-05 09:52:00 -05:00
|
|
|
//
|
|
|
|
#include "singx86.h"
|
|
|
|
|
|
|
|
HRESULT FindBound(const char *symbol, ULONG64 *ptrval)
|
|
|
|
{
|
|
|
|
HRESULT status = S_OK;
|
|
|
|
ULONG64 address;
|
|
|
|
|
|
|
|
EXT_CHECK(g_ExtSymbols->GetOffsetByName(symbol, &address));
|
|
|
|
EXT_CHECK(g_ExtData->ReadPointersVirtual(1, address, ptrval));
|
|
|
|
|
|
|
|
Exit:
|
2008-11-17 18:29:00 -05:00
|
|
|
ExtVerb("Find(%s) = %p\n", symbol, *ptrval);
|
2008-03-05 09:52:00 -05:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT SetBound(const char *symbol, ULONG64 ptrval)
|
|
|
|
{
|
|
|
|
HRESULT status = S_OK;
|
|
|
|
ULONG64 address;
|
|
|
|
|
|
|
|
EXT_CHECK(g_ExtSymbols->GetOffsetByName(symbol, &address));
|
|
|
|
EXT_CHECK(g_ExtData->WritePointersVirtual(1, address, &ptrval));
|
|
|
|
Exit:
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2008-11-17 18:29:00 -05:00
|
|
|
ULONG64 GetValue(PCSTR& args, bool fHex)
|
2008-03-05 09:52:00 -05:00
|
|
|
{
|
|
|
|
ULONG base = fHex ? 16 : 10;
|
|
|
|
if (*args == '0') {
|
|
|
|
fHex = true;
|
|
|
|
base = 16;
|
|
|
|
}
|
|
|
|
ULONG64 value = 0;
|
|
|
|
|
|
|
|
while (*args && *args != ' ' && *args != '\t') {
|
|
|
|
if (*args >= '0' && *args <= '9') {
|
|
|
|
value = value * base + (*args++ - '0');
|
|
|
|
}
|
|
|
|
else if (*args >= 'A' && *args <= 'F' && fHex) {
|
|
|
|
value = value * base + (*args++ - 'A') + 10;
|
|
|
|
}
|
|
|
|
else if (*args >= 'a' && *args <= 'f' && fHex) {
|
|
|
|
value = value * base + (*args++ - 'a') + 10;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXT_DECL(log) // Defines: PDEBUG_CLIENT Client, PCSTR args
|
|
|
|
{
|
|
|
|
EXT_ENTER(); // Defines: HRESULT status = S_OK;
|
|
|
|
|
2008-11-17 18:29:00 -05:00
|
|
|
//
|
|
|
|
// Try the new diag too. The code above will become obsolete when the old tracing is completly
|
|
|
|
// removed
|
|
|
|
//
|
2008-03-05 09:52:00 -05:00
|
|
|
|
2008-11-17 18:29:00 -05:00
|
|
|
const char * defaultCommand = "!diagnose -s LegacyTracing -t System.LEGACY_LOG_ENTRY -l IP "
|
|
|
|
"-y Msg -r Size|LinkOffset|Flags|Type|arg0|arg1|arg2|arg3|arg4|arg5|StrArg0|StrArg1 %s";
|
2008-03-05 09:52:00 -05:00
|
|
|
|
|
|
|
|
2008-11-17 18:29:00 -05:00
|
|
|
CHAR command[512];
|
|
|
|
_snprintf(command, sizeof(command), defaultCommand, args);
|
2008-03-05 09:52:00 -05:00
|
|
|
|
2008-11-17 18:29:00 -05:00
|
|
|
status = g_ExtControl->Execute(DEBUG_OUTCTL_ALL_CLIENTS |
|
|
|
|
DEBUG_OUTCTL_OVERRIDE_MASK |
|
|
|
|
DEBUG_OUTCTL_NOT_LOGGED,
|
|
|
|
command,
|
|
|
|
DEBUG_EXECUTE_DEFAULT );
|
2008-03-05 09:52:00 -05:00
|
|
|
|
|
|
|
EXT_LEAVE(); // Macro includes: return status;
|
|
|
|
}
|
2008-11-17 18:29:00 -05:00
|
|
|
|