public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 19/20] Add some types to struct builtin_type
Date: Mon, 13 Mar 2023 16:08:19 -0600	[thread overview]
Message-ID: <20230313-split-objfile-type-allocator-2-v1-19-69ba773ac17b@tromey.com> (raw)
In-Reply-To: <20230313-split-objfile-type-allocator-2-v1-0-69ba773ac17b@tromey.com>

This adds some types to struct builtin_type, ensuring it contains all
the types currently used by objfile_type.
---
 gdb/gdbtypes.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/gdbtypes.h | 15 +++++++++++++++
 2 files changed, 65 insertions(+)

diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 000e210940c..8fff30f9409 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -6062,6 +6062,56 @@ create_gdbtypes_data (struct gdbarch *gdbarch)
   builtin_type->xmethod
     = alloc.new_type (TYPE_CODE_XMETHOD, 0, "<xmethod>");
 
+  /* This type represents a type that was unrecognized in symbol read-in.  */
+  builtin_type->builtin_error
+    = alloc.new_type (TYPE_CODE_ERROR, 0, "<unknown type>");
+
+  /* The following set of types is used for symbols with no
+     debug information.  */
+  builtin_type->nodebug_text_symbol
+    = alloc.new_type (TYPE_CODE_FUNC, TARGET_CHAR_BIT,
+		      "<text variable, no debug info>");
+
+  builtin_type->nodebug_text_gnu_ifunc_symbol
+    = alloc.new_type (TYPE_CODE_FUNC, TARGET_CHAR_BIT,
+		      "<text gnu-indirect-function variable, no debug info>");
+  builtin_type->nodebug_text_gnu_ifunc_symbol->set_is_gnu_ifunc (true);
+
+  builtin_type->nodebug_got_plt_symbol
+    = init_pointer_type (alloc, gdbarch_addr_bit (gdbarch),
+			 "<text from jump slot in .got.plt, no debug info>",
+			 builtin_type->nodebug_text_symbol);
+  builtin_type->nodebug_data_symbol
+    = alloc.new_type (TYPE_CODE_ERROR, 0, "<data variable, no debug info>");
+  builtin_type->nodebug_unknown_symbol
+    = alloc.new_type (TYPE_CODE_ERROR, 0,
+		      "<variable (not text or data), no debug info>");
+  builtin_type->nodebug_tls_symbol
+    = alloc.new_type (TYPE_CODE_ERROR, 0,
+		      "<thread local variable, no debug info>");
+
+  /* NOTE: on some targets, addresses and pointers are not necessarily
+     the same.
+
+     The upshot is:
+     - gdb's `struct type' always describes the target's
+       representation.
+     - gdb's `struct value' objects should always hold values in
+       target form.
+     - gdb's CORE_ADDR values are addresses in the unified virtual
+       address space that the assembler and linker work with.  Thus,
+       since target_read_memory takes a CORE_ADDR as an argument, it
+       can access any memory on the target, even if the processor has
+       separate code and data address spaces.
+
+     In this context, builtin_type->builtin_core_addr is a bit odd:
+     it's a target type for a value the target will never see.  It's
+     only used to hold the values of (typeless) linker symbols, which
+     are indeed in the unified virtual address space.  */
+
+  builtin_type->builtin_core_addr
+    = init_integer_type (alloc, gdbarch_addr_bit (gdbarch), 1,
+			 "__CORE_ADDR");
   return builtin_type;
 }
 
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 8a0c57b7a05..34bec887676 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -2098,6 +2098,21 @@ struct builtin_type
 
   /* * This type is used to represent an xmethod.  */
   struct type *xmethod = nullptr;
+
+  /* * This type is used to represent symbol addresses.  */
+  struct type *builtin_core_addr = nullptr;
+
+  /* * This type represents a type that was unrecognized in symbol
+     read-in.  */
+  struct type *builtin_error = nullptr;
+
+  /* * Types used for symbols with no debug information.  */
+  struct type *nodebug_text_symbol = nullptr;
+  struct type *nodebug_text_gnu_ifunc_symbol = nullptr;
+  struct type *nodebug_got_plt_symbol = nullptr;
+  struct type *nodebug_data_symbol = nullptr;
+  struct type *nodebug_unknown_symbol = nullptr;
+  struct type *nodebug_tls_symbol = nullptr;
 };
 
 /* * Return the type table for the specified architecture.  */

-- 
2.39.1


  parent reply	other threads:[~2023-03-13 22:08 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-13 22:08 [PATCH 00/20] Remove objfile_type Tom Tromey
2023-03-13 22:08 ` [PATCH 01/20] Introduce type_allocator Tom Tromey
2023-03-13 22:08 ` [PATCH 02/20] Remove alloc_type_arch Tom Tromey
2023-03-13 22:08 ` [PATCH 03/20] Remove alloc_type_copy Tom Tromey
2023-03-13 22:08 ` [PATCH 04/20] Remove alloc_type Tom Tromey
2023-03-13 22:08 ` [PATCH 05/20] Reuse existing builtin types Tom Tromey
2023-03-13 22:08 ` [PATCH 06/20] Remove arch_type Tom Tromey
2023-03-13 22:08 ` [PATCH 07/20] Remove init_type Tom Tromey
2023-03-13 22:08 ` [PATCH 08/20] Unify arch_integer_type and init_integer_type Tom Tromey
2023-03-13 22:08 ` [PATCH 09/20] Unify arch_character_type and init_character_type Tom Tromey
2023-03-13 22:08 ` [PATCH 10/20] Unify arch_boolean_type and init_boolean_type Tom Tromey
2023-03-13 22:08 ` [PATCH 11/20] Unify arch_float_type and init_float_type Tom Tromey
2023-03-13 22:08 ` [PATCH 12/20] Unify arch_decfloat_type and init_decfloat_type Tom Tromey
2023-03-13 22:08 ` [PATCH 13/20] Unify arch_pointer_type and init_pointer_type Tom Tromey
2023-03-13 22:08 ` [PATCH 14/20] Use type allocator for range types Tom Tromey
2023-03-14 14:41   ` Simon Marchi
2023-03-18 15:56     ` Tom Tromey
2023-03-13 22:08 ` [PATCH 15/20] Use type allocator for array types Tom Tromey
2023-03-13 22:08 ` [PATCH 16/20] Use type allocator for set types Tom Tromey
2023-03-13 22:08 ` [PATCH 17/20] Use builtin type when appropriate Tom Tromey
2023-03-13 22:08 ` [PATCH 18/20] Rename objfile_type to builtin_type Tom Tromey
2023-03-13 22:08 ` Tom Tromey [this message]
2023-03-13 22:08 ` [PATCH 20/20] Remove objfile_type Tom Tromey
2023-03-14 14:48 ` [PATCH 00/20] " Simon Marchi
2023-03-18 15:57   ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230313-split-objfile-type-allocator-2-v1-19-69ba773ac17b@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).