diff mbox series

gcc: Fix gdbhooks.py VecPrinter for vec<> as well as vec<>* [PR109006]

Message ID 20230303180748.1645712-1-jwakely@redhat.com
State New
Headers show
Series gcc: Fix gdbhooks.py VecPrinter for vec<> as well as vec<>* [PR109006] | expand

Commit Message

Jonathan Wakely March 3, 2023, 6:07 p.m. UTC
This fixes Jakub's second testcase. The printer needs to do slightly
different things depending on whether the gdbval obejct is a vec or a
pointer to a vec.

OK for trunk?

-- >8 --

gcc/ChangeLog:

	PR middle-end/109006
	* gdbhooks.py (VecPrinter): Handle vec<T> as well as vec<T>*.
---
 gcc/gdbhooks.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Comments

Jakub Jelinek March 3, 2023, 6:12 p.m. UTC | #1
On Fri, Mar 03, 2023 at 06:07:48PM +0000, Jonathan Wakely via Gcc-patches wrote:
> This fixes Jakub's second testcase. The printer needs to do slightly
> different things depending on whether the gdbval obejct is a vec or a
> pointer to a vec.
> 
> OK for trunk?
> 
> -- >8 --
> 
> gcc/ChangeLog:
> 
> 	PR middle-end/109006
> 	* gdbhooks.py (VecPrinter): Handle vec<T> as well as vec<T>*.

Yes, thanks.

	Jakub
diff mbox series

Patch

diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py
index 78e6c97c30d..e29bd458909 100644
--- a/gcc/gdbhooks.py
+++ b/gcc/gdbhooks.py
@@ -461,13 +461,16 @@  class VecPrinter:
             return
         m_vecpfx = self.gdbval['m_vecpfx']
         m_num = m_vecpfx['m_num']
-        typ = self.gdbval.type
+        val = self.gdbval
+        typ = val.type
         if typ.code == gdb.TYPE_CODE_PTR:
             typ = typ.target()
-        typ = typ.template_argument(0) # the type T
-        m_vecdata = (self.gdbval.address + 1).cast(typ.pointer())
+        else:
+            val = val.address
+        typ_T = typ.template_argument(0) # the type T
+        vecdata = (val + 1).cast(typ_T.pointer())
         for i in range(m_num):
-            yield ('[%d]' % i, m_vecdata[i])
+            yield ('[%d]' % i, vecdata[i])
 
 ######################################################################