This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC/TileGX 2/2] fix gdbserver bug for 32bit elf


for tilegx, all general registers are 64bit, while the pseudo 'pc' is 32bit under tilegx32.

gdb client treat 'pc' correctly in

static struct type *
tilegx_register_type (struct gdbarch *gdbarch, int regnum)
{
  if (regnum == TILEGX_PC_REGNUM)
    return builtin_type (gdbarch)->builtin_func_ptr;


while gdbserver always treat it as 64bit, there is mismatch.

gdb/ChangeLog:
        * configure.tgt: Enable gdbserver for tilegx
        * gdbserver/Makefile.in: Add rule for reg-tilegx32.c
        * gdbserver/configure.srv: Add rule for reg-tilegx32.o
        * gdbserver/linux-tile-low.c: Add tile_arch_setup and
        init_registers_tilegx32, tile_arch_setup will register
        different register info according to elf class. also,
        use "uint_reg_t" to represent register size.
        * regformats/reg-tilegx.dat: Change abi name to "tilegx.
        * regformats/reg-tilegx32.dat: New.


please review.


thanks.

--
Regards,
Jiong. Wang
Tilera Corporation.

---
 gdb/configure.tgt               |    1 +
 gdb/gdbserver/Makefile.in       |    2 ++
 gdb/gdbserver/configure.srv     |    1 +
 gdb/gdbserver/linux-tile-low.c  |   31 +++++++++++++++---
 gdb/regformats/reg-tilegx.dat   |    2 +-
 gdb/regformats/reg-tilegx32.dat |   67 +++++++++++++++++++++++++++++++++++++++
 6 files changed, 98 insertions(+), 6 deletions(-)
 create mode 100644 gdb/regformats/reg-tilegx32.dat

diff --git a/gdb/configure.tgt b/gdb/configure.tgt
index 5b77bb2..d1e3a9b 100644
--- a/gdb/configure.tgt
+++ b/gdb/configure.tgt
@@ -579,6 +579,7 @@ tilegx-*-linux*)
         # Target: TILE-Gx
         gdb_target_obs="tilegx-tdep.o tilegx-linux-tdep.o solib-svr4.o \
 			symfile-mem.o glibc-tdep.o linux-tdep.o"
+	build_gdbserver=yes
         ;;
 
 xstormy16-*-*)
diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index f8b1794..79dc02c 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -689,6 +689,8 @@ reg-xtensa.c : $(srcdir)/../regformats/reg-xtensa.dat $(regdat_sh)
 	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/reg-xtensa.dat reg-xtensa.c
 reg-tilegx.c : $(srcdir)/../regformats/reg-tilegx.dat $(regdat_sh)
 	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/reg-tilegx.dat reg-tilegx.c
+reg-tilegx32.c : $(srcdir)/../regformats/reg-tilegx32.dat $(regdat_sh)
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/reg-tilegx32.dat reg-tilegx32.c
 
 #
 # Dependency tracking.  Most of this is conditional on GNU Make being
diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv
index cdb5487..91ca290 100644
--- a/gdb/gdbserver/configure.srv
+++ b/gdb/gdbserver/configure.srv
@@ -318,6 +318,7 @@ case "${target}" in
 			srv_linux_regsets=yes
 			;;
   tilegx-*-linux*)	srv_regobj=reg-tilegx.o
+			srv_regobj="${srv_regobj} reg-tilegx32.o"
 			srv_tgtobj="linux-low.o linux-tile-low.o linux-osdata.o linux-procfs.o"
 			srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
 			srv_linux_regsets=yes
diff --git a/gdb/gdbserver/linux-tile-low.c b/gdb/gdbserver/linux-tile-low.c
index c73bdf2..f242675 100644
--- a/gdb/gdbserver/linux-tile-low.c
+++ b/gdb/gdbserver/linux-tile-low.c
@@ -20,10 +20,13 @@
 #include "server.h"
 #include "linux-low.h"
 
