Use correct stream for process record output
authorTom Tromey <tom@tromey.com>
Sun, 26 Dec 2021 20:41:36 +0000 (13:41 -0700)
committerTom Tromey <tom@tromey.com>
Wed, 29 Dec 2021 17:40:10 +0000 (10:40 -0700)
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

13 files changed:
gdb/aarch64-linux-tdep.c
gdb/aarch64-tdep.c
gdb/amd64-linux-tdep.c
gdb/arm-linux-tdep.c
gdb/arm-tdep.c
gdb/i386-linux-tdep.c
gdb/i386-tdep.c
gdb/linux-record.c
gdb/moxie-tdep.c
gdb/ppc-linux-tdep.c
gdb/rs6000-tdep.c
gdb/s390-linux-tdep.c
gdb/s390-tdep.c

index 7a9cf0c87e9c0bff96d5408569a70a8696e3fb9f..2480c037d0b6123ca9589e3d77c7b8b22e09c6d3 100644 (file)
@@ -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;
     }
 
index 3287499ab05944984eb63a1549978226b782a79d..1dd5a51624ccbbeccc46357766837ae6d90837f4 100644 (file)
@@ -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;
     }
 
index 3fe3d3949328b8d94d189ed552644eae0c796db3..d9b8b7f3c9f7642d4be3a3ce5dcea9bb0d7001c6 100644 (file)
@@ -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
index 025ecf0c625fffc1367de0f9c2ffae36b4c43767..82a1b4ce42ebded1f2e318bdb445bccd47dc7034 100644 (file)
@@ -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;
     }
 
index e0ef1d2946e248598776e8390c7d9ed67b11aac7..e4af38ce8b429ea5149de3fee00628be1bef5109 100644 (file)
@@ -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;
     }
index 7c6274589c9b444bb49b69d19231ee4b6bd2339f..e4e0e6cdbbedded814509d8ca9946d019b3ccad5 100644 (file)
@@ -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;
     }
 
index 7bb0dd4b7395d96d484773c01df1b97fdd7e7328..802205ecf4c8ced3617dc72a9cd765394fa6c9b6 100644 (file)
@@ -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 @@ reswitch_prefix_add:
   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;
 }
 
index 4dfd3cfa599cf02544a8617800b947010681d99a..4be187ce21591392810641cbb18f394616f41673 100644 (file)
@@ -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;
     }
index 459bfb8ee5a80d55d4fc7d1483032a459422e54a..949a18d5241a25cdfc2088b38435f45d3e8b857a 100644 (file)
@@ -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;
     }
 
index 9e8954254974602f7105abc394d5f7a9214e3d59..e5206b59bc35980d18cb6fd45ac8c92846b4546d 100644 (file)
@@ -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;
     }
 
index ce98dc2f88438eb76df8ec2d95986754b1716c12..ad80c695f826a509673f2d44a700ee980d2e5dd7 100644 (file)
@@ -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;
index 3fa0b65f0b6d57d11e051fd2544742c6141d6e0e..7a43e275d7ba79f824ddc56f900b5d17b2755c3f 100644 (file)
@@ -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;
     }
 
index abbb094b11e9b4f49b1e360686d71684340c20a1..2637d713816440fcbc05434d40e077bcc4da96eb 100644 (file)
@@ -3103,7 +3103,7 @@ ex:
        }
       else
        {
-         printf_unfiltered (_("no syscall record support\n"));
+         fprintf_unfiltered (gdb_stderr, _("no syscall record support\n"));
          return -1;
        }
       break;