trace_output.c (2c1ed907520c50326b8f604907a8478b27881a2e) | trace_output.c (533c20b062d7c25cbcbadb31e3ecb95a08ddb877) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * trace_output.c 4 * 5 * Copyright (C) 2008 Red Hat Inc, Steven Rostedt <srostedt@redhat.com> 6 * 7 */ 8#include <linux/module.h> 9#include <linux/mutex.h> 10#include <linux/ftrace.h> 11#include <linux/kprobes.h> 12#include <linux/sched/clock.h> 13#include <linux/sched/mm.h> 14#include <linux/idr.h> | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * trace_output.c 4 * 5 * Copyright (C) 2008 Red Hat Inc, Steven Rostedt <srostedt@redhat.com> 6 * 7 */ 8#include <linux/module.h> 9#include <linux/mutex.h> 10#include <linux/ftrace.h> 11#include <linux/kprobes.h> 12#include <linux/sched/clock.h> 13#include <linux/sched/mm.h> 14#include <linux/idr.h> |
15#include <linux/btf.h> 16#include <linux/bpf.h> |
|
15 16#include "trace_output.h" | 17 18#include "trace_output.h" |
19#include "trace_btf.h" |
|
17 18/* must be a power of 2 */ 19#define EVENT_HASHSIZE 128 20 21DECLARE_RWSEM(trace_event_sem); 22 23static struct hlist_head event_hash[EVENT_HASHSIZE] __read_mostly; 24 --- 654 unchanged lines hidden (view full) --- 679 lat_print_generic(s, entry, iter->cpu); 680 } 681 682 lat_print_timestamp(iter, next_ts); 683 684 return !trace_seq_has_overflowed(s); 685} 686 | 20 21/* must be a power of 2 */ 22#define EVENT_HASHSIZE 128 23 24DECLARE_RWSEM(trace_event_sem); 25 26static struct hlist_head event_hash[EVENT_HASHSIZE] __read_mostly; 27 --- 654 unchanged lines hidden (view full) --- 682 lat_print_generic(s, entry, iter->cpu); 683 } 684 685 lat_print_timestamp(iter, next_ts); 686 687 return !trace_seq_has_overflowed(s); 688} 689 |
690#ifdef CONFIG_FUNCTION_TRACE_ARGS 691void print_function_args(struct trace_seq *s, unsigned long *args, 692 unsigned long func) 693{ 694 const struct btf_param *param; 695 const struct btf_type *t; 696 const char *param_name; 697 char name[KSYM_NAME_LEN]; 698 unsigned long arg; 699 struct btf *btf; 700 s32 tid, nr = 0; 701 int a, p, x; 702 703 trace_seq_printf(s, "("); 704 705 if (!args) 706 goto out; 707 if (lookup_symbol_name(func, name)) 708 goto out; 709 710 /* TODO: Pass module name here too */ 711 t = btf_find_func_proto(name, &btf); 712 if (IS_ERR_OR_NULL(t)) 713 goto out; 714 715 param = btf_get_func_param(t, &nr); 716 if (!param) 717 goto out_put; 718 719 for (a = 0, p = 0; p < nr; a++, p++) { 720 if (p) 721 trace_seq_puts(s, ", "); 722 723 /* This only prints what the arch allows (6 args by default) */ 724 if (a == FTRACE_REGS_MAX_ARGS) { 725 trace_seq_puts(s, "..."); 726 break; 727 } 728 729 arg = args[a]; 730 731 param_name = btf_name_by_offset(btf, param[p].name_off); 732 if (param_name) 733 trace_seq_printf(s, "%s=", param_name); 734 t = btf_type_skip_modifiers(btf, param[p].type, &tid); 735 736 switch (t ? BTF_INFO_KIND(t->info) : BTF_KIND_UNKN) { 737 case BTF_KIND_UNKN: 738 trace_seq_putc(s, '?'); 739 /* Still print unknown type values */ 740 fallthrough; 741 case BTF_KIND_PTR: 742 trace_seq_printf(s, "0x%lx", arg); 743 break; 744 case BTF_KIND_INT: 745 trace_seq_printf(s, "%ld", arg); 746 break; 747 case BTF_KIND_ENUM: 748 trace_seq_printf(s, "%ld", arg); 749 break; 750 default: 751 /* This does not handle complex arguments */ 752 trace_seq_printf(s, "(%s)[0x%lx", btf_type_str(t), arg); 753 for (x = sizeof(long); x < t->size; x += sizeof(long)) { 754 trace_seq_putc(s, ':'); 755 if (++a == FTRACE_REGS_MAX_ARGS) { 756 trace_seq_puts(s, "...]"); 757 goto out_put; 758 } 759 trace_seq_printf(s, "0x%lx", args[a]); 760 } 761 trace_seq_putc(s, ']'); 762 break; 763 } 764 } 765out_put: 766 btf_put(btf); 767out: 768 trace_seq_printf(s, ")"); 769} 770#endif 771 |
|
687/** 688 * ftrace_find_event - find a registered event 689 * @type: the type of event to look for 690 * 691 * Returns an event of type @type otherwise NULL 692 * Called with trace_event_read_lock() held. 693 */ 694struct trace_event *ftrace_find_event(int type) --- 1057 unchanged lines hidden --- | 772/** 773 * ftrace_find_event - find a registered event 774 * @type: the type of event to look for 775 * 776 * Returns an event of type @type otherwise NULL 777 * Called with trace_event_read_lock() held. 778 */ 779struct trace_event *ftrace_find_event(int type) --- 1057 unchanged lines hidden --- |