Skip to content
This repository

Reorganized the code a little and change from using shmem to mmap #8

Merged
merged 3 commits into from about 2 years ago

2 participants

akariv Yotam Rubin
akariv
Collaborator

No description provided.

Adam Kariv added some commits
Adam Kariv Some code and make file reorganization
- Create include directory
- Fix some makefile dependencies
30c029f
Adam Kariv SHMEM -> MMAP 63c3c05
Yotam Rubin
Owner

Cool, did you test this on Android?
I think you left some debug printf()'s along the way, can you remove those?

Collaborator
Owner

Great, I'm waiting for an updated version.

Collaborator
Collaborator
akariv
Collaborator

OK, removed those printfs.

Yotam Rubin yotamr merged commit 6322cb6 into from
Yotam Rubin yotamr closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 3 unique commits by 1 author.

Apr 22, 2012
Adam Kariv Some code and make file reorganization
- Create include directory
- Fix some makefile dependencies
30c029f
Apr 24, 2012
Adam Kariv SHMEM -> MMAP 63c3c05
Adam Kariv Removed forgotten debug printf 6322cb6
This page is out of date. Refresh to see the latest.
3  .gitignore
... ... @@ -1,8 +1,11 @@
1 1 trace_dumper/trace_dumper
2 2 trace_reader/simple_trace_reader
3 3 trace_instrumentor/trace_instrumentor.so
  4 +interactive_reader/_trace_parser_ctypes.py
4 5 traces.so
5 6 demo/demo
6 7 lib*.a
7 8 *.o
8 9 *.pyc
  10 +*\#
  11 +*~
49 Makefile
... ... @@ -1,29 +1,44 @@
1   -CFLAGS=-I. -c -Wall -g -fPIC
2   -LIBTRACE_OBJS=trace_metadata_util.o trace_parser.o halt.o trace_user.o
3   -LIBTRACEUSER_OBJS=trace_metadata_util.o trace_user.o halt.o
  1 +CFLAGS=-Iinclude/ -c -Wall -g -fPIC
  2 +LLVM_CONFIG=$(TRACE_LLVM_CONFIG_PATH)
  3 +
4 4 all: libtrace libtraceuser simple_trace_reader trace_dumper interactive_reader trace_instrumentor
5   -trace_dumper: $(LIBTRACE_OBJS) trace_dumper/trace_dumper.o trace_dumper/filesystem.o trace_user_stubs.o
6   - gcc -L. trace_dumper/filesystem.o trace_dumper/trace_dumper.o trace_user_stubs.o -ltrace -o trace_dumper/trace_dumper -lrt
7 5
8   -libtrace: $(LIBTRACE_OBJS)
9   - ar rcs libtrace.a trace_metadata_util.o trace_parser.o halt.o
10   - gcc -shared -g trace_metadata_util.o trace_parser.o halt.o -o traces.so
  6 +libtrace: libtrace.a traces.so
  7 +trace_dumper: trace_dumper/trace_dumper
  8 +libtraceuser: libtraceuser.a
  9 +simple_trace_reader: trace_reader/simple_trace_reader
  10 +interactive_reader: interactive_reader/_trace_parser_ctypes.py
  11 +
  12 +LIBTRACEUSER_FILES:=trace_metadata_util halt trace_user
  13 +LIBTRACE_FILES:=$(LIBTRACEUSER_FILES) trace_parser
  14 +LIBTRACE_OBJS=$(LIBTRACE_FILES:%=libtrace/%.o)
  15 +LIBTRACEUSER_OBJS=$(LIBTRACEUSER_FILES:%=libtrace/%.o)
  16 +
  17 +libtrace.a traces.so: $(LIBTRACE_OBJS)
  18 + ar rcs libtrace.a $^
  19 + gcc -shared -g -o traces.so $^
11 20
12   -libtraceuser: $(LIBTRACEUSER_OBJS)
13   - ar rcs libtraceuser.a trace_metadata_util.o trace_user.o halt.o
  21 +trace_dumper/trace_dumper: $(LIBTRACE_OBJS) trace_dumper/trace_dumper.o trace_dumper/filesystem.o trace_dumper/trace_user_stubs.o
  22 + gcc -L. trace_dumper/filesystem.o trace_dumper/trace_dumper.o trace_dumper/trace_user_stubs.o -ltrace -o trace_dumper/trace_dumper -lrt
14 23
15   -simple_trace_reader: $(LIBTRACE_OBJS) trace_reader/simple_trace_reader.o
  24 +libtraceuser.a: $(LIBTRACEUSER_OBJS)
  25 + ar rcs libtraceuser.a $^
  26 +
  27 +trace_reader/simple_trace_reader: $(LIBTRACE_OBJS) trace_reader/simple_trace_reader.o
16 28 gcc -L. trace_reader/simple_trace_reader.o -ltrace -o trace_reader/simple_trace_reader
17 29
18   -interactive_reader: trace_parser.h
19   - h2xml -c -I. trace_parser.h -o _trace_parser_ctypes.xml
20   - xml2py -k f -k e -k s _trace_parser_ctypes.xml > interactive_reader/_trace_parser_ctypes.py
  30 +interactive_reader/_trace_parser_ctypes.py: include/trace_parser.h
  31 + h2xml.py -c -I. include/trace_parser.h -o _trace_parser_ctypes.xml
  32 + xml2py.py -k f -k e -k s _trace_parser_ctypes.xml > interactive_reader/_trace_parser_ctypes.py
21 33 rm _trace_parser_ctypes.xml
22 34
23   -trace_instrumentor/trace_instrumentor.o: CXXFLAGS := $(shell llvm-config --cxxflags)
24   -trace_instrumentor/trace_instrumentor.o: LDFLAGS := $(shell llvm-config --libs --ldflags)
  35 +trace_instrumentor/trace_instrumentor.o: CXXFLAGS := $(shell $(LLVM_CONFIG) --cxxflags) -Iinclude/ $(TRACE_CLANG_INCLUDE_PATH:%=-I%)
  36 +trace_instrumentor/trace_instrumentor.o: LDFLAGS := $(shell $(LLVM_CONFIG) --libs --ldflags)
25 37 trace_instrumentor: trace_instrumentor/trace_instrumentor.o
26 38 gcc $(LDFLAGS) -shared trace_instrumentor/trace_instrumentor.o -o trace_instrumentor/trace_instrumentor.so
27 39
28 40 clean:
29   - rm -f *.o trace_reader/simple_trace_reader.o trace_reader/simple_trace_reader trace_dumper/*.o trace_instrumentor/*.o trace_instrumentor/*.so trace_dumper/trace_dumper trace_reader/trace_reader *so *.a
  41 + find -name \*.o -exec rm \{} \;
  42 + rm *.so *.a
  43 + rm interactive_reader/_trace_parser_ctypes.py
  44 +
4 ccwrap.py
@@ -107,8 +107,8 @@ def main():
107 107 cpp_args.extend(["-w", "-D", "_GNU_SOURCE"])
108 108
109 109 cpp_args.extend(["-D", "__TRACE_INSTRUMENTATION"])
110   - cpp_args.extend(["-include", os.path.join(os.path.dirname(sys.argv[0]), "trace_lib.h")])
111   - cpp_args.extend(["-include", os.path.join(os.path.dirname(sys.argv[0]), "trace_user.h")])
  110 + cpp_args.extend(["-include", os.path.join(os.path.dirname(sys.argv[0]), "include/trace_lib.h")])
  111 + cpp_args.extend(["-include", os.path.join(os.path.dirname(sys.argv[0]), "include/trace_user.h")])
112 112
113 113 out_pp_file = pp_file + ".i"
114 114 ret = spawn(cpp_args)
4 env_setup.sh
... ... @@ -0,0 +1,4 @@
  1 +export TRACE_INSTRUMENTOR=/code/traces/trace_instrumentor/trace_instrumentor.so
  2 +export TRACE_CLANG_PATH=/code/clang/build/Release/bin
  3 +export TRACE_LLVM_CONFIG_PATH=/code/clang/build/Release/bin/llvm-config
  4 +export TRACE_CLANG_INCLUDE_PATH="/code/clang/llvm/include/ /code/clang/llvm/tools/clang/include/ /code/clang/build/tools/clang/include/ /code/clang/build/include/"
0  array_length.h → include/array_length.h
File renamed without changes
0  bool.h → include/bool.h
File renamed without changes
13 include/config.h
... ... @@ -0,0 +1,13 @@
  1 +#ifndef _CONFIG_H_
  2 +#define _CONFIG_H_
  3 +
  4 +#define SHM_PATH "/dev/shm/"
  5 +#define TRACE_SHM_ID "_trace_shm_"
  6 +
  7 +#ifndef ANDROID
  8 +#define TRACE_RECORD_BUFFER_RECS 0x100000
  9 +#else
  10 +#define TRACE_RECORD_BUFFER_RECS 0x100000
  11 +#endif
  12 +
  13 +#endif // _CONFIG_H_
0  halt.h → include/halt.h
File renamed without changes
0  list_template.h → include/list_template.h
File renamed without changes
0  macros.h → include/macros.h
File renamed without changes
0  min_max.h → include/min_max.h
File renamed without changes
0  object_pool.h → include/object_pool.h
File renamed without changes
161 trace_defs.h → include/trace_defs.h
@@ -18,13 +18,14 @@ Copyright 2012 Yotam Rubin <yotamrubin@gmail.com>
18 18 #ifndef __TRACE_DEFS_H__
19 19 #define __TRACE_DEFS_H__
20 20
  21 +#include "config.h"
  22 +
21 23 #ifdef __cplusplus
22 24 extern "C" {
23 25 #endif
24 26
25 27 #define MAX_METADATA_SIZE (0x1000000)
26 28 #define TRACE_BUFFER_NUM_RECORDS (3)
27   -#define TRACE_RECORD_BUFFER_RECS 0x100000
28 29
29 30
30 31 #define TRACE_SEVERITY_DEF \
@@ -48,19 +49,19 @@ TRACE_SEVERITY_DEF
48 49
49 50 static inline int trace_strcmp(const char *s1, const char *s2)
50 51 {
51   - /* Move s1 and s2 to the first differing characters
52   - in each string, or the ends of the strings if they
53   - are identical. */
54   - while (*s1 != '\0' && *s1 == *s2) {
55   - s1++;
56   - s2++;
57   - }
58   - /* Compare the characters as unsigned char and
59   - return the difference. */
60   - const unsigned char uc1 = (*(const unsigned char *) s1);
61   - const unsigned char uc2 = (*(const unsigned char *) s2);
62   - return ((uc1 < uc2) ? -1 : (uc1 > uc2));
63   - }
  52 + /* Move s1 and s2 to the first differing characters
  53 + in each string, or the ends of the strings if they
  54 + are identical. */
  55 + while (*s1 != '\0' && *s1 == *s2) {
  56 + s1++;
  57 + s2++;
  58 + }
  59 + /* Compare the characters as unsigned char and
  60 + return the difference. */
  61 + const unsigned char uc1 = (*(const unsigned char *) s1);
  62 + const unsigned char uc2 = (*(const unsigned char *) s2);
  63 + return ((uc1 < uc2) ? -1 : (uc1 > uc2));
  64 +}
