Tizen RT Libs&Environment  v1.1 D4
ttrace.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright 2016 Samsung Electronics All Rights Reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an
13  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14  * either express or implied. See the License for the specific
15  * language governing permissions and limitations under the License.
16  *
17  ****************************************************************************/
25 
28 #ifndef __INCLUDE_TINYARA_TTRACE_H
29 #define __INCLUDE_TINYARA_TTRACE_H
30 
31 /****************************************************************************
32  * Included Files
33  ****************************************************************************/
34 #include <tinyara/config.h>
35 
36 #ifdef CONFIG_TTRACE
37 #include <stdio.h>
38 #include <stdint.h>
39 #include <stdarg.h>
40 #include <stdbool.h>
41 #include <debug.h>
42 #include <time.h>
43 #include <sys/types.h>
44 
45 /****************************************************************************
46  * Public Type Declarations
47  ****************************************************************************/
48 #define TTRACE_START 's'
49 #define TTRACE_OVERWRITE 'o'
50 #define TTRACE_FINISH 'f'
51 #define TTRACE_INFO 'i'
52 #define TTRACE_SELECTED_TAG 't'
53 #define TTRACE_FUNC_TAG 'g'
54 #define TTRACE_SET_BUFSIZE 'z'
55 #define TTRACE_USED_BUFSIZE 'u'
56 #define TTRACE_BUFFER 'b'
57 #define TTRACE_DUMP 'd'
58 #define TTRACE_PRINT 'p'
59 
60 #define TTRACE_CODE_VARIABLE 0
61 #define TTRACE_CODE_UNIQUE (1 << 7)
62 
63 #define TTRACE_MSG_BYTES 32
64 #define TTRACE_COMM_BYTES 12
65 #define TTRACE_BYTE_ALIGN 4
66 
67 #define TTRACE_NODATA -2
68 #define TTRACE_INVALID -1
69 #define TTRACE_VALID 0
70 
71 #define TTRACE_TAG_ALL -1
72 #define TTRACE_TAG_OFF 0
73 #define TTRACE_TAG_APPS (1 << 0)
74 #define TTRACE_TAG_LIBS (1 << 1)
75 #define TTRACE_TAG_LOCK (1 << 2)
76 #define TTRACE_TAG_TASK (1 << 3)
77 #define TTRACE_TAG_IPC (1 << 4)
78 
79 /****************************************************************************
80  * Public Variables
81  ****************************************************************************/
82 struct sched_message { // total 32B
83  pid_t prev_pid; // 2B
84  uint8_t prev_prio; // 1B
85  uint8_t prev_state; // 1B
87  pid_t next_pid; // 2B
88  uint8_t next_prio; // 1B
89  int8_t pad; // 1B
91 };
92 
93 union trace_message { // total 32B
94  char message[TTRACE_MSG_BYTES]; // 32B, message(256b)
95  struct sched_message sched_msg; // 32B
96 };
97 
98 struct trace_packet { // total 44 byte(message), 12byte(uid)
99  struct timeval ts; // 8B, time_t(32b) + long(32b)
100  pid_t pid; // 2B, int16_t(16b)
101  char event_type; // 1B, char(8b)
102  int8_t codelen; // 1B, code(1b) + variable length(7b) or uid(7b)
103  union trace_message msg; // 32B
104 };
105 
106 /****************************************************************************
107  * Public Function Prototypes
108  ****************************************************************************/
109 #if defined(__cplusplus)
110 extern "C" {
111 #endif
112 
122 int trace_begin(int tag, char *str, ...);
123 
133 int trace_begin_uid(int tag, int8_t uniqueid);
134 
143 int trace_end(int tag);
144 
153 int trace_end_uid(int tag);
154 
164 int trace_sched(struct tcb_s *prev, struct tcb_s *next);
165 #else
166 #define trace_begin(a, b, ...)
167 #define trace_begin_uid(a, b)
168 #define trace_end(a)
169 #define trace_end_uid(a)
170 #define trace_sched(a, b)
171 
172 #if defined(__cplusplus)
173 }
174 #endif
175 
176 #endif /* CONFIG_TTRACE */
177 #endif /* __INCLUDE_TINYARA_TTRACE_INTERNAL_H */
178 
int trace_end(int tag)
writes a trace log to indicate that the event has ended
char message[TTRACE_MSG_BYTES]
Definition: ttrace.h:94
uint8_t prev_prio
Definition: ttrace.h:84
Debug APIs.
char event_type
Definition: ttrace.h:101
uint8_t next_prio
Definition: ttrace.h:88
int8_t codelen
Definition: ttrace.h:102
#define TTRACE_MSG_BYTES
Definition: ttrace.h:63
int trace_sched(struct tcb_s *prev, struct tcb_s *next)
writes a trace log for scheduler events
struct sched_message sched_msg
Definition: ttrace.h:95
pid_t prev_pid
Definition: ttrace.h:83
int trace_end_uid(int tag)
writes a trace log to indicate that a event has ended
This is the common part of the task control block (TCB). The TCB is the heart of the TinyAra task-con...
Definition: sched.h:474
pid_t pid
Definition: ttrace.h:100
uint8_t prev_state
Definition: ttrace.h:85
int trace_begin(int tag, char *str,...)
writes a trace log with string to indicate that a event has begun
union trace_message msg
Definition: ttrace.h:103
int trace_begin_uid(int tag, int8_t uniqueid)
writes a trace log with unique id to indicate that a event has begun
char prev_comm[TTRACE_COMM_BYTES]
Definition: ttrace.h:86
structure represents an elapsed time
Definition: time.h:160
pid_t next_pid
Definition: ttrace.h:87
struct timeval ts
Definition: ttrace.h:99
Standard Input / Output APIs.
char next_comm[TTRACE_COMM_BYTES]
Definition: ttrace.h:90
#define TTRACE_COMM_BYTES
Definition: ttrace.h:64
Time APIs.
int8_t pad
Definition: ttrace.h:89