public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: [PATCH 12/16] gdb: more 'const' in gdb/reggroups.{c,h}
Date: Thu, 31 Mar 2022 22:04:18 +0100	[thread overview]
Message-ID: <4b01539542862737b960b78af6decfc174bbc0d9.1648760270.git.aburgess@redhat.com> (raw)
In-Reply-To: <cover.1648760270.git.aburgess@redhat.com>

Convert the reggroup_new and reggroup_gdbarch_new functions to return
a 'const regggroup *', and fix up all the fallout.

There should be no user visible changes after this commit.
---
 gdb/csky-tdep.c    | 10 +++++-----
 gdb/i386-tdep.c    |  4 ++--
 gdb/m32c-tdep.c    |  2 +-
 gdb/m68hc11-tdep.c |  4 ++--
 gdb/mep-tdep.c     |  6 +++---
 gdb/nds32-tdep.c   | 20 ++++++++++----------
 gdb/reggroups.c    |  8 ++++----
 gdb/reggroups.h    | 13 +++++++------
 gdb/riscv-tdep.c   |  2 +-
 gdb/xtensa-tdep.c  |  8 ++++----
 10 files changed, 39 insertions(+), 38 deletions(-)

diff --git a/gdb/csky-tdep.c b/gdb/csky-tdep.c
index feb416a2406..3712409dbe8 100644
--- a/gdb/csky-tdep.c
+++ b/gdb/csky-tdep.c
@@ -61,11 +61,11 @@
 /* Control debugging information emitted in this file.  */
 static bool csky_debug = false;
 
-static struct reggroup *cr_reggroup;
-static struct reggroup *fr_reggroup;
-static struct reggroup *vr_reggroup;
-static struct reggroup *mmu_reggroup;
-static struct reggroup *prof_reggroup;
+static const reggroup *cr_reggroup;
+static const reggroup *fr_reggroup;
+static const reggroup *vr_reggroup;
+static const reggroup *mmu_reggroup;
+static const reggroup *prof_reggroup;
 
 /* Convenience function to print debug messages in prologue analysis.  */
 
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 0f9e3fde6ce..154d484c342 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -4531,8 +4531,8 @@ i386_svr4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 /* i386 register groups.  In addition to the normal groups, add "mmx"
    and "sse".  */
 
-static struct reggroup *i386_sse_reggroup;
-static struct reggroup *i386_mmx_reggroup;
+static const reggroup *i386_sse_reggroup;
+static const reggroup *i386_mmx_reggroup;
 
 static void
 i386_init_reggroups (void)
diff --git a/gdb/m32c-tdep.c b/gdb/m32c-tdep.c
index 5a767c9ed52..55ef5a551f8 100644
--- a/gdb/m32c-tdep.c
+++ b/gdb/m32c-tdep.c
@@ -35,7 +35,7 @@
 \f
 /* The m32c tdep structure.  */
 
-static struct reggroup *m32c_dma_reggroup;
+static const reggroup *m32c_dma_reggroup;
 
 /* The type of a function that moves the value of REG between CACHE or
    BUF --- in either direction.  */
diff --git a/gdb/m68hc11-tdep.c b/gdb/m68hc11-tdep.c
index 9d978d88018..5c1f20415c8 100644
--- a/gdb/m68hc11-tdep.c
+++ b/gdb/m68hc11-tdep.c
@@ -1346,8 +1346,8 @@ m68hc11_elf_make_msymbol_special (asymbol *sym, struct minimal_symbol *msym)
 /* 68HC11/68HC12 register groups.
    Identify real hard registers and soft registers used by gcc.  */
 
-static struct reggroup *m68hc11_soft_reggroup;
-static struct reggroup *m68hc11_hard_reggroup;
+static const reggroup *m68hc11_soft_reggroup;
+static const reggroup *m68hc11_hard_reggroup;
 
 static void
 m68hc11_init_reggroups (void)
