[GDBServer][AArch64] Use the same break instruction as GDB
authorPierre Langlois <pierre.langlois@arm.com>
Mon, 29 Jun 2015 09:34:42 +0000 (10:34 +0100)
committerPierre Langlois <pierre.langlois@arm.com>
Mon, 29 Jun 2015 09:34:42 +0000 (10:34 +0100)
GDB uses a "brk #0" instruction to perform a software breakpoint while
GDBServer uses an illegal instruction.  Both instructions should match.

When enabling support for the 'Z0' packet, we let GDBServer insert the
breakpoint instruction instead of GDB.  And in case of permanent
breakpoints for example, GDB will check if a breakpoint is inserted in the
inferior with `program_breakpoint_here_p (gdbarch, address)', and
compare the instruction read from the inferior with the breakpoint
instruction.

On AArch64, instructions are always little endian so we need to
represent it as an array of bytes, as done in aarch64-tdep.c.

gdb/gdbserver/ChangeLog:

* linux-aarch64-low.c: Remove comment about endianness.
(aarch64_breakpoint): Change type to gdb_byte[].  Set to "brk #0".
(aarch64_breakpoint_at): Change type of insn to gdb_byte[].  Use
memcmp.

gdb/gdbserver/ChangeLog
gdb/gdbserver/linux-aarch64-low.c

index 2528f0f5d116c07a78f1311d6d0153b8b0efde03..8dad98ef3c2b6f8a48993415ade9e91bec6b12c9 100644 (file)
@@ -1,3 +1,10 @@
+2015-06-29  Pierre Langlois  <pierre.langlois@arm.com>
+
+       * linux-aarch64-low.c: Remove comment about endianness.
+       (aarch64_breakpoint): Change type to gdb_byte[].  Set to "brk #0".
+       (aarch64_breakpoint_at): Change type of insn to gdb_byte[].  Use
+       memcmp.
+
 2015-06-24  Gary Benson  <gbenson@redhat.com>
 
        * linux-i386-ipa.c (stdint.h): Do not include.
index 043458d68eaca4505013b26b71c695da5fa7230a..b0a277528df4478914b7b64b8ce7d8de45a23d5a 100644 (file)
@@ -295,19 +295,21 @@ aarch64_set_pc (struct regcache *regcache, CORE_ADDR pc)
   supply_register_by_name (regcache, "pc", &newpc);
 }
 
-/* Correct in either endianness.  */
-
 #define aarch64_breakpoint_len 4
 
-static const unsigned long aarch64_breakpoint = 0x00800011;
+/* AArch64 BRK software debug mode instruction.
+   This instruction needs to match gdb/aarch64-tdep.c
+   (aarch64_default_breakpoint).  */
+static const gdb_byte aarch64_breakpoint[] = {0x00, 0x00, 0x20, 0xd4};
 
 static int
 aarch64_breakpoint_at (CORE_ADDR where)
 {
-  unsigned long insn;
+  gdb_byte insn[aarch64_breakpoint_len];
 
-  (*the_target->read_memory) (where, (unsigned char *) &insn, 4);
-  if (insn == aarch64_breakpoint)
+  (*the_target->read_memory) (where, (unsigned char *) &insn,
+                             aarch64_breakpoint_len);
+  if (memcmp (insn, aarch64_breakpoint, aarch64_breakpoint_len) == 0)
     return 1;
 
   return 0;
This page took 0.032889 seconds and 4 git commands to generate.