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

Debug: modificator operationnel

parent 4507fe59
#include <iostream>
#include <fstream>
#include <string>
#include "DotModificator.h"
......@@ -8,46 +9,46 @@ namespace lrusecurity
void DotModificator::modify(otawa::CFG *cfg, const otawa::icache::Access *access, otawa::Address address)
{
std::ofstream flux(_filename);
std::ofstream flux(_filename, std::ios::app);
if (flux){
// On récupère le bloc correspondant à l'accès grâce à l'InstMatcher
otawa::BasicBlock *bb_match = _intM->match_access(access);
// Permet de mettre des nodes au même niveau
if (_first) {
if (isFirst()) {
flux << "rankdir = TB;" << io::endl;
_first = false;
}
//Copie de l'addresse pour affichage
string addr;
addr << address;
int addr = address.offset();
if (access){
// On récupère le bloc correspondant à l'accès grâce à l'InstMatcher
otawa::BasicBlock *bb_match = _intM->match_access(access);
// Copie de l'adresse de l'accès pour affichage
string acc_addr;
acc_addr << access->address();
int acc_addr;
acc_addr = access->address().offset();
// Creation du node UNSAFE
flux << "Unsafe_" << _count << "[label=\"{UNSAFE " << acc_addr
<<"| lead to a hit @" << addr <<"}\", color = red];" << io::endl;
flux << "Unsafe_" << _count << " [label=\"{UNSAFE 0x" << std::hex << acc_addr
<<"| lead to a hit @ 0x" << addr <<"}\", color = red];" << std::dec << 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)
string name = cfg->name();
flux << "{rank = same; Unsafe_" << _count << "; ";
for (String::Iter i = name.begin(); i!=name.end(); i++){
flux << *i;
}
flux << "_" << cfg->index() << "_" << bb_match->index() <<";}" << io::endl; //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}"; */
} else { // Debut du de la modification du CFG
flux << "Unsafe_" << _count << " [label=\"{UNSAFE at the ENTRY|Can lead to a hit @ 0x"
<< std::hex << addr <<"}\", color = red];" << std::dec << io::endl;
}
// On incrémente le compteur
_count++;
} else {
cout << "ERROR: Unable to open the file" << io::endl;
cerr << "ERROR: Unable to open the file" << io::endl;
}
}
......@@ -58,7 +59,7 @@ void DotModificator::finish(void)
if (flux){
flux << "}" << io::endl;
} else {
cout << "ERROR: Unable to open the file" << io::endl;
cerr << "ERROR: Unable to open the file" << io::endl;
}
}
......
......@@ -4,7 +4,6 @@
#include <otawa/icache/features.h>
#include <otawa/base.h>
#include <otawa/cfg/CFG.h>
#include <string>
#include "InstMatching.h"
namespace lrusecurity
......@@ -13,15 +12,15 @@ namespace lrusecurity
class DotModificator
{
public:
DotModificator(const char *dot_file, InstMatcher *match):_filename(dot_file), _intM(match), _first(true), _count(0){};
DotModificator(const char *dot_file, InstMatcher *match):_filename(dot_file), _intM(match), _count(0){};
void modify(otawa::CFG *cfg, const otawa::icache::Access *access, otawa::Address address);
void finish(void);
inline InstMatcher *getMatcher(void){return _intM;};
inline bool isFirst(void){return _count == 0;};
private:
const char *_filename;
InstMatcher *_intM;
bool _first;
int _count;
};
......
......@@ -16,7 +16,7 @@ void InstMatcher::setupCFG(CFG *cfg)
BasicBlock::InstIter iter_inst;
for (iter_inst = bb->begin(); iter_inst != bb->end(); iter_inst++){
insert(*iter_inst, bb);
}
}
}
}
}
......@@ -35,7 +35,7 @@ otawa::BasicBlock* InstMatcher::match_instruction(otawa::Inst *instruction)
if (search != _match.end())
return search->second;
else
cout << "Unable to find instruction";
cerr << "Unable to find instruction";
exit(EXIT_FAILURE);
}
......
......@@ -13,7 +13,7 @@ namespace lrusecurity
class InstMatcher
{
public:
InstMatcher(void);
InstMatcher(void){};
void setupCFG(otawa::CFG *cfg);
void setupColl(otawa::CFGCollection *collection);
inline void insert(otawa::Inst *inst, otawa::BasicBlock *bb){_match.insert({inst, bb});};
......
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