Sprint 31: end-of-sprint architecture refactor pass
This commit is contained in:
@@ -39,8 +39,8 @@ public:
|
||||
if (!error) return false;
|
||||
error->clear();
|
||||
if (!hasRequiredDebugIds(allocationId, sessionId)) return fail(error, "allocation_or_session_missing");
|
||||
if (address == 0) return fail(error, "allocation_address_invalid");
|
||||
if (sizeBytes == 0) return fail(error, "allocation_size_invalid");
|
||||
if (!isNonZeroU64(address)) return fail(error, "allocation_address_invalid");
|
||||
if (!isNonZeroU64(sizeBytes)) return fail(error, "allocation_size_invalid");
|
||||
if (owner.empty()) return fail(error, "allocation_owner_missing");
|
||||
if (activeOwners_.count(allocationId) != 0) return fail(error, "allocation_id_active_duplicate");
|
||||
|
||||
|
||||
@@ -1,12 +1,23 @@
|
||||
#pragma once
|
||||
// Sprint 30 refactor: shared debug validation helpers
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
inline bool hasRequiredDebugIds(const std::string& a, const std::string& b) {
|
||||
return !a.empty() && !b.empty();
|
||||
}
|
||||
|
||||
inline bool hasRequiredDebugIds(const std::string& a,
|
||||
const std::string& b,
|
||||
const std::string& c) {
|
||||
return hasRequiredDebugIds(a, b) && !c.empty();
|
||||
}
|
||||
|
||||
inline bool isPositiveLine(int line) {
|
||||
return line > 0;
|
||||
}
|
||||
|
||||
inline bool isNonZeroU64(std::uint64_t value) {
|
||||
return value > 0;
|
||||
}
|
||||
|
||||
@@ -47,9 +47,9 @@ public:
|
||||
if (!error) return false;
|
||||
error->clear();
|
||||
if (!hasRequiredDebugIds(signal.signalId, signal.sessionId)) return fail(error, "signal_or_session_missing");
|
||||
if (signal.allocationId.empty()) return fail(error, "allocation_id_missing");
|
||||
if (!hasRequiredDebugIds(signal.signalId, signal.sessionId, signal.allocationId)) return fail(error, "allocation_id_missing");
|
||||
if (signal.message.empty()) return fail(error, "signal_message_missing");
|
||||
if (signal.timestamp == 0) return fail(error, "signal_timestamp_invalid");
|
||||
if (!isNonZeroU64(signal.timestamp)) return fail(error, "signal_timestamp_invalid");
|
||||
if (containsSignal(signal.signalId)) return fail(error, "signal_duplicate");
|
||||
|
||||
signals_.push_back(signal);
|
||||
|
||||
@@ -74,11 +74,11 @@ public:
|
||||
*error = "region_id_missing";
|
||||
return false;
|
||||
}
|
||||
if (region.startAddress == 0) {
|
||||
if (!isNonZeroU64(region.startAddress)) {
|
||||
*error = "region_start_address_invalid";
|
||||
return false;
|
||||
}
|
||||
if (region.sizeBytes == 0) {
|
||||
if (!isNonZeroU64(region.sizeBytes)) {
|
||||
*error = "region_size_invalid";
|
||||
return false;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public:
|
||||
std::string* error) {
|
||||
if (!snapshot || !error) return false;
|
||||
error->clear();
|
||||
if (reference.fromAddress == 0 || reference.toAddress == 0) {
|
||||
if (!isNonZeroU64(reference.fromAddress) || !isNonZeroU64(reference.toAddress)) {
|
||||
*error = "reference_address_invalid";
|
||||
return false;
|
||||
}
|
||||
@@ -112,7 +112,7 @@ public:
|
||||
|
||||
static const MemoryRegionRecord* findRegionByAddress(const MemorySnapshot& snapshot,
|
||||
std::uint64_t address) {
|
||||
if (address == 0) return nullptr;
|
||||
if (!isNonZeroU64(address)) return nullptr;
|
||||
for (const auto& region : snapshot.regions) {
|
||||
const std::uint64_t regionEnd = region.startAddress + region.sizeBytes;
|
||||
if (address >= region.startAddress && address < regionEnd) return ®ion;
|
||||
@@ -123,7 +123,7 @@ public:
|
||||
static std::vector<MemoryReferenceRecord> outgoingReferences(const MemorySnapshot& snapshot,
|
||||
std::uint64_t fromAddress) {
|
||||
std::vector<MemoryReferenceRecord> filtered;
|
||||
if (fromAddress == 0) return filtered;
|
||||
if (!isNonZeroU64(fromAddress)) return filtered;
|
||||
for (const auto& reference : snapshot.references) {
|
||||
if (reference.fromAddress == fromAddress) filtered.push_back(reference);
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ public:
|
||||
if (!hasRequiredDebugIds(sample.sampleId, sample.sessionId)) return fail(error, "sample_or_session_missing");
|
||||
if (sample.bufferId.empty()) return fail(error, "sample_buffer_missing");
|
||||
if (!isPositiveLine(sample.line)) return fail(error, "sample_line_invalid");
|
||||
if (sample.durationMicros == 0) return fail(error, "sample_duration_invalid");
|
||||
if (sample.timestamp == 0) return fail(error, "sample_timestamp_invalid");
|
||||
if (!isNonZeroU64(sample.durationMicros)) return fail(error, "sample_duration_invalid");
|
||||
if (!isNonZeroU64(sample.timestamp)) return fail(error, "sample_timestamp_invalid");
|
||||
if (containsSample(sample.sampleId)) return fail(error, "sample_duplicate");
|
||||
|
||||
samples_.push_back(sample);
|
||||
|
||||
@@ -27,8 +27,8 @@ public:
|
||||
error->clear();
|
||||
if (!hasRequiredDebugIds(event.eventId, event.sessionId)) return fail(error, "event_or_session_missing");
|
||||
if (event.type.empty()) return fail(error, "event_type_missing");
|
||||
if (event.timestamp == 0) return fail(error, "event_timestamp_invalid");
|
||||
if (event.instructionPointer == 0) return fail(error, "event_ip_invalid");
|
||||
if (!isNonZeroU64(event.timestamp)) return fail(error, "event_timestamp_invalid");
|
||||
if (!isNonZeroU64(event.instructionPointer)) return fail(error, "event_ip_invalid");
|
||||
if (containsId(event.eventId)) return fail(error, "event_duplicate");
|
||||
|
||||
events_.push_back(event);
|
||||
|
||||
Reference in New Issue
Block a user