MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / debug

Method debug

core/debugger/local_debugger.cpp:124–328  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122};
123
124void LocalDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
125 ScriptLanguage *script_lang = script_debugger->get_break_language();
126
127 if (!target_function.is_empty()) {
128 String current_function = script_lang->debug_get_stack_level_function(0);
129 if (current_function != target_function) {
130 script_debugger->set_depth(0);
131 script_debugger->set_lines_left(1);
132 return;
133 }
134 target_function = "";
135 }
136
137 print_line("\nDebugger Break, Reason: '" + script_lang->debug_get_error() + "'");
138 print_line("*Frame " + itos(0) + " - " + script_lang->debug_get_stack_level_source(0) + ":" + itos(script_lang->debug_get_stack_level_line(0)) + " in function '" + script_lang->debug_get_stack_level_function(0) + "'");
139 print_line("Enter \"help\" for assistance.");
140 int current_frame = 0;
141 int total_frames = script_lang->debug_get_stack_level_count();
142 while (true) {
143 OS::get_singleton()->print("debug> ");
144 String line = OS::get_singleton()->get_stdin_string().strip_edges();
145
146 // Cache options
147 String variable_prefix = options["variable_prefix"];
148
149 if (line.is_empty() && !feof(stdin)) {
150 print_line("\nDebugger Break, Reason: '" + script_lang->debug_get_error() + "'");
151 print_line("*Frame " + itos(current_frame) + " - " + script_lang->debug_get_stack_level_source(current_frame) + ":" + itos(script_lang->debug_get_stack_level_line(current_frame)) + " in function '" + script_lang->debug_get_stack_level_function(current_frame) + "'");
152 print_line("Enter \"help\" for assistance.");
153 } else if (line == "c" || line == "continue") {
154 break;
155 } else if (line == "bt" || line == "breakpoint") {
156 for (int i = 0; i < total_frames; i++) {
157 String cfi = (current_frame == i) ? "*" : " "; //current frame indicator
158 print_line(cfi + "Frame " + itos(i) + " - " + script_lang->debug_get_stack_level_source(i) + ":" + itos(script_lang->debug_get_stack_level_line(i)) + " in function '" + script_lang->debug_get_stack_level_function(i) + "'");
159 }
160
161 } else if (line.begins_with("fr") || line.begins_with("frame")) {
162 if (line.get_slice_count(" ") == 1) {
163 print_line("*Frame " + itos(current_frame) + " - " + script_lang->debug_get_stack_level_source(current_frame) + ":" + itos(script_lang->debug_get_stack_level_line(current_frame)) + " in function '" + script_lang->debug_get_stack_level_function(current_frame) + "'");
164 } else {
165 int frame = line.get_slicec(' ', 1).to_int();
166 if (frame < 0 || frame >= total_frames) {
167 print_line("Error: Invalid frame.");
168 } else {
169 current_frame = frame;
170 print_line("*Frame " + itos(frame) + " - " + script_lang->debug_get_stack_level_source(frame) + ":" + itos(script_lang->debug_get_stack_level_line(frame)) + " in function '" + script_lang->debug_get_stack_level_function(frame) + "'");
171 }
172 }
173
174 } else if (line.begins_with("set")) {
175 if (line.get_slice_count(" ") == 1) {
176 for (const KeyValue<String, String> &E : options) {
177 print_line("\t" + E.key + "=" + E.value);
178 }
179
180 } else {
181 String key_value = line.get_slicec(' ', 1);

Callers

nothing calls this directly

Calls 15

print_lineFunction · 0.85
itosFunction · 0.85
strip_edgesMethod · 0.80
begins_withMethod · 0.80
get_slice_countMethod · 0.80
to_intMethod · 0.80
get_slicecMethod · 0.80
find_charMethod · 0.80
leftMethod · 0.80
substrMethod · 0.80
splitMethod · 0.80
sizeMethod · 0.65

Tested by

no test coverage detected