From aeee4812442c996f184965ce6894e5f3d3657c0f Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 2 Jan 2023 09:37:43 +0100 Subject: Update copyright years. --- gcc/gdbhooks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/gdbhooks.py') diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py index 8736eca..c9dea9b 100644 --- a/gcc/gdbhooks.py +++ b/gcc/gdbhooks.py @@ -1,5 +1,5 @@ # Python hooks for gdb for debugging GCC -# Copyright (C) 2013-2022 Free Software Foundation, Inc. +# Copyright (C) 2013-2023 Free Software Foundation, Inc. # Contributed by David Malcolm -- cgit v1.1 From ce1c99f1ccd7b1229a4f8531d6b6de6cf571a9ef Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Fri, 3 Mar 2023 16:41:29 +0000 Subject: gcc: Adjust gdbhooks.py VecPrinter for vec layout changes [PR109006] gcc/ChangeLog: PR middle-end/109006 * gdbhooks.py (VecPrinter): Adjust for new vec layout. --- gcc/gdbhooks.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'gcc/gdbhooks.py') diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py index c9dea9b..78e6c97 100644 --- a/gcc/gdbhooks.py +++ b/gcc/gdbhooks.py @@ -461,7 +461,11 @@ class VecPrinter: return m_vecpfx = self.gdbval['m_vecpfx'] m_num = m_vecpfx['m_num'] - m_vecdata = self.gdbval['m_vecdata'] + typ = self.gdbval.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()) for i in range(m_num): yield ('[%d]' % i, m_vecdata[i]) -- cgit v1.1 From 59a576f274b9093fd4b25eb6be556b40c2424478 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Fri, 3 Mar 2023 16:41:29 +0000 Subject: gcc: Fix gdbhooks.py VecPrinter for vec<> as well as vec<>* [PR109006] gcc/ChangeLog: PR middle-end/109006 * gdbhooks.py (VecPrinter): Handle vec as well as vec*. --- gcc/gdbhooks.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'gcc/gdbhooks.py') diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py index 78e6c97..e29bd45 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]) ###################################################################### -- cgit v1.1 From 4ee2f419fe42222dbb21dfb0622cc7c0e46a2261 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Sat, 4 Mar 2023 11:24:04 +0100 Subject: Remove remaining traces of m_vecdata from comments [PR109006] The following patch adjusts remaining references to the removed m_vecdata array from vec.h in various comments. 2023-03-04 Jakub Jelinek PR middle-end/109006 * vec.cc (test_auto_alias): Adjust comment for removal of m_vecdata. * read-rtl-function.cc (function_reader::parse_block): Likewise. * gdbhooks.py: Likewise. --- gcc/gdbhooks.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gcc/gdbhooks.py') diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py index e29bd45..32ddaf6 100644 --- a/gcc/gdbhooks.py +++ b/gcc/gdbhooks.py @@ -133,10 +133,10 @@ vector: attempting to do so instead gives you the vec itself (for vec[0]), or a (probably) invalid cast to vec<> for the memory after the vec (for vec[1] onwards). -Instead (for now) you must access m_vecdata: - (gdb) p bb->preds->m_vecdata[0] +Instead (for now) you must access the payload directly: + (gdb) p ((edge_def**)(bb->preds+1))[0] $20 = 5)> - (gdb) p bb->preds->m_vecdata[1] + (gdb) p ((edge_def**)(bb->preds+1))[1] $21 = 5)> """ import os.path -- cgit v1.1 From be6195c7e7adc7465214a0dc347c592822713c3f Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 17 Mar 2023 08:44:19 +0100 Subject: gdbhooks: Update gdbhooks.py for recent tree_code_type changes [PR108634] On Mon, Mar 13, 2023 at 04:15:12PM -0400, Jason Merrill wrote: > The r13-6577 change to use tree_code_type_tmpl in earlier C++ dialects broke > gdbhooks, which expects tree_code_type to always be available. I considered > trying to make gdbhooks more robust, but it seemed simpler to define > tree_code_type as a reference to the template. As I said earlier, I think it is better to tweak gdbhooks. The following patch does that, I've tested it now both with gcc 12 and older gcc as system compiler and the patch fixed the latter while keeping the former working as before. 2023-03-17 Jakub Jelinek PR plugins/108634 * gdbhooks.py (TreePrinter.to_string): Wrap gdb.parse_and_eval('tree_code_type') in a try block, parse and eval 'tree_code_type_tmpl<0>::tree_code_type' instead if it raises exception. Update comments for the recent tree_code_type changes. --- gcc/gdbhooks.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'gcc/gdbhooks.py') diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py index 32ddaf6..8028022 100644 --- a/gcc/gdbhooks.py +++ b/gcc/gdbhooks.py @@ -220,13 +220,23 @@ class TreePrinter: val_TREE_CODE = self.node.TREE_CODE() - # extern const enum tree_code_class tree_code_type[]; + # constexpr inline enum tree_code_class tree_code_type[] = { ... }; # #define TREE_CODE_CLASS(CODE) tree_code_type[(int) (CODE)] + # or + # template + # struct tree_code_type_tmpl { + # static constexpr enum tree_code_class tree_code_type[] = { ... }; + # }; }; + # #define TREE_CODE_CLASS(CODE) \ + # tree_code_type_tmpl <0>::tree_code_type[(int) (CODE)] if val_TREE_CODE == 0xa5a5: return '' % intptr(self.gdbval) - val_tree_code_type = gdb.parse_and_eval('tree_code_type') + try: + val_tree_code_type = gdb.parse_and_eval('tree_code_type') + except: + val_tree_code_type = gdb.parse_and_eval('tree_code_type_tmpl<0>::tree_code_type') val_tclass = val_tree_code_type[val_TREE_CODE] val_tree_code_name = gdb.parse_and_eval('tree_code_name') -- cgit v1.1