Examine generated native code

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
Jonbru
Posts: 1
Joined: Fri Oct 09, 2020 8:08 am

Examine generated native code

Post by Jonbru » Fri Oct 09, 2020 8:16 am

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

User avatar
jimmo
Posts: 2232
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Examine generated native code

Post by jimmo » Tue Oct 20, 2020 12:33 pm

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.

Post Reply