compute-hops: detail fixes and optional procps dep

Cleanups, warning fix, optional procps dep, --help correction.

Change-Id: Iba719493e4a8ec37acb7336a39172b3cdefbdc99
This commit is contained in:
Horst Schirmeier
2016-04-01 09:14:42 +02:00
parent b5aaddcb8f
commit 6509d50ec1
3 changed files with 18 additions and 6 deletions

View File

@ -9,5 +9,6 @@ if(NOT CONFIG_INJECTIONPOINT_HOPS)
endif()
add_executable(compute-hops main.cc ${SRCS})
target_link_libraries(compute-hops ${PROTOBUF_LIBRARY} fail-util fail-comm procps)
# add procps for built-in memory-usage measurements:
target_link_libraries(compute-hops ${PROTOBUF_LIBRARY} fail-util fail-comm)
install(TARGETS compute-hops RUNTIME DESTINATION bin)

View File

@ -17,7 +17,11 @@
#include "comm/InjectionPointHopsMessage.pb.h"
//#define MEASURE_MEM_USAGE
#ifdef MEASURE_MEM_USAGE
#include <proc/readproc.h>
#endif
using std::hex;
using std::dec;
@ -87,16 +91,16 @@ ResultCollector::addResult(std::vector<result_tuple >& res, unsigned int costs)
InjectionPointMessage_Hops *hop = hc.add_hops();
hop->set_address(it_hop->first.first);
enum InjectionPointMessage_Hops_AccessType at;
InjectionPointMessage::Hops::AccessType at;
switch (it_hop->first.second) {
case ACCESS_NONE:
at = InjectionPointMessage_Hops_AccessType_EXECUTE;
at = InjectionPointMessage::Hops::EXECUTE;
break;
case ACCESS_READ:
at = InjectionPointMessage_Hops_AccessType_READ;
at = InjectionPointMessage::Hops::READ;
break;
case ACCESS_WRITE:
at = InjectionPointMessage_Hops_AccessType_WRITE;
at = InjectionPointMessage::Hops::WRITE;
break;
case ACCESS_READORWRITE:
LOG << "ReadOrWrite memory access event not yet"
@ -106,6 +110,9 @@ ResultCollector::addResult(std::vector<result_tuple >& res, unsigned int costs)
case ACCESS_CHECKPOINT:
LOG << "Checkpoint not allowed after beginning of hop chain" << std::endl;
exit(-1);
default:
LOG << "Unknown memory-access event" << std::endl;
exit(-1);
}
hop->set_accesstype(at);
}
@ -153,9 +160,13 @@ ResultCollector::stopTimer()
void
ResultCollector::setMaxMemUsage()
{
#ifdef MEASURE_MEM_USAGE
struct proc_t usage;
look_up_our_self(&usage);
m_mem_usage = usage.vsize;
#else
m_mem_usage = 0;
#endif
}
void

View File

@ -45,7 +45,7 @@ int main(int argc, char *argv[])
CommandLine::option_handle ALGORITHM =
cmd.addOption("a", "algorithm", Arg::Required,
"-a,--algorithm \tHop algorithm (\"simple\"/\"smart\", default: \"none\")");
"-a,--algorithm \tHop algorithm (\"simple\"/\"smart\", default: \"smart\")");
CommandLine::option_handle OUTPUT_MODE =
cmd.addOption("m", "output-mode", Arg::Required,