Commit e5e23d92 authored by Julien Balette-Pape's avatar Julien Balette-Pape

Continue DotModificator

parent 388a1251
......@@ -6,13 +6,13 @@
namespace lrusecurity
{
void DotModificator::modify(otawa::CFG *cfg, otawa::icache::Access *access, otawa::Address address, InstMatcher *intM)
void DotModificator::modify(otawa::CFG *cfg, const otawa::icache::Access *access, otawa::Address address)
{
std::ofstream flux(_filename);
if (flux){
// On récupère le bloc correspondant à l'accès grâce à l'InstMatcher
otawa::BasicBlock *bb_match = intM->match_access(access);
otawa::BasicBlock *bb_match = _intM->match_access(access);
// Permet de mettre des nodes au même niveau
if (_first) {
......@@ -20,23 +20,31 @@ void DotModificator::modify(otawa::CFG *cfg, otawa::icache::Access *access, otaw
_first = false;
}
// Copie de l'adresse de l'accès pour affichage
string acc_addr;
acc_addr << access->address();
//Idem avec l'address "Unsafe"
//Copie de l'addresse pour affichage
string addr;
addr << address;
// Creation du node UNSAFE
flux << "Unsafe_" << _count << "[label=\"{UNSAFE " << acc_addr
<<"| lead to a hit @" << addr <<"}\", color = red];" << io::endl;
if (access){
// Copie de l'adresse de l'accès pour affichage
string acc_addr;
acc_addr << access->address();
// Creation du node UNSAFE
flux << "Unsafe_" << _count << "[label=\"{UNSAFE " << acc_addr
<<"| lead to a hit @" << addr <<"}\", color = red];" << io::endl;
// On met au même niveau le node Unsafe et le BB auquel il correspond
flux << "{rank = same; Unsafe_" << _count << "; "
<< cfg->name() << "_" << cfg->index() << "_" << bb_match->index() <<";}"; //TODO: à optimisé (1 par BB)
// On met au même niveau le node Unsafe et le BB auquel il correspond
flux << "{rank = same; Unsafe_" << _count << "; "
<< cfg->name() << "_" << cfg->index() << "_" << bb_match->index() <<";}"; //TODO: à optimisé (1 par BB)
} else { // Debut du CFG
flux << "Unsafe_" << _count << "[label=\"{UNSAFE at the ENTRY|Can lead to a hit @"
<< addr <<"}\", color = red];" << io::endl;
flux << "{rank = same; Unsafe_" << _count << "; "
<< cfg->name() << "_0_0";
}
// On incrémente
// On incrémente le compteur
_count++;
} else {
cout << "ERROR: Unable to open the file" << io::endl;
......
......@@ -13,12 +13,14 @@ namespace lrusecurity
class DotModificator
{
public:
DotModificator(const char *dot_file){_filename = dot_file; _first = true; _count=0;};
void modify(otawa::CFG *cfg, otawa::icache::Access *access, otawa::Address address, InstMatcher *instM);
DotModificator(const char *dot_file, InstMatcher *match):_filename(dot_file), _intM(match), _first(true), _count(0){};
void modify(otawa::CFG *cfg, const otawa::icache::Access *access, otawa::Address address);
void finish(void);
inline InstMatcher *getMatcher(void){return _intM;};
private:
const char *_filename;
InstMatcher *_intM;
bool _first;
int _count;
};
......
......@@ -5,13 +5,6 @@ using namespace otawa;
namespace lrusecurity
{
void InstMatcher::setupColl(CFGCollection *collection)
{
for(int i = 0; i < collection->count(); i++) {
setupCFG(*collection[i]);
}
}
void InstMatcher::setupCFG(CFG *cfg)
{
CFG::BlockIter iter_block;
......@@ -28,6 +21,13 @@ void InstMatcher::setupCFG(CFG *cfg)
}
}
void InstMatcher::setupColl(CFGCollection *collection)
{
for(int i = 0; i < collection->count(); i++) {
InstMatcher::setupCFG(*collection[i]);
}
}
otawa::BasicBlock* InstMatcher::match_instruction(otawa::Inst *instruction)
{
auto search = this->_match.find(instruction);
......
......@@ -14,12 +14,12 @@ class InstMatcher
{
public:
InstMatcher(void);
void setupColl(otawa::CFGCollection *collection);
void setupCFG(otawa::CFG *cfg);
void setupColl(otawa::CFGCollection *collection);
inline void insert(otawa::Inst *inst, otawa::BasicBlock *bb){_match.insert({inst, bb});};
otawa::BasicBlock *match_instruction(otawa::Inst *instruction);
inline otawa::BasicBlock *match_access(otawa::icache::Access *access){return match_instruction(access->instruction());};
inline otawa::BasicBlock *match_access(const otawa::icache::Access *access){return match_instruction(access->instruction());};
inline void clean(void){_match = std::map<otawa::Inst *, otawa::BasicBlock *>();};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment