-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstrument_test.c
More file actions
64 lines (50 loc) · 1.24 KB
/
instrument_test.c
File metadata and controls
64 lines (50 loc) · 1.24 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Exercise the interface in instrument.h
#include <stdbool.h>
#include <stdio.h>
#include "demo_shared_lib.h"
#include "instrument.h"
void
basic_func (void);
void
basic_func (void)
{
printf ("in function %s\n", __func__);
}
static void
static_func (void)
{
printf ("in function %s\n", __func__);
}
static void
i_fail_with_backtrace (void)
{
ASSERT_BT (false);
}
int
main (void)
{
printf ("\n");
// Announce ourselves and call the test functions to keep the compiler
// from issuing warnings and make sure they really exist.
printf ("I'm a client program\n");
basic_func ();
static_func ();
demo_shared_lib_func ();
printf ("\n");
printf ("Looking up name for function basic_func()...\n");
what_func (basic_func);
printf ("\n");
// Note that the optimizer tends to inline static functions especially often
printf ("Looking up name for static function static_func()...\n");
what_func (static_func);
printf ("\n");
printf ("Looking up name for demo_shared_lib_func()...\n");
what_func (demo_shared_lib_func);
printf ("\n");
printf("Trying BACKTRACE()...\n");
BACKTRACE ();
printf ("\n");
printf ("Calling function i_fail_with_backtrace() (expecting failure)...\n");
i_fail_with_backtrace ();
return 0;
}