public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-6730] gdbhooks: Update gdbhooks.py for recent tree_code_type changes [PR108634]
@ 2023-03-17  7:45 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2023-03-17  7:45 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:be6195c7e7adc7465214a0dc347c592822713c3f

commit r13-6730-gbe6195c7e7adc7465214a0dc347c592822713c3f
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Mar 17 08:44:19 2023 +0100

    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  <jakub@redhat.com>
    
            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.

Diff:
---
 gcc/gdbhooks.py | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py
index 32ddaf625e6..80280225644 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 <int N>
+        # 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 '<ggc_freed 0x%x>' % 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')

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-17  7:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-17  7:45 [gcc r13-6730] gdbhooks: Update gdbhooks.py for recent tree_code_type changes [PR108634] Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).