public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 00/11] fix build warnings for rx simulator
@ 2021-02-01 11:44 Andrew Burgess
  2021-02-01 11:44 ` [PATCH 01/11] sim/rx: define sim_memory_map Andrew Burgess
                   ` (11 more replies)
  0 siblings, 12 replies; 20+ messages in thread
From: Andrew Burgess @ 2021-02-01 11:44 UTC (permalink / raw)
  To: gdb-patches

Resolve all the build warnings for the rx simulator and enable build
warnings by default.

---

Andrew Burgess (11):
  sim/rx: define sim_memory_map
  sim/rx: fix an issue where we try to modify a const string
  sim/rx: fill in missing 'void' for empty argument lists
  sim/rx: mark some functions as static
  sim/rx: delete an unused function
  sim/rx: use puts instead of printf in a few places
  sim/rx: move some variable declarations to the start of the block
  sim/rx: use PRIx64 in printf format string
  sim/rx: add some missing includes
  sim/rx: avoid pointer arithmetic on void * pointers
  sim/rx: enable build with warnings

 sim/rx/ChangeLog    | 65 +++++++++++++++++++++++++++++++++++++++++++++
 sim/rx/configure    | 17 +++++++++---
 sim/rx/configure.ac |  2 +-
 sim/rx/cpu.h        |  2 +-
 sim/rx/err.c        | 11 +-------
 sim/rx/fpu.c        |  2 +-
 sim/rx/gdb-if.c     | 14 +++++++---
 sim/rx/load.c       |  3 +--
 sim/rx/mem.c        | 18 ++++++++-----
 sim/rx/mem.h        |  4 +--
 sim/rx/reg.c        | 14 +++++-----
 sim/rx/rx.c         |  6 ++---
 sim/rx/syscalls.c   |  7 ++---
 sim/rx/trace.c      |  4 ++-
 14 files changed, 125 insertions(+), 44 deletions(-)

-- 
2.25.4


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

* [PATCH 01/11] sim/rx: define sim_memory_map
  2021-02-01 11:44 [PATCH 00/11] fix build warnings for rx simulator Andrew Burgess
@ 2021-02-01 11:44 ` Andrew Burgess
  2021-02-01 14:46   ` Mike Frysinger
  2021-02-01 11:44 ` [PATCH 02/11] sim/rx: fix an issue where we try to modify a const string Andrew Burgess
                   ` (10 subsequent siblings)
  11 siblings, 1 reply; 20+ messages in thread
From: Andrew Burgess @ 2021-02-01 11:44 UTC (permalink / raw)
  To: gdb-patches

The rx simulator doesn't build due to sim_memory_map not being
defined.  Define it now to return NULL, this can be extended later to
return an actual memory map if anyone wants this functionality.

sim/rx/ChangeLog:

	* gdb-if.c (sim_memory_map): New function.
---
 sim/rx/ChangeLog | 4 ++++
 sim/rx/gdb-if.c  | 8 ++++++++
 2 files changed, 12 insertions(+)

diff --git a/sim/rx/gdb-if.c b/sim/rx/gdb-if.c
index 63705f9bb0e..6f8bfbd1c50 100644
--- a/sim/rx/gdb-if.c
+++ b/sim/rx/gdb-if.c
@@ -854,3 +854,11 @@ sim_complete_command (SIM_DESC sd, const char *text, const char *word)
 {
   return NULL;
 }
+
+/* Stub this out for now.  */
+
+char *
+sim_memory_map (SIM_DESC sd)
+{
+  return NULL;
+}
-- 
2.25.4


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

