Skip to content

Commit

Permalink
Adding command line capture to option output.
Browse files Browse the repository at this point in the history
  • Loading branch information
khuck committed Feb 4, 2019
1 parent 39df146 commit 9e4cc1c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/apex/apex_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
#include <fstream>
#include <string>
#include <vector>
#include <memory>
#include "utils.hpp"
#include "proc_read.h"

namespace apex
{
Expand Down Expand Up @@ -136,6 +138,10 @@ namespace apex
std::cout << #name << " : " << options.member_variable() << std::endl;
FOREACH_APEX_STRING_OPTION(apex_macro)
#undef apex_macro
std::unique_ptr<std::string> tmpstr = proc_data_reader::get_command_line();
if (tmpstr.length() > 0) {
std::cout << tmpstr << std::endl;
}
return;
}
}
Expand Down
15 changes: 15 additions & 0 deletions src/apex/proc_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,21 @@ double msr_current_power_high(void) {
}
#endif

std::unique_ptr<std::string> proc_data_reader::get_command_line(void) {
std::string line;
std::fstream myfile ("/proc/self/cmdline");
std::stringstream ss;
if (myfile.is_open())
{
while ( getline (myfile,line) )
{
ss << line << '\n';
}
myfile.close();
} else {
// it wasn't there, so return nothing.
}
return std::move(ss.str());
}

#endif // APEX_HAVE_PROC
2 changes: 2 additions & 0 deletions src/apex/proc_read.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <atomic>
#include <thread>
#include <string>
#include <memory>
#include "pthread_wrapper.hpp"
#include "apex_options.hpp"

Expand Down Expand Up @@ -59,6 +60,7 @@ class proc_data_reader {
stop_reading();
delete worker_thread;
}
static std::unique_ptr<std::string> get_command_line(void);
};

class ProcData {
Expand Down

0 comments on commit 9e4cc1c

Please sign in to comment.