proc_test: implement test for DWZ compressed DWARF

If dwz binary is available in the system, test delve's ability to find
deduplicated symbols in the DWARF information.

dwzcompression.go contains a small C function (void fortytwo()) which
calls glibc's fprintf with stdin as first argument. Normally, stdin
will be present as a DW_TAG_variable as part of a DW_TAG_compile_unit
named dwzcompression.cgo2.c.

After running dwz on the binary, stdin is moved to a
DW_TAG_partial_unit, which is imported from dwzcompression.cgo2.c with
a DW_TAG_imported_unit.

This test verifies that delve is able to find stdin symbol's type, as a
way to confirm it understands dwz's compressed/deduplicated DWARF
information.
This commit is contained in:
Sergio Lopez 2018-05-22 14:23:04 +02:00 committed by Derek Parker
parent ed71248f9b
commit bafa512067
2 changed files with 31 additions and 0 deletions

@ -0,0 +1,14 @@
package main
// #include <stdio.h>
// void fortytwo()
// {
// fprintf(stdin, "42");
// }
import "C"
import "runtime"
func main() {
C.fortytwo()
runtime.Breakpoint()
}

@ -3697,3 +3697,20 @@ func TestIssue951(t *testing.T) {
}
})
}
func TestDWZCompression(t *testing.T) {
// If dwz is not available in the system, skip this test
if _, err := exec.LookPath("dwz"); err != nil {
t.Skip("dwz not installed")
}
withTestProcessArgs("dwzcompression", t, ".", []string{}, protest.EnableDWZCompression, func(p proc.Process, fixture protest.Fixture) {
_, err := setFunctionBreakpoint(p, "C.fortytwo")
assertNoError(err, t, "setFunctionBreakpoint()")
assertNoError(proc.Continue(p), t, "first Continue()")
val := evalVariable(p, t, "stdin")
if val.RealType == nil {
t.Errorf("Can't find type for \"stdin\" global variable")
}
})
}