public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/2] gdb/riscv: Use TYPE_SAFE_NAME
  2018-07-10 11:58 [PUSHED] [PATCH 0/2] Small RiscV cleanup / fixes Andrew Burgess
@ 2018-07-10 11:58 ` Andrew Burgess
  2018-07-10 11:58 ` [PATCH 2/2] gdb/riscv: Fix assertion in inferior call code Andrew Burgess
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Burgess @ 2018-07-10 11:58 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

In debug printing, use TYPE_SAFE_NAME instead of replicating the
functionality using TYPE_NAME and a null check.

gdb/ChangeLog:

	* riscv-tdep.c (riscv_print_arg_location): Use TYPE_SAFE_NAME.
---
 gdb/ChangeLog    | 4 ++++
 gdb/riscv-tdep.c | 6 +-----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index 4c68ef73fc5..e2be993eaf0 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -1939,12 +1939,8 @@ riscv_print_arg_location (ui_file *stream, struct gdbarch *gdbarch,
 			  struct riscv_arg_info *info,
 			  CORE_ADDR sp_refs, CORE_ADDR sp_args)
 {
-  const char* type_name = TYPE_NAME (info->type);
-  if (type_name == nullptr)
-    type_name = "???";
-
   fprintf_unfiltered (stream, "type: '%s', length: 0x%x, alignment: 0x%x",
-		      type_name, info->length, info->align);
+		      TYPE_SAFE_NAME (info->type), info->length, info->align);
   switch (info->argloc[0].loc_type)
     {
     case riscv_arg_info::location::in_reg:
-- 
2.14.4

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

* [PATCH 2/2] gdb/riscv: Fix assertion in inferior call code
  2018-07-10 11:58 [PUSHED] [PATCH 0/2] Small RiscV cleanup / fixes Andrew Burgess
  2018-07-10 11:58 ` [PATCH 1/2] gdb/riscv: Use TYPE_SAFE_NAME Andrew Burgess
@ 2018-07-10 11:58 ` Andrew Burgess
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Burgess @ 2018-07-10 11:58 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

An assertion when setting up arguments for an inferior call checks the
size of the argument against xlen.  However, if xlen and flen are
different sizes, and the argument is being placed into a floating
pointer register then we should be comparing against flen not xlen.

This issue shows up as an assertion failure when running on an rv32g
target with a binary compiled using the rv32f abi and making an
inferior call involving large floating point arguments, for example
the test gdb.base/infcall-nested-structs.exp.

gdb/ChangeLog:

	* riscv-tdep.c (riscv_is_fp_regno_p): New function.
	(riscv_register_reggroup_p): Use new function, remove unneeded
	parenthesis.
	(riscv_push_dummy_call): Extend assert to compare against xlen or
	flen based on register type.
---
 gdb/ChangeLog    |  8 ++++++++
 gdb/riscv-tdep.c | 21 ++++++++++++++++-----
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index e2be993eaf0..25a8fda29c4 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -413,6 +413,15 @@ riscv_has_fp_abi (struct gdbarch *gdbarch)
   return (gdbarch_tdep (gdbarch)->abi.fields.float_abi != 0);
 }
 
+/* Return true if REGNO is a floating pointer register.  */
+
+static bool
+riscv_is_fp_regno_p (int regno)
+{
+  return (regno >= RISCV_FIRST_FP_REGNUM
+	  && regno <= RISCV_LAST_FP_REGNUM);
+}
+
 /* Implement the breakpoint_kind_from_pc gdbarch method.  */
 
 static int
@@ -787,10 +796,10 @@ riscv_register_reggroup_p (struct gdbarch  *gdbarch, int regnum,
       return 0;
     }
   else if (reggroup == float_reggroup)
-    return ((regnum >= RISCV_FIRST_FP_REGNUM && regnum <= RISCV_LAST_FP_REGNUM)
-	    || (regnum == RISCV_CSR_FCSR_REGNUM
-		|| regnum == RISCV_CSR_FFLAGS_REGNUM
-	        || regnum == RISCV_CSR_FRM_REGNUM));
+    return (riscv_is_fp_regno_p (regnum)
+	    || regnum == RISCV_CSR_FCSR_REGNUM
+	    || regnum == RISCV_CSR_FFLAGS_REGNUM
+	    || regnum == RISCV_CSR_FRM_REGNUM);
   else if (reggroup == general_reggroup)
     return regnum < RISCV_FIRST_FP_REGNUM;
   else if (reggroup == restore_reggroup || reggroup == save_reggroup)
@@ -2154,7 +2163,9 @@ riscv_push_dummy_call (struct gdbarch *gdbarch,
 	      {
 		gdb_byte tmp [sizeof (ULONGEST)];
 
-		gdb_assert (second_arg_length <= call_info.xlen);
+		gdb_assert ((riscv_is_fp_regno_p (info->argloc[1].loc_data.regno)
+			     && second_arg_length <= call_info.flen)
+			    || second_arg_length <= call_info.xlen);
 		memset (tmp, 0, sizeof (tmp));
 		memcpy (tmp, second_arg_data, second_arg_length);
 		regcache->cooked_write (info->argloc[1].loc_data.regno, tmp);
-- 
2.14.4

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

* [PUSHED] [PATCH 0/2] Small RiscV cleanup / fixes
@ 2018-07-10 11:58 Andrew Burgess
  2018-07-10 11:58 ` [PATCH 1/2] gdb/riscv: Use TYPE_SAFE_NAME Andrew Burgess
  2018-07-10 11:58 ` [PATCH 2/2] gdb/riscv: Fix assertion in inferior call code Andrew Burgess
  0 siblings, 2 replies; 3+ messages in thread
From: Andrew Burgess @ 2018-07-10 11:58 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

A couple of straight forward RiscV patches.

First is just a cleanup in debug printing.

Second addresses an assertion failure when XLEN and FLEN are
different.

--

Andrew Burgess (2):
  gdb/riscv: Use TYPE_SAFE_NAME
  gdb/riscv: Fix assertion in inferior call code

 gdb/ChangeLog    | 12 ++++++++++++
 gdb/riscv-tdep.c | 27 +++++++++++++++++----------
 2 files changed, 29 insertions(+), 10 deletions(-)

-- 
2.14.4

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

end of thread, other threads:[~2018-07-10 11:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-10 11:58 [PUSHED] [PATCH 0/2] Small RiscV cleanup / fixes Andrew Burgess
2018-07-10 11:58 ` [PATCH 1/2] gdb/riscv: Use TYPE_SAFE_NAME Andrew Burgess
2018-07-10 11:58 ` [PATCH 2/2] gdb/riscv: Fix assertion in inferior call code Andrew Burgess

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