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

Added support for 'print' command in local (command line -d) debugger #73729

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/debugger/local_debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ void LocalDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
if (line.get_slice_count(" ") <= 1) {
print_line("Usage: print <expre>");
} else {
String expr = line.get_slicec(' ', 2);
String expr = line.get_slicec(' ', 1);
String res = script_lang->debug_parse_stack_level_expression(current_frame, expr);
print_line(res);
}
Expand Down
20 changes: 19 additions & 1 deletion modules/gdscript/gdscript_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "core/config/engine.h"
#include "core/core_constants.h"
#include "core/io/file_access.h"
#include "core/math/expression.h"
#include "gdscript_analyzer.h"
#include "gdscript_compiler.h"
#include "gdscript_parser.h"
Expand Down Expand Up @@ -389,7 +390,24 @@ void GDScriptLanguage::debug_get_globals(List<String> *p_globals, List<Variant>
}

String GDScriptLanguage::debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems, int p_max_depth) {
return "";
List<String> names;
List<Variant> values;
debug_get_stack_level_locals(p_level, &names, &values, p_max_subitems, p_max_depth);

Vector<String> name_vector;
for (int i = 0; i < names.size(); ++i) {
name_vector.push_back(names[i]);
}

Array value_array;
for (int i = 0; i < values.size(); ++i) {
value_array.push_back(values[i]);
}

Expression expression;
expression.parse(p_expression, name_vector);
Variant return_val = expression.execute(value_array, debug_get_stack_level_instance(p_level)->get_owner());
return String(return_val);
}

void GDScriptLanguage::get_recognized_extensions(List<String> *p_extensions) const {
Expand Down