* [PATCH 02/11] sim/rx: fix an issue where we try to modify a const string
  2021-02-01 11:44 [PATCH 00/11] fix build warnings for rx simulator Andrew Burgess
  2021-02-01 11:44 ` [PATCH 01/11] sim/rx: define sim_memory_map Andrew Burgess
@ 2021-02-01 11:44 ` Andrew Burgess
  2021-02-01 11:44 ` [PATCH 03/11] sim/rx: fill in missing 'void' for empty argument lists Andrew Burgess
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: Andrew Burgess @ 2021-02-01 11:44 UTC (permalink / raw)
  To: gdb-patches

While experimenting with switching on warnings for the rx simulator I
discovered this bug.  In sim_do_command we get passed a 'const char *'
argument.  We create a copy of this string to work with locally, but
then while processing this we accidentally switch back to reference
the original string.

sim/rx/ChangeLog:

	* gdb-if.c (sim_do_command): Work with a copy of the command.
---
 sim/rx/ChangeLog | 4 ++++
 sim/rx/gdb-if.c  | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/sim/rx/gdb-if.c b/sim/rx/gdb-if.c
index 6f8bfbd1c50..55eb13d12ef 100644
--- a/sim/rx/gdb-if.c
+++ b/sim/rx/gdb-if.c
@@ -804,13 +804,13 @@ sim_do_command (SIM_DESC sd, const char *cmd)
     p++;
 
   /* Find the extent of the command word.  */
-  for (p = cmd; *p; p++)
+  for (; *p != '\0'; p++)
     if (isspace (*p))
       break;
 
   /* Null-terminate the command word, and record the start of any
      further arguments.  */
-  if (*p)
+  if (*p != '\0')
     {
       *p = '\0';
       args = p + 1;
-- 
2.25.4


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

* [PATCH 03/11] sim/rx: fill in missing 'void' for empty argument lists
  2021-02-01 11:44 [PATCH 00/11] fix build warnings for rx simulator Andrew Burgess
  2021-02-01 11:44 ` [PATCH 01/11] sim/rx: define sim_memory_map Andrew Burgess
  2021-02-01 11:44 ` [PATCH 02/11] sim/rx: fix an issue where we try to modify a const string Andrew Burgess
@ 2021-02-01 11:44 ` Andrew Burgess
  2021-02-01 11:44 ` [PATCH 04/11] sim/rx: mark some functions as static Andrew Burgess
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: Andrew Burgess @ 2021-02-01 11:44 UTC (permalink / raw)
  To: gdb-patches

Ensure we have 'void' inside empty argument lists.  This was causing
several warnings for the rx simulator.

sim/rx/ChangeLog:

	* cpu.h (trace_register_changes): Add void parameter type.
	* err.c (ee_overrides): Likewise.
	* mem.c (mem_usage_stats): Likewise.
	(e): Likewise.
	* reg.c (stack_heap_stats): Likewise.
	* rx.c (pop): Likewise.
	(poppc): Likewise.
	(decode_opcode): Likewise.
	* syscalls.c (arg): Likewise.
---
 sim/rx/ChangeLog  | 12 ++++++++++++
 sim/rx/cpu.h      |  2 +-
 sim/rx/err.c      |  2 +-
 sim/rx/mem.c      |  4 ++--
 sim/rx/reg.c      |  2 +-
 sim/rx/rx.c       |  6 +++---
 sim/rx/syscalls.c |  2 +-
 7 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/sim/rx/cpu.h b/sim/rx/cpu.h
index 700f2de3c2b..ef4503cc720 100644
--- a/sim/rx/cpu.h
+++ b/sim/rx/cpu.h
@@ -240,6 +240,6 @@ extern void reset_pipeline_stats (void);
 extern void halt_pipeline_stats (void);
 extern void pipeline_stats (void);
 
-extern void trace_register_changes ();
+extern void trace_register_changes (void);
 extern void generate_access_exception (void);
 extern jmp_buf decode_jmp_buf;
diff --git a/sim/rx/err.c b/sim/rx/err.c
index 3fc64d1d685..ce1cd571f59 100644
--- a/sim/rx/err.c
+++ b/sim/rx/err.c
@@ -28,7 +28,7 @@ static unsigned char ee_actions[SIM_ERR_NUM_ERRORS];
 static enum execution_error last_error;
 
 static void
-ee_overrides ()
+ee_overrides (void)
 {
   /* GCC may initialize a bitfield by reading the uninitialized byte,
      masking in the bitfield, and writing the byte back out.  */
diff --git a/sim/rx/mem.c b/sim/rx/mem.c
index 40ab0bd5e6a..7fbf08e6415 100644
--- a/sim/rx/mem.c
+++ b/sim/rx/mem.c
@@ -161,7 +161,7 @@ mcs (int isput, int bytes)
 }
 
 void
-mem_usage_stats ()
+mem_usage_stats (void)
 {
   int i, j;
   int rstart = 0;
@@ -244,7 +244,7 @@ s (int address, char *dir)
 
 #define S(d) if (trace) s(address, d)
 static void
-e ()
+e (void)
 {
   if (!trace)
     return;
diff --git a/sim/rx/reg.c b/sim/rx/reg.c
index c300f3ba6b2..00796a0c99a 100644
--- a/sim/rx/reg.c
+++ b/sim/rx/reg.c
@@ -149,7 +149,7 @@ get_reg64 (int id)
 static int highest_sp = 0, lowest_sp = 0xffffff;
 
 void
-stack_heap_stats ()
+stack_heap_stats (void)
 {
   if (heapbottom < heaptop)
     printf ("heap:  %08x - %08x (%d bytes)\n", heapbottom, heaptop,
diff --git a/sim/rx/rx.c b/sim/rx/rx.c
index beed6a14c81..e3737a56e98 100644
--- a/sim/rx/rx.c
+++ b/sim/rx/rx.c
@@ -682,7 +682,7 @@ pushpc(int val)
 }
 
 static int
-pop()
+pop (void)
 {
   int rv;
   int rsp = get_reg (sp);
@@ -693,7 +693,7 @@ pop()
 }
 
 static int
-poppc()
+poppc (void)
 {
   int rv;
   int rsp = get_reg (sp);
@@ -931,7 +931,7 @@ op_is_memory (const RX_Opcode_Decoded *rd, int i)
 #define DO_RETURN(x) { longjmp (decode_jmp_buf, x); }
 
 int
-decode_opcode ()
+decode_opcode (void)
 {
   unsigned int uma=0, umb=0;
   int ma=0, mb=0;
diff --git a/sim/rx/syscalls.c b/sim/rx/syscalls.c
index 1a6f65fad16..2f89da17330 100644
--- a/sim/rx/syscalls.c
+++ b/sim/rx/syscalls.c
@@ -69,7 +69,7 @@ get_callbacks (void)
 int argp, stackp;
 
 static int
-arg ()
+arg (void)
 {
   int rv = 0;
   argp++;
-- 
2.25.4


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

* [PATCH 04/11] sim/rx: mark some functions as static
  2021-02-01 11:44 [PATCH 00/11] fix build warnings for rx simulator Andrew Burgess
                   ` (2 preceding siblings ...)
  2021-02-01 11:44 ` [PATCH 03/11] sim/rx: fill in missing 'void' for empty argument lists Andrew Burgess
@ 2021-02-01 11:44 ` Andrew Burgess
  2021-02-01 11:44 ` [PATCH 05/11] sim/rx: delete an unused function Andrew Burgess
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: Andrew Burgess @ 2021-02-01 11:44 UTC (permalink / raw)
  To: gdb-patches

Some functions that should be marked static.

sim/rx/ChangeLog:

	* fpu.c (check_exceptions): Make static.
	* gdb-if.c (handle_step): Likewise.
	* mem.c (mem_put_byte): Likewise.
---
 sim/rx/ChangeLog | 6 ++++++
 sim/rx/fpu.c     | 2 +-
 sim/rx/gdb-if.c  | 2 +-
 sim/rx/mem.c     | 2 +-
 4 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/sim/rx/fpu.c b/sim/rx/fpu.c
index 00c3ab73f0b..f9e9007192a 100644
--- a/sim/rx/fpu.c
+++ b/sim/rx/fpu.c
@@ -354,7 +354,7 @@ static const char *ex_names[] = {
 /* This checks for all exceptional cases (not all FP exceptions) and
    returns TRUE if it is providing the result in *c.  If it returns
    FALSE, the caller should do the "normal" operation.  */
-int
+static int
 check_exceptions (FP_Parts *a, FP_Parts *b, fp_t *c,
 		  FP_ExceptionCases ex_tab[5][5], 
 		  FP_ExceptionCases *case_ret)
diff --git a/sim/rx/gdb-if.c b/sim/rx/gdb-if.c
index 55eb13d12ef..3d052e62baa 100644
--- a/sim/rx/gdb-if.c
+++ b/sim/rx/gdb-if.c
@@ -688,7 +688,7 @@ rx_signal_to_gdb_signal (int rx)
 
 /* Take a step return code RC and set up the variables consulted by
    sim_stop_reason appropriately.  */
-void
+static void
 handle_step (int rc)
 {
   if (execution_error_get_last_error () != SIM_ERR_NONE)
diff --git a/sim/rx/mem.c b/sim/rx/mem.c
index 7fbf08e6415..fe8e08d1460 100644
--- a/sim/rx/mem.c
+++ b/sim/rx/mem.c
@@ -262,7 +262,7 @@ mtypec (int address)
 
 #define E() if (trace) e()
 
-void
+static void
 mem_put_byte (unsigned int address, unsigned char value)
 {
   unsigned char *m;
-- 
2.25.4


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

* [PATCH 05/11] sim/rx: delete an unused function
  2021-02-01 11:44 [PATCH 00/11] fix build warnings for rx simulator Andrew Burgess
                   ` (3 preceding siblings ...)
  2021-02-01 11:44 ` [PATCH 04/11] sim/rx: mark some functions as static Andrew Burgess
@ 2021-02-01 11:44 ` Andrew Burgess
  2021-02-01 11:44 ` [PATCH 06/11] sim/rx: use puts instead of printf in a few places Andrew Burgess
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: Andrew Burgess @ 2021-02-01 11:44 UTC (permalink / raw)
  To: gdb-patches

This function is not used.

sim/rx/ChangeLog:

	* err.c (execution_error_exit_all): Delete.
---
 sim/rx/ChangeLog | 4 ++++
 sim/rx/err.c     | 9 ---------
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/sim/rx/err.c b/sim/rx/err.c
index ce1cd571f59..e72b6d3ddee 100644
--- a/sim/rx/err.c
+++ b/sim/rx/err.c
@@ -60,15 +60,6 @@ execution_error_init_debugger (void)
   ee_overrides ();
 }
 
-void
-execution_error_exit_all (void)
-{
-  int i;
-
-  for (i = 0; i < SIM_ERR_NUM_ERRORS; i++)
-    ee_actions[i] = SIM_ERRACTION_EXIT;
-}
-
 void
 execution_error_warn_all (void)
 {
-- 
2.25.4


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

* [PATCH 06/11] sim/rx: use puts instead of printf in a few places
  2021-02-01 11:44 [PATCH 00/11] fix build warnings for rx simulator Andrew Burgess
                   ` (4 preceding siblings ...)
  2021-02-01 11:44 ` [PATCH 05/11] sim/rx: delete an unused function Andrew Burgess
@ 2021-02-01 11:44 ` Andrew Burgess
  2021-02-01 14:49   ` Mike Frysinger
  2021-02-01 11:44 ` [PATCH 07/11] sim/rx: move some variable declarations to the start of the block Andrew Burgess
                   ` (5 subsequent siblings)
  11 siblings, 1 reply; 20+ messages in thread
From: Andrew Burgess @ 2021-02-01 11:44 UTC (permalink / raw)
  To: gdb-patches

Calling printf with the format being a non constant string results in
a GCC warning.  Use puts instead in a few places.

sim/rx/ChangeLog:

	* reg.c (fpsw2str): Replace use of printf with puts.
	(trace_register_changes): Likewise.
---
 sim/rx/ChangeLog | 5 +++++
 sim/rx/reg.c     | 8 ++++----
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/sim/rx/reg.c b/sim/rx/reg.c
index 00796a0c99a..f1bdd4c9841 100644
--- a/sim/rx/reg.c
+++ b/sim/rx/reg.c
@@ -509,7 +509,7 @@ fpsw2str(int rpsw)
 #define TRC(f,n) \
   if (oldregs.f != regs.f) \
     { \
-      if (tag) { printf (tag); tag = 0; } \
+      if (tag) { puts (tag); tag = 0; } \
       printf("  %s %08x:%08x", n, \
 	     (unsigned int)oldregs.f, \
 	     (unsigned int)regs.f); \
@@ -531,7 +531,7 @@ trace_register_changes (void)
   TRC (r_isp, "isp");
   if (oldregs.r_psw != regs.r_psw)
     {
-      if (tag) { printf (tag); tag = 0; }
+      if (tag) { puts (tag); tag = 0; }
       printf("  psw %s:", psw2str(oldregs.r_psw));
       printf("%s", psw2str(regs.r_psw));
       oldregs.r_psw = regs.r_psw;
@@ -539,7 +539,7 @@ trace_register_changes (void)
 
   if (oldregs.r_fpsw != regs.r_fpsw)
     {
-      if (tag) { printf (tag); tag = 0; }
+      if (tag) { puts (tag); tag = 0; }
       printf("  fpsw %s:", fpsw2str(oldregs.r_fpsw));
       printf("%s", fpsw2str(regs.r_fpsw));
       oldregs.r_fpsw = regs.r_fpsw;
@@ -547,9 +547,9 @@ trace_register_changes (void)
 
   if (oldregs.r_acc != regs.r_acc)
     {
-      if (tag) { printf (tag); tag = 0; }
       printf("  acc %016llx:", oldregs.r_acc);
       printf("%016llx", regs.r_acc);
+      if (tag) { puts (tag); tag = 0; }
       oldregs.r_acc = regs.r_acc;
     }
 
-- 
2.25.4


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

* [PATCH 07/11] sim/rx: move some variable declarations to the start of the block
  2021-02-01 11:44 [PATCH 00/11] fix build warnings for rx simulator Andrew Burgess
                   ` (5 preceding siblings ...)
  2021-02-01 11:44 ` [PATCH 06/11] sim/rx: use puts instead of printf in a few places Andrew Burgess
@ 2021-02-01 11:44 ` Andrew Burgess
  2021-02-01 11:44 ` [PATCH 08/11] sim/rx: use PRIx64 in printf format string Andrew Burgess
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: Andrew Burgess @ 2021-02-01 11:44 UTC (permalink / raw)
  To: gdb-patches

For sim code variables still need to be declared at the start of the
enclosing block.  This silences a few GCC warnings.

sim/rx/ChangeLog:

	* syscalls.c (rx_syscall): Move declaration of some variables to
	the start of the enclosing block.
	* trace.c (load_file_and_line): Likewise.
---
 sim/rx/ChangeLog  | 6 ++++++
 sim/rx/syscalls.c | 5 +++--
 sim/rx/trace.c    | 3 ++-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/sim/rx/syscalls.c b/sim/rx/syscalls.c
index 2f89da17330..22778b3df49 100644
--- a/sim/rx/syscalls.c
+++ b/sim/rx/syscalls.c
@@ -160,6 +160,7 @@ rx_syscall (int id)
 
     case SYS_open:
       {
+	int oflags, cflags;
 	int path = arg ();
 	/* The open function is defined as taking a variable number of arguments
 	   because the third parameter to it is optional:
@@ -167,8 +168,8 @@ rx_syscall (int id)
 	   Hence the oflags and cflags arguments will be on the stack and we need
 	   to skip the (empty) argument registers r3 and r4.  */
 	argp = 4;
-	int oflags = arg ();
-	int cflags = arg ();
+	oflags = arg ();
+	cflags = arg ();
 
 	read_target (buf, path, 256, 1);
 	if (trace)
diff --git a/sim/rx/trace.c b/sim/rx/trace.c
index 6f9294ad75a..9d9f2dfd98d 100644
--- a/sim/rx/trace.c
+++ b/sim/rx/trace.c
@@ -139,6 +139,7 @@ load_file_and_line (const char *filename, int lineno)
       break;
   if (!f)
     {
+      FILE *file;
       int i;
       struct stat s;
       const char *found_filename, *slash;
@@ -159,7 +160,7 @@ load_file_and_line (const char *filename, int lineno)
       files = f;
       f->filename = strdup (filename);
       f->data = (char *) malloc (s.st_size + 2);
-      FILE *file = fopen (found_filename, "rb");
+      file = fopen (found_filename, "rb");
       fread (f->data, 1, s.st_size, file);
       f->data[s.st_size] = 0;
       fclose (file);
-- 
2.25.4


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

* [PATCH 08/11] sim/rx: use PRIx64 in printf format string
  2021-02-01 11:44 [PATCH 00/11] fix build warnings for rx simulator Andrew Burgess
                   ` (6 preceding siblings ...)
  2021-02-01 11:44 ` [PATCH 07/11] sim/rx: move some variable declarations to the start of the block Andrew Burgess
@ 2021-02-01 11:44 ` Andrew Burgess
  2021-02-01 11:44 ` [PATCH 09/11] sim/rx: add some missing includes Andrew Burgess
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: Andrew Burgess @ 2021-02-01 11:44 UTC (permalink / raw)
  To: gdb-patches

Silence a GCC compiler warning by using PRIx64 in printf format string
instead of hard coded "llx".

sim/rx/ChangeLog:

	* reg.c (trace_register_changes): Use PRIx64 in printf format
	string.
---
 sim/rx/ChangeLog | 5 +++++
 sim/rx/reg.c     | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/sim/rx/reg.c b/sim/rx/reg.c
index f1bdd4c9841..b84507a7c9f 100644
--- a/sim/rx/reg.c
+++ b/sim/rx/reg.c
@@ -547,9 +547,9 @@ trace_register_changes (void)
 
   if (oldregs.r_acc != regs.r_acc)
     {
-      printf("  acc %016llx:", oldregs.r_acc);
-      printf("%016llx", regs.r_acc);
       if (tag) { puts (tag); tag = 0; }
+      printf("  acc %016" PRIx64 ":", oldregs.r_acc);
+      printf("%016" PRIx64, regs.r_acc);
       oldregs.r_acc = regs.r_acc;
     }
 
-- 
2.25.4


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

* [PATCH 09/11] sim/rx: add some missing includes
  2021-02-01 11:44 [PATCH 00/11] fix build warnings for rx simulator Andrew Burgess
                   ` (7 preceding siblings ...)
  2021-02-01 11:44 ` [PATCH 08/11] sim/rx: use PRIx64 in printf format string Andrew Burgess
@ 2021-02-01 11:44 ` Andrew Burgess
  2021-02-01 11:44 ` [PATCH 10/11] sim/rx: avoid pointer arithmetic on void * pointers Andrew Burgess
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: Andrew Burgess @ 2021-02-01 11:44 UTC (permalink / raw)
  To: gdb-patches

In load.c there's some GCC warnings about undefined
functions (bfd_get_elf_phdr_upper_bound and bfd_get_elf_phdrs).  To
get the declarations of these functions include 'elf-bfd.h'.  This
headers also pulls in other elf related headers, like 'elf/internal.h'
and 'elf/common.h', so these no longer need to be explicitly included
from load.c.

In trace.c and include for trace.h is missing, again this results in
GCC warnings for missing function declarations.

sim/rx/ChangeLog:

	* load.c: Replace 'elf/internal.h' and 'elf/common.h' includes
	with 'elf-bfd.h' include.
	* trace.c: Add 'trace.h' include.
---
 sim/rx/ChangeLog | 6 ++++++
 sim/rx/load.c    | 3 +--
 sim/rx/trace.c   | 1 +
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/sim/rx/load.c b/sim/rx/load.c
index d74f4ff3872..a8a473346c6 100644
--- a/sim/rx/load.c
+++ b/sim/rx/load.c
@@ -28,8 +28,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "cpu.h"
 #include "mem.h"
 #include "load.h"
-#include "elf/internal.h"
-#include "elf/common.h"
+#include "elf-bfd.h"
 
 /* Helper function for invoking a GDB-specified printf.  */
 static void
diff --git a/sim/rx/trace.c b/sim/rx/trace.c
index 9d9f2dfd98d..e5db49b5ca9 100644
--- a/sim/rx/trace.c
+++ b/sim/rx/trace.c
@@ -34,6 +34,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "cpu.h"
 #include "mem.h"
 #include "load.h"
+#include "trace.h"
 
 static int
 sim_dis_read (bfd_vma memaddr, bfd_byte * ptr, unsigned int length,
-- 
2.25.4


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

* [PATCH 10/11] sim/rx: avoid pointer arithmetic on void * pointers
  2021-02-01 11:44 [PATCH 00/11] fix build warnings for rx simulator Andrew Burgess
                   ` (8 preceding siblings ...)
  2021-02-01 11:44 ` [PATCH 09/11] sim/rx: add some missing includes Andrew Burgess
@ 2021-02-01 11:44 ` Andrew Burgess
  2021-02-01 11:44 ` [PATCH 11/11] sim/rx: enable build with warnings Andrew Burgess
  2021-02-02  4:37 ` [PATCH 00/11] fix build warnings for rx simulator Mike Frysinger
  11 siblings, 0 replies; 20+ messages in thread
