Tighten up a testpoint that looks for the compile unit
DW_AT_go_package_name attribute. The linker code that injects this
attribute was accidentally broken on the dev.link branch, but in a way
that wasn't detected by the test (attr was generated, but always with
an empty string). The new test will fail if the attr is an empty
string, or if we can't find the attribute for the runtime package.
Change-Id: I8b065e7eb3486646364d0eaf48a73db6acffbd18
Reviewed-on: https://go-review.googlesource.com/c/go/+/218483
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
}
rdr := d.Reader()
+ runtimeUnitSeen := false
for {
e, err := rdr.Next()
if err != nil {
continue
}
- _, ok := e.Val(dwarfAttrGoPackageName).(string)
+ pn, ok := e.Val(dwarfAttrGoPackageName).(string)
if !ok {
name, _ := e.Val(dwarf.AttrName).(string)
t.Errorf("found compile unit without package name: %s", name)
+
+ }
+ if pn == "" {
+ name, _ := e.Val(dwarf.AttrName).(string)
+ t.Errorf("found compile unit with empty package name: %s", name)
+ } else {
+ if pn == "runtime" {
+ runtimeUnitSeen = true
+ }
}
}
+
+ // Something is wrong if there's no runtime compilation unit.
+ if !runtimeUnitSeen {
+ t.Errorf("no package name for runtime unit")
+ }
}
func TestMachoIssue32233(t *testing.T) {