Translation block identification.
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
Quoted 11 lines · Rafael Kioji
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":
Quoted 4 lines
printf("sym: %lu %s\n", tb->pc, lookup_symbol(tb->pc));The function
lookup_symbolis 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
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
Quoted 24 lines · Alex Bennée
Quoted 11 lines · Rafael Kioji
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":Quoted 4 lines
printf("sym: %lu %s\n", tb->pc, lookup_symbol(tb->pc));The function
lookup_symbolis 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_asmprog--
Alex Bennée
Quoted 3 lines · Rafael Kioji
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.cfile 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
Quoted 3 lines · Rafael Kioji
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.cfile 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);
Quoted 29 lines
Kind regards,
RafaelQuoted 24 lines · Alex Bennée
Quoted 11 lines · Rafael Kioji
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":Quoted 4 lines
printf("sym: %lu %s\n", tb->pc, lookup_symbol(tb->pc));The function
lookup_symbolis 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_asmprog--
Alex Bennée
--
Alex Bennée
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:
Quoted 3 lines
if (
qemu_log_enabled()) {
load_symbols(ehdr, image_fd, load_bias);
}
Thanks!
Kind regards,
Rafael
Quoted 12 lines · Peter Maydell
Quoted 3 lines · Rafael Kioji
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.cfile the way I showed?The -d
in_asmlogging is just usinglookup_symbol()(eg for arm I think it's inarm_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