Delegate to target_ops->beneath for TARGET_OBJECT_RAW_MEMORY
authorYao Qi <yao@codesourcery.com>
Wed, 27 Nov 2013 10:01:05 +0000 (18:01 +0800)
committerYao Qi <yao@codesourcery.com>
Fri, 29 Nov 2013 13:32:03 +0000 (21:32 +0800)
commit9f7132948dd9a08e020e6409ebe790d8fd9c6d5d
treeda852d27b7b1156181e7e852a5e1e83e33131304
parent5425b0d80b3f883115ae120124625cb4f040e17c
Delegate to target_ops->beneath for TARGET_OBJECT_RAW_MEMORY

GDB on x86_64-linux is unable to disassemble on core-file target.

$ ./gdb ./testsuite/gdb.base/corefile
(gdb) core-file ./testsuite/gdb.base/corefile.core
(gdb) disassemble main
Dump of assembler code for function main:
   0x0000000000400976 <+0>: Cannot access memory at address 0x400976

However, it works if we turn code-cache off.

(gdb) set code-cache off
(gdb) disassemble main,+4
Dump of assembler code from 0x400976 to 0x40097a:
   0x0000000000400976 <main+0>: push   %rbp
   0x0000000000400977 <main+1>: mov    %rsp,%rbp
End of assembler dump.

When code-cache is off, GDB will iterate target_ops from top to bottom
and call to_xfer_partial.  When current_target is "core", it will call
to_xfer_partial of target "exec", which reads the contents for
disassemble.  However, dcache uses TARGET_OBJECT_RAW_MEMORY to read,
but target_xfer_partial doesn't delegate requests to beneath for
TARGET_OBJECT_RAW_MEMORY.

This patch factors out the iteration from top to bottom to a new
function, raw_memory_xfer_partial, and use it for
TARGET_OBJECT_RAW_MEMORY.

Regression tested on x86_64-linux.

gdb:

2013-11-29  Yao Qi  <yao@codesourcery.com>
    Pedro Alves  <palves@redhat.com>

* dcache.c (dcache_read_line): Use current_target.beneath
instead of &current_target.
* target.c (memory_xfer_partial_1): Factor code out to ...
(raw_memory_xfer_partial): ... it.  New function.
(target_xfer_partial): Call raw_memory_xfer_partial if OBJECT
is TARGET_OBJECT_RAW_MEMORY.
gdb/ChangeLog
gdb/dcache.c
gdb/target.c