<html>
<head>
    <base href="https://wiki.asterisk.org/wiki">
            <link rel="stylesheet" href="/wiki/s/en/2176/25/9/_/styles/combined.css?spaceKey=AST&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://wiki.asterisk.org/wiki/display/AST/CLI+commands+useful+for+debugging">CLI commands useful for debugging</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://wiki.asterisk.org/wiki/display/~rnewton">Rusty Newton</a>
    </h4>
        <div id="versionComment">
        <b>Comment:</b>
        Wrapped example output in expands - added another example of 'core show locks' with BETTER_BACKTRACES compiler flag enabled<br />
    </div>
        <br/>
                         <h4>Changes (17)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{warning} <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">This command is not available until you compile with [DEBUG_THREADS|AST:Using Menuselect to Select Asterisk Options]. If compiled with DEBUG_THREADS enabled and if you have glibc, then issuing the &quot;core show locks&quot; CLI command will give lock information output as well as a backtrace of the stack which led to the lock calls. <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">This command is not available until you compile with [DEBUG_THREADS|AST:Using Menuselect to Select Asterisk Options] and it is generally preferred that you also compile with [BETTER_BACKTRACES|AST:Using Menuselect to Select Asterisk Options] to get the most useful output. <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">If compiled with at least DEBUG_THREADS enabled and if you have glibc, then issuing the &quot;core show locks&quot; CLI command will give lock information output as well as a backtrace of the stack which led to the lock calls. <br> <br></td></tr>
            <tr><td class="diff-unchanged" >See the [AST:Getting a Backtrace] page for an example on why you might use this command. <br> <br> <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">Example command output: (lock</span> <span class="diff-added-words"style="background-color: #dfd;">Examples: (both a lock</span> during a feature code attended transfer) <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{expand:title=Example output with DEBUG_THREADS only} <br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br>ubuntu*CLI&gt; core show locks <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >======================================================================= <br>{code} <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{expand} <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">h3. &#39;core show taskprocessors&#39; <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{expand:title=Example output with DEBUG_THREADS and BETTER_BACKTRACES} <br>{code} <br>ubuntu*CLI&gt; core show locks <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">List instantiated task processors and statistics <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">======================================================================= <br>=== Currently Held Locks ============================================== <br>======================================================================= <br>=== <br>=== &lt;pending&gt; &lt;lock#&gt; (&lt;file&gt;): &lt;lock type&gt; &lt;line num&gt; &lt;function&gt; &lt;lock name&gt; &lt;lock addr&gt; (times locked) <br>=== <br>=== Thread ID: 0x7f44b6cda700 (pbx_thread           started at [ 6612] pbx.c ast_pbx_start()) <br>=== ---&gt; Lock #0 (features.c): RDLOCK 3304 ast_rdlock_call_features &amp;features_lock 0x816680 (1) <br>        main/logger.c:1541 ast_bt_get_addresses() (0x4fa6c0+E) <br>        main/lock.c:888 __ast_rwlock_rdlock() (0x4f7b20+C3) <br>        main/features.c:3453 builtin_feature_get_exten() <br>        main/features.c:3598 feature_interpret_helper() <br>        main/features.c:3727 feature_interpret() <br>        main/features.c:4676 ast_bridge_call() (0x4ce590+8EC) <br>        apps/app_dial.c:3045 dial_exec_full() <br>        apps/app_dial.c:3129 dial_exec() <br>        main/pbx.c:1590 pbx_exec() (0x527270+123) <br>        main/pbx.c:4665 pbx_extension_helper() <br>        main/pbx.c:6256 __ast_pbx_run() <br>        main/pbx.c:6554 decrease_call_count() <br>        main/utils.c:1093 dummy_start() <br>        :0 start_thread() <br>        libc.so.6 clone() (0x7f45082eac50+6D) <br>=== ------------------------------------------------------------------- <br>=== <br>======================================================================= <br>{code} <br>{expand} <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">Example command output: <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">h3. &#39;core show taskprocessors&#39; <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">List instantiated task processors and statistics <br> <br>{expand:title= Example command output} <br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br>ubuntu*CLI&gt; core show taskprocessors <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >        7 taskprocessors <br>{code} <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{expand} <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-unchanged" >h3. &#39;core show threads&#39; <br> <br>Shows running threads\!&amp;nbsp; Doesn&#39;t require any compilation flags to be set. <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">Example command output: <br> <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{expand:title= Example command output} <br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br>ubuntu*CLI&gt; core show threads <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >... &lt;snip&gt; <br>{code} <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{expand} <br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <div>
<ul>
    <li><a href='#CLIcommandsusefulfordebugging-%27coreshowlocks%27'>'core show locks'</a></li>
    <li><a href='#CLIcommandsusefulfordebugging-%27coreshowtaskprocessors%27'>'core show taskprocessors'</a></li>
    <li><a href='#CLIcommandsusefulfordebugging-%27coreshowthreads%27'>'core show threads'</a></li>
</ul></div>


<p>Example output on this page is from Asterisk 11.</p>


<h3><a name="CLIcommandsusefulfordebugging-%27coreshowlocks%27"></a>'core show locks'</h3>

