-
-
Notifications
You must be signed in to change notification settings - Fork 20.2k
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
base: master
Are you sure you want to change the base?
Add support for print
command in local (command line -d
) debugger
#97218
Conversation
wenqiangwang
commented
Sep 20, 2024
•
edited by AThousandShips
Loading
edited by AThousandShips
- Bugsquad edit, fixes: 'print' command in command line debugger does not show anything #73389
This is an attempt to reopen PR #73729 after the branch deleted |
print
command in local (command line -d
) debugger
List<String> names; | ||
List<Variant> values; | ||
debug_get_stack_level_locals(p_level, &names, &values, p_max_subitems, p_max_depth); |
There was a problem hiding this comment.
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
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); | ||
} |
There was a problem hiding this comment.
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.
for (auto it = names.begin(); it != names.end(); ++it) { | ||
name_vector.push_back(*it); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
for (auto it = values.begin(); it != values.end(); ++it) { | ||
value_array.push_back(*it); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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); |
There was a problem hiding this comment.
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:
return String(return_val); | |
return return_val.get_construct_string(); |
} | ||
} | ||
|
||
return ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return ""; | |
return String(); |