Additional source map paths for nRF Connect for VS Code

Hello,

I have an nRF project that links a static library that is built from a separate repo my company maintains. The library is built in CI and then the archive is added to the nRF project folder to make it available for linking. I would like to step into this library while debugging it. To do that I can build the library in debug mode, but the issue is that when VS Code wants to step into the library, the source code must exist on my local machine at the same folder location as the folder it was built with in CI, which is workable, but not ideal.

I am looking for an option in the extension like the "sourceFileMap" option that is available in VS Code when the launch type is "cppDebug", but it doesn't seem to to exist for the "nrf-connect" launch type or else I'm configuring it incorrectly.

Is there a way to remap source locatiosn to the nRF Connect launch configuration?

Thanks,

Mike

Parents
  • Hi Mike,

     

    My setup is quite simplistic to test this.

    I took zephyr/samples/application_development/external_lib and compiled/renamed the directory to "zephyr/samples/application_development/external_lib2".

    Default debug view showed that I could not open the src file:

    I tried to add every config I could find to my launch.json:

    {
    	"version": "0.2.0",
    	"configurations": [
    		{
    			"type": "nrf-connect",
    			"request": "launch",
    			"name": "Launch build",
    			"config": "${workspaceFolder}/external_lib/build",
    			"runToEntryPoint": "main",
    			"sourceFileMap": { "/opt/ncs/zephyr/samples/application_development/external_lib": "/opt/ncs/zephyr/samples/application_development/external_lib2" },
                "preAttachCommands": [
                    "set substitute-path /opt/ncs/zephyr/samples/application_development/external_lib /opt/ncs/zephyr/samples/application_development/external_lib2",
                ],
                "overrideLaunchCommands": [
                    "set substitute-path /opt/ncs/zephyr/samples/application_development/external_lib /opt/ncs/zephyr/samples/application_development/external_lib2",
                ],
                "overrideResetCommands": [
                    "set substitute-path /opt/ncs/zephyr/samples/application_development/external_lib /opt/ncs/zephyr/samples/application_development/external_lib2",
                ],
                "overrideRestartCommands": [
                    "set substitute-path /opt/ncs/zephyr/samples/application_development/external_lib /opt/ncs/zephyr/samples/application_development/external_lib2",
                ],									
    		}
    	]
    }

    Still, none of the above was able to resolve to the moved directory. I am not excluding operator error from my side here, I might have fudged the syntax or something in the above.

     

    But, I found this specific blog post (via https://github.com/Marus/cortex-debug/issues/611):

    https://alex.dzyoba.com/blog/gdb-source-path/

    I played around with this function, and found that using the gdb-command was working:

    set substitute-path ../zephyr/samples/application_development/external_lib ../zephyr/samples/application_development/external_lib2

    Please note that you need to start with -exec in the inbuild debug console in vscode:

    -exec set substitute-path /opt/ncs/zephyr/samples/application_development/external_lib /opt/ncs/zephyr/samples/application_development/external_lib2
     

    Could you try this and see if this helps to resolve the static .a functions at your end as well?

     

    Kind regards,

    Håkon

Reply
  • Hi Mike,

     

    My setup is quite simplistic to test this.

    I took zephyr/samples/application_development/external_lib and compiled/renamed the directory to "zephyr/samples/application_development/external_lib2".

    Default debug view showed that I could not open the src file:

    I tried to add every config I could find to my launch.json:

    {
    	"version": "0.2.0",
    	"configurations": [
    		{
    			"type": "nrf-connect",
    			"request": "launch",
    			"name": "Launch build",
    			"config": "${workspaceFolder}/external_lib/build",
    			"runToEntryPoint": "main",
    			"sourceFileMap": { "/opt/ncs/zephyr/samples/application_development/external_lib": "/opt/ncs/zephyr/samples/application_development/external_lib2" },
                "preAttachCommands": [
                    "set substitute-path /opt/ncs/zephyr/samples/application_development/external_lib /opt/ncs/zephyr/samples/application_development/external_lib2",
                ],
                "overrideLaunchCommands": [
                    "set substitute-path /opt/ncs/zephyr/samples/application_development/external_lib /opt/ncs/zephyr/samples/application_development/external_lib2",
                ],
                "overrideResetCommands": [
                    "set substitute-path /opt/ncs/zephyr/samples/application_development/external_lib /opt/ncs/zephyr/samples/application_development/external_lib2",
                ],
                "overrideRestartCommands": [
                    "set substitute-path /opt/ncs/zephyr/samples/application_development/external_lib /opt/ncs/zephyr/samples/application_development/external_lib2",
                ],									
    		}
    	]
    }

    Still, none of the above was able to resolve to the moved directory. I am not excluding operator error from my side here, I might have fudged the syntax or something in the above.

     

    But, I found this specific blog post (via https://github.com/Marus/cortex-debug/issues/611):

    https://alex.dzyoba.com/blog/gdb-source-path/

    I played around with this function, and found that using the gdb-command was working:

    set substitute-path ../zephyr/samples/application_development/external_lib ../zephyr/samples/application_development/external_lib2

    Please note that you need to start with -exec in the inbuild debug console in vscode:

    -exec set substitute-path /opt/ncs/zephyr/samples/application_development/external_lib /opt/ncs/zephyr/samples/application_development/external_lib2
     

    Could you try this and see if this helps to resolve the static .a functions at your end as well?

     

    Kind regards,

    Håkon

Children
Related