<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b>Warning!</b><br />Compiling with DEBUG_THREADS can reduce the performance of Asterisk. Primarily in terms of memory consumption.</td></tr></table></div>

<p>This command is not available until you compile with <a href="/wiki/display/AST/Using+Menuselect+to+Select+Asterisk+Options" title="Using Menuselect to Select Asterisk Options">DEBUG_THREADS</a> and it is generally preferred that you also compile with <a href="/wiki/display/AST/Using+Menuselect+to+Select+Asterisk+Options" title="Using Menuselect to Select Asterisk Options">BETTER_BACKTRACES</a> to get the most useful output.</p>

<p>If compiled with at least DEBUG_THREADS enabled and if you have glibc, then issuing the "core show locks" CLI command will give lock information output as well as a backtrace of the stack which led to the lock calls.</p>

<p>See the <a href="/wiki/display/AST/Getting+a+Backtrace" title="Getting a Backtrace">Getting a Backtrace</a> page for an example on why you might use this command.</p>


<p>Examples: (both a lock during a feature code attended transfer)</p>


<style type="text/css">
@media all {
    .expand-content { margin-left: 20px; }
    .expand-control-icon { display: inline-block; width: 20px; }
    .expand-control-text { vertical-align: top; text-decoration:none; }
    .expand-control-image { vertical-align: middle; text-decoration:none; }
}
@media screen {
    .expand-hidden { display: none; }
    .expand-control { cursor: pointer; text-decoration: none; }
}
@media print {
    /* show expander text in print */
    .expand-content { display: block !important; }
}
</style>

                 <div id="expander-400012425" class="expand-control" tabindex="0"><span class="expand-control-icon"><img class="expand-control-image" src="/wiki/images/icons/arrow_down.png"></span><span class="expand-control-text">Example output with DEBUG_THREADS only</span></div>
    <div class="expand-content"><div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">ubuntu*CLI&gt; core show locks

=======================================================================
=== Currently Held Locks ==============================================
=======================================================================
===
=== &lt;pending&gt; &lt;lock#&gt; (&lt;file&gt;): &lt;lock type&gt; &lt;line num&gt; &lt;function&gt; &lt;lock name&gt; &lt;lock addr&gt; (times locked)
===
=== Thread ID: 0x7f13ea9ed700 (pbx_thread           started at [ 6612] pbx.c ast_pbx_start())
=== ---&gt; Lock #0 (features.c): RDLOCK 3304 ast_rdlock_call_features &amp;features_lock 0x815660 (1)
        asterisk(ast_bt_get_addresses+0xe) [0x4fa57e]
        asterisk(__ast_rwlock_rdlock+0xc3) [0x4f7a93]
        asterisk() [0x4c4639]
        asterisk() [0x4c5378]
        asterisk() [0x4c5841]
        asterisk(ast_bridge_call+0x8ec) [0x4ced2c]
        /usr/lib/asterisk/modules/app_dial.so(+0xbe0c) [0x7f13f7d72e0c]
        /usr/lib/asterisk/modules/app_dial.so(+0xcd96) [0x7f13f7d73d96]
        asterisk(pbx_exec+0x123) [0x526a53]
        asterisk() [0x531381]
        asterisk() [0x536998]
        asterisk() [0x5381eb]
        asterisk() [0x57a384]
        /lib/x86_64-linux-gnu/libpthread.so.0(+0x7e9a) [0x7f143ada1e9a]
        /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7f143bed0cbd]
=== -------------------------------------------------------------------
===
=======================================================================</pre>
</div></div></div>



<style type="text/css">
@media all {
    .expand-content { margin-left: 20px; }
    .expand-control-icon { display: inline-block; width: 20px; }
    .expand-control-text { vertical-align: top; text-decoration:none; }
    .expand-control-image { vertical-align: middle; text-decoration:none; }
}
@media screen {
    .expand-hidden { display: none; }
    .expand-control { cursor: pointer; text-decoration: none; }
}
@media print {
    /* show expander text in print */
    .expand-content { display: block !important; }
}
</style>

                 <div id="expander-1802748817" class="expand-control" tabindex="0"><span class="expand-control-icon"><img class="expand-control-image" src="/wiki/images/icons/arrow_down.png"></span><span class="expand-control-text">Example output with DEBUG_THREADS and BETTER_BACKTRACES</span></div>
    <div class="expand-content"><div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">ubuntu*CLI&gt; core show locks

