public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Send some output to gdb_stderr
@ 2021-12-28 22:15 Tom Tromey
  2021-12-28 22:15 ` [PATCH 1/3] Send jit.c errors " Tom Tromey
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Tom Tromey @ 2021-12-28 22:15 UTC (permalink / raw)
  To: gdb-patches

PR gdb/7233 notes that some gdb output goes to the wrong stream.
While this is a never-ending battle, and so I think the bug can be
closed any time, in the meantime I found a few spots that were easy to
fix up.

This short series redirects some output to gdb_stderr, where
appropriate.

Regression tested on x86-64 Fedora 34.  (Though of course I wouldn't
expect to see any problems due to how the test suite works.)

Tom



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

* [PATCH 1/3] Send jit.c errors to gdb_stderr
  2021-12-28 22:15 [PATCH 0/3] Send some output to gdb_stderr Tom Tromey
@ 2021-12-28 22:15 ` Tom Tromey
  2021-12-28 22:15 ` [PATCH 2/3] Use correct stream for process record output Tom Tromey
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Tom Tromey @ 2021-12-28 22:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

jit.c writes some error messages to gdb_stdout, but using gdb_stderr
is better.  This is part of PR gdb/7233.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7233
---
 gdb/jit.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/gdb/jit.c b/gdb/jit.c
index e190e695aa8..477183f3e4b 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -251,8 +251,8 @@ jit_read_descriptor (gdbarch *gdbarch,
   err = target_read_memory (addr, desc_buf, desc_size);
   if (err)
     {
-      printf_unfiltered (_("Unable to read JIT descriptor from "
-			   "remote memory\n"));
+      fprintf_unfiltered (gdb_stderr, _("Unable to read JIT descriptor from "
+					"remote memory\n"));
       return false;
     }
 
@@ -719,7 +719,8 @@ jit_bfd_try_read_symtab (struct jit_code_entry *code_entry,
       (code_entry->symfile_addr, code_entry->symfile_size, gnutarget));
   if (nbfd == NULL)
     {
-      puts_unfiltered (_("Error opening JITed symbol file, ignoring it.\n"));
+      fputs_unfiltered (_("Error opening JITed symbol file, ignoring it.\n"),
+			gdb_stderr);
       return;
     }
 
@@ -727,7 +728,7 @@ jit_bfd_try_read_symtab (struct jit_code_entry *code_entry,
      We would segfault later without this line.  */
   if (!bfd_check_format (nbfd.get (), bfd_object))
     {
-      printf_unfiltered (_("\
+      fprintf_unfiltered (gdb_stderr, _("\
 JITed symbol file is not an object file, ignoring it.\n"));
       return;
     }
@@ -1138,9 +1139,10 @@ jit_inferior_init (inferior *inf)
       /* Check that the version number agrees with that we support.  */
       if (descriptor.version != 1)
 	{
-	  printf_unfiltered (_("Unsupported JIT protocol version %ld "
-			       "in descriptor (expected 1)\n"),
-			     (long) descriptor.version);
+	  fprintf_unfiltered (gdb_stderr,
+			      _("Unsupported JIT protocol version %ld "
+				"in descriptor (expected 1)\n"),
+			      (long) descriptor.version);
 	  continue;
 	}
 
@@ -1229,9 +1231,10 @@ jit_event_handler (gdbarch *gdbarch, objfile *jiter)
       {
 	objfile *jited = jit_find_objf_with_entry_addr (entry_addr);
 	if (jited == nullptr)
-	  printf_unfiltered (_("Unable to find JITed code "
-			       "entry at address: %s\n"),
-			     paddress (gdbarch, entry_addr));
+	  fprintf_unfiltered (gdb_stderr,
+			      _("Unable to find JITed code "
+				"entry at address: %s\n"),
+			      paddress (gdbarch, entry_addr));
 	else
 	  jited->unlink ();
 
-- 
2.31.1


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

* [PATCH 2/3] Use correct stream for process record output
  2021-12-28 22:15 [PATCH 0/3] Send some output to gdb_stderr Tom Tromey
  2021-12-28 22:15 ` [PATCH 1/3] Send jit.c errors " Tom Tromey
