]> sourceware.org Git - systemtap.git/commitdiff
stap-client: diagnostics
authorFrank Ch. Eigler <fche@elastic.org>
Tue, 6 Jul 2010 19:07:37 +0000 (15:07 -0400)
committerFrank Ch. Eigler <fche@elastic.org>
Tue, 6 Jul 2010 19:10:23 +0000 (15:10 -0400)
* csclient.cxx (compile_server_client::find_and_connect_to_server):
  Save vital stats of winning server for printing ...
  (compile_server_client::passes_0_4): ... here.
  (flush_to_stream): Use char-by-char copying.  Avoid accidentally
  closing cerr/cout.
* session.h: Add winning_server field.

csclient.cxx
session.h

index 8db504174ddbb929bcb819b9e56992458e9ad4d4..bf2b196f237d467adc7b00c70fe9a7700a796791 100644 (file)
@@ -116,7 +116,7 @@ compile_server_client::passes_0_4 ()
   // syntax errors, if any, are already printed
   if (s.verbose)
     {
-      clog << "Compilation using a server completed "
+      clog << "Passes: via server " << s.winning_server << " "
            << getmemusage()
            << TIMESPRINT
            << endl;
@@ -402,7 +402,14 @@ compile_server_client::find_and_connect_to_server ()
              ++servers;
              rc = compile_using_server (default_servers[i]);
              if (rc == 0)
-               return rc; // success!
+                {
+                  s.winning_server =
+                    default_servers[i].host_name + string(" [") +
+                    default_servers[i].ip_address + string(":") +
+                    lex_cast(default_servers[i].port) + string("]");
+                  return rc; // success!
+                }
+
            }
          continue;
        }
@@ -669,7 +676,7 @@ compile_server_client::read_from_file (const string &fname, int &data)
       goto error;
     }
 
-  f.close ();
+  // NB: not necessary to f.close ();
   return 0; // Success
 
  error:
@@ -703,7 +710,7 @@ compile_server_client::write_to_file (const string &fname, const string &data)
       goto error;
     }
 
-  f.close ();
+  // NB: not necessary to f.close ();
   return 0; // Success
 
  error:
@@ -729,16 +736,20 @@ compile_server_client::flush_to_stream (const string &fname, ostream &o)
     }
 
   // Stream the data
-  errno = 0;
-  o << f.rdbuf ();
-  if (f.fail ())
+
+  // NB: o << f.rdbuf() misbehaves for some reason, appearing to close o,
+  // which is unfortunate if o == cerr or cout.
+  while (1)
     {
-      cerr << "Error reading file '" << fname << "': ";
-      goto error;
+      errno = 0;
+      int c = f.get();
+      if (f.eof ()) return 0; // normal exit
+      if (! f.good()) break;
+      o.put(c);
+      if (! o.good()) break;
     }
 
-  f.close ();
-  return 0; // Success
+  // NB: not necessary to f.close ();
 
  error:
   if (errno)
index aaaaf13517c4ea51a4b72521f4dab20a84553b10..ebb0bf0c79e9c6be7d5111b46a87492a7232fc25 100644 (file)
--- a/session.h
+++ b/session.h
@@ -154,10 +154,11 @@ struct systemtap_session
   std::vector<std::string> server_status_strings;
   std::vector<std::string> specified_servers;
   std::vector<std::string> server_args;
+  std::string winning_server;
 
+  // XXX: why?
   std::string host_name;
   std::string domain_name;
-
   std::string &get_host_name ();
   std::string &get_domain_name ();
   void get_host_and_domain_name ();
This page took 0.032932 seconds and 5 git commands to generate.