public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH V2 1/4] ARM: extract_arm_insn function need to read instrs correctly in be8 case
  2014-10-22  5:26 [PATCH V2 0/4] arm: set of big endian related fixes for armeb (v7) Victor Kamensky
@ 2014-10-22  5:26 ` Victor Kamensky
  2014-10-22  5:26 ` [PATCH V2 2/4] ARM: arm_breakpoint should be little endian form in case for arm BE8 Victor Kamensky
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Victor Kamensky @ 2014-10-22  5:26 UTC (permalink / raw)
  To: gdb-patches, Yao Qi; +Cc: Andrew Pinski, victor.kamensky

extract_arm_insn function needs to read instructions in
gdbarch_byte_order_for_code byte order, because in case armv7b,
even data is big endian, instructions are still little endian.
Currently function uses gdbarch_byte_order which would be
big endian in armv7b case.

Because of this issue pretty much all gdb.reverse/ tests are
failing with 'Process record does not support instruction' message.

Fix is to change gdbarch_byte_order to gdbarch_byte_order_for_code,
when passed to extract_unsigned_integer that reads instruction.

gdb/ChangeLog:

2014-10-21  Victor Kamensky  <victor.kamensky@linaro.org>

	* arm-tdep.c (extract_arm_insn): Use
	gdbarch_byte_order_for_code to read arm instruction.
---
 gdb/arm-tdep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index e2559ec..e7a1ec5 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -13860,7 +13860,7 @@ extract_arm_insn (insn_decode_record *insn_record, uint32_t insn_size)
     return 1;
   insn_record->arm_insn = (uint32_t) extract_unsigned_integer (&buf[0],
                            insn_size, 
-                           gdbarch_byte_order (insn_record->gdbarch));
+			   gdbarch_byte_order_for_code (insn_record->gdbarch));
   return 0;
 }
 
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH V2 0/4] arm: set of big endian related fixes for armeb (v7)
@ 2014-10-22  5:26 Victor Kamensky
  2014-10-22  5:26 ` [PATCH V2 1/4] ARM: extract_arm_insn function need to read instrs correctly in be8 case Victor Kamensky
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Victor Kamensky @ 2014-10-22  5:26 UTC (permalink / raw)
  To: gdb-patches, Yao Qi; +Cc: Andrew Pinski, victor.kamensky

Hi Folks,

Here is second version of patches that fix big endian related 
issues for ARM V7 target.

Since version [1]:
* dropped first patch - it was posted on binutils@
* addressed Yao's comments
* moved all ChangeLog entries from patches to commit comments
* fixed mixed up ChangeLog entry for "ARM: arm_breakpoint 
should be little endian form in case" patch"
* changed title of read_pieced_value patch since it is not
really ARM specific issue, just general big endian

Thanks,
Victor

[1] https://sourceware.org/ml/gdb-patches/2014-10/msg00526.html

Victor Kamensky (4):
  ARM: extract_arm_insn function need to read instrs correctly in be8
    case
  ARM: arm_breakpoint should be little endian form in case for arm BE8
  read_pieced_value do big endian processing only in case of valid
    gdb_regnum
  ARM: asm-source.exp link options in case of armv7b target

 gdb/arm-linux-tdep.c                 |  2 +-
 gdb/arm-tdep.c                       |  2 +-
 gdb/dwarf2loc.c                      | 30 +++++++++++++++---------------
 gdb/testsuite/gdb.asm/asm-source.exp |  4 ++++
 4 files changed, 21 insertions(+), 17 deletions(-)

-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH V2 3/4] read_pieced_value do big endian processing only in case of valid gdb_regnum
  2014-10-22  5:26 [PATCH V2 0/4] arm: set of big endian related fixes for armeb (v7) Victor Kamensky
                   ` (2 preceding siblings ...)
  2014-10-22  5:26 ` [PATCH V2 4/4] ARM: asm-source.exp link options in case of armv7b target Victor Kamensky
@ 2014-10-22  5:26 ` Victor Kamensky
  3 siblings, 0 replies; 5+ messages in thread
From: Victor Kamensky @ 2014-10-22  5:26 UTC (permalink / raw)
  To: gdb-patches, Yao Qi; +Cc: Andrew Pinski, victor.kamensky

