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.
43 * struct gcov_ctr_info - information about counters for a single function
47 * This data is generated by gcc during compilation and doesn't change
48 * at run-time with the exception of the values array.
56 * struct gcov_fn_info - profiling meta data per function
63 * This data is generated by gcc during compilation and doesn't change
64 * at run-time.
69 * comdat functions was selected -- it points to the gcov_info object
81 * struct gcov_info - profiling data per object file
83 * @next: list head for a singly-linked list
85 * @filename: name of the associated gcov data file
90 * This data is generated by gcc during compilation and doesn't change
91 * at run-time with the exception of the next pointer.
104 * gcov_info_filename - return info filename
105 * @info: profiling data set
109 return info->filename; in gcov_info_filename()
113 * gcov_info_version - return info version
114 * @info: profiling data set
118 return info->version; in gcov_info_version()
122 * gcov_info_next - return next profiling data set
123 * @info: profiling data set
133 return info->next; in gcov_info_next()
137 * gcov_info_link - link/add profiling data set to the list
138 * @info: profiling data set
142 info->next = gcov_info_head; in gcov_info_link()
147 * gcov_info_unlink - unlink/remove profiling data set from the list
148 * @prev: previous profiling data set
149 * @info: profiling data set
154 prev->next = info->next; in gcov_info_unlink()
156 gcov_info_head = info->next; in gcov_info_unlink()
160 * gcov_info_within_module - check if a profiling data set belongs to a module
161 * @info: profiling data set
164 * Returns true if profiling data belongs module, false otherwise.
171 /* Symbolic links to be created for each profiling data file. */
178 * Determine whether a counter is active. Doesn't change at run-time.
182 return info->merge[type] ? 1 : 0; in counter_active()
185 /* Determine number of active counters. Based on gcc magic. */
199 * gcov_info_reset - reset profiling data to zero
200 * @info: profiling data set
208 for (fi_idx = 0; fi_idx < info->n_functions; fi_idx++) { in gcov_info_reset()
209 ci_ptr = info->functions[fi_idx]->ctrs; in gcov_info_reset()
215 memset(ci_ptr->values, 0, in gcov_info_reset()
216 sizeof(gcov_type) * ci_ptr->num); in gcov_info_reset()
223 * gcov_info_is_compatible - check if profiling data can be added
224 * @info1: first profiling data set
225 * @info2: second profiling data set
227 * Returns non-zero if profiling data can be added, zero otherwise.
231 return (info1->stamp == info2->stamp); in gcov_info_is_compatible()
235 * gcov_info_add - add up profiling data
236 * @dst: profiling data set to which data is added
237 * @src: profiling data set which is added
249 for (fi_idx = 0; fi_idx < src->n_functions; fi_idx++) { in gcov_info_add()
250 dci_ptr = dst->functions[fi_idx]->ctrs; in gcov_info_add()
251 sci_ptr = src->functions[fi_idx]->ctrs; in gcov_info_add()
257 for (val_idx = 0; val_idx < sci_ptr->num; val_idx++) in gcov_info_add()
258 dci_ptr->values[val_idx] += in gcov_info_add()
259 sci_ptr->values[val_idx]; in gcov_info_add()
268 * gcov_info_dup - duplicate profiling data set
269 * @info: profiling data set to duplicate
278 unsigned int active; in gcov_info_dup() local
288 dup->next = NULL; in gcov_info_dup()
289 dup->filename = NULL; in gcov_info_dup()
290 dup->functions = NULL; in gcov_info_dup()
292 dup->filename = kstrdup(info->filename, GFP_KERNEL); in gcov_info_dup()
293 if (!dup->filename) in gcov_info_dup()
296 dup->functions = kcalloc(info->n_functions, in gcov_info_dup()
298 if (!dup->functions) in gcov_info_dup()
301 active = num_counter_active(info); in gcov_info_dup()
303 fi_size += sizeof(struct gcov_ctr_info) * active; in gcov_info_dup()
305 for (fi_idx = 0; fi_idx < info->n_functions; fi_idx++) { in gcov_info_dup()
306 dup->functions[fi_idx] = kzalloc(fi_size, GFP_KERNEL); in gcov_info_dup()
307 if (!dup->functions[fi_idx]) in gcov_info_dup()
310 *(dup->functions[fi_idx]) = *(info->functions[fi_idx]); in gcov_info_dup()
312 sci_ptr = info->functions[fi_idx]->ctrs; in gcov_info_dup()
313 dci_ptr = dup->functions[fi_idx]->ctrs; in gcov_info_dup()
315 for (ct_idx = 0; ct_idx < active; ct_idx++) { in gcov_info_dup()
317 cv_size = sizeof(gcov_type) * sci_ptr->num; in gcov_info_dup()
319 dci_ptr->values = kvmalloc(cv_size, GFP_KERNEL); in gcov_info_dup()
321 if (!dci_ptr->values) in gcov_info_dup()
324 dci_ptr->num = sci_ptr->num; in gcov_info_dup()
325 memcpy(dci_ptr->values, sci_ptr->values, cv_size); in gcov_info_dup()
339 * gcov_info_free - release memory for profiling data set duplicate
340 * @info: profiling data set duplicate to free
344 unsigned int active; in gcov_info_free() local
349 if (!info->functions) in gcov_info_free()
352 active = num_counter_active(info); in gcov_info_free()
354 for (fi_idx = 0; fi_idx < info->n_functions; fi_idx++) { in gcov_info_free()
355 if (!info->functions[fi_idx]) in gcov_info_free()
358 ci_ptr = info->functions[fi_idx]->ctrs; in gcov_info_free()
360 for (ct_idx = 0; ct_idx < active; ct_idx++, ci_ptr++) in gcov_info_free()
361 kvfree(ci_ptr->values); in gcov_info_free()
363 kfree(info->functions[fi_idx]); in gcov_info_free()
367 kfree(info->functions); in gcov_info_free()
368 kfree(info->filename); in gcov_info_free()
373 * convert_to_gcda - convert profiling data set to gcda file format
374 * @buffer: the buffer to store file data or %NULL if no data should be stored
375 * @info: profiling data set to be converted
390 pos += store_gcov_u32(buffer, pos, info->version); in convert_to_gcda()
391 pos += store_gcov_u32(buffer, pos, info->stamp); in convert_to_gcda()
398 for (fi_idx = 0; fi_idx < info->n_functions; fi_idx++) { in convert_to_gcda()
399 fi_ptr = info->functions[fi_idx]; in convert_to_gcda()
405 pos += store_gcov_u32(buffer, pos, fi_ptr->ident); in convert_to_gcda()
406 pos += store_gcov_u32(buffer, pos, fi_ptr->lineno_checksum); in convert_to_gcda()
407 pos += store_gcov_u32(buffer, pos, fi_ptr->cfg_checksum); in convert_to_gcda()
409 ci_ptr = fi_ptr->ctrs; in convert_to_gcda()
419 ci_ptr->num * 2 * GCOV_UNIT_SIZE); in convert_to_gcda()
421 for (cv_idx = 0; cv_idx < ci_ptr->num; cv_idx++) { in convert_to_gcda()
423 ci_ptr->values[cv_idx]); in convert_to_gcda()