calltrace.reference
Members | Descriptions |
---|---|
#define METAL_NO_INSTRUMENT |
The macro that removes call monitoring for a function. |
int metal_calltrace_init(metal_calltrace * ct) |
This function initializes and registers a calltrace. Note that there is a limited amount of calltraces that can be added. The default value is 16, but can be changed by defining METAL_CALLTRACE_STACK_SIZE while compiling calltrace. |
int metal_calltrace_complete(metal_calltrace * ct) |
This functions returns a value different from zero if the calltrace was completed. The behaviour depends on the repeat setting of the calltrace. If the calltrace is set to repeat n-times it has to be at least repeated once, while any other number will require the calltrace to be repeated exactly as set. |
int metal_calltrace_success(metal_calltrace * ct) |
This functions returns a value different from zero if the calltrace was completed and did not err. |
int metal_calltrace_deinit(metal_calltrace * ct) |
This function deinitializes the calltrace and removes it from the stack. This function must be called before the calltrace struct is removed from the stack, otherwise it might casue memory leaks. |
namespace metal |
Namespace containing the calltrace |
This function initializes and registers a calltrace. Note that there is a limited amount of calltraces that can be added. The default value is 16, but can be changed by defining METAL_CALLTRACE_STACK_SIZE
while compiling calltrace.
Example
#include <cassert>
#include <metal/calltrace.h>
void func() {foo(); bar();}
int main(int argc, char *argv[])
{
const void * ct_arr[] = {&foo, &bar};
metal_calltrace ct = {&func, ct_arr, 2, 0, 0};
assert(metal_calltrace_init(&ct));
func();
assert(metal_calltrace_success(&ct));
assert(metal_calltrace_deinit(&ct));
return 0;
}
-
ct
A pointer to the calltrace to be initialized.
A value differnt from zero if it succeeded.
This functions returns a value different from zero if the calltrace was completed. The behaviour depends on the repeat setting of the calltrace. If the calltrace is set to repeat n-times it has to be at least repeated once, while any other number will require the calltrace to be repeated exactly as set.
-
ct
A pointer to the calltrace that shall be examined.
Unequal zero if successful.
This functions returns a value different from zero if the calltrace was completed and did not err.
-
ct
A pointer to the calltrace that shall be examined.
Unequal zero if completed without error.
This function deinitializes the calltrace and removes it from the stack. This function must be called before the calltrace struct is removed from the stack, otherwise it might casue memory leaks.
-
ct
The calltrace to be deinitialized
A value unequal to zero if the calltrace was succesful removed from the stack.
Members | Descriptions |
---|---|
public timestamp_t timestamp ()
|
|
class metal::test::calltrace
|
The actual calltrace implementation. |
class metal::test::calltrace<0>
|
Specialization for an empty calltrace. |
struct metal::test::fn
|
Convenience type to bind to any function with the given signature to pass to the calltrace. This does not take qualifier overloads in member function into account. |
class metal::test::calltrace
: private metal_calltrace_
The actual calltrace implementation.
-
Size
The number of the functions inside the trace body passed.
Example
void bar(std::vector<int> & v);
void foo()
{
std::vector<int> vec;
vec.push_back(42);
bar(vec);
vec.resize(2);
};
int main(int argc, char* argv[])
{
using namespace [metal::test](#namespacemetal_1_1test);
[calltrace](#classmetal_1_1test_1_1calltrace) ct
{
&foo, //starting point
any_fn, //constructor, no way to get the address
[fn<void(int&&)>](#structmetal_1_1test_1_1fn)(&std::vector<int>::push_back), //the move push back
&bar, //function not overloaded
&std::vector<int>::size,
any_fn //destructor
};
foo();
assert(ct);
return 0;
};
Members | Descriptions |
---|---|
template<> calltrace(Func func,int repeat,int skip) |
Construct an empty (i.e. asserting no calls) calltrace from the given function, including a repeat count and a skip. |
template<> calltrace(Func func,int repeat) |
Construct an empty calltrace from the given function, including a repeat count, but no skip. |
template<> calltrace(Func func) |
Construct an empty calltrace from the given function, without a repeat count and skip. |
template<> calltrace(Func func,int repeat,int skip,Args... args) |
Construct a calltrace from the given function, including a repeat count and a skip |
calltrace(const calltrace &) = delete |
Deleted copy-ctor. |
template<> calltrace(Func func,int repeat,Args... args) |
Construct a calltrace from the given function, including a repeat count, but no skip. |
template<> calltrace(Func func,Args ... args) |
Construct a calltrace from the given function, without a repeat count and skip. |
bool inited() const |
Check if the calltrace was inited, i..e added to the calltrace list. |
bool errored() const |
Check if the calltrace had an error occur. |
bool complete() const |
Check if the calltrace is completed, without checking the error count. The behaviour depends on the repeat setting of the calltrace. If the calltrace is set to repeat n-times it has to be at least repeated once, while any other number will require the calltrace to be repeated exactly as set. |
bool success() const |
Check if the calltrace was succesful, i.e. inited, completed and did not err. |
operator bool() const |
Convenience overload for success. |
~calltrace() |
Destructor, removes the calltrace from the list. |
Construct an empty (i.e. asserting no calls) calltrace from the given function, including a repeat count and a skip.
-
func
The function to trace -
repeat
The times the calltrace shall be repeated -
skip
The amount of calls that shall be ignore before activating the calltrace
Construct an empty calltrace from the given function, including a repeat count, but no skip.
-
func
The function to trace -
repeat
The times the calltrace shall be repeated
Construct an empty calltrace from the given function, without a repeat count and skip.
-
func
The function to trace
Construct a calltrace from the given function, including a repeat count and a skip.
-
func
The function to trace -
repeat
The times the calltrace shall be repeated -
skip
The amount of calls that shall be ignore before activating the calltrace -
args
The expected function calls.
Construct a calltrace from the given function, including a repeat count, but no skip.
-
func
The function to trace -
repeat
The times the calltrace shall be repeated -
args
The expected function calls.
Construct a calltrace from the given function, without a repeat count and skip.
-
func
The function to trace -
args
The expected function calls.
Check if the calltrace was inited, i..e added to the calltrace list.
Check if the calltrace had an error occur.
Check if the calltrace is completed, without checking the error count. The behaviour depends on the repeat setting of the calltrace. If the calltrace is set to repeat n-times it has to be at least repeated once, while any other number will require the calltrace to be repeated exactly as set.
Check if the calltrace was succesful, i.e. inited, completed and did not err.
Convenience overload for success.
Destructor, removes the calltrace from the list.
class metal::test::calltrace< 0 >
: private metal_calltrace_
Specialization for an empty calltrace.
Members | Descriptions |
---|---|
template<> alltrace(Func func,int repeat,int skip) |
Construct an empty (i.e. asserting no calls) calltrace from the given function, including a repeat count and a skip. |
template<> alltrace(Func func,int repeat) |
Construct an empty calltrace from the given function, including a repeat count, but no skip. |
template<> alltrace(Func func) |
Construct an empty calltrace from the given function, without a repeat count and skip. |
bool inited() const |
Check if the calltrace was inited, i..e added to the calltrace list. |
bool errored() const |
Check if the calltrace had an error occur. |
bool complete() const |
Check if the calltrace is completed, without checking the error count. The behaviour depends on the repeat setting of the calltrace. If the calltrace is set to repeat n-times it has to be at least repeated once, while any other number will require the calltrace to be repeated exactly as set. |
bool success() const |
Check if the calltrace was succesful, i.e. inited, completed and did not err. |
operator bool() const |
Convenience overload for success. |
~calltrace() |
Destructor, removes the calltrace from the list. |
Construct an empty (i.e. asserting no calls) calltrace from the given function, including a repeat count and a skip.
-
func
The function to trace -
repeat
The times the calltrace shall be repeated -
skip
The amount of calls that shall be ignore before activating the calltrace
Construct an empty calltrace from the given function, including a repeat count, but no skip.
-
func
The function to trace -
repeat
The times the calltrace shall be repeated
Construct an empty calltrace from the given function, without a repeat count and skip.
-
func
The function to trace
Check if the calltrace was inited, i..e added to the calltrace list.
Check if the calltrace had an error occur.
Check if the calltrace is completed, without checking the error count. The behaviour depends on the repeat setting of the calltrace. If the calltrace is set to repeat n-times it has to be at least repeated once, while any other number will require the calltrace to be repeated exactly as set.
Check if the calltrace was succesful, i.e. inited, completed and did not err.
Convenience overload for success.
Destructor, removes the calltrace from the list.
Convenience type to bind to any function with the given signature to pass to the calltrace. This does not take qualifier overloads in member function into account.
Example
void foo(int);
void foo(double);
struct bar
{
bar();
void f(int);
void f(double);
~bar();
};
bar b;
void func()
{
foo(42);
b.f(0.1);
}
calltrace ct{&func,
fn<void(int)>(&foo), //binds to foo(int)
fn<void(double)>(&bar::f) //binds to bar::f(double)
};
Helper type to bind to a member function, either any without const/volatile qualifier or with a specific signature.
Example
struct my_class
{
void foo();
void foo() const;
void bar();
void bar() const;
void bar(int);
void bar(int) const;
};
calltrace ct{&some_func,
mem_fn<>(&my_class::foo), //binds to my_class::foo()
mem_fn<void()>(&my_class::bar), //binds to my_class::bar()
mem_fn<void(int)>(&my_class::bar) //binds to my_class::bar(int)
};
- Overview
- Runner Introduction
- Runner Invocation
- Runner Plugins
- Runner Extender
- Runner FAQ
- Runner Reference
- Unit Introduction
- Unit Tutorial
- Unit FAQ
- Unit Reference
- Calltrace Introduction
- Calltrace Tutorial
- Calltrace FAQ
- Calltrace Plugin
- Calltrace Reference
- Serial Introduction
- Serial Tutorial
- Serial Invocation
- Serial Reference