cat /proc/version Linux version 5.15.0-69-generic (buildd@lcy02-amd64-071) (gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #76~20.04.1-Ubuntu SMP Mon Mar 20 15:54:19 UTC 2023
虚拟机2
1 2
cat /proc/version Linux version 5.4.0 (root@driver-virtual-machine) (gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1)) #1 SMP Fri May 19 09:19:53 CST 2023
初识
运行环境:虚拟机1
1 2
cat /proc/version Linux version 5.15.0-69-generic (buildd@lcy02-amd64-071) (gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #76~20.04.1-Ubuntu SMP Mon Mar 20 15:54:19 UTC 2023
NAMELIST This is a pathname to an uncompressed kernel image (a vmlinux file), or a Xen hypervisor image (a xen-syms file) which has been compiled with the "-g" option. If using the dumpfile form, a vmlinux file may be compressed in either gzip or bzip2 formats.
MEMORY-IMAGE A kernel core dump file created by the netdump, diskdump, LKCD kdump, xendump or kvmdump facilities.
获取vmlinux
方法1: apt下载方法(失败)
1 2 3 4 5 6 7 8 9 10 11 12 13
# lsb_release -cs即版本名,例如focal,麒麟操作系统kylin是不行的,可以考虑替换成相近的ubuntu版本名 echo"deb http://ddebs.ubuntu.com $(lsb_release -cs)-updates main restricted universe multiverse deb http://ddebs.ubuntu.com $(lsb_release -cs)-security main restricted universe multiverse deb http://ddebs.ubuntu.com $(lsb_release -cs)-proposed main restricted universe multiverse" | \ sudo tee -a /etc/apt/sources.list.d/ddebs.list
# 这个是解决问题public key is not available: NO_PUBKEY 3F01618A51312F3F,需加入相应的公钥 sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 428D7C01
apt-get install linux-image-$(uname -r)-dbgsym Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package linux-image-5.15.0-69-generic-dbgsym E: Couldn't find any package by glob 'linux-image-5.15.0-69-generic-dbgsym' E: Couldn't find any package by regex 'linux-image-5.15.0-69-generic-dbgsym'
crash 7.2.8 Copyright (C) 2002-2020 Red Hat, Inc. Copyright (C) 2004, 2005, 2006, 2010 IBM Corporation Copyright (C) 1999-2006 Hewlett-Packard Co Copyright (C) 2005, 2006, 2011, 2012 Fujitsu Limited Copyright (C) 2006, 2007 VA Linux Systems Japan K.K. Copyright (C) 2005, 2011 NEC Corporation Copyright (C) 1999, 2002, 2007 Silicon Graphics, Inc. Copyright (C) 1999, 2000, 2001, 2002 Mission Critical Linux, Inc. This program 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. Enter "help copying" to see the conditions. This program has absolutely no warranty. Enter "help warranty"for details.
GNU gdb (GDB) 7.6 Copyright (C) 2013 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-unknown-linux-gnu"... gdb called without error_hook: Dwarf Error: wrong version in compilation unit header (is 5, should be 2, 3, or 4) [in module /usr/lib/debug/boot/vmlinux-5.15.0-69-generic] Dwarf Error: wrong version in compilation unit header (is 5, should be 2, 3, or 4) [in module /usr/lib/debug/boot/vmlinux-5.15.0-69-generic]
crash: /usr/lib/debug/boot/vmlinux-5.15.0-69-generic: no debugging data available
cat /proc/version Linux version 5.4.0 (root@driver-virtual-machine) (gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1)) #1 SMP Fri May 19 09:19:53 CST 2023
crash 7.2.8 Copyright (C) 2002-2020 Red Hat, Inc. Copyright (C) 2004, 2005, 2006, 2010 IBM Corporation Copyright (C) 1999-2006 Hewlett-Packard Co Copyright (C) 2005, 2006, 2011, 2012 Fujitsu Limited Copyright (C) 2006, 2007 VA Linux Systems Japan K.K. Copyright (C) 2005, 2011 NEC Corporation Copyright (C) 1999, 2002, 2007 Silicon Graphics, Inc. Copyright (C) 1999, 2000, 2001, 2002 Mission Critical Linux, Inc. This program 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. Enter "help copying" to see the conditions. This program has absolutely no warranty. Enter "help warranty"for details.
GNU gdb (GDB) 7.6 Copyright (C) 2013 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-unknown-linux-gnu"...
crash 7.2.8 Copyright (C) 2002-2020 Red Hat, Inc. Copyright (C) 2004, 2005, 2006, 2010 IBM Corporation Copyright(C) 1999-2006 Hewlett-Packard Co Copyright(C) 2005, 2006, 2011, 2012 Fujitsu Limited Copyright(C) 2006, 2007 VA Linux Systems Japan K.K. Copyright(C) 2005, 2011 NEC Corporation Copyright(C) 1999, 2002, 2007 Silicon Graphics, Inc. Copyright(C) 1999, 2000, 2001, 2002 Mission Critical Linux, Inc. This program 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. Enter "help copying" to see the conditions. This program has absolutely no warranty. Enter "help warranty" for details.
GNU gdb(GDB) 7.6 Copyright(C) 2013 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-unknown-linux-gnu"...
crash> sys KERNEL: /root/kernel/linux-5.4/vmlinux DUMPFILE: dump.202305212232 [PARTIAL DUMP] CPUS: 2 DATE: Sun May 21 22:31:43 2023 UPTIME: 00:58:41 LOAD AVERAGE: 0.46, 0.33, 0.14 TASKS: 624 NODENAME: driver-virtual-machine RELEASE: 5.4.0 VERSION: #1 SMP Fri May 19 09:19:53 CST 2023 MACHINE: x86_64 (2096 Mhz) MEMORY: 13 GB PANIC: "Oops: 0002 [#1] SMP NOPTI" (check logfor details) crash> kmem -i PAGES TOTAL PERCENTAGE TOTAL MEM 3261021 12.4 GB ---- FREE 1550354 5.9 GB 47% of TOTAL MEM USED 1710667 6.5 GB 52% of TOTAL MEM SHARED 292849 1.1 GB 8% of TOTAL MEM BUFFERS 53004 207 MB 1% of TOTAL MEM CACHED 1061265 4 GB 32% of TOTAL MEM SLAB 116270 454.2 MB 3% of TOTAL MEM
TOTAL HUGE 0 0 ---- HUGE FREE 0 0 0% of TOTAL HUGE
TOTAL SWAP 236354 923.3 MB ---- SWAP USED 0 0 0% of TOTAL SWAP SWAP FREE 236354 923.3 MB 100% of TOTAL SWAP
COMMIT LIMIT 1866864 7.1 GB ---- COMMITTED 1340565 5.1 GB 71% of TOTAL LIMIT # l不知道为什么没有显示源代码 crash> l *0xffffffffc0832cf5 crash> l *0x00007f191ee1e73d
crash> help
* extend log rd task alias files mach repeat timer ascii foreach mod runq tree bpf fuser mount search union bt gdb net set vm btop help p sig vtop dev ipcs ps struct waitq dis irq pte swap whatis eval kmem ptob sym wr exit list ptov sys q
crash version: 7.2.8 gdb version: 7.6 For help on any command above, enter "help <command>". For help on input options, enter "help input". For help on output options, enter "help output".
crash> help dis
NAME dis - disassemble
SYNOPSIS dis [-rfludxs][-b [num]] [address | symbol | (expression)] [count]
DESCRIPTION This command disassembles source code instructions starting (or ending) at a text address that may be expressed by value, symbol or expression:
-r (reverse) displays all instructions from the start of the routine up to and including the designated address. -f (forward) displays all instructions from the given address to the end of the routine. -l displays source code line number data in addition to the disassembly output. -u address is a user virtual address in the current context; otherwise the address is assumed to be a kernel virtual address. If this option is used, then -r and -l are ignored. -x override default output format with hexadecimal format. -d override default output format with decimal format. -s displays the filename and line number of the source code that is associated with the specified text location, followed by a source code listing if it is available on the host machine. The line associated with the text location will be marked with an asterisk; depending upon gdb's internal "listsize" variable, several lines will precede the marked location. If a "count" argument is entered, it specifies the number of source code lines to be displayed after the marked location; otherwise the remaining source code of the containing function will be displayed. -b [num] modify the pre-calculated number of encoded bytes to skip after a kernel BUG ("ud2a") instruction; with no argument, displays the current number of bytes being skipped. (x86 and x86_64 only) address starting hexadecimal text address. symbol symbol of starting text address. On ppc64, the symbol preceded by '.' is used. (expression) expression evaluating to a starting text address. count the number of instructions to be disassembled (default is 1). If no count argument is entered, and the starting address is entered as a text symbol, then the whole routine will be disassembled. The count argument is supported when used with the -r and -f options.