Page MenuHomePhabricator

The compiler produces debug information that is incompatible with Keil-MDK
Closed, ResolvedPublic

Description

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.

Event Timeline

qixiang created this task.Jul 1 2019, 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.

Thanks.

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

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

Solution:

~/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_MINSIZEREL_INIT " -Oz -DNDEBUG")
     string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3 -DNDEBUG")
-    string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O3 -g -DNDEBUG")
+    string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O3 -gdwarf-2 -DNDEBUG")

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

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: https://review.trustedfirmware.org/#/c/trusted-firmware-m/+/1532/

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?

KenLSoft closed this task as Resolved.Jul 29 2019, 2:52 AM

Resolve the changes since no response. We can re-open it if there are still concerns.

Keil-MDK supports DWARF 4 debug information since version 5.35. You can compile with the -gdwarf-4 option to debug with Arm Debugger. However, if you are using legacy or third-party tools that do not support DWARF 4 debug information, you can specify the level of DWARF conformance required using the -gdwarf-2 or -gdwarf-3 options.
You can check in https://review.trustedfirmware.org/#/c/trusted-firmware-m/+/1532/ rooftop snipers

I can provide guidance on how to modify the -g option in the CMake file for ARMClang. Please locate the ARMClang.cmake file in your project, and look for the section where the compiler options are set. You should find a line similar to this:

target_compile_options(your_target_name PRIVATE -g)
To change the -g option to -gdwarf-2, you can modify that line as follows:

target_compile_options(your_target_name PRIVATE -gdwarf-2)
Save the file, regenerate your build files if necessary, and recompile your project. This change will set the debug information to DWARF 2 format, which is compatible with Keil-MDK for debugging. Rainbow Friends: Chapter 2

This comment was removed by Thous1975.

Has this issue really been resolved?
duck life

@Candy Crush This change will set the debug information to DWARF 2 format?