During armv7b testing gdb.base/store.exp test was failling with
'GDB internal error'. It turns out that compiler generated DWARF
with non-existent register numbers. The compiler issue is present
in both little endian (armv7) and big endian (armv7b) (it is
separate issue). In both case gdbarch_dwarf2_reg_to_regnum returns
-1 which is stored into gdb_regnum. But it cause severe problem
only in big endian case because in read_pieced_value and
write_pieced_value functions BFD_ENDIAN_BIG related processing
happen regardless of gdb_regnum value, and in case of gdb_regnum=-1,
it cause 'GDB internal error' and crash.

Solution is to move BFD_ENDIAN_BIG related processing under
(gdb_regnum != -1) branch of processing.

gdb/ChangeLog:

2014-10-21  Victor Kamensky  <victor.kamensky@linaro.org>

	* dwarf2loc.c (read_pieced_value): Do BE processing only if
	gdb_regnum is not -1.
	(write_pieced_value): Ditto.
---
 gdb/dwarf2loc.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index e347e59..fbe99bb 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -1686,20 +1686,20 @@ read_pieced_value (struct value *v)
 	    int gdb_regnum = gdbarch_dwarf2_reg_to_regnum (arch, p->v.regno);
 	    int reg_offset = source_offset;
 
-	    if (gdbarch_byte_order (arch) == BFD_ENDIAN_BIG
-		&& this_size < register_size (arch, gdb_regnum))
-	      {
-		/* Big-endian, and we want less than full size.  */
-		reg_offset = register_size (arch, gdb_regnum) - this_size;
-		/* We want the lower-order THIS_SIZE_BITS of the bytes
-		   we extract from the register.  */
-		source_offset_bits += 8 * this_size - this_size_bits;
-	      }
-
 	    if (gdb_regnum != -1)
 	      {
 		int optim, unavail;
 
+		if (gdbarch_byte_order (arch) == BFD_ENDIAN_BIG
+		    && this_size < register_size (arch, gdb_regnum))
+		  {
+		    /* Big-endian, and we want less than full size.  */
+		    reg_offset = register_size (arch, gdb_regnum) - this_size;
+		    /* We want the lower-order THIS_SIZE_BITS of the bytes
+		       we extract from the register.  */
+		    source_offset_bits += 8 * this_size - this_size_bits;
+		 }
+
 		if (!get_frame_register_bytes (frame, gdb_regnum, reg_offset,
 					       this_size, buffer,
 					       &optim, &unavail))
@@ -1878,13 +1878,13 @@ write_pieced_value (struct value *to, struct value *from)
 	    int gdb_regnum = gdbarch_dwarf2_reg_to_regnum (arch, p->v.regno);
 	    int reg_offset = dest_offset;
 
-	    if (gdbarch_byte_order (arch) == BFD_ENDIAN_BIG
-		&& this_size <= register_size (arch, gdb_regnum))
-	      /* Big-endian, and we want less than full size.  */
-	      reg_offset = register_size (arch, gdb_regnum) - this_size;
-
 	    if (gdb_regnum != -1)
 	      {
+		if (gdbarch_byte_order (arch) == BFD_ENDIAN_BIG
+		    && this_size <= register_size (arch, gdb_regnum))
+		  /* Big-endian, and we want less than full size.  */
+		  reg_offset = register_size (arch, gdb_regnum) - this_size;
+
 		if (need_bitwise)
 		  {
 		    int optim, unavail;
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH V2 4/4] ARM: asm-source.exp link options in case of armv7b target
  2014-10-22  5:26 [PATCH V2 0/4] arm: set of big endian related fixes for armeb (v7) Victor Kamensky
  2014-10-22  5:26 ` [PATCH V2 1/4] ARM: extract_arm_insn function need to read instrs correctly in be8 case Victor Kamensky
  2014-10-22  5:26 ` [PATCH V2 2/4] ARM: arm_breakpoint should be little endian form in case for arm BE8 Victor Kamensky
@ 2014-10-22  5:26 ` Victor Kamensky
  2014-10-22  5:26 ` [PATCH V2 3/4] read_pieced_value do big endian processing only in case of valid gdb_regnum Victor Kamensky
  3 siblings, 0 replies; 5+ messages in thread
From: Victor Kamensky @ 2014-10-22  5:26 UTC (permalink / raw)
  To: gdb-patches, Yao Qi; +Cc: Andrew Pinski, victor.kamensky

gdb.asm/asm-source.exp fails in armv7b case, because it does
not pass --be8 option to link, as result instructions in asm-source
executable are in big endian order and crash with SIGILL.

Solution is to add --be8 option to link command during test creation.

gdb/testsuite/ChangeLog:

2014-10-21  Victor Kamensky  <victor.kamensky@linaro.org>

	* gdb.asm/asm-source.exp: Add armv7b case for target.
---
 gdb/testsuite/gdb.asm/asm-source.exp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gdb/testsuite/gdb.asm/asm-source.exp b/gdb/testsuite/gdb.asm/asm-source.exp
index fa4585c..153bc50 100644
--- a/gdb/testsuite/gdb.asm/asm-source.exp
+++ b/gdb/testsuite/gdb.asm/asm-source.exp
@@ -37,6 +37,10 @@ switch -glob -- [istarget] {
         set asm-flags "-no-mdebug -I${srcdir}/${subdir} $obj_include"
 	set debug-flags "-gdwarf-2"
     }
+    "armv7b-*-*" {
+	set asm-arch arm
+	append link-flags " -be8"
+    }
     "arm*-*-*" {
         set asm-arch arm
     }
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH V2 2/4] ARM: arm_breakpoint should be little endian form in case for arm BE8
  2014-10-22  5:26 [PATCH V2 0/4] arm: set of big endian related fixes for armeb (v7) Victor Kamensky
  2014-10-22  5:26 ` [PATCH V2 1/4] ARM: extract_arm_insn function need to read instrs correctly in be8 case Victor Kamensky
@ 2014-10-22  5:26 ` Victor Kamensky
  2014-10-22  5:26 ` [PATCH V2 4/4] ARM: asm-source.exp link options in case of armv7b target Victor Kamensky
  2014-10-22  5:26 ` [PATCH V2 3/4] read_pieced_value do big endian processing only in case of valid gdb_regnum Victor Kamensky
  3 siblings, 0 replies; 5+ messages in thread
From: Victor Kamensky @ 2014-10-22  5:26 UTC (permalink / raw)
  To: gdb-patches, Yao Qi; +Cc: Andrew Pinski, victor.kamensky

tdep->arm_breakpoint, tdep->thumb_breakpoint, tdep->thumb2_breakpoint
should be set le_ variants in case of arm BE8 code. Those instruciton
sequences are writen to target with simple write_memory, without
regarding gdbarch_byte_order_for_code. But in BE8 case even data
memory is in big endian form, instructions are still in little endian
form.

Because of this issue there are many issues while running gdb test
case in armv7b mode. For example gdb.arch/arm-disp-step.exp test fails
because it gets SIGILL when displaced instrucion sequence reaches
break instruction, which is in wrong byte order.

Solution is to set tdep->xxx_breakpoint sequences in BE8 case (i.e
when gdbarch_byte_order_for_code is BFD_ENDIAN_BIG.

gdb/ChangeLog:

2014-10-21  Victor Kamensky  <victor.kamensky@linaro.org>

	* arm-linux-tdep.c (arm_linux_init_abi): Use
	info.byte_order_for_code to choose endianity of breakpoint
	instructions snippets.
---
 gdb/arm-linux-tdep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
index e3587f3..2e79658 100644
--- a/gdb/arm-linux-tdep.c
+++ b/gdb/arm-linux-tdep.c
@@ -1361,7 +1361,7 @@ arm_linux_init_abi (struct gdbarch_info info,
   linux_init_abi (info, gdbarch);
 
   tdep->lowest_pc = 0x8000;
-  if (info.byte_order == BFD_ENDIAN_BIG)
+  if (info.byte_order_for_code == BFD_ENDIAN_BIG)
     {
       if (tdep->arm_abi == ARM_ABI_AAPCS)
 	tdep->arm_breakpoint = eabi_linux_arm_be_breakpoint;
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-10-22  5:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-22  5:26 [PATCH V2 0/4] arm: set of big endian related fixes for armeb (v7) Victor Kamensky
2014-10-22  5:26 ` [PATCH V2 1/4] ARM: extract_arm_insn function need to read instrs correctly in be8 case Victor Kamensky
2014-10-22  5:26 ` [PATCH V2 2/4] ARM: arm_breakpoint should be little endian form in case for arm BE8 Victor Kamensky
2014-10-22  5:26 ` [PATCH V2 4/4] ARM: asm-source.exp link options in case of armv7b target Victor Kamensky
2014-10-22  5:26 ` [PATCH V2 3/4] read_pieced_value do big endian processing only in case of valid gdb_regnum Victor Kamensky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).