Lines Matching +full:data +full:- +full:active

1 // SPDX-License-Identifier: GPL-2.0
3 * This code provides functions to handle gcc's profiling data format
9 * gcc/gcov-io.h
12 * Uses gcc-internal data definitions.
45 * struct gcov_ctr_info - information about counters for a single function
49 * This data is generated by gcc during compilation and doesn't change
50 * at run-time with the exception of the values array.
58 * struct gcov_fn_info - profiling meta data per function
65 * This data is generated by gcc during compilation and doesn't change
66 * at run-time.
71 * comdat functions was selected -- it points to the gcov_info object
83 * struct gcov_info - profiling data per object file
85 * @next: list head for a singly-linked list
88 * @filename: name of the associated gcov data file
93 * This data is generated by gcc during compilation and doesn't change
94 * at run-time with the exception of the next pointer.
111 * gcov_info_filename - return info filename
112 * @info: profiling data set
116 return info->filename; in gcov_info_filename()
120 * gcov_info_version - return info version
121 * @info: profiling data set
125 return info->version; in gcov_info_version()
129 * gcov_info_next - return next profiling data set
130 * @info: profiling data set
140 return info->next; in gcov_info_next()
144 * gcov_info_link - link/add profiling data set to the list
145 * @info: profiling data set
149 info->next = gcov_info_head; in gcov_info_link()
154 * gcov_info_unlink - unlink/remove profiling data set from the list
155 * @prev: previous profiling data set
156 * @info: profiling data set
161 prev->next = info->next; in gcov_info_unlink()
163 gcov_info_head = info->next; in gcov_info_unlink()
167 * gcov_info_within_module - check if a profiling data set belongs to a module
168 * @info: profiling data set
171 * Returns true if profiling data belongs module, false otherwise.
178 /* Symbolic links to be created for each profiling data file. */
185 * Determine whether a counter is active. Doesn't change at run-time.
189 return info->merge[type] ? 1 : 0; in counter_active()
192 /* Determine number of active counters. Based on gcc magic. */
206 * gcov_info_reset - reset profiling data to zero
207 * @info: profiling data set
215 for (fi_idx = 0; fi_idx < info->n_functions; fi_idx++) { in gcov_info_reset()
216 ci_ptr = info->functions[fi_idx]->ctrs; in gcov_info_reset()
222 memset(ci_ptr->values, 0, in gcov_info_reset()
223 sizeof(gcov_type) * ci_ptr->num); in gcov_info_reset()
230 * gcov_info_is_compatible - check if profiling data can be added
231 * @info1: first profiling data set
232 * @info2: second profiling data set
234 * Returns non-zero if profiling data can be added, zero otherwise.
238 return (info1->stamp == info2->stamp); in gcov_info_is_compatible()
242 * gcov_info_add - add up profiling data
243 * @dst: profiling data set to which data is added
244 * @src: profiling data set which is added
256 for (fi_idx = 0; fi_idx < src->n_functions; fi_idx++) { in gcov_info_add()
257 dci_ptr = dst->functions[fi_idx]->ctrs; in gcov_info_add()
258 sci_ptr = src->functions[fi_idx]->ctrs; in gcov_info_add()
264 for (val_idx = 0; val_idx < sci_ptr->num; val_idx++) in gcov_info_add()
265 dci_ptr->values[val_idx] += in gcov_info_add()
266 sci_ptr->values[val_idx]; in gcov_info_add()
275 * gcov_info_dup - duplicate profiling data set
276 * @info: profiling data set to duplicate
285 unsigned int active; in gcov_info_dup() local
295 dup->next = NULL; in gcov_info_dup()
296 dup->filename = NULL; in gcov_info_dup()
297 dup->functions = NULL; in gcov_info_dup()
299 dup->filename = kstrdup(info->filename, GFP_KERNEL); in gcov_info_dup()
300 if (!dup->filename) in gcov_info_dup()
303 dup->functions = kcalloc(info->n_functions, in gcov_info_dup()
305 if (!dup->functions) in gcov_info_dup()
308 active = num_counter_active(info); in gcov_info_dup()
310 fi_size += sizeof(struct gcov_ctr_info) * active; in gcov_info_dup()
312 for (fi_idx = 0; fi_idx < info->n_functions; fi_idx++) { in gcov_info_dup()
313 dup->functions[fi_idx] = kzalloc(fi_size, GFP_KERNEL); in gcov_info_dup()
314 if (!dup->functions[fi_idx]) in gcov_info_dup()
317 *(dup->functions[fi_idx]) = *(info->functions[fi_idx]); in gcov_info_dup()
319 sci_ptr = info->functions[fi_idx]->ctrs; in gcov_info_dup()
320 dci_ptr = dup->functions[fi_idx]->ctrs; in gcov_info_dup()
322 for (ct_idx = 0; ct_idx < active; ct_idx++) { in gcov_info_dup()
324 cv_size = sizeof(gcov_type) * sci_ptr->num; in gcov_info_dup()
326 dci_ptr->values = kvmalloc(cv_size, GFP_KERNEL); in gcov_info_dup()
328 if (!dci_ptr->values) in gcov_info_dup()
331 dci_ptr->num = sci_ptr->num; in gcov_info_dup()
332 memcpy(dci_ptr->values, sci_ptr->values, cv_size); in gcov_info_dup()
346 * gcov_info_free - release memory for profiling data set duplicate
347 * @info: profiling data set duplicate to free
351 unsigned int active; in gcov_info_free() local
356 if (!info->functions) in gcov_info_free()
359 active = num_counter_active(info); in gcov_info_free()
361 for (fi_idx = 0; fi_idx < info->n_functions; fi_idx++) { in gcov_info_free()
362 if (!info->functions[fi_idx]) in gcov_info_free()
365 ci_ptr = info->functions[fi_idx]->ctrs; in gcov_info_free()
367 for (ct_idx = 0; ct_idx < active; ct_idx++, ci_ptr++) in gcov_info_free()
368 kvfree(ci_ptr->values); in gcov_info_free()
370 kfree(info->functions[fi_idx]); in gcov_info_free()
374 kfree(info->functions); in gcov_info_free()
375 kfree(info->filename); in gcov_info_free()
380 * convert_to_gcda - convert profiling data set to gcda file format
381 * @buffer: the buffer to store file data or %NULL if no data should be stored
382 * @info: profiling data set to be converted
397 pos += store_gcov_u32(buffer, pos, info->version); in convert_to_gcda()
398 pos += store_gcov_u32(buffer, pos, info->stamp); in convert_to_gcda()
405 for (fi_idx = 0; fi_idx < info->n_functions; fi_idx++) { in convert_to_gcda()
406 fi_ptr = info->functions[fi_idx]; in convert_to_gcda()
412 pos += store_gcov_u32(buffer, pos, fi_ptr->ident); in convert_to_gcda()
413 pos += store_gcov_u32(buffer, pos, fi_ptr->lineno_checksum); in convert_to_gcda()
414 pos += store_gcov_u32(buffer, pos, fi_ptr->cfg_checksum); in convert_to_gcda()
416 ci_ptr = fi_ptr->ctrs; in convert_to_gcda()
426 ci_ptr->num * 2 * GCOV_UNIT_SIZE); in convert_to_gcda()
428 for (cv_idx = 0; cv_idx < ci_ptr->num; cv_idx++) { in convert_to_gcda()
430 ci_ptr->values[cv_idx]); in convert_to_gcda()