Fix cursor jump on command row edit, data-change highlighting for containers, invalid pointer expansion, cycle detection with node IDs, O(n²) addNode cache, duplicate struct in C++ export, collapse bug for non-first root structs, remove hardcoded demo data

This commit is contained in:
megablocks(tm)
2026-02-07 12:02:41 -07:00
committed by sysadmin
parent 39cac316de
commit 9962e55820
7 changed files with 225 additions and 169 deletions

View File

@@ -75,17 +75,19 @@ static QString resolvePointerTarget(const NodeTree& tree, uint64_t refId) {
}
static inline uint64_t ptrToProviderAddr(const NodeTree& tree, uint64_t ptr) {
if (tree.baseAddress && ptr >= tree.baseAddress) return ptr - tree.baseAddress;
return ptr;
if (tree.baseAddress == 0) return ptr;
if (ptr >= tree.baseAddress) return ptr - tree.baseAddress;
return UINT64_MAX; // Invalid: ptr below base address
}
static int64_t relOffsetFromRoot(const NodeTree& tree, int idx, uint64_t rootId) {
int64_t total = 0;
QSet<int> visited;
QSet<uint64_t> visited;
int cur = idx;
while (cur >= 0 && cur < tree.nodes.size()) {
if (visited.contains(cur)) break;
visited.insert(cur);
uint64_t nid = tree.nodes[cur].id;
if (visited.contains(nid)) break;
visited.insert(nid);
const Node& n = tree.nodes[cur];
if (n.id == rootId) break;
total += n.offset;
@@ -337,6 +339,10 @@ void composeNode(ComposeState& state, const NodeTree& tree,
if (prov.isValid() && sz > 0 && prov.isReadable(absAddr, sz)) {
uint64_t ptrVal = (node.kind == NodeKind::Pointer32)
? (uint64_t)prov.readU32(absAddr) : prov.readU64(absAddr);
if (ptrVal != 0) {
uint64_t pBase = ptrToProviderAddr(tree, ptrVal);
if (pBase == UINT64_MAX) ptrVal = 0; // ptr below base: invalid
}
if (ptrVal != 0) {
uint64_t pBase = ptrToProviderAddr(tree, ptrVal);
qulonglong key = pBase ^ (node.refId * kGoldenRatio);
@@ -507,9 +513,6 @@ ComposeResult compose(const NodeTree& tree, const Provider& prov, uint64_t viewR
// If viewRootId is set, skip roots that don't match
if (viewRootId != 0 && tree.nodes[idx].id != viewRootId)
continue;
// Skip collapsed roots unless specifically targeted by viewRootId
if (viewRootId == 0 && tree.nodes[idx].collapsed)
continue;
composeNode(state, tree, prov, idx, 0);
}