📄 trace2.htm
字号:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta name="GENERATOR" content="Quadralay WebWorks Publisher Professional Edition 6.0.5">
<meta name="TEMPLATEBASE" content="book_html">
<meta name="LASTUPDATED" content="12/04/03 13:42:26">
<title>6.1 Introduction to tracing and profiling</title>
<STYLE TYPE="text/css">
<!--
span.Signal { text-transform: uppercase; font-family: Verdana }
-->
</STYLE>
</head>
<body link="#3366CC" vlink="#9999CC" text="#000000" alink="#0000CC" bgcolor="#FFFFFF"
background="images/backgrnd.gif">
<p><img src="images/stlogo.gif" width="106" height="83" align="left"
alt="logo here!"> </p>
<table width="331" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td><a href="a_userto.htm"><img src="images/navtoc.gif" width="84" height="23"
border="0" alt="TOC"> </a></td>
<td><a href="trace.htm"><img src="images/navprev.gif" width="80" height="23"
border="0" alt="PREV"> </a></td>
<td><a href="trace3.htm"><img src="images/navnext.gif" width="83" height="23"
border="0" alt="NEXT"> </a></td>
<td><a href="a_userix.htm"><img src="images/navidx.gif" width="84" height="23"
border="0" alt="INDEX"> </a></td>
</tr>
</table>
<p><br clear="all">
</p>
<hr align="left">
<blockquote>
<h2>
<a name="1228330"> </a><font color="#003366" face="Verdana, Arial, Helvetica, sans-serif">6.1 Introduction to tracing and profiling</font>
</h2><hr>
<h3>
<a name="1228250"> </a><font color="#003366" face="Verdana, Arial, Helvetica, sans-serif">6.1.1 Tracing</font>
</h3>
<p>
<a name="1228251"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">Tracing is a debugging technique in which the path of program execution is captured and displayed. This allows the user to discover what happened on the CPU to cause the occurrence of a bug. On the ST20, tracing works by configuring the DCU to capture a record of the CPU state when certain events occur during program execution. These events can include jumps, task switches, instruction fetch or reads/writes at memory locations.</font>
</p>
<p>
<a name="1228549"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">While the CPU is running, and even after it has crashed, the most recent captured trace records can be recovered using ST Visual Develop (<strong>st20dev</strong>) and displayed to show where the CPU was executing during the immediately preceding period. Capture of trace records can be started and stopped explicitly by the user using ST Visual Develop.</font>
</p>
<p>
<a name="1228550"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">When tracing, the DCU needs to be configured to tell it:</font>
</p>
<ul>
<p> <font size=2 face="Verdana, Arial, Helvetica, sans-serif"><li ><a name="1228256"> </a>the information to record,</font></p>
<p> <font size=2 face="Verdana, Arial, Helvetica, sans-serif"><li ><a name="1228257"> </a>the conditions which trigger the capture of a record,</font></p>
<p> <font size=2 face="Verdana, Arial, Helvetica, sans-serif"><li ><a name="1228258"> </a>the memory location for storage of the captured records.</font></p>
</ul>
<p>
<a name="1228260"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">Tracing requires a memory buffer to be allocated to store the trace records.</font>
</p>
<h3>
<a name="1228381"> </a><font color="#003366" face="Verdana, Arial, Helvetica, sans-serif">6.1.2 Profiling</font>
</h3>
<p>
<a name="1228395"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">Profiling is a performance analysis technique which allows the user to discover 'hotspots' in their program: areas in the running program where the CPU spends a lot of time. The locations of these hotspots allow the user to decide where in the program it is worth investing effort in 'optimizing' to increase performance. Saving a few cycles in a hotspot can improve performance significantly, however only minimal benefit is gained from optimizing parts of the program where the CPU spends little time.</font>
</p>
<p>
<a name="1228265"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">On the ST20, profiling works by the DCU being configured to regularly, but infrequently, capture and record the state of the CPU. Then, during program execution, a statistical picture (or execution profile) builds of where the program is spending its time. </font>
</p>
<p>
<a name="1228403"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">After or during a run of the program, the captured profile records can be recovered and displayed within the ST Visual Develop <strong>Trace and Profile</strong> window allowing the user to view the program's execution profile and identify performance hotspots.</font>
</p>
<p>
<a name="1228267"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">Trace and profile sessions can be saved for later analysis.</font>
</p>
<h3>
<a name="1228315"> </a><font color="#003366" face="Verdana, Arial, Helvetica, sans-serif">6.1.3 Tracing and profiling in the toolset</font>
</h3>
<p>
<a name="1228243"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">The toolset has features to facilitate tracing and profiling of a target application. These are typically used to analyze application performance to identify scope for improvement and to debug some target crash situations.</font>
</p>
<p>
<a name="1226389"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">The tracing system can capture key data at strategic points in time, such as the current instruction pointer (<span class=Signal>Iptr</span>) and time stamp on each program flow discontinuity (for example, an explicit branch or an interrupt), and store this data for later analysis.</font>
</p>
<p>
<a name="1226390"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">The profiling system samples the instruction pointer at a relatively low frequency. Over a period of time (usually at least one second) a statistical picture of program execution can be constructed.</font>
</p>
<p>
<a name="1226398"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">The tracing system requires a trace buffer located in target memory. This requirement introduces some limitations.</font>
</p>
<ul>
<p> <font size=2 face="Verdana, Arial, Helvetica, sans-serif"><li ><a name="1226399"> </a>This memory should be allocated at application build time and it is preferable to place this buffer in internal static RAM which is invariably at a premium (typically key OS20 sections are placed in this memory).</font></p>
<p> <font size=2 face="Verdana, Arial, Helvetica, sans-serif"><li ><a name="1226400"> </a>Trace operation introduces extra bus and memory subsystem activity and will impact application timings and performance to some degree. These effects will be severe if the trace buffer is placed in external memory.</font></p>
</ul>
<p>
<a name="1227902"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">To support the use of tracing in the development life cycle, the toolset configures the tracing system with some default parameters. It can be enabled at virtually any point while the application is being debugged, and the user can modify tracing configuration to use more elaborate trace settings. Tracing is not enabled by default because of the extra bus activity it introduces.</font>
</p>
<p>
<a name="1226431"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">If tracing has been enabled and there is an application crash that locks out the debugger, the postmortem trace analysis feature can be used. This resets the board and attempts to extract the trace from the trace buffer, see <a href="trace8.htm#1219779"><font color="#0000ff" face="Verdana, Arial, Helvetica, sans-serif"><i>Section
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -