]> sourceware.org Git - systemtap.git/commitdiff
stapdyn: Use program_invocation_short_name
authorJosh Stone <jistone@redhat.com>
Fri, 28 Sep 2012 21:46:48 +0000 (14:46 -0700)
committerJosh Stone <jistone@redhat.com>
Fri, 28 Sep 2012 21:48:45 +0000 (14:48 -0700)
I had previously added a global "program" with basename(argv[0]), but
GNU already provides program_invocation_short_name with the same.

stapdyn/stapdyn.cxx

index bc388cac88001c34e08c2437e9c3bf7a7be4f95c..9b13bd3b03cdca2a55d7fde71e8dfda7611318af 100644 (file)
@@ -5,9 +5,9 @@
 
 extern "C" {
 #include <dlfcn.h>
+#include <errno.h>
 #include <fcntl.h>
 #include <getopt.h>
-#include <libgen.h>
 #include <limits.h>
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -37,8 +37,6 @@ extern "C" {
 
 using namespace std;
 
-static const char* program = "stapdyn";
-
 
 struct stapdyn_uprobe_probe {
     uint64_t index, offset, semaphore;
@@ -196,7 +194,8 @@ find_uprobes(void* module)
     }
   catch (runtime_error& e)
     {
-      clog << program << ": dlsym " << e.what() << endl;
+      clog << program_invocation_short_name
+           << ": dlsym " << e.what() << endl;
       return targets;
     }
 
@@ -240,14 +239,16 @@ run_simple_module(void* module)
     }
   catch (runtime_error& e)
     {
-      clog << program << ": dlsym " << e.what() << endl;
+      clog << program_invocation_short_name
+           << ": dlsym " << e.what() << endl;
       return 1;
     }
 
   int rc = session_init();
   if (rc)
     {
-      clog << program << ": stp_dyninst_session_init returned " << rc << endl;
+      clog << program_invocation_short_name
+           << ": stp_dyninst_session_init returned " << rc << endl;
       return 1;
     }
 
@@ -301,13 +302,12 @@ main(int argc, char * const argv[])
   if (!module)
     usage (1);
 
-  program = basename(argv[0]);
-
   (void)dlerror(); // clear previous errors
   void* dlmodule = dlopen(module, RTLD_NOW);
   if (!dlmodule)
     {
-      clog << program << ": dlopen " << dlerror() << endl;
+      clog << program_invocation_short_name
+           << ": dlopen " << dlerror() << endl;
       return 1;
     }
 
This page took 0.028735 seconds and 5 git commands to generate.