GNU Binutils with patches for OS216
Revision | d31d319047a058fb13dcc50edeb83e9b89493437 (tree) |
---|---|
Time | 2002-08-27 04:57:39 |
Author | Andrew Cagney <cagney@redh...> |
Commiter | Andrew Cagney |
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.
@@ -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 | + | |
1 | 37 | 2002-08-25 Andrew Cagney <ac131313@redhat.com> |
2 | 38 | |
3 | 39 | * arch-utils.h (default_next_cooked_register_to_save): Declare. |
@@ -533,6 +533,7 @@ SFILES = ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c ada-tasks.c \ | ||
533 | 533 | event-loop.c event-top.c \ |
534 | 534 | expprint.c f-exp.y f-lang.c f-typeprint.c f-valprint.c \ |
535 | 535 | findvar.c regcache.c gdbarch.c arch-utils.c gdbtypes.c osabi.c \ |
536 | + reggroups.c \ | |
536 | 537 | inf-loop.c infcmd.c inflow.c infrun.c language.c \ |
537 | 538 | kod.c kod-cisco.c \ |
538 | 539 | ui-out.c cli-out.c \ |
@@ -689,6 +690,7 @@ ppc_tdep_h = ppc-tdep.h $(osabi_h) | ||
689 | 690 | ppcnbsd_tdep_h = ppcnbsd-tdep.h |
690 | 691 | proc_utils_h = proc-utils.h |
691 | 692 | regcache_h = regcache.h |
693 | +reggroups_h = reggroups.h | |
692 | 694 | remote_utils_h = remote-utils.h $(target_h) |
693 | 695 | remote_h = remote.h |
694 | 696 | 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 \ | ||
842 | 844 | nlmread.o serial.o mdebugread.o top.o utils.o \ |
843 | 845 | ui-file.o \ |
844 | 846 | 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 | |
846 | 849 | |
847 | 850 | OBS = $(COMMON_OBS) $(ANNOTATE_OBS) |
848 | 851 |
@@ -1674,7 +1677,11 @@ frv-tdep.o: frv-tdep.c $(defs_h) $(inferior_h) $(symfile_h) $(gdbcore_h) \ | ||
1674 | 1677 | $(arch_utils_h) $(regcache_h) |
1675 | 1678 | |
1676 | 1679 | 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) | |
1678 | 1685 | |
1679 | 1686 | fork-child.o: fork-child.c $(gdb_wait_h) $(defs_h) $(gdbcore_h) \ |
1680 | 1687 | $(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) \ | ||
1696 | 1703 | $(gdb_string_h) $(symtab_h) $(frame_h) $(inferior_h) $(breakpoint_h) \ |
1697 | 1704 | $(gdb_wait_h) $(gdbcore_h) $(gdbcmd_h) $(target_h) $(gdbthread_h) \ |
1698 | 1705 | $(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) | |
1700 | 1707 | |
1701 | 1708 | arch-utils.o: arch-utils.c $(defs_h) $(bfd_h) $(gdbcmd_h) \ |
1702 | 1709 | $(arch_utils_h) $(gdb_assert_h) $(inferior_h) \ |
@@ -1751,7 +1758,7 @@ i386gnu-nat.o: gnu-nat.h | ||
1751 | 1758 | i386-tdep.o: i386-tdep.c $(defs_h) $(gdb_string_h) $(frame_h) \ |
1752 | 1759 | $(inferior_h) $(gdbcore_h) $(target_h) $(floatformat_h) \ |
1753 | 1760 | $(symtab_h) $(gdbcmd_h) $(command_h) $(arch_utils_h) $(regcache_h) \ |
1754 | - $(doublest_h) $(value_h) | |
1761 | + $(doublest_h) $(value_h) $(reggroups_h) | |
1755 | 1762 | |
1756 | 1763 | i386-nat.o: i386-nat.c $(defs_h) $(breakpoint_h) $(command_h) $(gdbcmd_h) |
1757 | 1764 |
@@ -1807,7 +1814,7 @@ ia64-tdep.o: ia64-tdep.c $(defs_h) $(inferior_h) $(symfile_h) $(gdbcore_h) \ | ||
1807 | 1814 | |
1808 | 1815 | infcmd.o: infcmd.c $(defs_h) environ.h $(gdbcmd_h) $(gdbcore_h) \ |
1809 | 1816 | $(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) | |
1811 | 1818 | |
1812 | 1819 | inflow.o: inflow.c $(bfd_h) $(command_h) $(defs_h) $(inferior_h) \ |
1813 | 1820 | $(target_h) $(terminal_h) $(gdbthread_h) $(gdb_string_h) |
@@ -64,6 +64,7 @@ | ||
64 | 64 | #include "gdb_assert.h" |
65 | 65 | #include "gdb_string.h" |
66 | 66 | #include "gdb-events.h" |
67 | +#include "reggroup.h" | |
67 | 68 | |
68 | 69 | /* Static function declarations */ |
69 | 70 |
@@ -267,6 +268,7 @@ struct gdbarch | ||
267 | 268 | gdbarch_coff_make_msymbol_special_ftype *coff_make_msymbol_special; |
268 | 269 | gdbarch_next_cooked_register_to_save_ftype *next_cooked_register_to_save; |
269 | 270 | gdbarch_next_cooked_register_to_restore_ftype *next_cooked_register_to_restore; |
271 | + gdbarch_register_reggroup_p_ftype *register_reggroup_p; | |
270 | 272 | }; |
271 | 273 | |
272 | 274 |
@@ -423,6 +425,7 @@ struct gdbarch startup_gdbarch = | ||
423 | 425 | 0, |
424 | 426 | default_next_cooked_register_to_save, |
425 | 427 | default_next_cooked_register_to_restore, |
428 | + default_register_reggroup_p, | |
426 | 429 | /* startup_gdbarch() */ |
427 | 430 | }; |
428 | 431 |
@@ -555,6 +558,7 @@ gdbarch_alloc (const struct gdbarch_info *info, | ||
555 | 558 | current_gdbarch->coff_make_msymbol_special = default_coff_make_msymbol_special; |
556 | 559 | current_gdbarch->next_cooked_register_to_save = default_next_cooked_register_to_save; |
557 | 560 | current_gdbarch->next_cooked_register_to_restore = default_next_cooked_register_to_restore; |
561 | + current_gdbarch->register_reggroup_p = default_register_reggroup_p; | |
558 | 562 | /* gdbarch_alloc() */ |
559 | 563 | |
560 | 564 | return current_gdbarch; |
@@ -803,6 +807,9 @@ verify_gdbarch (struct gdbarch *gdbarch) | ||
803 | 807 | if ((GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) |
804 | 808 | && (gdbarch->next_cooked_register_to_restore == default_next_cooked_register_to_restore)) |
805 | 809 | 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"); | |
806 | 813 | buf = ui_file_xstrdup (log, &dummy); |
807 | 814 | make_cleanup (xfree, buf); |
808 | 815 | if (strlen (buf) > 0) |
@@ -841,6 +848,10 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) | ||
841 | 848 | (long) current_gdbarch->next_cooked_register_to_save); |
842 | 849 | if (GDB_MULTI_ARCH) |
843 | 850 | 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, | |
844 | 855 | "gdbarch_dump: pseudo_register_read = 0x%08lx\n", |
845 | 856 | (long) current_gdbarch->pseudo_register_read); |
846 | 857 | if (GDB_MULTI_ARCH) |
@@ -4940,6 +4951,25 @@ set_gdbarch_next_cooked_register_to_restore (struct gdbarch *gdbarch, | ||
4940 | 4951 | gdbarch->next_cooked_register_to_restore = next_cooked_register_to_restore; |
4941 | 4952 | } |
4942 | 4953 | |
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 | + | |
4943 | 4973 | |
4944 | 4974 | /* Keep a registry of per-architecture data-pointers required by GDB |
4945 | 4975 | modules. */ |
@@ -47,6 +47,7 @@ struct value; | ||
47 | 47 | struct objfile; |
48 | 48 | struct minimal_symbol; |
49 | 49 | struct regcache; |
50 | +struct reggroup; | |
50 | 51 | |
51 | 52 | extern struct gdbarch *current_gdbarch; |
52 | 53 |
@@ -2493,6 +2494,12 @@ typedef int (gdbarch_next_cooked_register_to_restore_ftype) (struct gdbarch *gdb | ||
2493 | 2494 | extern int gdbarch_next_cooked_register_to_restore (struct gdbarch *gdbarch, int last_regnum); |
2494 | 2495 | extern void set_gdbarch_next_cooked_register_to_restore (struct gdbarch *gdbarch, gdbarch_next_cooked_register_to_restore_ftype *next_cooked_register_to_restore); |
2495 | 2496 | |
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 | + | |
2496 | 2503 | extern struct gdbarch_tdep *gdbarch_tdep (struct gdbarch *gdbarch); |
2497 | 2504 | |
2498 | 2505 |
@@ -661,6 +661,8 @@ f:2:COFF_MAKE_MSYMBOL_SPECIAL:void:coff_make_msymbol_special:int val, struct min | ||
661 | 661 | # Iterators for the cooked registers to save or restore. |
662 | 662 | m:::int:next_cooked_register_to_save:int last_regnum:last_regnum:::default_next_cooked_register_to_save |
663 | 663 | 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 | |
664 | 666 | EOF |
665 | 667 | } |
666 | 668 |
@@ -772,6 +774,7 @@ struct value; | ||
772 | 774 | struct objfile; |
773 | 775 | struct minimal_symbol; |
774 | 776 | struct regcache; |
777 | +struct reggroup; | |
775 | 778 | |
776 | 779 | extern struct gdbarch *current_gdbarch; |
777 | 780 |
@@ -1247,6 +1250,7 @@ cat <<EOF | ||
1247 | 1250 | #include "gdb_assert.h" |
1248 | 1251 | #include "gdb_string.h" |
1249 | 1252 | #include "gdb-events.h" |
1253 | +#include "reggroups.h" | |
1250 | 1254 | |
1251 | 1255 | /* Static function declarations */ |
1252 | 1256 |
@@ -37,6 +37,7 @@ | ||
37 | 37 | #include "doublest.h" |
38 | 38 | #include "value.h" |
39 | 39 | #include "gdb_assert.h" |
40 | +#include "reggroups.h" | |
40 | 41 | |
41 | 42 | #include "i386-tdep.h" |
42 | 43 | #include "i387-tdep.h" |
@@ -1413,6 +1414,49 @@ i386_nw_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) | ||
1413 | 1414 | } |
1414 | 1415 | |
1415 | 1416 | |
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 | + | |
1416 | 1460 | static struct gdbarch * |
1417 | 1461 | i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) |
1418 | 1462 | { |
@@ -1570,6 +1614,10 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) | ||
1570 | 1614 | set_gdbarch_pseudo_register_read (gdbarch, i386_pseudo_register_read); |
1571 | 1615 | set_gdbarch_pseudo_register_write (gdbarch, i386_pseudo_register_write); |
1572 | 1616 | |
1617 | + /* Add the i386 register groups. */ | |
1618 | + i386_add_reggroups (gdbarch); | |
1619 | + set_gdbarch_register_reggroup_p (gdbarch, i386_register_reggroup_p); | |
1620 | + | |
1573 | 1621 | /* Hook in ABI-specific overrides, if they have been registered. */ |
1574 | 1622 | gdbarch_init_osabi (info, gdbarch, osabi); |
1575 | 1623 |
@@ -1643,4 +1691,7 @@ are \"default\", \"pcc\" and \"reg\", and the default value is \"default\".", | ||
1643 | 1691 | i386_go32_init_abi); |
1644 | 1692 | gdbarch_register_osabi (bfd_arch_i386, GDB_OSABI_NETWARE, |
1645 | 1693 | i386_nw_init_abi); |
1694 | + | |
1695 | + /* Define the i386 specific register groups. */ | |
1696 | + i386_init_reggroups (); | |
1646 | 1697 | } |
@@ -41,6 +41,8 @@ | ||
41 | 41 | #include "event-top.h" |
42 | 42 | #include "parser-defs.h" |
43 | 43 | #include "regcache.h" |
44 | +#include "reggroups.h" | |
45 | +#include <ctype.h> | |
44 | 46 | |
45 | 47 | /* Functions exported for general use: */ |
46 | 48 |
@@ -1586,9 +1588,9 @@ default_print_registers_info (struct gdbarch *gdbarch, | ||
1586 | 1588 | { |
1587 | 1589 | if (!print_all) |
1588 | 1590 | { |
1589 | - if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT) | |
1591 | + if (gdbarch_register_reggroup_p (gdbarch, i, float_reggroup)) | |
1590 | 1592 | continue; |
1591 | - if (TYPE_VECTOR (REGISTER_VIRTUAL_TYPE (i))) | |
1593 | + if (gdbarch_register_reggroup_p (gdbarch, i, vector_reggroup)) | |
1592 | 1594 | continue; |
1593 | 1595 | } |
1594 | 1596 | } |
@@ -1692,35 +1694,89 @@ registers_info (char *addr_exp, int fpregs) | ||
1692 | 1694 | return; |
1693 | 1695 | } |
1694 | 1696 | |
1695 | - do | |
1697 | + while (*addr_exp != '\0') | |
1696 | 1698 | { |
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. */ | |
1697 | 1710 | if (addr_exp[0] == '$') |
1698 | 1711 | 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"); | |
1714 | 1714 | |
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 | + } | |
1718 | 1775 | |
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); | |
1722 | 1778 | } |
1723 | - while (*addr_exp != '\0'); | |
1779 | + | |
1724 | 1780 | } |
1725 | 1781 | |
1726 | 1782 | void |
@@ -1933,7 +1989,7 @@ print_float_info (struct gdbarch *gdbarch, struct ui_file *file, | ||
1933 | 1989 | |
1934 | 1990 | for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++) |
1935 | 1991 | { |
1936 | - if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (regnum)) == TYPE_CODE_FLT) | |
1992 | + if (gdbarch_register_reggroup_p (gdbarch, regnum, float_reggroup)) | |
1937 | 1993 | { |
1938 | 1994 | printed_something = 1; |
1939 | 1995 | gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1); |
@@ -29,6 +29,7 @@ | ||
29 | 29 | #include "gdb_assert.h" |
30 | 30 | #include "gdb_string.h" |
31 | 31 | #include "gdbcmd.h" /* For maintenanceprintlist. */ |
32 | +#include "reggroups.h" | |
32 | 33 | |
33 | 34 | /* |
34 | 35 | * DATA STRUCTURE |
@@ -1641,6 +1642,30 @@ regcache_dump (struct regcache *regcache, struct ui_file *file, | ||
1641 | 1642 | } |
1642 | 1643 | } |
1643 | 1644 | |
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 | + | |
1644 | 1669 | fprintf_unfiltered (file, "\n"); |
1645 | 1670 | } |
1646 | 1671 |
@@ -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 | +} |
@@ -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 |