Skip to content

Commit d6147f5

Browse files
committed
Replace function calls
Adds an option --replace-calls f:g (can be repeated) to goto-instrument which replaces calls to function f by calls to function g. A use case is to replace certain functions by simpler stubs for analysis.
1 parent 5d8c9e8 commit d6147f5

File tree

18 files changed

+378
-0
lines changed

18 files changed

+378
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
int f(int a)
2+
{
3+
return a;
4+
}
5+
6+
int g(int b)
7+
{
8+
return b + 1;
9+
}
10+
11+
int main()
12+
{
13+
int r;
14+
15+
r = f(0);
16+
assert(r == 1);
17+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
main.c
3+
--replace-calls f:g
4+
g\(0\);
5+
^VERIFICATION SUCCESSFUL$
6+
^EXIT=0$
7+
^SIGNAL=0$
8+
--
9+
f\(0\);
10+
^warning: ignoring
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
int f()
2+
{
3+
return 0;
4+
}
5+
6+
int g()
7+
{
8+
return 1;
9+
}
10+
11+
int h()
12+
{
13+
return 2;
14+
}
15+
16+
int i()
17+
{
18+
return 3;
19+
}
20+
21+
int main()
22+
{
23+
int r;
24+
25+
r = f();
26+
assert(r == 1);
27+
28+
r = h();
29+
assert(r == 3);
30+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
main.c
3+
--replace-calls f:g --replace-calls h:i
4+
g\(\);
5+
i\(\);
6+
^VERIFICATION SUCCESSFUL$
7+
^EXIT=0$
8+
^SIGNAL=0$
9+
--
10+
f\(\);
11+
h\(\);
12+
^warning: ignoring
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
int f()
2+
{
3+
return 0;
4+
}
5+
6+
char g()
7+
{
8+
return 1;
9+
}
10+
11+
int main()
12+
{
13+
f();
14+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--replace-calls f:g
4+
Functions f and g are not type-compatible
5+
^EXIT=11$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
void f(int a)
2+
{
3+
return 0;
4+
}
5+
6+
void g(unsigned a)
7+
{
8+
return 1;
9+
}
10+
11+
int main()
12+
{
13+
f(0);
14+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--replace-calls f:g
4+
Functions f and g are not type-compatible
5+
^EXIT=11$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
int main()
2+
{
3+
return 0;
4+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--replace-calls f:g --replace-calls h:f
4+
Function f cannot both be replaced and be a replacement
5+
^EXIT=11$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring

0 commit comments

Comments
 (0)