Notes
main
main
  • Introduction
  • linuxKernel
    • tips
    • make_help
    • old linux
      • compile_linux0.11
      • TestEnvironment
      • load_setup
      • get_hard_data
    • list
    • plist
    • fifo
    • idr
    • xarray
    • rbtree
    • maple_tree
    • syscall
    • bitmap
    • page
    • page_flags
    • page_size
    • page mapcount
    • page refcount
    • folio
    • slub
      • proc_slabinfo
      • slub_theory
      • kmalloc_kfree
      • kmem_cache
      • slab_alloc
      • slab_free
      • proc_meminfo_SReclaimable_SReclaimable
    • vmalloc
    • brk
    • mmap
    • mremap
    • mprotect
    • madvise
    • read
    • write
    • shmem
    • huge_page
    • page_fault
    • rmap
    • lru
    • multi-gen-LRU
    • page_reclaim
    • page_cache
    • page_table
    • rcu
    • kvm
    • aarch64_boot
    • tracing_system
    • cache_coherence_and_memory_consistency
    • cpu_speculates
    • mmap_lock
    • per-vma_lock
    • cgroup
    • symbol
    • campact
    • page_ext
    • mempool
    • kernelstack
    • filesystem
    • io_stack
    • workingset
    • ioremap
    • sched_period
  • linuxDebug
    • openocd_openjtag
    • i2c_tools
    • objdump
    • addr2line
    • gdb_useage
    • debug_linux_kernel_via_gdb
    • debug_linux_module_via_gdb
    • early_boot
    • sequentially_execute
    • dynamic_debug
    • research_linuxKernel_by_patch
    • tracefs
    • ebpf
    • bpftrace
    • perf
    • flame_graph
    • crash
    • ASAN_HWASAN_MTE_check_mem_bug
    • page_owner
    • vmtouch
    • fio
    • benchmark
  • linuxSystem
    • common
      • system_version
      • procfs
      • proc_sys_vm
      • cmd_ps
      • makefile
      • file_descriptor
      • psi
      • ulimit
      • top
      • delay_accounting
    • ubuntu
      • custom_kernel
      • get_cmd_src
      • record_ssh_info
      • log
      • run_custom_script
      • repo
      • cockpit
      • nfs
      • tftp
      • misc
    • fedora
      • system_upgrade
      • custom_kernel
      • lvextend
      • yt-dlp
      • jellyfin
  • linuxDriver
    • i2c_peripherals_driver
    • spi_peripherals_driver
    • gpio_subsystem
    • IRQ_driver
    • blockIO_unblockIO_async
    • linux_own_driver
    • misc_device
    • input_device
    • timer
    • atomic_spinlock_semaphore_mutex
    • lcd
    • touch_screen
    • debugfs
    • v4l2
    • mmap
  • hardware
    • paging_mmu_pt
    • iommu
  • process_thread_scheduler
    • scheduler01
    • scheduler02
    • scheduler03
    • scheduler04
    • scheduler05
    • scheduler06
  • memory_management
    • mm1
    • mm2
    • mm3
    • mm4
    • mm5
  • input_output_filesystem
    • io_fs_01
    • io_fs_02
    • io_fs_03
    • io_fs_04
  • lock_and_lockup_detector
    • general_lock
    • hung_task
    • softLockup_hardLockup
    • crash_experiment
  • MIT_6.S081
    • 6.S081_Operating_System_Engineering
    • Schedule.md
    • Class
      • Overview
      • Administrivia
    • Labs
      • Tools
      • Guidance
      • startup
      • syscall
      • page_table
      • Calling_Convention
      • traps
    • xv6
      • xv6
    • References.md
  • qemu
    • qemu_buildroot
    • qemu_busybox.md
    • Serial.md
    • demo_mini2440
      • 0_compilation_error_summary
      • 1_compilation_steps
      • 2_operation_mode
      • 3_transplant_tools_libraries
      • 4_tools_use
      • reference_website
  • tools
    • getKernelSourceCodeList
    • nat
    • shell
    • translating
    • YouCompleteMe
    • cscope
    • global
    • vscode
    • vim
    • binary
    • markdown
    • draw
    • git
    • tig
    • tmux
    • mail_client
    • download_patchset_from_LKML
    • minicom
    • clash
  • other
    • interview
    • interview_c_base
    • know_dontknow
    • Stop-Ask-Questions-The-Stupid-Ways
    • How-To-Ask-Questions-The-Smart-Way
    • docker
    • buildroot
    • rv32_to_rv64
Powered by GitBook
On this page
  • 简介
  • 如何安装 crash?
  • 如何生成 vmcore?
  • 如何使用 crash?
  • crash 调试命令
  • 技巧

Was this helpful?

  1. linuxDebug

crash

Previousflame_graphNextASAN_HWASAN_MTE_check_mem_bug

Last updated 5 months ago

Was this helpful?

简介

Analyze Linux crash dump data or a live system

如何安装 crash?

安装本机架构(如:x86)crash,直接通过 $ sudo apt install crash 安装即可。

安装非本机架构(如:arm64)crash,下载 , 执行 $ make target=ARM64 编译源码,即可生成 arm64 crash 可执行文件。

如何生成 vmcore?

  • 在 Linux Kernel Panic 时自动生成 vmcore,不需要任何操作

  • 在用户空间手动触发生成 vmcore

$ echo c > /proc/sysrq-trigger
  • 通过 QEMU 手动触发生成 vmcore

## 启动 QEMU 后,按 Ctrl A+C 进入 QEMU monitor
(qemu) dump-guest-memory -p vmcore

如何使用 crash?

$ crash vmlinux vmcore
  • vmlinux 是在编译 Linux Kernel 后生成。

  • vmcore 是通过 netdump, diskdump, LKCD kdump, xendump kvmdump or VMware 生成。

如果调试在线系统,直接执行 $ crash vmlinux 即可。

crash 调试命令

crash> bt                                ## 显示 kernel-stack backtrace.
crash> dis -l [address]                  ## 显示 address 对应的源码位置和汇编指令
crash> dis -lr [address]                 ## 显示从函数开头到 address 的源码位置和汇编指令
crash> struct struct_name [address] -x   ## 查看 address 对应的结构体内容
crash> struct struct_name[.member] -ox   ## 查看结构体成员 member 的偏移
crash> rd [address] [count]              ## 从 address 读取 count 个数据,单位 8Bytes

技巧

通过 log 查找 linux kernel panic 现场的第一行能够知道简单 panic 原因,再通过 ESR 知道更加详细的 panic 原因。

通过 log 查找 linux kernel panic pc 指针,使用 dis pc_address 显示 address 对应的汇编指令,其汇编指令对应的寄存器值都可以通过 log 的 linux kernel panic 现场得到,到这里就能够理解此指令 panic 的真正原因。再通过 dis -r pc_address 显示从函数开头到 address 的汇编指令,向上跟踪不正常寄存器值的源头。

通过 log 查找 sp 指针,使用 rd sp_address count 显示 stack 内容,从而推导 得到函数调用关系、每一个函数的参数/局部变量等。(需要熟悉 x86_64/arm64 的汇编指令、 函数进出栈原理)

crash 仓库源码