blob: a24d45bfe0cc8beb97401bd033b09210466f440c (
plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
/*
* Copyright (c) 2017 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
*/
#include <config.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <LongBow/longBow_Event.h>
#include <LongBow/longBow_EventType.h>
#include <LongBow/longBow_Backtrace.h>
#include <LongBow/longBow_Location.h>
#include <LongBow/longBow_Status.h>
#include <LongBow/private/longBow_Memory.h>
/** @cond private */
struct longbow_event {
const LongBowEventType *type;
const LongBowLocation *location;
const char *kind;
const char *message;
const LongBowBacktrace *backtrace;
};
/** @endcond */
const char *
longBowEvent_GetName(const LongBowEvent *event)
{
return longBowEventType_GetName(event->type);
}
LongBowEvent *
longBowEvent_Create(const LongBowEventType *eventType, const LongBowLocation *location, const char *kind, const char *message, const LongBowBacktrace *backtrace)
{
LongBowEvent *result = longBowMemory_Allocate(sizeof(LongBowEvent));
if (result != NULL) {
result->type = eventType;
result->location = location;
result->kind = kind;
result->message = strndup(message, strlen(message));
result->backtrace = backtrace;
}
return result;
}
void
longBowEvent_Destroy(LongBowEvent **assertionPtr)
{
LongBowEvent *assertion = *assertionPtr;
if (assertion->location != NULL) {
longBowLocation_Destroy((LongBowLocation **) &assertion->location);
}
if (assertion->message != NULL) {
free((void *) assertion->message);
}
if (assertion->backtrace != NULL) {
longBowBacktrace_Destroy((LongBowBacktrace **) &assertion->backtrace);
}
longBowMemory_Deallocate((void **) assertionPtr);
}
const LongBowLocation *
longBowEvent_GetLocation(const LongBowEvent *event)
{
return event->location;
}
const LongBowEventType *
longBowEvent_GetEventType(const LongBowEvent *event)
{
return event->type;
}
const char *
longBowEvent_GetKind(const LongBowEvent *event)
{
return event->kind;
}
const char *
longBowEvent_GetMessage(const LongBowEvent *event)
{
return event->message;
}
const LongBowBacktrace *
longBowEvent_GetBacktrace(const LongBowEvent *event)
{
return event->backtrace;
}
char **
longBowEvent_CreateSymbolicCallstack(const LongBowEvent *event)
{
char **result = longBowBacktrace_Symbols(event->backtrace);
return result;
}
size_t
longBowEvent_GetCallStackLength(const LongBowEvent *event)
{
return longBowBacktrace_GetFrameCount(event->backtrace);
}
|