From c135dfbf1842993aa2fd4c293b2476ce4733daf7 Mon Sep 17 00:00:00 2001 From: Than McIntosh Date: Fri, 18 Jan 2019 15:16:11 -0500 Subject: debug/dwarf: more graceful handling of unsupported types Enhance the type decoder to do a better job handling unknown type tags. DWARF has a number of type DIEs that this package doesn't handle (things like "pointer to member" types in C++); avoid crashing for such types, but instead return a placeholder "UnsupportedType" object (this idea suggested by Austin). This provides a compromise between implementing the entire kitchen sink and simply returning an error outright on any unknown type DIE. Fixes #29601. Change-Id: I2eeffa094c86ef3a2c358ee42e8e629d74cec2ed Reviewed-on: https://go-review.googlesource.com/c/go/+/158797 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- src/debug/dwarf/testdata/cppunsuptypes.cc | 34 +++++++++++++++++++++++++++++ src/debug/dwarf/testdata/cppunsuptypes.elf | Bin 0 -> 3920 bytes 2 files changed, 34 insertions(+) create mode 100644 src/debug/dwarf/testdata/cppunsuptypes.cc create mode 100644 src/debug/dwarf/testdata/cppunsuptypes.elf (limited to 'src/debug/dwarf/testdata') diff --git a/src/debug/dwarf/testdata/cppunsuptypes.cc b/src/debug/dwarf/testdata/cppunsuptypes.cc new file mode 100644 index 0000000000..e9281c7dec --- /dev/null +++ b/src/debug/dwarf/testdata/cppunsuptypes.cc @@ -0,0 +1,34 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// cppunsuptypes.elf built with g++ 7.3 +// g++ -g -c -o cppunsuptypes.elf cppunsuptypes.cc + +int i = 3; +double d = 3; + +// anonymous reference type +int &culprit = i; + +// named reference type +typedef double &dref; +dref dr = d; + +// incorporated into another type +typedef struct { + dref q; + int &r; +} hasrefs; + +hasrefs hr = { d, i }; + +// This code is intended to trigger a DWARF "pointer to member" type DIE +struct CS { int dm; }; + +int foo() +{ + int CS::* pdm = &CS::dm; + CS cs = {42}; + return cs.*pdm; +} diff --git a/src/debug/dwarf/testdata/cppunsuptypes.elf b/src/debug/dwarf/testdata/cppunsuptypes.elf new file mode 100644 index 0000000000..e955512ecd Binary files /dev/null and b/src/debug/dwarf/testdata/cppunsuptypes.elf differ -- cgit v1.3