diff options
author | Alex Coplan <alex.coplan@arm.com> | 2024-11-26 15:10:29 +0000 |
---|---|---|
committer | Alex Coplan <alex.coplan@arm.com> | 2024-11-26 15:10:29 +0000 |
commit | 098a41cb972d3711ebcb518a72a1addfdb6c70cf (patch) | |
tree | 5734c60f247870a2990a8f7539949dd72af3c0d9 | |
parent | a22dfe208d94105a6e587a3b25e8fe8d62444d8a (diff) | |
download | gcc-098a41cb972d3711ebcb518a72a1addfdb6c70cf.zip gcc-098a41cb972d3711ebcb518a72a1addfdb6c70cf.tar.gz gcc-098a41cb972d3711ebcb518a72a1addfdb6c70cf.tar.bz2 |
gdbhooks: Handle references to vec* in VecPrinter
vec.h has this method:
template<typename T, typename A>
inline T *
vec_safe_push (vec<T, A, vl_embed> *&v, const T &obj CXX_MEM_STAT_INFO)
where v is a reference to a pointer to vec. This matches the regex for
VecPrinter, so gdbhooks.py attempts to print it but chokes on the reference.
I see the following:
#1 0x0000000002b84b7b in vec_safe_push<edge_def*, va_gc> (v=Traceback (most
recent call last):
File "$SRC/gcc/gcc/gdbhooks.py", line 486, in to_string
return '0x%x' % intptr(self.gdbval)
File "$SRC/gcc/gcc/gdbhooks.py", line 168, in intptr
return long(gdbval) if sys.version_info.major == 2 else int(gdbval)
gdb.error: Cannot convert value to long.
This patch makes VecPrinter handle such references by stripping them
(dereferencing) at the top of the relevant functions.
gcc/ChangeLog:
* gdbhooks.py (strip_ref): New. Use it ...
(VecPrinter.to_string): ... here,
(VecPrinter.children): ... and here.
-rw-r--r-- | gcc/gdbhooks.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py index 904ee28..a91e5fd 100644 --- a/gcc/gdbhooks.py +++ b/gcc/gdbhooks.py @@ -472,6 +472,11 @@ def get_vec_kind(val): else: assert False, f"unexpected vec kind {kind}" +def strip_ref(gdbval): + if gdbval.type.code == gdb.TYPE_CODE_REF: + return gdbval.referenced_value () + return gdbval + class VecPrinter: # -ex "up" -ex "p bb->preds" def __init__(self, gdbval): @@ -483,10 +488,10 @@ class VecPrinter: def to_string (self): # A trivial implementation; prettyprinting the contents is done # by gdb calling the "children" method below. - return '0x%x' % intptr(self.gdbval) + return '0x%x' % intptr(strip_ref(self.gdbval)) def children (self): - val = self.gdbval + val = strip_ref(self.gdbval) if intptr(val) != 0 and get_vec_kind(val) == VEC_KIND_PTR: val = val['m_vec'] |