Page 1 of 1

Examine generated native code

Posted: Fri Oct 09, 2020 8:16 am
by Jonbru
Hey,
New to this forum.

I'm interested in looking into the native code generated by function marked as @micropython.viper or @micropython.native
as Damien examined here
https://www.kickstarter.com/projects/21 ... sts/665145

any head start on how to do this?
because the code is compiled on the board itself.

thank you

Re: Examine generated native code

Posted: Tue Oct 20, 2020 12:33 pm
by jimmo
Jonbru wrote:
Fri Oct 09, 2020 8:16 am
any head start on how to do this?
because the code is compiled on the board itself.
I think the way to do this is to add debugging output to the code generator into your firmware such that when the compiler runs on the device it prints out what you need.

So for example you can enable DEBUG_printf in the top of emitnative.c and also you can dump out the generated code in asm_<arch>_end_pass in asm<arch>.c (take a look at asm_xtensa_end_pass in asmxtensa.c for an example of dumping out the generated code). You'll have to decode that into a format that you can pass to <arch>-objdump to view the disassembly.