From bdc8cfc1e43ebc4029cf130c678b9e1a4e4e5682 Mon Sep 17 00:00:00 2001 From: Tom Tromey <tom@tromey.com> Date: Wed, 27 Apr 2022 15:22:56 -0600 Subject: Fix crash in gdbpy_parse_register_id I noticed that gdbpy_parse_register_id would assert if passed a Python object of a type it was not expecting. The included test case shows this crash. This patch fixes the problem and also changes gdbpy_parse_register_id to be more "Python-like" -- it always ensures the Python error is set when it fails, and the callers now simply propagate the existing exception. --- gdb/python/python-internal.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gdb/python/python-internal.h') diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index 800b03a..d624b23 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -819,7 +819,8 @@ typedef std::unique_ptr<Py_buffer, Py_buffer_deleter> Py_buffer_up; If a register is parsed successfully then *REG_NUM will have been updated, and true is returned. Otherwise the contents of *REG_NUM are - undefined, and false is returned. + undefined, and false is returned. When false is returned, the + Python error is set. The PYO_REG_ID object can be a string, the name of the register. This is the slowest approach as GDB has to map the name to a number for each -- cgit v1.1