From: Andrew Burgess @ 2021-02-01 11:44 UTC (permalink / raw)
  To: gdb-patches

Pointer arithmetic on void * pointers results in a GCC warning.  Avoid
the warning by casting the pointer to its actual type earlier in the
function.

sim/rx/ChangeLog:

	* mem.c (mem_put_blk): Rename parameter, add cast from parameter
	type to local type.  Remove cast later in the function.
	(mem_get_blk): Likewise.
	* mem.h (mem_put_blk): Rename parameter to match definition.
	(mem_get_blk): Likewise.
---
 sim/rx/ChangeLog |  8 ++++++++
 sim/rx/mem.c     | 12 ++++++++----
 sim/rx/mem.h     |  4 ++--
 3 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/sim/rx/mem.c b/sim/rx/mem.c
index fe8e08d1460..7e62bfb8953 100644
--- a/sim/rx/mem.c
+++ b/sim/rx/mem.c
@@ -434,13 +434,15 @@ mem_put_si (int address, unsigned long value)
 }
 
 void
-mem_put_blk (int address, void *bufptr, int nbytes)
+mem_put_blk (int address, void *bufptr_void, int nbytes)
 {
+  unsigned char *bufptr = (unsigned char *) bufptr_void;
+
   S ("<=");
   if (enable_counting)
     mem_counters[1][1] += nbytes;
   while (nbytes--)
-    mem_put_byte (address++, *(unsigned char *) bufptr++);
+    mem_put_byte (address++, *bufptr++);
   E ();
 }
 
