iarsystems / cmake-tutorial

Build and test embedded software using the IAR C/C++ Compiler alongside CMake
https://iar.com
MIT License
76 stars 14 forks source link

Code indexing #6

Closed pterodragon closed 2 years ago

pterodragon commented 2 years ago
[
{
  "directory": "C:/SiliconLabs/SimplicityStudio/v4/developer/stacks/znet/v5.8.1.0/app/builder/proj/build",
  "command": "\"/C/Program Files (x86)/IAR Systems/Embedded Workbench 7.5/arm/bin/iccarm.exe\"  --silent /C/SiliconLabs/SimplicityStudio/v4/developer/stacks/znet/v5.8.1.0/app/builder/proj/Source/Comms.c -DCORTEXM3=1 <other defines> <include directories> --no_path_in_file_macros --separate_cluster_for_initialized_variables --no_wrap_diagnostics -e --use_c++_inline --cpu Cortex-M3 --fpu None --debug --dlib_config \"C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.5/arm/inc/c/DLib_Config_Normal.h\" --endian little --cpu_mode thumb -Ohz --diag_suppress Pa050 -e -o CMakeFiles/tempzz.dir/Source/Comms.c.o",
  "file": "C:/SiliconLabs/SimplicityStudio/v4/developer/stacks/znet/v5.8.1.0/app/builder/proj/Source/Comms.c"
}
]

The generated compile_commands.json of my project looks like this. But I have not found any language server which can parse that and can result in correct language server behavior ("jump to definition" etc.). Please write in the readme if there is a method where I can avoid using Simplicity studio but can still index the code properly

felipe-iar commented 2 years ago

This tutorial focuses on the command-line usage of the IAR C/C++ Compiler with CMake to build and test embedded applications.

An idea for stepping throughout the code, might be to use the debug-only project feature from within the IAR Embedded Workbench, already covered in this tutorial.

The IAR Embedded Workbench allows creating a debug-only project, where solely the executable target containing debug information can be added. The debug information in the executable contains pointers to its originating sources. That way, during runtime, becomes possible to navigate the source code through its execution flow using the IAR C-SPY Debugger.

Before runtime, there might be another option, as found in the Technical Note 200415. This technical note describes how Visual Studio Code can be used with the IAR Embedded Workbench as an alternative.

Such use cases are beyond the scope of this tutorial.