Commit 49a96f13 authored by Julien Balette-Pape's avatar Julien Balette-Pape

Amélioration affichage

parent 42850881
......@@ -7,6 +7,13 @@
namespace lrusecurity
{
void displayString(string str, std::ofstream *flux)
{
for (String::Iter i = str.begin(); i!= str.end(); i++)
*flux << *i;
}
void DotModificator::modify(otawa::CFG *cfg, const otawa::icache::Access *access, otawa::Address address)
{
std::ofstream flux(_filename, std::ios::app);
......@@ -18,31 +25,33 @@ void DotModificator::modify(otawa::CFG *cfg, const otawa::icache::Access *access
}
//Copie de l'addresse pour affichage
int addr = address.offset();
string addr = _ << address;
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
int acc_addr;
acc_addr = access->address().offset();
string acc_addr = _ << access->address();
// Creation du node UNSAFE
flux << "Unsafe_" << _count << " [label=\"{UNSAFE 0x" << std::hex << acc_addr
<<"| lead to a hit @ 0x" << addr <<"}\", color = red];" << std::dec << io::endl;
flux << "Unsafe_" << _count << " [label=\"{UNSAFE ";
displayString(acc_addr, &flux);
flux <<"|Lead to a hit @ ";
displayString(addr, &flux);
flux <<"}\", color = red];" << io::endl;
// On met au même niveau le node Unsafe et le BB auquel il correspond
string name = cfg->name();
flux << "{rank = same; Unsafe_" << _count << "; ";
for (String::Iter i = name.begin(); i!=name.end(); i++){
flux << *i;
}
displayString(cfg->name(), &flux);
flux << "_" << cfg->index() << "_" << bb_match->index() <<";}" << io::endl; //TODO: à optimisé (1 par BB)
} 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;
} else { // UNSAFE au début
flux << "Unsafe_" << _count << " [label=\"{UNSAFE at the ENTRY|Can lead to a hit @ ";
displayString(addr, &flux);
flux << "|In function ";
displayString(cfg->name(), &flux);
flux << "}\", color = red];" << io::endl;
}
// On incrémente le compteur
......
......@@ -30,7 +30,7 @@ public:
_stream(nullptr),
_line(false),
// Modification pour affichage en dot
_modificator(new DotModificator("test.dot", new InstMatcher)) //TODO: changer l'accès au fichier
_modificator(new DotModificator("result.dot", new InstMatcher)) //TODO: changer l'accès au fichier
{
}
......
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