Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

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

Debug: modificator operationnel

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