On 9/23/24 4:33 AM, Alex Coplan wrote:
On 30/08/2024 18:11, Alex Coplan wrote:Hi, 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. I thought about trying to make VecPrinter.{to_string,children} robust against non-pointer values (i.e. actual vec structs) as the current calls to intptr will fail on those. However, I then realised that the current regex only matches pointer types: pp.add_printer_for_regex(r'vec<(\S+), (\S+), (\S+)> \*', 'vec', VecPrinter) That is somewhat at odds with the (pre-existing) code in VecPrinter.children which appears to attempt to handle non-pointer types. ISTM either we should drop the handling for non-pointer types (since the regex requires a pointer) or (perhaps more usefully) relax the regex to allow matching a plain vec<...> struct and fix the member functions to handle those properly. Any thoughts on that, Dave? Is the current patch OK as an intermediate step (manually tested by verifying both a vec*& and vec* print OK)?Gentle ping on this.
OK Jeff