@@ -567,13 +569,15 @@ mem_get_si (int address)
 }
 
 void
-mem_get_blk (int address, void *bufptr, int nbytes)
+mem_get_blk (int address, void *bufptr_void, int nbytes)
 {
+  char *bufptr = (char *) bufptr_void;
+
   S ("=>");
   if (enable_counting)
     mem_counters[0][1] += nbytes;
   while (nbytes--)
-    *(char *) bufptr++ = mem_get_byte (address++);
+    *bufptr++ = mem_get_byte (address++);
   E ();
 }
 
diff --git a/sim/rx/mem.h b/sim/rx/mem.h
index 21080f6e6e3..a4c7455a20d 100644
--- a/sim/rx/mem.h
+++ b/sim/rx/mem.h
@@ -53,7 +53,7 @@ void mem_put_hi (int address, unsigned short value);
 void mem_put_psi (int address, unsigned long value);
 void mem_put_si (int address, unsigned long value);
 
-void mem_put_blk (int address, void *bufptr, int nbytes);
+void mem_put_blk (int address, void *bufptr_void, int nbytes);
 
 unsigned char mem_get_pc (int address);
 
@@ -62,7 +62,7 @@ unsigned short mem_get_hi (int address);
 unsigned long mem_get_psi (int address);
 unsigned long mem_get_si (int address);
 
