GNU Binutils with patches for OS216
Revision | 2c0f1e706145cd2408654c5a0ef3217c02108d97 (tree) |
---|---|
Zeit | 2005-03-30 23:59:31 |
Autor | Daniel Jacobowitz <drow@fals...> |
Commiter | Daniel Jacobowitz |
* gdb/Makefile.in (arm-linux-nat.o): Update dependencies.
* gdb/arm-linux-nat.c: Include "gdb_assert.h".
(PTRACE_GETWMMXREGS, PTRACE_SETWMMXREGS): Define.
(arm_linux_has_wmmx_registers): New flag.
(GET_THREAD_ID): Remove stray punctuation.
(IWMMXT_REGS_SIZE): Define.
(fetch_wmmx_regs, store_wmmx_regs): New functions.
(fetch_inferior_registers, store_inferior_registers): Call them.
(arm_linux_available_registers): New function.
* gdb/inftarg.c (child_xfer_partial): Handle
TARGET_OBJECT_AVAILABLE_REGISTERS.
* gdb/config/arm/nm-linux.h (arm_linux_available_registers): Add
prototype.
(NATIVE_XFER_AVAILABLE_REGISTERS): Define.
* gdb/gdbserver/linux-arm-low.c (arm_fill_wmmxregset)
(arm_store_wmmxregset): Remove stray text.
(arm_available_registers): Remove debugging output. Use hex.
* gdb/gdbserver/regcache.c (num_registers): Make global.
* gdb/gdbserver/server.c (handle_p_packet, handle_P_packet): Check
the value of regnum.
@@ -1,3 +1,27 @@ | ||
1 | +2005-03-30 Daniel Jacobowitz <dan@codesourcery.com> | |
2 | + | |
3 | + * gdb/Makefile.in (arm-linux-nat.o): Update dependencies. | |
4 | + * gdb/arm-linux-nat.c: Include "gdb_assert.h". | |
5 | + (PTRACE_GETWMMXREGS, PTRACE_SETWMMXREGS): Define. | |
6 | + (arm_linux_has_wmmx_registers): New flag. | |
7 | + (GET_THREAD_ID): Remove stray punctuation. | |
8 | + (IWMMXT_REGS_SIZE): Define. | |
9 | + (fetch_wmmx_regs, store_wmmx_regs): New functions. | |
10 | + (fetch_inferior_registers, store_inferior_registers): Call them. | |
11 | + (arm_linux_available_registers): New function. | |
12 | + * gdb/inftarg.c (child_xfer_partial): Handle | |
13 | + TARGET_OBJECT_AVAILABLE_REGISTERS. | |
14 | + * gdb/config/arm/nm-linux.h (arm_linux_available_registers): Add | |
15 | + prototype. | |
16 | + (NATIVE_XFER_AVAILABLE_REGISTERS): Define. | |
17 | + | |
18 | + * gdb/gdbserver/linux-arm-low.c (arm_fill_wmmxregset) | |
19 | + (arm_store_wmmxregset): Remove stray text. | |
20 | + (arm_available_registers): Remove debugging output. Use hex. | |
21 | + * gdb/gdbserver/regcache.c (num_registers): Make global. | |
22 | + * gdb/gdbserver/server.c (handle_p_packet, handle_P_packet): Check | |
23 | + the value of regnum. | |
24 | + | |
1 | 25 | 2005-03-28 Paul Brook <paul@codesourcery.com> |
2 | 26 | Daniel Jacobowitz <dan@codesourcery.com> |
3 | 27 |
@@ -1732,7 +1732,7 @@ arch-utils.o: arch-utils.c $(defs_h) $(arch_utils_h) $(buildsym_h) \ | ||
1732 | 1732 | $(floatformat_h) |
1733 | 1733 | arm-linux-nat.o: arm-linux-nat.c $(defs_h) $(inferior_h) $(gdbcore_h) \ |
1734 | 1734 | $(gdb_string_h) $(regcache_h) $(arm_tdep_h) $(gregset_h)\ |
1735 | - $(gdb_proc_service_h) | |
1735 | + $(gdb_proc_service_h) $(gdb_assert_h) | |
1736 | 1736 | arm-linux-tdep.o: arm-linux-tdep.c $(defs_h) $(target_h) $(value_h) \ |
1737 | 1737 | $(gdbtypes_h) $(floatformat_h) $(gdbcore_h) $(frame_h) $(regcache_h) \ |
1738 | 1738 | $(doublest_h) $(solib_svr4_h) $(osabi_h) $(arm_tdep_h) \ |
@@ -23,6 +23,7 @@ | ||
23 | 23 | #include "gdbcore.h" |
24 | 24 | #include "gdb_string.h" |
25 | 25 | #include "regcache.h" |
26 | +#include "gdb_assert.h" | |
26 | 27 | |
27 | 28 | #include "arm-tdep.h" |
28 | 29 |
@@ -41,6 +42,13 @@ | ||
41 | 42 | #define PTRACE_GET_THREAD_AREA 22 |
42 | 43 | #endif |
43 | 44 | |
45 | +#ifndef PTRACE_GETWMMXREGS | |
46 | +#define PTRACE_GETWMMXREGS 18 | |
47 | +#define PTRACE_SETWMMXREGS 19 | |
48 | +#endif | |
49 | + | |
50 | +static int arm_linux_has_wmmx_registers = 1; | |
51 | + | |
44 | 52 | extern int arm_apcs_32; |
45 | 53 | |
46 | 54 | #define typeNone 0x00 |
@@ -99,7 +107,7 @@ get_thread_id (ptid_t ptid) | ||
99 | 107 | tid = PIDGET (ptid); |
100 | 108 | return tid; |
101 | 109 | } |
102 | -#define GET_THREAD_ID(PTID) get_thread_id ((PTID)); | |
110 | +#define GET_THREAD_ID(PTID) get_thread_id (PTID) | |
103 | 111 | |
104 | 112 | static void |
105 | 113 | fetch_nwfpe_single (unsigned int fn, FPA11 * fpa11) |
@@ -550,6 +558,97 @@ store_regs (void) | ||
550 | 558 | } |
551 | 559 | } |
552 | 560 | |
561 | +/* Fetch all WMMX registers of the process and store into | |
562 | + regcache. */ | |
563 | + | |
564 | +#define IWMMXT_REGS_SIZE (16 * 8 + 6 * 4) | |
565 | + | |
566 | +static void | |
567 | +fetch_wmmx_regs (void) | |
568 | +{ | |
569 | + char regbuf[IWMMXT_REGS_SIZE]; | |
570 | + int ret, regno, tid, first; | |
571 | + | |
572 | + /* Get the thread id for the ptrace call. */ | |
573 | + tid = GET_THREAD_ID (inferior_ptid); | |
574 | + | |
575 | + ret = ptrace (PTRACE_GETWMMXREGS, tid, 0, regbuf); | |
576 | + if (ret < 0) | |
577 | + { | |
578 | + warning (_("Unable to fetch WMMX registers.")); | |
579 | + return; | |
580 | + } | |
581 | + | |
582 | + first = gdbarch_tdep (current_gdbarch)->first_iwmmxt_regnum; | |
583 | + | |
584 | + for (regno = 0; regno < NUM_IWMMXT_COP0REGS; regno++) | |
585 | + regcache_raw_supply (current_regcache, first + regno, | |
586 | + ®buf[regno * 8]); | |
587 | + | |
588 | + first += NUM_IWMMXT_COP0REGS; | |
589 | + | |
590 | + for (regno = 0; regno < 2; regno++) | |
591 | + regcache_raw_supply (current_regcache, first + regno, NULL); | |
592 | + | |
593 | + for (regno = 2; regno < 4; regno++) | |
594 | + regcache_raw_supply (current_regcache, first + regno, | |
595 | + ®buf[16 * 8 + (regno - 2) * 4]); | |
596 | + | |
597 | + for (regno = 4; regno < 8; regno++) | |
598 | + regcache_raw_supply (current_regcache, first + regno, NULL); | |
599 | + | |
600 | + for (regno = 8; regno < 12; regno++) | |
601 | + regcache_raw_supply (current_regcache, first + regno, | |
602 | + ®buf[16 * 8 + 2 * 4 + (regno - 8) * 4]); | |
603 | + | |
604 | + for (regno = 12; regno < 16; regno++) | |
605 | + regcache_raw_supply (current_regcache, first + regno, NULL); | |
606 | +} | |
607 | + | |
608 | +static void | |
609 | +store_wmmx_regs (void) | |
610 | +{ | |
611 | + char regbuf[IWMMXT_REGS_SIZE]; | |
612 | + int ret, regno, tid, first; | |
613 | + | |
614 | + /* Get the thread id for the ptrace call. */ | |
615 | + tid = GET_THREAD_ID (inferior_ptid); | |
616 | + | |
617 | + ret = ptrace (PTRACE_GETWMMXREGS, tid, 0, regbuf); | |
618 | + if (ret < 0) | |
619 | + { | |
620 | + warning (_("Unable to fetch WMMX registers.")); | |
621 | + return; | |
622 | + } | |
623 | + | |
624 | + first = gdbarch_tdep (current_gdbarch)->first_iwmmxt_regnum; | |
625 | + | |
626 | + for (regno = 0; regno < NUM_IWMMXT_COP0REGS; regno++) | |
627 | + if (register_cached (first + regno)) | |
628 | + regcache_raw_collect (current_regcache, first + regno, | |
629 | + ®buf[regno * 8]); | |
630 | + | |
631 | + first += 18; | |
632 | + for (regno = 0; regno < 2; regno++) | |
633 | + if (register_cached (first + regno)) | |
634 | + regcache_raw_collect (current_regcache, first + regno, | |
635 | + ®buf[16 * 8 + regno * 4]); | |
636 | + | |
637 | + first += 6; | |
638 | + for (regno = 0; regno < 4; regno++) | |
639 | + if (register_cached (first + regno)) | |
640 | + regcache_raw_collect (current_regcache, first + regno, | |
641 | + ®buf[16 * 8 + 2 * 4 + regno * 4]); | |
642 | + | |
643 | + ret = ptrace (PTRACE_SETWMMXREGS, tid, 0, regbuf); | |
644 | + | |
645 | + if (ret < 0) | |
646 | + { | |
647 | + warning (_("Unable to store WMMX registers.")); | |
648 | + return; | |
649 | + } | |
650 | +} | |
651 | + | |
553 | 652 | /* Fetch registers from the child process. Fetch all registers if |
554 | 653 | regno == -1, otherwise fetch all general registers or all floating |
555 | 654 | point registers depending upon the value of regno. */ |
@@ -561,14 +660,21 @@ fetch_inferior_registers (int regno) | ||
561 | 660 | { |
562 | 661 | fetch_regs (); |
563 | 662 | fetch_fpa_regs (); |
663 | + if (arm_linux_has_wmmx_registers) | |
664 | + fetch_wmmx_regs (); | |
564 | 665 | } |
565 | 666 | else |
566 | 667 | { |
567 | - if (regno < ARM_F0_REGNUM || regno > ARM_FPS_REGNUM) | |
668 | + if (regno < ARM_F0_REGNUM || regno == ARM_PS_REGNUM) | |
568 | 669 | fetch_register (regno); |
569 | - | |
570 | - if (regno >= ARM_F0_REGNUM && regno <= ARM_FPS_REGNUM) | |
670 | + else if (regno >= ARM_F0_REGNUM && regno <= ARM_FPS_REGNUM) | |
571 | 671 | fetch_fpa_register (regno); |
672 | + else if (arm_linux_has_wmmx_registers) | |
673 | + { | |
674 | + int first = gdbarch_tdep (current_gdbarch)->first_iwmmxt_regnum; | |
675 | + if (regno >= first && regno < first + NUM_IWMMXT_REGS) | |
676 | + fetch_wmmx_regs (); | |
677 | + } | |
572 | 678 | } |
573 | 679 | } |
574 | 680 |
@@ -583,14 +689,21 @@ store_inferior_registers (int regno) | ||
583 | 689 | { |
584 | 690 | store_regs (); |
585 | 691 | store_fpa_regs (); |
692 | + if (arm_linux_has_wmmx_registers) | |
693 | + store_wmmx_regs (); | |
586 | 694 | } |
587 | 695 | else |
588 | 696 | { |
589 | - if ((regno < ARM_F0_REGNUM) || (regno > ARM_FPS_REGNUM)) | |
697 | + if (regno < ARM_F0_REGNUM || regno == ARM_PS_REGNUM) | |
590 | 698 | store_register (regno); |
591 | - | |
592 | - if ((regno >= ARM_F0_REGNUM) && (regno <= ARM_FPS_REGNUM)) | |
593 | - store_fpa_register (regno); | |
699 | + else if ((regno >= ARM_F0_REGNUM) && (regno <= ARM_FPS_REGNUM)) | |
700 | + store_fpa_register (regno); | |
701 | + else if (arm_linux_has_wmmx_registers) | |
702 | + { | |
703 | + int first = gdbarch_tdep (current_gdbarch)->first_iwmmxt_regnum; | |
704 | + if (regno >= first && regno < first + NUM_IWMMXT_REGS) | |
705 | + store_wmmx_regs (); | |
706 | + } | |
594 | 707 | } |
595 | 708 | } |
596 | 709 |
@@ -740,6 +853,50 @@ get_linux_version (unsigned int *vmajor, | ||
740 | 853 | return ((*vmajor << 16) | (*vminor << 8) | *vrelease); |
741 | 854 | } |
742 | 855 | |
856 | +LONGEST | |
857 | +arm_linux_available_registers (struct target_ops *ops, | |
858 | + int /* enum target_object */ object, | |
859 | + const char *annex, | |
860 | + void *readbuf, | |
861 | + const void *writebuf, | |
862 | + ULONGEST offset, | |
863 | + LONGEST len) | |
864 | +{ | |
865 | + char *result = NULL; | |
866 | + int total_len; | |
867 | + | |
868 | + gdb_assert (object == TARGET_OBJECT_AVAILABLE_REGISTERS); | |
869 | + gdb_assert (readbuf && !writebuf); | |
870 | + | |
871 | + if (arm_linux_has_wmmx_registers) | |
872 | + { | |
873 | + int ret; | |
874 | + char regbuf[IWMMXT_REGS_SIZE]; | |
875 | + | |
876 | + ret = ptrace (PTRACE_GETWMMXREGS, GET_THREAD_ID (inferior_ptid), 0, | |
877 | + regbuf); | |
878 | + if (ret < 0) | |
879 | + /* Should we be checking the error code? */ | |
880 | + arm_linux_has_wmmx_registers = 0; | |
881 | + } | |
882 | + | |
883 | + if (arm_linux_has_wmmx_registers) | |
884 | + result = "iwmmxt"; | |
885 | + | |
886 | + if (result == NULL) | |
887 | + return 0; | |
888 | + | |
889 | + total_len = strlen (result); | |
890 | + if (total_len > offset) | |
891 | + { | |
892 | + int bytes_read = min (total_len - offset, len); | |
893 | + memcpy (readbuf, result + offset, bytes_read); | |
894 | + return bytes_read; | |
895 | + } | |
896 | + | |
897 | + return 0; | |
898 | +} | |
899 | + | |
743 | 900 | void |
744 | 901 | _initialize_arm_linux_nat (void) |
745 | 902 | { |
@@ -38,4 +38,20 @@ extern int kernel_u_size (void); | ||
38 | 38 | /* Override copies of {fetch,store}_inferior_registers in infptrace.c. */ |
39 | 39 | #define FETCH_INFERIOR_REGISTERS |
40 | 40 | |
41 | +/* This function is called like a to_xfer_partial hook, | |
42 | + but must be called with TARGET_OBJECT_AVAILABLE_REGISTERS. */ | |
43 | + | |
44 | +struct target_ops; | |
45 | + | |
46 | +extern LONGEST arm_linux_available_registers | |
47 | + (struct target_ops *ops, | |
48 | + int /* enum target_object */ object, | |
49 | + const char *annex, | |
50 | + void *readbuf, | |
51 | + const void *writebuf, | |
52 | + ULONGEST offset, | |
53 | + LONGEST len); | |
54 | + | |
55 | +#define NATIVE_XFER_AVAILABLE_REGISTERS arm_linux_available_registers | |
56 | + | |
41 | 57 | #endif /* NM_ARMLINUX_H */ |
@@ -155,11 +155,6 @@ arm_fill_wmmxregset (void *buf) | ||
155 | 155 | |
156 | 156 | for (i = 0; i < 4; i++) |
157 | 157 | collect_register (arm_num_regs + i + 16 + 8, ((char *) buf) + 16 * 8 + 8 + i * 4); |
158 | - | |
159 | - ((int*)buf)[0], | |
160 | - ((int*)buf)[1], | |
161 | - ((int*)buf)[2], | |
162 | - ((int*)buf)[3]); | |
163 | 158 | } |
164 | 159 | |
165 | 160 | static void |
@@ -167,10 +162,6 @@ arm_store_wmmxregset (const void *buf) | ||
167 | 162 | { |
168 | 163 | int i; |
169 | 164 | |
170 | - ((int*)buf)[0], | |
171 | - ((int*)buf)[1], | |
172 | - ((int*)buf)[2], | |
173 | - ((int*)buf)[3]); | |
174 | 165 | for (i = 0; i < 16; i++) |
175 | 166 | supply_register (arm_num_regs + i, ((char *) buf) + i * 8); |
176 | 167 |
@@ -186,11 +177,10 @@ arm_available_registers (void) | ||
186 | 177 | { |
187 | 178 | char buf[64]; |
188 | 179 | |
189 | - printf ("use_regsets %d target_regsets %d\n", use_regsets_p, target_regsets[1].size); | |
190 | 180 | if (use_regsets_p && target_regsets[1].size > 0) |
191 | 181 | { |
192 | 182 | int wr0 = find_regno ("wr0"); |
193 | - sprintf (buf, "iwmmxt:%d", wr0); | |
183 | + sprintf (buf, "iwmmxt:%x", wr0); | |
194 | 184 | return strdup (buf); |
195 | 185 | } |
196 | 186 |
@@ -38,7 +38,7 @@ struct inferior_regcache_data | ||
38 | 38 | static int register_bytes, g_register_bytes; |
39 | 39 | |
40 | 40 | static struct reg *reg_defs; |
41 | -static int num_registers; | |
41 | +int num_registers; | |
42 | 42 | |
43 | 43 | const char **gdbserver_expedite_regs; |
44 | 44 |
@@ -295,6 +295,8 @@ handle_v_requests (char *own_buf, char *status, unsigned char *signal) | ||
295 | 295 | return; |
296 | 296 | } |
297 | 297 | |
298 | +extern int num_registers; | |
299 | + | |
298 | 300 | /* Handle a register fetch ('p') request. */ |
299 | 301 | void |
300 | 302 | handle_p_packet (char *own_buf) |
@@ -302,7 +304,7 @@ handle_p_packet (char *own_buf) | ||
302 | 304 | char *end = own_buf + 1; |
303 | 305 | int regnum = strtol (own_buf + 1, &end, 16); |
304 | 306 | |
305 | - if (*end) | |
307 | + if (*end || regnum < 0 || regnum >= num_registers) | |
306 | 308 | { |
307 | 309 | write_enn (own_buf); |
308 | 310 | return; |
@@ -318,7 +320,7 @@ handle_P_packet (char *own_buf) | ||
318 | 320 | char *end = own_buf + 1; |
319 | 321 | int regnum = strtol (own_buf + 1, &end, 16); |
320 | 322 | |
321 | - if (*end != '=') | |
323 | + if (*end != '=' || regnum < 0 || regnum >= num_registers) | |
322 | 324 | { |
323 | 325 | write_enn (own_buf); |
324 | 326 | return; |
@@ -559,6 +559,13 @@ child_xfer_partial (struct target_ops *ops, enum target_object object, | ||
559 | 559 | return NATIVE_XFER_AUXV (ops, object, annex, readbuf, writebuf, |
560 | 560 | offset, len); |
561 | 561 | |
562 | + case TARGET_OBJECT_AVAILABLE_REGISTERS: | |
563 | +#ifndef NATIVE_XFER_AVAILABLE_REGISTERS | |
564 | +#define NATIVE_XFER_AVAILABLE_REGISTERS(OPS,OBJECT,ANNEX,WRITEBUF,READBUF,OFFSET,LEN) (-1) | |
565 | +#endif | |
566 | + return NATIVE_XFER_AVAILABLE_REGISTERS (ops, object, annex, readbuf, | |
567 | + writebuf, offset, len); | |
568 | + | |
562 | 569 | default: |
563 | 570 | return -1; |
564 | 571 | } |