From: Pedro Alves <palves@redhat.com>
To: Yao Qi <yao@codesourcery.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Delegate to target_ops->beneath to read cache lines
Date: Wed, 27 Nov 2013 15:27:00 -0000 [thread overview]
Message-ID: <5295F877.3060004@redhat.com> (raw)
In-Reply-To: <1385554824-7159-1-git-send-email-yao@codesourcery.com>
On 11/27/2013 12:20 PM, Yao Qi wrote:
> 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 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 doesn't have such mechanism, and that is
> the cause for the error.
This points out that we end up caching core and exec code, which
isn't really necessary. We could limit it to has_all_memory targets,
I think. Not sure if that'd complicate things.
> This patch adds something similar in dcache_read_line to go through
> target_ops from top to bottom, and call to_xfer_partial.
> The original code uses TARGET_OBJECT_RAW_MEMORY, which is replaced
> by TARGET_OBJECT_MEMORY in target_xfer_partial,
>
> enum target_object raw_object = object;
>
> /* If this is a raw memory transfer, request the normal
> memory object from other layers. */
> if (raw_object == TARGET_OBJECT_RAW_MEMORY)
> raw_object = TARGET_OBJECT_MEMORY;
>
> so we can use TARGET_OBJECT_MEMORY here. Regression tested on
> x86_64-linux.
The dcache is the sole user of TARGET_OBJECT_RAW_MEMORY. This shows
that if we want to code from lower targets too, then this sole user also
wants to do the top to bottom delegation that memory_xfer_partial_1 does.
So this can all be done within target.c. Factor out the
memory_xfer_partial_1 top to bottom memory read code to a separate
raw_memory_xfer_partial function (despite the name, it'd request
TARGET_OBJECT_MEMORY from the targets), and make target_xfer_partial
call that for TARGET_OBJECT_RAW_MEMORY:
LONGEST
target_xfer_partial (struct target_ops *ops,
enum target_object object, const char *annex,
void *readbuf, const void *writebuf,
ULONGEST offset, LONGEST len)
{
LONGEST retval;
/* If this is a memory transfer, let the memory-specific code
have a look at it instead. Memory transfers are more
complicated. */
if (object == TARGET_OBJECT_MEMORY || object == TARGET_OBJECT_STACK_MEMORY
|| object == TARGET_OBJECT_CODE_MEMORY)
retval = memory_xfer_partial (ops, object, readbuf,
writebuf, offset, len);
else if (object == TARGET_OBJECT_RAW_MEMORY)
{
/* Request the normal memory object from other layers. */
retval = raw_memory_xfer_partial (ops, readbuf, writebuf, offset, len);
}
else
{
retval = ops->to_xfer_partial (ops, raw_object, annex, readbuf,
writebuf, offset, len);
}
Then dcache.c doesn't need to change, and doesn't need to inline that
top to bottom dance.
--
Pedro Alves
next prev parent reply other threads:[~2013-11-27 13:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-27 12:41 Yao Qi
2013-11-27 15:27 ` Pedro Alves [this message]
2013-11-29 11:12 ` Yao Qi
2013-11-29 13:47 ` Pedro Alves
2013-11-29 14:00 ` Yao Qi
2013-11-29 14:27 ` Pedro Alves
2013-11-29 20:06 ` Doug Evans
2013-11-29 20:16 ` Pedro Alves
2013-12-02 6:07 ` Yao Qi
2013-12-02 10:36 ` Pedro Alves
2013-12-02 11:04 ` Yao Qi
2013-12-02 11:12 ` Pedro Alves
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=5295F877.3060004@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=yao@codesourcery.com \
/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