-void mem_get_blk (int address, void *bufptr, int nbytes);
+void mem_get_blk (int address, void *bufptr_void, int nbytes);
 
 int sign_ext (int v, int bits);
 
-- 
2.25.4


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

* [PATCH 11/11] sim/rx: enable build with warnings
  2021-02-01 11:44 [PATCH 00/11] fix build warnings for rx simulator Andrew Burgess
                   ` (9 preceding siblings ...)
  2021-02-01 11:44 ` [PATCH 10/11] sim/rx: avoid pointer arithmetic on void * pointers Andrew Burgess
@ 2021-02-01 11:44 ` Andrew Burgess
  2021-02-01 14:50   ` Mike Frysinger
  2021-02-02  4:37 ` [PATCH 00/11] fix build warnings for rx simulator Mike Frysinger
  11 siblings, 1 reply; 20+ messages in thread
From: Andrew Burgess @ 2021-02-01 11:44 UTC (permalink / raw)
  To: gdb-patches

The rx simulator now has no build warnings, so enable build with
warnings by default.

sim/rx/ChangeLog:

	* configure: Regenerate.
	* configure.ac (SIM_AC_OPTION_WARNINGS): Pass yes.
---
 sim/rx/ChangeLog    |  5 +++++
 sim/rx/configure    | 17 ++++++++++++++---
 sim/rx/configure.ac |  2 +-
 3 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/sim/rx/configure b/sim/rx/configure
index 3969c670380..8501f84e727 100755
--- a/sim/rx/configure
+++ b/sim/rx/configure
@@ -6903,7 +6903,15 @@ fi
 test -z "$AR" && AR=ar
 if test -n "$plugin_option"; then
   if $AR --help 2>&1 | grep -q "\--plugin"; then
-    AR="$AR $plugin_option"
+    touch conftest.c
+    $AR $plugin_option rc conftest.a conftest.c
+    if test "$?" != 0; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Failed: $AR $plugin_option rc" >&5
+$as_echo "$as_me: WARNING: Failed: $AR $plugin_option rc" >&2;}
+    else
+      AR="$AR $plugin_option"
+    fi
+    rm -f conftest.*
   fi
 fi
 test -z "$AR_FLAGS" && AR_FLAGS=cru
@@ -12927,7 +12935,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12930 "configure"
+#line 12938 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -13033,7 +13041,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 13036 "configure"
+#line 13044 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -13600,6 +13608,9 @@ if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
 fi
 
 WERROR_CFLAGS=""
+  if test "${ERROR_ON_WARNING}" = yes ; then
+    WERROR_CFLAGS="-Werror"
+  fi
 
 build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
 -Wpointer-sign \
diff --git a/sim/rx/configure.ac b/sim/rx/configure.ac
index 6c14434f4af..b81c322d441 100644
--- a/sim/rx/configure.ac
+++ b/sim/rx/configure.ac
@@ -22,7 +22,7 @@ AC_INIT(Makefile.in)
 sinclude(../common/acinclude.m4)
 
 SIM_AC_COMMON
-SIM_AC_OPTION_WARNINGS(no)
+SIM_AC_OPTION_WARNINGS(yes)
 
 AC_CHECK_HEADERS(getopt.h)
 
-- 
2.25.4


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

* Re: [PATCH 01/11] sim/rx: define sim_memory_map
  2021-02-01 11:44 ` [PATCH 01/11] sim/rx: define sim_memory_map Andrew Burgess
