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/

lrusecurity_ExistHitPrevAnalysis.cpp 2.86 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "ExistHitPrevAnalysis.h"

#include <chrono>

#include <otawa/ai/ArrayStore.h>
#include <otawa/ai/SimpleAI.h>
#include <otawa/icache/features.h>
#include <otawa/icat3/features.h>

#include <lrusecurity/features.h>

#include "ExistHitPrevAdapter.h"
#include "ExistHitPrevDomain.h"

using namespace otawa;

namespace lrusecurity
{

ExistHitPrevAnalysis::ExistHitPrevAnalysis(p::declare& r) :
		Processor(r),
		_initExistHitPrev(nullptr),
		_coll(nullptr),
		_cfgs(nullptr)
{
}

void ExistHitPrevAnalysis::configure(const PropList& props)
{
	Processor::configure(props);
31
32
	if(props.hasProp(EXIST_HIT_PREV_INIT))
		_initExistHitPrev = &EXIST_HIT_PREV_INIT(props);
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
}

void ExistHitPrevAnalysis::setup(WorkSpace* ws)
{
	_coll = icat3::LBLOCKS(ws);
	ASSERT(_coll != nullptr);
	_cfgs = INVOLVED_CFGS(ws);
	ASSERT(_cfgs != nullptr);
}

  void ExistHitPrevAnalysis::processWorkSpace(WorkSpace* ws) //changer les ACS en ACSSecurity
{
	auto start = std::chrono::system_clock::now();

	// prepare containers
	for(CFGCollection::BlockIter b(_cfgs); b; b++)
49
		(*EXIST_HIT_PREV_IN(b)).configure(*_coll);
50
51
52
53
54
55
56
57
58
59
60
61
62

	// compute ACS
	for(int i = 0; i < _coll->cache()->setCount(); i++) {
		if((*_coll)[i].count()) {
			if(logFor(LOG_FUN))
				log << "\tanalyzing set " << i << io::endl;
			processSet(i, ws);
		}
	}

	auto end = std::chrono::system_clock::now();
	auto elapsed = std::chrono::duration_cast<std::chrono::seconds>(end - start);
	if(logFor(LOG_FUN))
63
		log << "\tExist Hit Prev Analysis running time: " << elapsed.count() << " s" << io::endl;
64
65
66
67
68
}

void ExistHitPrevAnalysis::destroy(WorkSpace*)
{
	for(CFGCollection::BlockIter b(_cfgs); b; b++)
69
		EXIST_HIT_PREV_IN(b).remove();
70
71
72
73
74
75
76
77
78
79
80
}

void ExistHitPrevAnalysis::processSet(int set, WorkSpace* ws)
{
	// perform the analysis
	ExistHitPrevAdapter ada(set, _initExistHitPrev ? &_initExistHitPrev->get(set) : nullptr, *_coll, *_cfgs, ws);
	ai::SimpleAI<ExistHitPrevAdapter> ana(ada);
	ana.run();
	// store the results
	for(CFGCollection::BlockIter b(_cfgs); b; b++)
		if(b->isBasic()) {
81
		  ada.domain().copy((*EXIST_HIT_PREV_IN(b))[set], ada.store().get(b));
82
83
84
85
86
87
88
89
90
91
			if(logFor(LOG_BLOCK))
				log << "\t\t\t" << *b << ": " << ada.domain().print(ada.store().get(b)) << io::endl;
		}
}

p::declare ExistHitPrevAnalysis::reg = p::init("lrusecurity::ExistHitPrevAnalysis", Version(1, 0, 0))
	.require(icat3::LBLOCKS_FEATURE)
	.require(COLLECTED_CFG_FEATURE)
	.require(icat3::MUST_PERS_ANALYSIS_FEATURE)
	.require(icat3::CATEGORY_FEATURE)
Valentin Touzeau's avatar
Valentin Touzeau committed
92
	.require(lrupreanalysis::eh_em::EXIST_HIT_ANALYSIS_FEATURE)
93
	.provide(EXIST_HIT_PREV_ANALYSIS_FEATURE)
94
95
	.make<ExistHitPrevAnalysis>();

96
p::feature EXIST_HIT_PREV_ANALYSIS_FEATURE("lrusecurity::EXIST_HIT_PREV_ANALYSIS_FEATURE", p::make<ExistHitPrevAnalysis>());
97

98
  p::id<icat3::Container<ACSSecurity> > EXIST_HIT_PREV_IN("lrusecurity::PREV_IN");
99

100
  p::id<icat3::Container<ACSSecurity> > EXIST_HIT_PREV_INIT("lrusecurity::PREV_INIT");
101
102

}; // namespace lrusecurity