From f1059ee0ae26356f86e1d212118de3a9d1ac32f0 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 28 Sep 2012 14:46:48 -0700 Subject: [PATCH] stapdyn: Use program_invocation_short_name 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 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/stapdyn/stapdyn.cxx b/stapdyn/stapdyn.cxx index bc388cac8..9b13bd3b0 100644 --- a/stapdyn/stapdyn.cxx +++ b/stapdyn/stapdyn.cxx @@ -5,9 +5,9 @@ extern "C" { #include +#include #include #include -#include #include #include #include @@ -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; } -- 2.43.5