linux 分析进程占用CPU过高

心不动则不痛 提交于 2021-02-10 11:17:44

<div id="article_content" csdn-tracking-statistics"="" data-pid="blog" data-mod="popu_307" data-dsm="post" style="box-sizing: inherit; outline: 0px; padding: 0px; margin: 0px; word-break: break-all;"><div style="box-sizing: inherit; outline: 0px; padding: 0px; margin: 0px; font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; word-break: break-all;"><p style="box-sizing: border-box; outline: 0px; padding: 0px; margin: 0px 0px 16px; font-size: 16px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all;">重点是查看进程的线程中,哪个线程占用cpu过高,然后用gdb附加到进程,调试线程,看是否有死循环或者死锁等问题,步骤如下:&nbsp;<br style="box-sizing: border-box; outline: 0px; word-break: break-all;">1 先用ps + grep找出该死的进程pid,比如 1706</p><p style="box-sizing: border-box; outline: 0px; padding: 0px; margin: 0px 0px 16px; font-size: 16px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all;">2 top -H -p 1706,(top然后shift+H可以看出某个线程,左上角有提示:thread on 则为可查看线程)所有该进程的线程都列出来, 看看哪个线程pid占用最多,记下对应的线程号,如:1723</p><ol style="box-sizing: border-box; outline: 0px; padding: 0px; margin: 0px 0px 24px; list-style: none; word-break: break-all;"><li style="box-sizing: border-box; outline: 0px; padding: 0px; margin: 8px 0px 0px 40px; list-style-type: decimal; word-break: break-all;">gdb attach 到进程号码(1706)</li><li style="box-sizing: border-box; outline: 0px; padding: 0px; margin: 8px 0px 0px 40px; list-style-type: decimal; word-break: break-all;">(仍然在gdb中) info threads 结果大致如下:</li></ol><pre name="code" style="box-sizing: border-box; outline: 0px; padding: 8px 16px 4px 56px; margin-top: 0px; margin-bottom: 24px; position: relative; overflow-y: hidden; overflow-x: auto; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 22px; color: #000000; word-break: break-all; background-color: #f6f8fa; border: none;"><code python="" has-numbering"="" style="box-sizing: border-box; outline: 0px; display: block; padding: 0px; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 22px; border-radius: 4px; overflow-x: auto; word-wrap: normal; word-break: break-all;" class="hljs groovy">(gdb) info threads <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">8</span></span> Thread <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">0x7f9fa9366700</span></span> (LWP <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">1716</span></span>) <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">0x0000003cec00b98e</span></span> <span style="box-sizing: border-box; outline: 0px; color: #000088; word-break: break-all;"><span class="hljs-keyword">in</span></span> pthread_cond_timedwait<span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;">@<span class="hljs-meta">@GLIBC</span>_2<span class="hljs-number">.3</span><span class="hljs-number">.2</span> () from <span class="hljs-regexp">/lib64/</span>libpthread.so<span class="hljs-number">.0</span></span> <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">7</span></span> Thread <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">0x7f9fa8965700</span></span> (LWP <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">1720</span></span>) <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">0x0000003cec00b98e</span></span> <span style="box-sizing: border-box; outline: 0px; color: #000088; word-break: break-all;"><span class="hljs-keyword">in</span></span> pthread_cond_timedwait<span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;">@<span class="hljs-meta">@GLIBC</span>_2<span class="hljs-number">.3</span><span class="hljs-number">.2</span> () from <span class="hljs-regexp">/lib64/</span>libpthread.so<span class="hljs-number">.0</span></span> <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">6</span></span> Thread <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">0x7f9fa7f64700</span></span> (LWP <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">1721</span></span>) <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">0x0000003cec00f4b5</span></span> <span style="box-sizing: border-box; outline: 0px; color: #000088; word-break: break-all;"><span class="hljs-keyword">in</span></span> sigwait () <span style="box-sizing: border-box; outline: 0px; color: #000088; word-break: break-all;">from</span> <span class="hljs-regexp">/lib64/</span>libpthread.so<span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">.0</span></span> <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">5</span></span> Thread <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">0x7f9fa7563700</span></span> (LWP <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">1722</span></span>) <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">0x0000003cec00b98e</span></span> <span style="box-sizing: border-box; outline: 0px; color: #000088; word-break: break-all;"><span class="hljs-keyword">in</span></span> pthread_cond_timedwait<span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;">@<span class="hljs-meta">@GLIBC</span>_2<span class="hljs-number">.3</span><span class="hljs-number">.2</span> () from <span class="hljs-regexp">/lib64/</span>libpthread.so<span class="hljs-number">.0</span></span> <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">4</span></span> Thread <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">0x7f9fa6b62700</span></span> (LWP <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">1723</span></span>) <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">0x0000003cec00b5bc</span></span> <span style="box-sizing: border-box; outline: 0px; color: #000088; word-break: break-all;"><span class="hljs-keyword">in</span></span> pthread_cond_wait<span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;">@<span class="hljs-meta">@GLIBC</span>_2<span class="hljs-number">.3</span><span class="hljs-number">.2</span></span> () <span style="box-sizing: border-box; outline: 0px; color: #000088; word-break: break-all;">from</span> <span class="hljs-regexp">/lib64/</span>libpthread.so<span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">.0</span></span> <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">3</span></span> Thread <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">0x7f9fa6161700</span></span> (LWP <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">1724</span></span>) <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">0x0000003cebce9163</span></span> <span style="box-sizing: border-box; outline: 0px; color: #000088; word-break: break-all;"><span class="hljs-keyword">in</span></span> epoll_wait () <span style="box-sizing: border-box; outline: 0px; color: #000088; word-break: break-all;">from</span> <span class="hljs-regexp">/lib64/</span>libc.so<span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">.6</span></span> <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">2</span></span> Thread <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">0x7f9fa1159700</span></span> (LWP <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">1887</span></span>) <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">0x0000003cebce9163</span></span> <span style="box-sizing: border-box; outline: 0px; color: #000088; word-break: break-all;"><span class="hljs-keyword">in</span></span> epoll_wait () <span style="box-sizing: border-box; outline: 0px; color: #000088; word-break: break-all;">from</span> <span class="hljs-regexp">/lib64/</span>libc.so<span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">.6</span></span> * <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">1</span></span> Thread <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">0x7f9fa95ad820</span></span> (LWP <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">1706</span></span>) <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">0x0000003cec00b5bc</span></span> <span style="box-sizing: border-box; outline: 0px; color: #000088; word-break: break-all;"><span class="hljs-keyword">in</span></span> pthread_cond_wait<span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;">@<span class="hljs-meta">@GLIBC</span>_2<span class="hljs-number">.3</span><span class="hljs-number">.2</span></span> () <span style="box-sizing: border-box; outline: 0px; color: #000088; word-break: break-all;">from</span> <span class="hljs-regexp">/lib64/</span>libpthread.so<span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">.0</span></span></code><ul style="box-sizing: border-box; outline: 0px; padding: 8px 0px; margin: 0px; list-style: none; word-break: break-all; position: absolute; width: 48px; background-color: #eef0f4; top: 0px; left: 0px;"><li style="box-sizing: border-box; outline: 0px; padding: 0px 8px; margin: 0px; list-style: none; word-break: break-all; color: #999999;">1</li><li style="box-sizing: border-box; outline: 0px; padding: 0px 8px; margin: 0px; list-style: none; word-break: break-all; color: #999999;">2</li><li style="box-sizing: border-box; outline: 0px; padding: 0px 8px; margin: 0px; list-style: none; word-break: break-all; color: #999999;">3</li><li style="box-sizing: border-box; outline: 0px; padding: 0px 8px; margin: 0px; list-style: none; word-break: break-all; color: #999999;">4</li><li style="box-sizing: border-box; outline: 0px; padding: 0px 8px; margin: 0px; list-style: none; word-break: break-all; color: #999999;">5</li><li style="box-sizing: border-box; outline: 0px; padding: 0px 8px; margin: 0px; list-style: none; word-break: break-all; color: #999999;">6</li><li style="box-sizing: border-box; outline: 0px; padding: 0px 8px; margin: 0px; list-style: none; word-break: break-all; color: #999999;">7</li><li style="box-sizing: border-box; outline: 0px; padding: 0px 8px; margin: 0px; list-style: none; word-break: break-all; color: #999999;">8</li><li style="box-sizing: border-box; outline: 0px; padding: 0px 8px; margin: 0px; list-style: none; word-break: break-all; color: #999999;">9</li><li style="box-sizing: border-box; outline: 0px; padding: 0px 8px; margin: 0px; list-style: none; word-break: break-all; color: #999999;">10</li><li style="box-sizing: border-box; outline: 0px; padding: 0px 8px; margin: 0px; list-style: none; word-break: break-all; color: #999999;">11</li><li style="box-sizing: border-box; outline: 0px; padding: 0px 8px; margin: 0px; list-style: none; word-break: break-all; color: #999999;">12</li><li style="box-sizing: border-box; outline: 0px; padding: 0px 8px; margin: 0px; list-style: none; word-break: break-all; color: #999999;">13</li><li style="box-sizing: border-box; outline: 0px; padding: 0px 8px; margin: 0px; list-style: none; word-break: break-all; color: #999999;">14</li></ul></pre><p style="box-sizing: border-box; outline: 0px; padding: 0px; margin: 0px 0px 16px; font-size: 16px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all;">找到线程号码对应的thread(LWP1723)即是我们刚刚记下的线程号</p><ol style="box-sizing: border-box; outline: 0px; padding: 0px; margin: 0px 0px 24px; list-style: none; word-break: break-all;"><li style="box-sizing: border-box; outline: 0px; padding: 0px; margin: 8px 0px 0px 40px; list-style-type: decimal; word-break: break-all;">(仍然在gdb中)thread 线程号码切换到线程(4)–这里在info threads显示出来的序号需要使用gdb能识别的线程序号,即执行:thread 4切换到我们刚刚记下的线程号:1723的对应线程,如下:</li></ol><pre name="code" style="box-sizing: border-box; outline: 0px; padding: 8px 16px 4px 56px; margin-top: 0px; margin-bottom: 24px; position: relative; overflow-y: hidden; overflow-x: auto; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 22px; color: #000000; word-break: break-all; background-color: #f6f8fa; border: none;"><code oxygene="" has-numbering"="" style="box-sizing: border-box; outline: 0px; display: block; padding: 0px; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 22px; border-radius: 4px; overflow-x: auto; word-wrap: normal; word-break: break-all;" class="hljs css">(<span class="hljs-selector-tag">gdb</span>) <span class="hljs-selector-tag">thread</span> <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;">4</span> <span class="hljs-selector-attr">[Switching </span><span style="box-sizing: border-box; outline: 0px; color: #000088; word-break: break-all;"><span class="hljs-selector-attr">to</span></span><span class="hljs-selector-attr"> thread </span><span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-selector-attr">4</span></span><span class="hljs-selector-attr"> (Thread </span><span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-selector-attr">0</span></span><span class="hljs-selector-attr">x7f9fa6b62700 (LWP </span><span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-selector-attr">1723</span></span><span class="hljs-selector-attr">))]</span><span style="box-sizing: border-box; outline: 0px; color: #009900; word-break: break-all;"><span class="hljs-selector-id">#0</span></span> <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;">0</span><span class="hljs-selector-tag">x0000003cec00b5bc</span> <span style="box-sizing: border-box; outline: 0px; color: #000088; word-break: break-all;"><span class="hljs-selector-tag">in</span></span> <span class="hljs-selector-tag">pthread_cond_wait</span>@@<span class="hljs-keyword">GLIBC_2</span>.<span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-keyword">3</span>.<span class="hljs-keyword">2</span></span> () <span style="box-sizing: border-box; outline: 0px; color: #000088; word-break: break-all;">from</span> /lib64/libpthread.so.<span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">0</span></span></code><ul style="box-sizing: border-box; outline: 0px; padding: 8px 0px; margin: 0px; list-style: none; word-break: break-all; position: absolute; width: 48px; background-color: #eef0f4; top: 0px; left: 0px;"><li style="box-sizing: border-box; outline: 0px; padding: 0px 8px; margin: 0px; list-style: none; word-break: break-all; color: #999999;">1</li><li style="box-sizing: border-box; outline: 0px; padding: 0px 8px; margin: 0px; list-style: none; word-break: break-all; color: #999999;">2</li></ul></pre><p style="box-sizing: border-box; outline: 0px; padding: 0px; margin: 0px 0px 16px; font-size: 16px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all;">6.(仍然在gdb中)bt 查看线程调用堆栈&nbsp;<br style="box-sizing: border-box; outline: 0px; word-break: break-all;">(gdb) bt</p><pre name="code" style="box-sizing: border-box; outline: 0px; padding: 8px 16px 4px 56px; margin-top: 0px; margin-bottom: 24px; position: relative; overflow-y: hidden; overflow-x: auto; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 22px; color: #000000; word-break: break-all; background-color: #f6f8fa; border: none;"><code lasso="" has-numbering"="" style="box-sizing: border-box; outline: 0px; display: block; padding: 0px; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 22px; border-radius: 4px; overflow-x: auto; word-wrap: normal; word-break: break-all;" class="hljs less"><span style="box-sizing: border-box; outline: 0px; color: #4f4f4f; word-break: break-all;"><span class="hljs-selector-id">#0</span></span> <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-selector-tag">0x0000003cec00b5bc</span></span> <span style="box-sizing: border-box; outline: 0px; color: #000088; word-break: break-all;"><span class="hljs-selector-tag">in</span></span> <span class="hljs-selector-tag">pthread_cond_wait</span>@@<span class="hljs-selector-tag">GLIBC_2</span><span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-selector-class">.3</span></span><span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-selector-class">.2</span></span> () <span class="hljs-selector-tag">from</span> /<span class="hljs-selector-tag">lib64</span>/<span class="hljs-selector-tag">libpthread</span><span style="box-sizing: border-box; outline: 0px; color: #4f4f4f; word-break: break-all;"><span class="hljs-selector-class">.</span></span><span class="hljs-selector-class">so</span><span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-selector-class">.0</span></span> <span style="box-sizing: border-box; outline: 0px; color: #4f4f4f; word-break: break-all;"><span class="hljs-selector-id">#1</span></span> <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-selector-tag">0x00007f9fa9f7144d</span></span> <span style="box-sizing: border-box; outline: 0px; color: #000088; word-break: break-all;"><span class="hljs-selector-tag">in</span></span> <span class="hljs-selector-tag">IceUtil</span><span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-selector-pseudo">::Cond</span></span><span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-selector-pseudo">::waitImpl</span></span> (this<span style="box-sizing: border-box; outline: 0px; color: #4f4f4f; word-break: break-all;">=</span><span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">0</span>x263f4c8</span>, mutex<span style="box-sizing: border-box; outline: 0px; color: #4f4f4f; word-break: break-all;">=</span><span style="box-sizing: border-box; outline: 0px; word-break: break-all;">...</span>) <span class="hljs-selector-tag">at</span> <span style="box-sizing: border-box; outline: 0px; color: #4f4f4f; word-break: break-all;">..</span><span style="box-sizing: border-box; outline: 0px; color: #4f4f4f; word-break: break-all;">/</span><span style="box-sizing: border-box; outline: 0px; color: #4f4f4f; word-break: break-all;">..</span>/<span class="hljs-selector-tag">include</span>/<span class="hljs-selector-tag">IceUtil</span>/<span class="hljs-selector-tag">Cond</span><span style="box-sizing: border-box; outline: 0px; color: #4f4f4f; word-break: break-all;"><span class="hljs-selector-class">.</span></span><span class="hljs-selector-class">h</span><span class="hljs-selector-pseudo">:</span><span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-selector-pseudo">215</span></span> <span style="box-sizing: border-box; outline: 0px; color: #4f4f4f; word-break: break-all;"><span class="hljs-selector-id">#2</span></span> <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-selector-tag">0x00007f9fa9f9a4b1</span></span> <span style="box-sizing: border-box; outline: 0px; color: #000088; word-break: break-all;"><span class="hljs-selector-tag">in</span></span> <span class="hljs-selector-tag">IceUtil</span><span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-selector-pseudo">::Monitor</span></span><span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-selector-pseudo">::wait</span></span> (this<span style="box-sizing: border-box; outline: 0px; color: #4f4f4f; word-break: break-all;">=</span><span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">0</span>x263f4c8</span>) <span class="hljs-selector-tag">at</span> <span style="box-sizing: border-box; outline: 0px; color: #4f4f4f; word-break: break-all;">..</span><span style="box-sizing: border-box; outline: 0px; color: #4f4f4f; word-break: break-all;">/</span><span style="box-sizing: border-box; outline: 0px; color: #4f4f4f; word-break: break-all;">..</span>/<span class="hljs-selector-tag">include</span>/<span class="hljs-selector-tag">IceUtil</span>/<span class="hljs-selector-tag">Monitor</span><span style="box-sizing: border-box; outline: 0px; color: #4f4f4f; word-break: break-all;"><span class="hljs-selector-class">.</span></span><span class="hljs-selector-class">h</span><span class="hljs-selector-pseudo">:</span><span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-selector-pseudo">152</span></span> <span style="box-sizing: border-box; outline: 0px; color: #4f4f4f; word-break: break-all;"><span class="hljs-selector-id">#3</span></span> <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-selector-tag">0x00007f9fa9fd7567</span></span> <span style="box-sizing: border-box; outline: 0px; color: #000088; word-break: break-all;"><span class="hljs-selector-tag">in</span></span> <span class="hljs-selector-tag">IceInternal</span><span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-selector-pseudo">::EndpointHostResolver</span></span><span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-selector-pseudo">::run</span></span> (this<span style="box-sizing: border-box; outline: 0px; color: #4f4f4f; word-break: break-all;">=</span><span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">0</span>x263f480</span>) <span class="hljs-selector-tag">at</span> <span class="hljs-selector-tag">EndpointI</span><span style="box-sizing: border-box; outline: 0px; color: #4f4f4f; word-break: break-all;"><span class="hljs-selector-class">.</span></span><span class="hljs-selector-class">cpp</span><span class="hljs-selector-pseudo">:</span><span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-selector-pseudo">161</span></span> <span style="box-sizing: border-box; outline: 0px; color: #4f4f4f; word-break: break-all;"><span class="hljs-selector-id">#4</span></span> <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-selector-tag">0x00007f9fa9b1b975</span></span> <span style="box-sizing: border-box; outline: 0px; color: #000088; word-break: break-all;"><span class="hljs-selector-tag">in</span></span> <span class="hljs-selector-tag">startHook</span> (arg<span style="box-sizing: border-box; outline: 0px; color: #4f4f4f; word-break: break-all;">=</span><span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-number">0</span>x263f480</span>) <span class="hljs-selector-tag">at</span> <span style="box-sizing: border-box; outline: 0px; color: #000088; word-break: break-all;"><span class="hljs-selector-tag">Thread</span></span><span style="box-sizing: border-box; outline: 0px; color: #4f4f4f; word-break: break-all;"><span class="hljs-selector-class">.</span></span><span class="hljs-selector-class">cpp</span><span class="hljs-selector-pseudo">:</span><span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-selector-pseudo">413</span></span> <span style="box-sizing: border-box; outline: 0px; color: #4f4f4f; word-break: break-all;"><span class="hljs-selector-id">#5</span></span> <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-selector-tag">0x0000003cec0079d1</span></span> <span style="box-sizing: border-box; outline: 0px; color: #000088; word-break: break-all;"><span class="hljs-selector-tag">in</span></span> <span class="hljs-selector-tag">start_thread</span> () <span class="hljs-selector-tag">from</span> /<span class="hljs-selector-tag">lib64</span>/<span class="hljs-selector-tag">libpthread</span><span style="box-sizing: border-box; outline: 0px; color: #4f4f4f; word-break: break-all;"><span class="hljs-selector-class">.</span></span><span class="hljs-selector-class">so</span><span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-selector-class">.0</span></span> <span style="box-sizing: border-box; outline: 0px; color: #4f4f4f; word-break: break-all;"><span class="hljs-selector-id">#6</span></span> <span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-selector-tag">0x0000003cebce8b6d</span></span> <span style="box-sizing: border-box; outline: 0px; color: #000088; word-break: break-all;"><span class="hljs-selector-tag">in</span></span> <span class="hljs-selector-tag">clone</span> () <span class="hljs-selector-tag">from</span> /<span class="hljs-selector-tag">lib64</span>/<span class="hljs-selector-tag">libc</span><span style="box-sizing: border-box; outline: 0px; color: #4f4f4f; word-break: break-all;"><span class="hljs-selector-class">.</span></span><span class="hljs-selector-class">so</span><span style="box-sizing: border-box; outline: 0px; color: #006666; word-break: break-all;"><span class="hljs-selector-class">.6</span></span></code><ul style="box-sizing: border-box; outline: 0px; padding: 8px 0px; margin: 0px; list-style: none; word-break: break-all; position: absolute; width: 48px; background-color: #eef0f4; top: 0px; left: 0px;"><li style="box-sizing: border-box; outline: 0px; padding: 0px 8px; margin: 0px; list-style: none; word-break: break-all; color: #999999;">1</li><li style="box-sizing: border-box; outline: 0px; padding: 0px 8px; margin: 0px; list-style: none; word-break: break-all; color: #999999;">2</li><li style="box-sizing: border-box; outline: 0px; padding: 0px 8px; margin: 0px; list-style: none; word-break: break-all; color: #999999;">3</li><li style="box-sizing: border-box; outline: 0px; padding: 0px 8px; margin: 0px; list-style: none; word-break: break-all; color: #999999;">4</li><li style="box-sizing: border-box; outline: 0px; padding: 0px 8px; margin: 0px; list-style: none; word-break: break-all; color: #999999;">5</li><li style="box-sizing: border-box; outline: 0px; padding: 0px 8px; margin: 0px; list-style: none; word-break: break-all; color: #999999;">6</li><li style="box-sizing: border-box; outline: 0px; padding: 0px 8px; margin: 0px; list-style: none; word-break: break-all; color: #999999;">7</li><li style="box-sizing: border-box; outline: 0px; padding: 0px 8px; margin: 0px; list-style: none; word-break: break-all; color: #999999;">8</li><li style="box-sizing: border-box; outline: 0px; padding: 0px 8px; margin: 0px; list-style: none; word-break: break-all; color: #999999;">9</li><li style="box-sizing: border-box; outline: 0px; padding: 0px 8px; margin: 0px; list-style: none; word-break: break-all; color: #999999;">10</li></ul></pre><p style="box-sizing: border-box; outline: 0px; padding: 0px; margin: 0px 0px 16px; font-size: 16px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all;">7.从上面输出的信息,基本上可以查看线程对应的代码断,是否有死循环等,如果是死锁的话,需要多次查看当前线程堆栈,或者查看全部线程的堆栈,总是会有某些个线程跟其他线程不一致,然后再对应到代码来进行定位解决</p></div>原文地址:https://www.cnblogs.com/wxmdevelop/p/8982255.html</div>

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!