From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/5] Regularize some DWARF type initialization
Date: Tue, 05 Sep 2023 13:47:02 -0600 [thread overview]
Message-ID: <20230905-dap-30821-pointers-v1-2-0d7323327678@adacore.com> (raw)
In-Reply-To: <20230905-dap-30821-pointers-v1-0-0d7323327678@adacore.com>
In one spot, it will be convenient for a subsequent patch if the CU is
passed to a type-creation helper function. In another spot, remove
the redundant 'objfile' parameter to another such function.
---
gdb/dwarf2/read.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 2335bbe0aba..63a2a83f0a2 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -15090,9 +15090,10 @@ gnat_encoded_fixed_point_type_info (const char *name)
it to guess the correct format if necessary. */
static struct type *
-dwarf2_init_float_type (struct objfile *objfile, int bits, const char *name,
+dwarf2_init_float_type (struct dwarf2_cu *cu, int bits, const char *name,
const char *name_hint, enum bfd_endian byte_order)
{
+ struct objfile *objfile = cu->per_objfile->objfile;
struct gdbarch *gdbarch = objfile->arch ();
const struct floatformat **format;
struct type *type;
@@ -15110,10 +15111,11 @@ dwarf2_init_float_type (struct objfile *objfile, int bits, const char *name,
/* Allocate an integer type of size BITS and name NAME. */
static struct type *
-dwarf2_init_integer_type (struct dwarf2_cu *cu, struct objfile *objfile,
- int bits, int unsigned_p, const char *name)
+dwarf2_init_integer_type (struct dwarf2_cu *cu, int bits, int unsigned_p,
+ const char *name)
{
struct type *type;
+ struct objfile *objfile = cu->per_objfile->objfile;
/* Versions of Intel's C Compiler generate an integer type called "void"
instead of using DW_TAG_unspecified_type. This has been seen on
@@ -15167,10 +15169,10 @@ has_zero_over_zero_small_attribute (struct die_info *die,
component. */
static struct type *
dwarf2_init_complex_target_type (struct dwarf2_cu *cu,
- struct objfile *objfile,
int bits, const char *name_hint,
enum bfd_endian byte_order)
{
+ struct objfile *objfile = cu->per_objfile->objfile;
gdbarch *gdbarch = objfile->arch ();
struct type *tt = nullptr;
@@ -15218,7 +15220,7 @@ dwarf2_init_complex_target_type (struct dwarf2_cu *cu,
tt = nullptr;
const char *name = (tt == nullptr) ? nullptr : tt->name ();
- return dwarf2_init_float_type (objfile, bits, name, name_hint, byte_order);
+ return dwarf2_init_float_type (cu, bits, name, name_hint, byte_order);
}
/* Find a representation of a given base type and install
@@ -15321,7 +15323,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
type = init_boolean_type (alloc, bits, 1, name);
break;
case DW_ATE_complex_float:
- type = dwarf2_init_complex_target_type (cu, objfile, bits / 2, name,
+ type = dwarf2_init_complex_target_type (cu, bits / 2, name,
byte_order);
if (type->code () == TYPE_CODE_ERROR)
{
@@ -15341,10 +15343,10 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
type = init_decfloat_type (alloc, bits, name);
break;
case DW_ATE_float:
- type = dwarf2_init_float_type (objfile, bits, name, name, byte_order);
+ type = dwarf2_init_float_type (cu, bits, name, name, byte_order);
break;
case DW_ATE_signed:
- type = dwarf2_init_integer_type (cu, objfile, bits, 0, name);
+ type = dwarf2_init_integer_type (cu, bits, 0, name);
break;
case DW_ATE_unsigned:
if (cu->lang () == language_fortran
@@ -15352,7 +15354,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
&& startswith (name, "character("))
type = init_character_type (alloc, bits, 1, name);
else
- type = dwarf2_init_integer_type (cu, objfile, bits, 1, name);
+ type = dwarf2_init_integer_type (cu, bits, 1, name);
break;
case DW_ATE_signed_char:
if (cu->lang () == language_ada
@@ -15361,7 +15363,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
|| cu->lang () == language_fortran)
type = init_character_type (alloc, bits, 0, name);
else
- type = dwarf2_init_integer_type (cu, objfile, bits, 0, name);
+ type = dwarf2_init_integer_type (cu, bits, 0, name);
break;
case DW_ATE_unsigned_char:
if (cu->lang () == language_ada
@@ -15371,7 +15373,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
|| cu->lang () == language_rust)
type = init_character_type (alloc, bits, 1, name);
else
- type = dwarf2_init_integer_type (cu, objfile, bits, 1, name);
+ type = dwarf2_init_integer_type (cu, bits, 1, name);
break;
case DW_ATE_UTF:
{
--
2.40.1
next prev parent reply other threads:[~2023-09-05 19:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-05 19:47 [PATCH 0/5] Handle pointers and references correctly in DAP Tom Tromey
2023-09-05 19:47 ` [PATCH 1/5] Pass a type allocator to init_fixed_point_type Tom Tromey
2023-09-05 19:47 ` Tom Tromey [this message]
2023-09-05 19:47 ` [PATCH 3/5] Add is_array_like and to_array to language_defn Tom Tromey
2023-09-05 19:47 ` [PATCH 4/5] Give a language to a type Tom Tromey
2023-09-05 19:47 ` [PATCH 5/5] Handle pointers and references correctly in DAP Tom Tromey
2023-09-19 19:30 ` [PATCH 0/5] " 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=20230905-dap-30821-pointers-v1-2-0d7323327678@adacore.com \
--to=tromey@adacore.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).