##// END OF EJS Templates
Few cosmetic changes and lowered optim to -O2...
jeandet -
r400:9d5e16586c2c 3.2.0.22 R3++ draft
parent child
Show More
@@ -1,14 +1,14
1 cmake_minimum_required (VERSION 2.6)
1 cmake_minimum_required (VERSION 3.6)
2 project (LFR_FSW)
2 project (LFR_FSW)
3
3
4 if(NOT CMAKE_BUILD_TYPE)
4 if(NOT CMAKE_BUILD_TYPE)
5 set(CMAKE_BUILD_TYPE "Release" CACHE STRING
5 set(CMAKE_BUILD_TYPE "Release" CACHE STRING
6 "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
6 "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
7 endif(NOT CMAKE_BUILD_TYPE)
7 endif(NOT CMAKE_BUILD_TYPE)
8
8
9 set(LFR_BP_SRC ${CMAKE_CURRENT_SOURCE_DIR}/LFR_basic-parameters/basic_parameters.c)
9 set(LFR_BP_SRC ${CMAKE_CURRENT_SOURCE_DIR}/LFR_basic-parameters/basic_parameters.c)
10
10
11 SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/sparc")
11 SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/sparc")
12
12
13 add_subdirectory(libgcov)
13 add_subdirectory(libgcov)
14 add_subdirectory(src)
14 add_subdirectory(src)
@@ -1,17 +1,20
1 cmake_minimum_required(VERSION 3.6)
1 cmake_minimum_required(VERSION 3.6)
2 project(libgcov C)
2 project(libgcov C)
3 include(sparc-rtems)
3 include(sparc-rtems)
4 include(cppcheck)
4 include(cppcheck)
5
5
6 set(LIB_GCOV_SOURCES
6 set(LIB_GCOV_SOURCES
7 gcov-io.c
7 gcov-io.c
8 gcov-io.h
8 gcov-io.h
9 gcov-iov.h
9 gcov-iov.h
10 libgcov.c
10 libgcov.c
11 )
11 )
12
12 if(Coverage)
13 # add_definitions(-DGCOV_USE_EXIT)
14 add_definitions(-DGCOV_ENABLED)
15 endif()
13 add_library(gcov STATIC ${LIB_GCOV_SOURCES})
16 add_library(gcov STATIC ${LIB_GCOV_SOURCES})
14
17
15 add_custom_target(gcovr
18 add_custom_target(gcovr
16 COMMAND gcovr --exclude='.*gcov.*' --gcov-executable=${rtems_dir}/bin/sparc-rtems-gcov --object-directory ${CMAKE_BINARY_DIR} -r ${CMAKE_SOURCE_DIR} --html --html-details -o ${CMAKE_CURRENT_BINARY_DIR}/gcov.html && xdg-open ${CMAKE_CURRENT_BINARY_DIR}/gcov.html
19 COMMAND gcovr --exclude='.*gcov.*' --gcov-executable=${rtems_dir}/bin/sparc-rtems-gcov --object-directory ${CMAKE_BINARY_DIR} -r ${CMAKE_SOURCE_DIR} --html --html-details -o ${CMAKE_CURRENT_BINARY_DIR}/gcov.html && xdg-open ${CMAKE_CURRENT_BINARY_DIR}/gcov.html
17 )
20 )
@@ -1,488 +1,490
1 /* Test for GCC >= 3.4.4 && <= 4.4.6 */
1 /* Test for GCC >= 3.4.4 && <= 4.4.6 */
2 //#if ( ( __GNUC__ > 3 ) || \
2 //#if ( ( __GNUC__ > 3 ) || \
3 // ( __GNUC__ == 3 && __GNUC_MINOR__ > 4 )|| \
3 // ( __GNUC__ == 3 && __GNUC_MINOR__ > 4 )|| \
4 // ( __GNUC__ == 3 && __GNUC_MINOR__ == 4 && __GNUC_PATCHLEVEL__ >= 4 ) ) && \
4 // ( __GNUC__ == 3 && __GNUC_MINOR__ == 4 && __GNUC_PATCHLEVEL__ >= 4 ) ) && \
5 // ( ( __GNUC__ < 4 ) || \
5 // ( ( __GNUC__ < 4 ) || \
6 // ( __GNUC__ == 4 && __GNUC_MINOR__ < 4 )|| \
6 // ( __GNUC__ == 4 && __GNUC_MINOR__ < 4 )|| \
7 // ( __GNUC__ == 4 && __GNUC_MINOR__ == 4 && __GNUC_PATCHLEVEL__ <= 6 ) )
7 // ( __GNUC__ == 4 && __GNUC_MINOR__ == 4 && __GNUC_PATCHLEVEL__ <= 6 ) )
8 /*
8 /*
9 * =====================================================================================
9 * =====================================================================================
10 *
10 *
11 * Filename: gcov-io.c
11 * Filename: gcov-io.c
12 *
12 *
13 * Description: This is the I/O file for embedded systems
13 * Description: This is the I/O file for embedded systems
14 *
14 *
15 * Version: 1.0
15 * Version: 1.0
16 * Created: 03/04/08 09:51:59
16 * Created: 03/04/08 09:51:59
17 * Revision: none
17 * Revision: none
18 * Compiler: gcc
18 * Compiler: gcc
19 *
19 *
20 * Author: Aitor Viana Sanchez (avs), aitor.viana.sanchez@esa.int
20 * Author: Aitor Viana Sanchez (avs), aitor.viana.sanchez@esa.int
21 * Company: European Space Agency (ESA-ESTEC)
21 * Company: European Space Agency (ESA-ESTEC)
22 *
22 *
23 * =====================================================================================
23 * =====================================================================================
24 */
24 */
25
25
26 /* File format for coverage information
26 /* File format for coverage information
27 Copyright (C) 1996, 1997, 1998, 2000, 2002,
27 Copyright (C) 1996, 1997, 1998, 2000, 2002,
28 2003 Free Software Foundation, Inc.
28 2003 Free Software Foundation, Inc.
29 Contributed by Bob Manson <manson@cygnus.com>.
29 Contributed by Bob Manson <manson@cygnus.com>.
30 Completely remangled by Nathan Sidwell <nathan@codesourcery.com>.
30 Completely remangled by Nathan Sidwell <nathan@codesourcery.com>.
31
31
32 This file is part of GCC.
32 This file is part of GCC.
33
33
34 GCC is free software; you can redistribute it and/or modify it under
34 GCC is free software; you can redistribute it and/or modify it under
35 the terms of the GNU General Public License as published by the Free
35 the terms of the GNU General Public License as published by the Free
36 Software Foundation; either version 2, or (at your option) any later
36 Software Foundation; either version 2, or (at your option) any later
37 version.
37 version.
38
38
39 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
39 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
40 WARRANTY; without even the implied warranty of MERCHANTABILITY or
40 WARRANTY; without even the implied warranty of MERCHANTABILITY or
41 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
41 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
42 for more details.
42 for more details.
43
43
44 You should have received a copy of the GNU General Public License
44 You should have received a copy of the GNU General Public License
45 along with GCC; see the file COPYING. If not, write to the Free
45 along with GCC; see the file COPYING. If not, write to the Free
46 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
46 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
47 02111-1307, USA. */
47 02111-1307, USA. */
48
48
49 #include <stdio.h>
49 #include <stdio.h>
50 #include <stdlib.h> /* for atexit() */
50 #include <stdlib.h> /* for atexit() */
51 #include <string.h>
51 #include <string.h>
52 #include "gcov-io.h"
52 #include "gcov-io.h"
53
53
54 /* Routines declared in gcov-io.h. This file should be #included by
54 /* Routines declared in gcov-io.h. This file should be #included by
55 another source file, after having #included gcov-io.h. */
55 another source file, after having #included gcov-io.h. */
56
56
57
57
58 /* This function shall be defined somewhere else */
58 /* This function shall be defined somewhere else */
59 //int send_data(unsigned char * buffer, unsigned int size);
59 //int send_data(unsigned char * buffer, unsigned int size);
60
60
61 /*-----------------------------------------------------------------------------
61 /*-----------------------------------------------------------------------------
62 * PRIVATE INTERFACE
62 * PRIVATE INTERFACE
63 *-----------------------------------------------------------------------------*/
63 *-----------------------------------------------------------------------------*/
64
64
65 static void gcov_write_block (unsigned);
65 static void gcov_write_block (unsigned);
66 static gcov_unsigned_t *gcov_write_words (unsigned);
66 static gcov_unsigned_t *gcov_write_words (unsigned);
67 GCOV_LINKAGE int gcov_send (void);
67 GCOV_LINKAGE int gcov_send (void);
68 GCOV_LINKAGE int gcov_close(void);
68 GCOV_LINKAGE int gcov_close(void);
69
69
70 extern struct gcov_info * gcov_list;
70 extern struct gcov_info * gcov_list;
71 extern gcov_unsigned_t gcov_crc32;
71 extern gcov_unsigned_t gcov_crc32;
72
72
73 int dev_id = 0;
73 int dev_id = 0;
74
74
75 /*
75 /*
76 * === FUNCTION ======================================================================
76 * === FUNCTION ======================================================================
77 * Name: from_file
77 * Name: from_file
78 * Description: This function just return the given parameter
78 * Description: This function just return the given parameter
79 * =====================================================================================
79 * =====================================================================================
80 */
80 */
81 static inline gcov_unsigned_t from_file (gcov_unsigned_t value)
81 static inline gcov_unsigned_t from_file (gcov_unsigned_t value)
82 {
82 {
83 return value;
83 return value;
84 }
84 }
85
85
86 /*
86 /*
87 * === FUNCTION ======================================================================
87 * === FUNCTION ======================================================================
88 * Name: gcov_version
88 * Name: gcov_version
89 * Description: This function returns TRUE (1) if the gcov version is the
89 * Description: This function returns TRUE (1) if the gcov version is the
90 * version expected. The function returns FALSE (0) in any other case.
90 * version expected. The function returns FALSE (0) in any other case.
91 * =====================================================================================
91 * =====================================================================================
92 */
92 */
93 static int gcov_version (struct gcov_info *ptr, gcov_unsigned_t version)
93 static int gcov_version (struct gcov_info *ptr, gcov_unsigned_t version)
94 {
94 {
95 if (version != GCOV_VERSION)
95 if (version != GCOV_VERSION)
96 {
96 {
97 char v[4], e[4];
97 char v[4], e[4];
98
98
99 GCOV_UNSIGNED2STRING (v, version);
99 GCOV_UNSIGNED2STRING (v, version);
100 GCOV_UNSIGNED2STRING (e, GCOV_VERSION);
100 GCOV_UNSIGNED2STRING (e, GCOV_VERSION);
101
101
102 printf ("profiling:%s:Version mismatch - expected %.4s got %.4s\n",
102 printf ("profiling:%s:Version mismatch - expected %.4s got %.4s\n",
103 ptr->filename, e, v);
103 ptr->filename, e, v);
104
104
105 return 0;
105 return 0;
106 }
106 }
107 return 1;
107 return 1;
108 }
108 }
109
109
110
110
111 /*-----------------------------------------------------------------------------
111 /*-----------------------------------------------------------------------------
112 * PUBLIC INTERFACE
112 * PUBLIC INTERFACE
113 *-----------------------------------------------------------------------------*/
113 *-----------------------------------------------------------------------------*/
114
114
115 /* Dump the coverage counts. We merge with existing counts when
115 /* Dump the coverage counts. We merge with existing counts when
116 possible, to avoid growing the .da files ad infinitum. We use this
116 possible, to avoid growing the .da files ad infinitum. We use this
117 program's checksum to make sure we only accumulate whole program
117 program's checksum to make sure we only accumulate whole program
118 statistics to the correct summary. An object file might be embedded
118 statistics to the correct summary. An object file might be embedded
119 in two separate programs, and we must keep the two program
119 in two separate programs, and we must keep the two program
120 summaries separate. */
120 summaries separate. */
121
121
122 /*
122 /*
123 * === FUNCTION ======================================================================
123 * === FUNCTION ======================================================================
124 * Name: gcov_exit
124 * Name: gcov_exit
125 * Description: This function dumps the coverage couns. The merging with
125 * Description: This function dumps the coverage couns. The merging with
126 * existing counts is not done in embedded systems.
126 * existing counts is not done in embedded systems.
127 * =====================================================================================
127 * =====================================================================================
128 */
128 */
129 void gcov_exit (void)
129 void gcov_exit (void)
130 {
130 {
131 struct gcov_info *gi_ptr;
131 struct gcov_info *gi_ptr;
132 struct gcov_summary this_program;
132 struct gcov_summary this_program;
133 struct gcov_summary all;
133 struct gcov_summary all;
134 struct gcov_ctr_summary *cs_ptr;
134 struct gcov_ctr_summary *cs_ptr;
135 const struct gcov_ctr_info *ci_ptr;
135 const struct gcov_ctr_info *ci_ptr;
136 unsigned t_ix;
136 unsigned t_ix;
137 gcov_unsigned_t c_num;
137 gcov_unsigned_t c_num;
138 unsigned long coreId = 0;
138 unsigned long coreId = 0;
139
139
140 /* retrieve the id of the CPU the program is running on */
140 /* retrieve the id of the CPU the program is running on */
141 #ifdef LEON3
141 #ifdef LEON3
142 __asm__ __volatile__("rd %%asr17,%0\n\t"
142 __asm__ __volatile__("rd %%asr17,%0\n\t"
143 "srl %0,28,%0" :
143 "srl %0,28,%0" :
144 "=&r" (coreId) : );
144 "=&r" (coreId) : );
145 #endif
145 #endif
146
146
147 printf("_GCOVEXIT_BEGIN_,core%d\n", coreId); /* see also _GCOVEXIT_END_ */
147 printf("_GCOVEXIT_BEGIN_,core%d\n", coreId); /* see also _GCOVEXIT_END_ */
148
148
149 if(gcov_list == (void*)0x0)
149 if(gcov_list == (void*)0x0)
150 printf("%s: gcov_list == NULL\n", __func__);
150 printf("%s: gcov_list == NULL\n", __func__);
151
151
152 memset (&all, 0, sizeof (all));
152 memset (&all, 0, sizeof (all));
153 /* Find the totals for this execution. */
153 /* Find the totals for this execution. */
154 memset (&this_program, 0, sizeof (this_program));
154 memset (&this_program, 0, sizeof (this_program));
155 for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next)
155 for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next)
156 {
156 {
157
157
158 ci_ptr = gi_ptr->counts;
158 ci_ptr = gi_ptr->counts;
159 for (t_ix = 0; t_ix < GCOV_COUNTERS_SUMMABLE; t_ix++)
159 for (t_ix = 0; t_ix < GCOV_COUNTERS_SUMMABLE; t_ix++)
160 {
160 {
161 if (!((1 << t_ix) & gi_ptr->ctr_mask))
161 if (!((1 << t_ix) & gi_ptr->ctr_mask))
162 continue;
162 continue;
163
163
164 cs_ptr = &this_program.ctrs[t_ix];
164 cs_ptr = &this_program.ctrs[t_ix];
165 cs_ptr->num += ci_ptr->num;
165 cs_ptr->num += ci_ptr->num;
166 for (c_num = 0; c_num < ci_ptr->num; c_num++)
166 for (c_num = 0; c_num < ci_ptr->num; c_num++)
167 {
167 {
168 cs_ptr->sum_all += ci_ptr->values[c_num];
168 cs_ptr->sum_all += ci_ptr->values[c_num];
169 if (cs_ptr->run_max < ci_ptr->values[c_num])
169 if (cs_ptr->run_max < ci_ptr->values[c_num])
170 cs_ptr->run_max = ci_ptr->values[c_num];
170 cs_ptr->run_max = ci_ptr->values[c_num];
171 }
171 }
172 ci_ptr++;
172 ci_ptr++;
173 }
173 }
174 }
174 }
175 /* Now merge each file. */
175 /* Now merge each file. */
176 for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next)
176 for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next)
177 {
177 {
178
178
179 struct gcov_summary program;
179 struct gcov_summary program;
180 gcov_type *values[GCOV_COUNTERS];
180 gcov_type *values[GCOV_COUNTERS];
181 const struct gcov_fn_info *fi_ptr;
181 const struct gcov_fn_info *fi_ptr;
182 unsigned fi_stride;
182 unsigned fi_stride;
183 unsigned c_ix, f_ix, n_counts;
183 unsigned c_ix, f_ix, n_counts;
184
184
185 c_ix = 0;
185 c_ix = 0;
186 for (t_ix = 0; t_ix < GCOV_COUNTERS; t_ix++)
186 for (t_ix = 0; t_ix < GCOV_COUNTERS; t_ix++)
187 if ((1 << t_ix) & gi_ptr->ctr_mask)
187 if ((1 << t_ix) & gi_ptr->ctr_mask)
188 {
188 {
189 values[c_ix] = gi_ptr->counts[c_ix].values;
189 values[c_ix] = gi_ptr->counts[c_ix].values;
190 c_ix++;
190 c_ix++;
191 }
191 }
192
192
193 /* Calculate the function_info stride. This depends on the
193 /* Calculate the function_info stride. This depends on the
194 number of counter types being measured. */
194 number of counter types being measured. */
195 fi_stride = sizeof (struct gcov_fn_info) + c_ix * sizeof (unsigned);
195 fi_stride = sizeof (struct gcov_fn_info) + c_ix * sizeof (unsigned);
196 if (__alignof__ (struct gcov_fn_info) > sizeof (unsigned))
196 if (__alignof__ (struct gcov_fn_info) > sizeof (unsigned))
197 {
197 {
198 fi_stride += __alignof__ (struct gcov_fn_info) - 1;
198 fi_stride += __alignof__ (struct gcov_fn_info) - 1;
199 fi_stride &= ~(__alignof__ (struct gcov_fn_info) - 1);
199 fi_stride &= ~(__alignof__ (struct gcov_fn_info) - 1);
200 }
200 }
201
201
202 if (!gcov_open (gi_ptr->filename))
202 if (!gcov_open (gi_ptr->filename))
203 {
203 {
204 printf ("profiling:%s:Cannot open\n", gi_ptr->filename);
204 printf ("profiling:%s:Cannot open\n", gi_ptr->filename);
205 continue;
205 continue;
206 }
206 }
207
207
208 program.checksum = gcov_crc32;
208 program.checksum = gcov_crc32;
209
209
210 /* Write out the data. */
210 /* Write out the data. */
211 gcov_write_tag_length (GCOV_DATA_MAGIC, GCOV_VERSION);
211 gcov_write_tag_length (GCOV_DATA_MAGIC, GCOV_VERSION);
212 gcov_write_unsigned (gi_ptr->stamp);
212 gcov_write_unsigned (gi_ptr->stamp);
213
213
214 /* Write execution counts for each function. */
214 /* Write execution counts for each function. */
215 for (f_ix = 0; f_ix < gi_ptr->n_functions; f_ix++)
215 for (f_ix = 0; f_ix < gi_ptr->n_functions; f_ix++)
216 {
216 {
217 fi_ptr = (const struct gcov_fn_info *)
217 fi_ptr = (const struct gcov_fn_info *)
218 ((const char *) gi_ptr->functions + f_ix * fi_stride);
218 ((const char *) gi_ptr->functions + f_ix * fi_stride);
219
219
220 /* Announce function. */
220 /* Announce function. */
221 gcov_write_tag_length (GCOV_TAG_FUNCTION, GCOV_TAG_FUNCTION_LENGTH);
221 gcov_write_tag_length (GCOV_TAG_FUNCTION, GCOV_TAG_FUNCTION_LENGTH);
222 gcov_write_unsigned (fi_ptr->ident);
222 gcov_write_unsigned (fi_ptr->ident);
223 gcov_write_unsigned (fi_ptr->checksum);
223 gcov_write_unsigned (fi_ptr->checksum);
224
224
225 c_ix = 0;
225 c_ix = 0;
226 for (t_ix = 0; t_ix < GCOV_COUNTERS; t_ix++)
226 for (t_ix = 0; t_ix < GCOV_COUNTERS; t_ix++)
227 {
227 {
228 gcov_type *c_ptr;
228 gcov_type *c_ptr;
229
229
230 if (!((1 << t_ix) & gi_ptr->ctr_mask))
230 if (!((1 << t_ix) & gi_ptr->ctr_mask))
231 continue;
231 continue;
232
232
233 n_counts = fi_ptr->n_ctrs[c_ix];
233 n_counts = fi_ptr->n_ctrs[c_ix];
234
234
235 gcov_write_tag_length (GCOV_TAG_FOR_COUNTER (t_ix),
235 gcov_write_tag_length (GCOV_TAG_FOR_COUNTER (t_ix),
236 GCOV_TAG_COUNTER_LENGTH (n_counts));
236 GCOV_TAG_COUNTER_LENGTH (n_counts));
237 c_ptr = values[c_ix];
237 c_ptr = values[c_ix];
238 while (n_counts--)
238 while (n_counts--)
239 gcov_write_counter (*c_ptr++);
239 gcov_write_counter (*c_ptr++);
240
240
241 values[c_ix] = c_ptr;
241 values[c_ix] = c_ptr;
242 c_ix++;
242 c_ix++;
243 }
243 }
244 }
244 }
245
245
246 gcov_send();
246 gcov_send();
247 gcov_close();
247 gcov_close();
248
248
249 }
249 }
250
250
251 printf("_GCOVEXIT_END_,core%d\n", coreId);
251 printf("_GCOVEXIT_END_,core%d\n", coreId);
252 }
252 }
253
253
254
254
255 /* Called before fork or exec - write out profile information gathered so
255 /* Called before fork or exec - write out profile information gathered so
256 far and reset it to zero. This avoids duplication or loss of the
256 far and reset it to zero. This avoids duplication or loss of the
257 profile information gathered so far. */
257 profile information gathered so far. */
258
258
259 void
259 void
260 __gcov_flush (void)
260 __gcov_flush (void)
261 {
261 {
262 const struct gcov_info *gi_ptr;
262 const struct gcov_info *gi_ptr;
263
263
264 gcov_exit ();
264 gcov_exit ();
265 for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next)
265 for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next)
266 {
266 {
267 unsigned t_ix;
267 unsigned t_ix;
268 const struct gcov_ctr_info *ci_ptr;
268 const struct gcov_ctr_info *ci_ptr;
269
269
270 for (t_ix = 0, ci_ptr = gi_ptr->counts; t_ix != GCOV_COUNTERS; t_ix++)
270 for (t_ix = 0, ci_ptr = gi_ptr->counts; t_ix != GCOV_COUNTERS; t_ix++)
271 if ((1 << t_ix) & gi_ptr->ctr_mask)
271 if ((1 << t_ix) & gi_ptr->ctr_mask)
272 {
272 {
273 memset (ci_ptr->values, 0, sizeof (gcov_type) * ci_ptr->num);
273 memset (ci_ptr->values, 0, sizeof (gcov_type) * ci_ptr->num);
274 ci_ptr++;
274 ci_ptr++;
275 }
275 }
276 }
276 }
277 }
277 }
278
278
279
279
280
280
281 /* Open a gcov file. NAME is the name of the file to open and MODE
281 /* Open a gcov file. NAME is the name of the file to open and MODE
282 indicates whether a new file should be created, or an existing file
282 indicates whether a new file should be created, or an existing file
283 opened for modification. If MODE is >= 0 an existing file will be
283 opened for modification. If MODE is >= 0 an existing file will be
284 opened, if possible, and if MODE is <= 0, a new file will be
284 opened, if possible, and if MODE is <= 0, a new file will be
285 created. Use MODE=0 to attempt to reopen an existing file and then
285 created. Use MODE=0 to attempt to reopen an existing file and then
286 fall back on creating a new one. Return zero on failure, >0 on
286 fall back on creating a new one. Return zero on failure, >0 on
287 opening an existing file and <0 on creating a new one. */
287 opening an existing file and <0 on creating a new one. */
288 GCOV_LINKAGE int gcov_open(const char *name)
288 GCOV_LINKAGE int gcov_open(const char *name)
289 {
289 {
290 // gcov_var.start is cleared in the gcov_close function.
290 // gcov_var.start is cleared in the gcov_close function.
291 // If this variable is not cleared...ERROR
291 // If this variable is not cleared...ERROR
292 if( gcov_var.start != 0 )
292 if( gcov_var.start != 0 )
293 return 0;
293 return 0;
294
294
295 // Clear everything
295 // Clear everything
296 gcov_var.start = 0;
296 gcov_var.start = 0;
297 gcov_var.offset = gcov_var.length = 0;
297 gcov_var.offset = gcov_var.length = 0;
298 gcov_var.overread = -1u;
298 gcov_var.overread = -1u;
299 gcov_var.error = 0;
299 gcov_var.error = 0;
300
300
301
301
302 // copy the filename in the gcov_var structure
302 // copy the filename in the gcov_var structure
303 strcpy(gcov_var.filename, name);
303 strcpy(gcov_var.filename, name);
304
304
305
305
306 // return 1 means everything is OK
306 // return 1 means everything is OK
307 return 1;
307 return 1;
308 }
308 }
309
309
310 /* Close the current gcov file. Flushes data to disk. Returns nonzero
310 /* Close the current gcov file. Flushes data to disk. Returns nonzero
311 on failure or error flag set. */
311 on failure or error flag set. */
312
312
313 GCOV_LINKAGE int gcov_send (void)
313 GCOV_LINKAGE int gcov_send (void)
314 {
314 {
315 /*printf("%s: file %s\n", __func__, gcov_var.filename);*/
315 /*printf("%s: file %s\n", __func__, gcov_var.filename);*/
316 if (gcov_var.offset)
316 if (gcov_var.offset)
317 gcov_write_block (gcov_var.offset);
317 gcov_write_block (gcov_var.offset);
318
318
319 gcov_var.length = 0;
319 gcov_var.length = 0;
320 return gcov_var.error;
320 return gcov_var.error;
321 }
321 }
322
322
323 GCOV_LINKAGE int gcov_close(void)
323 GCOV_LINKAGE int gcov_close(void)
324 {
324 {
325 memset(gcov_var.filename, 0, strlen(gcov_var.filename));
325 memset(gcov_var.filename, 0, strlen(gcov_var.filename));
326
326
327 // Clear the start variable because will be tested in the gcov_open
327 // Clear the start variable because will be tested in the gcov_open
328 // function
328 // function
329 gcov_var.start = 0;
329 gcov_var.start = 0;
330
330
331 // Return the error, not sure whether the error is modifed.
331 // Return the error, not sure whether the error is modifed.
332 return gcov_var.error;
332 return gcov_var.error;
333 }
333 }
334
334
335
335
336 static void gcov_write_block (unsigned size) {
336 static void gcov_write_block (unsigned size) {
337 unsigned char *buffer = (unsigned char*) gcov_var.buffer;
337 unsigned char *buffer = (unsigned char*) gcov_var.buffer;
338 unsigned int i;
338 unsigned int i;
339
339
340 printf("_GCOV_,%s,", gcov_var.filename);
340 printf("_GCOV_,%s,", gcov_var.filename);
341 /* to speed up the printing process, we display bytes 4 by 4 */
341 /* to speed up the printing process, we display bytes 4 by 4 */
342 for(i = 0; i < size; i++) {
342 for(i = 0; i < size; i++) {
343 printf("%02X%02X%02X%02X", (unsigned int)(buffer[0]),
343 printf("%02X%02X%02X%02X", (unsigned int)(buffer[0]),
344 (unsigned int)(buffer[1]),
344 (unsigned int)(buffer[1]),
345 (unsigned int)(buffer[2]),
345 (unsigned int)(buffer[2]),
346 (unsigned int)(buffer[3]));
346 (unsigned int)(buffer[3]));
347
347
348 buffer += sizeof(gcov_unsigned_t);
348 buffer += sizeof(gcov_unsigned_t);
349 }
349 }
350 printf("\n");
350 printf("\n");
351
351
352 gcov_var.start += size;
352 gcov_var.start += size;
353 gcov_var.offset -= size;
353 gcov_var.offset -= size;
354 }
354 }
355
355
356 /* Allocate space to write BYTES bytes to the gcov file. Return a
356 /* Allocate space to write BYTES bytes to the gcov file. Return a
357 pointer to those bytes, or NULL on failure. */
357 pointer to those bytes, or NULL on failure. */
358
358
359 static gcov_unsigned_t *gcov_write_words (unsigned words) {
359 static gcov_unsigned_t *gcov_write_words (unsigned words) {
360 gcov_unsigned_t *result;
360 gcov_unsigned_t *result;
361
361
362 GCOV_CHECK_WRITING ();
362 GCOV_CHECK_WRITING ();
363 if (gcov_var.offset >= GCOV_BLOCK_SIZE)
363 if (gcov_var.offset >= GCOV_BLOCK_SIZE)
364 {
364 {
365 gcov_write_block (GCOV_BLOCK_SIZE);
365 gcov_write_block (GCOV_BLOCK_SIZE);
366 if (gcov_var.offset)
366 if (gcov_var.offset)
367 {
367 {
368 GCOV_CHECK (gcov_var.offset == 1);
368 GCOV_CHECK (gcov_var.offset == 1);
369 memcpy (gcov_var.buffer, gcov_var.buffer + GCOV_BLOCK_SIZE, 4);
369 memcpy (gcov_var.buffer, gcov_var.buffer + GCOV_BLOCK_SIZE, 4);
370 }
370 }
371 }
371 }
372 result = &gcov_var.buffer[gcov_var.offset];
372 result = &gcov_var.buffer[gcov_var.offset];
373 gcov_var.offset += words;
373 gcov_var.offset += words;
374
374
375 return result;
375 return result;
376 }
376 }
377
377
378 /* Write unsigned VALUE to coverage file. Sets error flag
378 /* Write unsigned VALUE to coverage file. Sets error flag
379 appropriately. */
379 appropriately. */
380
380
381 GCOV_LINKAGE void
381 GCOV_LINKAGE void
382 gcov_write_unsigned (gcov_unsigned_t value)
382 gcov_write_unsigned (gcov_unsigned_t value)
383 {
383 {
384 gcov_unsigned_t *buffer = gcov_write_words (1);
384 gcov_unsigned_t *buffer = gcov_write_words (1);
385
385
386 buffer[0] = value;
386 buffer[0] = value;
387 }
387 }
388
388
389 /* Write counter VALUE to coverage file. Sets error flag
389 /* Write counter VALUE to coverage file. Sets error flag
390 appropriately. */
390 appropriately. */
391
391
392 GCOV_LINKAGE void
392 GCOV_LINKAGE void
393 gcov_write_counter (gcov_type value)
393 gcov_write_counter (gcov_type value)
394 {
394 {
395 gcov_unsigned_t *buffer = gcov_write_words (2);
395 gcov_unsigned_t *buffer = gcov_write_words (2);
396
396
397 buffer[0] = (gcov_unsigned_t) value;
397 buffer[0] = (gcov_unsigned_t) value;
398 if (sizeof (value) > sizeof (gcov_unsigned_t))
398 if (sizeof (value) > sizeof (gcov_unsigned_t))
399 buffer[1] = (gcov_unsigned_t) (value >> 32);
399 buffer[1] = (gcov_unsigned_t) (value >> 32);
400 else
400 else
401 buffer[1] = 0;
401 buffer[1] = 0;
402
402
403 }
403 }
404
404
405 /* Write a tag TAG and length LENGTH. */
405 /* Write a tag TAG and length LENGTH. */
406
406
407 GCOV_LINKAGE void
407 GCOV_LINKAGE void
408 gcov_write_tag_length (gcov_unsigned_t tag, gcov_unsigned_t length)
408 gcov_write_tag_length (gcov_unsigned_t tag, gcov_unsigned_t length)
409 {
409 {
410 gcov_unsigned_t *buffer = gcov_write_words (2);
410 gcov_unsigned_t *buffer = gcov_write_words (2);
411
411
412 buffer[0] = tag;
412 buffer[0] = tag;
413 buffer[1] = length;
413 buffer[1] = length;
414 }
414 }
415
415
416 /* Write a summary structure to the gcov file. Return nonzero on
416 /* Write a summary structure to the gcov file. Return nonzero on
417 overflow. */
417 overflow. */
418
418
419 GCOV_LINKAGE void
419 GCOV_LINKAGE void
420 gcov_write_summary (gcov_unsigned_t tag, const struct gcov_summary *summary)
420 gcov_write_summary (gcov_unsigned_t tag, const struct gcov_summary *summary)
421 {
421 {
422 unsigned ix;
422 unsigned ix;
423 const struct gcov_ctr_summary *csum;
423 const struct gcov_ctr_summary *csum;
424
424
425 gcov_write_tag_length (tag, GCOV_TAG_SUMMARY_LENGTH);
425 gcov_write_tag_length (tag, GCOV_TAG_SUMMARY_LENGTH);
426 gcov_write_unsigned (summary->checksum);
426 gcov_write_unsigned (summary->checksum);
427 for (csum = summary->ctrs, ix = GCOV_COUNTERS_SUMMABLE; ix--; csum++)
427 for (csum = summary->ctrs, ix = GCOV_COUNTERS_SUMMABLE; ix--; csum++)
428 {
428 {
429 gcov_write_unsigned (csum->num);
429 gcov_write_unsigned (csum->num);
430 gcov_write_unsigned (csum->runs);
430 gcov_write_unsigned (csum->runs);
431 gcov_write_counter (csum->sum_all);
431 gcov_write_counter (csum->sum_all);
432 gcov_write_counter (csum->run_max);
432 gcov_write_counter (csum->run_max);
433 gcov_write_counter (csum->sum_max);
433 gcov_write_counter (csum->sum_max);
434 }
434 }
435 }
435 }
436
436
437 GCOV_LINKAGE gcov_type
437 GCOV_LINKAGE gcov_type
438 gcov_read_counter (void)
438 gcov_read_counter (void)
439 {
439 {
440 return 0;
440 return 0;
441 }
441 }
442
442
443 /* Add a new object file onto the bb chain. Invoked automatically
443 /* Add a new object file onto the bb chain. Invoked automatically
444 when running an object file's global ctors. */
444 when running an object file's global ctors. */
445
445
446 void
446 void
447 __gcov_init (struct gcov_info *info)
447 __gcov_init (struct gcov_info *info)
448 {
448 {
449 if (!info->version)
449 if (!info->version)
450 return;
450 return;
451 if (gcov_version (info, info->version))
451 if (gcov_version (info, info->version))
452 {
452 {
453 const char *ptr = info->filename;
453 const char *ptr = info->filename;
454 gcov_unsigned_t crc32 = gcov_crc32;
454 gcov_unsigned_t crc32 = gcov_crc32;
455
455
456 /* Added by LESIA*/
456 /* Added by LESIA*/
457 printf("Covered file: %s\n", info->filename);
457 printf("Covered file: %s\n", info->filename);
458 /* End of Added by LESIA*/
458 /* End of Added by LESIA*/
459
459
460 do
460 do
461 {
461 {
462 unsigned ix;
462 unsigned ix;
463 gcov_unsigned_t value = *ptr << 24;
463 gcov_unsigned_t value = *ptr << 24;
464
464
465 for (ix = 8; ix--; value <<= 1)
465 for (ix = 8; ix--; value <<= 1)
466 {
466 {
467 gcov_unsigned_t feedback;
467 gcov_unsigned_t feedback;
468
468
469 feedback = (value ^ crc32) & 0x80000000 ? 0x04c11db7 : 0;
469 feedback = (value ^ crc32) & 0x80000000 ? 0x04c11db7 : 0;
470 crc32 <<= 1;
470 crc32 <<= 1;
471 crc32 ^= feedback;
471 crc32 ^= feedback;
472 }
472 }
473 }
473 }
474 while (*ptr++);
474 while (*ptr++);
475
475
476 gcov_crc32 = crc32;
476 gcov_crc32 = crc32;
477
477
478 #ifdef GCOV_USE_EXIT
478 if (!gcov_list)
479 if (!gcov_list)
479 atexit (gcov_exit);
480 atexit (gcov_exit);
481 #endif
480
482
481 info->next = gcov_list;
483 info->next = gcov_list;
482 gcov_list = info;
484 gcov_list = info;
483 }
485 }
484 else
486 else
485 printf("%s: Version mismatch\n", "WARNING");
487 printf("%s: Version mismatch\n", "WARNING");
486 info->version = 0;
488 info->version = 0;
487 }
489 }
488 //#endif /* __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__ */
490 //#endif /* __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__ */
@@ -1,39 +1,39
1 set(rtems_dir /opt/rtems-4.10/)
1 set(rtems_dir /opt/rtems-4.10/)
2
2
3 set(CMAKE_SYSTEM_NAME rtems)
3 set(CMAKE_SYSTEM_NAME rtems)
4 set(CMAKE_C_COMPILER ${rtems_dir}/bin/sparc-rtems-gcc)
4 set(CMAKE_C_COMPILER ${rtems_dir}/bin/sparc-rtems-gcc)
5 set(CMAKE_CXX_COMPILER ${rtems_dir}/bin/sparc-rtems-g++)
5 set(CMAKE_CXX_COMPILER ${rtems_dir}/bin/sparc-rtems-g++)
6 set(CMAKE_LINKER ${rtems_dir}/bin/sparc-rtems-g++)
6 set(CMAKE_LINKER ${rtems_dir}/bin/sparc-rtems-g++)
7 SET(CMAKE_EXE_LINKER_FLAGS "-static")
7 SET(CMAKE_EXE_LINKER_FLAGS "-static")
8 option(fix-b2bst "Activate -mfix-b2bst switch to mitigate \"LEON3FT Stale Cache Entry After Store with Data Tag Parity Error\" errata, GRLIB-TN-0009" ON)
8 option(fix-b2bst "Activate -mfix-b2bst switch to mitigate \"LEON3FT Stale Cache Entry After Store with Data Tag Parity Error\" errata, GRLIB-TN-0009" ON)
9
9
10 option(Coverage "Enables code coverage" OFF)
10 option(Coverage "Enables code coverage" OFF)
11
11
12
12
13 set(CMAKE_C_FLAGS_RELEASE "-O3")
13 set(CMAKE_C_FLAGS_RELEASE "-O2")
14 set(CMAKE_C_FLAGS_DEBUG "-O3 -fno-inline")
14 set(CMAKE_C_FLAGS_DEBUG "-O2 -g -fno-inline")
15
15
16
16
17 if(fix-b2bst)
17 if(fix-b2bst)
18 set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -mfix-b2bst")
18 set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -mfix-b2bst")
19 set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -mfix-b2bst")
19 set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -mfix-b2bst")
20 endif()
20 endif()
21
21
22
22
23 set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_LINKER> <FLAGS> -Xlinker -Map=<TARGET>.map <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
23 set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_LINKER> <FLAGS> -Xlinker -Map=<TARGET>.map <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
24
24
25 include_directories("${rtems_dir}/sparc-rtems/leon3/lib/include")
25 include_directories("${rtems_dir}/sparc-rtems/leon3/lib/include")
26
26
27 function (check_b2bst target bin)
27 function (check_b2bst target bin)
28 add_custom_command(TARGET ${target}
28 add_custom_command(TARGET ${target}
29 POST_BUILD
29 POST_BUILD
30 COMMAND ${rtems_dir}/bin/sparc-rtems-objdump -d ${bin}/${target} | ${CMAKE_SOURCE_DIR}/sparc/leon3ft-b2bst-scan.tcl
30 COMMAND ${rtems_dir}/bin/sparc-rtems-objdump -d ${bin}/${target} | ${CMAKE_SOURCE_DIR}/sparc/leon3ft-b2bst-scan.tcl
31 )
31 )
32 endfunction()
32 endfunction()
33
33
34 function (build_srec target bin rev)
34 function (build_srec target bin rev)
35 add_custom_command(TARGET ${target}
35 add_custom_command(TARGET ${target}
36 POST_BUILD
36 POST_BUILD
37 COMMAND ${rtems_dir}/bin/sparc-rtems-objcopy -j .data -F srec ${bin}/${target} RpwLfrApp_XXXX_data_rev-${rev}.srec && ${rtems_dir}/bin/sparc-rtems-objcopy -j .text -F srec ${bin}/${target} RpwLfrApp_XXXX_text_rev-${rev}.srec
37 COMMAND ${rtems_dir}/bin/sparc-rtems-objcopy -j .data -F srec ${bin}/${target} RpwLfrApp_XXXX_data_rev-${rev}.srec && ${rtems_dir}/bin/sparc-rtems-objcopy -j .text -F srec ${bin}/${target} RpwLfrApp_XXXX_text_rev-${rev}.srec
38 )
38 )
39 endfunction()
39 endfunction()
@@ -1,130 +1,130
1 cmake_minimum_required (VERSION 2.6)
1 cmake_minimum_required (VERSION 3.6)
2 project (fsw)
2 project (fsw)
3
3
4 include(sparc-rtems)
4 include(sparc-rtems)
5 include(cppcheck)
5 include(cppcheck)
6
6
7 include_directories("../header"
7 include_directories("../header"
8 "../header/lfr_common_headers"
8 "../header/lfr_common_headers"
9 "../header/processing"
9 "../header/processing"
10 "../LFR_basic-parameters"
10 "../LFR_basic-parameters"
11 "../src")
11 "../src")
12
12
13 set(SOURCES wf_handler.c
13 set(SOURCES wf_handler.c
14 tc_handler.c
14 tc_handler.c
15 fsw_misc.c
15 fsw_misc.c
16 fsw_init.c
16 fsw_init.c
17 fsw_globals.c
17 fsw_globals.c
18 fsw_spacewire.c
18 fsw_spacewire.c
19 tc_load_dump_parameters.c
19 tc_load_dump_parameters.c
20 tm_lfr_tc_exe.c
20 tm_lfr_tc_exe.c
21 tc_acceptance.c
21 tc_acceptance.c
22 processing/fsw_processing.c
22 processing/fsw_processing.c
23 processing/avf0_prc0.c
23 processing/avf0_prc0.c
24 processing/avf1_prc1.c
24 processing/avf1_prc1.c
25 processing/avf2_prc2.c
25 processing/avf2_prc2.c
26 lfr_cpu_usage_report.c
26 lfr_cpu_usage_report.c
27 ${LFR_BP_SRC}
27 ${LFR_BP_SRC}
28 ../header/wf_handler.h
28 ../header/wf_handler.h
29 ../header/tc_handler.h
29 ../header/tc_handler.h
30 ../header/grlib_regs.h
30 ../header/grlib_regs.h
31 ../header/fsw_misc.h
31 ../header/fsw_misc.h
32 ../header/fsw_init.h
32 ../header/fsw_init.h
33 ../header/fsw_spacewire.h
33 ../header/fsw_spacewire.h
34 ../header/tc_load_dump_parameters.h
34 ../header/tc_load_dump_parameters.h
35 ../header/tm_lfr_tc_exe.h
35 ../header/tm_lfr_tc_exe.h
36 ../header/tc_acceptance.h
36 ../header/tc_acceptance.h
37 ../header/processing/fsw_processing.h
37 ../header/processing/fsw_processing.h
38 ../header/processing/avf0_prc0.h
38 ../header/processing/avf0_prc0.h
39 ../header/processing/avf1_prc1.h
39 ../header/processing/avf1_prc1.h
40 ../header/processing/avf2_prc2.h
40 ../header/processing/avf2_prc2.h
41 ../header/fsw_params_wf_handler.h
41 ../header/fsw_params_wf_handler.h
42 ../header/lfr_cpu_usage_report.h
42 ../header/lfr_cpu_usage_report.h
43 ../header/lfr_common_headers/ccsds_types.h
43 ../header/lfr_common_headers/ccsds_types.h
44 ../header/lfr_common_headers/fsw_params.h
44 ../header/lfr_common_headers/fsw_params.h
45 ../header/lfr_common_headers/fsw_params_nb_bytes.h
45 ../header/lfr_common_headers/fsw_params_nb_bytes.h
46 ../header/lfr_common_headers/fsw_params_processing.h
46 ../header/lfr_common_headers/fsw_params_processing.h
47 ../header/lfr_common_headers/tm_byte_positions.h
47 ../header/lfr_common_headers/tm_byte_positions.h
48 ../LFR_basic-parameters/basic_parameters.h
48 ../LFR_basic-parameters/basic_parameters.h
49 ../LFR_basic-parameters/basic_parameters_params.h
49 ../LFR_basic-parameters/basic_parameters_params.h
50 ../header/GscMemoryLPP.hpp
50 ../header/GscMemoryLPP.hpp
51 )
51 )
52
52
53
53
54 option(FSW_verbose "Enable verbose LFR" OFF)
54 option(FSW_verbose "Enable verbose LFR" OFF)
55 option(FSW_boot_messages "Enable LFR boot messages" OFF)
55 option(FSW_boot_messages "Enable LFR boot messages" OFF)
56 option(FSW_debug_messages "Enable LFR debug messages" OFF)
56 option(FSW_debug_messages "Enable LFR debug messages" OFF)
57 option(FSW_cpu_usage_report "Enable LFR cpu usage report" OFF)
57 option(FSW_cpu_usage_report "Enable LFR cpu usage report" OFF)
58 option(FSW_stack_report "Enable LFR stack report" OFF)
58 option(FSW_stack_report "Enable LFR stack report" OFF)