📄 debugging-techniques.html
字号:
<!-- Copyright (C) 2003 Red Hat, Inc. --><!-- This material may be distributed only subject to the terms --><!-- and conditions set forth in the Open Publication License, v1.0 --><!-- or later (the latest version is presently available at --><!-- http://www.opencontent.org/openpub/). --><!-- Distribution of the work or derivative of the work in any --><!-- standard (paper) book form is prohibited unless prior --><!-- permission is obtained from the copyright holder. --><HTML><HEAD><TITLE>Debugging Techniques</TITLE><meta name="MSSmartTagsPreventParsing" content="TRUE"><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+"><LINKREL="HOME"TITLE="eCos User Guide"HREF="ecos-user-guide.html"><LINKREL="UP"TITLE="eCos Programming Concepts and Techniques"HREF="ecos-programming-concepts-and-techniques.html"><LINKREL="PREVIOUS"TITLE="Compiling a C++ Application"HREF="compiling-cpp-app.html"><LINKREL="NEXT"TITLE="Kernel Instrumentation"HREF="kernel-instrumentation.html"></HEAD><BODYCLASS="CHAPTER"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLESUMMARY="Header navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">eCos User Guide</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="compiling-cpp-app.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom"></TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="kernel-instrumentation.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="CHAPTER"><H1><ANAME="DEBUGGING-TECHNIQUES">Chapter 27. Debugging Techniques</H1><DIVCLASS="TOC"><DL><DT><B>Table of Contents</B></DT><DT><AHREF="debugging-techniques.html#TRACING">Tracing</A></DT><DT><AHREF="kernel-instrumentation.html">Kernel Instrumentation</A></DT></DL></DIV><P><SPANCLASS="PRODUCTNAME">eCos</SPAN> applications and components can be debugged in traditional ways, with printing statements and debugger single-stepping, but there are situations in which these techniques cannot be used. One example of this is when a program is getting data at a high rate from a real-time source, and cannot be slowed down or interrupted.</P><P><SPANCLASS="PRODUCTNAME">eCos</SPAN>’s infrastructure module provides a <SPANCLASS="emphasis"><ICLASS="EMPHASIS">tracing</I></SPAN> formalism, allowing the kernel’s tracing macros to be configured in many useful ways. <SPANCLASS="PRODUCTNAME">eCos</SPAN>’s kernel provides <ICLASS="FIRSTTERM">instrumentation buffers</I> which also collect specific (configurable) data about the system’s history and performance.</P><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="TRACING">Tracing</H1><P>To use <SPANCLASS="PRODUCTNAME">eCos</SPAN>’s tracing facilities you must first configure your system to use <ICLASS="FIRSTTERM">tracing</I>. You should enable the Asserts and Tracing component (<TTCLASS="OPTION">CYGPKG_INFRA_DEBUG</TT>) and the <TTCLASS="OPTION">Use tracing</TT> component within it (<TTCLASS="OPTION">CYGDBG_USE_TRACING</TT>). These options can be enabled with the <SPANCLASS="APPLICATION">Configuration Tool</SPAN> or by editing the file <TTCLASS="FILENAME"><TTCLASS="REPLACEABLE"><I>BUILD_DIR</I></TT>/pkgconf/infra.h </TT> manually.</P><P>You should then examine all the tracing-related options inthe <ICLASS="CITETITLE">Package: Infrastructure</I> chapter of the <ICLASS="CITETITLE"><SPANCLASS="PRODUCTNAME">eCos</SPAN> ReferenceManual</I>. One useful set of configuration options are: <TTCLASS="LITERAL">CYGDBG_INFRA_DEBUG_FUNCTION_REPORTS</TT> and <TTCLASS="LITERAL">CYGDBG_INFRA_DEBUG_TRACE_MESSAGE</TT>,which are both enabled by default when tracing is enabled.</P><P>The following “Hello world with tracing” showsthe output from running the hello world program (from <AHREF="building-and-running-sample-appliations.html#ECOS-HELLO-WORLD">the Section called <I><SPANCLASS="PRODUCTNAME">eCos</SPAN> Hello World</I> in Chapter 13</A>) that wasbuilt with tracing enabled: </P><DIVCLASS="EXAMPLE"><ANAME="AEN2289"><P><B>Example 27-1. Hello world with tracing</B></P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="SCREEN">$ mips-tx39-elf-run --board=jmr3904 helloHello, eCos world!ASSERT FAIL: <2>cyg_trac.h [ 623] Cyg_TraceFunction_Report_::set_exitvoid() exitvoid used in typed functionTRACE: <1>mlqueue.cxx [ 395] Cyg_ThreadQueue_Implementation::enqueue() {{enterTRACE: <1>mlqueue.cxx [ 395] Cyg_ThreadQueue_Implementation::enqueue() }}RETURNING UNSET!TRACE: <1>mlqueue.cxx [ 126] Cyg_Scheduler_Implementation::add_thread() }}RETURNING UNSET!TRACE: <1>thread.cxx [ 654] Cyg_Thread::resume() }}return voidTRACE: <1>cstartup.cxx [ 160] cyg_iso_c_start() }}return voidTRACE: <1>startup.cxx [ 142] cyg_package_start() }}return voidTRACE: <1>startup.cxx [ 150] cyg_user_start() {{enterTRACE: <1>startup.cxx [ 150] cyg_user_start() (((void)))TRACE: <1>startup.cxx [ 153] cyg_user_start() 'This is the system default cyg_user_start()'TRACE: <1>startup.cxx [ 157] cyg_user_start() }}return voidTRACE: <1>sched.cxx [ 212] Cyg_Scheduler::start() {{enterTRACE: <1>mlqueue.cxx [ 102] Cyg_Scheduler_Implementation::schedule() {{enterTRACE: <1>mlqueue.cxx [ 437] Cyg_ThreadQueue_Implementation::highpri() {{enterTRACE: <1>mlqueue.cxx [ 437] Cyg_ThreadQueue_Implementation::highpri() }}RETURNING UNSET!TRACE: <1>mlqueue.cxx [ 102] Cyg_Scheduler_Implementation::schedule() }}RETURNING UNSET!TRACE: <2>intr.cxx [ 450] Cyg_Interrupt::enable_interrupts() {{enterTRACE: <2>intr.cxx [ 450] Cyg_Interrupt::enable_interrupts() }}RETURNING UNSET!TRACE: <2>thread.cxx [ 69] Cyg_HardwareThread::thread_entry() {{enterTRACE: <2>cstartup.cxx [ 127] invoke_main() {{enterTRACE: <2>cstartup.cxx [ 127] invoke_main() ((argument is ignored))TRACE: <2>dummyxxmain.cxx [ 60] __main() {{enterTRACE: <2>dummyxxmain.cxx [ 60] __main() (((void)))TRACE: <2>dummyxxmain.cxx [ 63] __main() 'This is the system default __main()'TRACE: <2>dummyxxmain.cxx [ 67] __main() }}return voidTRACE: <2>memcpy.c [ 112] _memcpy() {{enterTRACE: <2>memcpy.c [ 112] _memcpy() ((dst=80002804, src=BFC14E58, n=19))TRACE: <2>memcpy.c [ 164] _memcpy() }}returning 80002804TRACE: <2>cstartup.cxx [ 137] invoke_main() 'main() has returned with code 0. Calling exit()'TRACE: <2>exit.cxx [ 71] __libc_exit() {{enterTRACE: <2>exit.cxx [ 71] __libc_exit() ((status=0 ))TRACE: <2>atexit.cxx [ 84] cyg_libc_invoke_atexit_handlers() {{enterTRACE: <2>atexit.cxx [ 84] cyg_libc_invoke_atexit_handlers() (((void)))Scheduler:Lock: 0Current Thread: <null>Threads:Idle Thread pri = 31 state = R id = 1 stack base = 800021F0 ptr = 80002510 size = 00000400 sleep reason NONE wake reason NONE queue = 80000C54 wait info = 00000000<null> pri = 0 state = R id = 2 stack base = 80002A48 ptr = 8000A968 size = 00008000 sleep reason NONE wake reason NONE queue = 80000BD8 wait info = 00000000 </PRE></TD></TR></TABLE></DIV></DIV></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLESUMMARY="Footer navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="compiling-cpp-app.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="ecos-user-guide.html"ACCESSKEY="H">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="kernel-instrumentation.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Compiling a C++ Application</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="ecos-programming-concepts-and-techniques.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Kernel Instrumentation</TD></TR></TABLE></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -