• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/toolchains/hndtools-armeabi-2013.11/share/doc/arm-arm-none-eabi/html/getting-started/
1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>3.7.�ARM Profiling Implementation</title><link rel="stylesheet" type="text/css" href="cs.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.0"><link rel="home" href="index.html" title="Sourcery CodeBench Lite"><link rel="up" href="chap-target.html" title="Chapter�3.�Sourcery CodeBench Lite for ARM EABI"><link rel="prev" href="ch03s06.html" title="3.6.�ABI Compatibility"><link rel="next" href="portable-objects.html" title="3.8.�Object File Portability"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">3.7.�ARM Profiling Implementation</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch03s06.html">Prev</a>�</td><th width="60%" align="center">Chapter�3.�Sourcery CodeBench Lite for ARM EABI</th><td width="20%" align="right">�<a accesskey="n" href="portable-objects.html">Next</a></td></tr></table><hr></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="arm-mcount"></a>3.7.�ARM Profiling Implementation</h2></div></div></div><p>
2    Profiling is enabled by means of the <code class="option">-pg</code>
3    compiler option. In this mode, the compiler inserts a call to
4    <code class="function">__gnu_mcount_nc</code> into every function prologue.
5    However, no implementation of <code class="function">__gnu_mcount_nc</code>
6    is provided (to do so would be impossible without knowledge of
7    the execution environment).
8  </p><p>
9    You must provide your own implementation of
10    <code class="function">__gnu_mcount_nc </code>. Here are the requirements:
11    </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
12	On exit, pop the top value from the stack, and place it in the
13	<code class="code">lr</code> register. The <code class="code">sp</code> register should
14	be adjusted accordingly. For example, this is how to write it
15	as a stub function:
16	<div class="informalexample"><pre class="programlisting">        .globl __gnu_mcount_nc
17        .type __gnu_mcount_nc, %function
18__gnu_mcount_nc:
19        mov    ip, lr
20        pop    { lr }
21        bx     ip</pre></div></li><li class="listitem">
22	Preserve all other register state except for <code class="code">r12</code>
23	and the CPSR condition code bits.  In particular all coprocessor
24	state and registers <code class="code">r0</code>-<code class="code">r3</code> must
25	be preserved.
26      </li><li class="listitem">
27	Record and count all occurrences of the function calls
28	in the program.  The caller can be determined from the
29	<code class="code">lr</code> value stored on the top of the stack (on entry
30	to <code class="function">__gnu_mcount_nc</code>), and the callee can
31	be determined from the current value of the <code class="code">lr</code>
32	register (i.e. the caller of this function).
33      </li><li class="listitem">
34	Arrange for the data to be saved to a file named
35	<code class="filename">gmon.out</code> when the program exits
36	(via <code class="function">atexit</code>).  Refer to the
37	<code class="command">gprof</code> profiler manual for more information.
38      </li></ul></div><p>
39  </p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch03s06.html">Prev</a>�</td><td width="20%" align="center"><a accesskey="u" href="chap-target.html">Up</a></td><td width="40%" align="right">�<a accesskey="n" href="portable-objects.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">3.6.�ABI Compatibility�</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">�3.8.�Object File Portability</td></tr></table></div></body></html>
40