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_ExistHitPrevUAnalysis.cpp 2.71 KB
Newer Older
1
2

#include "ExistHitPrevUAnalysis.h"
3
4
5
6
7
8
9
10
11
12

#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>

13
14
#include "ExistHitPrevUAdapter.h"
#include "ExistHitPrevUDomain.h"
15
16
17
18
19
using namespace otawa;

namespace lrusecurity
{

20
ExistHitPrevUAnalysis::ExistHitPrevUAnalysis(p::declare& r) :
21
		Processor(r),
22
		_initExistHitPrevU(nullptr),
23
24
25
26
		_coll(nullptr),
		_cfgs(nullptr)
{
}
27
void ExistHitPrevUAnalysis::configure(const PropList& props)
28
29
30
{
	Processor::configure(props);
	if(props.hasProp(EXIST_HIT_PREV_INIT))
31
		_initExistHitPrevU = &EXIST_HIT_PREV_INIT(props);
32
33
}

34
void ExistHitPrevUAnalysis::setup(WorkSpace* ws)
35
36
37
38
39
40
41
{
	_coll = icat3::LBLOCKS(ws);
	ASSERT(_coll != nullptr);
	_cfgs = INVOLVED_CFGS(ws);
	ASSERT(_cfgs != nullptr);
}

42
  void ExistHitPrevUAnalysis::processWorkSpace(WorkSpace* ws) //changer les ACS en ACSSecurity
43
{
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
	auto start = std::chrono::system_clock::now();

	// prepare containers
	for(CFGCollection::BlockIter b(_cfgs); b; b++)
		(*EXIST_HIT_PREV_IN(b)).configure(*_coll);

	// 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))
		log << "\tExist Hit Prev Analysis running time: " << elapsed.count() << " s" << io::endl;
}
64
void ExistHitPrevUAnalysis::destroy(WorkSpace*)
65
66
67
68
69
{
	for(CFGCollection::BlockIter b(_cfgs); b; b++)
		EXIST_HIT_PREV_IN(b).remove();
}

70
71

void ExistHitPrevUAnalysis::processSet(int set, WorkSpace* ws)
72
73
{
	// perform the analysis
74
75
	ExistHitPrevUAdapter ada(set, _initExistHitPrevU ? &_initExistHitPrevU->get(set) : nullptr, *_coll, *_cfgs, ws);
	ai::SimpleAI<ExistHitPrevUAdapter> ana(ada);
76
77
78
79
80
81
82
83
84
85
	ana.run();
	// store the results
	for(CFGCollection::BlockIter b(_cfgs); b; b++)
		if(b->isBasic()) {
		  ada.domain().copy((*EXIST_HIT_PREV_IN(b))[set], ada.store().get(b));
			if(logFor(LOG_BLOCK))
				log << "\t\t\t" << *b << ": " << ada.domain().print(ada.store().get(b)) << io::endl;
		}
}

86
p::declare ExistHitPrevUAnalysis::reg = p::init("lrusecurity::ExistHitPrevUAnalysis", Version(1, 0, 0))
87
88
89
90
	.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
91
	.require(lrupreanalysis::eh_em::EXIST_HIT_ANALYSIS_FEATURE)
92
93
	.provide(EXIST_HIT_PREV_U_ANALYSIS_FEATURE)
	.make<ExistHitPrevUAnalysis>();
94

95
p::feature EXIST_HIT_PREV_U_ANALYSIS_FEATURE("lrusecurity::EXIST_HIT_PREV_ANALYSIS_U_FEATURE", p::make<ExistHitPrevUAnalysis>());
96
}; // namespace lrusecurity