Lines Matching +full:com +full:- +full:seq

1 // SPDX-License-Identifier: GPL-2.0
6 * Author(s): Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
8 * Uses gcc-internal data definitions.
9 * Based on the gcov-kernel patch by:
10 * Hubertus Franke <frankeh@us.ibm.com>
11 * Nigel Hinds <nhinds@us.ibm.com>
12 * Rajan Ravindran <rajancr@us.ibm.com>
13 * Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
33 * struct gcov_node - represents a debugfs entry
71 /* If non-zero, keep copies of profiling data for unloaded modules. */
92 * struct gcov_iterator - specifies current file position in logical records
106 * gcov_iter_new - allocate and initialize profiling data iterator
116 /* Dry-run to get the actual buffer size. */ in gcov_iter_new()
123 iter->info = info; in gcov_iter_new()
124 iter->size = size; in gcov_iter_new()
125 convert_to_gcda(iter->buffer, info); in gcov_iter_new()
132 * gcov_iter_free - free iterator data
141 * gcov_iter_get_info - return profiling data set for given file iterator
146 return iter->info; in gcov_iter_get_info()
150 * gcov_iter_start - reset file iterator to starting position
155 iter->pos = 0; in gcov_iter_start()
159 * gcov_iter_next - advance file iterator to next logical record
162 * Return zero if new position is valid, non-zero if iterator has reached end.
166 if (iter->pos < iter->size) in gcov_iter_next()
167 iter->pos += ITER_STRIDE; in gcov_iter_next()
169 if (iter->pos >= iter->size) in gcov_iter_next()
170 return -EINVAL; in gcov_iter_next()
176 * gcov_iter_write - write data for current pos to seq_file
178 * @seq: seq_file handle
180 * Return zero on success, non-zero otherwise.
182 static int gcov_iter_write(struct gcov_iterator *iter, struct seq_file *seq) in gcov_iter_write() argument
186 if (iter->pos >= iter->size) in gcov_iter_write()
187 return -EINVAL; in gcov_iter_write()
190 if (iter->pos + len > iter->size) in gcov_iter_write()
191 len = iter->size - iter->pos; in gcov_iter_write()
193 seq_write(seq, iter->buffer + iter->pos, len); in gcov_iter_write()
204 static void *gcov_seq_start(struct seq_file *seq, loff_t *pos) in gcov_seq_start() argument
208 gcov_iter_start(seq->private); in gcov_seq_start()
210 if (gcov_iter_next(seq->private)) in gcov_seq_start()
213 return seq->private; in gcov_seq_start()
217 static void *gcov_seq_next(struct seq_file *seq, void *data, loff_t *pos) in gcov_seq_next() argument
229 static int gcov_seq_show(struct seq_file *seq, void *data) in gcov_seq_show() argument
233 if (gcov_iter_write(iter, seq)) in gcov_seq_show()
234 return -EINVAL; in gcov_seq_show()
238 static void gcov_seq_stop(struct seq_file *seq, void *data) in gcov_seq_stop() argument
257 if (node->num_loaded > 0) in get_node_info()
258 return node->loaded_info[0]; in get_node_info()
260 return node->unloaded_info; in get_node_info()
272 if (node->unloaded_info) in get_accumulated_info()
273 info = gcov_info_dup(node->unloaded_info); in get_accumulated_info()
275 info = gcov_info_dup(node->loaded_info[i++]); in get_accumulated_info()
278 for (; i < node->num_loaded; i++) in get_accumulated_info()
279 gcov_info_add(info, node->loaded_info[i]); in get_accumulated_info()
290 struct gcov_node *node = inode->i_private; in gcov_seq_open()
292 struct seq_file *seq; in gcov_seq_open() local
294 int rc = -ENOMEM; in gcov_seq_open()
311 seq = file->private_data; in gcov_seq_open()
312 seq->private = iter; in gcov_seq_open()
332 struct seq_file *seq; in gcov_seq_release() local
334 seq = file->private_data; in gcov_seq_release()
335 iter = seq->private; in gcov_seq_release()
369 if (node->unloaded_info) in reset_node()
370 gcov_info_reset(node->unloaded_info); in reset_node()
371 for (i = 0; i < node->num_loaded; i++) in reset_node()
372 gcov_info_reset(node->loaded_info[i]); in reset_node()
385 struct seq_file *seq; in gcov_seq_write() local
389 seq = file->private_data; in gcov_seq_write()
390 info = gcov_iter_get_info(seq->private); in gcov_seq_write()
395 if (node->num_loaded == 0) in gcov_seq_write()
447 if (ext->dir == SRC_TREE) in get_link_target()
448 result = link_target(srctree, rel, ext->ext); in get_link_target()
450 result = link_target(objtree, rel, ext->ext); in get_link_target()
453 result = link_target(NULL, filename, ext->ext); in get_link_target()
463 * for filename skewing caused by the mod-versioning mechanism.
467 if (strncmp(basename, SKEW_PREFIX, sizeof(SKEW_PREFIX) - 1) == 0) in deskew()
468 return basename + sizeof(SKEW_PREFIX) - 1; in deskew()
485 node->links = kcalloc(num, sizeof(struct dentry *), GFP_KERNEL); in add_links()
486 if (!node->links) in add_links()
497 node->links[i] = debugfs_create_symlink(deskew(basename), in add_links()
505 while (i-- > 0) in add_links()
506 debugfs_remove(node->links[i]); in add_links()
507 kfree(node->links); in add_links()
508 node->links = NULL; in add_links()
523 INIT_LIST_HEAD(&node->list); in init_node()
524 INIT_LIST_HEAD(&node->children); in init_node()
525 INIT_LIST_HEAD(&node->all); in init_node()
526 if (node->loaded_info) { in init_node()
527 node->loaded_info[0] = info; in init_node()
528 node->num_loaded = 1; in init_node()
530 node->parent = parent; in init_node()
532 strcpy(node->name, name); in init_node()
548 node->loaded_info = kcalloc(1, sizeof(struct gcov_info *), in new_node()
550 if (!node->loaded_info) in new_node()
556 node->dentry = debugfs_create_file(deskew(node->name), 0600, in new_node()
557 parent->dentry, node, &gcov_data_fops); in new_node()
559 node->dentry = debugfs_create_dir(node->name, parent->dentry); in new_node()
561 add_links(node, parent->dentry); in new_node()
562 list_add(&node->list, &parent->children); in new_node()
563 list_add(&node->all, &all_head); in new_node()
578 if (!node->links) in remove_links()
581 debugfs_remove(node->links[i]); in remove_links()
582 kfree(node->links); in remove_links()
583 node->links = NULL; in remove_links()
592 list_del(&node->list); in release_node()
593 list_del(&node->all); in release_node()
594 debugfs_remove(node->dentry); in release_node()
596 kfree(node->loaded_info); in release_node()
597 if (node->unloaded_info) in release_node()
598 gcov_info_free(node->unloaded_info); in release_node()
607 while ((node != &root_node) && list_empty(&node->children)) { in remove_node()
608 parent = node->parent; in remove_node()
623 list_for_each_entry(node, &parent->children, list) { in get_child_by_name()
624 if (strcmp(node->name, name) == 0) in get_child_by_name()
643 if (node->num_loaded > 0) in reset_write()
645 else if (list_empty(&node->children)) { in reset_write()
647 /* Several nodes may have gone - restart loop. */ in reset_write()
694 if (!parent->parent) in add_node()
696 parent = parent->parent; in add_node()
727 int num = node->num_loaded; in add_info()
740 memcpy(loaded_info, node->loaded_info, in add_info()
749 if (!gcov_info_is_compatible(node->unloaded_info, info)) { in add_info()
753 gcov_info_free(node->unloaded_info); in add_info()
754 node->unloaded_info = NULL; in add_info()
761 if (!gcov_info_is_compatible(node->loaded_info[0], info)) { in add_info()
769 kfree(node->loaded_info); in add_info()
770 node->loaded_info = loaded_info; in add_info()
771 node->num_loaded = num + 1; in add_info()
781 for (i = 0; i < node->num_loaded; i++) { in get_info_index()
782 if (node->loaded_info[i] == info) in get_info_index()
785 return -ENOENT; in get_info_index()
793 if (node->unloaded_info) in save_info()
794 gcov_info_add(node->unloaded_info, info); in save_info()
796 node->unloaded_info = gcov_info_dup(info); in save_info()
797 if (!node->unloaded_info) { in save_info()
822 node->loaded_info[i] = node->loaded_info[node->num_loaded - 1]; in remove_info()
823 node->num_loaded--; in remove_info()
824 if (node->num_loaded > 0) in remove_info()
827 kfree(node->loaded_info); in remove_info()
828 node->loaded_info = NULL; in remove_info()
829 node->num_loaded = 0; in remove_info()
830 if (!node->unloaded_info) in remove_info()
836 * -fprofile-arcs is loaded/unloaded.
878 /* Replay previous events to get our fs hierarchy up-to-date. */ in gcov_fs_init()