Compare commits

..

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
8c38b03b3c
!14 [sync] PR-12: btf_encoder: Fix dwarf int type with greater-than-16 byte issue
From: @openeuler-sync-bot 
Reviewed-by: @nlgwcy 
Signed-off-by: @nlgwcy
2024-06-21 08:11:26 +00:00
bitcoffee
7f1726aa88 btf_encoder: Fix dwarf int type with greater-than-16 byte issue
Nick Desaulniers and Xin Liu separately reported that int type might
have greater-than-16 byte size ([1] and [2]). More specifically, the
reported int type sizes are 1024 and 64 bytes.

The libbpf and bpf program does not really support any int type greater
than 16 bytes. Therefore, with current pahole, btf encoding will fail
with greater-than-16 byte int types.

Since for now bpf does not support '> 16' bytes int type, the simplest
way is to sanitize such types, similar to existing conditions like
'!byte_sz' and 'byte_sz & (byte_sz - 1)'. This way, pahole won't
call libbpf with an unsupported int type size. The patch [3] was
proposed before. Now I resubmitted this patch as there are another
failure due to the same issue.

Signed-off-by: bitcoffee <liuxin350@huawei.com>
(cherry picked from commit 4edfa257cd9982267aea870609a4a22884f28b96)
2024-06-11 11:03:45 +08:00
openeuler-ci-bot
d3957f2dca
!8 [sync] PR-7: 修复使用LLVM + CONFIG_DEBUG_INFO_BTF出现的大量警告信息
From: @openeuler-sync-bot 
Reviewed-by: @LemmyHuang 
Signed-off-by: @LemmyHuang
2023-02-23 07:04:03 +00:00
Chenxi Mao
942ff259cf Fix spew of warnings if build kernel with LLVM and CONFIG_DEBUG_INFO_BTF
When building a kernel with LLVM and CONFIG_DEBUG_INFO_BTF after commit
32ef9e5054ec ("Makefile.debug: re-enable debug info for .S files") in
the kernel, I see the following spew of warnings, which appear to come
from pahole:

die__process_unit: DW_TAG_label (0xa) @ <0x7b> not handled!
die__process_unit: tag not supported 0xa (label)!
die__process_unit: DW_TAG_label (0xa) @ <0x97> not handled!
die__process_unit: DW_TAG_label (0xa) @ <0xbd> not handled!
die__process_unit: DW_TAG_label (0xa) @ <0xed> not handled!
die__process_unit: DW_TAG_label (0xa) @ <0x109> not handled!
die__process_unit: DW_TAG_label (0xa) @ <0x12a> not handled!
die__process_unit: DW_TAG_label (0xa) @ <0x146> not handled!
die__process_unit: DW_TAG_label (0xa) @ <0x16f> not handled!

To fix this issue, backport dwarves upstream patch:
dwarf_loader: Support DW_TAG_label outside DW_TAG_lexblock

Signed-off-by: Chenxi Mao <chenxi.mao@suse.com>
(cherry picked from commit 934a5d12d585348b435c0e32fb37ad5b97421cae)
2023-02-23 14:25:21 +08:00
openeuler-ci-bot
7956e6356f
!4 [sync] PR-3: 升级dwarves版本到1.22
From: @openeuler-sync-bot 
Reviewed-by: @bitcoffee 
Signed-off-by: @bitcoffee
2022-12-16 02:43:20 +00:00
Kai Liu
712a992903 Upgrade to version 1.22
Also upgrade bundled libbpf to commit 393a058, the same as what's
designated in upstream submodule commit.

Introduce a patch from upstream commit 73383b3a3 to avoid using
deprecated libbpf APIs.

References: bsn#158
Signed-off-by: Kai Liu <kai.liu@suse.com>
Signed-off-by: Chenxi Mao <chenxi.mao@suse.com>
Change-Id: I656420e250f84c5cb513d3099868541e8fc0aa45
(cherry picked from commit 8709c8b953b4b702b74a393ca3e6f93763255e17)
2022-12-15 15:26:01 +08:00
openeuler-ci-bot
a9ca898dd6 !2 fix about stopping using the deprecated mallinfo function
From: @xia_qirong
Reviewed-by: @bitcoffee
Signed-off-by: @bitcoffee
2021-05-24 20:26:46 +08:00
xia_qirong
96895db3dd fix about stopping using the deprecated mallinfo function 2021-05-24 20:18:25 +08:00
openeuler-ci-bot
ea6027258e !1 add dwarves package
From: @xia_qirong
Reviewed-by: @MrRlu,@hubble_zhu
Signed-off-by: @hubble_zhu
2020-09-18 10:57:07 +08:00
xia_qirong
23fa94731b add dwarves package 2020-09-16 21:03:23 +08:00
6 changed files with 378 additions and 0 deletions

