* [Qemu-devel] Translation block identification.
@ 2018-05-01 9:28 Rafael Kioji
2018-05-01 10:04 ` Alex Bennée
0 siblings, 1 reply; 6+ messages in thread
From: Rafael Kioji @ 2018-05-01 9:28 UTC (permalink / raw)
To: qemu-devel
Dear all,
During translation how can I identify what is the basic block of the
guest code? I wanted to know whether the block being translated is the
beginning of a function and get its name.
My current approach involves looking up the symbol associated with the
first PC of the translation block. But no symbol is ever found. What I
did was to add the following code in the function "translator_loop" at
"accel/tcg/translator.c":
printf("sym: %lu %s\n", tb->pc, lookup_symbol(tb->pc));
The function lookup_symbol is defined in the file "./disas.c". I am
compiling my application with symbols (-g). My target arch is ARM.
Thanks!
Kind regards,
Rafael
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] Translation block identification.
2018-05-01 9:28 [Qemu-devel] Translation block identification Rafael Kioji
@ 2018-05-01 10:04 ` Alex Bennée
2018-05-01 10:20 ` Rafael Kioji
0 siblings, 1 reply; 6+ messages in thread
From: Alex Bennée @ 2018-05-01 10:04 UTC (permalink / raw)
To: Rafael Kioji; +Cc: qemu-devel
Rafael Kioji <rafaelkioji@gmail.com> writes:
> Dear all,
>
> During translation how can I identify what is the basic block of the
> guest code? I wanted to know whether the block being translated is the
> beginning of a function and get its name.
>
> My current approach involves looking up the symbol associated with the
> first PC of the translation block. But no symbol is ever found. What I
> did was to add the following code in the function "translator_loop" at
> "accel/tcg/translator.c":
>
> printf("sym: %lu %s\n", tb->pc, lookup_symbol(tb->pc));
>
> The function lookup_symbol is defined in the file "./disas.c". I am
> compiling my application with symbols (-g). My target arch is ARM.
If you run QEMU with the debug flags you should see name resolution for
each basic block. e.g.
qemu-arm -d in_asm prog
--
Alex Bennée
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] Translation block identification.
2018-05-01 10:04 ` Alex Bennée
@ 2018-05-01 10:20 ` Rafael Kioji
2018-05-01 10:28 ` Peter Maydell
2018-05-01 10:43 ` Alex Bennée
0 siblings, 2 replies; 6+ messages in thread
From: Rafael Kioji @ 2018-05-01 10:20 UTC (permalink / raw)
To: Alex Bennée; +Cc: qemu-devel
This logging flag prints what I want. But I really wanted is to get this
info inside the QEMU source code. Why am I not able to lookup the
symbols in the translator.c file the way I showed?
Kind regards,
Rafael
On 5/1/2018 6:04 PM, Alex Bennée wrote:
> Rafael Kioji <rafaelkioji@gmail.com> writes:
>
>> Dear all,
>>
>> During translation how can I identify what is the basic block of the
>> guest code? I wanted to know whether the block being translated is the
>> beginning of a function and get its name.
>>
>> My current approach involves looking up the symbol associated with the
>> first PC of the translation block. But no symbol is ever found. What I
>> did was to add the following code in the function "translator_loop" at
>> "accel/tcg/translator.c":
>>
>> printf("sym: %lu %s\n", tb->pc, lookup_symbol(tb->pc));
>>
>> The function lookup_symbol is defined in the file "./disas.c". I am
>> compiling my application with symbols (-g). My target arch is ARM.
> If you run QEMU with the debug flags you should see name resolution for
> each basic block. e.g.
>
> qemu-arm -d in_asm prog
>
> --
> Alex Bennée
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] Translation block identification.
2018-05-01 10:20 ` Rafael Kioji
@ 2018-05-01 10:28 ` Peter Maydell
2018-05-01 10:47 ` Rafael Kioji
2018-05-01 10:43 ` Alex Bennée
1 sibling, 1 reply; 6+ messages in thread
From: Peter Maydell @ 2018-05-01 10:28 UTC (permalink / raw)
To: Rafael Kioji; +Cc: Alex Bennée, QEMU Developers
On 1 May 2018 at 11:20, Rafael Kioji <rafaelkioji@gmail.com> wrote:
> This logging flag prints what I want. But I really wanted is to get this
> info inside the QEMU source code. Why am I not able to lookup the symbols in
> the translator.c file the way I showed?
The -d in_asm logging is just using lookup_symbol() (eg for arm
I think it's in arm_tr_disas_log() that that particular logging
is done), so if it works when it's called by the existing QEMU code
but not in your modification then it sounds like there's an
error in your modification somewhere.
thanks
-- PMM
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] Translation block identification.
2018-05-01 10:20 ` Rafael Kioji
2018-05-01 10:28 ` Peter Maydell
@ 2018-05-01 10:43 ` Alex Bennée
1 sibling, 0 replies; 6+ messages in thread
From: Alex Bennée @ 2018-05-01 10:43 UTC (permalink / raw)
To: Rafael Kioji; +Cc: qemu-devel
Rafael Kioji <rafaelkioji@gmail.com> writes:
> This logging flag prints what I want. But I really wanted is to get
> this info inside the QEMU source code. Why am I not able to lookup the
> symbols in the translator.c file the way I showed?
Without a failing patch it's hard to say, after all the working
disassembly is called at the bottom of translator_loop():
ops->disas_log(db, cpu);
>
> Kind regards,
> Rafael
>
> On 5/1/2018 6:04 PM, Alex Bennée wrote:
>> Rafael Kioji <rafaelkioji@gmail.com> writes:
>>
>>> Dear all,
>>>
>>> During translation how can I identify what is the basic block of the
>>> guest code? I wanted to know whether the block being translated is the
>>> beginning of a function and get its name.
>>>
>>> My current approach involves looking up the symbol associated with the
>>> first PC of the translation block. But no symbol is ever found. What I
>>> did was to add the following code in the function "translator_loop" at
>>> "accel/tcg/translator.c":
>>>
>>> printf("sym: %lu %s\n", tb->pc, lookup_symbol(tb->pc));
>>>
>>> The function lookup_symbol is defined in the file "./disas.c". I am
>>> compiling my application with symbols (-g). My target arch is ARM.
>> If you run QEMU with the debug flags you should see name resolution for
>> each basic block. e.g.
>>
>> qemu-arm -d in_asm prog
>>
>> --
>> Alex Bennée
--
Alex Bennée
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] Translation block identification.
2018-05-01 10:28 ` Peter Maydell
@ 2018-05-01 10:47 ` Rafael Kioji
0 siblings, 0 replies; 6+ messages in thread
From: Rafael Kioji @ 2018-05-01 10:47 UTC (permalink / raw)
To: Peter Maydell; +Cc: Alex Bennée, QEMU Developers
Solved. The reason I was not able to get the symbols is because logging
has to be enabled, otherwise the symbols are not loaded. In "elfload.c"
there is the condition:
> if (qemu_log_enabled()) {
> load_symbols(ehdr, image_fd, load_bias);
> }
Thanks!
Kind regards,
Rafael
On 5/1/2018 6:28 PM, Peter Maydell wrote:
> On 1 May 2018 at 11:20, Rafael Kioji <rafaelkioji@gmail.com> wrote:
>> This logging flag prints what I want. But I really wanted is to get this
>> info inside the QEMU source code. Why am I not able to lookup the symbols in
>> the translator.c file the way I showed?
> The -d in_asm logging is just using lookup_symbol() (eg for arm
> I think it's in arm_tr_disas_log() that that particular logging
> is done), so if it works when it's called by the existing QEMU code
> but not in your modification then it sounds like there's an
> error in your modification somewhere.
>
> thanks
> -- PMM
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-05-01 10:47 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-01 9:28 [Qemu-devel] Translation block identification Rafael Kioji
2018-05-01 10:04 ` Alex Bennée
2018-05-01 10:20 ` Rafael Kioji
2018-05-01 10:28 ` Peter Maydell
2018-05-01 10:47 ` Rafael Kioji
2018-05-01 10:43 ` Alex Bennée
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.