From fa17a6814113ac22d8059d61514aa2c6e29b0aae Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sun, 12 Jun 2022 11:36:08 -0600 Subject: Handle bool specially in gdb.set_parameter PR python/29217 points out that gdb.parameter will return bool values, but gdb.set_parameter will not properly accept them. This patch fixes the problem by adding a special case to set_parameter. I looked at a fix involving rewriting set_parameter in C++. However, this one is simpler. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29217 --- gdb/python/lib/gdb/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gdb/python') diff --git a/gdb/python/lib/gdb/__init__.py b/gdb/python/lib/gdb/__init__.py index 17ee6a1..9e9978e 100644 --- a/gdb/python/lib/gdb/__init__.py +++ b/gdb/python/lib/gdb/__init__.py @@ -239,6 +239,13 @@ def find_pc_line(pc): def set_parameter(name, value): """Set the GDB parameter NAME to VALUE.""" + # Handle the specific case of booleans here, because gdb.parameter + # can return them, but they can't be passed to 'set' this way. + if isinstance(value, bool): + if value: + value = 'on' + else: + value = 'off' execute("set " + name + " " + str(value), to_string=True) -- cgit v1.1