crash sym command

来源:互联网 发布:梦里花落知多少txt下载 编辑:程序博客网 时间:2024/06/01 10:11

sym: 用途:translate a symbol to its virtual address, or vice-versa

虚拟地址和符号间的转化。


crash> help sym

NAME
  sym - translate a symbol to its virtual address, or vice-versa

SYNOPSIS
  sym [-l] | [-M] | [-m module] | [-p|-n] | [-q string] | [symbol | vaddr]

DESCRIPTION
  This command translates a symbol to its virtual address, or a static
  kernel virtual address to its symbol -- or to a symbol-plus-offset value,
  if appropriate.  Additionally, the symbol type is shown in parentheses,
  and if the symbol is a known text value, the file and line number are shown.
/*显示所有的符号和对应的虚拟地址*/
              -l  dumps all symbols and their values.
/*这里的-M and m说的应该是动态加载的module,而不是编译进内核的module*/
              -M  dumps the current set of module symbols.
       -m module  dumps the current set of symbols for a specified module.
/*-p的意思是前一个符号,-n的意思是下一个符号*/
              -p  display the target symbol and the previous symbol.
              -n  display the target symbol and the next symbol.
/*-q:在所有sym中,搜索包含string 的symbol*/
       -q string  searches for all symbols containing "string".
/*最常见的符号和虚拟地址间的转换*/
          symbol  a kernel text or data symbol.
           vaddr  a kernel virtual address
.
 
  If the "symbol", "vaddr" or "string" argument resolves to a module
  symbol, then the module name will be displayed in brackets following the
  symbol value.

EXAMPLES
  Translate data symbol jiffies to its value, and vice-versa:

    crash> sym jiffies
    c0213ae0 (D) jiffies

    crash> sym c0213ae0
    c0213ae0 (D) jiffies
/*如果是函数名会显示出在文件中的位置*/
  Translate a text address to its symbolic value and source file:
crash> sym android_work
c0342874 (t) android_work /home/wenshuai/code/kernel3.4/linux_kernel/drivers/usb/gadget/android.c: 174


  Dump the whole symbol table:

    crash> sym -l
    c0004000 (A) swapper_pg_dir
    c0008000 (t) .head.text
    c0008000 (T) _text
    c0008000 (T) stext
    c0008050 (t) __create_page_tables
    c0008104 (t) __turn_mmu_on_loc
    c0008110 (t) __vet_atags
    c0008180 (t) .text
    c0008180 (T) __exception_text_start
    c0008180 (T) _stext
    c0008180 (T) asm_do_IRQ
    c0008194 (T) do_undefinstr
    c00082d8 (T) do_IPI

    ...

  Find all symbols containing the string "pipe":
  最常见的用途是,知道其中的一部分,去查找符号

crash> sym -p pipe
    symbol not found: pipe
    possible alternatives:
      c00b2b40 (t) umh_pipe_setup
      c00b4bf8 (T) generic_pipe_buf_confirm
      c00b4c0c (t) bad_pipe_r
      c00b4c20 (t) bad_pipe_w
      c00b4c34 (t) pipe_poll
      c00b4ce4 (T) get_pipe_info
      c00b4d10 (t) pipefs_mount
      c00b4d4c (t) pipefs_dname
      c00b4e20 (t) pipe_lock_nested
      c00b4e44 (T) pipe_double_lock


  Dump the symbols of the uart401 module, both before, and then after,
  the complete set of symbols are loaded with the "mod -s" command:

    crash> sym -m uart401
    c8032000 MODULE START: uart401
    c8032138 (?) uart401intr  
    c803235c (?) attach_uart401  
    c8032638 (?) probe_uart401  
    c80326d4 (?) unload_uart401  
    c8033770 MODULE END: uart401
    crash> mod -s uart401
     MODULE   NAME         SIZE  OBJECT FILE
    c8032000  uart401      6000  /lib/modules/2.2.14/misc/uart401.o
    crash> sym -m uart401
    c8032000 MODULE START: uart401
    c8032050 (t) my_notifier_call  
    c8032084 (t) uart401_status  
    c8032098 (t) uart401_cmd  
    c80320a8 (t) uart401_read  
    c80320bc (t) uart401_write  
    c80320cc (t) uart401_input_loop  
    c8032138 (T) uart401intr  
    c8032168 (t) uart401_open  
    c80321c8 (t) uart401_close  
    c80321f4 (t) uart401_out  
    c80322ac (t) uart401_start_read  
    c80322b4 (t) uart401_end_read  
    c80322bc (t) uart401_kick  
    c80322c4 (t) uart401_buffer_status  
    c80322cc (t) enter_uart_mode  
    c803235c (T) attach_uart401  
    c803259c (t) reset_uart401  
    c8032638 (T) probe_uart401  
    c80326d4 (T) unload_uart401  
    c8032760 (T) init_module
    c80327cc (T) cleanup_module  
    c8032b00 (d) sound_notifier  
    c8032b0c (d) detected_devc  
    c8032b20 (d) std_synth_info  
    c8032bc0 (d) std_midi_synth  
    c8033600 (d) uart401_operations  
    c80336c4 (D) io  
    c80336c8 (D) irq  
    c80336e0 (b) hw_info.508  
    c8033770 MODULE END: uart401
