diff options
author | Tom Tromey <tromey@adacore.com> | 2022-01-04 08:52:40 -0700 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2022-01-26 06:49:51 -0700 |
commit | dedb7102b3b35f789fd5c140fe01917eaeae2853 (patch) | |
tree | 9331b631ef404e8704a7a4f5b939fdb1192ef4ee /gdb/arm-tdep.c | |
parent | 1da5d0e664e362857153af8682321a89ebafb7f6 (diff) | |
download | gdb-dedb7102b3b35f789fd5c140fe01917eaeae2853.zip gdb-dedb7102b3b35f789fd5c140fe01917eaeae2853.tar.gz gdb-dedb7102b3b35f789fd5c140fe01917eaeae2853.tar.bz2 |
Fix another crash with gdb parameters in Python
While looking into the language-capturing issue, I found another way
to crash gdb using parameters from Python:
(gdb) python print(gdb.parameter('endian'))
(This is related to PR python/12188, though this patch isn't going to
fix what that bug is really about.)
The problem here is that the global variable that underlies the
"endian" parameter is initialized to NULL. However, that's not a
valid value for an "enum" set/show parameter.
My understanding is that, in gdb, an "enum" parameter's underlying
variable must have a value that is "==" (not just strcmp-equal) to one
of the values coming from the enum array. This invariant is relied on
in various places.
I started this patch by fixing the problem with "endian". Then I
added some assertions to add_setshow_enum_cmd to try to catch other
problems of the same type.
This patch fixes all the problems that I found. I also looked at all
the calls to add_setshow_enum_cmd to ensure that they were all
included in the gdb I tested. I think they are: there are no calls in
nat-* files, or in remote-sim.c; and I was trying a build with all
targets, Python, and Guile enabled.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=12188
Diffstat (limited to 'gdb/arm-tdep.c')
-rw-r--r-- | gdb/arm-tdep.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index f6bd76a..f46913e 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -9802,6 +9802,8 @@ _initialize_arm_tdep () size_t offset = strlen ("reg-names-"); const char *style = disasm_options->name[i]; valid_disassembly_styles[j++] = &style[offset]; + if (strcmp (&style[offset], "std") == 0) + disassembly_style = &style[offset]; length = snprintf (rdptr, rest, "%s - %s\n", &style[offset], disasm_options->description[i]); rdptr += length; |