debug: fix basic types

This commit is contained in:
Li Jie
2024-09-27 20:08:45 +08:00
parent 3028081fa2
commit e392956e2a
7 changed files with 66 additions and 86 deletions

View File

@@ -34,5 +34,5 @@ export DEFAULT_PACKAGE_PATH="./cl/_testdata/debug"
# Function to build the project
build_project() {
local package_path="$1"
LLGO_DEBUG=1 go run ./cmd/llgo build -o "${package_path}/out" "${package_path}"
LLGO_DEBUG=1 go run ./cmd/llgo build -o "${package_path}/debug.out" "${package_path}"
}

View File

@@ -147,7 +147,10 @@ def format_value(var: lldb.SBValue, debugger: lldb.SBDebugger, include_type: boo
def format_slice(var: lldb.SBValue, debugger: lldb.SBDebugger, indent: int) -> str:
length = int(var.GetChildMemberWithName('len').GetValue())
length = var.GetChildMemberWithName('len').GetValue()
if length is None:
return "<variable not available>"
length = int(length)
data_ptr = var.GetChildMemberWithName('data')
elements: List[str] = []
@@ -204,11 +207,12 @@ def format_string(var: lldb.SBValue) -> str:
return summary # Keep the quotes
else:
data = var.GetChildMemberWithName('data').GetValue()
length = int(var.GetChildMemberWithName('len').GetValue())
length = var.GetChildMemberWithName('len').GetValue()
if data and length:
length = int(length)
error = lldb.SBError()
return '"%s"' % var.process.ReadCStringFromMemory(int(data, 16), length + 1, error)
return '""'
return "<variable not available>"
def format_struct(var: lldb.SBValue, debugger: lldb.SBDebugger, include_type: bool = True, indent: int = 0, type_name: str = "") -> str:

View File

@@ -40,7 +40,7 @@ build_project "$package_path" || exit 1
# Prepare LLDB commands
lldb_commands=(
"command script import _lldb/test.py"
"script test.run_tests(\\\"${package_path}/out\\\", [\\\"${package_path}/in.go\\\"], ${verbose}, ${interactive}, ${plugin_path})"
"script test.run_tests(\\\"${package_path}/debug.out\\\", [\\\"${package_path}/in.go\\\"], ${verbose}, ${interactive}, ${plugin_path})"
)
# Add quit command if not in interactive mode