[00/20] Remove objfile_type

Message ID 20230313-split-objfile-type-allocator-2-v1-0-69ba773ac17b@tromey.com
Headers
Series Remove objfile_type |

Message

Tom Tromey March 13, 2023, 10:08 p.m. UTC
  The "split objfile" to-do list has an item for moving objfile_type to
the per-BFD object.  However, I noticed recently that the contents of
objfile_type depend solely on the gdbarch.  So, there's no reason to
even have this on the objfile at all.  In fact, I reasoned, we could
go further and remove it in favor of the per-gdbarch builtin_type.

However, this doesn't work due to the way type allocation is done.  I
have never much liked this part of gdb, so this series first attempts
to clean it up, by introducing a type allocator.  This allows for the
removal of some code.  During this process, the symbol readers are
changed to prefer allocation of their types on the per-objfile
obstack, which I think is more correct anyway.

Finally, by the end of the series, objfile_type can be removed.

Regression tested on x86-64 Fedora 36.

Tom

---
Tom Tromey (20):
      Introduce type_allocator
      Remove alloc_type_arch
      Remove alloc_type_copy
      Remove alloc_type
      Reuse existing builtin types
      Remove arch_type
      Remove init_type
      Unify arch_integer_type and init_integer_type
      Unify arch_character_type and init_character_type
      Unify arch_boolean_type and init_boolean_type
      Unify arch_float_type and init_float_type
      Unify arch_decfloat_type and init_decfloat_type
      Unify arch_pointer_type and init_pointer_type
      Use type allocator for range types
      Use type allocator for array types
      Use type allocator for set types
      Use builtin type when appropriate
      Rename objfile_type to builtin_type
      Add some types to struct builtin_type
      Remove objfile_type

 gdb/ada-lang.c                      |  92 ++---
 gdb/amdgpu-tdep.c                   |   5 +-
 gdb/arm-tdep.c                      |   9 +-
 gdb/avr-tdep.c                      |   6 +-
 gdb/coffread.c                      |  42 +--
 gdb/compile/compile-c-symbols.c     |  10 +-
 gdb/compile/compile-c-types.c       |  11 +-
 gdb/compile/compile-cplus-symbols.c |  10 +-
 gdb/compile/compile-cplus-types.c   |   5 +-
 gdb/csky-tdep.c                     |   5 +-
 gdb/ctfread.c                       |  47 +--
 gdb/d-lang.c                        |  44 +--
 gdb/dwarf2/cu.c                     |   2 +-
 gdb/dwarf2/expr.c                   |   9 +-
 gdb/dwarf2/read.c                   | 111 +++---
 gdb/f-exp.y                         |  13 +-
 gdb/f-lang.c                        |  55 +--
 gdb/fbsd-tdep.c                     |  20 +-
 gdb/ft32-tdep.c                     |   5 +-
 gdb/gdbtypes.c                      | 704 +++++++++++-------------------------
 gdb/gdbtypes.h                      | 266 ++++++++++----
 gdb/gnu-v3-abi.c                    |   9 +-
 gdb/go-lang.c                       |  34 +-
 gdb/ia64-tdep.c                     |   9 +-
 gdb/jit.c                           |   5 +-
 gdb/linux-tdep.c                    |  29 +-
 gdb/m2-lang.c                       |  12 +-
 gdb/m32c-tdep.c                     |  24 +-
 gdb/m68k-tdep.c                     |   9 +-
 gdb/mdebugread.c                    |  95 ++---
 gdb/nds32-tdep.c                    |   7 +-
 gdb/netbsd-tdep.c                   |  22 +-
 gdb/objfiles.c                      |   4 +-
 gdb/opencl-lang.c                   |  43 +--
 gdb/parse.c                         |  12 +-
 gdb/rl78-tdep.c                     |  20 +-
 gdb/rs6000-tdep.c                   |   3 +-
 gdb/rust-lang.c                     |  33 +-
 gdb/sh-tdep.c                       |   9 +-
 gdb/stabsread.c                     | 155 ++++----
 gdb/target-descriptions.c           |  18 +-
 gdb/valops.c                        |  10 +-
 gdb/windows-tdep.c                  |  55 +--
 gdb/xcoffread.c                     |   4 +-
 gdb/xtensa-tdep.c                   |   3 +-
 gdb/z80-tdep.c                      |   7 +-
 46 files changed, 1014 insertions(+), 1088 deletions(-)
---
base-commit: 7fee66abd3fd69a0c4dc6c8dcd9aa49eede3864e
change-id: 20230313-split-objfile-type-allocator-2-07980fa05a7e

Best regards,
  

Comments

Simon Marchi March 14, 2023, 2:48 p.m. UTC | #1
On 3/13/23 18:08, Tom Tromey wrote:
> The "split objfile" to-do list has an item for moving objfile_type to
> the per-BFD object.  However, I noticed recently that the contents of
> objfile_type depend solely on the gdbarch.  So, there's no reason to
> even have this on the objfile at all.  In fact, I reasoned, we could
> go further and remove it in favor of the per-gdbarch builtin_type.
> 
> However, this doesn't work due to the way type allocation is done.  I
> have never much liked this part of gdb, so this series first attempts
> to clean it up, by introducing a type allocator.  This allows for the
> removal of some code.  During this process, the symbol readers are
> changed to prefer allocation of their types on the per-objfile
> obstack, which I think is more correct anyway.
> 
> Finally, by the end of the series, objfile_type can be removed.

I went quickly through the series, it looks like a nice
simplification.  The type_allocator stuff seems to remove a lot of
duplication, and obviously the removal of objfile_type does too.

Given I just gave it a quick look:

Reviewed-By: Simon Marchi <simon.marchi@efficios.com>

Simon
  
Tom Tromey March 18, 2023, 3:57 p.m. UTC | #2
Simon> I went quickly through the series, it looks like a nice
Simon> simplification.  The type_allocator stuff seems to remove a lot of
Simon> duplication, and obviously the removal of objfile_type does too.

Simon> Given I just gave it a quick look:

Simon> Reviewed-By: Simon Marchi <simon.marchi@efficios.com>

Thanks.  I'm rebuilding it & re-testing it.  Since the changes were
pretty trivial (some parameters names in a .h and a couple of comment
changes), I'm not going to re-send it.  I'll check it in once regression
testing is done.

Tom