zoukankan      html  css  js  c++  java
  • FreeBSD 用kgdb调试kernel dump文件

    FreeBSD 用kgdb调试kernel dump文件

    来自: http://blog.csdn.net/ztz0223/article/details/8600052

    kgdb貌似和ddb一样属于FreeBSD专属的调试器。


    1、开启kdump功能
    root@BTazuo:/root # cat /etc/rc.conf
    # Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
    dumpdev="AUTO"

    2、模拟触发一个内核崩溃,做一个panic即可
    root@BTazuo:/root # sysctl debug.kdb.panic=1

    3、系统会把这个panic导致的dump文件存储在 /var/crash/目录下面,第一个命名为vmcore.0

    4、开始调试,先到 对应的内核版本的kernel.debug文件的路径下去:

    root@BTazuo:/usr/obj/usr/src/sys/GENERIC_20130219 # ll | grep kernel
    -rwxr-xr-x  1 root  wheel  16031061 Feb 19 14:36 kernel*
    -rwxr-xr-x  1 root  wheel  62180463 Feb 19 14:36 kernel.debug*
    -rwxr-xr-x  1 root  wheel  48269559 Feb 19 14:36 kernel.symbols*

    5、开始调试
    root@BTazuo:/usr/obj/usr/src/sys/GENERIC_20130219 # kgdb kernel.debug /var/crash/vmcore.0
    GNU gdb 6.1.1 [FreeBSD]
    Copyright 2004 Free Software Foundation, Inc.
    GDB is free software, covered by the GNU General Public License, and you are
    welcome to change it and/or distribute copies of it under certain conditions.
    Type "show copying" to see the conditions.
    There is absolutely no warranty for GDB.  Type "show warranty" for details.
    This GDB was configured as "i386-marcel-freebsd"...

    Unread portion of the kernel message buffer:
    panic: kdb_sysctl_panic
    cpuid = 1
    KDB: stack backtrace:
    #0 0xc0af3aff at kdb_backtrace+0x4f
    #1 0xc0ac052f at panic+0x16f
    #2 0xc0af36c9 at kdb_sysctl_panic+0x59
    #3 0xc0aca40a at sysctl_root+0x1fa
    #4 0xc0aca6c3 at userland_sysctl+0x1d3
    #5 0xc0acaa84 at sys___sysctl+0x94
    #6 0xc0e2579a at syscall+0x34a
    #7 0xc0e0f6d1 at Xint0x80_syscall+0x21
    Uptime: 24m35s
    Physical memory: 983 MB
    Dumping 202 MB: 187 171 155 139 123 107 91 75 59 43 27 11

    #0  doadump (textdump=1) at pcpu.h:244
    244             __asm("movl %%fs:0,%0" : "=r" (td));

    6、查看调用栈:
    (kgdb) bt
    #0  doadump (textdump=1) at pcpu.h:244
    ##1  0xc0ac027f in kern_reboot (howto=260) at /usr/src/sys/kern/kern_shutdown.c:448
    ##2  0xc0ac0572 in panic (fmt=Variable "fmt" is not available.
    #) at /usr/src/sys/kern/kern_shutdown.c:636
    ##3  0xc0af36c9 in kdb_sysctl_panic (oidp=0xc111aa60, arg1=0x0, arg2=0, req=0xd91c9b74) at /usr/src/sys/kern/subr_kdb.c:185
    ##4  0xc0aca40a in sysctl_root (oidp=Variable "oidp" is not available.
    #) at /usr/src/sys/kern/kern_sysctl.c:1513
    ##5  0xc0aca6c3 in userland_sysctl (td=0xc7d098a0, name=0xd91c9be0, namelen=3, old=0x0, oldlenp=0x0, inkernel=0, new=0xbfbfe4a0, newlen=4, retval=0xd91c9c40, flags=0)
    #    at /usr/src/sys/kern/kern_sysctl.c:1623
    #    #6  0xc0acaa84 in sys___sysctl (td=0xc7d098a0, uap=0xd91c9ccc) at /usr/src/sys/kern/kern_sysctl.c:1549
    #    #7  0xc0e2579a in syscall (frame=0xd91c9d08) at subr_syscall.c:135
    #    #8  0xc0e0f6d1 in Xint0x80_syscall () at /usr/src/sys/i386/i386/exception.s:267
    #    #9  0x00000033 in ?? ()
    #    Previous frame inner to this frame (corrupt stack?)


    可见这个panic是因为用户输入了sysctl panic导致的。

  • 相关阅读:
    贴一段微博上的小知识
    关于编译Qt以及驱动的一点总结吧
    一些服务器客户端的c例子
    android中DatePicker和TimePicker的使用
    Python标准库string模块《未完待续》
    Qt: SQL Programming
    和一个坑爹的项目组的经历
    linux一些杂项整理
    Qt中的QTableWidget
    Linux c学习进程基础学习
  • 原文地址:https://www.cnblogs.com/lsgxeva/p/8596202.html
Copyright © 2011-2022 走看看