GDB: set correct data model for x86_64-nacl

This is required for reading typed values from target memory, in particular, to read correct pointer values.

The change is risky. It confuses a lot of code that uses pointer size to distinguish from x86_64 and i386. Luckily, this code is mostly about native debugging and syscalls, so it is not used for NaCl.

Anyway, the way to check for x86_64 by pointer size is lame, as it mixes architecture properties and data model. We plan to clean this up using some better check.

The change is hacky, as it fixes types of registers values directly. This should be done in xml descriptions instead. However, this requires much more work, and this requires introducing NaCl-specific xml files.

BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com/10798008
diff --git a/gdb/features/i386/amd64-linux.c b/gdb/features/i386/amd64-linux.c
index 71efcbe..2eb9f96 100644
--- a/gdb/features/i386/amd64-linux.c
+++ b/gdb/features/i386/amd64-linux.c
@@ -42,8 +42,8 @@
   tdesc_create_reg (feature, "rdx", 3, 1, NULL, 64, "int64");
   tdesc_create_reg (feature, "rsi", 4, 1, NULL, 64, "int64");
   tdesc_create_reg (feature, "rdi", 5, 1, NULL, 64, "int64");
-  tdesc_create_reg (feature, "rbp", 6, 1, NULL, 64, "data_ptr");
-  tdesc_create_reg (feature, "rsp", 7, 1, NULL, 64, "data_ptr");
+  tdesc_create_reg (feature, "rbp", 6, 1, NULL, 64, "int64");
+  tdesc_create_reg (feature, "rsp", 7, 1, NULL, 64, "int64");
   tdesc_create_reg (feature, "r8", 8, 1, NULL, 64, "int64");
   tdesc_create_reg (feature, "r9", 9, 1, NULL, 64, "int64");
   tdesc_create_reg (feature, "r10", 10, 1, NULL, 64, "int64");
@@ -52,7 +52,7 @@
   tdesc_create_reg (feature, "r13", 13, 1, NULL, 64, "int64");
   tdesc_create_reg (feature, "r14", 14, 1, NULL, 64, "int64");
   tdesc_create_reg (feature, "r15", 15, 1, NULL, 64, "int64");
-  tdesc_create_reg (feature, "rip", 16, 1, NULL, 64, "code_ptr");
+  tdesc_create_reg (feature, "rip", 16, 1, NULL, 64, "int64");
   tdesc_create_reg (feature, "eflags", 17, 1, NULL, 32, "i386_eflags");
   tdesc_create_reg (feature, "cs", 18, 1, NULL, 32, "int32");
   tdesc_create_reg (feature, "ss", 19, 1, NULL, 32, "int32");
diff --git a/gdb/nacl-tdep.c b/gdb/nacl-tdep.c
index 91db262..edb3763 100644
--- a/gdb/nacl-tdep.c
+++ b/gdb/nacl-tdep.c
@@ -81,6 +81,24 @@
   set_solib_svr4_fetch_link_map_offsets (gdbarch,
 					 svr4_lp64_fetch_link_map_offsets);
   nacl_init_abi (info, gdbarch);
+
+  /* NaCl data model.
+
+     WARNING! This might confuse a lot of code, as it uses
+       if (set_gdbarch_ptr_bit (gdbarch) == <bits>)
+     to distinguish between i386 and x86_64 (lame!).  Luckily, most of that
+     code is about native debugging and syscalls, so it is not used for NaCl.
+
+     TODO(eaeltsin): find better way to distinguish between i386 and x86_64!  */
+  set_gdbarch_long_bit (gdbarch, 32);
+  set_gdbarch_ptr_bit (gdbarch, 32);
+
+  /* TODO(eaeltsin): we might use address size instead of pointer size to
+     distinguish between i386 and x86_64...  At least address size is not
+     a property of the data model.  */
+  set_gdbarch_addr_bit (gdbarch, 64);
+
+  /* How to extract addresses from registers.  */
   set_gdbarch_addr_bits_remove (gdbarch, amd64_nacl_addr_bits_remove);
   set_gdbarch_unwind_pc (gdbarch, amd64_nacl_unwind_pc);
   set_gdbarch_unwind_sp (gdbarch, amd64_nacl_unwind_sp);