The compiler produces debug information that is incompatible with Keil-MDK
Open, Needs TriagePublic


In TF-M, we using -g option, and the default level is DWARF 4 in latest Arm compiler. And the Keil-MDK don't support DWARF 4 debug information. It makes the Keil can't debug the tfm binary which compiled with cmake.

Could you please change the -g option to -gdwarf-2 in cmake/Compiler/ARMClang.cmake? or we need to add some special documents for build and debug tf-m on Keil/DS-5.

qixiang created this task.Mon, Jul 1, 3:38 AM

Hi Qixiang,
Can you help to :

  1. provide the version customer are using
  2. provide the solution you have created?

We can add a feature to enable dwarf-2; if you can contribute then that would be great, or we can create a patch based on your solution.


KenLSoft claimed this task.Wed, Jul 3, 5:45 AM
KenLSoft added a subscriber: gyuri-szing.
qixiang added a comment.EditedWed, Jul 3, 6:47 AM

Product: DS-5 Ultimate Edition 5.29.1
Component: ARM Compiler 6.10.1
Tool: armclang [5d143200]


~/workspace/arm/tf-m/tfm-github$ git diff
diff --git a/cmake/Compiler/ARMClang.cmake b/cmake/Compiler/ARMClang.cmake
index a5ed2f3..57b704d 100644
--- a/cmake/Compiler/ARMClang.cmake
+++ b/cmake/Compiler/ARMClang.cmake
@@ -28,10 +28,10 @@ macro(__compiler_armclang lang)
   if(NOT CMAKE_${lang}_FLAGS_SET)
     set(CMAKE_${lang}_FLAGS_SET TRUE)
     string(APPEND CMAKE_${lang}_FLAGS_INIT " ")
-    string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g -O0")
+    string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -gdwarf-2 -O0")
+    string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O3 -gdwarf-2 -DNDEBUG")

     set(CMAKE_${lang}_OUTPUT_EXTENSION ".o")

Thanks, that is helpful. Will let you know after the feature is created.

Hi Qixiang, could you check the patch on your side?

The Patch link is:

You can decide which dwarf version to use when building by "-DBUILD_DWARF_VERSION=<version number>"

@qixiang this patch had been merged into the master branch. Can you help to update the task status?