diff options
author | Tom Tromey <tromey@adacore.com> | 2023-01-11 12:42:40 -0700 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2023-02-09 07:55:34 -0700 |
commit | 1775f8b3804744c22611ed0c9fd2df4f5b4d8641 (patch) | |
tree | 06c240bfc9fe68afe224cfc4e9bddc3e09e7850b /gdb/gdb-gdb.py.in | |
parent | 119f6cfbd0236c9684a8a12ff9241dc834418309 (diff) | |
download | gdb-1775f8b3804744c22611ed0c9fd2df4f5b4d8641.zip gdb-1775f8b3804744c22611ed0c9fd2df4f5b4d8641.tar.gz gdb-1775f8b3804744c22611ed0c9fd2df4f5b4d8641.tar.bz2 |
Increase size of main_type::nfields
main_type::nfields is a 'short', and has been for many years. PR
c++/29985 points out that 'short' is too narrow for an enum that
contains more than 2^15 constants.
This patch bumps the size of 'nfields'. To verify that the field
isn't directly used, it is also renamed. Note that this does not
affect the size of main_type on x86-64 Fedora 36. And, if it does
have a negative effect somewhere, it's worth considering that types
could be shrunk more drastically by using subclasses for the different
codes.
This is v2 of this patch, which has these changes:
* I changed nfields to 'unsigned', per Simon's request. I looked at
changing all the uses, but this quickly fans out into a very large
patch. (One additional tweak was needed, though.)
* I wrote a test case. I discovered that GCC cannot compile a large
enough C test case, so I resorted to using the DWARF assembler.
This test doesn't reproduce the crash, but it does fail without the
patch.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29985
Diffstat (limited to 'gdb/gdb-gdb.py.in')
-rw-r--r-- | gdb/gdb-gdb.py.in | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/gdb/gdb-gdb.py.in b/gdb/gdb-gdb.py.in index dbc4d77..95b7d84 100644 --- a/gdb/gdb-gdb.py.in +++ b/gdb/gdb-gdb.py.in @@ -261,8 +261,8 @@ class StructMainTypePrettyPrinter: fields.append("flags = [%s]" % self.flags_to_string()) fields.append("owner = %s" % self.owner_to_string()) fields.append("target_type = %s" % self.val["m_target_type"]) - if self.val["nfields"] > 0: - for fieldno in range(self.val["nfields"]): + if self.val["m_nfields"] > 0: + for fieldno in range(self.val["m_nfields"]): fields.append(self.struct_field_img(fieldno)) if self.val["code"] == gdb.TYPE_CODE_RANGE: fields.append(self.bounds_img()) |