=======================================================================
=== Currently Held Locks ==============================================
=======================================================================
===
=== &lt;pending&gt; &lt;lock#&gt; (&lt;file&gt;): &lt;lock type&gt; &lt;line num&gt; &lt;function&gt; &lt;lock name&gt; &lt;lock addr&gt; (times locked)
===
=== Thread ID: 0x7f44b6cda700 (pbx_thread           started at [ 6612] pbx.c ast_pbx_start())
=== ---&gt; Lock #0 (features.c): RDLOCK 3304 ast_rdlock_call_features &amp;features_lock 0x816680 (1)
        main/logger.c:1541 ast_bt_get_addresses() (0x4fa6c0+E)
        main/lock.c:888 __ast_rwlock_rdlock() (0x4f7b20+C3)
        main/features.c:3453 builtin_feature_get_exten()
        main/features.c:3598 feature_interpret_helper()
        main/features.c:3727 feature_interpret()
        main/features.c:4676 ast_bridge_call() (0x4ce590+8EC)
        apps/app_dial.c:3045 dial_exec_full()
        apps/app_dial.c:3129 dial_exec()
        main/pbx.c:1590 pbx_exec() (0x527270+123)
        main/pbx.c:4665 pbx_extension_helper()
        main/pbx.c:6256 __ast_pbx_run()
        main/pbx.c:6554 decrease_call_count()
        main/utils.c:1093 dummy_start()
        :0 start_thread()
        libc.so.6 clone() (0x7f45082eac50+6D)
=== -------------------------------------------------------------------
===
=======================================================================</pre>
</div></div></div>



<h3><a name="CLIcommandsusefulfordebugging-%27coreshowtaskprocessors%27"></a>'core show taskprocessors'</h3>

<p>List instantiated task processors and statistics</p>


<style type="text/css">
@media all {
    .expand-content { margin-left: 20px; }
    .expand-control-icon { display: inline-block; width: 20px; }
    .expand-control-text { vertical-align: top; text-decoration:none; }
    .expand-control-image { vertical-align: middle; text-decoration:none; }
}
@media screen {
    .expand-hidden { display: none; }
    .expand-control { cursor: pointer; text-decoration: none; }
}
@media print {
    /* show expander text in print */
    .expand-content { display: block !important; }
}
</style>

                 <div id="expander-502911204" class="expand-control" tabindex="0"><span class="expand-control-icon"><img class="expand-control-image" src="/wiki/images/icons/arrow_down.png"></span><span class="expand-control-text">Example command output</span></div>
    <div class="expand-content"><div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">ubuntu*CLI&gt; core show taskprocessors

        +----- Processor -----+--- Processed ---+- In Queue -+- Max Depth -+
               app_queue                   8            0            0
   core_event_dispatcher                  29            0            1
           app_voicemail                   0            0            0
                pbx-core                  11            0            0
           ast_msg_queue                   0            0            0
               CCSS core                   0            0            0
           iax2_transmit                   0            0            0
        +---------------------+-----------------+------------+-------------+
        7 taskprocessors</pre>
</div></div></div>


<h3><a name="CLIcommandsusefulfordebugging-%27coreshowthreads%27"></a>'core show threads'</h3>

<p>Shows running threads&#33;&nbsp; Doesn't require any compilation flags to be set.</p>


<style type="text/css">
@media all {
    .expand-content { margin-left: 20px; }
    .expand-control-icon { display: inline-block; width: 20px; }
    .expand-control-text { vertical-align: top; text-decoration:none; }
    .expand-control-image { vertical-align: middle; text-decoration:none; }
}
@media screen {
    .expand-hidden { display: none; }
    .expand-control { cursor: pointer; text-decoration: none; }
}
@media print {
    /* show expander text in print */
    .expand-content { display: block !important; }
}
</style>

                 <div id="expander-1034581571" class="expand-control" tabindex="0"><span class="expand-control-icon"><img class="expand-control-image" src="/wiki/images/icons/arrow_down.png"></span><span class="expand-control-text">Example command output</span></div>
    <div class="expand-content"><div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">ubuntu*CLI&gt; core show threads
0x7f869a7fb700 25102 netconsole           started at [ 1442] asterisk.c listener()
0x7f869a877700 25100 tps_processing_function started at [  471] taskprocessor.c ast_taskprocessor_get()
0x7f869a8f3700 25099 do_monitor           started at [ 5743] chan_unistim.c restart_monitor()
0x7f869a96f700 25098 tps_processing_function started at [  471] taskprocessor.c ast_taskprocessor_get()
0x7f869a9eb700 25097 process_clearcache   started at [ 2267] pbx_dundi.c start_network_thread()
0x7f869aa67700 25096 process_precache     started at [ 2266] pbx_dundi.c start_network_thread()
0x7f869aae3700 25095 network_thread       started at [ 2265] pbx_dundi.c start_network_thread()
0x7f869ab5f700 25094 cleanup              started at [  414] pbx_realtime.c load_module()
0x7f869abdb700 25093 lock_broker          started at [  509] func_lock.c load_module()

... &lt;snip&gt;</pre>
</div></div></div>

    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;" class="grey">
                        <a href="https://wiki.asterisk.org/wiki/users/removespacenotification.action?spaceKey=AST">Stop watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://wiki.asterisk.org/wiki/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
        <a href="https://wiki.asterisk.org/wiki/display/AST/CLI+commands+useful+for+debugging">View Online</a>
        |
        <a href="https://wiki.asterisk.org/wiki/pages/diffpagesbyversion.action?pageId=22087961&revisedVersion=2&originalVersion=1">View Changes</a>
                |
        <a href="https://wiki.asterisk.org/wiki/display/AST/CLI+commands+useful+for+debugging?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>