@ 2021-02-01 14:46   ` Mike Frysinger
  2021-02-08 11:01     ` Andrew Burgess
  0 siblings, 1 reply; 20+ messages in thread
From: Mike Frysinger @ 2021-02-01 14:46 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: gdb-patches

On 01 Feb 2021 11:44, Andrew Burgess wrote:
> The rx simulator doesn't build due to sim_memory_map not being
> defined.  Define it now to return NULL, this can be extended later to
> return an actual memory map if anyone wants this functionality.

i build every sim port, and rx was/is building fine for me.  nothing in
the sim refers to the sim_memory_map, so it failing to build is a bit
surprising.  do you mean gdb is failing to link instead ?  i don't always
try to build those for ports as not all have gdb ports.
-mike

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

* Re: [PATCH 06/11] sim/rx: use puts instead of printf in a few places
  2021-02-01 11:44 ` [PATCH 06/11] sim/rx: use puts instead of printf in a few places Andrew Burgess
@ 2021-02-01 14:49   ` Mike Frysinger
  2021-02-08 10:58     ` Andrew Burgess
  0 siblings, 1 reply; 20+ messages in thread
From: Mike Frysinger @ 2021-02-01 14:49 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: gdb-patches

On 01 Feb 2021 11:44, Andrew Burgess wrote:
> Calling printf with the format being a non constant string results in
> a GCC warning.  Use puts instead in a few places.

puts() outputs the string with a trailing newline.
doesn't seem equiv in this code ?

i change to printf ("%s", ...) to avoid these warnings.
-mike

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

* Re: [PATCH 11/11] sim/rx: enable build with warnings
  2021-02-01 11:44 ` [PATCH 11/11] sim/rx: enable build with warnings Andrew Burgess
