Mono: Partially implement some Godot debug api functions

Debug breaks sent with debug_break and debug_break_parse should display correctly in the Godot debugger now.
This commit is contained in:
Ignacio Etcheverry 2019-03-07 20:47:13 +01:00
parent 4c0b0a6bdd
commit 8e2e0795bb
2 changed files with 59 additions and 15 deletions

View file

@ -499,6 +499,47 @@ String CSharpLanguage::_get_indentation() const {
return "\t";
}
String CSharpLanguage::debug_get_error() const {
return _debug_error;
}
int CSharpLanguage::debug_get_stack_level_count() const {
if (_debug_parse_err_line >= 0)
return 1;
// TODO: StackTrace
return 1;
}
int CSharpLanguage::debug_get_stack_level_line(int p_level) const {
if (_debug_parse_err_line >= 0)
return _debug_parse_err_line;
// TODO: StackTrace
return 1;
}
String CSharpLanguage::debug_get_stack_level_function(int p_level) const {
if (_debug_parse_err_line >= 0)
return String();
// TODO: StackTrace
return String();
}
String CSharpLanguage::debug_get_stack_level_source(int p_level) const {
if (_debug_parse_err_line >= 0)
return _debug_parse_err_file;
// TODO: StackTrace
return String();
}
Vector<ScriptLanguage::StackInfo> CSharpLanguage::debug_get_current_stack_info() {
#ifdef DEBUG_ENABLED
@ -958,12 +999,11 @@ void CSharpLanguage::thread_exit() {
bool CSharpLanguage::debug_break_parse(const String &p_file, int p_line, const String &p_error) {
// Break because of parse error
// Not a parser error in our case, but it's still used for other type of errors
if (ScriptDebugger::get_singleton() && Thread::get_caller_id() == Thread::get_main_id()) {
// TODO
//_debug_parse_err_line = p_line;
//_debug_parse_err_file = p_file;
//_debug_error = p_error;
_debug_parse_err_line = p_line;
_debug_parse_err_file = p_file;
_debug_error = p_error;
ScriptDebugger::get_singleton()->debug(this, false);
return true;
} else {
@ -974,10 +1014,9 @@ bool CSharpLanguage::debug_break_parse(const String &p_file, int p_line, const S
bool CSharpLanguage::debug_break(const String &p_error, bool p_allow_continue) {
if (ScriptDebugger::get_singleton() && Thread::get_caller_id() == Thread::get_main_id()) {
// TODO
//_debug_parse_err_line = -1;
//_debug_parse_err_file = "";
//_debug_error = p_error;
_debug_parse_err_line = -1;
_debug_parse_err_file = "";
_debug_error = p_error;
ScriptDebugger::get_singleton()->debug(this, p_allow_continue);
return true;
} else {

View file

@ -162,7 +162,7 @@ public:
virtual bool has_script_signal(const StringName &p_signal) const;
virtual void get_script_signal_list(List<MethodInfo> *r_signals) const;
/* TODO */ virtual bool get_property_default_value(const StringName &p_property, Variant &r_value) const;
virtual bool get_property_default_value(const StringName &p_property, Variant &r_value) const;
virtual void get_script_property_list(List<PropertyInfo> *p_list) const;
virtual void update_exports();
@ -309,6 +309,11 @@ class CSharpLanguage : public ScriptLanguage {
Dictionary scripts_metadata;
// For debug_break and debug_break_parse
int _debug_parse_err_line;
String _debug_parse_err_file;
String _debug_error;
friend class GDMono;
void _uninitialize_script_bindings();
@ -368,11 +373,11 @@ public:
/* TODO */ virtual void add_global_constant(const StringName &p_variable, const Variant &p_value) {}
/* DEBUGGER FUNCTIONS */
/* TODO */ virtual String debug_get_error() const { return ""; }
/* TODO */ virtual int debug_get_stack_level_count() const { return 1; }
/* TODO */ virtual int debug_get_stack_level_line(int p_level) const { return 1; }
/* TODO */ virtual String debug_get_stack_level_function(int p_level) const { return ""; }
/* TODO */ virtual String debug_get_stack_level_source(int p_level) const { return ""; }
virtual String debug_get_error() const;
virtual int debug_get_stack_level_count() const;
virtual int debug_get_stack_level_line(int p_level) const;
virtual String debug_get_stack_level_function(int p_level) const;
virtual String debug_get_stack_level_source(int p_level) const;
/* TODO */ virtual void debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {}
/* TODO */ virtual void debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {}
/* TODO */ virtual void debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {}