📄 misc_debugging.htm
字号:
<html><!-- InstanceBegin template="/Templates/helpnav.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Driver Support Routines: Debugging</title>
<!-- InstanceEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<!-- InstanceParam name="HeaderColor" type="color" value="#0000FF" -->
<!-- InstanceParam name="FooterColor" type="color" value="#0000FF" -->
<!-- InstanceParam name="NavBackgroundColor" type="color" value="#FFFFFF" -->
<!-- InstanceParam name="BodyBackgroundColor" type="color" value="#FFFFFF" -->
<link href="CodeTHelp.css" rel="stylesheet" type="text/css">
</head><a name="TopTopic"></a>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td width="40%" rowspan="2" bgcolor="#0000FF"><a href="http://www.codetelligence.com"><img src="Images/codetelligence_lrg.gif" name="image" width="252" height="40" border="0"></a></td>
<td width="60%" height="62" bgcolor="#0000FF">
<font color="#FFFFFF" size="5" face="Arial, Helvetica, sans-serif"><strong>Embedded SDIO Driver Kit Help </strong></font></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="10" cellpadding="0">
<tr>
<td width="93%"><font face="Arial, Helvetica, sans-serif">
<p class="Topic"><!-- InstanceBeginEditable name="SubTemplate" --> Debugging<!-- InstanceEndEditable --> </p>
</font></td>
<td><!-- InstanceBeginEditable name="NavBack" --><a href="misc_memory.htm"><img src="Images/leftarrow.gif" width="27" height="32" border="0"></a><!-- InstanceEndEditable --></td><td><!-- InstanceBeginEditable name="Nav" --><a href="misc_synchronization.htm"><img src="Images/rightarrow.gif" width="27" height="32" border="0"></a><!-- InstanceEndEditable --></td>
</tr>
</table>
<hr>
<table width="100%" border="0" cellspacing="0" cellpadding="15">
<tr><td>
<!-- InstanceBeginEditable name="Help Content" -->
<OBJECT type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e">
<param name="Keyword" value="Driver Support Routines : Debugging">
</OBJECT>
<p class="BODYTEXT">The SDK provides a set of debug macros to aid the developer.
The debug macros
translates into the OS specific methods of printing debug messages and generating
assertions. </p>
<p class="HEADING1">Debug Prints</p>
<p class="BODYTEXT">Drivers can output debug strings to a debugger (or console)
using the <font face="Courier New, Courier, mono"><a href="Support_Reference.htm#FUNC_DBG_PRINT">DBG_PRINT</a></font>() macro.
This macro takes a debug level constant and a string with format specifiers
followed by arguments. The <font face="Courier New, Courier, mono">DBG_PRINT</font> macro
is compiled-out when a driver is built as a "release" binary. The
syntax is similar to printf() but uses a bit test of the debug level constant
and a
global variable (usually instantiated statically in a driver
source file with a default level). If the debug level is less than the current
debug level variable the print is sent. The higher the level, the more verbose
the
software module. This technique keeps informative debug
prints embedded
in the code with the capability of masking such prints during runtime to
minimize impact on performance during debugging. A driver can use any OS
specific method to change the debug level during run time. The SDK defines
a minimum set of levels (ranked highest priority to lowest priority) </p>
<p class="BODYTEXT"><font face="Courier New, Courier, mono">SDDBG_ERROR</font><br>
<font face="Courier New, Courier, mono">SDDBG_WARN</font><br>
<font face="Courier New, Courier, mono">
SDDBG_DEBUG</font><br>
<font face="Courier New, Courier, mono">
SDDBG_TRACE</font> </p>
<p class="BODYTEXT">A driver should derive additional debug levels from one
of these prefined levels (typically <font face="Courier New, Courier, mono">SDDBG_TRACE</font>).
For example:</p>
<p class="BODYTEXT"><font face="Courier New, Courier, mono">#define MY_RX_LVL
(SDDBG_TRACE +
0) <br>#define MY_TX_LVL (SDDBG_TRACE + 1)
</font></p>
<p class="BODYTEXT"><font face="Courier New, Courier, mono">DBG_PRINT(MY_RX_LVL,
("This is a print : %d count\r\n",count));</font></p>
<p class="BODYTEXT">Setting the default debug level is done by using the macro:
<font face="Courier New, Courier, mono">DBG_DECLARE</font> "level". Changing
the level at run-time is OS specific. </p>
<p class="HEADING1">Assertions</p>
<p class="BODYTEXT"> An assertion is used to check a boolean expression and throw
an error or exception( in some OS's, a breakpoint) when the expression
evaluates to FALSE. Typical expressions are: checks for NULL pointers, decrementing
past a minimum value, etc. Normally an assertion also prints the source
code line and number of where the assertion occurred. Assertions are usually
compiled out in release builds and typically used in the early stages
of debugging
to
catch major implementation
errors. Leaving assertions in code can ease software maintenance by catching
functional errors early in developer regression testing.
The following macro shows the basic form of an assertion:</p>
<pre><blockquote>
#define DBG_ASSERT(test) \
{ \
if (!(test)) { \
DBG_PRINT(SDBG_ERROR, \
("Debug Assert Caught at file: %s line:%s", \
__FILE__,__LINE__)); \
... throw exception \
} \
}
</blockquote></pre>
<p><br>
</p>
<!-- InstanceEndEditable -->
<br/></table></td></tr>
<table width="100%" border="0" cellspacing="0" cellpadding="2" >
<tr> <td><div align="right"><a href="#TopTopic">Back to top</a></div></td></tr>
<tr bgcolor="#0000FF">
<td>
<font color="#FFFFFF"face="Arial, Helvetica, sans-serif"><strong>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -