Skip to contentSkip to conversation

tools lib symbols: Introduce kallsyms__is_function()

tip:perf/core tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message May 2, 2018

lore
Share & tools
lore
#0 lore raw
Commit-ID:  494e31e2a2b1cdc3efc60043fac5bbd39a6fb04f
Gitweb:     https://git.kernel.org/tip/494e31e2a2b1cdc3efc60043fac5bbd39a6fb04f
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Wed, 25 Apr 2018 17:09:55 -0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 26 Apr 2018 13:47:14 -0300

tools lib symbols: Introduce kallsyms__is_function()

Out of symbol_type__is_a(type, MAP__FUNCTION), which is the only variant used so far, useful in a kallsyms library and one more step in ditching the MAP__FUNCTION/VARIABLE split.

---
 tools/lib/symbol/kallsyms.c | 6 ++++++
 tools/lib/symbol/kallsyms.h | 2 ++
 2 files changed, 8 insertions(+)
tools/lib/symbol/kallsyms.c +6 -0
index 689b6a130dd7..96d830545bbb 100644
@@ -10,6 +10,12 @@ u8 kallsyms2elf_type(char type)
 	return (type == 't' || type == 'w') ? STT_FUNC : STT_OBJECT;
 }
 
+bool kallsyms__is_function(char symbol_type)
+{
+	symbol_type = toupper(symbol_type);
+	return symbol_type == 'T' || symbol_type == 'W';
+}
+
 int kallsyms__parse(const char *filename, void *arg,
 		    int (*process_symbol)(void *arg, const char *name,
 					  char type, u64 start))
tools/lib/symbol/kallsyms.h +2 -0
index bc40101d72c1..72ab9870454b 100644
@@ -20,6 +20,8 @@ static inline u8 kallsyms2elf_binding(char type)
 
 u8 kallsyms2elf_type(char type);
 
+bool kallsyms__is_function(char symbol_type);
+
 int kallsyms__parse(const char *filename, void *arg,
 		    int (*process_symbol)(void *arg, const char *name,
 					  char type, u64 start));