Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Paolo Pisati <p.pisati@gmail.com>
To: gdb@sourceware.org
Subject: Re: Tracing code memcpy()-ied to a new location
Date: Tue, 03 May 2011 16:01:00 -0000	[thread overview]
Message-ID: <4DC026CF.6020709@gmail.com> (raw)
In-Reply-To: <4DC02372.6040409@gmail.com>

[resending due to bad formatting...]

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.


  reply	other threads:[~2011-05-03 16:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-03 15:47 Paolo Pisati
2011-05-03 16:01 ` Paolo Pisati [this message]
2011-05-04 12:55   ` Jan Kratochvil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DC026CF.6020709@gmail.com \
    --to=p.pisati@gmail.com \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox