Add focused route result tracing
This commit is contained in:
@@ -105,6 +105,7 @@ constexpr bool kEnableGpsProviderClassPatch = false;
|
|||||||
constexpr bool kEnableGpsProviderClassPatchTrace = false;
|
constexpr bool kEnableGpsProviderClassPatchTrace = false;
|
||||||
constexpr bool kEnableGpsTraceHooks = true;
|
constexpr bool kEnableGpsTraceHooks = true;
|
||||||
constexpr bool kEnableGpsQueryLifecycleHooks = false;
|
constexpr bool kEnableGpsQueryLifecycleHooks = false;
|
||||||
|
constexpr bool kEnableGpsQueryResultTraceHooks = true;
|
||||||
constexpr bool kEnableGpsAsyncTrafficProbe = false;
|
constexpr bool kEnableGpsAsyncTrafficProbe = false;
|
||||||
constexpr bool kEnableGpsTrafficEdgeWeightPatch = false;
|
constexpr bool kEnableGpsTrafficEdgeWeightPatch = false;
|
||||||
constexpr bool kEnableGpsSpatialEdgeWeightPatch = true;
|
constexpr bool kEnableGpsSpatialEdgeWeightPatch = true;
|
||||||
@@ -3878,13 +3879,15 @@ int32_t DetourGpsQuerySubmit(void* aManager, void* aQuery)
|
|||||||
uintptr_t returnRva = 0;
|
uintptr_t returnRva = 0;
|
||||||
TryGetImageRva(returnAddress, returnRva);
|
TryGetImageRva(returnAddress, returnRva);
|
||||||
|
|
||||||
const auto callCount = gGpsQuerySubmitLogCount;
|
const auto callCount = gGpsQuerySubmitLogCount++;
|
||||||
const auto shouldLog = callCount < kMaxCalls;
|
|
||||||
uint32_t queryKind = 0;
|
uint32_t queryKind = 0;
|
||||||
const auto hasQueryKind = aQuery && TryReadMemory(reinterpret_cast<const void*>(reinterpret_cast<uintptr_t>(aQuery) + 0xCC),
|
const auto hasQueryKind = aQuery && TryReadMemory(reinterpret_cast<const void*>(reinterpret_cast<uintptr_t>(aQuery) + 0xCC),
|
||||||
queryKind);
|
queryKind);
|
||||||
const auto shouldTraceResolver =
|
const auto shouldTraceResolver =
|
||||||
returnRva == kGpsMapRouteSubmitReturnRva && hasQueryKind && queryKind == 5;
|
returnRva == kGpsMapRouteSubmitReturnRva && hasQueryKind && queryKind == 5;
|
||||||
|
const auto shouldLog =
|
||||||
|
callCount < kMaxCalls &&
|
||||||
|
(kEnableGpsQueryLifecycleHooks || (returnRva == kGpsMapRouteSubmitReturnRva && hasQueryKind && queryKind == 5));
|
||||||
if (shouldTraceResolver)
|
if (shouldTraceResolver)
|
||||||
{
|
{
|
||||||
ExtendGpsResolveTraceWindow(GetElapsedMs());
|
ExtendGpsResolveTraceWindow(GetElapsedMs());
|
||||||
@@ -3908,7 +3911,6 @@ int32_t DetourGpsQuerySubmit(void* aManager, void* aQuery)
|
|||||||
}
|
}
|
||||||
AppendReturnRva(line, returnAddress);
|
AppendReturnRva(line, returnAddress);
|
||||||
LogRed4ext(line.str());
|
LogRed4ext(line.str());
|
||||||
++gGpsQuerySubmitLogCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t result = -1;
|
int32_t result = -1;
|
||||||
@@ -3975,8 +3977,12 @@ bool DetourGpsQueryResultFetch(void* aManager, uint32_t aQueryId, void* aOutPath
|
|||||||
TrackedGpsQuery trackedQuery{};
|
TrackedGpsQuery trackedQuery{};
|
||||||
uint32_t perQueryCall = 0;
|
uint32_t perQueryCall = 0;
|
||||||
const auto isTracked = NoteTrackedGpsQueryResultFetch(aQueryId, aManager, trackedQuery, perQueryCall);
|
const auto isTracked = NoteTrackedGpsQueryResultFetch(aQueryId, aManager, trackedQuery, perQueryCall);
|
||||||
const auto shouldLog = (isTracked && (perQueryCall < kMaxTrackedSamplesPerQuery || result)) ||
|
const auto isMapRouteQuery = isTracked && trackedQuery.submitReturnRva == kGpsMapRouteSubmitReturnRva;
|
||||||
(!isTracked && callCount < kMaxUntrackedSamples && aQueryId < 2);
|
const auto shouldLog =
|
||||||
|
kEnableGpsQueryLifecycleHooks
|
||||||
|
? ((isTracked && (perQueryCall < kMaxTrackedSamplesPerQuery || result)) ||
|
||||||
|
(!isTracked && callCount < kMaxUntrackedSamples && aQueryId < 2))
|
||||||
|
: (result && isMapRouteQuery);
|
||||||
|
|
||||||
if (shouldLog)
|
if (shouldLog)
|
||||||
{
|
{
|
||||||
@@ -3992,7 +3998,7 @@ bool DetourGpsQueryResultFetch(void* aManager, uint32_t aQueryId, void* aOutPath
|
|||||||
AppendPointerWithRva(line, "outPath", aOutPath);
|
AppendPointerWithRva(line, "outPath", aOutPath);
|
||||||
AppendReturnRva(line, returnAddress);
|
AppendReturnRva(line, returnAddress);
|
||||||
AppendPathBufferSummary(line, "outPath", aOutPath);
|
AppendPathBufferSummary(line, "outPath", aOutPath);
|
||||||
if (result && isTracked && trackedQuery.submitReturnRva == 0x8D20D4)
|
if (result && isMapRouteQuery)
|
||||||
{
|
{
|
||||||
AppendGpsResultObjectSummary(line, "gpsResult", aOutPath);
|
AppendGpsResultObjectSummary(line, "gpsResult", aOutPath);
|
||||||
}
|
}
|
||||||
@@ -5180,15 +5186,21 @@ RED4EXT_C_EXPORT bool RED4EXT_CALL Main(RED4ext::v1::PluginHandle aHandle, RED4e
|
|||||||
AttachProbeHook("UpdateGPSQuery body 0x29bd254", kUpdateGpsQueryBodyRva,
|
AttachProbeHook("UpdateGPSQuery body 0x29bd254", kUpdateGpsQueryBodyRva,
|
||||||
reinterpret_cast<void*>(&DetourUpdateGpsQueryBody),
|
reinterpret_cast<void*>(&DetourUpdateGpsQueryBody),
|
||||||
reinterpret_cast<void**>(&gOriginalUpdateGpsQueryBody));
|
reinterpret_cast<void**>(&gOriginalUpdateGpsQueryBody));
|
||||||
|
}
|
||||||
|
if (kEnableGpsQueryLifecycleHooks || kEnableGpsQueryResultTraceHooks)
|
||||||
|
{
|
||||||
AttachProbeHook("GPSQuerySubmit 0x70a42c", kGpsQuerySubmitRva,
|
AttachProbeHook("GPSQuerySubmit 0x70a42c", kGpsQuerySubmitRva,
|
||||||
reinterpret_cast<void*>(&DetourGpsQuerySubmit),
|
reinterpret_cast<void*>(&DetourGpsQuerySubmit),
|
||||||
reinterpret_cast<void**>(&gOriginalGpsQuerySubmit));
|
reinterpret_cast<void**>(&gOriginalGpsQuerySubmit));
|
||||||
AttachProbeHook("GPSQueryDispatch 0x70a570", kGpsQueryDispatchRva,
|
|
||||||
reinterpret_cast<void*>(&DetourGpsQueryDispatch),
|
|
||||||
reinterpret_cast<void**>(&gOriginalGpsQueryDispatch));
|
|
||||||
AttachProbeHook("GPSQueryResultFetch 0x7094b8", kGpsQueryResultFetchRva,
|
AttachProbeHook("GPSQueryResultFetch 0x7094b8", kGpsQueryResultFetchRva,
|
||||||
reinterpret_cast<void*>(&DetourGpsQueryResultFetch),
|
reinterpret_cast<void*>(&DetourGpsQueryResultFetch),
|
||||||
reinterpret_cast<void**>(&gOriginalGpsQueryResultFetch));
|
reinterpret_cast<void**>(&gOriginalGpsQueryResultFetch));
|
||||||
|
}
|
||||||
|
if (kEnableGpsQueryLifecycleHooks)
|
||||||
|
{
|
||||||
|
AttachProbeHook("GPSQueryDispatch 0x70a570", kGpsQueryDispatchRva,
|
||||||
|
reinterpret_cast<void*>(&DetourGpsQueryDispatch),
|
||||||
|
reinterpret_cast<void**>(&gOriginalGpsQueryDispatch));
|
||||||
AttachProbeHook("GPSQueryStatus 0xaa5704", kGpsQueryStatusRva,
|
AttachProbeHook("GPSQueryStatus 0xaa5704", kGpsQueryStatusRva,
|
||||||
reinterpret_cast<void*>(&DetourGpsQueryStatus),
|
reinterpret_cast<void*>(&DetourGpsQueryStatus),
|
||||||
reinterpret_cast<void**>(&gOriginalGpsQueryStatus));
|
reinterpret_cast<void**>(&gOriginalGpsQueryStatus));
|
||||||
@@ -5395,9 +5407,15 @@ RED4EXT_C_EXPORT bool RED4EXT_CALL Main(RED4ext::v1::PluginHandle aHandle, RED4e
|
|||||||
{
|
{
|
||||||
DetachProbeHook("RunGPSQuery body 0x29bd128", kRunGpsQueryBodyRva);
|
DetachProbeHook("RunGPSQuery body 0x29bd128", kRunGpsQueryBodyRva);
|
||||||
DetachProbeHook("UpdateGPSQuery body 0x29bd254", kUpdateGpsQueryBodyRva);
|
DetachProbeHook("UpdateGPSQuery body 0x29bd254", kUpdateGpsQueryBodyRva);
|
||||||
|
}
|
||||||
|
if (kEnableGpsQueryLifecycleHooks || kEnableGpsQueryResultTraceHooks)
|
||||||
|
{
|
||||||
DetachProbeHook("GPSQuerySubmit 0x70a42c", kGpsQuerySubmitRva);
|
DetachProbeHook("GPSQuerySubmit 0x70a42c", kGpsQuerySubmitRva);
|
||||||
DetachProbeHook("GPSQueryDispatch 0x70a570", kGpsQueryDispatchRva);
|
|
||||||
DetachProbeHook("GPSQueryResultFetch 0x7094b8", kGpsQueryResultFetchRva);
|
DetachProbeHook("GPSQueryResultFetch 0x7094b8", kGpsQueryResultFetchRva);
|
||||||
|
}
|
||||||
|
if (kEnableGpsQueryLifecycleHooks)
|
||||||
|
{
|
||||||
|
DetachProbeHook("GPSQueryDispatch 0x70a570", kGpsQueryDispatchRva);
|
||||||
DetachProbeHook("GPSQueryStatus 0xaa5704", kGpsQueryStatusRva);
|
DetachProbeHook("GPSQueryStatus 0xaa5704", kGpsQueryStatusRva);
|
||||||
}
|
}
|
||||||
if (kEnableGpsAsyncTrafficProbe)
|
if (kEnableGpsAsyncTrafficProbe)
|
||||||
|
|||||||
Reference in New Issue
Block a user