internal/gocore: ignore non-ClassExprLoc locations when reading locations
viewcore only knows how to handle ExprLoc-encoded location information.
As of Go 1.11, we now encode locals with ClassLocListPtr.
This CL just skips location list info. That's fine for globals (they
are still ExprLoc-encoded), but for locals we'll need a CL to make
gocore understand location lists. This CL just gets us to a point
where viewcore doesn't crash.
Change-Id: Ibde9ebcb130bc7e9141e7b6162e1500ff8b852e8
Reviewed-on: https://go-review.googlesource.com/127118
Reviewed-by: Heschi Kreinick <heschi@google.com>
diff --git a/internal/gocore/dwarf.go b/internal/gocore/dwarf.go
index 513a5f3..7267270 100644
--- a/internal/gocore/dwarf.go
+++ b/internal/gocore/dwarf.go
@@ -413,6 +413,10 @@
if f == nil {
continue
}
+ if f.Class != dwarf.ClassExprLoc {
+ // Globals are all encoded with this class.
+ continue
+ }
loc := f.Val.([]byte)
if len(loc) == 0 || loc[0] != _DW_OP_addr {
continue
@@ -498,6 +502,13 @@
if aloc == nil {
continue
}
+ if aloc.Class != dwarf.ClassExprLoc {
+ // TODO: handle ClassLocListPtr here.
+ // As of go 1.11, locals are encoded this way.
+ // Until we fix this TODO, viewcore will not be able to
+ // show local variables.
+ continue
+ }
// Interpret locations of the form
// DW_OP_call_frame_cfa
// DW_OP_consts <off>