BIN
393a058.tar.gz Normal file

Binary file not shown.

View File

@ -0,0 +1,47 @@
From b9607b8bf5fe3180ae4cd44cddaf054e5595e699 Mon Sep 17 00:00:00 2001
From: Yonghong Song <yonghong.song@linux.dev>
Date: Wed, 24 Apr 2024 15:35:38 -0700
Subject: [PATCH dwarves] btf_encoder: Fix dwarf int type with greater-than-16 byte issue
Nick Desaulniers and Xin Liu separately reported that int type might
have greater-than-16 byte size ([1] and [2]). More specifically, the
reported int type sizes are 1024 and 64 bytes.
The libbpf and bpf program does not really support any int type greater
than 16 bytes. Therefore, with current pahole, btf encoding will fail
with greater-than-16 byte int types.
Since for now bpf does not support '> 16' bytes int type, the simplest
way is to sanitize such types, similar to existing conditions like
'!byte_sz' and 'byte_sz & (byte_sz - 1)'. This way, pahole won't
call libbpf with an unsupported int type size. The patch [3] was
proposed before. Now I resubmitted this patch as there are another
failure due to the same issue.
[1] https://github.com/libbpf/libbpf/pull/680
[2]https://lore.kernel.org/bpf/20240422144538.351722-1-liuxin350@huawei.com/
[3] https://lore.kernel.org/bpf/20230426055030.3743074-1-yhs@fb.com/
Cc: Xin Liu <liuxin350@huawei.com>
Cc: Alan Maguire <alan.maguire@oracle.com>
Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
---
btf_encoder.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/btf_encoder.c b/btf_encoder.c
index 65f6e71..1aa0ad0 100644
--- a/btf_encoder.c
+++ b/btf_encoder.c
@@ -394,7 +394,7 @@ static int32_t btf_encoder__add_base_type(struct btf_encoder *encoder, const str
* these non-regular int types to avoid libbpf/kernel complaints.
*/
byte_sz = BITS_ROUNDUP_BYTES(bt->bit_size);
- if (!byte_sz || (byte_sz & (byte_sz - 1))) {
+ if (!byte_sz || (byte_sz & (byte_sz - 1)) || byte_sz > 16) {
name = "__SANITIZED_FAKE_INT__";
byte_sz = 4;
}
--
2.33.0

View File

@ -0,0 +1,99 @@
From f01e5f3a849558b8ed6b310686d10738f4c2f3bf Mon Sep 17 00:00:00 2001
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Date: Thu, 29 Sep 2022 09:43:16 -0300
Subject: [PATCH 1/1] dwarf_loader: Support DW_TAG_label outside
DW_TAG_lexblock
This happens with asm CUs, noticed when building the Linux kernel with
clang 15, where we have, for instance:
Contents of the .debug_info section:
Compilation Unit @ offset 0x0:
Length: 0x1df (32-bit)
Version: 5
Unit Type: DW_UT_compile (1)
Abbrev Offset: 0x0
Pointer Size: 8
<0><c>: Abbrev Number: 1 (DW_TAG_compile_unit)
<d> DW_AT_stmt_list : 0x0
<11> DW_AT_ranges : 0xc
<15> DW_AT_name : arch/x86/kernel/verify_cpu.S
<32> DW_AT_comp_dir : /home/nathan/cbl/src/linux
<4d> DW_AT_producer : ClangBuiltLinux clang version 16.0.0 (https://github.com/llvm/llvm-project 7e22179d38c438fedb0d9bb0cff1585843bd7082)
<c2> DW_AT_language : 32769 (MIPS assembler)
<1><c4>: Abbrev Number: 2 (DW_TAG_label)
<c5> DW_AT_name : startup_64
<d0> DW_AT_decl_file : 0x0
<d4> DW_AT_decl_line : 0x364
<d8> DW_AT_low_pc : 0xffffffff81000000
<1><e0>: Abbrev Number: 2 (DW_TAG_label)
<e1> DW_AT_name : secondary_startup_64
<f6> DW_AT_decl_file : 0x0
<fa> DW_AT_decl_line : 0x399
<fe> DW_AT_low_pc : 0xffffffff81000060
<1><106>: Abbrev Number: 2 (DW_TAG_label)
<107> DW_AT_name : secondary_startup_64_no_verify
<126> DW_AT_decl_file : 0x0
<12a> DW_AT_decl_line : 0x39f
<12e> DW_AT_low_pc : 0xffffffff81000065
<1><136>: Abbrev Number: 2 (DW_TAG_label)
<137> DW_AT_name : verify_cpu
<142> DW_AT_decl_file : 0x0
<146> DW_AT_decl_line : 0x430
<14a> DW_AT_low_pc : 0xffffffff81000150
<SNIP>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/dwarves/YzWSzXKcm6rSWOC5@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
dwarf_loader.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/dwarf_loader.c b/dwarf_loader.c
index 631bbd4..28a912e 100644
--- a/dwarf_loader.c
+++ b/dwarf_loader.c
@@ -1485,7 +1485,12 @@ static struct tag *die__create_new_label(Dwarf_Die *die,
if (label == NULL)
return NULL;
- lexblock__add_label(lexblock, label);
+ if (lexblock != NULL) {
+ // asm CUs have labels and they will be in the cu top level tag list
+ // See die__process_unit()
+ lexblock__add_label(lexblock, label);
+ }
+
return &label->ip.tag;
}
@@ -2037,6 +2042,12 @@ static struct tag *__die__process_tag(Dwarf_Die *die, struct cu *cu,
*/
tag = &unsupported_tag;
break;
+ case DW_TAG_label:
+ if (conf->ignore_labels)
+ tag = &unsupported_tag; // callers will assume conf->ignore_labels is true
+ else // We can have labels in asm CUs, no lexblock
+ tag = die__create_new_label(die, NULL, cu, conf);
+ break;
}
if (tag != NULL)
@@ -2055,7 +2066,8 @@ static int die__process_unit(Dwarf_Die *die, struct cu *cu, struct conf_load *co
if (tag == &unsupported_tag) {
// XXX special case DW_TAG_dwarf_procedure, appears when looking at a recent ~/bin/perf
// Investigate later how to properly support this...
- if (dwarf_tag(die) != DW_TAG_dwarf_procedure)
+ if (dwarf_tag(die) != DW_TAG_dwarf_procedure &&
+ dwarf_tag(die) != DW_TAG_label) // conf->ignore_labels == true, see die__process_tag()
tag__print_not_supported(dwarf_tag(die));
continue;
}
--
2.33.0

119
dwarves.spec Normal file
View File

@ -0,0 +1,119 @@
%define libname libdwarves
%define libver 1
%define libbpfver 393a058
Name: dwarves
Version: 1.22
Release: 3
License: GPLv2
Summary: Debugging Information Manipulation Tools
URL: http://acmel.wordpress.com
Source: http://github.com/acmel/dwarves/archive/v%{version}.tar.gz
Source1: http://github.com/libbpf/libbpf/archive/%{libbpfver}.tar.gz
Requires: %{libname}%{libver} = %{version}-%{release}
BuildRequires: gcc
BuildRequires: cmake
BuildRequires: zlib-devel
BuildRequires: elfutils-devel >= 0.170
Patch0: replace-deprecated-libbpf-APIs-with-new-ones.patch
Patch1: backport-dwarf_loader-Support-DW_TAG_label-outside-DW_TAG_lex.patch
Patch2: backport-btf_encoder-Fix-dwarf-int-type-with-greater-than-16-.patch
%description
dwarves is a set of tools that use the debugging information inserted in
ELF binaries by compilers such as GCC, used by well known debuggers such as
GDB, and more recent ones such as systemtap.
%package -n %{libname}%{libver}
Summary: Debugging information processing library
%description -n %{libname}%{libver}
Debugging information processing library.
%package -n %{libname}%{libver}-devel
Summary: Debugging information library development files
Requires: %{libname}%{libver} = %{version}-%{release}
%description -n %{libname}%{libver}-devel
Debugging information processing library development files.
%prep
%autosetup -p1 -n %{name}-%{version}
tar -zxvf %{SOURCE1} --strip-components 1 -C %{_builddir}/%{name}-%{version}/lib/bpf/
%build
# Remove _FORTIFY_SOURCE from CFLAGS or else will get below error:
# error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp]
export CFLAGS=$(echo %optflags | sed -e 's/-Wp,-D_FORTIFY_SOURCE=2//g')
%cmake .
make VERBOSE=1 %{?_smp_mflags}
%install
rm -Rf %{buildroot}
make install DESTDIR=%{buildroot}
%ldconfig_scriptlets -n %{libname}%{libver}
%files
%doc README.ctracer
%doc README.btf
%doc changes-v1.17
%doc NEWS
%{_bindir}/*
%dir %{_datadir}/dwarves/
%dir %{_datadir}/dwarves/runtime/
%dir %{_datadir}/dwarves/runtime/python/
%defattr(0644,root,root,0755)
%{_mandir}/man1/pahole.1*
%{_datadir}/dwarves/runtime/Makefile
%{_datadir}/dwarves/runtime/linux.blacklist.cu
%{_datadir}/dwarves/runtime/ctracer_relay.c
%{_datadir}/dwarves/runtime/ctracer_relay.h
%attr(0755,root,root) %{_datadir}/dwarves/runtime/python/ostra.py*
%files -n %{libname}%{libver}
%{_libdir}/%{libname}.so.*
%{_libdir}/%{libname}_emit.so.*
%{_libdir}/%{libname}_reorganize.so.*
%files -n %{libname}%{libver}-devel
%doc MANIFEST README
%{_includedir}/*
%{_libdir}/%{libname}.so
%{_libdir}/%{libname}_emit.so
%{_libdir}/%{libname}_reorganize.so
%changelog
* Mon May 6 2024 - liuxin <liuxin350@huawei.com> - 1.22-3
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix dwarf int type with greater than 16 bytes issue
* Mon Mar 21 2022 - Kai Liu <kai.liu@suse.com> - 1.22-2
- Type:bugfix
- ID:NA
- SUG:NA
- DESC: Fix spew of warnings if build kernel with LLVM and
CONFIG_DEBUG_INFO_BTF after commit 32ef9e5054ec
("Makefile.debug: re-enable debug info for .S files")
* Mon Mar 21 2022 - Kai Liu <kai.liu@suse.com> - 1.22-1
- Upgrade to v1.22. Also upgrade bundled libbpf to commit 393a058,
the same as upstream submodule version.
Introduce a patch from upstream commit 73383b3a3 to avoid using
deprecated libbpf APIs.
* Mon May 24 2021 xiaqirong <xiaqirong1@huawei.com> - 1.17-2
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:bugfix about stopping using the deprecated mallinfo function
* Wed Sep 16 2020 xiaqirong <xiaqirong1@huawei.com> - 1.17-1
- Type:package init
- ID:NA
- SUG:NA
- DESC:add dwarves package

View File

@ -0,0 +1,113 @@
From 73383b3a39afe86b22e098773e47b8546c48a649 Mon Sep 17 00:00:00 2001
From: Kui-Feng Lee <kuifeng@fb.com>
Date: Wed, 26 Jan 2022 11:20:39 -0800
Subject: [PATCH] libbpf: Update libbpf to the latest git HEAD
Replace deprecated APIs with new ones.
Signed-off-by: Kui-Feng Lee <kuifeng@fb.com>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: bpf@vger.kernel.org
Cc: dwarves@vger.kernel.org
Link: https://lore.kernel.org/r/20220126192039.2840752-5-kuifeng@fb.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Kai Liu <kai.liu@suse.com>
---
btf_encoder.c | 20 ++++++++++----------
btf_loader.c | 2 +-
lib/bpf | 2 +-
3 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/btf_encoder.c b/btf_encoder.c
index 56a76f5d..fa29824f 100644
--- a/btf_encoder.c
+++ b/btf_encoder.c
@@ -172,7 +172,7 @@ __attribute ((format (printf, 5, 6)))
static void btf__log_err(const struct btf *btf, int kind, const char *name,
bool output_cr, const char *fmt, ...)
{
- fprintf(stderr, "[%u] %s %s", btf__get_nr_types(btf) + 1,
+ fprintf(stderr, "[%u] %s %s", btf__type_cnt(btf),
btf_kind_str[kind], name ?: "(anon)");
if (fmt && *fmt) {
@@ -203,7 +203,7 @@ static void btf_encoder__log_type(const struct btf_encoder *encoder, const struc
out = err ? stderr : stdout;
fprintf(out, "[%u] %s %s",
- btf__get_nr_types(btf), btf_kind_str[kind],
+ btf__type_cnt(btf) - 1, btf_kind_str[kind],
btf__printable_name(btf, t->name_off));
if (fmt && *fmt) {
@@ -449,10 +449,10 @@ static int btf_encoder__add_field(struct btf_encoder *encoder, const char *name,
int err;
err = btf__add_field(btf, name, type, offset, bitfield_size);
- t = btf__type_by_id(btf, btf__get_nr_types(btf));
+ t = btf__type_by_id(btf, btf__type_cnt(btf) - 1);
if (err) {
fprintf(stderr, "[%u] %s %s's field '%s' offset=%u bit_size=%u type=%u Error emitting field\n",
- btf__get_nr_types(btf), btf_kind_str[btf_kind(t)],
+ btf__type_cnt(btf) - 1, btf_kind_str[btf_kind(t)],
btf__printable_name(btf, t->name_off),
name, offset, bitfield_size, type);
} else {
@@ -899,9 +899,9 @@ static int btf_encoder__write_raw_file(struct btf_encoder *encoder)
const void *raw_btf_data;
int fd, err;
- raw_btf_data = btf__get_raw_data(encoder->btf, &raw_btf_size);
+ raw_btf_data = btf__raw_data(encoder->btf, &raw_btf_size);
if (raw_btf_data == NULL) {
- fprintf(stderr, "%s: btf__get_raw_data failed!\n", __func__);
+ fprintf(stderr, "%s: btf__raw_data failed!\n", __func__);
return -1;
}
@@ -976,7 +976,7 @@ static int btf_encoder__write_elf(struct btf_encoder *encoder)
}
}
- raw_btf_data = btf__get_raw_data(btf, &raw_btf_size);
+ raw_btf_data = btf__raw_data(btf, &raw_btf_size);
if (btf_data) {
/* Existing .BTF section found */
@@ -1043,10 +1043,10 @@ int btf_encoder__encode(struct btf_encoder *encoder)
btf_encoder__add_datasec(encoder, PERCPU_SECTION);
/* Empty file, nothing to do, so... done! */
- if (btf__get_nr_types(encoder->btf) == 0)
+ if (btf__type_cnt(encoder->btf) == 1)
return 0;
- if (btf__dedup(encoder->btf, NULL, NULL)) {
+ if (btf__dedup(encoder->btf, NULL)) {
fprintf(stderr, "%s: btf__dedup failed!\n", __func__);
return -1;
}
@@ -1403,7 +1403,7 @@ void btf_encoder__delete(struct btf_encoder *encoder)
int btf_encoder__encode_cu(struct btf_encoder *encoder, struct cu *cu)
{
- uint32_t type_id_off = btf__get_nr_types(encoder->btf);
+ uint32_t type_id_off = btf__type_cnt(encoder->btf) - 1;
uint32_t core_id;
struct function *fn;
struct tag *pos;
diff --git a/btf_loader.c b/btf_loader.c
index b61cadd5..b5d44464 100644
--- a/btf_loader.c
+++ b/btf_loader.c
@@ -399,7 +399,7 @@ static int btf__load_types(struct btf *btf, struct cu *cu)
uint32_t type_index;
int err;
- for (type_index = 1; type_index <= btf__get_nr_types(btf); type_index++) {
+ for (type_index = 1; type_index < btf__type_cnt(btf); type_index++) {
const struct btf_type *type_ptr = btf__type_by_id(btf, type_index);
uint32_t type = btf_kind(type_ptr);

BIN
v1.22.tar.gz Normal file

Binary file not shown.