blob: 546e5fca6c166b9a9526b155309a992a75bd727a [file] [log] [blame]
Basil Eljuse4b14afb2020-09-30 13:07:23 +01001/*!
2##############################################################################
3# Copyright (c) 2020, ARM Limited and Contributors. All rights reserved.
4#
5# SPDX-License-Identifier: BSD-3-Clause
6##############################################################################
7*/
8#ifndef _COVERAGE_TOOL_COVERAGE_PLUGIN_PLUGIN_UTILS_H_
9#define _COVERAGE_TOOL_COVERAGE_PLUGIN_PLUGIN_UTILS_H_
10
11#include <sstream>
12#include <map>
13#include <vector>
14#include <string>
15#include "MTI/ModelTraceInterface.h"
16using namespace eslapi;
17using namespace MTI;
18using namespace std;
19
20typedef struct {
21 const char *name;
22 MTI::ValueIndex *index;
23} ValueBind_t;
24
25// Declare an MTI callback method and define a static thunk method to call
26// into this from C code.
27#define CALLBACK_DECL_AND_THUNK(class_name, name) \
28 static void name##Thunk(void * user_data, const MTI::EventClass *event_class, const MTI::EventRecord *record) \
29 { \
30 reinterpret_cast<class_name *>(user_data)->name(event_class, record); \
31 } \
32 void name(const MTI::EventClass *event_class, const MTI::EventRecord *record)
33
34
35// Get a named trace source, create an event class from the named subset of
36// event fields, register the event class and look up the field indexes, and
37// register a user-provided MTI callback with the trace source.
38// Writes to error_ss and returns false if anything fails.
39bool RegisterCallbackForComponent(const MTI::ComponentTraceInterface *mti,
40 const char *trace_source,
41 ValueBind_t *value_bind, void *this_ptr,
42 MTI::CallbackT callback,
43 MTI::EventClass **ptr_event_class,
44 std::stringstream &error_ss);
45
46#endif // _COVERAGE_TOOL_COVERAGE_PLUGIN_PLUGIN_UTILS_H_