nRF Connect with VSCode: how to generate assembly files

I'm using the latest nRF Connect (2.4.2) in VSCode (on Windows) to develop an application on an nRF52840.  I would like to look at some of the assembly code generated by the compiler.  How do I do that in this environment?  With gcc I would use the -S switch; is it the same here?  Where do I add this switch--Build Configuration (how?), CMakeLists.txt (what would the magic incantation be?), or somewhere else?

I can't easily hook up my j-link pod and just look at it in the debugger, since it requires a fair amount of mechanical disassembly.

Thanks in advance for any info.

--mkj

Parents
  • Hi mkj,

     

    As you mention, normally you output .asm via the "-S" switch in GCC.

    Adding custom compiler switches can be done using "CONFIG_COMPILER_OPT", but the adding the -S switch does not combine well with the build system in zephyr.

     

    What you can do is, after the fact, use objdump to disassemble your .elf file:

    arm-zephyr-eabi-objdump -S --disassemble my-build-folder/zephyr/zephyr.elf > disassembly.lst

     

    Kind regards,

    Håkon

  • That did the trick (once I remembered to add the "nRF Connect" shell in VSCode, since it has the correct PATH already set up).  And, with the DEBUG build anyway, there is enough context from the C code to easily find the functions I was interested in.

    Thanks so much for the quick response!

    --mkj

  • Hi mkj,

     

    Glad to hear that this helped!

    mkjones said:
    once I remembered to add the "nRF Connect" shell in VSCode, since it has the correct PATH already set up

    Sorry about this, I should have added a c:\PATH\to\ in my former post. You can do an absolute path towards objdump if you want to add this to some sort of "post build operation" in vscode, , ie. : c:\ncs\toolchains\...\bin\arm-zephyr-eabi-objdump <file.elf>

     

    Kind regards,

    Håkon

Reply
  • Hi mkj,

     

    Glad to hear that this helped!

    mkjones said:
    once I remembered to add the "nRF Connect" shell in VSCode, since it has the correct PATH already set up

    Sorry about this, I should have added a c:\PATH\to\ in my former post. You can do an absolute path towards objdump if you want to add this to some sort of "post build operation" in vscode, , ie. : c:\ncs\toolchains\...\bin\arm-zephyr-eabi-objdump <file.elf>

     

    Kind regards,

    Håkon

Children
No Data
Related