Ericsson / codechecker

CodeChecker is an analyzer tooling, defect database and viewer extension for the Clang Static Analyzer and Clang Tidy
https://codechecker.readthedocs.io
Apache License 2.0
2.23k stars 374 forks source link

Compiler detection calls with arduino-cli #3564

Open vChavezB opened 2 years ago

vChavezB commented 2 years ago

Is your feature request related to a problem? Please describe. I am currently developing software with the Arduino SDK and its IDE. Currently Codechecker does not detect calls from the arduino-cli neither from the Arduino IDE. In comparison I tested the same with PVS-Studio and it had no problems detecting the compiler calls directly with the arduino-cli.

Describe the solution you would like Detection of compiler calls when using the arduino-cli.

Describe alternatives you have considered What I ended up doing is using a Cmake file which allows me to compile projects with the Arduino SDK separately.

How to reproduce

#Install  latest arduino-cli for linux x64
wget -nv -O arduino-cli.tar.gz https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Linux_64bit.tar.gz
tar -xf arduino-cli.tar.gz arduino-cli
mv arduino-cli /usr/bin/arduino-cli

#Update indexes for arduino-cli
arduino-cli core update-index
#Install SDK for AVR Microcontrollers
arduino-cli core install arduino:avr

#Create an arduino project
arduino-cli sketch new MyFirstSketch

#Instrument compilation with codechecker
source PATH/WHERE/CODECHECKER/INSTALLED
export CC_LOGGER_GCC_LIKE="avr-gcc:avr-g++"
CodeChecker log -b "arduino-cli compile --fqbn arduino:avr:uno MyFirstSketch" -o arduino.log
#This will produce an empty arduino.log file...
vChavezB commented 2 years ago

``I have checked the logs of codechecker and it detects compiler calls to cc1plus and not the gcc frontend directly. I changed the env. variable CC_LOGGER_GCC_LIKE to cc1plus. The logger detects the call but doesn't process the commands with codechecker analyze

[INFO 2021-12-24 11:07:11][src/ldlogger-logger.c:192] - Processing command: /root/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/../lib/gcc/arm-none-eabi/4.8.3/cc1plus /root/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/../lib/gcc/arm-none-eabi/4.8.3/cc1plus -quiet -I /root/.arduino15/packages/arduino/hardware/sam/1.6.12/system/libsam -I /root/.arduino15/packages/arduino/hardware/sam/1.6.12/system/CMSIS/CMSIS/Include/ -I /root/.arduino15/packages/arduino/hardware/sam/1.6.12/system/CMSIS/Device/ATMEL/ -I /root/.arduino15/packages/arduino/hardware/sam/1.6.12/cores/arduino -I /root/.arduino15/packages/arduino/hardware/sam/1.6.12/variants/arduino_due_x -I /root/Arduino/libraries/iol-master-stack/src -I /root/.arduino15/packages/arduino/hardware/sam/1.6.12/libraries/SPI/src -imultilib armv7-m -iprefix /root/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/../lib/gcc/arm-none-eabi/4.8.3/ -isysroot /root/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/../arm-none-eabi -MMD /builds/io-link/iol-master-stack/build/ardu/sketch/demo.ino.cpp.d -MQ /builds/io-link/iol-master-stack/build/ardu/sketch/demo.ino.cpp.o -D__USES_INITFINI__ -D F_CPU=84000000L -D ARDUINO=10607 -D ARDUINO_SAM_DUE -D ARDUINO_ARCH_SAM -D __SAM3X8E__ -D USB_VID=0x2341 -D USB_PID=0x003e -D USBCON -D USB_MANUFACTURER="Arduino LLC" -D USB_PRODUCT="Arduino Due" /builds/io-link/iol-master-stack/build/ardu/sketch/demo.ino.cpp -quiet -dumpbase demo.ino.cpp -mcpu=cortex-m3 -mthumb -mthumb -auxbase-strip /builds/io-link/iol-master-stack/build/ardu/sketch/demo.ino.cpp.o -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -fno-rtti -fno-exceptions --param max-inline-insns-single=500 -o /tmp/ccohBACf.s