<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>S32KのトピックHow to obtain the correct Frame Pointer (FP) for DumpCallStack on S32K3 using the GHS compiler?</title>
    <link>https://community.nxp.com/t5/S32K/How-to-obtain-the-correct-Frame-Pointer-FP-for-DumpCallStack-on/m-p/2402409#M60260</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I am working on an S32K3 MCU using the Green Hills Software (GHS) compiler, and I am implementing a DumpCallStack function.&lt;/P&gt;&lt;P&gt;To obtain the frame pointer (FP), I am using the following inline assembly:&lt;/P&gt;&lt;P&gt;__asm volatile ("mov %0, r7" : "=r" (locals.fp));&lt;BR /&gt;However, the value I get for locals.fp is 0x02B1, which does not appear to be a valid frame pointer. It is not aligned and does not point to a valid stack location, so the call stack cannot be unwound correctly.&lt;/P&gt;&lt;P&gt;My questions are:&lt;/P&gt;&lt;P&gt;What is the correct way to obtain the current frame pointer when using the GHS compiler on the S32K3 (Arm Cortex-M7)?&lt;BR /&gt;Does the GHS compiler always use R7 as the frame pointer, or can it omit the frame pointer or use another register depending on the optimization level?&lt;BR /&gt;Are there any compiler options that must be enabled to preserve the frame pointer for stack unwinding?&lt;BR /&gt;Is there a recommended GHS-specific API or intrinsic for retrieving the frame pointer instead of using inline assembly?&lt;BR /&gt;If anyone has implemented stack unwinding or a DumpCallStack function with the GHS compiler on S32K3, I would appreciate any guidance or examples.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Thu, 06 Aug 2026 07:09:00 GMT</pubDate>
    <dc:creator>nitin_aher</dc:creator>
    <dc:date>2026-08-06T07:09:00Z</dc:date>
    <item>
      <title>How to obtain the correct Frame Pointer (FP) for DumpCallStack on S32K3 using the GHS compiler?</title>
      <link>https://community.nxp.com/t5/S32K/How-to-obtain-the-correct-Frame-Pointer-FP-for-DumpCallStack-on/m-p/2402409#M60260</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I am working on an S32K3 MCU using the Green Hills Software (GHS) compiler, and I am implementing a DumpCallStack function.&lt;/P&gt;&lt;P&gt;To obtain the frame pointer (FP), I am using the following inline assembly:&lt;/P&gt;&lt;P&gt;__asm volatile ("mov %0, r7" : "=r" (locals.fp));&lt;BR /&gt;However, the value I get for locals.fp is 0x02B1, which does not appear to be a valid frame pointer. It is not aligned and does not point to a valid stack location, so the call stack cannot be unwound correctly.&lt;/P&gt;&lt;P&gt;My questions are:&lt;/P&gt;&lt;P&gt;What is the correct way to obtain the current frame pointer when using the GHS compiler on the S32K3 (Arm Cortex-M7)?&lt;BR /&gt;Does the GHS compiler always use R7 as the frame pointer, or can it omit the frame pointer or use another register depending on the optimization level?&lt;BR /&gt;Are there any compiler options that must be enabled to preserve the frame pointer for stack unwinding?&lt;BR /&gt;Is there a recommended GHS-specific API or intrinsic for retrieving the frame pointer instead of using inline assembly?&lt;BR /&gt;If anyone has implemented stack unwinding or a DumpCallStack function with the GHS compiler on S32K3, I would appreciate any guidance or examples.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 06 Aug 2026 07:09:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/How-to-obtain-the-correct-Frame-Pointer-FP-for-DumpCallStack-on/m-p/2402409#M60260</guid>
      <dc:creator>nitin_aher</dc:creator>
      <dc:date>2026-08-06T07:09:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to obtain the correct Frame Pointer (FP) for DumpCallStack on S32K3 using the GHS compiler?</title>
      <link>https://community.nxp.com/t5/S32K/How-to-obtain-the-correct-Frame-Pointer-FP-for-DumpCallStack-on/m-p/2402789#M60311</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;DIV&gt;
&lt;P&gt;I would not assume that R7 is always used as the frame pointer. Depending on the GHS version, optimization level, and compiler options, the compiler may use a different register or omit the frame pointer entirely and use R7 as a general-purpose register. The value 0x02B1 suggests that R7 might not be acting as a frame pointer in your build.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please check the generated assembly and verify whether GHS is creating frame records at all. If frame pointers are enabled, you should see a consistent function prologue saving/restoring the frame pointer; otherwise stack unwinding based on R7/R11 will not be reliable.&lt;/P&gt;
&lt;P&gt;Since this is primarily a compiler-specific question, I would also recommend contacting Green Hills Software support. They can advise on:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Whether GHS uses R7, R11, or another register as the frame pointer for your target/configuration.&lt;/LI&gt;
&lt;LI&gt;Which compiler options preserve frame pointers.&lt;/LI&gt;
&lt;LI&gt;Whether there is a recommended intrinsic or API for obtaining the current frame pointer.&lt;/LI&gt;
&lt;LI&gt;Preferred methods for implementing call stack unwinding with GHS.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;They are best positioned to provide guidance specific to your compiler version and settings.&lt;/P&gt;
&lt;P&gt;BR, Petr&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 07 Aug 2026 08:25:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/How-to-obtain-the-correct-Frame-Pointer-FP-for-DumpCallStack-on/m-p/2402789#M60311</guid>
      <dc:creator>PetrS</dc:creator>
      <dc:date>2026-08-07T08:25:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to obtain the correct Frame Pointer (FP) for DumpCallStack on S32K3 using the GHS compiler?</title>
      <link>https://community.nxp.com/t5/S32K/How-to-obtain-the-correct-Frame-Pointer-FP-for-DumpCallStack-on/m-p/2403177#M60340</link>
      <description>Sure</description>
      <pubDate>Mon, 10 Aug 2026 06:47:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/How-to-obtain-the-correct-Frame-Pointer-FP-for-DumpCallStack-on/m-p/2403177#M60340</guid>
      <dc:creator>nitin_aher</dc:creator>
      <dc:date>2026-08-10T06:47:31Z</dc:date>
    </item>
  </channel>
</rss>

