function q1
alias sq1="ssh -p 8000 127.0.0.1"
用如上命令q1啟動虛擬機器,注意加了-s選項。
# vncviewer :1
進入vnc介面後按ctrl + alt + 2,進入了所謂的qemu monitor console,
輸入
# gdbserver tcp::1234
在物理機上輸入:
$ gdb vmlinux
gnu gdb (gdb) 8.0.50.20171229-git
license gplv3+: gnu gpl version 3 or later 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-pc-linux-gnu".
type "show configuration" for configuration details.
for bug reporting instructions, please see:
.find the gdb manual and other documentation resources online at:
.for help, type "help".
type "apropos word" to search for commands related to "word"...
reading symbols from vmlinux...done.
(gdb) target remote :1234
remote debugging using :1234
0xffffffff8175db46 in cpu_idle_poll () at kernel/sched/idle.c:71
71 trace_cpu_idle_rcuidle(pwr_event_exit, smp_processor_id());
(gdb) lx-symbols
loading vmlinux
scanning for modules in /home1/chrism/linux
loading @0xffffffffa057e000: /home1/chrism/linux/fs/nfs/nfsv3.ko
loading @0xffffffffa03de000: /home1/chrism/linux/fs/nfs_common/nfs_acl.ko
loading @0xffffffffa041f000: /home1/chrism/linux/net/sunrpc/auth_gss/rpcsec_gss_krb5.ko
loading @0xffffffffa03f7000: /home1/chrism/linux/net/sunrpc/auth_gss/auth_rpcgss.ko
loading @0xffffffffa0716000: /home1/chrism/linux/fs/nfs/nfsv4.ko
loading @0xffffffffa026a000: /home1/chrism/linux/net/dns_resolver/dns_resolver.ko
loading @0xffffffffa06d9000: /home1/chrism/linux/fs/nfs/nfs.ko
loading @0xffffffffa0567000: /home1/chrism/linux/fs/lockd/lockd.ko
loading @0xffffffffa025a000: /home1/chrism/linux/fs/nfs_common/grace.ko
loading @0xffffffffa046f000: /home1/chrism/linux/fs/fscache/fscache.ko
loading @0xffffffffa0642000: /home1/chrism/linux/net/wireless/cfg80211.ko
loading @0xffffffffa01c2000: /home1/chrism/linux/net/rfkill/rfkill.ko
loading @0xffffffffa058d000: /home1/chrism/linux/net/sunrpc/sunrpc.ko
loading @0xffffffffa0497000: /home1/chrism/linux/fs/ext4/ext4.ko
loading @0xffffffffa0255000: /home1/chrism/linux/fs/mbcache.ko
loading @0xffffffffa0455000: /home1/chrism/linux/fs/jbd2/jbd2.ko
loading @0xffffffffa0484000: /home1/chrism/linux/sound/pci/hda/snd-hda-codec-generic.ko
loading @0xffffffffa01ab000: /home1/chrism/linux/arch/x86/crypto/crct10dif-pclmul.ko
loading @0xffffffffa041a000: /home1/chrism/linux/arch/x86/crypto/crc32-pclmul.ko
loading @0xffffffffa025f000: /home1/chrism/linux/sound/pci/hda/snd-hda-intel.ko
loading @0xffffffffa01db000: /home1/chrism/linux/arch/x86/crypto/ghash-clmulni-intel.ko
...
下面就可以設定斷點除錯了:
(gdb) b mlx5e_xmit
breakpoint 2 at 0xffffffffa0215f50: file drivers/net/ethernet/mellanox/mlx5/core/en_tx.c, line 371.
(gdb) c
continuing.
thread 7 hit breakpoint 2, mlx5e_xmit (skb=0xffff8801277e0200, dev=0xffff8801225c0000) at drivers/net/ethernet/mellanox/mlx5/core/en_tx.c:371
371 ,
如果要用kvm,而不是qemu的話,加上如下內容:
# virsh edit vm1
需要說明的是,虛擬機器需要重新編譯核心,加上如下選項:
config_gdb_scripts=y
物理機需要和虛擬機器有同樣的vmlinux 如何在linux核心中讀寫檔案
在vfs的支援下,使用者態程序讀寫任何型別的檔案系統都可以使用read和write著兩個系統呼叫,但是在linux核心中沒有這樣的系統呼叫我們如何操作檔案呢?我們知道read和write在進入核心態之後,實際執行的是sys read 和sys write,但是檢視核心源 發現這些操作檔案的函式都沒有...
linux核心中如何修改skb報文
核心 中有許多用於計算校驗和的api,下面是linux網路技術內幕相關api的截圖 sk buf中的csum欄位 sk buf中的ip summed欄位 ip summed欄位表示l4層的校驗和狀態。根據報文的不同 輸入報文和輸出報文 ip summed會有不同的取值。當資料報為輸入報文 defin...
如何在核心中喚醒和睡眠使用者程序??(zt
你可以參考interruptible sleep on和wake up interruptible的 實現對指定程序的睡眠與喚醒,其中,使用interruptible sleep on將當前程序置入睡眠態和一睡眠程序管理佇列中,該佇列中的程序可被中斷喚醒,wake up interruptible則...