This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gdb symbol is wrong when using separate debug info file


Hi, all,

I met a problem that gdb gets wrong address for global variables
when debug kernel module and load symbol from separate debug information
file.

I am not sure if it is gdb problem or related to elfutils also, because
it only happends when debug information is stripped out separately.

In order to debug kernel modules which are too big to include the debug
information in the module .o files, I am using a redhat 8.0 system with

gdb-5.3post-1.20021129.37
elfutils-0.84-3
elfutils-libelf-0.84-3
gcc-3.2-7

Basically the problem is that gdb gets wrong with the address of global
variables. Following is a very simple example:

variable g_a, s_a is declared in t.c, and s_a is static. g_a is not.
variable x_a is declared in t_x.c.
t.c and t_x.c are compiled and linked to kernel module t.o.
the debug information in t.o is stripped to t.dbg by eu-strip.

this is the load map output by insmod:

root@(none):~# insmod -m t.o
Warning: loading t.o will taint the kernel: no license
  See http://www.tux.org/lkml/#export-tainted for information about
  tainted modules
Sections:       Size      Address   Align
.this           00000060  a2802000  2**2
.text           0000001c  a2802060  2**2
.kstrtab        00000069  a280207c  2**0
__ksymtab       00000028  a28020e8  2**2
__archdata      00000000  a2802110  2**4
__kallsyms      000001c0  a2802110  2**2
.data           0000000c  a28022d0  2**2
.bss            00000000  a28022dc  2**2
   
Symbols:
00000000 a tst.c
00000000 a tst_x.c
a2802000 d __this_module
a2802000 D __insmod_t_O/mnt/uml/modtest/t.o_M3F176B5B_V132116
a2802060 t .text
a2802060 T __insmod_t_S.text_L28
a2802060 t init_module
a2802060 t init
a2802074 t fini
a2802074 t cleanup_module
a28022d0 D __insmod_t_S.data_L12
a28022d0 D g_a
a28022d0 d .data
a28022d4 d s_a
a28022d8 D x_a
a28022dc d .bss

and the gdb session is like following:

Breakpoint 1, sys_init_module (name_user=0x0, mod_user=0x8068d00) at
module.c:552
552             if (mod->init && (error = mod->init()) != 0) {
(gdb) add-symbol-file modtest/t.o 0xa2802060 -s .data 0xa28022d0
add symbol table from file "modtest/t.o" at
        .text_addr = 0xa2802060
		.data_addr = 0xa28022d0
(y or n) y
Reading symbols from modtest/t.o...
Reading symbols from /home/xjiang/uml/modtest/t.dbg...done.
done.
(gdb) p &s_a
$1 = (int *) 0xa2802064
(gdb) p &g_a
$2 = (int *) 0xa28022d0
(gdb) p &x_a
$3 = (int *) 0xa28022d8
(gdb)

Obviously gdb is wrong with &s_a.

With very big modules, I also experience some situation that gdb 
doesn't calculate the relocated address of global variables at all.
it just shows &global_variable as 0x60 or similar number. it's merely
the offset of the variable in .data section before relocation.

Any hints is highly appreciated.

Best regards,

Xiong Jiang


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]