1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-13 13:31:48 +00:00

Merge pull request #97210 from AleksLitynski/object-snapshot-debugger

Add an ObjectDB Profiling Tool
This commit is contained in:
Thaddeus Crews
2025-10-03 12:01:11 -05:00
34 changed files with 3885 additions and 24 deletions

View File

@@ -2374,12 +2374,12 @@ void postinitialize_handler(Object *p_object) {
p_object->_postinitialize();
}
void ObjectDB::debug_objects(DebugFunc p_func) {
void ObjectDB::debug_objects(DebugFunc p_func, void *p_user_data) {
spin_lock.lock();
for (uint32_t i = 0, count = slot_count; i < slot_max && count != 0; i++) {
if (object_slots[i].validator) {
p_func(object_slots[i].object);
p_func(object_slots[i].object, p_user_data);
count--;
}
}
@@ -2547,6 +2547,9 @@ void ObjectDB::cleanup() {
if (obj->is_class("Resource")) {
extra_info = " - Resource path: " + String(resource_get_path->call(obj, nullptr, 0, call_error));
}
if (obj->is_class("RefCounted")) {
extra_info = " - Reference count: " + itos((static_cast<RefCounted *>(obj))->get_reference_count());
}
uint64_t id = uint64_t(i) | (uint64_t(object_slots[i].validator) << OBJECTDB_SLOT_MAX_COUNT_BITS) | (object_slots[i].is_ref_counted ? OBJECTDB_REFERENCE_BIT : 0);
DEV_ASSERT(id == (uint64_t)obj->get_instance_id()); // We could just use the id from the object, but this check may help catching memory corruption catastrophes.