+#include <arch/abi.h>
 #include <sys/ptrace.h>
 
-/* Defined in auto-generated file reg-tile.c.  */
-void init_registers_tile (void);
+/* Defined in auto-generated file reg-tilegx.c.  */
+void init_registers_tilegx (void);
+/* Defined in auto-generated file reg-tilegx32.c.  */
+void init_registers_tilegx32 (void);
 
 #define tile_num_regs 65
 
@@ -103,7 +106,7 @@ tile_fill_gregset (struct regcache *regcache, void *buf)
 
   for (i = 0; i < tile_num_regs; i++)
     if (tile_regmap[i] != -1)
-      collect_register (regcache, i, ((unsigned int *) buf) + tile_regmap[i]);
+      collect_register (regcache, i, ((uint_reg_t *) buf) + tile_regmap[i]);
 }
 
 static void
@@ -113,7 +116,7 @@ tile_store_gregset (struct regcache *regcache, const void *buf)
 
   for (i = 0; i < tile_num_regs; i++)
     if (tile_regmap[i] != -1)
-      supply_register (regcache, i, ((unsigned long *) buf) + tile_regmap[i]);
+      supply_register (regcache, i, ((uint_reg_t *) buf) + tile_regmap[i]);
 }
 
 struct regset_info target_regsets[] =
@@ -123,9 +126,27 @@ struct regset_info target_regsets[] =
   { 0, 0, 0, -1, -1, NULL, NULL }
 };
 
+static void
+tile_arch_setup (void)
+{
+  int pid = pid_of (get_thread_lwp (current_inferior));
+  unsigned int machine;
+  int is_elf64 = linux_pid_exe_is_elf_64_file (pid, &machine);
+
+  if (sizeof (void *) == 4)
+    if (is_elf64 > 0)
+      error (_("Can't debug 64-bit process with 32-bit GDBserver"));
+
+  if (!is_elf64)
+    init_registers_tilegx32();
+  else
+    init_registers_tilegx();
+}
+
+
 struct linux_target_ops the_low_target =
 {
-  init_registers_tile,
+  tile_arch_setup,
   tile_num_regs,
   tile_regmap,
   NULL,
diff --git a/gdb/regformats/reg-tilegx.dat b/gdb/regformats/reg-tilegx.dat
index fc971f9..588252f 100644
--- a/gdb/regformats/reg-tilegx.dat
+++ b/gdb/regformats/reg-tilegx.dat
@@ -1,4 +1,4 @@
-name:tile
+name:tilegx
 expedite:sp,lr,pc
 64:r0
 64:r1
diff --git a/gdb/regformats/reg-tilegx32.dat b/gdb/regformats/reg-tilegx32.dat
new file mode 100644
index 0000000..d8bfe2a
--- /dev/null
+++ b/gdb/regformats/reg-tilegx32.dat
@@ -0,0 +1,67 @@
+name:tilegx32
+expedite:sp,lr,pc
+64:r0
+64:r1
+64:r2
+64:r3
+64:r4
+64:r5
+64:r6
+64:r7
+64:r8
+64:r9
+64:r10
+64:r11
+64:r12
+64:r13
+64:r14
+64:r15
+64:r16
+64:r17
+64:r18
+64:r19
+64:r20
+64:r21
+64:r22
+64:r23
+64:r24
+64:r25
+64:r26
+64:r27
+64:r28
+64:r29
+64:r30
+64:r31
+64:r32
+64:r33
+64:r34
+64:r35
+64:r36
+64:r37
+64:r38
+64:r39
+64:r40
+64:r41
+64:r42
+64:r43
+64:r44
+64:r45
+64:r46
+64:r47
+64:r48
+64:r49
+64:r50
+64:r51
+64:r52
+64:tp
+64:sp
+64:lr
+64:sn
+64:io0
+64:io1
+64:us0
+64:us1
+64:us2
+64:us3
+64:zero
+32:pc
-- 
1.7.10.3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]