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 ¤t_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.