• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

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

修订版2c0f1e706145cd2408654c5a0ef3217c02108d97 (tree)
时间2005-03-30 23:59:31
作者Daniel Jacobowitz <drow@fals...>
CommiterDaniel Jacobowitz

Log Message

* 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.

更改概述

差异

--- a/ChangeLog.csl
+++ b/ChangeLog.csl
@@ -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+
125 2005-03-28 Paul Brook <paul@codesourcery.com>
226 Daniel Jacobowitz <dan@codesourcery.com>
327
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1732,7 +1732,7 @@ arch-utils.o: arch-utils.c $(defs_h) $(arch_utils_h) $(buildsym_h) \
17321732 $(floatformat_h)
17331733 arm-linux-nat.o: arm-linux-nat.c $(defs_h) $(inferior_h) $(gdbcore_h) \
17341734 $(gdb_string_h) $(regcache_h) $(arm_tdep_h) $(gregset_h)\
1735- $(gdb_proc_service_h)
1735+ $(gdb_proc_service_h) $(gdb_assert_h)
17361736 arm-linux-tdep.o: arm-linux-tdep.c $(defs_h) $(target_h) $(value_h) \
17371737 $(gdbtypes_h) $(floatformat_h) $(gdbcore_h) $(frame_h) $(regcache_h) \
17381738 $(doublest_h) $(solib_svr4_h) $(osabi_h) $(arm_tdep_h) \
--- a/gdb/arm-linux-nat.c
+++ b/gdb/arm-linux-nat.c
@@ -23,6 +23,7 @@
2323 #include "gdbcore.h"
2424 #include "gdb_string.h"
2525 #include "regcache.h"
26+#include "gdb_assert.h"
2627
2728 #include "arm-tdep.h"
2829
@@ -41,6 +42,13 @@
4142 #define PTRACE_GET_THREAD_AREA 22
4243 #endif
4344
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+
4452 extern int arm_apcs_32;
4553
4654 #define typeNone 0x00
@@ -99,7 +107,7 @@ get_thread_id (ptid_t ptid)
99107 tid = PIDGET (ptid);
100108 return tid;
101109 }
102-#define GET_THREAD_ID(PTID) get_thread_id ((PTID));
110+#define GET_THREAD_ID(PTID) get_thread_id (PTID)
103111
104112 static void
105113 fetch_nwfpe_single (unsigned int fn, FPA11 * fpa11)
@@ -550,6 +558,97 @@ store_regs (void)
550558 }
551559 }
552560
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+ &regbuf[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+ &regbuf[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+ &regbuf[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+ &regbuf[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+ &regbuf[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+ &regbuf[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+
553652 /* Fetch registers from the child process. Fetch all registers if
554653 regno == -1, otherwise fetch all general registers or all floating
555654 point registers depending upon the value of regno. */
@@ -561,14 +660,21 @@ fetch_inferior_registers (int regno)
561660 {
562661 fetch_regs ();
563662 fetch_fpa_regs ();
663+ if (arm_linux_has_wmmx_registers)
664+ fetch_wmmx_regs ();
564665 }
565666 else
566667 {
567- if (regno < ARM_F0_REGNUM || regno > ARM_FPS_REGNUM)
668+ if (regno < ARM_F0_REGNUM || regno == ARM_PS_REGNUM)
568669 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)
571671 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+ }
572678 }
573679 }
574680
@@ -583,14 +689,21 @@ store_inferior_registers (int regno)
583689 {
584690 store_regs ();
585691 store_fpa_regs ();
692+ if (arm_linux_has_wmmx_registers)
693+ store_wmmx_regs ();
586694 }
587695 else
588696 {
589- if ((regno < ARM_F0_REGNUM) || (regno > ARM_FPS_REGNUM))
697+ if (regno < ARM_F0_REGNUM || regno == ARM_PS_REGNUM)
590698 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+ }
594707 }
595708 }
596709
@@ -740,6 +853,50 @@ get_linux_version (unsigned int *vmajor,
740853 return ((*vmajor << 16) | (*vminor << 8) | *vrelease);
741854 }
742855
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+
743900 void
744901 _initialize_arm_linux_nat (void)
745902 {
--- a/gdb/config/arm/nm-linux.h
+++ b/gdb/config/arm/nm-linux.h
@@ -38,4 +38,20 @@ extern int kernel_u_size (void);
3838 /* Override copies of {fetch,store}_inferior_registers in infptrace.c. */
3939 #define FETCH_INFERIOR_REGISTERS
4040
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+
4157 #endif /* NM_ARMLINUX_H */
--- a/gdb/gdbserver/linux-arm-low.c
+++ b/gdb/gdbserver/linux-arm-low.c
@@ -155,11 +155,6 @@ arm_fill_wmmxregset (void *buf)
155155
156156 for (i = 0; i < 4; i++)
157157 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]);
163158 }
164159
165160 static void
@@ -167,10 +162,6 @@ arm_store_wmmxregset (const void *buf)
167162 {
168163 int i;
169164
170- ((int*)buf)[0],
171- ((int*)buf)[1],
172- ((int*)buf)[2],
173- ((int*)buf)[3]);
174165 for (i = 0; i < 16; i++)
175166 supply_register (arm_num_regs + i, ((char *) buf) + i * 8);
176167
@@ -186,11 +177,10 @@ arm_available_registers (void)
186177 {
187178 char buf[64];
188179
189- printf ("use_regsets %d target_regsets %d\n", use_regsets_p, target_regsets[1].size);
190180 if (use_regsets_p && target_regsets[1].size > 0)
191181 {
192182 int wr0 = find_regno ("wr0");
193- sprintf (buf, "iwmmxt:%d", wr0);
183+ sprintf (buf, "iwmmxt:%x", wr0);
194184 return strdup (buf);
195185 }
196186
--- a/gdb/gdbserver/regcache.c
+++ b/gdb/gdbserver/regcache.c
@@ -38,7 +38,7 @@ struct inferior_regcache_data
3838 static int register_bytes, g_register_bytes;
3939
4040 static struct reg *reg_defs;
41-static int num_registers;
41+int num_registers;
4242
4343 const char **gdbserver_expedite_regs;
4444
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -295,6 +295,8 @@ handle_v_requests (char *own_buf, char *status, unsigned char *signal)
295295 return;
296296 }
297297
298+extern int num_registers;
299+
298300 /* Handle a register fetch ('p') request. */
299301 void
300302 handle_p_packet (char *own_buf)
@@ -302,7 +304,7 @@ handle_p_packet (char *own_buf)
302304 char *end = own_buf + 1;
303305 int regnum = strtol (own_buf + 1, &end, 16);
304306
305- if (*end)
307+ if (*end || regnum < 0 || regnum >= num_registers)
306308 {
307309 write_enn (own_buf);
308310 return;
@@ -318,7 +320,7 @@ handle_P_packet (char *own_buf)
318320 char *end = own_buf + 1;
319321 int regnum = strtol (own_buf + 1, &end, 16);
320322
321- if (*end != '=')
323+ if (*end != '=' || regnum < 0 || regnum >= num_registers)
322324 {
323325 write_enn (own_buf);
324326 return;
--- a/gdb/inftarg.c
+++ b/gdb/inftarg.c
@@ -559,6 +559,13 @@ child_xfer_partial (struct target_ops *ops, enum target_object object,
559559 return NATIVE_XFER_AUXV (ops, object, annex, readbuf, writebuf,
560560 offset, len);
561561
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+
562569 default:
563570 return -1;
564571 }