【问题标题】:linux program does not answer. how can I know which routine caused that freeze?linux程序不回答。我怎么知道是哪个程序导致了冻结?
【发布时间】:2014-09-03 14:02:53
【问题描述】:

我的公司服务器应用程序出现问题。 我不能杀死它,因为我认为我下次将无法重现此错误。 所以我想知道如何获得有关此程序冻结原因的最大信息,包括但不限于其中的函数或例程。

如何知道当前正在执行哪个程序?

【问题讨论】:

    标签: linux procedure core freeze dump


    【解决方案1】:

    您可以使用gdb --pid=PID 调试进程,backtrace 会为您提供堆栈跟踪以找出函数。

    --pid=PID          Attach to running process PID.
    

    sleep 的示例

    $ sleep 1000 &
    [2] 13221
    $ gdb --pid=13221
    GNU gdb (GDB) Fedora 7.7.1-13.fc20
    Copyright (C) 2014 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
    and "show warranty" for details.
    This GDB was configured as "x86_64-redhat-linux-gnu".
    Type "show configuration" for configuration details.
    For bug reporting instructions, please see:
    <http://www.gnu.org/software/gdb/bugs/>.
    Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.
    For help, type "help".
    Type "apropos word" to search for commands related to "word".
    Attaching to process 13221
    Reading symbols from /usr/bin/sleep...Reading symbols from /usr/bin/sleep...(no debugging symbols found)...done.
    (no debugging symbols found)...done.
    Reading symbols from /lib64/libc.so.6...(no debugging symbols found)...done.
    Loaded symbols for /lib64/libc.so.6
    Reading symbols from /lib64/ld-linux-x86-64.so.2...(no debugging symbols found)...done.
    Loaded symbols for /lib64/ld-linux-x86-64.so.2
    0x0000003122abc970 in __nanosleep_nocancel () from /lib64/libc.so.6
    Missing separate debuginfos, use: debuginfo-install coreutils-8.21-21.fc20.x86_64
    (gdb) backtrace 
    #0  0x0000003122abc970 in __nanosleep_nocancel () from /lib64/libc.so.6
    #1  0x00000000004040cf in rpl_nanosleep ()
    #2  0x0000000000403f30 in xnanosleep ()
    #3  0x00000000004018ed in main ()
    (gdb) 
    

    【讨论】:

    • 如果应用程序使用调试信息编译(例如使用gcc -g),效果会更好。
    猜你喜欢
    • 1970-01-01
    • 2011-04-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多