- gdb: fix p command to print module variables correctly
This commit is contained in:
parent
f5b4657b33
commit
721317a5b3
@ -0,0 +1,77 @@
|
||||
From eedf12d4758409c3c405f56edf3177a3955e1f67 Mon Sep 17 00:00:00 2001
|
||||
From: Lianbo Jiang <lijiang@redhat.com>
|
||||
Date: Wed, 6 Mar 2024 14:31:27 +0800
|
||||
Subject: [PATCH] gdb: fix "p" command to print module variables correctly
|
||||
|
||||
Some objects format may potentially support copy relocations, but
|
||||
currently the maybe_copied is always initialized to 0 in the symbol().
|
||||
And the type is 'mst_file_bss', not always the 'mst_bss' or 'mst_data'
|
||||
in the lookup_minimal_symbol_linkage(). For example:
|
||||
|
||||
(gdb) p *msymbol
|
||||
$42 = {<general_symbol_info> = {m_name = 0x349812f "test_no_static", value = {ivalue = 8, block = 0x8,
|
||||
bytes = 0x8 <error: Cannot access memory at address 0x8>, address = 8, common_block = 0x8, chain = 0x8}, language_specific = {
|
||||
obstack = 0x0, demangled_name = 0x0}, m_language = language_auto, ada_mangled = 0, section = 20}, size = 4,
|
||||
filename = 0x6db3440 "test_sanity.c", type = mst_file_bss, created_by_gdb = 0, target_flag_1 = 0, target_flag_2 = 0, has_size = 1,
|
||||
maybe_copied = 0, name_set = 1, hash_next = 0x0, demangled_hash_next = 0x0}
|
||||
|
||||
This causes a problem that the 'p' command cannot work well as expected,
|
||||
and emits an error or a bogus value:
|
||||
|
||||
crash> mod -s test_sanity /home/test_sanity.ko
|
||||
MODULE NAME BASE SIZE OBJECT FILE
|
||||
ffffffffc1084040 test_sanity ffffffffc1082000 16384 /home/test_sanity.ko
|
||||
crash> p test_no_static
|
||||
p: gdb request failed: p test_no_static
|
||||
crash>
|
||||
|
||||
The issue occurs with Linux 6.2 and later or kernels that have kernel
|
||||
commit 80e4c1cd42ff ("x86/retbleed: Add X86_FEATURE_CALL_DEPTH") and
|
||||
configured with CONFIG_CALL_DEPTH_TRACKING=y, including RHEL9.3 and
|
||||
later kernels.
|
||||
|
||||
With the patch:
|
||||
crash> mod -s test_sanity /home/test_sanity.ko
|
||||
MODULE NAME BASE SIZE OBJECT FILE
|
||||
ffffffffc1084040 test_sanity ffffffffc1082000 16384 /home/test_sanity.ko
|
||||
crash> p test_no_static
|
||||
test_no_static = $1 = 5
|
||||
crash>
|
||||
|
||||
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
|
||||
---
|
||||
gdb-10.2.patch | 24 ++++++++++++++++++++++++
|
||||
1 file changed, 24 insertions(+)
|
||||
|
||||
diff --git a/gdb-10.2.patch b/gdb-10.2.patch
|
||||
index 7416efed..3694b131 100644
|
||||
--- a/gdb-10.2.patch
|
||||
+++ b/gdb-10.2.patch
|
||||
@@ -3237,3 +3237,27 @@ exit 0
|
||||
|
||||
for (compunit_symtab *cust : objfile->compunits ())
|
||||
{
|
||||
+--- gdb-10.2/gdb/minsyms.c.orig
|
||||
++++ gdb-10.2/gdb/minsyms.c
|
||||
+@@ -535,7 +535,9 @@ lookup_minimal_symbol_linkage (const char *name, struct objfile *objf)
|
||||
+ {
|
||||
+ if (strcmp (msymbol->linkage_name (), name) == 0
|
||||
+ && (MSYMBOL_TYPE (msymbol) == mst_data
|
||||
+- || MSYMBOL_TYPE (msymbol) == mst_bss))
|
||||
++ || MSYMBOL_TYPE (msymbol) == mst_bss
|
||||
++ || MSYMBOL_TYPE (msymbol) == mst_file_bss
|
||||
++ || MSYMBOL_TYPE (msymbol) == mst_file_data))
|
||||
+ return {msymbol, objfile};
|
||||
+ }
|
||||
+ }
|
||||
+--- gdb-10.2/gdb/symtab.h.orig
|
||||
++++ gdb-10.2/gdb/symtab.h
|
||||
+@@ -1110,7 +1110,7 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
|
||||
+ is_objfile_owned (1),
|
||||
+ is_argument (0),
|
||||
+ is_inlined (0),
|
||||
+- maybe_copied (0),
|
||||
++ maybe_copied (1), /* The objfile potentially supports copy relocations. */
|
||||
+ subclass (SYMBOL_NONE)
|
||||
+ {
|
||||
+ /* We can't use an initializer list for members of a base class, and
|
@ -34,6 +34,10 @@ Patch13: 0012-arm64-rewrite-the-arm64_get_vmcoreinfo_ul-to-arm64_g.patch
|
||||
Patch14: 0013-help.c-Remove-kmem-l-help-messages.patch
|
||||
Patch15: 0014-x86_64-check-bt-bptr-before-calculate-framesize.patch
|
||||
Patch16: 0001-symbols-skip-the-module-if-the-given-address-is-not-.patch
|
||||
# Patches were taken from:
|
||||
# https://github.com/crash-utility/crash/commit/eedf12d4758409c3c405f56edf3177a3955e1f67
|
||||
Patch17: gdb-fix-p-command-to-print-module-variables-correctly.patch
|
||||
|
||||
|
||||
%description
|
||||
The core analysis suite is a self-contained tool that can be used to
|
||||
@ -70,6 +74,7 @@ offered by Mission Critical Linux, or the LKCD kernel patch.
|
||||
%patch -P 14 -p1
|
||||
%patch -P 15 -p1
|
||||
%patch -P 16 -p1
|
||||
%patch -P 17 -p1
|
||||
|
||||
|
||||
%build
|
||||
@ -96,6 +101,9 @@ cp -p defs.h %{buildroot}%{_includedir}/crash
|
||||
%{_includedir}/*
|
||||
|
||||
%changelog
|
||||
* Wed Jul 24 2024 Eduard Abdullin <eabdullin@almalinux.org> - 8.0.4-3.el9_4.alma.1
|
||||
- gdb: fix "p" command to print module variables correctly
|
||||
|
||||
* Thu Mar 28 2024 Eduard Abdullin <eabdullin@almalinux.org> - 8.0.4-3.alma.1
|
||||
- Debrand for AlmaLinux
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user