License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 22:07:57 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2009-09-25 00:02:18 +08:00
|
|
|
#ifndef __PERF_SYMBOL
|
|
|
|
#define __PERF_SYMBOL 1
|
2009-05-29 01:55:04 +08:00
|
|
|
|
|
|
|
#include <linux/types.h>
|
2019-08-30 21:19:19 +08:00
|
|
|
#include <linux/refcount.h>
|
2009-10-21 00:25:40 +08:00
|
|
|
#include <stdbool.h>
|
2010-03-26 06:59:00 +08:00
|
|
|
#include <stdint.h>
|
2009-07-02 01:46:08 +08:00
|
|
|
#include <linux/list.h>
|
2009-07-01 23:28:37 +08:00
|
|
|
#include <linux/rbtree.h>
|
2010-03-26 06:59:00 +08:00
|
|
|
#include <stdio.h>
|
2023-06-09 07:28:02 +08:00
|
|
|
#include "addr_location.h"
|
2017-04-18 22:33:48 +08:00
|
|
|
#include "path.h"
|
2019-01-22 20:32:27 +08:00
|
|
|
#include "symbol_conf.h"
|
2019-09-25 09:14:46 +08:00
|
|
|
#include "spark.h"
|
2009-05-29 01:55:04 +08:00
|
|
|
|
2013-09-30 18:07:11 +08:00
|
|
|
#ifdef HAVE_LIBELF_SUPPORT
|
2012-08-11 06:22:57 +08:00
|
|
|
#include <libelf.h>
|
|
|
|
#include <gelf.h>
|
|
|
|
#endif
|
2012-12-28 15:16:49 +08:00
|
|
|
#include <elf.h>
|
2012-08-11 06:22:57 +08:00
|
|
|
|
2019-08-30 21:26:37 +08:00
|
|
|
struct dso;
|
2019-01-22 21:14:55 +08:00
|
|
|
struct map;
|
2019-11-26 08:58:33 +08:00
|
|
|
struct maps;
|
2019-01-22 21:14:55 +08:00
|
|
|
struct option;
|
2020-10-14 03:24:34 +08:00
|
|
|
struct build_id;
|
2019-01-22 21:14:55 +08:00
|
|
|
|
2009-10-25 00:10:36 +08:00
|
|
|
/*
|
|
|
|
* libelf 0.8.x and earlier do not support ELF_C_READ_MMAP;
|
|
|
|
* for newer versions we can use mmap to reduce memory usage:
|
|
|
|
*/
|
2020-08-19 09:36:07 +08:00
|
|
|
#ifdef ELF_C_READ_MMAP
|
2009-10-25 00:10:36 +08:00
|
|
|
# define PERF_ELF_C_READ_MMAP ELF_C_READ_MMAP
|
2012-09-28 17:31:59 +08:00
|
|
|
#else
|
|
|
|
# define PERF_ELF_C_READ_MMAP ELF_C_READ
|
2009-10-25 00:10:36 +08:00
|
|
|
#endif
|
|
|
|
|
2014-01-16 17:39:49 +08:00
|
|
|
#ifdef HAVE_LIBELF_SUPPORT
|
2016-03-24 02:06:35 +08:00
|
|
|
Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep,
|
|
|
|
GElf_Shdr *shp, const char *name, size_t *idx);
|
2014-01-16 17:39:49 +08:00
|
|
|
#endif
|
|
|
|
|
2021-11-12 11:51:22 +08:00
|
|
|
/**
|
|
|
|
* A symtab entry. When allocated this may be preceded by an annotation (see
|
|
|
|
* symbol__annotation), a browser_index (see symbol__browser_index) and rb_node
|
|
|
|
* to sort by name (see struct symbol_name_rb_node).
|
2011-03-12 00:36:01 +08:00
|
|
|
*/
|
2009-05-29 01:55:04 +08:00
|
|
|
struct symbol {
|
|
|
|
struct rb_node rb_node;
|
2021-11-12 11:51:22 +08:00
|
|
|
/** Range of symbol [start, end). */
|
perf_counter tools: Define and use our own u64, s64 etc. definitions
On 64-bit powerpc, __u64 is defined to be unsigned long rather than
unsigned long long. This causes compiler warnings every time we
print a __u64 value with %Lx.
Rather than changing __u64, we define our own u64 to be unsigned long
long on all architectures, and similarly s64 as signed long long.
For consistency we also define u32, s32, u16, s16, u8 and s8. These
definitions are put in a new header, types.h, because these definitions
are needed in util/string.h and util/symbol.h.
The main change here is the mechanical change of __[us]{64,32,16,8}
to remove the "__". The other changes are:
* Create types.h
* Include types.h in perf.h, util/string.h and util/symbol.h
* Add types.h to the LIB_H definition in Makefile
* Added (u64) casts in process_overflow_event() and print_sym_table()
to kill two remaining warnings.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: benh@kernel.crashing.org
LKML-Reference: <19003.33494.495844.956580@cargo.ozlabs.ibm.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2009-06-19 20:21:42 +08:00
|
|
|
u64 start;
|
|
|
|
u64 end;
|
2021-11-12 11:51:22 +08:00
|
|
|
/** Length of the string name. */
|
2010-05-11 00:57:51 +08:00
|
|
|
u16 namelen;
|
2021-11-12 11:51:22 +08:00
|
|
|
/** ELF symbol type as defined for st_info. E.g STT_OBJECT or STT_FUNC. */
|
2018-04-26 22:09:10 +08:00
|
|
|
u8 type:4;
|
2021-11-12 11:51:22 +08:00
|
|
|
/** ELF binding type as defined for st_info. E.g. STB_WEAK or STB_GLOBAL. */
|
2018-04-26 22:09:10 +08:00
|
|
|
u8 binding:4;
|
2021-11-12 11:51:22 +08:00
|
|
|
/** Set true for kernel symbols of idle routines. */
|
2016-08-30 22:15:59 +08:00
|
|
|
u8 idle:1;
|
2021-11-12 11:51:22 +08:00
|
|
|
/** Resolvable but tools ignore it (e.g. idle routines). */
|
2016-11-24 09:11:12 +08:00
|
|
|
u8 ignore:1;
|
2021-11-12 11:51:22 +08:00
|
|
|
/** Symbol for an inlined function. */
|
2017-10-10 04:32:57 +08:00
|
|
|
u8 inlined:1;
|
2021-11-12 11:51:23 +08:00
|
|
|
/** Has symbol__annotate2 been performed. */
|
|
|
|
u8 annotate2:1;
|
2023-01-31 21:16:20 +08:00
|
|
|
/** Symbol is an alias of an STT_GNU_IFUNC */
|
|
|
|
u8 ifunc_alias:1;
|
2021-11-12 11:51:22 +08:00
|
|
|
/** Architecture specific. Unused except on PPC where it holds st_other. */
|
2016-04-12 17:10:50 +08:00
|
|
|
u8 arch_sym;
|
2021-11-12 11:51:22 +08:00
|
|
|
/** The name of length namelen associated with the symbol. */
|
2020-05-16 01:29:26 +08:00
|
|
|
char name[];
|
2009-05-29 01:55:04 +08:00
|
|
|
};
|
|
|
|
|
2011-03-31 21:56:28 +08:00
|
|
|
void symbol__delete(struct symbol *sym);
|
2018-12-07 03:18:17 +08:00
|
|
|
void symbols__delete(struct rb_root_cached *symbols);
|
2010-02-25 23:57:40 +08:00
|
|
|
|
perf probe: Allow to add events on the local functions
Allow to add events on the local functions without debuginfo.
(With the debuginfo, we can add events even on inlined functions)
Currently, probing on local functions requires debuginfo to
locate actual address. It is also possible without debuginfo since
we have symbol maps.
Without this change;
----
# ./perf probe -a t_show
Added new event:
probe:t_show (on t_show)
You can now use it in all perf tools, such as:
perf record -e probe:t_show -aR sleep 1
# ./perf probe -x perf -a identity__map_ip
no symbols found in /kbuild/ksrc/linux-3/tools/perf/perf, maybe install a debug package?
Failed to load map.
Error: Failed to add events. (-22)
----
As the above results, perf probe just put one event
on the first found symbol for kprobe event. Moreover,
for uprobe event, perf probe failed to find local
functions.
With this change;
----
# ./perf probe -a t_show
Added new events:
probe:t_show (on t_show)
probe:t_show_1 (on t_show)
probe:t_show_2 (on t_show)
probe:t_show_3 (on t_show)
You can now use it in all perf tools, such as:
perf record -e probe:t_show_3 -aR sleep 1
# ./perf probe -x perf -a identity__map_ip
Added new events:
probe_perf:identity__map_ip (on identity__map_ip in /kbuild/ksrc/linux-3/tools/perf/perf)
probe_perf:identity__map_ip_1 (on identity__map_ip in /kbuild/ksrc/linux-3/tools/perf/perf)
probe_perf:identity__map_ip_2 (on identity__map_ip in /kbuild/ksrc/linux-3/tools/perf/perf)
probe_perf:identity__map_ip_3 (on identity__map_ip in /kbuild/ksrc/linux-3/tools/perf/perf)
You can now use it in all perf tools, such as:
perf record -e probe_perf:identity__map_ip_3 -aR sleep 1
----
Now we succeed to put events on every given local functions
for both kprobes and uprobes. :)
Note that this also introduces some symbol rbtree
iteration macros; symbols__for_each, dso__for_each_symbol,
and map__for_each_symbol. These are for walking through
the symbol list in a map.
Changes from v2:
- Fix add_exec_to_probe_trace_events() not to convert address
to tp->symbol any more.
- Fix to set kernel probes based on ref_reloc_sym.
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: "David A. Long" <dave.long@linaro.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: yrl.pp-manager.tt@hitachi.com
Link: http://lkml.kernel.org/r/20140206053225.29635.15026.stgit@kbuild-fedora.yrl.intra.hitachi.co.jp
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2014-02-06 13:32:25 +08:00
|
|
|
/* symbols__for_each_entry - iterate over symbols (rb_root)
|
|
|
|
*
|
|
|
|
* @symbols: the rb_root of symbols
|
|
|
|
* @pos: the 'struct symbol *' to use as a loop cursor
|
|
|
|
* @nd: the 'struct rb_node *' to use as a temporary storage
|
|
|
|
*/
|
|
|
|
#define symbols__for_each_entry(symbols, pos, nd) \
|
2018-12-07 03:18:17 +08:00
|
|
|
for (nd = rb_first_cached(symbols); \
|
perf probe: Allow to add events on the local functions
Allow to add events on the local functions without debuginfo.
(With the debuginfo, we can add events even on inlined functions)
Currently, probing on local functions requires debuginfo to
locate actual address. It is also possible without debuginfo since
we have symbol maps.
Without this change;
----
# ./perf probe -a t_show
Added new event:
probe:t_show (on t_show)
You can now use it in all perf tools, such as:
perf record -e probe:t_show -aR sleep 1
# ./perf probe -x perf -a identity__map_ip
no symbols found in /kbuild/ksrc/linux-3/tools/perf/perf, maybe install a debug package?
Failed to load map.
Error: Failed to add events. (-22)
----
As the above results, perf probe just put one event
on the first found symbol for kprobe event. Moreover,
for uprobe event, perf probe failed to find local
functions.
With this change;
----
# ./perf probe -a t_show
Added new events:
probe:t_show (on t_show)
probe:t_show_1 (on t_show)
probe:t_show_2 (on t_show)
probe:t_show_3 (on t_show)
You can now use it in all perf tools, such as:
perf record -e probe:t_show_3 -aR sleep 1
# ./perf probe -x perf -a identity__map_ip
Added new events:
probe_perf:identity__map_ip (on identity__map_ip in /kbuild/ksrc/linux-3/tools/perf/perf)
probe_perf:identity__map_ip_1 (on identity__map_ip in /kbuild/ksrc/linux-3/tools/perf/perf)
probe_perf:identity__map_ip_2 (on identity__map_ip in /kbuild/ksrc/linux-3/tools/perf/perf)
probe_perf:identity__map_ip_3 (on identity__map_ip in /kbuild/ksrc/linux-3/tools/perf/perf)
You can now use it in all perf tools, such as:
perf record -e probe_perf:identity__map_ip_3 -aR sleep 1
----
Now we succeed to put events on every given local functions
for both kprobes and uprobes. :)
Note that this also introduces some symbol rbtree
iteration macros; symbols__for_each, dso__for_each_symbol,
and map__for_each_symbol. These are for walking through
the symbol list in a map.
Changes from v2:
- Fix add_exec_to_probe_trace_events() not to convert address
to tp->symbol any more.
- Fix to set kernel probes based on ref_reloc_sym.
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: "David A. Long" <dave.long@linaro.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: yrl.pp-manager.tt@hitachi.com
Link: http://lkml.kernel.org/r/20140206053225.29635.15026.stgit@kbuild-fedora.yrl.intra.hitachi.co.jp
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2014-02-06 13:32:25 +08:00
|
|
|
nd && (pos = rb_entry(nd, struct symbol, rb_node)); \
|
|
|
|
nd = rb_next(nd))
|
|
|
|
|
2012-04-19 21:57:06 +08:00
|
|
|
static inline size_t symbol__size(const struct symbol *sym)
|
|
|
|
{
|
2014-10-15 04:19:44 +08:00
|
|
|
return sym->end - sym->start;
|
2012-04-19 21:57:06 +08:00
|
|
|
}
|
|
|
|
|
2009-12-16 06:04:40 +08:00
|
|
|
struct strlist;
|
2015-03-24 23:52:41 +08:00
|
|
|
struct intlist;
|
2009-12-16 06:04:40 +08:00
|
|
|
|
2016-04-15 02:54:36 +08:00
|
|
|
struct symbol_name_rb_node {
|
|
|
|
struct rb_node rb_node;
|
|
|
|
struct symbol sym;
|
|
|
|
};
|
|
|
|
|
2014-07-29 21:21:58 +08:00
|
|
|
static inline int __symbol__join_symfs(char *bf, size_t size, const char *path)
|
|
|
|
{
|
|
|
|
return path__join(bf, size, symbol_conf.symfs, path);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define symbol__join_symfs(bf, path) __symbol__join_symfs(bf, sizeof(bf), path)
|
|
|
|
|
2012-12-08 04:39:39 +08:00
|
|
|
extern int vmlinux_path__nr_entries;
|
|
|
|
extern char **vmlinux_path;
|
2009-10-31 02:28:24 +08:00
|
|
|
|
2011-03-31 21:56:28 +08:00
|
|
|
static inline void *symbol__priv(struct symbol *sym)
|
2009-10-31 02:28:24 +08:00
|
|
|
{
|
2011-03-31 21:56:28 +08:00
|
|
|
return ((void *)sym) - symbol_conf.priv_size;
|
2009-10-31 02:28:24 +08:00
|
|
|
}
|
|
|
|
|
2010-02-04 02:52:00 +08:00
|
|
|
struct ref_reloc_sym {
|
|
|
|
const char *name;
|
|
|
|
u64 addr;
|
|
|
|
u64 unrelocated_addr;
|
|
|
|
};
|
|
|
|
|
2016-09-02 06:25:52 +08:00
|
|
|
int dso__load(struct dso *dso, struct map *map);
|
2011-03-31 21:56:28 +08:00
|
|
|
int dso__load_vmlinux(struct dso *dso, struct map *map,
|
2016-09-02 06:25:52 +08:00
|
|
|
const char *vmlinux, bool vmlinux_allocated);
|
|
|
|
int dso__load_vmlinux_path(struct dso *dso, struct map *map);
|
2016-04-19 23:12:49 +08:00
|
|
|
int __dso__load_kallsyms(struct dso *dso, const char *filename, struct map *map,
|
2016-09-02 06:25:52 +08:00
|
|
|
bool no_kcore);
|
|
|
|
int dso__load_kallsyms(struct dso *dso, const char *filename, struct map *map);
|
2012-10-28 05:18:32 +08:00
|
|
|
|
2018-04-27 03:52:34 +08:00
|
|
|
void dso__insert_symbol(struct dso *dso,
|
2020-10-16 19:47:18 +08:00
|
|
|
struct symbol *sym);
|
|
|
|
void dso__delete_symbol(struct dso *dso,
|
2016-05-11 11:26:46 +08:00
|
|
|
struct symbol *sym);
|
|
|
|
|
2018-04-27 03:52:34 +08:00
|
|
|
struct symbol *dso__find_symbol(struct dso *dso, u64 addr);
|
2023-01-20 20:34:50 +08:00
|
|
|
struct symbol *dso__find_symbol_nocache(struct dso *dso, u64 addr);
|
2018-04-27 03:52:34 +08:00
|
|
|
struct symbol *dso__find_symbol_by_name(struct dso *dso, const char *name);
|
2018-04-26 04:46:28 +08:00
|
|
|
|
2015-01-17 02:39:53 +08:00
|
|
|
struct symbol *symbol__next_by_name(struct symbol *sym);
|
2009-05-29 01:55:04 +08:00
|
|
|
|
2018-04-26 04:01:46 +08:00
|
|
|
struct symbol *dso__first_symbol(struct dso *dso);
|
|
|
|
struct symbol *dso__last_symbol(struct dso *dso);
|
2014-07-14 18:02:50 +08:00
|
|
|
struct symbol *dso__next_symbol(struct symbol *sym);
|
|
|
|
|
2014-07-22 21:17:59 +08:00
|
|
|
enum dso_type dso__type_fd(int fd);
|
|
|
|
|
2020-10-14 03:24:34 +08:00
|
|
|
int filename__read_build_id(const char *filename, struct build_id *id);
|
2020-10-14 03:24:35 +08:00
|
|
|
int sysfs__read_build_id(const char *filename, struct build_id *bid);
|
2013-10-08 16:45:48 +08:00
|
|
|
int modules__parse(const char *filename, void *arg,
|
|
|
|
int (*process_module)(void *arg, const char *name,
|
2017-08-03 21:49:02 +08:00
|
|
|
u64 start, u64 size));
|
2012-08-06 12:41:20 +08:00
|
|
|
int filename__read_debuglink(const char *filename, char *debuglink,
|
|
|
|
size_t size);
|
2022-12-16 03:28:11 +08:00
|
|
|
bool filename__has_section(const char *filename, const char *sec);
|
2009-11-04 07:46:10 +08:00
|
|
|
|
2015-08-28 17:48:04 +08:00
|
|
|
struct perf_env;
|
|
|
|
int symbol__init(struct perf_env *env);
|
2010-07-31 05:31:28 +08:00
|
|
|
void symbol__exit(void);
|
2012-08-06 12:41:19 +08:00
|
|
|
void symbol__elf_init(void);
|
2016-08-26 03:09:21 +08:00
|
|
|
int symbol__annotation_init(void);
|
|
|
|
|
2018-04-26 22:09:10 +08:00
|
|
|
struct symbol *symbol__new(u64 start, u64 len, u8 binding, u8 type, const char *name);
|
2016-04-12 09:03:56 +08:00
|
|
|
size_t __symbol__fprintf_symname_offs(const struct symbol *sym,
|
|
|
|
const struct addr_location *al,
|
2016-11-16 14:06:27 +08:00
|
|
|
bool unknown_as_addr,
|
|
|
|
bool print_offsets, FILE *fp);
|
2012-01-30 12:43:15 +08:00
|
|
|
size_t symbol__fprintf_symname_offs(const struct symbol *sym,
|
|
|
|
const struct addr_location *al, FILE *fp);
|
2016-04-12 09:03:56 +08:00
|
|
|
size_t __symbol__fprintf_symname(const struct symbol *sym,
|
|
|
|
const struct addr_location *al,
|
|
|
|
bool unknown_as_addr, FILE *fp);
|
2012-01-30 12:42:57 +08:00
|
|
|
size_t symbol__fprintf_symname(const struct symbol *sym, FILE *fp);
|
2012-10-28 05:18:32 +08:00
|
|
|
size_t symbol__fprintf(struct symbol *sym, FILE *fp);
|
2012-12-08 04:39:39 +08:00
|
|
|
bool symbol__restricted_filename(const char *filename,
|
|
|
|
const char *restricted_filename);
|
2016-05-19 19:47:37 +08:00
|
|
|
int symbol__config_symfs(const struct option *opt __maybe_unused,
|
|
|
|
const char *dir, int unset __maybe_unused);
|
2010-01-05 02:19:27 +08:00
|
|
|
|
2019-08-30 21:26:37 +08:00
|
|
|
struct symsrc;
|
|
|
|
|
2020-08-22 00:52:37 +08:00
|
|
|
#ifdef HAVE_LIBBFD_SUPPORT
|
|
|
|
int dso__load_bfd_symbols(struct dso *dso, const char *debugfile);
|
|
|
|
#endif
|
|
|
|
|
2012-08-11 06:23:01 +08:00
|
|
|
int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss,
|
2016-09-02 06:25:52 +08:00
|
|
|
struct symsrc *runtime_ss, int kmodule);
|
2018-04-27 03:52:34 +08:00
|
|
|
int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss);
|
2012-08-06 12:41:20 +08:00
|
|
|
|
2017-08-07 05:24:34 +08:00
|
|
|
char *dso__demangle_sym(struct dso *dso, int kmodule, const char *elf_name);
|
2017-03-26 04:34:26 +08:00
|
|
|
|
2018-12-07 03:18:17 +08:00
|
|
|
void __symbols__insert(struct rb_root_cached *symbols, struct symbol *sym,
|
|
|
|
bool kernel);
|
|
|
|
void symbols__insert(struct rb_root_cached *symbols, struct symbol *sym);
|
|
|
|
void symbols__fixup_duplicate(struct rb_root_cached *symbols);
|
2022-04-16 08:40:46 +08:00
|
|
|
void symbols__fixup_end(struct rb_root_cached *symbols, bool is_kallsyms);
|
2019-11-26 09:21:28 +08:00
|
|
|
void maps__fixup_end(struct maps *maps);
|
2012-08-06 12:41:20 +08:00
|
|
|
|
2013-08-07 19:38:51 +08:00
|
|
|
typedef int (*mapfn_t)(u64 start, u64 len, u64 pgoff, void *data);
|
|
|
|
int file__read_maps(int fd, bool exe, mapfn_t mapfn, void *data,
|
|
|
|
bool *is_64_bit);
|
|
|
|
|
2013-10-09 20:01:12 +08:00
|
|
|
#define PERF_KCORE_EXTRACT "/tmp/perf-kcore-XXXXXX"
|
|
|
|
|
|
|
|
struct kcore_extract {
|
|
|
|
char *kcore_filename;
|
|
|
|
u64 addr;
|
|
|
|
u64 offs;
|
|
|
|
u64 len;
|
|
|
|
char extract_filename[sizeof(PERF_KCORE_EXTRACT)];
|
|
|
|
int fd;
|
|
|
|
};
|
|
|
|
|
|
|
|
int kcore_extract__create(struct kcore_extract *kce);
|
|
|
|
void kcore_extract__delete(struct kcore_extract *kce);
|
|
|
|
|
2013-10-14 21:57:29 +08:00
|
|
|
int kcore_copy(const char *from_dir, const char *to_dir);
|
|
|
|
int compare_proc_modules(const char *from, const char *to);
|
|
|
|
|
2013-11-19 04:32:48 +08:00
|
|
|
int setup_list(struct strlist **list, const char *list_str,
|
|
|
|
const char *list_name);
|
2015-03-24 23:52:41 +08:00
|
|
|
int setup_intlist(struct intlist **list, const char *list_str,
|
|
|
|
const char *list_name);
|
2013-11-19 04:32:48 +08:00
|
|
|
|
2015-04-28 20:05:35 +08:00
|
|
|
#ifdef HAVE_LIBELF_SUPPORT
|
|
|
|
bool elf__needs_adjust_symbols(GElf_Ehdr ehdr);
|
2016-04-12 17:10:50 +08:00
|
|
|
void arch__sym_update(struct symbol *s, GElf_Sym *sym);
|
2015-04-28 20:05:35 +08:00
|
|
|
#endif
|
|
|
|
|
2017-12-09 00:28:12 +08:00
|
|
|
const char *arch__normalize_symbol_name(const char *name);
|
2015-04-28 20:05:36 +08:00
|
|
|
#define SYMBOL_A 0
|
|
|
|
#define SYMBOL_B 1
|
|
|
|
|
perf symbols: Allow user probes on versioned symbols
Symbol versioning, as in glibc, results in symbols being defined as:
<real symbol>@[@]<version>
(Note that "@@" identifies a default symbol, if the symbol name is
repeated.)
perf is currently unable to deal with this, and is unable to create user
probes at such symbols:
--
$ nm /lib/powerpc64le-linux-gnu/libpthread.so.0 | grep pthread_create
0000000000008d30 t __pthread_create_2_1
0000000000008d30 T pthread_create@@GLIBC_2.17
$ /usr/bin/sudo perf probe -v -x /lib/powerpc64le-linux-gnu/libpthread.so.0 pthread_create
probe-definition(0): pthread_create
symbol:pthread_create file:(null) line:0 offset:0 return:0 lazy:(null)
0 arguments
Open Debuginfo file: /usr/lib/debug/lib/powerpc64le-linux-gnu/libpthread-2.19.so
Try to find probe point from debuginfo.
Probe point 'pthread_create' not found.
Error: Failed to add events. Reason: No such file or directory (Code: -2)
--
One is not able to specify the fully versioned symbol, either, due to
syntactic conflicts with other uses of "@" by perf:
--
$ /usr/bin/sudo perf probe -v -x /lib/powerpc64le-linux-gnu/libpthread.so.0 pthread_create@@GLIBC_2.17
probe-definition(0): pthread_create@@GLIBC_2.17
Semantic error :SRC@SRC is not allowed.
0 arguments
Error: Command Parse Error. Reason: Invalid argument (Code: -22)
--
This patch ignores versioning for default symbols, thus allowing probes to be
created for these symbols:
--
$ /usr/bin/sudo ./perf probe -x /lib/powerpc64le-linux-gnu/libpthread.so.0 pthread_create
Added new event:
probe_libpthread:pthread_create (on pthread_create in /lib/powerpc64le-linux-gnu/libpthread-2.19.so)
You can now use it in all perf tools, such as:
perf record -e probe_libpthread:pthread_create -aR sleep 1
$ /usr/bin/sudo ./perf record -e probe_libpthread:pthread_create -aR ./test 2
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.052 MB perf.data (2 samples) ]
$ /usr/bin/sudo ./perf script
test 2915 [000] 19124.260729: probe_libpthread:pthread_create: (3fff99248d38)
test 2916 [000] 19124.260962: probe_libpthread:pthread_create: (3fff99248d38)
$ /usr/bin/sudo ./perf probe --del=probe_libpthread:pthread_create
Removed event: probe_libpthread:pthread_create
--
Committer note:
Change the variable storing the result of strlen() to 'int', to fix the build
on debian:experimental-x-mipsel, fedora:24-x-ARC-uClibc, ubuntu:16.04-x-arm,
etc:
util/symbol.c: In function 'symbol__match_symbol_name':
util/symbol.c:422:11: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
if (len < versioning - name)
^
Signed-off-by: Paul A. Clarke <pc@us.ibm.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Link: http://lkml.kernel.org/r/c2b18d9c-17f8-9285-4868-f58b6359ccac@us.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2017-04-26 02:15:49 +08:00
|
|
|
int arch__compare_symbol_names(const char *namea, const char *nameb);
|
|
|
|
int arch__compare_symbol_names_n(const char *namea, const char *nameb,
|
|
|
|
unsigned int n);
|
2015-04-28 20:05:36 +08:00
|
|
|
int arch__choose_best_symbol(struct symbol *syma, struct symbol *symb);
|
|
|
|
|
perf symbols: Allow user probes on versioned symbols
Symbol versioning, as in glibc, results in symbols being defined as:
<real symbol>@[@]<version>
(Note that "@@" identifies a default symbol, if the symbol name is
repeated.)
perf is currently unable to deal with this, and is unable to create user
probes at such symbols:
--
$ nm /lib/powerpc64le-linux-gnu/libpthread.so.0 | grep pthread_create
0000000000008d30 t __pthread_create_2_1
0000000000008d30 T pthread_create@@GLIBC_2.17
$ /usr/bin/sudo perf probe -v -x /lib/powerpc64le-linux-gnu/libpthread.so.0 pthread_create
probe-definition(0): pthread_create
symbol:pthread_create file:(null) line:0 offset:0 return:0 lazy:(null)
0 arguments
Open Debuginfo file: /usr/lib/debug/lib/powerpc64le-linux-gnu/libpthread-2.19.so
Try to find probe point from debuginfo.
Probe point 'pthread_create' not found.
Error: Failed to add events. Reason: No such file or directory (Code: -2)
--
One is not able to specify the fully versioned symbol, either, due to
syntactic conflicts with other uses of "@" by perf:
--
$ /usr/bin/sudo perf probe -v -x /lib/powerpc64le-linux-gnu/libpthread.so.0 pthread_create@@GLIBC_2.17
probe-definition(0): pthread_create@@GLIBC_2.17
Semantic error :SRC@SRC is not allowed.
0 arguments
Error: Command Parse Error. Reason: Invalid argument (Code: -22)
--
This patch ignores versioning for default symbols, thus allowing probes to be
created for these symbols:
--
$ /usr/bin/sudo ./perf probe -x /lib/powerpc64le-linux-gnu/libpthread.so.0 pthread_create
Added new event:
probe_libpthread:pthread_create (on pthread_create in /lib/powerpc64le-linux-gnu/libpthread-2.19.so)
You can now use it in all perf tools, such as:
perf record -e probe_libpthread:pthread_create -aR sleep 1
$ /usr/bin/sudo ./perf record -e probe_libpthread:pthread_create -aR ./test 2
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.052 MB perf.data (2 samples) ]
$ /usr/bin/sudo ./perf script
test 2915 [000] 19124.260729: probe_libpthread:pthread_create: (3fff99248d38)
test 2916 [000] 19124.260962: probe_libpthread:pthread_create: (3fff99248d38)
$ /usr/bin/sudo ./perf probe --del=probe_libpthread:pthread_create
Removed event: probe_libpthread:pthread_create
--
Committer note:
Change the variable storing the result of strlen() to 'int', to fix the build
on debian:experimental-x-mipsel, fedora:24-x-ARC-uClibc, ubuntu:16.04-x-arm,
etc:
util/symbol.c: In function 'symbol__match_symbol_name':
util/symbol.c:422:11: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
if (len < versioning - name)
^
Signed-off-by: Paul A. Clarke <pc@us.ibm.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Link: http://lkml.kernel.org/r/c2b18d9c-17f8-9285-4868-f58b6359ccac@us.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2017-04-26 02:15:49 +08:00
|
|
|
enum symbol_tag_include {
|
|
|
|
SYMBOL_TAG_INCLUDE__NONE = 0,
|
|
|
|
SYMBOL_TAG_INCLUDE__DEFAULT_ONLY
|
|
|
|
};
|
|
|
|
|
|
|
|
int symbol__match_symbol_name(const char *namea, const char *nameb,
|
|
|
|
enum symbol_tag_include includes);
|
|
|
|
|
perf sdt: ELF support for SDT
This patch serves the initial support to identify and list SDT events in
binaries. When programs containing SDT markers are compiled, gcc with
the help of assembler directives identifies them and places them in the
section ".note.stapsdt".
To find these markers from the binaries, one needs to traverse through
this section and parse the relevant details like the name, type and
location of the marker. Also, the original location could be skewed due
to the effect of prelinking. If that is the case, the locations need to
be adjusted.
The functions in this patch open a given ELF, find out the SDT section,
parse the relevant details, adjust the location (if necessary) and
populate them in a list.
A typical note entry in ".note.stapsdt" section is as follows :
|--nhdr.n_namesz--|
------------------------------------
| nhdr | "stapsdt" |
----- |----------------------------------|
| | <location> <base_address> |
| | <semaphore> |
nhdr.n_descsize | "provider_name" "note_name" |
| | <args> |
----- |----------------------------------|
| nhdr | "stapsdt" |
|...
The above shows an excerpt from the section ".note.stapsdt". 'nhdr' is
a structure which has the note name size (n_namesz), note description
size (n_desc_sz) and note type (n_type).
So, in order to parse the note note info, we need nhdr to tell us where
to start from. As can be seen from <sys/sdt.h>, the name of the SDT
notes given is "stapsdt". But this is not the identifier of the note.
After that, we go to description of the note to find out its location, the
address of the ".stapsdt.base" section and the semaphore address.
Then, we find the provider name and the SDT marker name and then follow the
arguments.
Signed-off-by: Hemant Kumar <hemant@linux.vnet.ibm.com>
Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/146736022628.27797.1201368329092908163.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-01 16:03:46 +08:00
|
|
|
/* structure containing an SDT note's info */
|
|
|
|
struct sdt_note {
|
|
|
|
char *name; /* name of the note*/
|
|
|
|
char *provider; /* provider name */
|
2016-12-14 08:07:31 +08:00
|
|
|
char *args;
|
perf sdt: ELF support for SDT
This patch serves the initial support to identify and list SDT events in
binaries. When programs containing SDT markers are compiled, gcc with
the help of assembler directives identifies them and places them in the
section ".note.stapsdt".
To find these markers from the binaries, one needs to traverse through
this section and parse the relevant details like the name, type and
location of the marker. Also, the original location could be skewed due
to the effect of prelinking. If that is the case, the locations need to
be adjusted.
The functions in this patch open a given ELF, find out the SDT section,
parse the relevant details, adjust the location (if necessary) and
populate them in a list.
A typical note entry in ".note.stapsdt" section is as follows :
|--nhdr.n_namesz--|
------------------------------------
| nhdr | "stapsdt" |
----- |----------------------------------|
| | <location> <base_address> |
| | <semaphore> |
nhdr.n_descsize | "provider_name" "note_name" |
| | <args> |
----- |----------------------------------|
| nhdr | "stapsdt" |
|...
The above shows an excerpt from the section ".note.stapsdt". 'nhdr' is
a structure which has the note name size (n_namesz), note description
size (n_desc_sz) and note type (n_type).
So, in order to parse the note note info, we need nhdr to tell us where
to start from. As can be seen from <sys/sdt.h>, the name of the SDT
notes given is "stapsdt". But this is not the identifier of the note.
After that, we go to description of the note to find out its location, the
address of the ".stapsdt.base" section and the semaphore address.
Then, we find the provider name and the SDT marker name and then follow the
arguments.
Signed-off-by: Hemant Kumar <hemant@linux.vnet.ibm.com>
Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/146736022628.27797.1201368329092908163.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-01 16:03:46 +08:00
|
|
|
bool bit32; /* whether the location is 32 bits? */
|
|
|
|
union { /* location, base and semaphore addrs */
|
|
|
|
Elf64_Addr a64[3];
|
|
|
|
Elf32_Addr a32[3];
|
|
|
|
} addr;
|
|
|
|
struct list_head note_list; /* SDT notes' list */
|
|
|
|
};
|
|
|
|
|
|
|
|
int get_sdt_note_list(struct list_head *head, const char *target);
|
|
|
|
int cleanup_sdt_note_list(struct list_head *sdt_notes);
|
|
|
|
int sdt_notes__get_count(struct list_head *start);
|
|
|
|
|
2018-08-20 12:42:50 +08:00
|
|
|
#define SDT_PROBES_SCN ".probes"
|
perf sdt: ELF support for SDT
This patch serves the initial support to identify and list SDT events in
binaries. When programs containing SDT markers are compiled, gcc with
the help of assembler directives identifies them and places them in the
section ".note.stapsdt".
To find these markers from the binaries, one needs to traverse through
this section and parse the relevant details like the name, type and
location of the marker. Also, the original location could be skewed due
to the effect of prelinking. If that is the case, the locations need to
be adjusted.
The functions in this patch open a given ELF, find out the SDT section,
parse the relevant details, adjust the location (if necessary) and
populate them in a list.
A typical note entry in ".note.stapsdt" section is as follows :
|--nhdr.n_namesz--|
------------------------------------
| nhdr | "stapsdt" |
----- |----------------------------------|
| | <location> <base_address> |
| | <semaphore> |
nhdr.n_descsize | "provider_name" "note_name" |
| | <args> |
----- |----------------------------------|
| nhdr | "stapsdt" |
|...
The above shows an excerpt from the section ".note.stapsdt". 'nhdr' is
a structure which has the note name size (n_namesz), note description
size (n_desc_sz) and note type (n_type).
So, in order to parse the note note info, we need nhdr to tell us where
to start from. As can be seen from <sys/sdt.h>, the name of the SDT
notes given is "stapsdt". But this is not the identifier of the note.
After that, we go to description of the note to find out its location, the
address of the ".stapsdt.base" section and the semaphore address.
Then, we find the provider name and the SDT marker name and then follow the
arguments.
Signed-off-by: Hemant Kumar <hemant@linux.vnet.ibm.com>
Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/146736022628.27797.1201368329092908163.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-07-01 16:03:46 +08:00
|
|
|
#define SDT_BASE_SCN ".stapsdt.base"
|
|
|
|
#define SDT_NOTE_SCN ".note.stapsdt"
|
|
|
|
#define SDT_NOTE_TYPE 3
|
|
|
|
#define SDT_NOTE_NAME "stapsdt"
|
|
|
|
#define NR_ADDR 3
|
|
|
|
|
2018-08-20 12:42:50 +08:00
|
|
|
enum {
|
|
|
|
SDT_NOTE_IDX_LOC = 0,
|
|
|
|
SDT_NOTE_IDX_BASE,
|
|
|
|
SDT_NOTE_IDX_REFCTR,
|
|
|
|
};
|
|
|
|
|
2018-03-07 23:50:06 +08:00
|
|
|
struct mem_info *mem_info__new(void);
|
|
|
|
struct mem_info *mem_info__get(struct mem_info *mi);
|
|
|
|
void mem_info__put(struct mem_info *mi);
|
|
|
|
|
|
|
|
static inline void __mem_info__zput(struct mem_info **mi)
|
|
|
|
{
|
|
|
|
mem_info__put(*mi);
|
|
|
|
*mi = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define mem_info__zput(mi) __mem_info__zput(&mi)
|
|
|
|
|
2021-10-18 21:48:41 +08:00
|
|
|
int symbol__validate_sym_arguments(void);
|
|
|
|
|
2009-09-25 00:02:18 +08:00
|
|
|
#endif /* __PERF_SYMBOL */
|