@ 2021-02-01 14:50   ` Mike Frysinger
  2021-02-02  4:53     ` [PATCH] sim: erc32/m32c/rl78: add sim_memory_map stub for gdb Mike Frysinger
  2021-02-08 10:57     ` [PATCH 11/11] sim/rx: enable build with warnings Andrew Burgess
  0 siblings, 2 replies; 20+ messages in thread
From: Mike Frysinger @ 2021-02-01 14:50 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: gdb-patches

On 01 Feb 2021 11:44, Andrew Burgess wrote:
> The rx simulator now has no build warnings, so enable build with
> warnings by default.
> 
> --- a/sim/rx/configure.ac
> +++ b/sim/rx/configure.ac
> @@ -22,7 +22,7 @@ AC_INIT(Makefile.in)
>  sinclude(../common/acinclude.m4)
>  
>  SIM_AC_COMMON
> -SIM_AC_OPTION_WARNINGS(no)
> +SIM_AC_OPTION_WARNINGS(yes)

i would just delete the call while you're here.  SIM_AC_OUTPUT will
call the func with (yes) as the arg for you.
-mike

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

* Re: [PATCH 00/11] fix build warnings for rx simulator
  2021-02-01 11:44 [PATCH 00/11] fix build warnings for rx simulator Andrew Burgess
                   ` (10 preceding siblings ...)
  2021-02-01 11:44 ` [PATCH 11/11] sim/rx: enable build with warnings Andrew Burgess
@ 2021-02-02  4:37 ` Mike Frysinger
  11 siblings, 0 replies; 20+ messages in thread
From: Mike Frysinger @ 2021-02-02  4:37 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: gdb-patches

On 01 Feb 2021 11:44, Andrew Burgess wrote:
> Resolve all the build warnings for the rx simulator and enable build
> warnings by default.

all the ones i didn't comment on already look good!
-mike

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

* [PATCH] sim: erc32/m32c/rl78: add sim_memory_map stub for gdb
  2021-02-01 14:50   ` Mike Frysinger
@ 2021-02-02  4:53     ` Mike Frysinger
  2021-02-08 10:57     ` [PATCH 11/11] sim/rx: enable build with warnings Andrew Burgess
  1 sibling, 0 replies; 20+ messages in thread
From: Mike Frysinger @ 2021-02-02  4:53 UTC (permalink / raw)
  To: gdb-patches

These ports don't use the common sim core, so they weren't providing
a sim_memory_map for gdb, so they failed to link with the new memory
map logic added for the sim.  Add stubs to fix.

erc32/
	* interf.c (sim_memory_map): Define.

m32c/
	* gdb-if.c (sim_memory_map): Define.

rl78/
	* gdb-if.c (sim_memory_map): Define.
---
 sim/erc32/interf.c | 6 ++++++
 sim/m32c/gdb-if.c  | 6 ++++++
 sim/rl78/gdb-if.c  | 6 ++++++
 3 files changed, 18 insertions(+)

diff --git a/sim/erc32/interf.c b/sim/erc32/interf.c
index 5dd464b0ce76..ca2e9faea217 100644
--- a/sim/erc32/interf.c
+++ b/sim/erc32/interf.c
@@ -465,6 +465,12 @@ sim_complete_command (SIM_DESC sd, const char *text, const char *word)
   return NULL;
 }
 
+char *
+sim_memory_map (SIM_DESC sd)
+{
+  return NULL;
+}
+
 #if 0 /* FIXME: These shouldn't exist.  */
 
 int
diff --git a/sim/m32c/gdb-if.c b/sim/m32c/gdb-if.c
index 5ada0b0bc17e..92e447f17faa 100644
--- a/sim/m32c/gdb-if.c
+++ b/sim/m32c/gdb-if.c
@@ -707,6 +707,12 @@ sim_complete_command (SIM_DESC sd, const char *text, const char *word)
   return NULL;
 }
 
+char *
+sim_memory_map (SIM_DESC sd)
+{
+  return NULL;
+}
+
 void
 sim_info (SIM_DESC sd, int verbose)
 {
diff --git a/sim/rl78/gdb-if.c b/sim/rl78/gdb-if.c
index 320db34f436a..56717917e552 100644
--- a/sim/rl78/gdb-if.c
+++ b/sim/rl78/gdb-if.c
@@ -603,3 +603,9 @@ sim_complete_command (SIM_DESC sd, const char *text, const char *word)
 {
     return NULL;
 }
+
+char *
+sim_memory_map (SIM_DESC sd)
+{
+  return NULL;
+}
-- 
2.30.0


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

* Re: [PATCH 11/11] sim/rx: enable build with warnings
  2021-02-01 14:50   ` Mike Frysinger
  2021-02-02  4:53     ` [PATCH] sim: erc32/m32c/rl78: add sim_memory_map stub for gdb Mike Frysinger
@ 2021-02-08 10:57     ` Andrew Burgess
  1 sibling, 0 replies; 20+ messages in thread
