Debugging Synergy Applications: Examining and Using ETM Trace Data

In the last post, we setup our SEGGER J-Trace debug probe on the DK-S7G2 and setup a Blinky project using IAR Embedded Workbench (EW) for Synergy. We discussed a few potential warning messages that a developer might encounter when getting the ETM up and running. In today’s post, we will examine what information we can retrieve and how that can be useful to us when we want to debug our application or just verify that it behaves as expected.

From within IAR EW for Synergy during a debug session, there will be a menu item that appears named J-Link. Within this menu, there are several different options that may be interesting to a developer such as:

  • ETM Trace
  • Function Trace
  • Function Profiling

A quick truncated look at this menu can be seen below:

The first option that is interesting to investigate is the ETM Trace option. ETM Trace displays in a new window, every trace frame that is received from the ETM. In most cases, a frame contains an instruction that was executed by the CPU but there are also special frames such as synchronization frames that can be seen at the start of the following trace:

There are several useful reasons why a developer may want to perform instruction tracing such as:

  • Debugging at the lowest firmware levels
  • Test verification that all lines of code have been executed
  • Application profiling (not just statistical profiling which occasionally samples the program counter)

The function trace option provides developers with a slightly higher up viewpoint than instruction tracing. It provides developers with a record for the order in which functions were executed. An example ETM Function Trace can be seen below:

The next useful trace feature is to perform function profiling. Function profiling uses the instruction trace to determine:

  • How many times a particular function was called
  • The time spent executing that function
  • The time percentage that was spent in that function

An example function trace can be found below:

As the reader can imagine, function tracing can be very useful to profile and discover where all the CPU clock cycles are being spent. If we expect an idle function to be called most of the time but discover instead that there is some other function utilizing 90% of the CPU, that could be pointing to a problem with application or a misunderstanding about how the system is supposed to operate. Either way, additional investigation and understanding would be necessary to make sure that the application is robust.

As one can image, attempting to search through a giant trace log can be time consuming. Developers can navigate through their code to functions and variables of interest, right click and then select “Find in Trace”. Their trace view will then filter for function that they were looking for in the trace.

There are also several other options which can be seen in the same menu below:

These options allow a developer to start and stop the trace at specific break-points in their code so that they can capture small data amounts that can be used to easily investigate and debug issues they are experiencing in their software.

In the next post, we will look at a third-party visualization tool, Percepio Tracealyzer that can be used to visual trace data. (The trace data doesn’t have to necessarily be received over ETM).  

Until next time,

Live long and profit!

Professor_IoT

Hot Tip of the WeekHave you found the new Getting Started Guides that are being added to the Synergy Knowledge base? These guides provide a guided series of lessons that cover important development topics for the Synergy Platform.

One of the newly added Getting Started Guides covers basic debugging. It collects a wide variety of Synergy related documents, videos, Prof IoT posts, Renesas Academy courses and Knowledge Base articles and presents them in an easy to follow series that will get you up to speed with debugging in record time. Topics covered include:

  • Run and Launch the e2 studio Debugger
  • Debug perspective in e2 studio- windows, buttons and commands
  • Run and Launch the IAR C-SPY debugger
  • Debugging features and techniques
    • e2 studio
    • IAR C-SPY
    • General debugging techniques

Check it out here: https://en-us.knowledgebase.renesas.com/English_Content/Renesas_Synergy%E2%84%A2_Platform/Renesas_Synergy_Knowledge_Base/How_do_I_get_started_with_Debugging_in_SSP%3F