64 65
65 66 #define TRACE_SEV_X(num, name) \
66 67 if (trace_strcmp(function_name, #name) == 0) { \
@@ -74,13 +75,13 @@ static inline enum trace_severity trace_function_name_to_severity(const char *fu
74 75 }
75 76
76 77 enum trace_rec_type {
77   - TRACE_REC_TYPE_UNKNOWN = 0,
78   - TRACE_REC_TYPE_TYPED = 1,
79   - TRACE_REC_TYPE_FILE_HEADER = 2,
80   - TRACE_REC_TYPE_METADATA_HEADER = 3,
81   - TRACE_REC_TYPE_METADATA_PAYLOAD = 4,
82   - TRACE_REC_TYPE_DUMP_HEADER = 5,
83   - TRACE_REC_TYPE_BUFFER_CHUNK = 6,
  78 + TRACE_REC_TYPE_UNKNOWN = 0,
  79 + TRACE_REC_TYPE_TYPED = 1,
  80 + TRACE_REC_TYPE_FILE_HEADER = 2,
  81 + TRACE_REC_TYPE_METADATA_HEADER = 3,
  82 + TRACE_REC_TYPE_METADATA_PAYLOAD = 4,
  83 + TRACE_REC_TYPE_DUMP_HEADER = 5,
  84 + TRACE_REC_TYPE_BUFFER_CHUNK = 6,
84 85 TRACE_REC_TYPE_END_OF_FILE = 7
85 86 };
86 87
@@ -96,21 +97,21 @@ enum trace_log_descriptor_kind {
96 97
97 98
98 99 enum trace_termination_type {
99   - TRACE_TERMINATION_LAST = 1,
100   - TRACE_TERMINATION_FIRST = 2
  100 + TRACE_TERMINATION_LAST = 1,
  101 + TRACE_TERMINATION_FIRST = 2
101 102 };
102 103
103 104 #define TRACE_MACHINE_ID_SIZE 0x18
104 105
105 106 static inline int trace_compare_generation(unsigned int a, unsigned int b)
106 107 {
107   - if (a >= 0xc0000000 && b < 0x40000000)
108   - return 1;
109   - if (b > a)
110   - return 1;
111   - if (b < a)
112   - return -1;
113   - return 0;
  108 + if (a >= 0xc0000000 && b < 0x40000000)
  109 + return 1;
  110 + if (b > a)
  111 + return 1;
  112 + if (b < a)
  113 + return -1;
  114 + return 0;
114 115 }
115 116
116 117 enum trace_file_type {
@@ -143,61 +144,61 @@ struct trace_type_definition {
143 144 };
144 145
145 146 struct trace_record {
146   - /* 20 bytes header */
147   - unsigned long long ts;
148   - unsigned short int pid;
149   - unsigned short int tid;
  147 + /* 20 bytes header */
  148 + unsigned long long ts;
  149 + unsigned short int pid;
  150 + unsigned short int tid;
150 151 short nesting;
151   - unsigned termination:2;
152   - unsigned reserved:6;
153   - unsigned severity:4;
154   - unsigned rec_type:4;
155   - unsigned int generation;
156   -
157   - /* 44 bytes payload */
158   - union trace_record_u {
159   - unsigned char payload[TRACE_RECORD_PAYLOAD_SIZE];
160   - struct trace_record_typed {
161   - unsigned int log_id;
162   - unsigned char payload[0];
163   - } typed;
164   - struct trace_record_file_header {
165   - unsigned char machine_id[TRACE_MACHINE_ID_SIZE];
  152 + unsigned termination:2;
  153 + unsigned reserved:6;
  154 + unsigned severity:4;
  155 + unsigned rec_type:4;
  156 + unsigned int generation;
  157 +
  158 + /* 44 bytes payload */
  159 + union trace_record_u {
  160 + unsigned char payload[TRACE_RECORD_PAYLOAD_SIZE];
  161 + struct trace_record_typed {
  162 + unsigned int log_id;
  163 + unsigned char payload[0];
  164 + } typed;
  165 + struct trace_record_file_header {
  166 + unsigned char machine_id[TRACE_MACHINE_ID_SIZE];
166 167 unsigned long long boot_time;
167   - } file_header;
168   - struct trace_record_metadata {
169   - unsigned int metadata_size_bytes;
170   - } metadata;
171   - struct trace_record_dump_header {
172   - unsigned int prev_dump_offset;
173   - unsigned int total_dump_size;
  168 + } file_header;
  169 + struct trace_record_metadata {
  170 + unsigned int metadata_size_bytes;
  171 + } metadata;
  172 + struct trace_record_dump_header {
  173 + unsigned int prev_dump_offset;
  174 + unsigned int total_dump_size;
174 175 unsigned int first_chunk_offset;
175   - } dump_header;
176   - struct trace_record_buffer_dump {
177   - unsigned int last_metadata_offset;
178   - unsigned int prev_chunk_offset;
179   - unsigned int dump_header_offset;
180   - unsigned long long ts;
181   - unsigned int records;
182   - unsigned int severity_type;
183   - } buffer_chunk;
184   - } __attribute__((packed)) u;
  176 + } dump_header;
  177 + struct trace_record_buffer_dump {
  178 + unsigned int last_metadata_offset;
  179 + unsigned int prev_chunk_offset;
  180 + unsigned int dump_header_offset;
  181 + unsigned long long ts;
  182 + unsigned int records;
  183 + unsigned int severity_type;
  184 + } buffer_chunk;
  185 + } __attribute__((packed)) u;
185 186 } __attribute__((packed));
186   -
  187 +
187 188 enum trace_param_desc_flags {
188   - TRACE_PARAM_FLAG_NUM_8 = 0x001,
189   - TRACE_PARAM_FLAG_NUM_16 = 0x002,
190   - TRACE_PARAM_FLAG_NUM_32 = 0x004,
191   - TRACE_PARAM_FLAG_NUM_64 = 0x008,
192   - TRACE_PARAM_FLAG_VARRAY = 0x010,
193   - TRACE_PARAM_FLAG_CSTR = 0x020,
194   -
195   - TRACE_PARAM_FLAG_STR = 0x040,
196   - TRACE_PARAM_FLAG_BLOB = 0x080,
197   -
198   - TRACE_PARAM_FLAG_UNSIGNED = 0x100,
199   - TRACE_PARAM_FLAG_HEX = 0x200,
200   - TRACE_PARAM_FLAG_ZERO = 0x400,
  189 + TRACE_PARAM_FLAG_NUM_8 = 0x001,
  190 + TRACE_PARAM_FLAG_NUM_16 = 0x002,
  191 + TRACE_PARAM_FLAG_NUM_32 = 0x004,
  192 + TRACE_PARAM_FLAG_NUM_64 = 0x008,
  193 + TRACE_PARAM_FLAG_VARRAY = 0x010,
  194 + TRACE_PARAM_FLAG_CSTR = 0x020,
  195 +
  196 + TRACE_PARAM_FLAG_STR = 0x040,
  197 + TRACE_PARAM_FLAG_BLOB = 0x080,
  198 +
  199 + TRACE_PARAM_FLAG_UNSIGNED = 0x100,
  200 + TRACE_PARAM_FLAG_HEX = 0x200,
  201 + TRACE_PARAM_FLAG_ZERO = 0x400,
201 202 TRACE_PARAM_FLAG_ENUM = 0x800,
202 203 TRACE_PARAM_FLAG_RECORD = 0x1000,
203 204 TRACE_PARAM_FLAG_ENTER = 0x2000,
22 trace_lib.h → include/trace_lib.h
@@ -22,18 +22,28 @@ Copyright 2012 Yotam Rubin <yotamrubin@gmail.com>
22 22 extern "C" {
23 23 #endif
24 24
25   -#define TRACE_SHM_ID "_trace_shm_"
  25 +#include "config.h"
26 26 #include "trace_defs.h"
27 27 #include <sys/syscall.h>
28 28 #include <time.h>
29 29
30   -#ifndef _UNISTD_H
  30 +#ifdef ANDROID
  31 +#ifndef _UNISTD_H
31 32 #ifdef __cplusplus
32   - extern long int syscall (long int __sysno, ...) throw ();
  33 + extern int syscall (int __sysno, ...) throw ();
33 34 #else
  35 + extern int syscall(int __sysno, ...);
  36 +#endif //__clusplus
  37 +#endif //_UNISTD
  38 +#else //ANDROID
  39 +#ifndef _SYS_SYSCALL_H_
  40 +#ifdef __cplusplus
  41 + extern long int syscall (long int __sysno, ...) throw ();
  42 +#else
34 43 extern long int syscall(long int __sysno, ...);
35   -#endif
36   -#endif
  44 +#endif //__cplusplus
  45 +#endif //_SYS_SYSCALL_H_
  46 +#endif //ANDROID
37 47
38 48 #define _O_RDONLY 00000000
39 49 extern struct trace_buffer *current_trace_buffer;
@@ -41,7 +51,7 @@ extern struct trace_log_descriptor __static_log_information_start;
41 51 extern struct trace_log_descriptor __static_log_information_end;
42 52 extern struct trace_type_definition *__type_information_start;
43 53 extern __thread unsigned short trace_current_nesting;
44   -
  54 +
45 55 static inline unsigned short int trace_get_pid(void)
46 56 {
47 57 static __thread int pid_cache = 0;
0  trace_metadata_util.h → include/trace_metadata_util.h
File renamed without changes
0  trace_parser.h → include/trace_parser.h
File renamed without changes
0  trace_user.h → include/trace_user.h
File renamed without changes
587 interactive_reader/_trace_parser_ctypes.py
... ... @@ -1,587 +0,0 @@
1   -from ctypes import *
2   -
3   -STRING = c_char_p
4   -
5   -
6   -class trace_type_definition(Structure):
7   - pass
8   -
9   -# values for enumeration 'trace_type_id'
10   -TRACE_TYPE_ID_ENUM = 1
11   -TRACE_TYPE_ID_RECORD = 2
12   -TRACE_TYPE_ID_TYPEDEF = 3
13   -trace_type_id = c_int # enum
14   -class N21trace_type_definition4DOT_30E(Union):
15   - pass
16   -class trace_enum_value(Structure):
17   - pass
18   -N21trace_type_definition4DOT_30E._fields_ = [
19   - ('params', c_void_p),
20   - ('enum_values', POINTER(trace_enum_value)),
21   -]
22   -trace_type_definition._anonymous_ = ['_0']
23   -trace_type_definition._fields_ = [
24   - ('type_id', trace_type_id),
25   - ('type_name', STRING),
26   - ('_0', N21trace_type_definition4DOT_30E),
27   -]
28   -trace_enum_value._fields_ = [
29   - ('name', STRING),
30   - ('value', c_uint),
31   -]
32   -class trace_record(Structure):
33   - pass
34   -class trace_record_u(Union):
35   - pass
36   -class trace_record_typed(Structure):
37   - pass
38   -trace_record_typed._fields_ = [
39   - ('log_id', c_uint),
40   - ('payload', c_ubyte * 0),
41   -]
42   -class trace_record_file_header(Structure):
43   - pass
44   -trace_record_file_header._fields_ = [
45   - ('machine_id', c_ubyte * 24),
46   - ('boot_time', c_ulonglong),
47   -]
48   -class trace_record_metadata(Structure):
49   - pass
50   -trace_record_metadata._fields_ = [
51   - ('metadata_size_bytes', c_uint),
52   -]
53   -class trace_record_dump_header(Structure):
54   - pass
55   -trace_record_dump_header._fields_ = [
56   - ('prev_dump_offset', c_uint),
57   - ('total_dump_size', c_uint),
58   - ('first_chunk_offset', c_uint),
59   -]
60   -class trace_record_buffer_dump(Structure):
61   - pass
62   -trace_record_buffer_dump._fields_ = [
63   - ('last_metadata_offset', c_uint),
64   - ('prev_chunk_offset', c_uint),
65   - ('dump_header_offset', c_uint),
66   - ('ts', c_ulonglong),
67   - ('records', c_uint),
68   - ('severity_type', c_uint),
69   -]
70   -trace_record_u._pack_ = 1
71   -trace_record_u._fields_ = [
72   - ('payload', c_ubyte * 44),
73   - ('typed', trace_record_typed),
74   - ('file_header', trace_record_file_header),
75   - ('metadata', trace_record_metadata),
76   - ('dump_header', trace_record_dump_header),
77   - ('buffer_chunk', trace_record_buffer_dump),
78   -]
79   -trace_record._fields_ = [
80   - ('ts', c_ulonglong),
81   - ('pid', c_ushort),
82   - ('tid', c_ushort),
83   - ('nesting', c_short),
84   - ('termination', c_uint, 2),
85   - ('reserved', c_uint, 6),
86   - ('severity', c_uint, 4),
87   - ('rec_type', c_uint, 4),
88   - ('generation', c_uint),
89   - ('u', trace_record_u),
90   -]
91   -class trace_param_descriptor(Structure):
92   - pass
93   -class N22trace_param_descriptor4DOT_31E(Union):
94   - pass
95   -N22trace_param_descriptor4DOT_31E._fields_ = [
96   - ('str', STRING),
97   - ('const_str', STRING),
98   - ('type_name', STRING),
99   -]
100   -trace_param_descriptor._anonymous_ = ['_0']
101   -trace_param_descriptor._fields_ = [
102   - ('flags', c_ulong),
103   - ('param_name', STRING),
104   - ('_0', N22trace_param_descriptor4DOT_31E),
105   -]
106   -class trace_log_descriptor(Structure):
107   - pass
108   -
109   -# values for enumeration 'trace_log_descriptor_kind'
110   -TRACE_LOG_DESCRIPTOR_KIND_FUNC_ENTRY = 0
111   -TRACE_LOG_DESCRIPTOR_KIND_FUNC_LEAVE = 1
112   -TRACE_LOG_DESCRIPTOR_KIND_EXPLICIT = 2
113   -trace_log_descriptor_kind = c_int # enum
114   -trace_log_descriptor._fields_ = [
115   - ('kind', trace_log_descriptor_kind),
116   - ('params', POINTER(trace_param_descriptor)),
117   -]
118   -class trace_metadata_region(Structure):
119   - pass
120   -trace_metadata_region._fields_ = [
121   - ('name', c_char * 256),
122   - ('base_address', c_void_p),
123   - ('log_descriptor_count', c_ulong),
124   - ('type_definition_count', c_ulong),
125   - ('data', c_char * 0),
126   -]
127   -class trace_parser_buffer_context(Structure):
128   - pass
129   -trace_parser_buffer_context._fields_ = [
130   - ('metadata', POINTER(trace_metadata_region)),
131   - ('metadata_size', c_ulong),
132   - ('current_metadata_offset', c_ulong),
133   - ('metadata_read', c_ulong),
134   - ('descriptors', POINTER(trace_log_descriptor)),
135   - ('types', POINTER(trace_type_definition)),
136   - ('name', c_char * 256),
137   - ('id', c_uint),
138   -]
139   -class trace_record_accumulator(Structure):
140   - pass
141   -trace_record_accumulator._fields_ = [
142   - ('accumulated_data', c_char * 40960),
143   - ('data_offset', c_uint),
144   - ('tid', c_ushort),
145   -]
146   -class BufferParseContextList_s(Structure):
147   - pass
148   -BufferParseContextList_s._fields_ = [
149   - ('element_count', c_int),
150   - ('elements', trace_parser_buffer_context * 20),
151   -]
152   -class RecordsAccumulatorList_s(Structure):
153   - pass
154   -RecordsAccumulatorList_s._fields_ = [
155   - ('element_count', c_int),
156   - ('elements', trace_record_accumulator * 20),
157   -]
158   -class parser_complete_typed_record(Structure):
159   - pass
160   -parser_complete_typed_record._fields_ = [
161   - ('record', POINTER(trace_record)),
162   - ('buffer', POINTER(trace_parser_buffer_context)),
163   -]
164   -class trace_file_info(Structure):
165   - pass
166   -trace_file_info._fields_ = [
167   - ('filename', c_char * 256),
168   - ('machine_id', c_char * 256),
169   - ('boot_time', c_long),
170   - ('fd', c_int),
171   -]
172   -class record_dump_context_s(Structure):
173   - pass
174   -record_dump_context_s._fields_ = [
175   - ('start_offset', c_longlong),
176   - ('current_offset', c_longlong),
177   - ('end_offset', c_longlong),
178   -]
179   -class buffer_dump_context_s(Structure):
180   - pass
181   -buffer_dump_context_s._fields_ = [
182   - ('record_dump_contexts', record_dump_context_s * 150),
183   - ('end_offset', c_longlong),
184   - ('previous_dump_offset', c_longlong),
185   - ('file_offset', c_longlong),
186   - ('num_chunks', c_uint),
187   -]
188   -class trace_record_matcher_spec_s(Structure):
189   - pass
190   -
191   -# values for enumeration 'trace_record_matcher_type'
192   -TRACE_MATCHER_TRUE = 0
193   -TRACE_MATCHER_FALSE = 1
194   -TRACE_MATCHER_OR = 2
195   -TRACE_MATCHER_AND = 3
196   -TRACE_MATCHER_NOT = 4
197   -TRACE_MATCHER_PID = 5
198   -TRACE_MATCHER_TID = 6
199   -TRACE_MATCHER_TIMERANGE = 7
200   -TRACE_MATCHER_LOGID = 8
201   -TRACE_MATCHER_SEVERITY = 9
202   -TRACE_MATCHER_FUNCTION = 10
203   -TRACE_MATCHER_TYPE = 11
204   -TRACE_MATCHER_LOG_PARAM_VALUE = 12
205   -TRACE_MATCHER_LOG_NAMED_PARAM_VALUE = 13
206   -TRACE_MATCHER_PROCESS_NAME = 14
207   -trace_record_matcher_type = c_int # enum
208   -class trace_record_matcher_data_u(Union):
209   - pass
210   -class trace_time_range(Structure):
211   - pass
212   -trace_time_range._fields_ = [
213   - ('start', c_ulonglong),
214   - ('end', c_ulonglong),
215   -]
216   -class trace_matcher_named_param_value(Structure):
217   - pass
218   -trace_matcher_named_param_value._fields_ = [
219   - ('param_name', c_char * 256),
220   - ('param_value', c_ulonglong),
221   -]
222   -class trace_record_matcher_binary_operator_params(Structure):
223   - pass
224   -trace_record_matcher_binary_operator_params._fields_ = [
225   - ('a', POINTER(trace_record_matcher_spec_s)),
226   - ('b', POINTER(trace_record_matcher_spec_s)),
227   -]
228   -class trace_record_matcher_unary_operator_params(Structure):
229   - pass
230   -trace_record_matcher_unary_operator_params._fields_ = [
231   - ('param', POINTER(trace_record_matcher_spec_s)),
232   -]
233   -trace_record_matcher_data_u._fields_ = [
234   - ('pid', c_ushort),
235   - ('tid', c_ushort),
236   - ('log_id', c_uint),
237   - ('severity', c_uint),
238   - ('time_range', trace_time_range),
239   - ('function_name', c_char * 256),
240   - ('type_name', c_char * 256),
241   - ('process_name', c_char * 256),
242   - ('param_value', c_ulonglong),
243   - ('named_param_value', trace_matcher_named_param_value),
244   - ('binary_operator_parameters', trace_record_matcher_binary_operator_params),
245   - ('unary_operator_parameters', trace_record_matcher_unary_operator_params),
246   -]
247   -trace_record_matcher_spec_s._fields_ = [
248   - ('type', trace_record_matcher_type),
249   - ('u', trace_record_matcher_data_u),
250   -]
251   -class trace_parser(Structure):
252   - pass
253   -BufferParseContextList = BufferParseContextList_s
254   -RecordsAccumulatorList = RecordsAccumulatorList_s
255   -
256   -# values for enumeration 'trace_parser_event_e'
257   -TRACE_PARSER_COMPLETE_TYPED_RECORD_PROCESSED = 0
258   -TRACE_PARSER_MATCHED_RECORD = 1
259   -TRACE_PARSER_SEARCHING_METADATA = 2
260   -TRACE_PARSER_FOUND_METADATA = 3
261   -trace_parser_event_e = c_int # enum
262   -trace_parser_event_handler_t = CFUNCTYPE(None, POINTER(trace_parser), trace_parser_event_e, c_void_p, c_void_p)
263   -class _IO_FILE(Structure):
264   - pass
265   -FILE = _IO_FILE
266   -
267   -# values for enumeration 'trace_input_stream_type'
268   -TRACE_INPUT_STREAM_TYPE_NONSEEKABLE = 0
269   -TRACE_INPUT_STREAM_TYPE_SEEKABLE_FILE = 1
270   -trace_input_stream_type = c_int # enum
271   -trace_parser._fields_ = [
272   - ('fd', c_int),
273   - ('file_info', trace_file_info),
274   - ('buffer_contexts', BufferParseContextList),
275   - ('records_accumulators', RecordsAccumulatorList),
276   - ('buffer_dump_context', buffer_dump_context_s),
277   - ('event_handler', trace_parser_event_handler_t),
278   - ('max_ts', c_ulonglong),
279   - ('arg', c_void_p),
280   - ('out_file', POINTER(FILE)),
281   - ('color', c_int),
282   - ('always_hex', c_int),
283   - ('indent', c_int),
284   - ('relative_ts', c_int),
285   - ('record_filter', trace_record_matcher_spec_s),
286   - ('ignored_records_count', c_uint),
287   - ('stream_type', trace_input_stream_type),
288   -]
289   -class _G_fpos_t(Structure):
290   - pass
291   -__off_t = c_long
292   -class __mbstate_t(Structure):
293   - pass
294   -class N11__mbstate_t4DOT_26E(Union):
295   - pass
296   -N11__mbstate_t4DOT_26E._fields_ = [
297   - ('__wch', c_uint),
298   - ('__wchb', c_char * 4),
299   -]
300   -__mbstate_t._fields_ = [
301   - ('__count', c_int),
302   - ('__value', N11__mbstate_t4DOT_26E),
303   -]
304   -_G_fpos_t._fields_ = [
305   - ('__pos', __off_t),
306   - ('__state', __mbstate_t),
307   -]
308   -class _G_fpos64_t(Structure):
309   - pass
310   -__off64_t = c_long
311   -_G_fpos64_t._fields_ = [
312   - ('__pos', __off64_t),
313   - ('__state', __mbstate_t),
314   -]
315   -class _IO_jump_t(Structure):
316   - pass
317   -_IO_jump_t._fields_ = [
318   -]
319   -class _IO_marker(Structure):
320   - pass
321   -_IO_marker._fields_ = [
322   - ('_next', POINTER(_IO_marker)),
323   - ('_sbuf', POINTER(_IO_FILE)),
324   - ('_pos', c_int),
325   -]
326   -_IO_lock_t = None
327   -size_t = c_ulong
328   -_IO_FILE._fields_ = [
329   - ('_flags', c_int),
330   - ('_IO_read_ptr', STRING),
331   - ('_IO_read_end', STRING),
332   - ('_IO_read_base', STRING),
333   - ('_IO_write_base', STRING),
334   - ('_IO_write_ptr', STRING),
335   - ('_IO_write_end', STRING),
336   - ('_IO_buf_base', STRING),
337   - ('_IO_buf_end', STRING),
338   - ('_IO_save_base', STRING),
339   - ('_IO_backup_base', STRING),
340   - ('_IO_save_end', STRING),
341   - ('_markers', POINTER(_IO_marker)),
342   - ('_chain', POINTER(_IO_FILE)),
343   - ('_fileno', c_int),
344   - ('_flags2', c_int),
345   - ('_old_offset', __off_t),
346   - ('_cur_column', c_ushort),
347   - ('_vtable_offset', c_byte),
348   - ('_shortbuf', c_char * 1),
349   - ('_lock', POINTER(_IO_lock_t)),
350   - ('_offset', __off64_t),
351   - ('__pad1', c_void_p),
352   - ('__pad2', c_void_p),
353   - ('__pad3', c_void_p),
354   - ('__pad4', c_void_p),
355   - ('__pad5', size_t),
356   - ('_mode', c_int),
357   - ('_unused2', c_char * 20),
358   -]
359   -class _IO_FILE_plus(Structure):
360   - pass
361   -_IO_FILE_plus._fields_ = [
362   -]
363   -class _IO_cookie_io_functions_t(Structure):
364   - pass
365   -__ssize_t = c_long
366   -__io_read_fn = CFUNCTYPE(__ssize_t, c_void_p, STRING, size_t)
367   -__io_write_fn = CFUNCTYPE(__ssize_t, c_void_p, STRING, size_t)
368   -__io_seek_fn = CFUNCTYPE(c_int, c_void_p, POINTER(__off64_t), c_int)
369   -__io_close_fn = CFUNCTYPE(c_int, c_void_p)
370   -_IO_cookie_io_functions_t._fields_ = [
371   - ('read', POINTER(__io_read_fn)),
372   - ('write', POINTER(__io_write_fn)),
373   - ('seek', POINTER(__io_seek_fn)),
374   - ('close', POINTER(__io_close_fn)),
375   -]
376   -class _IO_cookie_file(Structure):
377   - pass
378   -_IO_cookie_file._fields_ = [
379   -]
380   -class _pthread_cleanup_buffer(Structure):
381   - pass
382   -_pthread_cleanup_buffer._fields_ = [
383   - ('__routine', CFUNCTYPE(None, c_void_p)),
384   - ('__arg', c_void_p),
385   - ('__canceltype', c_int),
386   - ('__prev', POINTER(_pthread_cleanup_buffer)),
387   -]
388   -class _4DOT_23(Structure):
389   - pass
390   -class N4DOT_234DOT_24E(Structure):
391   - pass
392   -__jmp_buf = c_long * 8
393   -N4DOT_234DOT_24E._fields_ = [
394   - ('__cancel_jmp_buf', __jmp_buf),
395   - ('__mask_was_saved', c_int),
396   -]
397   -_4DOT_23._fields_ = [
398   - ('__cancel_jmp_buf', N4DOT_234DOT_24E * 1),
399   - ('__pad', c_void_p * 4),
400   -]
401   -class __pthread_cleanup_frame(Structure):
402   - pass
403   -__pthread_cleanup_frame._fields_ = [
404   - ('__cancel_routine', CFUNCTYPE(None, c_void_p)),
405   - ('__cancel_arg', c_void_p),
406   - ('__do_it', c_int),
407   - ('__cancel_type', c_int),
408   -]
409   -class __jmp_buf_tag(Structure):
410   - pass
411   -__jmp_buf_tag._fields_ = [
412   -]
413   -class obstack(Structure):
414   - pass
415   -obstack._fields_ = [
416   -]
417   -class timespec(Structure):
418   - pass
419   -__time_t = c_long
420   -timespec._fields_ = [
421   - ('tv_sec', __time_t),
422   - ('tv_nsec', c_long),
423   -]
424   -class tm(Structure):
425   - pass
426   -tm._fields_ = [
427   - ('tm_sec', c_int),
428   - ('tm_min', c_int),
429   - ('tm_hour', c_int),
430   - ('tm_mday', c_int),
431   - ('tm_mon', c_int),
432   - ('tm_year', c_int),
433   - ('tm_wday', c_int),
434   - ('tm_yday', c_int),
435   - ('tm_isdst', c_int),
436   - ('tm_gmtoff', c_long),
437   - ('tm_zone', STRING),
438   -]
439   -class itimerspec(Structure):
440   - pass
441   -itimerspec._fields_ = [
442   - ('it_interval', timespec),
443   - ('it_value', timespec),
444   -]
445   -class sigevent(Structure):
446   - pass
447   -sigevent._fields_ = [
448   -]
449   -class __pthread_internal_list(Structure):
450   - pass
451   -__pthread_internal_list._fields_ = [
452   - ('__prev', POINTER(__pthread_internal_list)),
453   - ('__next', POINTER(__pthread_internal_list)),
454   -]
455   -class __pthread_mutex_s(Structure):
456   - pass
457   -__pthread_list_t = __pthread_internal_list
458   -__pthread_mutex_s._fields_ = [
459   - ('__lock', c_int),
460   - ('__count', c_uint),
461   - ('__owner', c_int),
462   - ('__nusers', c_uint),
463   - ('__kind', c_int),
464   - ('__spins', c_int),
465   - ('__list', __pthread_list_t),
466   -]
467   -class N14pthread_cond_t3DOT_6E(Structure):
468   - pass
469   -N14pthread_cond_t3DOT_6E._fields_ = [
470   - ('__lock', c_int),
471   - ('__futex', c_uint),
472   - ('__total_seq', c_ulonglong),
473   - ('__wakeup_seq', c_ulonglong),
474   - ('__woken_seq', c_ulonglong),
475   - ('__mutex', c_void_p),
476   - ('__nwaiters', c_uint),
477   - ('__broadcast_seq', c_uint),
478   -]
479   -class N16pthread_rwlock_t3DOT_9E(Structure):
480   - pass
481   -N16pthread_rwlock_t3DOT_9E._fields_ = [
482   - ('__lock', c_int),
483   - ('__nr_readers', c_uint),
484   - ('__readers_wakeup', c_uint),
485   - ('__writer_wakeup', c_uint),
486   - ('__nr_readers_queued', c_uint),
487   - ('__nr_writers_queued', c_uint),
488   - ('__writer', c_int),
489   - ('__shared', c_int),
490   - ('__pad1', c_ulong),
491   - ('__pad2', c_ulong),
492   - ('__flags', c_uint),
493   -]
494   -class sched_param(Structure):
495   - pass
496   -sched_param._fields_ = [
497   - ('__sched_priority', c_int),
498   -]
499   -class __sched_param(Structure):
500   - pass
501   -__sched_param._fields_ = [
502   - ('__sched_priority', c_int),
503   -]
504   -class cpu_set_t(Structure):
505   - pass
506   -__cpu_mask = c_ulong
507   -cpu_set_t._fields_ = [
508   - ('__bits', __cpu_mask * 16),
509   -]
510   -class __fsid_t(Structure):
511   - pass
512   -__fsid_t._fields_ = [
513   - ('__val', c_int * 2),
514   -]
515   -class __locale_struct(Structure):
516   - pass
517   -class __locale_data(Structure):
518   - pass
519   -__locale_struct._fields_ = [
520   - ('__locales', POINTER(__locale_data) * 13),
521   - ('__ctype_b', POINTER(c_ushort)),
522   - ('__ctype_tolower', POINTER(c_int)),
523   - ('__ctype_toupper', POINTER(c_int)),
524   - ('__names', STRING * 13),
525   -]
526   -__locale_data._fields_ = [
527   -]
528   -class __va_list_tag(Structure):
529   - pass
530   -__va_list_tag._fields_ = [
531   -]
532   -__all__ = ['TRACE_TYPE_ID_ENUM', 'N11__mbstate_t4DOT_26E',
533   - 'cpu_set_t', '__pthread_mutex_s', 'trace_type_definition',
534   - 'TRACE_MATCHER_TRUE', 'N14pthread_cond_t3DOT_6E',
535   - '__fsid_t', 'FILE', '__off64_t', 'size_t',
536   - 'trace_file_info', 'TRACE_MATCHER_TYPE', 'trace_parser',
537   - 'N4DOT_234DOT_24E', 'RecordsAccumulatorList', 'tm',
538   - '__cpu_mask', 'TRACE_MATCHER_FUNCTION', 'trace_record',
539   - 'TRACE_INPUT_STREAM_TYPE_NONSEEKABLE',
540   - '__pthread_internal_list', 'TRACE_MATCHER_PID',
541   - 'trace_input_stream_type', 'TRACE_MATCHER_NOT', '__time_t',
542   - 'buffer_dump_context_s', '_G_fpos64_t',
543   - 'trace_record_metadata', 'trace_enum_value', '_IO_jump_t',
544   - 'TRACE_INPUT_STREAM_TYPE_SEEKABLE_FILE',
545   - 'RecordsAccumulatorList_s', 'TRACE_MATCHER_PROCESS_NAME',
546   - '__io_close_fn', '__va_list_tag', 'sigevent',
547   - 'trace_log_descriptor_kind', 'trace_metadata_region',
548   - 'trace_time_range', 'TRACE_TYPE_ID_RECORD',
549   - 'trace_param_descriptor', 'TRACE_MATCHER_SEVERITY',
550   - 'TRACE_MATCHER_LOGID', '__jmp_buf_tag',
551   - 'TRACE_MATCHER_TIMERANGE', '_G_fpos_t',
552   - '_pthread_cleanup_buffer', '_IO_cookie_io_functions_t',
553   - 'trace_record_dump_header', '__locale_data',
554   - '_IO_FILE_plus',
555   - 'TRACE_PARSER_COMPLETE_TYPED_RECORD_PROCESSED',
556   - 'BufferParseContextList_s', '__pthread_list_t',
557   - 'TRACE_PARSER_MATCHED_RECORD',
558   - 'TRACE_LOG_DESCRIPTOR_KIND_FUNC_LEAVE', 'timespec',
559   - 'N16pthread_rwlock_t3DOT_9E',
560   - 'parser_complete_typed_record', '__sched_param',
561   - 'BufferParseContextList', 'trace_record_u', '__off_t',
562   - 'record_dump_context_s', 'TRACE_PARSER_SEARCHING_METADATA',
563   - '__ssize_t', 'obstack', 'trace_record_file_header',
564   - '_IO_cookie_file',
565   - 'trace_record_matcher_binary_operator_params',
566   - 'TRACE_MATCHER_FALSE', '__mbstate_t',
567   - 'TRACE_MATCHER_LOG_PARAM_VALUE', '__io_seek_fn',
568   - 'trace_parser_event_e', '_4DOT_23',
569   - 'TRACE_TYPE_ID_TYPEDEF', 'TRACE_MATCHER_TID', '_IO_FILE',
570   - 'TRACE_LOG_DESCRIPTOR_KIND_FUNC_ENTRY', 'sched_param',
571   - '__locale_struct', '__io_read_fn', 'trace_type_id',
572   - 'trace_parser_buffer_context', 'trace_record_buffer_dump',
573   - '__jmp_buf', 'trace_record_matcher_unary_operator_params',
574   - '__pthread_cleanup_frame',
575   - 'trace_matcher_named_param_value',
576   - 'TRACE_MATCHER_LOG_NAMED_PARAM_VALUE',
577   - 'trace_record_matcher_data_u', '_IO_marker',
578   - 'N21trace_type_definition4DOT_30E', 'TRACE_MATCHER_OR',
579   - 'trace_record_matcher_spec_s', '__io_write_fn',
580   - 'TRACE_PARSER_FOUND_METADATA',
581   - 'TRACE_LOG_DESCRIPTOR_KIND_EXPLICIT',
582   - 'trace_log_descriptor',
583   - 'N22trace_param_descriptor4DOT_31E', '_IO_lock_t',
584   - 'itimerspec', 'trace_record_accumulator',
585   - 'TRACE_MATCHER_AND', 'trace_record_typed',
586   - 'trace_record_matcher_type',
587   - 'trace_parser_event_handler_t']
0  halt.c → libtrace/halt.c
File renamed without changes
0  trace_metadata_util.c → libtrace/trace_metadata_util.c
File renamed without changes
0  trace_parser.c → libtrace/trace_parser.c
File renamed without changes
12 trace_user.c → libtrace/trace_user.c
@@ -26,13 +26,13 @@ Copyright 2012 Yotam Rubin <yotamrubin@gmail.com>
26 26 #include <string.h>
27 27 #include <libgen.h>
28 28
  29 +#include "config.h"
29 30 #include "macros.h"
30 31 #include "trace_lib.h"
31 32 #include "trace_user.h"
32 33
33 34 #include "halt.h"
34 35
35   -
36 36 struct trace_buffer *current_trace_buffer = NULL;
37 37 __thread unsigned short trace_current_nesting;
38 38
@@ -252,8 +252,9 @@ static void map_static_log_data(const char *buffer_name)
252 252 unsigned int type_definition_count;
253 253 unsigned int enum_value_count;
254 254 static_log_alloc_size(log_descriptor_count, &total_log_descriptor_params, &type_definition_count, &enum_value_count, &alloc_size);
255   - snprintf(shm_name, sizeof(shm_name), "%s%d_static_trace_metadata", TRACE_SHM_ID, getpid());
256   - int shm_fd = shm_open(shm_name, O_CREAT | O_RDWR, 0660);
  255 + snprintf(shm_name, sizeof(shm_name), "%s%s%d_static_trace_metadata", SHM_PATH, TRACE_SHM_ID, getpid());
  256 + int shm_fd = open(shm_name, O_CREAT | O_RDWR, 0660);
  257 + printf("map_static_log_data %s\n",shm_name);
257 258 if (shm_fd < 0) {
258 259 return;
259 260 }
@@ -291,8 +292,9 @@ static void init_records_metadata(void)
291 292 static void map_dynamic_log_buffers()
292 293 {
293 294 char shm_name[0x100];
294   - snprintf(shm_name, sizeof(shm_name), "%s%d_dynamic_trace_data", TRACE_SHM_ID, getpid());
295   - int shm_fd = shm_open(shm_name, O_CREAT | O_RDWR, 0660);
  295 + snprintf(shm_name, sizeof(shm_name), "%s%s%d_dynamic_trace_data", SHM_PATH, TRACE_SHM_ID, getpid());
  296 + int shm_fd = open(shm_name, O_CREAT | O_RDWR, 0660);
  297 + printf("map_dynamic_log_buffers %s\n",shm_name);
296 298 if (shm_fd < 0) {
297 299 return;
298 300 }
43 trace_dumper/trace_dumper.c
@@ -14,22 +14,26 @@
14 14 #include <sys/uio.h>
15 15 #include <sys/time.h>
16 16 #include <sys/utsname.h>
17   -#include "../list_template.h"
18   -#include "filesystem.h"
19   -#include "../bool.h"
20   -#include "../trace_metadata_util.h"
21   -#include "../trace_parser.h"
22   -#include "../min_max.h"
23   -#include "../array_length.h"
24 17 #include <syslog.h>
25 18 #include <time.h>
26 19 #include <sys/sysinfo.h>
27   -#include "../trace_lib.h"
28   -#include "../trace_user.h"
  20 +
  21 +#include "config.h"
  22 +#include "list_template.h"
  23 +#include "filesystem.h"
  24 +#include "bool.h"
  25 +#include "trace_metadata_util.h"
  26 +#include "trace_parser.h"
  27 +#include "min_max.h"
  28 +#include "array_length.h"
  29 +#include "trace_lib.h"
  30 +#include "trace_user.h"
29 31
30 32 #define MAX_FILTER_SIZE (10)
31 33 #define METADATA_IOVEC_SIZE 2*(MAX_METADATA_SIZE/TRACE_RECORD_PAYLOAD_SIZE+1)
32 34
  35 +#define TRACE_FILE_MAX_RECORDS_PER_FILE 0x1000000
  36 +
33 37 struct trace_mapped_metadata {
34 38 struct iovec metadata_iovec[METADATA_IOVEC_SIZE];
35 39 struct trace_record metadata_payload_record;
@@ -83,7 +87,6 @@ CREATE_LIST_IMPLEMENTATION(BufferFilter, buffer_name_t);
83 87
84 88 #define TRACE_METADATA_IOVEC_SIZE (2*(MAX_METADATA_SIZE/TRACE_RECORD_PAYLOAD_SIZE+1))
85 89
86   -#define TRACE_FILE_MAX_RECORDS_PER_FILE 0x1000000
87 90 #define TRACE_FILE_MAX_RECORDS_PER_LOGDIR (TRACE_FILE_MAX_RECORDS_PER_FILE) * 10
88 91 #define TRACE_FILE_MAX_RECORDS_PER_CHUNK 0x10000
89 92
@@ -123,8 +126,6 @@ struct trace_dumper_configuration_s {
123 126
124 127 static struct trace_dumper_configuration_s trace_dumper_configuration;
125 128
126   -#define SHM_DIR "/dev/shm"
127   -
128 129 bool_t is_trace_shm_region(const char *shm_name)
129 130 {
130 131 if (strncmp(shm_name, TRACE_SHM_ID, strlen(TRACE_SHM_ID)) == 0) {
@@ -360,8 +361,8 @@ static int delete_shm_files(unsigned short pid)
360 361 int rc;
361 362 snprintf(dynamic_trace_filename, sizeof(dynamic_trace_filename), "_trace_shm_%d_dynamic_trace_data", pid);
362 363 snprintf(static_log_data_filename, sizeof(static_log_data_filename), "_trace_shm_%d_static_trace_metadata", pid);
363   - snprintf(full_dynamic_trace_filename, sizeof(full_dynamic_trace_filename), "%s/%s", SHM_DIR, dynamic_trace_filename);
364   - snprintf(full_static_log_data_filename, sizeof(full_static_log_data_filename), "%s/%s", SHM_DIR, static_log_data_filename);
  364 + snprintf(full_dynamic_trace_filename, sizeof(full_dynamic_trace_filename), "%s/%s", SHM_PATH, dynamic_trace_filename);
  365 + snprintf(full_static_log_data_filename, sizeof(full_static_log_data_filename), "%s/%s", SHM_PATH, static_log_data_filename);
365 366
366 367 rc = unlink(full_dynamic_trace_filename);
367 368 rc |= unlink(full_static_log_data_filename);
@@ -393,8 +394,8 @@ static int map_buffer(struct trace_dumper_configuration_s *conf, pid_t pid)
393 394 unsigned int dead = 0;
394 395 snprintf(dynamic_trace_filename, sizeof(dynamic_trace_filename), "_trace_shm_%d_dynamic_trace_data", pid);
395 396 snprintf(static_log_data_filename, sizeof(static_log_data_filename), "_trace_shm_%d_static_trace_metadata", pid);
396   - snprintf(full_dynamic_trace_filename, sizeof(full_dynamic_trace_filename), "%s/%s", SHM_DIR, dynamic_trace_filename);
397   - snprintf(full_static_log_data_filename, sizeof(full_static_log_data_filename), "%s/%s", SHM_DIR, static_log_data_filename);
  397 + snprintf(full_dynamic_trace_filename, sizeof(full_dynamic_trace_filename), "%s/%s", SHM_PATH, dynamic_trace_filename);
  398 + snprintf(full_static_log_data_filename, sizeof(full_static_log_data_filename), "%s/%s", SHM_PATH, static_log_data_filename);
398 399
399 400 int trace_region_size = get_file_size(full_dynamic_trace_filename);
400 401 if (trace_region_size <= 0) {
@@ -410,15 +411,17 @@ static int map_buffer(struct trace_dumper_configuration_s *conf, pid_t pid)
410 411 goto delete_shm_files;
411 412 }
412 413
413   - dynamic_fd = shm_open(dynamic_trace_filename, O_RDWR, 0);
  414 + dynamic_fd = open(full_dynamic_trace_filename, O_RDWR, 0);
  415 + printf("opened (1) %s\n", full_dynamic_trace_filename);
414 416 if (dynamic_fd < 0) {
415 417 ERROR("Unable to open dynamic buffer %s: %s", dynamic_trace_filename, strerror(errno));
416 418 rc = -1;
417 419 goto delete_shm_files;
418 420 }