@ 2021-12-28 22:15 ` Tom Tromey
  2021-12-28 22:15 ` [PATCH 3/3] Send arch-utils error messages to gdb_stderr Tom Tromey
  2021-12-29  4:12 ` [PATCH 0/3] Send some output " Joel Brobecker
  3 siblings, 0 replies; 5+ messages in thread
From: Tom Tromey @ 2021-12-28 22:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

The process record code often emits unfiltered output.  In some cases,
this output ought to go to gdb_stderr (but see below).  In other
cases, the output is guarded by a logging variable and so ought to go
to gdb_stdlog.  This patch makes these changes.

Note that in many cases, the output to stderr is followed by a
"return -1", which is how process record indicates an error.  It seems
to me that calling error here would be preferable, because, in many
cases, that's all the caller does when it sees a -1.  However, I
haven't made this change.

This is part of PR gdb/7233.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7233
---
 gdb/aarch64-linux-tdep.c |  7 +++--
 gdb/aarch64-tdep.c       |  9 +++---
 gdb/amd64-linux-tdep.c   |  7 +++--
 gdb/arm-linux-tdep.c     |  7 +++--
 gdb/arm-tdep.c           | 40 +++++++++++++-----------
 gdb/i386-linux-tdep.c    |  7 +++--
 gdb/i386-tdep.c          | 66 ++++++++++++++++++++++++----------------
 gdb/linux-record.c       | 31 +++++++++++--------
 gdb/moxie-tdep.c         |  7 +++--
 gdb/ppc-linux-tdep.c     |  5 +--
 gdb/rs6000-tdep.c        |  2 +-
 gdb/s390-linux-tdep.c    |  7 +++--
 gdb/s390-tdep.c          |  2 +-
 13 files changed, 113 insertions(+), 84 deletions(-)

diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
index 7a9cf0c87e9..2480c037d0b 100644
--- a/gdb/aarch64-linux-tdep.c
+++ b/gdb/aarch64-linux-tdep.c
@@ -1489,9 +1489,10 @@ aarch64_linux_syscall_record (struct regcache *regcache,
 
   if (syscall_gdb < 0)
     {
-      printf_unfiltered (_("Process record and replay target doesn't "
-			   "support syscall number %s\n"),
-			 plongest (svc_number));
+      fprintf_unfiltered (gdb_stderr,
+			  _("Process record and replay target doesn't "
+			    "support syscall number %s\n"),
+			  plongest (svc_number));
       return -1;
     }
 
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index 3287499ab05..1dd5a51624c 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -4657,10 +4657,11 @@ aarch64_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
   ret = aarch64_record_decode_insn_handler (&aarch64_record);
   if (ret == AARCH64_RECORD_UNSUPPORTED)
     {
-      printf_unfiltered (_("Process record does not support instruction "
-			   "0x%0x at address %s.\n"),
-			 aarch64_record.aarch64_insn,
-			 paddress (gdbarch, insn_addr));
+      fprintf_unfiltered (gdb_stderr,
+			  _("Process record does not support instruction "
+			    "0x%0x at address %s.\n"),
+			  aarch64_record.aarch64_insn,
+			  paddress (gdbarch, insn_addr));
       ret = -1;
     }
 
diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
index 3fe3d394932..d9b8b7f3c9f 100644
--- a/gdb/amd64-linux-tdep.c
+++ b/gdb/amd64-linux-tdep.c
@@ -1496,9 +1496,10 @@ amd64_linux_syscall_record_common (struct regcache *regcache,
 
   if (syscall_gdb == gdb_sys_no_syscall)
     {
-      printf_unfiltered (_("Process record and replay target doesn't "
-			   "support syscall number %s\n"), 
-			 pulongest (syscall_native));
+      fprintf_unfiltered (gdb_stderr,
+			  _("Process record and replay target doesn't "
+			    "support syscall number %s\n"), 
+			  pulongest (syscall_native));
       return -1;
     }
   else
diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
index 025ecf0c625..82a1b4ce42e 100644
--- a/gdb/arm-linux-tdep.c
+++ b/gdb/arm-linux-tdep.c
@@ -1650,9 +1650,10 @@ arm_linux_syscall_record (struct regcache *regcache, unsigned long svc_number)
 
   if (syscall_gdb == gdb_sys_no_syscall)
     {
-      printf_unfiltered (_("Process record and replay target doesn't "
-			   "support syscall number %s\n"),
-			   plongest (svc_number));
+      fprintf_unfiltered (gdb_stderr,
+			  _("Process record and replay target doesn't "
+			    "support syscall number %s\n"),
+			  plongest (svc_number));
       return -1;
     }
 
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index e0ef1d2946e..e4af38ce8b4 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -11328,9 +11328,10 @@ arm_record_b_bl (insn_decode_record *arm_insn_r)
 static int
 arm_record_unsupported_insn (insn_decode_record *arm_insn_r)
 {
-  printf_unfiltered (_("Process record does not support instruction "
-		       "0x%0x at address %s.\n"),arm_insn_r->arm_insn,
-		     paddress (arm_insn_r->gdbarch, arm_insn_r->this_addr));
+  fprintf_unfiltered (gdb_stderr,
+		      _("Process record does not support instruction "
+			"0x%0x at address %s.\n"),arm_insn_r->arm_insn,
+		      paddress (arm_insn_r->gdbarch, arm_insn_r->this_addr));
 
   return -1;
 }
@@ -11916,7 +11917,7 @@ arm_record_coproc_data_proc (insn_decode_record *arm_insn_r)
 	}
       else
 	{
-	  printf_unfiltered (_("no syscall record support\n"));
+	  fprintf_unfiltered (gdb_stderr, _("no syscall record support\n"));
 	  return -1;
 	}
     }
@@ -12348,11 +12349,12 @@ thumb_record_misc (insn_decode_record *thumb_insn_r)
 	  record_buf[1] = ARM_LR_REGNUM;
 	  thumb_insn_r->reg_rec_count = 2;
 	  /* We need to save SPSR value, which is not yet done.  */
-	  printf_unfiltered (_("Process record does not support instruction "
-			       "0x%0x at address %s.\n"),
-			     thumb_insn_r->arm_insn,
-			     paddress (thumb_insn_r->gdbarch,
-				       thumb_insn_r->this_addr));
+	  fprintf_unfiltered (gdb_stderr,
+			      _("Process record does not support instruction "
+				"0x%0x at address %s.\n"),
+			      thumb_insn_r->arm_insn,
+			      paddress (thumb_insn_r->gdbarch,
+					thumb_insn_r->this_addr));
 	  return -1;
 
 	case 0xf:
@@ -12440,7 +12442,7 @@ thumb_record_ldm_stm_swi (insn_decode_record *thumb_insn_r)
 	  }
 	else
 	  {
-	    printf_unfiltered (_("no syscall record support\n"));
+	    fprintf_unfiltered (gdb_stderr, _("no syscall record support\n"));
 	    return -1;
 	  }
     }
@@ -13351,10 +13353,11 @@ decode_insn (abstract_memory_reader &reader, insn_decode_record *arm_record,
     {
       if (record_debug)
 	{
-	  printf_unfiltered (_("Process record: error reading memory at "
-			       "addr %s len = %d.\n"),
-			     paddress (arm_record->gdbarch,
-				       arm_record->this_addr), insn_size);
+	  fprintf_unfiltered (gdb_stdlog,
+			      _("Process record: error reading memory at "
+				"addr %s len = %d.\n"),
+			      paddress (arm_record->gdbarch,
+					arm_record->this_addr), insn_size);
 	}
       return -1;
     }
@@ -13619,10 +13622,11 @@ arm_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
     {
       if (record_debug)
 	{
-	  printf_unfiltered (_("Process record: error reading memory at "
-			       "addr %s len = %d.\n"),
-			     paddress (arm_record.gdbarch,
-				       arm_record.this_addr), 2);
+	  fprintf_unfiltered (gdb_stdlog,
+			      _("Process record: error reading memory at "
+				"addr %s len = %d.\n"),
+			      paddress (arm_record.gdbarch,
+					arm_record.this_addr), 2);
 	}
       return -1;
     }
diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c
index 7c6274589c9..e4e0e6cdbbe 100644
--- a/gdb/i386-linux-tdep.c
+++ b/gdb/i386-linux-tdep.c
@@ -466,9 +466,10 @@ i386_linux_intx80_sysenter_syscall_record (struct regcache *regcache)
 
   if (syscall_gdb < 0)
     {
-      printf_unfiltered (_("Process record and replay target doesn't "
-			   "support syscall number %s\n"), 
-			 plongest (syscall_native));
+      fprintf_unfiltered (gdb_stderr,
+			  _("Process record and replay target doesn't "
+			    "support syscall number %s\n"), 
+			  plongest (syscall_native));
       return -1;
     }
 
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 7bb0dd4b739..802205ecf4c 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -6864,8 +6864,9 @@ Do you want to stop the program?"),
 
       /* XXX */
     case 0xcc:    /* int3 */
-      printf_unfiltered (_("Process record does not support instruction "
-			   "int3.\n"));
+      fprintf_unfiltered (gdb_stderr,
+			  _("Process record does not support instruction "
+			    "int3.\n"));
       ir.addr -= 1;
       goto no_support;
       break;
@@ -6881,9 +6882,10 @@ Do you want to stop the program?"),
 	if (interrupt != 0x80
 	    || tdep->i386_intx80_record == NULL)
 	  {
-	    printf_unfiltered (_("Process record does not support "
-				 "instruction int 0x%02x.\n"),
-			       interrupt);
+	    fprintf_unfiltered (gdb_stderr,
+				_("Process record does not support "
+				  "instruction int 0x%02x.\n"),
+				interrupt);
 	    ir.addr -= 2;
 	    goto no_support;
 	  }
@@ -6895,8 +6897,9 @@ Do you want to stop the program?"),
 
       /* XXX */
     case 0xce:    /* into */
-      printf_unfiltered (_("Process record does not support "
-			   "instruction into.\n"));
+      fprintf_unfiltered (gdb_stderr,
+			  _("Process record does not support "
+			    "instruction into.\n"));
       ir.addr -= 1;
       goto no_support;
       break;
@@ -6906,8 +6909,9 @@ Do you want to stop the program?"),
       break;
 
     case 0x62:    /* bound */
-      printf_unfiltered (_("Process record does not support "
-			   "instruction bound.\n"));
+      fprintf_unfiltered (gdb_stderr,
+			  _("Process record does not support "
+			    "instruction bound.\n"));
       ir.addr -= 1;
       goto no_support;
       break;
@@ -6942,15 +6946,17 @@ Do you want to stop the program?"),
       break;
 
     case 0x0f30:    /* wrmsr */
-      printf_unfiltered (_("Process record does not support "
-			   "instruction wrmsr.\n"));
+      fprintf_unfiltered (gdb_stderr,
+			  _("Process record does not support "
+			    "instruction wrmsr.\n"));
       ir.addr -= 2;
       goto no_support;
       break;
 
     case 0x0f32:    /* rdmsr */
-      printf_unfiltered (_("Process record does not support "
-			   "instruction rdmsr.\n"));
+      fprintf_unfiltered (gdb_stderr,
+			  _("Process record does not support "
+			    "instruction rdmsr.\n"));
       ir.addr -= 2;
       goto no_support;
       break;
@@ -6970,8 +6976,9 @@ Do you want to stop the program?"),
 	  }
 	if (tdep->i386_sysenter_record == NULL)
 	  {
-	    printf_unfiltered (_("Process record does not support "
-				 "instruction sysenter.\n"));
+	    fprintf_unfiltered (gdb_stderr,
+				_("Process record does not support "
+				  "instruction sysenter.\n"));
 	    ir.addr -= 2;
 	    goto no_support;
 	  }
@@ -6982,8 +6989,9 @@ Do you want to stop the program?"),
       break;
 
     case 0x0f35:    /* sysexit */
-      printf_unfiltered (_("Process record does not support "
-			   "instruction sysexit.\n"));
+      fprintf_unfiltered (gdb_stderr,
+			  _("Process record does not support "
+			    "instruction sysexit.\n"));
       ir.addr -= 2;
       goto no_support;
       break;
@@ -6993,8 +7001,9 @@ Do you want to stop the program?"),
 	int ret;
 	if (tdep->i386_syscall_record == NULL)
 	  {
-	    printf_unfiltered (_("Process record does not support "
-				 "instruction syscall.\n"));
+	    fprintf_unfiltered (gdb_stderr,
+				_("Process record does not support "
+				  "instruction syscall.\n"));
 	    ir.addr -= 2;
 	    goto no_support;
 	  }
@@ -7005,8 +7014,9 @@ Do you want to stop the program?"),
       break;
 
     case 0x0f07:    /* sysret */
-      printf_unfiltered (_("Process record does not support "
-			   "instruction sysret.\n"));
+      fprintf_unfiltered (gdb_stderr,
+			  _("Process record does not support "
+			    "instruction sysret.\n"));
       ir.addr -= 2;
       goto no_support;
       break;
@@ -7019,8 +7029,9 @@ Do you want to stop the program?"),
       break;
 
     case 0xf4:    /* hlt */
-      printf_unfiltered (_("Process record does not support "
-			   "instruction hlt.\n"));
+      fprintf_unfiltered (gdb_stderr,
+			  _("Process record does not support "
+			    "instruction hlt.\n"));
       ir.addr -= 1;
       goto no_support;
       break;
@@ -8138,10 +8149,11 @@ Do you want to stop the program?"),
   return 0;
 
  no_support:
-  printf_unfiltered (_("Process record does not support instruction 0x%02x "
-		       "at address %s.\n"),
-		     (unsigned int) (opcode),
-		     paddress (gdbarch, ir.orig_addr));
+  fprintf_unfiltered (gdb_stderr,
+		      _("Process record does not support instruction 0x%02x "
+			"at address %s.\n"),
+		      (unsigned int) (opcode),
+		      paddress (gdbarch, ir.orig_addr));
   return -1;
 }
 
diff --git a/gdb/linux-record.c b/gdb/linux-record.c
index 4dfd3cfa599..4be187ce215 100644
--- a/gdb/linux-record.c
+++ b/gdb/linux-record.c
@@ -492,15 +492,17 @@ record_linux_system_call (enum gdb_syscall syscall,
 	}
       else if (tmpulongest == tdep->ioctl_TIOCSERGSTRUCT)
 	{
-	  printf_unfiltered (_("Process record and replay target doesn't "
-			       "support ioctl request TIOCSERGSTRUCT\n"));
+	  fprintf_unfiltered (gdb_stderr,
+			      _("Process record and replay target doesn't "
+				"support ioctl request TIOCSERGSTRUCT\n"));
 	  return 1;
 	}
       else
 	{
-	  printf_unfiltered (_("Process record and replay target doesn't "
-			       "support ioctl request 0x%s.\n"),
-			     OUTPUT_REG (tmpulongest, tdep->arg2));
+	  fprintf_unfiltered (gdb_stderr,
+			      _("Process record and replay target doesn't "
+				"support ioctl request 0x%s.\n"),
+			      OUTPUT_REG (tmpulongest, tdep->arg2));
 	  return 1;
 	}
       break;
@@ -1008,9 +1010,10 @@ Do you want to stop the program?"),
 	  }
 	  break;
 	default:
-	  printf_unfiltered (_("Process record and replay target "
-			       "doesn't support socketcall call 0x%s\n"),
-			     OUTPUT_REG (tmpulongest, tdep->arg1));
+	  fprintf_unfiltered (gdb_stderr,
+			      _("Process record and replay target "
+				"doesn't support socketcall call 0x%s\n"),
+			      OUTPUT_REG (tmpulongest, tdep->arg1));
 	  return -1;
 	  break;
 	}
@@ -1148,9 +1151,10 @@ Do you want to stop the program?"),
 	  break;
 	default:
 	  /* XXX RECORD_SEMCTL still not supported.  */
-	  printf_unfiltered (_("Process record and replay target doesn't "
-			       "support ipc number %s\n"),
-			     pulongest (tmpulongest));
+	  fprintf_unfiltered (gdb_stderr,
+			      _("Process record and replay target doesn't "
+				"support ipc number %s\n"),
+			      pulongest (tmpulongest));
 	  break;
 	}
       break;
@@ -2032,8 +2036,9 @@ Do you want to stop the program?"),
       break;
 
     default:
-      printf_unfiltered (_("Process record and replay target doesn't "
-			   "support syscall number %d\n"), syscall);
+      fprintf_unfiltered (gdb_stderr,
+			  _("Process record and replay target doesn't "
+			    "support syscall number %d\n"), syscall);
       return -1;
       break;
     }
diff --git a/gdb/moxie-tdep.c b/gdb/moxie-tdep.c
index 459bfb8ee5a..949a18d5241 100644
--- a/gdb/moxie-tdep.c
+++ b/gdb/moxie-tdep.c
@@ -279,9 +279,10 @@ moxie_process_readu (CORE_ADDR addr, gdb_byte *buf,
   if (target_read_memory (addr, buf, length))
     {
       if (record_debug)
-	printf_unfiltered (_("Process record: error reading memory at "
-			     "addr 0x%s len = %d.\n"),
-			   paddress (target_gdbarch (), addr), length);
+	fprintf_unfiltered (gdb_stderr,
+			    _("Process record: error reading memory at "
+			      "addr 0x%s len = %d.\n"),
+			    paddress (target_gdbarch (), addr), length);
       return -1;
     }
 
diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index 9e895425497..e5206b59bc3 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -1427,8 +1427,9 @@ ppc_linux_syscall_record (struct regcache *regcache)
 
   if (syscall_gdb < 0)
     {
-      printf_unfiltered (_("Process record and replay target doesn't "
-			   "support syscall number %d\n"), (int) scnum);
+      fprintf_unfiltered (gdb_stderr,
+			  _("Process record and replay target doesn't "
+			    "support syscall number %d\n"), (int) scnum);
       return 0;
     }
 
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
index ce98dc2f884..ad80c695f82 100644
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -5986,7 +5986,7 @@ ppc_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
 	}
       else
 	{
-	  printf_unfiltered (_("no syscall record support\n"));
+	  fprintf_unfiltered (gdb_stderr, _("no syscall record support\n"));
 	  return -1;
 	}
       break;
diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c
index 3fa0b65f0b6..7a43e275d7b 100644
--- a/gdb/s390-linux-tdep.c
+++ b/gdb/s390-linux-tdep.c
@@ -815,9 +815,10 @@ s390_linux_syscall_record (struct regcache *regcache, LONGEST syscall_native)
 
   if (syscall_gdb < 0)
     {
-      printf_unfiltered (_("Process record and replay target doesn't "
-			   "support syscall number %s\n"),
-			 plongest (syscall_native));
+      fprintf_unfiltered (gdb_stderr,
+			  _("Process record and replay target doesn't "
+			    "support syscall number %s\n"),
+			  plongest (syscall_native));
       return -1;
     }
 
diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c
index abbb094b11e..2637d713816 100644
--- a/gdb/s390-tdep.c
+++ b/gdb/s390-tdep.c
@@ -3103,7 +3103,7 @@ s390_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
 	}
       else
 	{
-	  printf_unfiltered (_("no syscall record support\n"));
+	  fprintf_unfiltered (gdb_stderr, _("no syscall record support\n"));
 	  return -1;
 	}
       break;
-- 
2.31.1


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

* [PATCH 3/3] Send arch-utils error messages to gdb_stderr
  2021-12-28 22:15 [PATCH 0/3] Send some output to gdb_stderr Tom Tromey
  2021-12-28 22:15 ` [PATCH 1/3] Send jit.c errors " Tom Tromey
  2021-12-28 22:15 ` [PATCH 2/3] Use correct stream for process record output Tom Tromey
@ 2021-12-28 22:15 ` Tom Tromey
  2021-12-29  4:12 ` [PATCH 0/3] Send some output " Joel Brobecker
  3 siblings, 0 replies; 5+ messages in thread
From: Tom Tromey @ 2021-12-28 22:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes arch-utils.c to send some error messages to gdb_stderr.
This is part of PR gdb/7233.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7233
---
 gdb/arch-utils.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index 4442ec9b82f..fb92b993c78 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -405,7 +405,8 @@ set_endian (const char *ignore_args, int from_tty, struct cmd_list_element *c)
     {
       info.byte_order = BFD_ENDIAN_LITTLE;
       if (! gdbarch_update_p (info))
-	printf_unfiltered (_("Little endian target not supported by GDB\n"));
+	fprintf_unfiltered (gdb_stderr,
+			    _("Little endian target not supported by GDB\n"));
       else
 	target_byte_order_user = BFD_ENDIAN_LITTLE;
     }
@@ -413,7 +414,8 @@ set_endian (const char *ignore_args, int from_tty, struct cmd_list_element *c)
     {
       info.byte_order = BFD_ENDIAN_BIG;
       if (! gdbarch_update_p (info))
-	printf_unfiltered (_("Big endian target not supported by GDB\n"));
+	fprintf_unfiltered (gdb_stderr,
+			    _("Big endian target not supported by GDB\n"));
       else
 	target_byte_order_user = BFD_ENDIAN_BIG;
     }
@@ -567,8 +569,9 @@ set_architecture (const char *ignore_args,
       if (gdbarch_update_p (info))
 	target_architecture_user = info.bfd_arch_info;
       else
-	printf_unfiltered (_("Architecture `%s' not recognized.\n"),
-			   set_architecture_string);
+	fprintf_unfiltered (gdb_stderr,
+			    _("Architecture `%s' not recognized.\n"),
+			    set_architecture_string);
     }
   show_architecture (gdb_stdout, from_tty, NULL, NULL);
 }
