This is the mail archive of the gdb@sourceware.org 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]

Tracing code memcpy()-ied to a new location


Dear,

while debugging linux's kexec() on an arm board, i hit this problem in
machine_kexec():

http://fxr.watson.org/fxr/source/arch/arm/kernel/machine_kexec.c?v=linux-2.6

68         /* copy our kernel relocation code to the control code page */
69         memcpy(reboot_code_buffer,
70                relocate_new_kernel, relocate_new_kernel_size);

here we copy the relocate_new_kernel routine
(arch/arm/kernel/relocate_kernel.S::relocate_new_kernel()) to
reboot_code_buffer, and later...

 83         cpu_reset(reboot_code_buffer_phys);

we jump to it

tracing it with gdb i have this:

132             cpu_reset(reboot_code_buffer_phys);
(gdb) x/20 relocate_new_kernel                            <- the
original routine
0xc0056c4c <relocate_new_kernel>:       0xe59f0074      0xe59f106c     
0xe3500000      0x0a000014
0xc0056c5c <relocate_new_kernel+16>:    0xe4903004      0xe3130001     
0x0a000001      0xe3c34001
0xc0056c6c <relocate_new_kernel+32>:    0xeafffffa      0xe3130002     
0x0a000001      0xe3c30002
0xc0056c7c <relocate_new_kernel+48>:    0xeafffff6      0xe3130004     
0x0a000000      0xea000008
0xc0056c8c <relocate_new_kernel+64>:    0xe3130008      0x0afffff1     
0xe3c33008      0xe3a06b01
(gdb) x/20 reboot_code_buffer                             <- the same
routine as the VM/MMU sees it
0xef356000:     0xe59f0074      0xe59f106c      0xe3500000      0x0a000014
0xef356010:     0xe4903004      0xe3130001      0x0a000001      0xe3c34001
0xef356020:     0xeafffffa      0xe3130002      0x0a000001      0xe3c30002
0xef356030:     0xeafffff6      0xe3130004      0x0a000000      0xea000008
0xef356040:     0xe3130008      0x0afffff1      0xe3c33008      0xe3a06b01
(gdb) p/x reboot_code_buffer_phys
$1 = 0xaf356000
(gdb) mon mdw phys 0xaf356000 20                    <- again the same
routine in physical memory/location
0xaf356000: e59f0074 e59f106c e3500000 0a000014 e4903004 e3130001
0a000001 e3c34001
0xaf356020: eafffffa e3130002 0a000001 e3c30002 eafffff6 e3130004
0a000000 ea000008
0xaf356040: e3130008 0afffff1 e3c33008 e3a06b01

this confirms that the memory in
reboot_code_buffer/reboot_code_buffer_phys contains relocate_new_kernel()

(gdb) stepi
0xc0056b3c      132             cpu_reset(reboot_code_buffer_phys);
(gdb) stepi
cpu_v7_reset () at
/home/flag/canonical/ubuntu-natty/arch/arm/mm/proc-v7.S:64
64              mov     pc, r0
(gdb) stepi
0xaf356000 in ?? ()

and from this point on, i can't follow the code anymore.

So here is the question: since i know there is relocate_new_kernel() in
that location, is there a way to tell gdb to "remap" the
symbols/environment/$whatever of that routine in that location so i can
keep debugging it?

-- 
bye,
p.


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