From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH 07/14] ODR warning for "struct stack_item"
Date: Wed, 18 May 2022 12:00:42 -0600 [thread overview]
Message-ID: <20220518180049.2337257-8-tromey@adacore.com> (raw)
In-Reply-To: <20220518180049.2337257-1-tromey@adacore.com>
"struct stack_item" is defined in multiple .c files, causing ODR
warnings. This patch renames these types.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=22395
---
gdb/arm-tdep.c | 21 +++++++++++----------
gdb/avr-tdep.c | 22 +++++++++++-----------
gdb/cris-tdep.c | 19 ++++++++++---------
gdb/csky-tdep.c | 8 ++++----
4 files changed, 36 insertions(+), 34 deletions(-)
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 49664093f00..07836cfa1d5 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -3844,18 +3844,19 @@ arm_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
/* When arguments must be pushed onto the stack, they go on in reverse
order. The code below implements a FILO (stack) to do this. */
-struct stack_item
+struct arm_stack_item
{
int len;
- struct stack_item *prev;
+ struct arm_stack_item *prev;
gdb_byte *data;
};
-static struct stack_item *
-push_stack_item (struct stack_item *prev, const gdb_byte *contents, int len)
+static struct arm_stack_item *
+push_stack_item (struct arm_stack_item *prev, const gdb_byte *contents,
+ int len)
{
- struct stack_item *si;
- si = XNEW (struct stack_item);
+ struct arm_stack_item *si;
+ si = XNEW (struct arm_stack_item);
si->data = (gdb_byte *) xmalloc (len);
si->len = len;
si->prev = prev;
@@ -3863,10 +3864,10 @@ push_stack_item (struct stack_item *prev, const gdb_byte *contents, int len)
return si;
}
-static struct stack_item *
-pop_stack_item (struct stack_item *si)
+static struct arm_stack_item *
+pop_stack_item (struct arm_stack_item *si)
{
- struct stack_item *dead = si;
+ struct arm_stack_item *dead = si;
si = si->prev;
xfree (dead->data);
xfree (dead);
@@ -4184,7 +4185,7 @@ arm_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
int argnum;
int argreg;
int nstack;
- struct stack_item *si = NULL;
+ struct arm_stack_item *si = NULL;
int use_vfp_abi;
struct type *ftype;
unsigned vfp_regs_free = (1 << 16) - 1;
diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c
index 9e73c507b2e..e103045cb23 100644
--- a/gdb/avr-tdep.c
+++ b/gdb/avr-tdep.c
@@ -1199,18 +1199,19 @@ avr_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
/* When arguments must be pushed onto the stack, they go on in reverse
order. The below implements a FILO (stack) to do this. */
-struct stack_item
+struct avr_stack_item
{
int len;
- struct stack_item *prev;
+ struct avr_stack_item *prev;
gdb_byte *data;
};
-static struct stack_item *
-push_stack_item (struct stack_item *prev, const bfd_byte *contents, int len)
+static struct avr_stack_item *
+push_stack_item (struct avr_stack_item *prev, const bfd_byte *contents,
+ int len)
{
- struct stack_item *si;
- si = XNEW (struct stack_item);
+ struct avr_stack_item *si;
+ si = XNEW (struct avr_stack_item);
si->data = (gdb_byte *) xmalloc (len);
si->len = len;
si->prev = prev;
@@ -1218,11 +1219,10 @@ push_stack_item (struct stack_item *prev, const bfd_byte *contents, int len)
return si;
}
-static struct stack_item *pop_stack_item (struct stack_item *si);
-static struct stack_item *
-pop_stack_item (struct stack_item *si)
+static struct avr_stack_item *
+pop_stack_item (struct avr_stack_item *si)
{
- struct stack_item *dead = si;
+ struct avr_stack_item *dead = si;
si = si->prev;
xfree (dead->data);
xfree (dead);
@@ -1281,7 +1281,7 @@ avr_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
int call_length = tdep->call_length;
CORE_ADDR return_pc = avr_convert_iaddr_to_raw (bp_addr);
int regnum = AVR_ARGN_REGNUM;
- struct stack_item *si = NULL;
+ struct avr_stack_item *si = NULL;
if (return_method == return_method_struct)
{
diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
index 898d277b3fe..efd728a5229 100644
--- a/gdb/cris-tdep.c
+++ b/gdb/cris-tdep.c
@@ -656,17 +656,18 @@ static CORE_ADDR crisv32_scan_prologue (CORE_ADDR pc,
order. The below implements a FILO (stack) to do this.
Copied from d10v-tdep.c. */
-struct stack_item
+struct cris_stack_item
{
int len;
- struct stack_item *prev;
+ struct cris_stack_item *prev;
gdb_byte *data;
};
-static struct stack_item *
-push_stack_item (struct stack_item *prev, const gdb_byte *contents, int len)
+static struct cris_stack_item *
+push_stack_item (struct cris_stack_item *prev, const gdb_byte *contents,
+ int len)
{
- struct stack_item *si = XNEW (struct stack_item);
+ struct cris_stack_item *si = XNEW (struct cris_stack_item);
si->data = (gdb_byte *) xmalloc (len);
si->len = len;
si->prev = prev;
@@ -674,10 +675,10 @@ push_stack_item (struct stack_item *prev, const gdb_byte *contents, int len)
return si;
}
-static struct stack_item *
-pop_stack_item (struct stack_item *si)
+static struct cris_stack_item *
+pop_stack_item (struct cris_stack_item *si)
{
- struct stack_item *dead = si;
+ struct cris_stack_item *dead = si;
si = si->prev;
xfree (dead->data);
xfree (dead);
@@ -798,7 +799,7 @@ cris_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
int argreg;
int argnum;
- struct stack_item *si = NULL;
+ struct cris_stack_item *si = NULL;
/* Push the return address. */
regcache_cooked_write_unsigned (regcache, SRP_REGNUM, bp_addr);
diff --git a/gdb/csky-tdep.c b/gdb/csky-tdep.c
index a9b53916561..4c2aa010cb4 100644
--- a/gdb/csky-tdep.c
+++ b/gdb/csky-tdep.c
@@ -307,9 +307,9 @@ csky_register_type (struct gdbarch *gdbarch, int reg_nr)
/* Data structure to marshall items in a dummy stack frame when
calling a function in the inferior. */
-struct stack_item
+struct csky_stack_item
{
- stack_item (int len_, const gdb_byte *data_)
+ csky_stack_item (int len_, const gdb_byte *data_)
: len (len_), data (data_)
{}
@@ -330,7 +330,7 @@ csky_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
int argreg = CSKY_ABI_A0_REGNUM;
int last_arg_regnum = CSKY_ABI_LAST_ARG_REGNUM;
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- std::vector<stack_item> stack_items;
+ std::vector<csky_stack_item> stack_items;
/* Set the return address. For CSKY, the return breakpoint is
always at BP_ADDR. */
@@ -406,7 +406,7 @@ csky_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
}
/* Transfer the dummy stack frame to the target. */
- std::vector<stack_item>::reverse_iterator iter;
+ std::vector<csky_stack_item>::reverse_iterator iter;
for (iter = stack_items.rbegin (); iter != stack_items.rend (); ++iter)
{
sp -= iter->len;
--
2.34.1
next prev parent reply other threads:[~2022-05-18 18:01 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-18 18:00 [PATCH 00/14] More ODR fixes Tom Tromey
2022-05-18 18:00 ` [PATCH 01/14] Fix ODR warning in observable.h Tom Tromey
2022-05-18 18:00 ` [PATCH 02/14] ODR warnings for struct symloc Tom Tromey
2022-05-18 18:00 ` [PATCH 03/14] ODR warnings for struct nextfield Tom Tromey
2022-05-18 18:00 ` [PATCH 04/14] ODR warning for struct field_info Tom Tromey
2022-05-18 18:00 ` [PATCH 05/14] ODR warning for struct ext_link_map Tom Tromey
2022-05-18 18:00 ` [PATCH 06/14] ODR warning for "struct instruction_type" Tom Tromey
2022-05-18 18:00 ` Tom Tromey [this message]
2022-05-18 18:00 ` [PATCH 08/14] ODR warning for "struct find_targ_sec_arg" Tom Tromey
2022-05-18 18:00 ` [PATCH 09/14] ODR warning for "enum string_repr_result" Tom Tromey
2022-05-18 18:00 ` [PATCH 10/14] ODR warnings from overlay constants Tom Tromey
2022-05-18 18:00 ` [PATCH 11/14] ODR warnings for "struct insn_info" Tom Tromey
2022-05-18 18:00 ` [PATCH 12/14] ODR warnings for "struct insn_decode_record_t" Tom Tromey
2022-05-18 18:00 ` [PATCH 13/14] ODR warnings for "struct coff_symbol" Tom Tromey
2022-05-18 18:00 ` [PATCH 14/14] ODR warning for "main" Tom Tromey
2022-06-02 15:28 ` [PATCH 00/14] More ODR fixes 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=20220518180049.2337257-8-tromey@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).