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.
This commit is contained in:
Tom Tromey 2022-04-27 15:22:56 -06:00
parent 12f26cb22e
commit bdc8cfc1e4
7 changed files with 48 additions and 20 deletions

View file

@ -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