• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

修訂d31d319047a058fb13dcc50edeb83e9b89493437 (tree)
時間2002-08-27 04:57:39
作者Andrew Cagney <cagney@redh...>
CommiterAndrew Cagney

Log Message

2002-08-26 Andrew Cagney <ac131313@redhat.com>

* i386-tdep.c: Include "reggroups.h".
(i386_register_reggroup_p): New function.
(i386_add_reggroups, i386_init_reggroups): New function.
(i386_gdbarch_init): Call i386_add_reggroups. Set
register_reggroup_p.
(_initialize_i386_tdep): Call i386_init_reggroups.

* infcmd.c: Include <ctype.h>.
(registers_info): Rewrite. Handle reggroups.
(default_print_registers_info): Use gdbarch_register_reggroup_p.
(print_float_info): Use gdbarch_register_reggroup_p.

* regcache.c: Include "reggroups.h".
(regcache_dump): Include the register groups in the maint print
registers command.

* infcmd.c: Include "regroup.h".
(default_print_registers_info): Use gdbarch_register_reggroup_p.
(print_float_info): Ditto.

* gdbarch.sh: Include "reggroups.h".
(register_reggroup_p): New method.
(struct reggroup): Add opaque declaration.
* gdbarch.h, gdbarch.c: Regenerate.

* Makefile.in (SFILES): Add reggroups.c.
(reggroups_h): Define.
(COMMON_OBS): Add reggroups.o.
(reggroups.o): Specify dependencies.
(gdbarch.o, infcmd.o, i386-tdep.o): Update dependencies.

* reggroups.c: New file.
* reggroups.h: New file.

Change Summary

