关于Iar 的 call_graph 使用

iar对堆栈管理的比较好,但是有时也会出问题。

iar 提供了很多功能,帮助我们分析 系统使用堆栈的情况。

--call_grahp  这个参数启用后会输出函数使用栈的信息,

原型:

--call_graph
Syntax: --call_graph {filename | directory}
Description: Use this option to produce a call graph file. If no filename extension is specified, the 
extension cgx  is used. This option can only be used once on the command line.
Using this option enables stack usage analysis in the linker.


首先设置root 目录,在函数前面添加一个参数:

#pragma call_graph_root="main"
void main (void)

{

…………

}

如果包含函数指针,那么需要指定,该指针可能会指向的函数:

{

   #pragma calls =App_TaskStart
    (void)ptcb;

……

}

编译链接之后,在文件中会输出信息:

    <function>
      <id>85</id>
      <name>main</name>
      <root>main</root>
      <address>0x200261e0</address>
      <stack>24</stack>
      <callee>81</callee>
      <callee>252</callee>
      <callee>256</callee>
      <call>
        <callee>318</callee>
        <arg>
          <index>0</index>
          <function>84</function>
        </arg>
      </call>
    </function>

    <function>
      <id>85</id>
      <name>main</name>
      <address>0x200261e0</address>
      <stack>24</stack>
      <callee>81</callee>
      <callee>252</callee>
      <callee>256</callee>
      <call>
        <callee>318</callee>
        <arg>
          <index>0</index>
          <function>84</function>
        </arg>
      </call>
    </function>

     <function>
      <id>210</id>
      <name>__iar_program_start</name>
      <root>Program entry</root>
      <address>0x20000000</address>
    </function>
    <function>
      <id>742</id>
      <name>__iar_return_from_swi</name>
      <root>software interrupt</root>
      <address>0x2002ba54</address>
      <stack>0</stack>
    </function>

启用之后,同时可以在map文件中会有一些信息

*******************************************************************************
*** STACK USAGE
***
  Call Graph Root Category  Max Use  Total Use
  ------------------------  -------  ---------
  main                          176        176
  Program entry                   0          0
  Uncalled function           4 584     16 320


在连接脚本中,通过这个命令可以检查是否有溢出:

Error[Lp034]: no stack usage could be calculated for at least one function in category "main" 


但是总是有个错误:

Error[Lp034]: no stack usage could be calculated for at least one function in category "main" 

不知道为什么。


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值