Revision: 18913
Author:   [email protected]
Date:     Wed Jan 29 15:00:37 2014 UTC
Log:      Consistenly use stderr for printing simulator and debug messages

stdout is buffered, so if we crash, we don't see the last messages

LOG=n
BUG=none
[email protected]

Review URL: https://codereview.chromium.org/132233055
http://code.google.com/p/v8/source/detail?r=18913

Modified:
 /branches/experimental/a64/src/a64/debugger-a64.h
 /branches/experimental/a64/src/a64/instrument-a64.cc
 /branches/experimental/a64/src/a64/macro-assembler-a64.h
 /branches/experimental/a64/src/a64/simulator-a64.cc
 /branches/experimental/a64/src/a64/simulator-a64.h

=======================================
--- /branches/experimental/a64/src/a64/debugger-a64.h Wed Jan 22 12:46:44 2014 UTC +++ /branches/experimental/a64/src/a64/debugger-a64.h Wed Jan 29 15:00:37 2014 UTC
@@ -41,7 +41,7 @@

 class Debugger : public Simulator {
  public:
-  Debugger(Decoder* decoder, FILE* stream = stdout)
+  Debugger(Decoder* decoder, FILE* stream = stderr)
     : Simulator(decoder, NULL, stream) {}

   // Functions overloading.
=======================================
--- /branches/experimental/a64/src/a64/instrument-a64.cc Wed Jan 22 12:46:44 2014 UTC +++ /branches/experimental/a64/src/a64/instrument-a64.cc Wed Jan 29 15:00:37 2014 UTC
@@ -118,15 +118,15 @@


 Instrument::Instrument(const char* datafile, uint64_t sample_period)
-    : output_stream_(stdout), sample_period_(sample_period) {
+    : output_stream_(stderr), sample_period_(sample_period) {

// Set up the output stream. If datafile is non-NULL, use that file. If it
-  // can't be opened, or datafile is NULL, use stdout.
+  // can't be opened, or datafile is NULL, use stderr.
   if (datafile != NULL) {
     output_stream_ = fopen(datafile, "w");
     if (output_stream_ == NULL) {
-      printf("Can't open output file %s. Using stdout.\n", datafile);
-      output_stream_ = stdout;
+ fprintf(stderr, "Can't open output file %s. Using stderr.\n", datafile);
+      output_stream_ = stderr;
     }
   }

@@ -157,7 +157,7 @@
     delete *it;
   }

-  if (output_stream_ != stdout) {
+  if (output_stream_ != stderr) {
     fclose(output_stream_);
   }
 }
=======================================
--- /branches/experimental/a64/src/a64/macro-assembler-a64.h Tue Jan 28 17:32:54 2014 UTC +++ /branches/experimental/a64/src/a64/macro-assembler-a64.h Wed Jan 29 15:00:37 2014 UTC
@@ -1727,7 +1727,7 @@
   void Check(Condition cond, const char* msg);
   void CheckRegisterIsClear(Register reg, const char* msg);

-  // Print a message to stdout and abort execution.
+  // Print a message to stderr and abort execution.
   void Abort(const char* msg);

   // Conditionally load the cached Array transitioned map of type
=======================================
--- /branches/experimental/a64/src/a64/simulator-a64.cc Wed Jan 29 14:57:39 2014 UTC +++ /branches/experimental/a64/src/a64/simulator-a64.cc Wed Jan 29 15:00:37 2014 UTC
@@ -945,15 +945,15 @@
// Visitors---------------------------------------------------------------------

 void Simulator::VisitUnimplemented(Instruction* instr) {
-  printf("Unimplemented instruction at %p: 0x%08" PRIx32 "\n",
-         reinterpret_cast<void*>(instr), instr->InstructionBits());
+  fprintf(stream_, "Unimplemented instruction at %p: 0x%08" PRIx32 "\n",
+          reinterpret_cast<void*>(instr), instr->InstructionBits());
   UNIMPLEMENTED();
 }


 void Simulator::VisitUnallocated(Instruction* instr) {
-  printf("Unallocated instruction at %p: 0x%08" PRIx32 "\n",
-         reinterpret_cast<void*>(instr), instr->InstructionBits());
+  fprintf(stream_, "Unallocated instruction at %p: 0x%08" PRIx32 "\n",
+          reinterpret_cast<void*>(instr), instr->InstructionBits());
   UNIMPLEMENTED();
 }

@@ -1238,11 +1238,13 @@
   uint64_t stack_limit = reinterpret_cast<uint64_t>(stack_limit_);
   uint64_t stack_address = sp();
if ((access_address >= stack_limit) && (access_address < stack_address)) {
-    printf("ACCESS BELOW STACK POINTER:\n");
-    printf("  sp is here:          0x%016" PRIx64 "\n", stack_address);
-    printf("  access was here:     0x%016" PRIx64 "\n", access_address);
-    printf("  stack limit is here: 0x%016" PRIx64 "\n", stack_limit);
-    printf("\n");
+    fprintf(stream_, "ACCESS BELOW STACK POINTER:\n");
+    fprintf(stream_, "  sp is here:          0x%016" PRIx64 "\n",
+            stack_address);
+    fprintf(stream_, "  access was here:     0x%016" PRIx64 "\n",
+            access_address);
+ fprintf(stream_, " stack limit is here: 0x%016" PRIx64 "\n", stack_limit);
+    fprintf(stream_, "\n");
     ABORT();
   }

@@ -3378,20 +3380,20 @@
         // Pass all of the relevant PCS registers onto printf. It doesn't
         // matter if we pass too many as the extra ones won't be read.
         int result;
-        fputs(clr_printf, stdout);
+        fputs(clr_printf, stream_);
         if (type == CPURegister::kRegister) {
-          result = printf(format,
-                          xreg(1), xreg(2), xreg(3), xreg(4),
-                          xreg(5), xreg(6), xreg(7));
+          result = fprintf(stream_, format,
+                           xreg(1), xreg(2), xreg(3), xreg(4),
+                           xreg(5), xreg(6), xreg(7));
         } else if (type == CPURegister::kFPRegister) {
-          result = printf(format,
-                          dreg(0), dreg(1), dreg(2), dreg(3),
-                          dreg(4), dreg(5), dreg(6), dreg(7));
+          result = fprintf(stream_, format,
+                           dreg(0), dreg(1), dreg(2), dreg(3),
+                           dreg(4), dreg(5), dreg(6), dreg(7));
         } else {
           ASSERT(type == CPURegister::kNoRegister);
-          result = printf("%s", format);
+          result = fprintf(stream_, "%s", format);
         }
-        fputs(clr_normal, stdout);
+        fputs(clr_normal, stream_);
         set_xreg(0, result);

// TODO(jbramley): Consider clobbering all caller-saved registers here.
=======================================
--- /branches/experimental/a64/src/a64/simulator-a64.h Mon Jan 27 10:54:11 2014 UTC +++ /branches/experimental/a64/src/a64/simulator-a64.h Wed Jan 29 15:00:37 2014 UTC
@@ -194,7 +194,7 @@
  public:
   explicit Simulator(Decoder* decoder,
                      Isolate* isolate = NULL,
-                     FILE* stream = stdout);
+                     FILE* stream = stderr);
   ~Simulator();

   // System functions.

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to