Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for print command in local (command line -d) debugger #97218

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wenqiangwang
Copy link

@wenqiangwang wenqiangwang commented Sep 20, 2024

@wenqiangwang
Copy link
Author

This is an attempt to reopen PR #73729 after the branch deleted

@AThousandShips AThousandShips added this to the 4.4 milestone Sep 20, 2024
@AThousandShips AThousandShips changed the title Added support for 'print' command in local (command line -d) debugger Add support for print command in local (command line -d) debugger Sep 20, 2024
Comment on lines +431 to +433
List<String> names;
List<Variant> values;
debug_get_stack_level_locals(p_level, &names, &values, p_max_subitems, p_max_depth);
Copy link
Member

Choose a reason for hiding this comment

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

The indentation in this code is invalid, please make sure to only use tabs for indentation. You can run clang-format when committing code by setting up pre-commit with:

pip install pre-commit
pre-commit install

Comment on lines +435 to +443
Vector<String> name_vector;
for (auto it = names.begin(); it != names.end(); ++it) {
name_vector.push_back(*it);
}

Array value_array;
for (auto it = values.begin(); it != values.end(); ++it) {
value_array.push_back(*it);
}
Copy link
Member

Choose a reason for hiding this comment

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

We ban the usage of the auto keyword in the Godot codebase (with a few exceptions in complex lambdas) as we prefer the types to be explicit.

Comment on lines +436 to +437
for (auto it = names.begin(); it != names.end(); ++it) {
name_vector.push_back(*it);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
for (auto it = names.begin(); it != names.end(); ++it) {
name_vector.push_back(*it);
for (const String &name : names) {
name_vector.push_back(name);

Use for-each syntax

Comment on lines +441 to +442
for (auto it = values.begin(); it != values.end(); ++it) {
value_array.push_back(*it);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
for (auto it = values.begin(); it != values.end(); ++it) {
value_array.push_back(*it);
for (const Variant &value : values) {
value_array.push_back(value);

@@ -211,7 +211,7 @@ void LocalDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
if (line.get_slice_count(" ") <= 1) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (line.get_slice_count(" ") <= 1) {
if (line.find_char(' ') < 0) {

ScriptInstance *instance = debug_get_stack_level_instance(p_level);
if (instance) {
Variant return_val = expression.execute(value_array, instance->get_owner());
return String(return_val);
Copy link
Member

Choose a reason for hiding this comment

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

I'm not familiar with the Debugger, but it might make sense to use a more useful string representation:

Suggested change
return String(return_val);
return return_val.get_construct_string();

}
}

return "";
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return "";
return String();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'print' command in command line debugger does not show anything
4 participants