-- 
2.31.1


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

* Re: [PATCH 0/3] Send some output to gdb_stderr
  2021-12-28 22:15 [PATCH 0/3] Send some output to gdb_stderr Tom Tromey
                   ` (2 preceding siblings ...)
  2021-12-28 22:15 ` [PATCH 3/3] Send arch-utils error messages to gdb_stderr Tom Tromey
@ 2021-12-29  4:12 ` Joel Brobecker
  3 siblings, 0 replies; 5+ messages in thread
From: Joel Brobecker @ 2021-12-29  4:12 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches, Joel Brobecker

Hi Tom,

> PR gdb/7233 notes that some gdb output goes to the wrong stream.
> While this is a never-ending battle, and so I think the bug can be
> closed any time, in the meantime I found a few spots that were easy to
> fix up.
> 
> This short series redirects some output to gdb_stderr, where
> appropriate.
> 
> Regression tested on x86-64 Fedora 34.  (Though of course I wouldn't
> expect to see any problems due to how the test suite works.)

Thanks again for the patch series. I went through it, and it all
looked good to me.

-- 
Joel

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

end of thread, other threads:[~2021-12-29  4:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-28 22:15 [PATCH 0/3] Send some output to gdb_stderr Tom Tromey
2021-12-28 22:15 ` [PATCH 1/3] Send jit.c errors " Tom Tromey
2021-12-28 22:15 ` [PATCH 2/3] Use correct stream for process record output Tom Tromey
2021-12-28 22:15 ` [PATCH 3/3] Send arch-utils error messages to gdb_stderr Tom Tromey
2021-12-29  4:12 ` [PATCH 0/3] Send some output " Joel Brobecker

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