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
86 * @filename: name of the associated gcov data file
91 * This data is generated by gcc during compilation and doesn't change
92 * at run-time with the exception of the next pointer.
109 * gcov_info_filename - return info filename
110 * @info: profiling data set
114 return info->filename; in gcov_info_filename()
118 * gcov_info_version - return info version
119 * @info: profiling data set
123 return info->version; in gcov_info_version()
127 * gcov_info_next - return next profiling data set
128 * @info: profiling data set
138 return info->next; in gcov_info_next()
142 * gcov_info_link - link/add profiling data set to the list
143 * @info: profiling data set
147 info->next = gcov_info_head; in gcov_info_link()
152 * gcov_info_unlink - unlink/remove profiling data set from the list
153 * @prev: previous profiling data set
154 * @info: profiling data set
159 prev->next = info->next; in gcov_info_unlink()
161 gcov_info_head = info->next; in gcov_info_unlink()
165 * gcov_info_within_module - check if a profiling data set belongs to a module
166 * @info: profiling data set
169 * Returns true if profiling data belongs module, false otherwise.
176 /* Symbolic links to be created for each profiling data file. */
183 * Determine whether a counter is active. Doesn't change at run-time.
187 return info->merge[type] ? 1 : 0; in counter_active()
190 /* Determine number of active counters. Based on gcc magic. */
204 * gcov_info_reset - reset profiling data to zero
205 * @info: profiling data set
213 for (fi_idx = 0; fi_idx < info->n_functions; fi_idx++) { in gcov_info_reset()
214 ci_ptr = info->functions[fi_idx]->ctrs; in gcov_info_reset()
220 memset(ci_ptr->values, 0, in gcov_info_reset()
221 sizeof(gcov_type) * ci_ptr->num); in gcov_info_reset()
228 * gcov_info_is_compatible - check if profiling data can be added
229 * @info1: first profiling data set
230 * @info2: second profiling data set
232 * Returns non-zero if profiling data can be added, zero otherwise.
236 return (info1->stamp == info2->stamp); in gcov_info_is_compatible()
240 * gcov_info_add - add up profiling data
241 * @dst: profiling data set to which data is added
242 * @src: profiling data set which is added
254 for (fi_idx = 0; fi_idx < src->n_functions; fi_idx++) { in gcov_info_add()
255 dci_ptr = dst->functions[fi_idx]->ctrs; in gcov_info_add()
256 sci_ptr = src->functions[fi_idx]->ctrs; in gcov_info_add()
262 for (val_idx = 0; val_idx < sci_ptr->num; val_idx++) in gcov_info_add()
263 dci_ptr->values[val_idx] += in gcov_info_add()
264 sci_ptr->values[val_idx]; in gcov_info_add()
273 * gcov_info_dup - duplicate profiling data set
274 * @info: profiling data set to duplicate
283 unsigned int active; in gcov_info_dup() local
293 dup->next = NULL; in gcov_info_dup()
294 dup->filename = NULL; in gcov_info_dup()
295 dup->functions = NULL; in gcov_info_dup()
297 dup->filename = kstrdup(info->filename, GFP_KERNEL); in gcov_info_dup()
298 if (!dup->filename) in gcov_info_dup()
301 dup->functions = kcalloc(info->n_functions, in gcov_info_dup()
303 if (!dup->functions) in gcov_info_dup()
306 active = num_counter_active(info); in gcov_info_dup()
308 fi_size += sizeof(struct gcov_ctr_info) * active; in gcov_info_dup()
310 for (fi_idx = 0; fi_idx < info->n_functions; fi_idx++) { in gcov_info_dup()
311 dup->functions[fi_idx] = kzalloc(fi_size, GFP_KERNEL); in gcov_info_dup()
312 if (!dup->functions[fi_idx]) in gcov_info_dup()
315 *(dup->functions[fi_idx]) = *(info->functions[fi_idx]); in gcov_info_dup()
317 sci_ptr = info->functions[fi_idx]->ctrs; in gcov_info_dup()
318 dci_ptr = dup->functions[fi_idx]->ctrs; in gcov_info_dup()
320 for (ct_idx = 0; ct_idx < active; ct_idx++) { in gcov_info_dup()
322 cv_size = sizeof(gcov_type) * sci_ptr->num; in gcov_info_dup()
324 dci_ptr->values = kvmalloc(cv_size, GFP_KERNEL); in gcov_info_dup()
326 if (!dci_ptr->values) in gcov_info_dup()
329 dci_ptr->num = sci_ptr->num; in gcov_info_dup()
330 memcpy(dci_ptr->values, sci_ptr->values, cv_size); in gcov_info_dup()
344 * gcov_info_free - release memory for profiling data set duplicate
345 * @info: profiling data set duplicate to free
349 unsigned int active; in gcov_info_free() local
354 if (!info->functions) in gcov_info_free()
357 active = num_counter_active(info); in gcov_info_free()
359 for (fi_idx = 0; fi_idx < info->n_functions; fi_idx++) { in gcov_info_free()
360 if (!info->functions[fi_idx]) in gcov_info_free()
363 ci_ptr = info->functions[fi_idx]->ctrs; in gcov_info_free()
365 for (ct_idx = 0; ct_idx < active; ct_idx++, ci_ptr++) in gcov_info_free()
366 kvfree(ci_ptr->values); in gcov_info_free()
368 kfree(info->functions[fi_idx]); in gcov_info_free()
372 kfree(info->functions); in gcov_info_free()
373 kfree(info->filename); in gcov_info_free()
378 * convert_to_gcda - convert profiling data set to gcda file format
379 * @buffer: the buffer to store file data or %NULL if no data should be stored
380 * @info: profiling data set to be converted
395 pos += store_gcov_u32(buffer, pos, info->version); in convert_to_gcda()
396 pos += store_gcov_u32(buffer, pos, info->stamp); in convert_to_gcda()
403 for (fi_idx = 0; fi_idx < info->n_functions; fi_idx++) { in convert_to_gcda()
404 fi_ptr = info->functions[fi_idx]; in convert_to_gcda()
410 pos += store_gcov_u32(buffer, pos, fi_ptr->ident); in convert_to_gcda()
411 pos += store_gcov_u32(buffer, pos, fi_ptr->lineno_checksum); in convert_to_gcda()
412 pos += store_gcov_u32(buffer, pos, fi_ptr->cfg_checksum); in convert_to_gcda()
414 ci_ptr = fi_ptr->ctrs; in convert_to_gcda()
424 ci_ptr->num * 2 * GCOV_UNIT_SIZE); in convert_to_gcda()
426 for (cv_idx = 0; cv_idx < ci_ptr->num; cv_idx++) { in convert_to_gcda()
428 ci_ptr->values[cv_idx]); in convert_to_gcda()