From ced4c34c37acd1854aca9fb4818ae726758e80a3 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 28 Jun 2021 15:08:42 -0300 Subject: [PATCH] core: Remove strings.c, unused We were using this just for the ctf_encoder, that never really got complete, so ditch it. For BTF the strings table is done by libbpf, so we don't need it there either. Signed-off-by: Arnaldo Carvalho de Melo --- CMakeLists.txt | 4 +- dwarves.c | 1 - dwarves.h | 1 - libctf.c | 1 - pahole.c | 1 - pahole_strings.h | 33 ---------------- rpm/SPECS/dwarves.spec | 1 - strings.c | 89 ------------------------------------------ 8 files changed, 2 insertions(+), 129 deletions(-) delete mode 100644 pahole_strings.h delete mode 100644 strings.c diff --git a/CMakeLists.txt b/CMakeLists.txt index d94bbe1..dff8604 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -111,7 +111,7 @@ if (NOT LIBBPF_FOUND) ${CMAKE_CURRENT_SOURCE_DIR}/lib/bpf/include/uapi) endif() -set(dwarves_LIB_SRCS dwarves.c dwarves_fprintf.c gobuffer.c strings.c +set(dwarves_LIB_SRCS dwarves.c dwarves_fprintf.c gobuffer.c ctf_loader.c libctf.c btf_encoder.c btf_loader.c dwarf_loader.c dutil.c elf_symtab.c rbtree.c) if (NOT LIBBPF_FOUND) @@ -178,7 +178,7 @@ install(TARGETS codiff ctracer dtagnames pahole pdwtags install(TARGETS dwarves LIBRARY DESTINATION ${LIB_INSTALL_DIR} ARCHIVE DESTINATION ${LIB_INSTALL_DIR}) install(TARGETS dwarves dwarves_emit dwarves_reorganize LIBRARY DESTINATION ${LIB_INSTALL_DIR} ARCHIVE DESTINATION ${LIB_INSTALL_DIR}) install(FILES dwarves.h dwarves_emit.h dwarves_reorganize.h - dutil.h gobuffer.h list.h rbtree.h pahole_strings.h + dutil.h gobuffer.h list.h rbtree.h btf_encoder.h config.h ctf.h elfcreator.h elf_symtab.h hash.h libctf.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/dwarves/) diff --git a/dwarves.c b/dwarves.c index e8d8e5a..10917a8 100644 --- a/dwarves.c +++ b/dwarves.c @@ -28,7 +28,6 @@ #include "list.h" #include "dwarves.h" #include "dutil.h" -#include "pahole_strings.h" #define min(x, y) ((x) < (y) ? (x) : (y)) diff --git a/dwarves.h b/dwarves.h index 557442c..5eb5f1f 100644 --- a/dwarves.h +++ b/dwarves.h @@ -17,7 +17,6 @@ #include "dutil.h" #include "list.h" #include "rbtree.h" -#include "pahole_strings.h" struct cu; diff --git a/libctf.c b/libctf.c index e274e43..cb12bb4 100644 --- a/libctf.c +++ b/libctf.c @@ -19,7 +19,6 @@ #include "ctf.h" #include "dutil.h" #include "gobuffer.h" -#include "pahole_strings.h" bool ctf__ignore_symtab_function(const GElf_Sym *sym, const char *sym_name) { diff --git a/pahole.c b/pahole.c index d52d4e2..ec2b6e7 100644 --- a/pahole.c +++ b/pahole.c @@ -24,7 +24,6 @@ #include "dutil.h" //#include "ctf_encoder.h" FIXME: disabled, probably its better to move to Oracle's libctf #include "btf_encoder.h" -#include "pahole_strings.h" static struct btf_encoder *btf_encoder; static char *detached_btf_filename; diff --git a/pahole_strings.h b/pahole_strings.h deleted file mode 100644 index 700f0d9..0000000 --- a/pahole_strings.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _STRINGS_H_ -#define _STRINGS_H_ 1 -/* - SPDX-License-Identifier: GPL-2.0-only - - Copyright (C) 2008 Arnaldo Carvalho de Melo -*/ - -#include - -typedef unsigned int strings_t; - -struct strings { - struct btf *btf; -}; - -extern const char *kabi_prefix; - -struct strings *strings__new(void); - -void strings__delete(struct strings *strings); - -strings_t strings__add(struct strings *strings, const char *str); -strings_t strings__find(struct strings *strings, const char *str); -strings_t strings__size(const struct strings *strings); -int strings__copy(const struct strings *strings, void *dst); - -static inline const char *strings__ptr(const struct strings *strings, strings_t s) -{ - return btf__str_by_offset(strings->btf, s); -} - -#endif /* _STRINGS_H_ */ diff --git a/rpm/SPECS/dwarves.spec b/rpm/SPECS/dwarves.spec index a194927..25eec1d 100644 --- a/rpm/SPECS/dwarves.spec +++ b/rpm/SPECS/dwarves.spec @@ -127,7 +127,6 @@ rm -Rf %{buildroot} %{_includedir}/dwarves/libctf.h %{_includedir}/dwarves/list.h %{_includedir}/dwarves/rbtree.h -%{_includedir}/dwarves/pahole_strings.h %{_libdir}/%{libname}.so %{_libdir}/%{libname}_emit.so %{_libdir}/%{libname}_reorganize.so diff --git a/strings.c b/strings.c deleted file mode 100644 index 8c2f900..0000000 --- a/strings.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - SPDX-License-Identifier: GPL-2.0-only - - Copyright (C) 2008 Arnaldo Carvalho de Melo -*/ - -#include "pahole_strings.h" -#include "gobuffer.h" - -#include -#include -#include -#include -#include -#include -#include - -#include "dutil.h" - -struct strings *strings__new(void) -{ - struct strings *strs = malloc(sizeof(*strs)); - - if (!strs) - return NULL; - - strs->btf = btf__new_empty(); - if (libbpf_get_error(strs->btf)) { - free(strs); - return NULL; - } - - return strs; -} - -void strings__delete(struct strings *strs) -{ - if (strs == NULL) - return; - btf__free(strs->btf); - free(strs); -} - -strings_t strings__add(struct strings *strs, const char *str) -{ - strings_t index; - - if (str == NULL) - return 0; - - index = btf__add_str(strs->btf, str); - - if (index < 0) - return 0; - - return index; -} - -strings_t strings__find(struct strings *strs, const char *str) -{ - return btf__find_str(strs->btf, str); -} - -/* a horrible and inefficient hack to get string section size out of BTF */ -strings_t strings__size(const struct strings *strs) -{ - const struct btf_header *p; - uint32_t sz; - - p = btf__get_raw_data(strs->btf, &sz); - if (!p) - return -1; - - return p->str_len; -} - -/* similarly horrible hack to copy out string section out of BTF */ -int strings__copy(const struct strings *strs, void *dst) -{ - const struct btf_header *p; - uint32_t sz; - - p = btf__get_raw_data(strs->btf, &sz); - if (!p) - return -1; - - memcpy(dst, (void *)p + p->str_off, p->str_len); - return 0; -}