From: Andrew Burgess @ 2021-02-08 10:57 UTC (permalink / raw)
  To: gdb-patches

* Mike Frysinger <vapier@gentoo.org> [2021-02-01 09:50:55 -0500]:

> On 01 Feb 2021 11:44, Andrew Burgess wrote:
> > The rx simulator now has no build warnings, so enable build with
> > warnings by default.
> > 
> > --- a/sim/rx/configure.ac
> > +++ b/sim/rx/configure.ac
> > @@ -22,7 +22,7 @@ AC_INIT(Makefile.in)
> >  sinclude(../common/acinclude.m4)
> >  
> >  SIM_AC_COMMON
> > -SIM_AC_OPTION_WARNINGS(no)
> > +SIM_AC_OPTION_WARNINGS(yes)
> 
> i would just delete the call while you're here.  SIM_AC_OUTPUT will
> call the func with (yes) as the arg for you.

Thanks, I made this change.

Andrew

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

* Re: [PATCH 06/11] sim/rx: use puts instead of printf in a few places
  2021-02-01 14:49   ` Mike Frysinger
@ 2021-02-08 10:58     ` Andrew Burgess
  0 siblings, 0 replies; 20+ messages in thread
From: Andrew Burgess @ 2021-02-08 10:58 UTC (permalink / raw)
  To: gdb-patches

* Mike Frysinger <vapier@gentoo.org> [2021-02-01 09:49:00 -0500]:

> On 01 Feb 2021 11:44, Andrew Burgess wrote:
> > Calling printf with the format being a non constant string results in
> > a GCC warning.  Use puts instead in a few places.
> 
> puts() outputs the string with a trailing newline.
> doesn't seem equiv in this code ?
> 
> i change to printf ("%s", ...) to avoid these warnings.

Good point, I think I got confused with fputs :(  I made the change
back to printf inline with your suggestion.

Thanks,
Andrew

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

* Re: [PATCH 01/11] sim/rx: define sim_memory_map
  2021-02-01 14:46   ` Mike Frysinger
@ 2021-02-08 11:01     ` Andrew Burgess
  0 siblings, 0 replies; 20+ messages in thread
From: Andrew Burgess @ 2021-02-08 11:01 UTC (permalink / raw)
  To: gdb-patches

* Mike Frysinger <vapier@gentoo.org> [2021-02-01 09:46:44 -0500]:

> On 01 Feb 2021 11:44, Andrew Burgess wrote:
> > The rx simulator doesn't build due to sim_memory_map not being
> > defined.  Define it now to return NULL, this can be extended later to
> > return an actual memory map if anyone wants this functionality.
> 
> i build every sim port, and rx was/is building fine for me.  nothing in
> the sim refers to the sim_memory_map, so it failing to build is a bit
> surprising.  do you mean gdb is failing to link instead ?  i don't always
> try to build those for ports as not all have gdb ports.

You are correct of course.

I updated the wording of the commit message more inline with the patch
you submitted here:

   https://sourceware.org/pipermail/gdb-patches/2021-February/175689.html

Thanks,
Andrew

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

end of thread, other threads:[~2021-02-08 11:01 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-01 11:44 [PATCH 00/11] fix build warnings for rx simulator Andrew Burgess
2021-02-01 11:44 ` [PATCH 01/11] sim/rx: define sim_memory_map Andrew Burgess
2021-02-01 14:46   ` Mike Frysinger
2021-02-08 11:01     ` Andrew Burgess
2021-02-01 11:44 ` [PATCH 02/11] sim/rx: fix an issue where we try to modify a const string Andrew Burgess
2021-02-01 11:44 ` [PATCH 03/11] sim/rx: fill in missing 'void' for empty argument lists Andrew Burgess
2021-02-01 11:44 ` [PATCH 04/11] sim/rx: mark some functions as static Andrew Burgess
2021-02-01 11:44 ` [PATCH 05/11] sim/rx: delete an unused function Andrew Burgess
2021-02-01 11:44 ` [PATCH 06/11] sim/rx: use puts instead of printf in a few places Andrew Burgess
2021-02-01 14:49   ` Mike Frysinger
2021-02-08 10:58     ` Andrew Burgess
2021-02-01 11:44 ` [PATCH 07/11] sim/rx: move some variable declarations to the start of the block Andrew Burgess
2021-02-01 11:44 ` [PATCH 08/11] sim/rx: use PRIx64 in printf format string Andrew Burgess
2021-02-01 11:44 ` [PATCH 09/11] sim/rx: add some missing includes Andrew Burgess
2021-02-01 11:44 ` [PATCH 10/11] sim/rx: avoid pointer arithmetic on void * pointers Andrew Burgess
2021-02-01 11:44 ` [PATCH 11/11] sim/rx: enable build with warnings Andrew Burgess
2021-02-01 14:50   ` Mike Frysinger
2021-02-02  4:53     ` [PATCH] sim: erc32/m32c/rl78: add sim_memory_map stub for gdb Mike Frysinger
2021-02-08 10:57     ` [PATCH 11/11] sim/rx: enable build with warnings Andrew Burgess
2021-02-02  4:37 ` [PATCH 00/11] fix build warnings for rx simulator Mike Frysinger

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