MCPcopy Create free account
hub / github.com/DFHack/dfhack / queue_item

Method queue_item

plugins/devel/check-structures-sanity/dispatch.cpp:36–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34}
35
36bool Checker::queue_item(const QueueItem & item, CheckedStructure cs)
37{
38 if (!cs.identity)
39 {
40 UNEXPECTED;
41 return false;
42 }
43
44 if (cs.identity->type() == IDTYPE_CLASS)
45 {
46 if (cs.count)
47 {
48 UNEXPECTED;
49 }
50
51 if (get_vtable_name(item, cs, true))
52 {
53 auto actual_identity = virtual_identity::get(reinterpret_cast<virtual_ptr>(const_cast<void *>(item.ptr)));
54 if (static_cast<const virtual_identity *>(cs.identity)->is_subclass(actual_identity))
55 {
56 cs.identity = actual_identity;
57 }
58 }
59 }
60
61 auto ptr_end = PTR_ADD(item.ptr, cs.full_size());
62
63 auto prev = data.lower_bound(item.ptr);
64 if (prev != data.cbegin() && uintptr_t(prev->first) > uintptr_t(item.ptr))
65 {
66 prev--;
67 }
68 if (prev != data.cend() && uintptr_t(prev->first) <= uintptr_t(item.ptr) && uintptr_t(prev->first) + prev->second.second.full_size() > uintptr_t(item.ptr))
69 {
70 auto offset = uintptr_t(item.ptr) - uintptr_t(prev->first);
71 if (!prev->second.second.has_type_at_offset(cs, offset))
72 {
73 if (offset == 0 && cs.identity == df::identity_traits<void *>::get())
74 {
75 FAIL("unknown pointer is " << prev->second.second.identity->getFullName() << ", previously seen at " << prev->second.first);
76 return false;
77 }
78 // TODO
79 FAIL("TODO: handle merging structures: " << item.path << " overlaps " << prev->second.first << " (backward)");
80 return false;
81 }
82
83 // we've already checked this structure, or we're currently queued to do so
84 return false;
85 }
86
87 auto overlap_start = data.lower_bound(item.ptr);
88 auto overlap_end = data.lower_bound(ptr_end);
89 for (auto overlap = overlap_start; overlap != overlap_end; overlap++)
90 {
91 auto offset = uintptr_t(overlap->first) - uintptr_t(item.ptr);
92 if (!cs.has_type_at_offset(overlap->second.second, offset))
93 {

Callers 1

commandFunction · 0.80

Calls 9

is_subclassMethod · 0.80
full_sizeMethod · 0.80
cbeginMethod · 0.80
cendMethod · 0.80
has_type_at_offsetMethod · 0.80
getFunction · 0.50
typeMethod · 0.45
getFullNameMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected