66 const DesignFlowManagerConstRef _design_flow_manager,
69 profiling_source_file(
parameters->getOption<
std::string>(OPT_output_temporary_directory) +
"/host_profiling.c")
86 const auto c_backend_factory =
88 relationship.insert(c_backend_factory->CreateCBackendStep(
96 const auto functions =
AppM->CGetCallGraphManager()->GetReachedBodyFunctions();
99 AppM->GetFunctionBehavior(
function)->profiling_information->Clear();
105 std::filesystem::path temporary_path(
parameters->getOption<std::string>(OPT_output_temporary_directory));
107 std::filesystem::path run_name = temporary_path / (
"run.tmp");
115 compiler_wrapper->CreateExecutable(tp_files, run_name.string(),
"");
116 std::string change_directory;
120 change_directory =
"cd \"" +
parameters->getOption<std::string>(OPT_path) +
"\" && ";
122 "---Changing working directory to " +
parameters->getOption<std::string>(OPT_path));
125 for(
const auto& exec_argv : exec_argvs)
129 std::filesystem::remove(profile_data_name);
131 const auto command = change_directory +
"\"" + run_name.string() +
"\" " + exec_argv +
" ";
135 if(errno and not
parameters->getOption<
bool>(OPT_no_return_zero))
141 std::ifstream profilefile(profile_data_name.string().c_str());
142 if(profilefile.is_open())
147 while(!profilefile.eof())
149 getline(profilefile, line);
153 std::vector<std::string> splitted =
SplitString(line,
" ");
155 if(line.find(
"Function") != std::string::npos)
157 const auto function_behavior =
158 AppM->CGetFunctionBehavior(static_cast<unsigned>(std::stoul(splitted[1])));
160 "---Found data of function " +
161 function_behavior->CGetBehavioralHelper()->get_function_name());
162 profiling_information = function_behavior->profiling_information;
163 bb_index_map = function_behavior->CGetBBGraph(
FunctionBehavior::FBB)->CGetBBGraphInfo()->bb_index_map;
167 const auto bb_index =
static_cast<unsigned>(std::stoul(splitted[0]));
168 if(bb_index_map.find(bb_index) != bb_index_map.end())
170 const auto bb_vertex = bb_index_map.find(bb_index)->second;
171 profiling_information->bb_executions[bb_vertex] = std::stoull(splitted[1]);
189 if(
parameters->getOption<
bool>(OPT_print_dot))
191 const auto functions =
AppM->CGetCallGraphManager()->GetReachedBodyFunctions();
#define DEBUG_LEVEL_VERY_PEDANTIC
extremely verbose debugging print is performed.
#define INDENT_DBG_MEX(dbgLevel, curDbgLevel, mex)
We are producing a debug version of the program, so the message is printed;.
Factory class to create c backend.
#define GET_CLASS(obj)
Macro returning the actual type of an object.
Definition of the class representing a generic C application.
const int output_level
The output level.
const std::vector< std::string > SplitString(const std::string &input, const std::string &separators)
Function which splits a string into tokens.
constants used in host profiling library
RelationshipType
The relationship type.
const std::string profiling_source_file
The instrumented source code.
#define INDENT_OUT_MEX(outLevel, curOutLevel, mex)
#define STR_CST_host_profiling_data
The file where profiling data are written by instrumented executable.
Definition of hash function for EdgeDescriptor.
#define OUTPUT_LEVEL_MINIMUM
minimum debugging print is performed.
Simple class used to drive the backend in order to be able to print c source code.
void line(int x1, int y1, int x2, int y2, unsigned int color)
Auxiliary methods for manipulating string.
bool IsError(const int error_value)
Utility include.
const CustomUnorderedSet< std::pair< FrontendFlowStepType, FunctionRelationship > > ComputeFrontendRelationships(const DesignFlowStep::RelationshipType relationship_type) const override
Return the set of analyses in relationship with this design step.
Analysis step performing a dynamic profiling of basic blocks execution.
#define STR_CST_host_profiling_output
The file where output of instrumented executable is saved.
BasicBlocksProfiling(const application_managerRef AppM, const DesignFlowManagerConstRef design_flow_manager, const ParameterConstRef parameters)
Constructor.
Classes to describe design flow graph.
Basic block control flow graph with feedback.
redefinition of set to manage ordered/unordered structures
utility function used to read files.
CompilerWrapper_CompilerTarget
target of the compiler
const Wrefcount< const DesignFlowManager > design_flow_manager
The design flow manager.
const ParameterConstRef parameters
Set of input parameters.
DesignFlowStep_Status
The status of a step.
#define DEBUG_LEVEL_NONE
no debugging print is performed.
int PandaSystem(const ParameterConstRef Param, const std::string &system_command, bool host_exec, const std::string &output, const unsigned int type, const bool background, const size_t timeout)
System call forcing execution with bash.
refcount< T > lock() const
void ComputeRelationships(DesignFlowStepSet &relationship, const DesignFlowStep::RelationshipType relationship_type) override
Compute the relationships of a step with other steps.
const application_managerRef AppM
The application manager.
void ComputeRelationships(DesignFlowStepSet &relationship, const DesignFlowStep::RelationshipType relationship_type) final
Compute the relationships of a step with other steps.
This file collects some hash functors.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
#define THROW_ERROR_CODE(code, str_expr)
helper function used to throw an error with a code error
this class is used to manage the command-line or XML options.
Main class for wrapping the frontend compiler.
int debug_level
The debug level.
CustomUnorderedMap< unsigned int, vertex > bb_index_map
DesignFlowStep_Status Exec() final
Execute this step.
A brief description of the C++ Header File.
void Initialize() final
Initialize the step (i.e., like a constructor, but executed just before exec.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...
Implementation of the wrapper to Gcc for C sources.