|
From: Tom H. <to...@co...> - 2005-11-04 12:04:22
|
In message <436...@cn...>
Yao Qi <qiy...@cn...> wrote:
> Tom Hughes wrote:
>> In message <436...@cn...>
>> Yao Qi <qiy...@cn...> wrote:
>>
>>>I am thinking of how to map IRStmt to guest original instruction in
>>>valgrind tool. I find that there are some funtions relative to this
>>>purpose in include/pub_tool_debuginfo.h and
>>>include/pub_tool_execontext.h. I could only get address and length of
>>>every original instruction per IRStmt, but how could I get the content
>>>of guest instructions?
>> Well if you've got the address and the length then just read it
>> from that address!
>
> I have considered this solution previously, and it is an effective way to
> read every guest instruction in '.text' section from the client. However,
> it will break the integrity and encapsulation of the CLIENT--CORE--TOOL
> orgnization of valgrind.
There has never been any prohibition on tools reading areas of the
client memory - there was a prohibition on clients reading core and
tool memory but even that is now gone although we certainly wouldn't
want to encourage it.
> All the machine instructions of CLIENT are translated to an intermediate
> representation and optimized by CORE, and TOOL get all the information
> of CLIENT from CORE, so now if My tool read machine instruction directly
> from CLIENT bypass CORE, it would not be a best solution to this problem.
> The coregrind/m_debuginfo/symtab.c is a good example that TOOL get all the
> information from CORE instead of from CLIENT directly.
Because decoding the symbol table is a complex operation that the
core already needs to do so it makes sense to expose it to the tools
for them to use.
> Maybe, I did not describe my ideas clearly, and what I want to say is,
>
> 1 Is there any API to get the original instruction?
No. Unless you count VG_(memcpy) that is ;-)
> 2 If no such API in valgrind, do you think it is necessary to implement
> such API in valgrind? And can someone show me where should I start to
> investigate it?
I still don't understand the point, but here is an implementation
of such an API if you want it:
void VG_(get_instruction)(Addr addr, Int length, UChar *buf)
{
VG_(memcpy)(buf, addr, length);
}
> Maybe, VG_(describe_IP)(Addr eip, Char* buf, Int n_buf)
> could do this, but it seems that the SegInfo do not save enought
> information about '.text' segment, so I am not sure that the CORE should
> be enhaunced to support TOOL's feature of mapping IRStmt to original
> instruction.
What sort of information about the test segment do you think is
needed? If you have the address of the instruction and it's length
then what else do you need?
Tom
--
Tom Hughes (to...@co...)
http://www.compton.nu/
|