<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Running function stack trace</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/68222/running-function-stack-trace</link><description>Hi,Master: 
 
 Question： 
 When the finished product cannot be debugged with jlink, I want to save and trace the function stack information through the firmware. When there are some accidental exceptions, I need to use the function stack to more delicately</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 29 Jan 2021 10:52:58 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/68222/running-function-stack-trace" /><item><title>RE: Running function stack trace</title><link>https://devzone.nordicsemi.com/thread/291955?ContentTypeID=1</link><pubDate>Fri, 29 Jan 2021 10:52:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:914dfbd6-abbc-4345-90b1-48ff41b29e77</guid><dc:creator>outspace</dc:creator><description>&lt;p&gt;Hi,&lt;a class="internal-link view-user-profile" href="https://devzone.nordicsemi.com/members/kme"&gt;Kenneth&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Sorry to reply you so late, thank you for your guidance&lt;/p&gt;
&lt;p&gt;Because sometimes, for example, some dynamic memory overflows cause occasional program exceptions, I want to use this idea to determine and narrow the scope of the problem, I want to see the same context as the call stack window in the IDE, and further provide me with some ideas&lt;/p&gt;
&lt;p&gt;Thank you very much.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Running function stack trace</title><link>https://devzone.nordicsemi.com/thread/279583?ContentTypeID=1</link><pubDate>Wed, 11 Nov 2020 19:10:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:38c6fee7-1e79-4f01-b9e3-08bf9e4c7490</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;&lt;span&gt;I think this can be done simpler.&amp;nbsp;&lt;/span&gt;&lt;span&gt;When the processor takes an exception, the processor pushes information onto the current stack. S&lt;/span&gt;&lt;span&gt;ee here:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://developer.arm.com/documentation/dui0552/a/the-cortex-m3-processor/exception-model/exception-entry-and-return"&gt;https://developer.arm.com/documentation/dui0552/a/the-cortex-m3-processor/exception-model/exception-entry-and-return&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thereby I believe you can get the information you want from the call stack.&amp;nbsp;&lt;/span&gt;Typically in the nRF5 SDK you can for instance catch exceptions (hardfaults) by including (one of the files are compiler specific):&lt;/p&gt;
&lt;p&gt;$(SDK_ROOT)/components/libraries/hardfault/hardfault_implementation.c&amp;nbsp;&lt;br /&gt;$(SDK_ROOT)/components/libraries/hardfault/nrf52/handler/hardfault_handler_gcc.c&amp;nbsp;&lt;/p&gt;
&lt;p&gt;After adding the above files and setting HARDFAULT_HANDLER_ENABLED 1 in sdk_config.h, you&amp;nbsp;should be able to catch the hardfaults in HardFault_c_handler() and can process these as you like.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>