ssa: fix function and global var debug info scope
This commit is contained in:
@@ -309,12 +309,15 @@ def parse_expected_values(source_files):
|
|||||||
return test_cases
|
return test_cases
|
||||||
|
|
||||||
|
|
||||||
def execute_tests(executable_path, test_cases, interactive, plugin_path):
|
def execute_tests(executable_path, test_cases, verbose, interactive, plugin_path):
|
||||||
results = TestResults()
|
results = TestResults()
|
||||||
|
|
||||||
for test_case in test_cases:
|
for test_case in test_cases:
|
||||||
debugger = LLDBDebugger(executable_path, plugin_path)
|
debugger = LLDBDebugger(executable_path, plugin_path)
|
||||||
try:
|
try:
|
||||||
|
if verbose:
|
||||||
|
log(f"Setting breakpoint at {
|
||||||
|
test_case.source_file}:{test_case.end_line}")
|
||||||
debugger.setup()
|
debugger.setup()
|
||||||
debugger.set_breakpoint(
|
debugger.set_breakpoint(
|
||||||
test_case.source_file, test_case.end_line)
|
test_case.source_file, test_case.end_line)
|
||||||
@@ -356,7 +359,7 @@ def run_tests(executable_path, source_files, verbose, interactive, plugin_path):
|
|||||||
', '.join(source_files)} with {executable_path}")
|
', '.join(source_files)} with {executable_path}")
|
||||||
log(f"Found {len(test_cases)} test cases")
|
log(f"Found {len(test_cases)} test cases")
|
||||||
|
|
||||||
results = execute_tests(executable_path, test_cases,
|
results = execute_tests(executable_path, test_cases, verbose,
|
||||||
interactive, plugin_path)
|
interactive, plugin_path)
|
||||||
if not interactive:
|
if not interactive:
|
||||||
print_test_results(results, verbose)
|
print_test_results(results, verbose)
|
||||||
|
|||||||
@@ -5,5 +5,5 @@
|
|||||||
# lldb -S _lldbtest/runmain.lldb
|
# lldb -S _lldbtest/runmain.lldb
|
||||||
|
|
||||||
command script import _lldbtest/main.py
|
command script import _lldbtest/main.py
|
||||||
script main.run_tests("cl/_testdata/debug/out", ["cl/_testdata/debug/in.go"], True, True, None)
|
script main.run_tests("cl/_testdata/debug/out", ["cl/_testdata/debug/in.go"], True, False, None)
|
||||||
quit
|
quit
|
||||||
|
|||||||
@@ -78,7 +78,10 @@ func FuncWithAllTypeStructParam(s StructWithAllTypeFields) {
|
|||||||
// s.e: github.com/goplus/llgo/cl/_testdata/debug.E{i = 30}
|
// s.e: github.com/goplus/llgo/cl/_testdata/debug.E{i = 30}
|
||||||
// s.pad1: 100
|
// s.pad1: 100
|
||||||
// s.pad2: 200
|
// s.pad2: 200
|
||||||
println(len(s.s))
|
s.i8 = 8
|
||||||
|
// Expected:
|
||||||
|
// s.i8: '\x08'
|
||||||
|
println(len(s.s), s.i8)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Params is a function with all types of parameters.
|
// Params is a function with all types of parameters.
|
||||||
@@ -125,7 +128,7 @@ func FuncWithAllTypeParams(
|
|||||||
fn,
|
fn,
|
||||||
)
|
)
|
||||||
// Expected:
|
// Expected:
|
||||||
// all variables: i8 i16 i32 i64 i u8 u16 u32 u64 u f32 f64 b c64 c128 slice arr arr2 s e f pf pi intr m c err fn globalInt globalStruct globalStructPtr
|
// all variables: i8 i16 i32 i64 i u8 u16 u32 u64 u f32 f64 b c64 c128 slice arr arr2 s e f pf pi intr m c err fn
|
||||||
// i8: '\x01'
|
// i8: '\x01'
|
||||||
// i16: 2
|
// i16: 2
|
||||||
// i32: 3
|
// i32: 3
|
||||||
@@ -146,6 +149,10 @@ func FuncWithAllTypeParams(
|
|||||||
// arr2: [3]github.com/goplus/llgo/cl/_testdata/debug.E{{i = 27}, {i = 28}, {i = 29}}
|
// arr2: [3]github.com/goplus/llgo/cl/_testdata/debug.E{{i = 27}, {i = 28}, {i = 29}}
|
||||||
// s: hello
|
// s: hello
|
||||||
// e: github.com/goplus/llgo/cl/_testdata/debug.E{i = 30}
|
// e: github.com/goplus/llgo/cl/_testdata/debug.E{i = 30}
|
||||||
|
i8 = 9
|
||||||
|
// Expected:
|
||||||
|
// i8: '\x09'
|
||||||
|
println(i8)
|
||||||
return 1, errors.New("some error")
|
return 1, errors.New("some error")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,8 +221,17 @@ func main() {
|
|||||||
// all variables: globalInt globalStruct globalStructPtr s i err
|
// all variables: globalInt globalStruct globalStructPtr s i err
|
||||||
// s.i8: '\x01'
|
// s.i8: '\x01'
|
||||||
// s.i16: 2
|
// s.i16: 2
|
||||||
|
s.i8 = 0x12
|
||||||
|
println(s.i8)
|
||||||
|
// Expected:
|
||||||
|
// all variables: globalInt globalStruct globalStructPtr s i err
|
||||||
|
// s.i8: '\x12'
|
||||||
|
// globalStruct.i8: '\x01'
|
||||||
|
println((*globalStructPtr).i8)
|
||||||
println("done")
|
println("done")
|
||||||
println("")
|
println("")
|
||||||
|
println(&s, &globalStruct, globalStructPtr.i16, globalStructPtr)
|
||||||
|
globalStructPtr = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var globalInt int = 301
|
var globalInt int = 301
|
||||||
|
|||||||
@@ -730,15 +730,20 @@ func (p *context) compileInstr(b llssa.Builder, instr ssa.Instruction) {
|
|||||||
// Not a local variable.
|
// Not a local variable.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if v.IsAddr {
|
if variable.IsField() {
|
||||||
// skip *ssa.Alloc or *ssa.FieldAddr
|
// skip *ssa.FieldAddr
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
pos := p.goProg.Fset.Position(v.Pos())
|
pos := p.goProg.Fset.Position(v.Pos())
|
||||||
value := p.compileValue(b, v.X)
|
value := p.compileValue(b, v.X)
|
||||||
fn := v.Parent()
|
fn := v.Parent()
|
||||||
dbgVar := p.getLocalVariable(b, fn, variable)
|
dbgVar := p.getLocalVariable(b, fn, variable)
|
||||||
b.DIValue(value, dbgVar, p.fn, pos, b.Func.Block(v.Block().Index))
|
if v.IsAddr {
|
||||||
|
// *ssa.Alloc
|
||||||
|
b.DIDeclare(value, dbgVar, p.fn, pos, b.Func.Block(v.Block().Index))
|
||||||
|
} else {
|
||||||
|
b.DIValue(value, dbgVar, p.fn, pos, b.Func.Block(v.Block().Index))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("compileInstr: unknown instr - %T\n", instr))
|
panic(fmt.Sprintf("compileInstr: unknown instr - %T\n", instr))
|
||||||
|
|||||||
@@ -339,7 +339,7 @@ func (p Function) scopeMeta(b diBuilder, pos token.Position) DIScopeMeta {
|
|||||||
})
|
})
|
||||||
p.diFunc = &aDIFunction{
|
p.diFunc = &aDIFunction{
|
||||||
b.di.CreateFunction(
|
b.di.CreateFunction(
|
||||||
p.Pkg.cu.ll,
|
b.file(pos.Filename).ll,
|
||||||
llvm.DIFunction{
|
llvm.DIFunction{
|
||||||
Type: diFuncType,
|
Type: diFuncType,
|
||||||
Name: p.Name(),
|
Name: p.Name(),
|
||||||
|
|||||||
@@ -56,6 +56,10 @@ type aCompilationUnit struct {
|
|||||||
|
|
||||||
type CompilationUnit = *aCompilationUnit
|
type CompilationUnit = *aCompilationUnit
|
||||||
|
|
||||||
|
func (c CompilationUnit) scopeMeta(b diBuilder, pos token.Position) DIScopeMeta {
|
||||||
|
return &aDIScopeMeta{c.ll}
|
||||||
|
}
|
||||||
|
|
||||||
var DWARF_LANG_C llvm.DwarfLang = 0x2
|
var DWARF_LANG_C llvm.DwarfLang = 0x2
|
||||||
var DWARF_LANG_GO llvm.DwarfLang = 0x16
|
var DWARF_LANG_GO llvm.DwarfLang = 0x16
|
||||||
|
|
||||||
@@ -576,7 +580,7 @@ func (b Builder) DIGlobal(v Expr, name string, pos token.Position) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
gv := b.di().createGlobalVariableExpression(
|
gv := b.di().createGlobalVariableExpression(
|
||||||
b.di().file(pos.Filename),
|
b.Pkg.cu,
|
||||||
pos,
|
pos,
|
||||||
name,
|
name,
|
||||||
name,
|
name,
|
||||||
|
|||||||
Reference in New Issue
Block a user