src/diagnostics_dump.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /** | ||
| 2 | * @file diagnostics_dump.cpp | ||
| 3 | * @brief Aggregates DMK's runtime diagnostics into a single Snapshot. | ||
| 4 | */ | ||
| 5 | |||
| 6 | #include "DetourModKit/diagnostics_dump.hpp" | ||
| 7 | |||
| 8 | #include <cstddef> | ||
| 9 | #include <unordered_map> | ||
| 10 | |||
| 11 | namespace DetourModKit | ||
| 12 | { | ||
| 13 | namespace Diagnostics | ||
| 14 | { | ||
| 15 | 5 | Snapshot collect(const HookManager &hooks, std::span<const Anchors::ResolvedAnchor> anchor_report, | |
| 16 | std::span<const Rtti::DriftEntry> drift_report) | ||
| 17 | { | ||
| 18 | 5 | Snapshot snapshot; | |
| 19 | |||
| 20 |
2/2✓ Branch 8 → 3 taken 40 times.
✓ Branch 8 → 9 taken 5 times.
|
50 | for (std::size_t i = 0; i < snapshot.intentional_leaks.size(); ++i) |
| 21 | { | ||
| 22 | 40 | snapshot.intentional_leaks[i] = intentional_leak_count(static_cast<LeakSubsystem>(i)); | |
| 23 | } | ||
| 24 | 5 | snapshot.total_intentional_leaks = total_intentional_leaks(); | |
| 25 | |||
| 26 | // get_hook_counts() reports only the inline + mid registry (VMT hooks are tracked separately). Sum every | ||
| 27 | // status for the total so a transient Enabling / Disabling hook is still counted, and pull out the two | ||
| 28 | // steady states callers care about. | ||
| 29 |
1/2✓ Branch 10 → 11 taken 5 times.
✗ Branch 10 → 46 not taken.
|
5 | const std::unordered_map<HookStatus, std::size_t> hook_counts = hooks.get_hook_counts(); |
| 30 |
2/2✓ Branch 22 → 13 taken 10 times.
✓ Branch 22 → 23 taken 5 times.
|
15 | for (const auto &[status, count] : hook_counts) |
| 31 | { | ||
| 32 | 10 | snapshot.hooks_total += count; | |
| 33 |
2/2✓ Branch 16 → 17 taken 5 times.
✓ Branch 16 → 18 taken 5 times.
|
10 | if (status == HookStatus::Active) |
| 34 | { | ||
| 35 | 5 | snapshot.hooks_active = count; | |
| 36 | } | ||
| 37 |
1/2✓ Branch 18 → 19 taken 5 times.
✗ Branch 18 → 20 not taken.
|
5 | else if (status == HookStatus::Disabled) |
| 38 | { | ||
| 39 | 5 | snapshot.hooks_disabled = count; | |
| 40 | } | ||
| 41 | } | ||
| 42 | |||
| 43 | 5 | snapshot.anchor_quality = Anchors::assess_quality(anchor_report); | |
| 44 | |||
| 45 | 5 | snapshot.drift_total = drift_report.size(); | |
| 46 |
2/2✓ Branch 41 → 27 taken 3 times.
✓ Branch 41 → 42 taken 5 times.
|
13 | for (const Rtti::DriftEntry &entry : drift_report) |
| 47 | { | ||
| 48 |
2/2✓ Branch 29 → 30 taken 2 times.
✓ Branch 29 → 31 taken 1 time.
|
3 | if (entry.ok) |
| 49 | { | ||
| 50 | 2 | ++snapshot.drift_healed; | |
| 51 | } | ||
| 52 | else | ||
| 53 | { | ||
| 54 | 1 | ++snapshot.drift_failed; | |
| 55 | } | ||
| 56 | } | ||
| 57 | |||
| 58 | 10 | return snapshot; | |
| 59 | 5 | } | |
| 60 | } // namespace Diagnostics | ||
| 61 | } // namespace DetourModKit | ||
| 62 |