crash> mod -s
no modules installed

  Display the value of jiffies, along with the next and previous symbols:

    crash> sym -np jiffies
    c023027c (D) prof_shift
    c0230280 (D) jiffies
    c02302a0 (D) task

  Translate a symbol value to its name and module:

    crash> sym f88878d1
    f88878d1 (t) ext3_readdir [ext3]
    crash>



mod 命令用来加载调试符号,有时一些结构或者函数的符号信息不在调试版本内核里面,需要用gcc的 -g选项编译自己的模块,然后用mod命令加载里面的调试信息。这样 sym 和whatis 命令就能正确解释我们自己模块里面自定义的结构等信息。



crash> mod
     MODULE       NAME                   SIZE  OBJECT FILE
ffffffff88009e80  ehci_hcd              65741  (not loaded)  [CONFIG_KALLSYMS]
ffffffff88019280  ohci_hcd              54493  (not loaded)  [CONFIG_KALLSYMS]
ffffffff88028e00  uhci_hcd              57433  (not loaded)  [CONFIG_KALLSYMS]
ffffffff88041c00  jbd                   93873  (not loaded)  [CONFIG_KALLSYMS]
ffffffff8806bb00  ext3                 167249  (not loaded)  [CONFIG_KALLSYMS]
ffffffff880a8c00  scsi_mod             188665  (not loaded)  [CONFIG_KALLSYMS]
ffffffff880b8980  sd_mod                56257  (not loaded)  [CONFIG_KALLSYMS]
ffffffff881bab80  pcspkr                36289  (not loaded)  [CONFIG_KALLSYMS]
ffffffff881ca780  edac_mc               60193  (not loaded)  [CONFIG_KALLSYMS]
ffffffff881dd200  shpchp                70765  (not loaded)  [CONFIG_KALLSYMS]
ffffffff881eac00  serio_raw             40517  (not loaded)  [CONFIG_KALLSYMS]
ffffffff881f6280  i5000_edac            42177  (not loaded)  [CONFIG_KALLSYMS]
ffffffff88208f00  sg                    69993  (not loaded)  [CONFIG_KALLSYMS]
ffffffff8821b600  cdrom                 68713  (not loaded)  [CONFIG_KALLSYMS]
ffffffff88229400  sr_mod                50789  (not loaded)  [CONFIG_KALLSYMS]
ffffffff8823cb00  parport               73165  (not loaded)  [CONFIG_KALLSYMS]
ffffffff88249080  lp                    47121  (not loaded)  [CONFIG_KALLSYMS]
ffffffff8825a000  parport_pc            62313  (not loaded)  [CONFIG_KALLSYMS]
ffffffff88265500  ac                    38729  (not loaded)  [CONFIG_KALLSYMS]
ffffffff88270a80  acpi_memhotplug       40133  (not loaded)  [CONFIG_KALLSYMS]
ffffffff8827e480  asus_acpi             50917  (not loaded)  [CONFIG_KALLSYMS]
ffffffff8828a900  battery               43849  (not loaded)  [CONFIG_KALLSYMS]
ffffffff88295c00  button                40545  (not loaded)  [CONFIG_KALLSYMS]
ffffffff882a4900  i2c_core              56129  (not loaded)  [CONFIG_KALLSYMS]
ffffffff882af480  i2c_ec                38593  (not loaded)  [CONFIG_KALLSYMS]
ffffffff882ba980  backlight             39873  (not loaded)  [CONFIG_KALLSYMS]
ffffffff882c8080  sbs                   49921  (not loaded)  [CONFIG_KALLSYMS]
ffffffff882d6d80  video                 53197  (not loaded)  [CONFIG_KALLSYMS]
ffffffff882efa80  dm_mod                99737  (not loaded)  [CONFIG_KALLSYMS]
ffffffff882fec80  dm_multipath          52945  (not loaded)  [CONFIG_KALLSYMS]
ffffffff8830ea80  dm_mirror             60617  (not loaded)  [CONFIG_KALLSYMS]
ffffffff8831dd80  autofs4               57289  (not loaded)  [CONFIG_KALLSYMS]
ffffffff88329280  crypto_api            42177  (not loaded)  [CONFIG_KALLSYMS]
ffffffff88335900  xfrm_nalgo            43845  (not loaded)  [CONFIG_KALLSYMS]
ffffffff88340000  hangcheck_timer       37465  (not loaded)  [CONFIG_KALLSYMS]
crash>
crash>
crash> mod -d test_module
crash> mod -s test_module  test_module.ko
     MODULE       NAME                   SIZE  OBJECT FILE
ffffffff88198180  test_module         165128  test_module.ko

原创粉丝点击