Skip to content

Conversation

@Bromeon
Copy link
Member

@Bromeon Bromeon commented Jul 6, 2025

Continuation of #1226.

Improves Debug impl for Gd, DynGd and Variant holding objects:

  • Includes a refc field for RefCounted classes.
  • No longer creates a new object just for the Debug impl.
    • In particular, this addresses the issue that reading ref-counts in Debug is subject to the Observer Effect, where debugging changes object stats.
  • Variant now also uses a short-circuited Debug impl instead of converting to an object first.

Also cleans up trace logging and makes it more useful, by including dynamic object types. Fixes an issue where Debug is accessed during C++ destructors, making introspection unreliable.

@Bromeon Bromeon added quality-of-life No new functionality, but improves ergonomics/internals c: ffi Low-level components and interaction with GDExtension API labels Jul 6, 2025
@GodotRust
Copy link

API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-1227


out!(
" Storage::mark_destroyed_by_godot: {base_id} (lcy={lifecycle:?})",
// ptr: std::ptr::from_ref(storage),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftover?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I printed this before, but now disabled it for consistency with the other outputs. Not sure if it's useful given we have object ID... I guess the address is not needed anymore 👌

While C++ destructors are run, virtual functions on C++ Object will no
longer dispatch correctly. These are however relied upon for functionality
like casting, dynamic class query, etc.
Bromeon added 2 commits July 7, 2025 00:18
Previously, Debug for Variant converted objects by creating a new Gd<T> pointer. This is
subject to the observer effect, and changes the reference count of objects being inspected.

Use an alternative direct way to fetch data, using Variant::call().
@Bromeon Bromeon added this pull request to the merge queue Jul 6, 2025
Merged via the queue into master with commit 4902b34 Jul 6, 2025
18 checks passed
@Bromeon Bromeon deleted the qol/gd-debug branch July 6, 2025 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: ffi Low-level components and interaction with GDExtension API quality-of-life No new functionality, but improves ergonomics/internals

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants