aboutsummaryrefslogtreecommitdiff
path: root/gcc/gdbhooks.py
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2023-03-29 09:01:23 -0700
committerIan Lance Taylor <iant@golang.org>2023-03-29 09:01:23 -0700
commit6612f4f8cb9b0d5af18ec69ad04e56debc3e6ced (patch)
tree1deecdcfbf185c7044bc861d0ace51285c96cb62 /gcc/gdbhooks.py
parent795cffe109e28b248a54b8ee583cbae48368c2a7 (diff)
parentaa8f4242efc99f24de73c59d53996f28db28c13f (diff)
downloadgcc-6612f4f8cb9b0d5af18ec69ad04e56debc3e6ced.zip
gcc-6612f4f8cb9b0d5af18ec69ad04e56debc3e6ced.tar.gz
gcc-6612f4f8cb9b0d5af18ec69ad04e56debc3e6ced.tar.bz2
Merge from trunk revision aa8f4242efc99f24de73c59d53996f28db28c13f.
Diffstat (limited to 'gcc/gdbhooks.py')
-rw-r--r--gcc/gdbhooks.py33
1 files changed, 25 insertions, 8 deletions
diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py
index 8736eca..8028022 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 <dmalcolm@redhat.com>
@@ -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 = <edge 0x7ffff044d380 (3 -> 5)>
- (gdb) p bb->preds->m_vecdata[1]
+ (gdb) p ((edge_def**)(bb->preds+1))[1]
$21 = <edge 0x7ffff044d3b8 (4 -> 5)>
"""
import os.path
@@ -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')
@@ -461,9 +471,16 @@ class VecPrinter:
return
m_vecpfx = self.gdbval['m_vecpfx']
m_num = m_vecpfx['m_num']
- m_vecdata = self.gdbval['m_vecdata']
+ val = self.gdbval
+ typ = val.type
+ if typ.code == gdb.TYPE_CODE_PTR:
+ typ = typ.target()
+ 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])
######################################################################