Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
ScriptBacktrace
继承: RefCounted < Object
捕获的特定脚本语言的追踪信息。
描述
ScriptBacktrace 中包含的是已捕获的追踪信息,针对特定的脚本语言,例如 GDScript、C# 等。捕获的方法是使用 Engine.capture_script_backtraces()。
控制该类内容的方法见 ProjectSettings.debug/settings/gdscript/always_track_call_stacks 和 ProjectSettings.debug/settings/gdscript/always_track_local_variables。
方法
get_frame_count() const |
|
get_frame_file(index: int) const |
|
get_frame_function(index: int) const |
|
get_frame_line(index: int) const |
|
get_global_variable_count() const |
|
get_global_variable_name(variable_index: int) const |
|
get_global_variable_value(variable_index: int) const |
|
get_language_name() const |
|
get_local_variable_count(frame_index: int) const |
|
get_local_variable_name(frame_index: int, variable_index: int) const |
|
get_local_variable_value(frame_index: int, variable_index: int) const |
|
get_member_variable_count(frame_index: int) const |
|
get_member_variable_name(frame_index: int, variable_index: int) const |
|
get_member_variable_value(frame_index: int, variable_index: int) const |
|
is_empty() const |
方法说明
String format(indent_all: int = 0, indent_frames: int = 4) const 🔗
将捕获信息转换为 String,整个字符串都会缩进 indent_all 个空格,各个栈帧还会额外缩进 indent_frames 个空格。
注意:对 ScriptBacktrace 调用 Object.to_string() 的输出和保持所有默认参数调用 format() 的输出相同。
返回追踪信息中的栈帧数。
String get_frame_file(index: int) const 🔗
返回位于指定索引处的栈帧所代表的调用点的文件名。
String get_frame_function(index: int) const 🔗
返回位于指定索引处的栈帧所调用的函数名。
int get_frame_line(index: int) const 🔗
返回位于指定索引处的栈帧所代表的调用点的行号。
int get_global_variable_count() const 🔗
返回追踪信息中的全局变量数(例如自动加载单例)。
注意:使用 Engine.capture_script_backtraces() 捕获追踪信息时如果参数 include_variables 为 true,则数量非零。
String get_global_variable_name(variable_index: int) const 🔗
返回位于指定索引处的全局变量名称。
Variant get_global_variable_value(variable_index: int) const 🔗
返回位于指定索引处的全局变量取值。
警告:在 GDScript 追踪信息中,返回的 Variant 是变量的实际值,包含对象引用。这意味着存储返回的 Variant 会阻止这类对象的释放,因此通常不建议这么做。
String get_language_name() const 🔗
返回捕获信息所捕获的脚本语言的名称。
int get_local_variable_count(frame_index: int) const 🔗
返回位于指定索引处的栈帧中的局部变量数。
注意:使用 Engine.capture_script_backtraces() 捕获追踪信息时如果参数 include_variables 为 true,则数量非零。
String get_local_variable_name(frame_index: int, variable_index: int) const 🔗
返回索引为 frame_index 的栈帧中索引为 variable_index 的局部变量的名称。
Variant get_local_variable_value(frame_index: int, variable_index: int) const 🔗
返回索引为 frame_index 的栈帧中索引为 variable_index 的局部变量的取值。
警告:在 GDScript 追踪信息中,返回的 Variant 是变量的实际值,包含对象引用。这意味着存储返回的 Variant 会阻止这类对象的释放,因此通常不建议这么做。
int get_member_variable_count(frame_index: int) const 🔗
返回位于指定索引处的栈帧中的成员变量数。
注意:使用 Engine.capture_script_backtraces() 捕获追踪信息时如果参数 include_variables 为 true,则数量非零。
String get_member_variable_name(frame_index: int, variable_index: int) const 🔗
返回索引为 frame_index 的栈帧中索引为 variable_index 的成员变量的名称。
Variant get_member_variable_value(frame_index: int, variable_index: int) const 🔗
返回索引为 frame_index 的栈帧中索引为 variable_index 的成员变量的取值。
警告:在 GDScript 追踪信息中,返回的 Variant 是变量的实际值,包含对象引用。这意味着存储返回的 Variant 会阻止这类对象的释放,因此通常不建议这么做。
如果追踪信息中没有栈帧,则返回 true。