Predator
[unstable] git snapshot
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
symcall.hh
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2010-2011 Kamil Dudka <kdudka@redhat.com>
3
*
4
* This file is part of predator.
5
*
6
* predator is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* any later version.
10
*
11
* predator is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with predator. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#ifndef H_GUARD_SYM_CALL_H
21
#define H_GUARD_SYM_CALL_H
22
23
/**
24
* @file symcall.hh
25
* classes SymCallCache and SymCallCtx for function @b call @b optimization
26
* during the symbolic execution
27
*/
28
29
#include "
symheap.hh
"
30
31
class
SymBackTrace
;
32
class
SymState
;
33
class
SymCallCtx
;
34
35
namespace
CodeStorage {
36
struct
Fnc;
37
struct
Insn;
38
}
39
40
/// persistent cache for results of fncs called during the symbolic execution
41
class
SymCallCache
{
42
public
:
43
/// create long term cache, this should happen once per SymExec lifetime
44
SymCallCache
(
TStorRef
stor);
45
~SymCallCache
();
46
47
SymBackTrace
&
bt
();
48
49
/**
50
* cache entry point. This returns either existing, or a newly created
51
* call context.
52
* @param heap a symbolic heap valid for call entry
53
* @param fnc a function which is about to be called
54
* @param insn a call instruction which is about to be executed
55
* @note parameters fnc and insn have to match with each other!
56
* @return an instance of the corresponding SymCallCtx object, zero if
57
* an unrecoverable error occurs
58
*/
59
SymCallCtx
*
getCallCtx
(
60
SymHeap
heap,
61
const
CodeStorage::Fnc
&fnc,
62
const
CodeStorage::Insn
&insn);
63
64
private
:
65
/// object copying is @b not allowed
66
SymCallCache
(
const
SymCallCache
&);
67
68
/// object copying is @b not allowed
69
SymCallCache
&
operator=
(
const
SymCallCache
&);
70
71
private
:
72
struct
Private;
73
Private *
d
;
74
75
friend
class
SymCallCtx
;
76
};
77
78
/**
79
* function call context, which represents a cache entry of SymCallCache
80
* @note these objects can't be created/destroyed out of SymCallCache
81
*/
82
class
SymCallCtx
{
83
public
:
84
/**
85
* check if we need to execute the function call in this context. If @b
86
* true, you need to execute the call, starting with entry(), and insert
87
* all results into rawResults(). If @b false, you don't need to
88
* execute the function call and you can use the already cached result.
89
*/
90
bool
needExec
()
const
;
91
92
/// return true if the context is being used by the current backtrace
93
bool
inUse
()
const
;
94
95
/**
96
* a pre-computed symbolic heap valid for the entry of the eventual
97
* function call. Do not use this method if needExec() has returned @b
98
* false.
99
*/
100
const
SymHeap
&
entry
()
const
;
101
102
/**
103
* a place for raw results of a function call, later polished and merged
104
* into the target state. Do not use this method if needExec() has
105
* returned @b false.
106
*/
107
SymState
&
rawResults
();
108
109
/**
110
* merge the (either cached, or just computed) results of the
111
* corresponding function call into the target state
112
* @param dst target state
113
*/
114
void
flushCallResults
(
SymState
&dst);
115
116
/**
117
* invalidate the context, which may trigger its removal from cache and
118
* consequently destruction of the SymCallCtx object itself
119
*/
120
void
invalidate
();
121
122
private
:
123
/// @note these objects can't be created/destroyed out of SymCallCache
124
SymCallCtx
(SymCallCache::Private *);
125
126
/// @note these objects can't be created/destroyed out of SymCallCache
127
~SymCallCtx
();
128
129
/// @note these objects can't be created/destroyed out of SymCallCache
130
friend
class
/* SymCallCache helper */
PerFncCache
;
131
friend
class
SymCallCache
;
132
133
/// object copying is @b not allowed
134
SymCallCtx
(
const
SymCallCtx
&);
135
136
/// object copying is @b not allowed
137
SymCallCtx
&
operator=
(
const
SymCallCtx
&);
138
139
private
:
140
struct
Private;
141
Private *
d
;
142
};
143
144
#endif
/* H_GUARD_SYM_CALL_H */
Generated on Mon Nov 9 2015 14:51:59 for Predator by
1.8.1.2