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

Method check_unknown_pointer

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

Source from the content-addressed store, hash-verified

782}
783
784void Checker::check_unknown_pointer(const QueueItem & item)
785{
786 const static CheckedStructure cs(nullptr, 0, nullptr, true);
787 if (auto allocated_size = get_allocated_size(item))
788 {
789 FAIL("pointer to a block of " << allocated_size << " bytes of allocated memory");
790 if (allocated_size >= MIN_SIZE_FOR_SUGGEST && known_types_by_size.count(allocated_size))
791 {
792 FAIL("known types of this size: " << join_strings(", ", known_types_by_size.at(allocated_size)));
793 }
794
795 // check recursively if it's the right size for a pointer
796 // or if it starts with what might be a valid pointer
797 QueueItem ptr_item(item, "?ptr?", item.ptr);
798 if (allocated_size == sizeof(void *) || (allocated_size > sizeof(void *) && is_valid_dereference(ptr_item, 1, true)))
799 {
800 CheckedStructure ptr_cs(df::identity_traits<void *>::get());
801 if (queue_item(ptr_item, ptr_cs))
802 {
803 queue.pop_back();
804 dispatch_pointer(ptr_item, ptr_cs);
805 }
806 }
807 }
808#ifndef WIN32
809 else if (auto str = validate_stl_string_pointer(&item.ptr))
810 {
811 FAIL("untyped pointer is actually stl-string with value \"" << *str << "\" (length " << str->length() << ")");
812 }
813#endif
814 else if (auto vtable_name = get_vtable_name(QueueItem(item.path, &item.ptr), cs, true))
815 {
816 FAIL("pointer to a vtable: " << vtable_name);
817 }
818 else if (sizes)
819 {
820 //FAIL("pointer to memory with no size information");
821 }
822}
823
824void Checker::check_stl_vector(const QueueItem & item, const type_identity *item_identity, const type_identity *eid)
825{

Callers

nothing calls this directly

Calls 3

join_stringsFunction · 0.50
getFunction · 0.50
countMethod · 0.45

Tested by

no test coverage detected