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 <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2021-06-28 15:08:42 -03:00
parent adbb66c295
commit ced4c34c37
8 changed files with 2 additions and 129 deletions

View File

@ -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/)

View File

@ -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))

View File

@ -17,7 +17,6 @@
#include "dutil.h"
#include "list.h"
#include "rbtree.h"
#include "pahole_strings.h"
struct cu;

View File

@ -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)
{

View File

@ -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;

View File

@ -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 <acme@redhat.com>
*/
#include <bpf/btf.h>
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_ */

View File

@ -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

View File

@ -1,89 +0,0 @@
/*
SPDX-License-Identifier: GPL-2.0-only
Copyright (C) 2008 Arnaldo Carvalho de Melo <acme@redhat.com>
*/
#include "pahole_strings.h"
#include "gobuffer.h"
#include <search.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <zlib.h>
#include <bpf/libbpf.h>
#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;
}