diff --git a/gdb/mep-tdep.c b/gdb/mep-tdep.c
index e449c66c9b5..27a1c5dd1ca 100644
--- a/gdb/mep-tdep.c
+++ b/gdb/mep-tdep.c
@@ -1022,9 +1022,9 @@ mep_register_name (struct gdbarch *gdbarch, int regnr)
 
 
 /* Custom register groups for the MeP.  */
-static struct reggroup *mep_csr_reggroup; /* control/special */
-static struct reggroup *mep_cr_reggroup;  /* coprocessor general-purpose */
-static struct reggroup *mep_ccr_reggroup; /* coprocessor control */
+static const reggroup *mep_csr_reggroup; /* control/special */
+static const reggroup *mep_cr_reggroup;  /* coprocessor general-purpose */
+static const reggroup *mep_ccr_reggroup; /* coprocessor control */
 
 
 static int
diff --git a/gdb/nds32-tdep.c b/gdb/nds32-tdep.c
index a94a03ab2ab..06b129bdd31 100644
--- a/gdb/nds32-tdep.c
+++ b/gdb/nds32-tdep.c
@@ -314,16 +314,16 @@ nds32_dwarf2_reg_to_regnum (struct gdbarch *gdbarch, int num)
 }
 \f
 /* NDS32 register groups.  */
-static struct reggroup *nds32_cr_reggroup;
-static struct reggroup *nds32_ir_reggroup;
-static struct reggroup *nds32_mr_reggroup;
-static struct reggroup *nds32_dr_reggroup;
-static struct reggroup *nds32_pfr_reggroup;
-static struct reggroup *nds32_hspr_reggroup;
-static struct reggroup *nds32_dmar_reggroup;
-static struct reggroup *nds32_racr_reggroup;
-static struct reggroup *nds32_idr_reggroup;
-static struct reggroup *nds32_secur_reggroup;
+static const reggroup *nds32_cr_reggroup;
+static const reggroup *nds32_ir_reggroup;
+static const reggroup *nds32_mr_reggroup;
+static const reggroup *nds32_dr_reggroup;
+static const reggroup *nds32_pfr_reggroup;
+static const reggroup *nds32_hspr_reggroup;
+static const reggroup *nds32_dmar_reggroup;
+static const reggroup *nds32_racr_reggroup;
+static const reggroup *nds32_idr_reggroup;
+static const reggroup *nds32_secur_reggroup;
 
 static void
 nds32_init_reggroups (void)
diff --git a/gdb/reggroups.c b/gdb/reggroups.c
index 4607c4b674c..419e091c3c0 100644
--- a/gdb/reggroups.c
+++ b/gdb/reggroups.c
@@ -36,7 +36,7 @@ struct reggroup
   enum reggroup_type type;
 };
 