差異

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,39 @@
1+2002-08-26 Andrew Cagney <ac131313@redhat.com>
2+
3+ * i386-tdep.c: Include "reggroups.h".
4+ (i386_register_reggroup_p): New function.
5+ (i386_add_reggroups, i386_init_reggroups): New function.
6+ (i386_gdbarch_init): Call i386_add_reggroups. Set
7+ register_reggroup_p.
8+ (_initialize_i386_tdep): Call i386_init_reggroups.
9+
10+ * infcmd.c: Include <ctype.h>.
11+ (registers_info): Rewrite. Handle reggroups.
12+ (default_print_registers_info): Use gdbarch_register_reggroup_p.
13+ (print_float_info): Use gdbarch_register_reggroup_p.
14+
15+ * regcache.c: Include "reggroups.h".
16+ (regcache_dump): Include the register groups in the ``maint print
17+ registers'' command.
18+
19+ * infcmd.c: Include "regroup.h".
20+ (default_print_registers_info): Use gdbarch_register_reggroup_p.
21+ (print_float_info): Ditto.
22+
23+ * gdbarch.sh: Include "reggroups.h".
24+ (register_reggroup_p): New method.
25+ (struct reggroup): Add opaque declaration.
26+ * gdbarch.h, gdbarch.c: Regenerate.
27+
28+ * Makefile.in (SFILES): Add reggroups.c.
29+ (reggroups_h): Define.
30+ (COMMON_OBS): Add reggroups.o.
31+ (reggroups.o): Specify dependencies.
32+ (gdbarch.o, infcmd.o, i386-tdep.o): Update dependencies.
33+
34+ * reggroups.c: New file.
35+ * reggroups.h: New file.
36+
137 2002-08-25 Andrew Cagney <ac131313@redhat.com>
238
339 * arch-utils.h (default_next_cooked_register_to_save): Declare.
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -533,6 +533,7 @@ SFILES = ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c ada-tasks.c \
533533 event-loop.c event-top.c \
534534 expprint.c f-exp.y f-lang.c f-typeprint.c f-valprint.c \
535535 findvar.c regcache.c gdbarch.c arch-utils.c gdbtypes.c osabi.c \
536+ reggroups.c \
536537 inf-loop.c infcmd.c inflow.c infrun.c language.c \
537538 kod.c kod-cisco.c \
538539 ui-out.c cli-out.c \
@@ -689,6 +690,7 @@ ppc_tdep_h = ppc-tdep.h $(osabi_h)
689690 ppcnbsd_tdep_h = ppcnbsd-tdep.h
690691 proc_utils_h = proc-utils.h
691692 regcache_h = regcache.h
693+reggroups_h = reggroups.h
692694 remote_utils_h = remote-utils.h $(target_h)
693695 remote_h = remote.h
694696 scm_lang_h = scm-lang.h $(scm_tags_h)
@@ -842,7 +844,8 @@ COMMON_OBS = version.o blockframe.o breakpoint.o findvar.o regcache.o \
842844 nlmread.o serial.o mdebugread.o top.o utils.o \
843845 ui-file.o \
844846 frame.o doublest.o \
845- gnu-v2-abi.o gnu-v3-abi.o hpacc-abi.o cp-abi.o
847+ gnu-v2-abi.o gnu-v3-abi.o hpacc-abi.o cp-abi.o \
848+ reggroups.o
846849
847850 OBS = $(COMMON_OBS) $(ANNOTATE_OBS)
848851
@@ -1674,7 +1677,11 @@ frv-tdep.o: frv-tdep.c $(defs_h) $(inferior_h) $(symfile_h) $(gdbcore_h) \
16741677 $(arch_utils_h) $(regcache_h)
16751678
16761679 regcache.o: regcache.c $(defs_h) $(inferior_h) $(target_h) $(gdbarch_h) \
1677- $(gdbcmd_h) $(regcache_h) $(gdb_assert_h) $(gdb_string_h) $(gdbcmd_h)
1680+ $(gdbcmd_h) $(regcache_h) $(gdb_assert_h) $(gdb_string_h) $(gdbcmd_h) \
1681+ $(reggroups_h)
1682+
1683+reggroups.o: reggroups.c $(defs_h) $(reggroups_h) $(gdbtypes_h) \
1684+ $(gdb_assert_h) $(regcache_h)
16781685
16791686 fork-child.o: fork-child.c $(gdb_wait_h) $(defs_h) $(gdbcore_h) \
16801687 $(inferior_h) $(target_h) $(terminal_h) $(gdbthread_h) $(gdb_string_h)
@@ -1696,7 +1703,7 @@ gdbarch.o: gdbarch.c $(defs_h) $(arch_utils_h) $(gdbcmd_h) $(inferior_h) \
16961703 $(gdb_string_h) $(symtab_h) $(frame_h) $(inferior_h) $(breakpoint_h) \
16971704 $(gdb_wait_h) $(gdbcore_h) $(gdbcmd_h) $(target_h) $(gdbthread_h) \
16981705 $(annotate_h) $(symfile_h) $(value_h) $(symcat_h) $(floatformat_h) \
1699- $(gdb_assert_h) $(gdb_string_h) $(gdb_events_h)
1706+ $(gdb_assert_h) $(gdb_string_h) $(gdb_events_h) $(reggroups_h)
17001707
17011708 arch-utils.o: arch-utils.c $(defs_h) $(bfd_h) $(gdbcmd_h) \
17021709 $(arch_utils_h) $(gdb_assert_h) $(inferior_h) \
@@ -1751,7 +1758,7 @@ i386gnu-nat.o: gnu-nat.h
17511758 i386-tdep.o: i386-tdep.c $(defs_h) $(gdb_string_h) $(frame_h) \
17521759 $(inferior_h) $(gdbcore_h) $(target_h) $(floatformat_h) \
17531760 $(symtab_h) $(gdbcmd_h) $(command_h) $(arch_utils_h) $(regcache_h) \
1754- $(doublest_h) $(value_h)
1761+ $(doublest_h) $(value_h) $(reggroups_h)
17551762
17561763 i386-nat.o: i386-nat.c $(defs_h) $(breakpoint_h) $(command_h) $(gdbcmd_h)
17571764
@@ -1807,7 +1814,7 @@ ia64-tdep.o: ia64-tdep.c $(defs_h) $(inferior_h) $(symfile_h) $(gdbcore_h) \
18071814
18081815 infcmd.o: infcmd.c $(defs_h) environ.h $(gdbcmd_h) $(gdbcore_h) \
18091816 $(inferior_h) $(target_h) $(language_h) $(symfile_h) $(gdb_string_h) \
1810- $(ui_out_h) $(completer_h) $(regcache_h)
1817+ $(ui_out_h) $(completer_h) $(regcache_h) $(reggroups_h)
18111818
18121819 inflow.o: inflow.c $(bfd_h) $(command_h) $(defs_h) $(inferior_h) \
18131820 $(target_h) $(terminal_h) $(gdbthread_h) $(gdb_string_h)
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -64,6 +64,7 @@
6464 #include "gdb_assert.h"
6565 #include "gdb_string.h"
6666 #include "gdb-events.h"
67+#include "reggroup.h"
6768
6869 /* Static function declarations */
6970
@@ -267,6 +268,7 @@ struct gdbarch
267268 gdbarch_coff_make_msymbol_special_ftype *coff_make_msymbol_special;
268269 gdbarch_next_cooked_register_to_save_ftype *next_cooked_register_to_save;
269270 gdbarch_next_cooked_register_to_restore_ftype *next_cooked_register_to_restore;
271+ gdbarch_register_reggroup_p_ftype *register_reggroup_p;
270272 };
271273
272274
@@ -423,6 +425,7 @@ struct gdbarch startup_gdbarch =
423425 0,
424426 default_next_cooked_register_to_save,
425427 default_next_cooked_register_to_restore,
428+ default_register_reggroup_p,
426429 /* startup_gdbarch() */
427430 };
428431
@@ -555,6 +558,7 @@ gdbarch_alloc (const struct gdbarch_info *info,
555558 current_gdbarch->coff_make_msymbol_special = default_coff_make_msymbol_special;
556559 current_gdbarch->next_cooked_register_to_save = default_next_cooked_register_to_save;
557560 current_gdbarch->next_cooked_register_to_restore = default_next_cooked_register_to_restore;
561+ current_gdbarch->register_reggroup_p = default_register_reggroup_p;
558562 /* gdbarch_alloc() */
559563
560564 return current_gdbarch;
@@ -803,6 +807,9 @@ verify_gdbarch (struct gdbarch *gdbarch)
803807 if ((GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL)
804808 && (gdbarch->next_cooked_register_to_restore == default_next_cooked_register_to_restore))
805809 fprintf_unfiltered (log, "\n\tnext_cooked_register_to_restore");
810+ if ((GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL)
811+ && (gdbarch->register_reggroup_p == default_register_reggroup_p))
812+ fprintf_unfiltered (log, "\n\tregister_reggroup_p");
806813 buf = ui_file_xstrdup (log, &dummy);
807814 make_cleanup (xfree, buf);
808815 if (strlen (buf) > 0)
@@ -841,6 +848,10 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
841848 (long) current_gdbarch->next_cooked_register_to_save);
842849 if (GDB_MULTI_ARCH)
843850 fprintf_unfiltered (file,
851+ "gdbarch_dump: register_reggroup_p = 0x%08lx\n",
852+ (long) current_gdbarch->register_reggroup_p);
853+ if (GDB_MULTI_ARCH)
854+ fprintf_unfiltered (file,
844855 "gdbarch_dump: pseudo_register_read = 0x%08lx\n",
845856 (long) current_gdbarch->pseudo_register_read);
846857 if (GDB_MULTI_ARCH)
@@ -4940,6 +4951,25 @@ set_gdbarch_next_cooked_register_to_restore (struct gdbarch *gdbarch,
49404951 gdbarch->next_cooked_register_to_restore = next_cooked_register_to_restore;
49414952 }
49424953
4954+int
4955+gdbarch_register_reggroup_p (struct gdbarch *gdbarch, int regnum, struct reggroup *reggroup)
4956+{
4957+ gdb_assert (gdbarch != NULL);
4958+ if (gdbarch->register_reggroup_p == 0)
4959+ internal_error (__FILE__, __LINE__,
4960+ "gdbarch: gdbarch_register_reggroup_p invalid");
4961+ if (gdbarch_debug >= 2)
4962+ fprintf_unfiltered (gdb_stdlog, "gdbarch_register_reggroup_p called\n");
4963+ return gdbarch->register_reggroup_p (gdbarch, regnum, reggroup);
4964+}
4965+
4966+void
4967+set_gdbarch_register_reggroup_p (struct gdbarch *gdbarch,
4968+ gdbarch_register_reggroup_p_ftype register_reggroup_p)
4969+{
4970+ gdbarch->register_reggroup_p = register_reggroup_p;
4971+}
4972+
49434973
49444974 /* Keep a registry of per-architecture data-pointers required by GDB
49454975 modules. */
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -47,6 +47,7 @@ struct value;
4747 struct objfile;
4848 struct minimal_symbol;
4949 struct regcache;
50+struct reggroup;
5051
5152 extern struct gdbarch *current_gdbarch;
5253
@@ -2493,6 +2494,12 @@ typedef int (gdbarch_next_cooked_register_to_restore_ftype) (struct gdbarch *gdb
24932494 extern int gdbarch_next_cooked_register_to_restore (struct gdbarch *gdbarch, int last_regnum);
24942495 extern void set_gdbarch_next_cooked_register_to_restore (struct gdbarch *gdbarch, gdbarch_next_cooked_register_to_restore_ftype *next_cooked_register_to_restore);
24952496
2497+/* Is a register in a group */
2498+
2499+typedef int (gdbarch_register_reggroup_p_ftype) (struct gdbarch *gdbarch, int regnum, struct reggroup *reggroup);
2500+extern int gdbarch_register_reggroup_p (struct gdbarch *gdbarch, int regnum, struct reggroup *reggroup);
2501+extern void set_gdbarch_register_reggroup_p (struct gdbarch *gdbarch, gdbarch_register_reggroup_p_ftype *register_reggroup_p);
2502+
24962503 extern struct gdbarch_tdep *gdbarch_tdep (struct gdbarch *gdbarch);
24972504
24982505
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -661,6 +661,8 @@ f:2:COFF_MAKE_MSYMBOL_SPECIAL:void:coff_make_msymbol_special:int val, struct min
661661 # Iterators for the cooked registers to save or restore.
662662 m:::int:next_cooked_register_to_save:int last_regnum:last_regnum:::default_next_cooked_register_to_save
663663 m:::int:next_cooked_register_to_restore:int last_regnum:last_regnum:::default_next_cooked_register_to_restore
664+# Is a register in a group
665+m:::int:register_reggroup_p:int regnum, struct reggroup *reggroup:regnum, reggroup:::default_register_reggroup_p
664666 EOF
665667 }
666668
@@ -772,6 +774,7 @@ struct value;
772774 struct objfile;
773775 struct minimal_symbol;
774776 struct regcache;
777+struct reggroup;
775778
776779 extern struct gdbarch *current_gdbarch;
777780
@@ -1247,6 +1250,7 @@ cat <<EOF
12471250 #include "gdb_assert.h"
12481251 #include "gdb_string.h"
12491252 #include "gdb-events.h"
1253+#include "reggroups.h"
12501254
12511255 /* Static function declarations */
12521256
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -37,6 +37,7 @@
3737 #include "doublest.h"
3838 #include "value.h"
3939 #include "gdb_assert.h"
40+#include "reggroups.h"
4041
4142 #include "i386-tdep.h"
4243 #include "i387-tdep.h"
@@ -1413,6 +1414,49 @@ i386_nw_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
14131414 }
14141415
14151416
1417+/* i386 register groups. In addition to the normal groups, add "mmx"
1418+ and "sse". */
1419+
1420+struct reggroup *i368_sse_reggroup;
1421+struct reggroup *i368_mmx_reggroup;
1422+
1423+static void
1424+i386_init_reggroups (void)
1425+{
1426+ i368_sse_reggroup = reggroup_new ("sse");
1427+ i368_mmx_reggroup = reggroup_new ("mmx");
1428+}
1429+
1430+static void
1431+i386_add_reggroups (struct gdbarch *gdbarch)
1432+{
1433+ reggroup_add (gdbarch, i368_sse_reggroup);
1434+ reggroup_add (gdbarch, i368_mmx_reggroup);
1435+ reggroup_add (gdbarch, general_reggroup);
1436+ reggroup_add (gdbarch, float_reggroup);
1437+ reggroup_add (gdbarch, all_reggroup);
1438+ reggroup_add (gdbarch, vector_reggroup);
1439+ reggroup_add (gdbarch, system_reggroup);
1440+}
1441+
1442+static int
1443+i386_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
1444+ struct reggroup *group)
1445+{
1446+ if (group == all_reggroup)
1447+ return 1;
1448+ if (mmx_regnum_p (regnum) || regnum == MXCSR_REGNUM)
1449+ return (group == i368_mmx_reggroup || group == vector_reggroup);
1450+ if (FP_REGNUM_P (regnum) || FPC_REGNUM_P (regnum))
1451+ return (group == float_reggroup || group == all_reggroup);
1452+ if (SSE_REGNUM_P (regnum))
1453+ return (group == i368_sse_reggroup || group == vector_reggroup);
1454+ if (group == general_reggroup)
1455+ return 1;
1456+ return 0;
1457+}
1458+
1459+
14161460 static struct gdbarch *
14171461 i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
14181462 {
@@ -1570,6 +1614,10 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
15701614 set_gdbarch_pseudo_register_read (gdbarch, i386_pseudo_register_read);
15711615 set_gdbarch_pseudo_register_write (gdbarch, i386_pseudo_register_write);
15721616
1617+ /* Add the i386 register groups. */
1618+ i386_add_reggroups (gdbarch);
1619+ set_gdbarch_register_reggroup_p (gdbarch, i386_register_reggroup_p);
1620+
15731621 /* Hook in ABI-specific overrides, if they have been registered. */
15741622 gdbarch_init_osabi (info, gdbarch, osabi);
15751623
@@ -1643,4 +1691,7 @@ are \"default\", \"pcc\" and \"reg\", and the default value is \"default\".",
16431691 i386_go32_init_abi);
16441692 gdbarch_register_osabi (bfd_arch_i386, GDB_OSABI_NETWARE,
16451693 i386_nw_init_abi);
1694+
1695+ /* Define the i386 specific register groups. */
1696+ i386_init_reggroups ();
16461697 }
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -41,6 +41,8 @@
4141 #include "event-top.h"
4242 #include "parser-defs.h"
4343 #include "regcache.h"
44+#include "reggroups.h"
45+#include <ctype.h>
4446
4547 /* Functions exported for general use: */
4648
@@ -1586,9 +1588,9 @@ default_print_registers_info (struct gdbarch *gdbarch,
15861588 {
15871589 if (!print_all)
15881590 {
1589- if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT)
1591+ if (gdbarch_register_reggroup_p (gdbarch, i, float_reggroup))
15901592 continue;
1591- if (TYPE_VECTOR (REGISTER_VIRTUAL_TYPE (i)))
1593+ if (gdbarch_register_reggroup_p (gdbarch, i, vector_reggroup))
15921594 continue;
15931595 }
15941596 }
@@ -1692,35 +1694,89 @@ registers_info (char *addr_exp, int fpregs)
16921694 return;
16931695 }
16941696
1695- do
1697+ while (*addr_exp != '\0')
16961698 {
1699+ const char *start;
1700+ const char *end;
1701+ /* Keep skipping leading white space until something interesting
1702+ is found. */
1703+ if (isspace ((*addr_exp)))
1704+ {
1705+ addr_exp++;
1706+ continue;
1707+ }
1708+
1709+ /* Discard any ``$''. There had better be something after it. */
16971710 if (addr_exp[0] == '$')
16981711 addr_exp++;
1699- end = addr_exp;
1700- while (*end != '\0' && *end != ' ' && *end != '\t')
1701- ++end;
1702- numregs = NUM_REGS + NUM_PSEUDO_REGS;
1703-
1704- regnum = target_map_name_to_register (addr_exp, end - addr_exp);
1705- if (regnum >= 0)
1706- goto found;
1707-
1708- regnum = numregs;
1709-
1710- if (*addr_exp >= '0' && *addr_exp <= '9')
1711- regnum = atoi (addr_exp); /* Take a number */
1712- if (regnum >= numregs) /* Bad name, or bad number */
1713- error ("%.*s: invalid register", (int) (end - addr_exp), addr_exp);
1712+ if (isspace ((*addr_exp)) || (*addr_exp) == '\0')
1713+ error ("Missing register name");
17141714
1715- found:
1716- gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
1717- selected_frame, regnum, fpregs);
1715+ /* Find the start/end of this register name/group. */
1716+ start = addr_exp;
1717+ while ((*addr_exp) != '\0' && !isspace ((*addr_exp)))
1718+ addr_exp++;
1719+ end = addr_exp;
1720+
1721+ /* Figure out what we've found, display it. */
1722+
1723+ /* A register name? */
1724+ {
1725+ int regnum = target_map_name_to_register (addr_exp, end - start);
1726+ if (regnum >= 0)
1727+ {
1728+ gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
1729+ selected_frame, regnum, fpregs);
1730+ continue;
1731+ }
1732+ }
1733+
1734+ /* A register number? (how portable is this one?). */
1735+ {
1736+ char *endptr;
1737+ int regnum = strtol (start, &endptr, 0);
1738+ if (endptr == end
1739+ && regnum >= 0
1740+ && regnum < NUM_REGS + NUM_PSEUDO_REGS)
1741+ {
1742+ gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
1743+ selected_frame, regnum, fpregs);
1744+ continue;
1745+ }
1746+ }
1747+
1748+ /* A register group? */
1749+ {
1750+ struct reggroup *const *group;
1751+ for (group = reggroups (current_gdbarch);
1752+ (*group) != NULL;
1753+ group++)
1754+ {
1755+ if (strncmp (start, reggroup_name ((*group)), end - start) == 0)
1756+ break;
1757+ }
1758+ if ((*group) != NULL)
1759+ {
1760+ /* Don't bother with a length check. If the user enters
1761+ just part of a register group's name, go with the first
1762+ matching one. */
1763+ int regnum;
1764+ for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
1765+ {
1766+ if (gdbarch_register_reggroup_p (current_gdbarch, regnum,
1767+ (*group)))
1768+ gdbarch_print_registers_info (current_gdbarch,
1769+ gdb_stdout, selected_frame,
1770+ regnum, fpregs);
1771+ }
1772+ continue;
1773+ }
1774+ }
17181775
1719- addr_exp = end;
1720- while (*addr_exp == ' ' || *addr_exp == '\t')
1721- ++addr_exp;
1776+ /* Nothing matched. */
1777+ error ("Invalid register `%.*s'", (int) (end - start), start);
17221778 }
1723- while (*addr_exp != '\0');
1779+
17241780 }
17251781
17261782 void
@@ -1933,7 +1989,7 @@ print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
19331989
19341990 for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
19351991 {
1936- if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (regnum)) == TYPE_CODE_FLT)
1992+ if (gdbarch_register_reggroup_p (gdbarch, regnum, float_reggroup))
19371993 {
19381994 printed_something = 1;
19391995 gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1);
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -29,6 +29,7 @@
2929 #include "gdb_assert.h"
3030 #include "gdb_string.h"
3131 #include "gdbcmd.h" /* For maintenanceprintlist. */
32+#include "reggroups.h"
3233
3334 /*
3435 * DATA STRUCTURE
@@ -1641,6 +1642,30 @@ regcache_dump (struct regcache *regcache, struct ui_file *file,
16411642 }
16421643 }
16431644
1645+ /* The registers groups. */
1646+ if (what_to_dump == regcache_dump_none)
1647+ {
1648+ if (regnum < 0)
1649+ fprintf_unfiltered (file, "Groups");
1650+ else
1651+ {
1652+ struct reggroup *const *group;
1653+ const char *prefix = "";
1654+ for (group = reggroups (regcache->descr->gdbarch);
1655+ *group != NULL;
1656+ group++)
1657+ {
1658+ if (gdbarch_register_reggroup_p (regcache->descr->gdbarch,
1659+ regnum, *group))
1660+ {
1661+ fprintf_unfiltered (file, "%s%s", prefix,
1662+ reggroup_name (*group));
1663+ prefix = ",";
1664+ }
1665+ }
1666+ }
1667+ }
1668+
16441669 fprintf_unfiltered (file, "\n");
16451670 }
16461671
--- /dev/null
+++ b/gdb/reggroups.c
@@ -0,0 +1,187 @@
1+/* Register groupings for GDB, the GNU debugger.
2+
3+ Copyright 2002 Free Software Foundation, Inc.
4+
5+ Contributed by Red Hat.
6+
7+ This file is part of GDB.
8+
9+ This program is free software; you can redistribute it and/or modify
10+ it under the terms of the GNU General Public License as published by
11+ the Free Software Foundation; either version 2 of the License, or
12+ (at your option) any later version.
13+
14+ This program is distributed in the hope that it will be useful,
15+ but WITHOUT ANY WARRANTY; without even the implied warranty of
16+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+ GNU General Public License for more details.
18+
19+ You should have received a copy of the GNU General Public License
20+ along with this program; if not, write to the Free Software
21+ Foundation, Inc., 59 Temple Place - Suite 330,
22+ Boston, MA 02111-1307, USA. */
23+
24+#include "defs.h"
25+#include "reggroups.h"
26+#include "gdbtypes.h"
27+#include "gdb_assert.h"
28+#include "regcache.h"
29+
30+/* Individual register groups. */
31+
32+struct reggroup
33+{
34+ const char *name;
35+};
36+
37+struct reggroup *
38+reggroup_new (const char *name)
39+{
40+ struct reggroup *group = XMALLOC (struct reggroup);
41+ group->name = name;
42+ return group;
43+}
44+
45+/* Register group attributes. */
46+
47+const char *
48+reggroup_name (struct reggroup *group)
49+{
50+ return group->name;
51+}
52+
53+/* All the groups for a given architecture. */
54+
55+struct reggroups
56+{
57+ int nr_group;
58+ struct reggroup **group;
59+};
60+
61+static struct gdbarch_data *reggroups_data;
62+
63+static void *
64+reggroups_init (struct gdbarch *gdbarch)
65+{
66+ struct reggroups *groups = XMALLOC (struct reggroups);
67+ groups->nr_group = 0;
68+ groups->group = NULL;
69+ return groups;
70+}
71+
72+static void
73+reggroups_free (struct gdbarch *gdbarch, void *data)
74+{
75+ struct reggroups *groups = data;
76+ xfree (groups->group);
77+ xfree (groups);
78+}
79+
80+/* Add a register group (with attribute values) to the pre-defined
81+ list. This function can be called during architecture
82+ initialization and hence needs to handle NULL architecture groups. */
83+
84+static void
85+add_group (struct reggroups *groups, struct reggroup *group)
86+{
87+ gdb_assert (group != NULL);
88+ groups->nr_group++;
89+ groups->group = xrealloc (groups->group, (sizeof (struct reggroup *)
90+ * (groups->nr_group + 1)));
91+ groups->group[groups->nr_group - 1] = group;
92+ groups->group[groups->nr_group] = NULL;
93+}
94+
95+void
96+reggroup_add (struct gdbarch *gdbarch, struct reggroup *group)
97+{
98+ struct reggroups *groups = gdbarch_data (gdbarch, reggroups_data);
99+ if (groups == NULL)
100+ {
101+ /* ULGH, called during architecture initialization. Patch
102+ things up. */
103+ groups = reggroups_init (gdbarch);
104+ set_gdbarch_data (gdbarch, reggroups_data, groups);
105+ }
106+ add_group (groups, group);
107+}
108+
109+/* The register groups for the current architecture. Mumble something
110+ about the lifetime of the buffer.... */
111+
112+static struct reggroups *default_groups;
113+
114+struct reggroup * const*
115+reggroups (struct gdbarch *gdbarch)
116+{
117+ struct reggroups *groups = gdbarch_data (gdbarch, reggroups_data);
118+ /* Don't allow this function to be called during architecture
119+ creation. */
120+ gdb_assert (groups != NULL);
121+ if (groups->group == NULL)
122+ return default_groups->group;
123+ else
124+ return groups->group;
125+}
126+
127+/* Is REGNUM a member of REGGROUP? */
128+int
129+default_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
130+ struct reggroup *group)
131+{
132+ int vector_p;
133+ int float_p;
134+ if (REGISTER_NAME (regnum) == NULL
135+ || *REGISTER_NAME (regnum) == '\0')
136+ return 0;
137+ if (group == all_reggroup)
138+ return 1;
139+ vector_p = TYPE_VECTOR (register_type (gdbarch, regnum));
140+ float_p = TYPE_CODE (register_type (gdbarch, regnum)) == TYPE_CODE_FLT;
141+ if (group == float_reggroup)
142+ return float_p;
143+ if (group == vector_reggroup)
144+ return vector_p;
145+ if (group == general_reggroup)
146+ return (!vector_p && !float_p);
147+ return 0;
148+}
149+
150+
151+
152+
153+/* Pre-defined register groups. */
154+struct reggroup general_group = { "general" };
155+struct reggroup float_group = { "float" };
156+struct reggroup system_group = { "system" };
157+struct reggroup vector_group = { "vector" };
158+struct reggroup all_group = { "all" };
159+
160+struct reggroup *const general_reggroup = &general_group;
161+struct reggroup *const float_reggroup = &float_group;
162+struct reggroup *const system_reggroup = &system_group;
163+struct reggroup *const vector_reggroup = &vector_group;
164+struct reggroup *const all_reggroup = &all_group;
165+
166+void
167+_initialize_reggroup (void)
168+{
169+ reggroups_data = register_gdbarch_data (reggroups_init, reggroups_free);
170+
171+#if 0
172+ /* The pre-defined groups. */
173+ general_reggroup = reggroup_new ("general");
174+ float_reggroup = reggroup_new ("float");
175+ system_reggroup = reggroup_new ("system");
176+ vector_reggroup = reggroup_new ("vector");
177+ all_reggroup = reggroup_new ("all");
178+#endif
179+
180+ /* The pre-defined list of groups. */
181+ default_groups = reggroups_init (NULL);
182+ add_group (default_groups, general_reggroup);
183+ add_group (default_groups, float_reggroup);
184+ add_group (default_groups, system_reggroup);
185+ add_group (default_groups, vector_reggroup);
186+ add_group (default_groups, all_reggroup);
187+}
--- /dev/null
+++ b/gdb/reggroups.h
@@ -0,0 +1,53 @@
1+/* Register groupings for GDB, the GNU debugger.
2+
3+ Copyright 2002 Free Software Foundation, Inc.
4+
5+ Contributed by Red Hat.
6+
7+ This file is part of GDB.
8+
9+ This program is free software; you can redistribute it and/or modify
10+ it under the terms of the GNU General Public License as published by
11+ the Free Software Foundation; either version 2 of the License, or
12+ (at your option) any later version.
13+
14+ This program is distributed in the hope that it will be useful,
15+ but WITHOUT ANY WARRANTY; without even the implied warranty of
16+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+ GNU General Public License for more details.
18+
19+ You should have received a copy of the GNU General Public License
20+ along with this program; if not, write to the Free Software
21+ Foundation, Inc., 59 Temple Place - Suite 330,
22+ Boston, MA 02111-1307, USA. */
23+
24+#ifndef REGGROUPS_H
25+#define REGGROUPS_H
26+
27+struct gdbarch;
28+struct reggroup;
29+
30+/* Pre-defined register groups. */
31+extern struct reggroup *const general_reggroup;
32+extern struct reggroup *const float_reggroup;
33+extern struct reggroup *const system_reggroup;
34+extern struct reggroup *const vector_reggroup;
35+extern struct reggroup *const all_reggroup;
36+
37+/* Create a new local register group. */
38+extern struct reggroup *reggroup_new (const char *name);
39+
40+/* Add a register group (with attribute values) to the pre-defined list. */
41+extern void reggroup_add (struct gdbarch *gdbarch, struct reggroup *group);
42+
43+/* Register group attributes. */
44+extern const char *reggroup_name (struct reggroup *reggroup);
45+
46+/* The register groups for the current architecture. */
47+extern struct reggroup *const *reggroups (struct gdbarch *gdbarch);
48+
49+/* Is REGNUM a member of REGGROUP? */
50+extern int default_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
51+ struct reggroup *reggroup);
52+
53+#endif