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/

DotModificator.cpp 1.89 KB
Newer Older
1
2
3
4
5
6
7
8
#include <iostream>
#include <fstream>

#include "DotModificator.h"

namespace lrusecurity
{

Julien Balette-Pape's avatar
Julien Balette-Pape committed
9
void DotModificator::modify(otawa::CFG *cfg, const otawa::icache::Access *access, otawa::Address address)
10
11
12
13
14
{
    std::ofstream flux(_filename);

    if (flux){
        // On récupère le bloc correspondant à l'accès grâce à l'InstMatcher
Julien Balette-Pape's avatar
Julien Balette-Pape committed
15
        otawa::BasicBlock *bb_match = _intM->match_access(access);
16
17
18
19
20
21
22

        // Permet de mettre des nodes au même niveau
        if (_first) {
            flux << "rankdir = TB;" << io::endl;
            _first = false;
        }

Julien Balette-Pape's avatar
Julien Balette-Pape committed
23
        //Copie de l'addresse pour affichage
24
25
26
        string addr;
        addr << address;

Julien Balette-Pape's avatar
Julien Balette-Pape committed
27
28
29
30
31
32
33
34
        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;
35

Julien Balette-Pape's avatar
Julien Balette-Pape committed
36
37
38
39
40
41
42
            // 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;
Julien Balette-Pape's avatar
Julien Balette-Pape committed
43
44
/*            flux << "{rank = same; Unsafe_" << _count << "; "
                << cfg->name() << "_0_0}"; */
Julien Balette-Pape's avatar
Julien Balette-Pape committed
45
        }
46

Julien Balette-Pape's avatar
Julien Balette-Pape committed
47
        // On incrémente le compteur
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
        _count++;
    } else {
        cout << "ERROR: Unable to open the file" << io::endl;
    }
}

void DotModificator::finish(void)
{
    std::ofstream flux(_filename);

    if (flux){
        flux << "}" << io::endl;
    } else {
        cout << "ERROR: Unable to open the file" << io::endl;
    }
}

}