-struct reggroup *
+const reggroup *
 reggroup_new (const char *name, enum reggroup_type type)
 {
   struct reggroup *group = XNEW (struct reggroup);
@@ -48,7 +48,7 @@ reggroup_new (const char *name, enum reggroup_type type)
 
 /* See reggroups.h.  */
 
-struct reggroup *
+const reggroup *
 reggroup_gdbarch_new (struct gdbarch *gdbarch, const char *name,
 		      enum reggroup_type type)
 {
@@ -81,7 +81,7 @@ struct reggroups
 {
   /* Add GROUP to the list of register groups.  */
 
-  void add (struct reggroup *group)
+  void add (const reggroup *group)
   {
     gdb_assert (group != nullptr);
     gdb_assert (std::find (m_groups.begin(), m_groups.end(), group)
@@ -116,7 +116,7 @@ static struct gdbarch_data *reggroups_data;
 /* Add GROUP to the list of register groups for GDBARCH.  */
 
 void
-reggroup_add (struct gdbarch *gdbarch, struct reggroup *group)
+reggroup_add (struct gdbarch *gdbarch, const reggroup *group)
 {
   struct reggroups *groups
     = (struct reggroups *) gdbarch_data (gdbarch, reggroups_data);
diff --git a/gdb/reggroups.h b/gdb/reggroups.h
index 959191c4180..28bd00ff176 100644
--- a/gdb/reggroups.h
+++ b/gdb/reggroups.h
@@ -39,15 +39,16 @@ extern struct reggroup *const save_reggroup;
 extern struct reggroup *const restore_reggroup;
 
 /* Create a new local register group.  */
-extern struct reggroup *reggroup_new (const char *name,
-				      enum reggroup_type type);
+extern const reggroup *reggroup_new (const char *name,
+				     enum reggroup_type type);
+
 /* Create a new register group allocated onto the gdbarch obstack.  */
-extern struct reggroup *reggroup_gdbarch_new (struct gdbarch *gdbarch,
-					      const char *name,
-					      enum reggroup_type type);
+extern const reggroup *reggroup_gdbarch_new (struct gdbarch *gdbarch,
+					     const char *name,
+					     enum reggroup_type type);
 
 /* Add a register group (with attribute values) to the pre-defined list.  */
-extern void reggroup_add (struct gdbarch *gdbarch, struct reggroup *group);
+extern void reggroup_add (struct gdbarch *gdbarch, const reggroup *group);
 
 /* Register group attributes.  */
 extern const char *reggroup_name (const struct reggroup *reggroup);
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index ce62cfeb65c..f48260fbd93 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -129,7 +129,7 @@ struct riscv_unwind_cache
 
 /* RISC-V specific register group for CSRs.  */
 
-static reggroup *csr_reggroup = NULL;
+static const reggroup *csr_reggroup = nullptr;
 
 /* Callback function for user_reg_add.  */
 
diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c
index 6e478ee893d..89bdd7ffd28 100644
--- a/gdb/xtensa-tdep.c
+++ b/gdb/xtensa-tdep.c
@@ -712,10 +712,10 @@ xtensa_pseudo_register_write (struct gdbarch *gdbarch,
 		    _("invalid register number %d"), regnum);
 }
 
-static struct reggroup *xtensa_ar_reggroup;
-static struct reggroup *xtensa_user_reggroup;
-static struct reggroup *xtensa_vectra_reggroup;
-static struct reggroup *xtensa_cp[XTENSA_MAX_COPROCESSOR];
+static const reggroup *xtensa_ar_reggroup;
+static const reggroup *xtensa_user_reggroup;
+static const reggroup *xtensa_vectra_reggroup;
+static const reggroup *xtensa_cp[XTENSA_MAX_COPROCESSOR];
 
 static void
 xtensa_init_reggroups (void)
-- 
2.25.4


  parent reply	other threads:[~2022-03-31 21:04 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-31 21:04 [PATCH 00/16] Default register groups, and general related cleanup Andrew Burgess
2022-03-31 21:04 ` [PATCH 01/16] gdb: don't try to use readline before it's initialized Andrew Burgess
2022-03-31 21:04 ` [PATCH 02/16] gdb: add some const in gdb/reggroups.c Andrew Burgess
2022-03-31 21:04 ` [PATCH 03/16] gdb: make gdbarch_register_reggroup_p take a const reggroup * Andrew Burgess
2022-04-04 22:35   ` Lancelot SIX
2022-04-05  8:24     ` Andrew Burgess
2022-03-31 21:04 ` [PATCH 04/16] gdb: switch to using 'const reggroup *' in tui-regs.{c, h} Andrew Burgess
2022-03-31 21:04 ` [PATCH 05/16] gdb: use 'const reggroup *' in python/py-registers.c file Andrew Burgess
2022-03-31 21:04 ` [PATCH 06/16] gdb: have reggroup_find return a const Andrew Burgess
2022-03-31 21:04 ` [PATCH 07/16] gdb/tui: avoid theoretical bug with 'tui reg' command Andrew Burgess
2022-03-31 21:04 ` [PATCH 08/16] gdb/tui: fix 'tui reg next/prev' command when data window is hidden Andrew Burgess
2022-03-31 21:04 ` [PATCH 09/16] gdb: always add the default register groups Andrew Burgess
2022-03-31 21:04 ` [PATCH 10/16] gdb: convert reggroups to use a std::vector Andrew Burgess
2022-03-31 21:04 ` [PATCH 11/16] gdb: remove reggroup_next and reggroup_prev Andrew Burgess
2022-04-05 23:11   ` Lancelot SIX
2022-04-06 12:06     ` Andrew Burgess
2022-03-31 21:04 ` Andrew Burgess [this message]
2022-03-31 21:04 ` [PATCH 13/16] gdb: make the pre-defined register groups const Andrew Burgess
2022-03-31 21:04 ` [PATCH 14/16] gdb: convert reggroup to a C++ class with constructor, etc Andrew Burgess
2022-03-31 21:04 ` [PATCH 15/16] gdb: move struct reggroup into reggroups.h header Andrew Burgess
2022-03-31 21:04 ` [PATCH 16/16] gdb: update comments throughout reggroups.{c,h} files Andrew Burgess
2022-04-06 14:28   ` Simon Marchi
2022-04-06 12:04 ` [PATCHv2 00/16] Default register groups, and general related cleanup Andrew Burgess
2022-04-06 12:04   ` [PATCHv2 01/16] gdb: don't try to use readline before it's initialized Andrew Burgess
2022-04-06 12:57     ` Simon Marchi
2022-04-06 12:04   ` [PATCHv2 02/16] gdb: add some const in gdb/reggroups.c Andrew Burgess
2022-04-06 12:58     ` Simon Marchi
2022-04-06 12:04   ` [PATCHv2 03/16] gdb: make gdbarch_register_reggroup_p take a const reggroup * Andrew Burgess
2022-04-06 12:04   ` [PATCHv2 04/16] gdb: switch to using 'const reggroup *' in tui-regs.{c, h} Andrew Burgess
2022-04-06 12:04   ` [PATCHv2 05/16] gdb: use 'const reggroup *' in python/py-registers.c file Andrew Burgess
2022-04-06 12:04   ` [PATCHv2 06/16] gdb: have reggroup_find return a const Andrew Burgess
2022-04-06 12:04   ` [PATCHv2 07/16] gdb/tui: avoid theoretical bug with 'tui reg' command Andrew Burgess
2022-04-06 13:02     ` Simon Marchi
2022-04-06 12:04   ` [PATCHv2 08/16] gdb/tui: fix 'tui reg next/prev' command when data window is hidden Andrew Burgess
2022-04-06 13:13     ` Simon Marchi
2022-04-06 12:04   ` [PATCHv2 09/16] gdb: always add the default register groups Andrew Burgess
2022-04-06 13:22     ` Simon Marchi
2022-04-06 12:04   ` [PATCHv2 10/16] gdb: convert reggroups to use a std::vector Andrew Burgess
2022-04-06 12:04   ` [PATCHv2 11/16] gdb: remove reggroup_next and reggroup_prev Andrew Burgess
2022-04-06 14:22     ` Simon Marchi
2022-04-06 14:23       ` Simon Marchi
2022-04-06 12:04   ` [PATCHv2 12/16] gdb: more 'const' in gdb/reggroups.{c,h} Andrew Burgess
2022-04-06 12:04   ` [PATCHv2 13/16] gdb: make the pre-defined register groups const Andrew Burgess
2022-04-06 12:04   ` [PATCHv2 14/16] gdb: convert reggroup to a C++ class with constructor, etc Andrew Burgess
2022-04-06 12:04   ` [PATCHv2 15/16] gdb: move struct reggroup into reggroups.h header Andrew Burgess
2022-04-06 12:04   ` [PATCHv2 16/16] gdb: update comments throughout reggroups.{c, h} files Andrew Burgess
2022-04-06 14:34   ` [PATCHv2 00/16] Default register groups, and general related cleanup Simon Marchi
2022-04-07 15:16     ` Andrew Burgess

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=4b01539542862737b960b78af6decfc174bbc0d9.1648760270.git.aburgess@redhat.com \
    --to=aburgess@redhat.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).