virtualbox(linux host) 调试linux guest 内核

来源:互联网 发布:amd优化的游戏有哪些 编辑:程序博客网 时间:2024/05/29 11:09

windows host的vbox 串口可以选择namepipe,linux host同样可以选择这个配置。

 

在串口配置中选择host pipe,名称选择/tmp/vbox (这是local socket),选择为server(自动创建pipe文件)。

guest启动之后/tmp/vbox就建立起来了。

使用socat可以检查是否成功连接。

socat -d -d /home/fotisl/virtualbox/myvm/serial1 pty   (这里一定要是-d -d)

2009/01/01 00:00:00 socat[12345] N opening connection to AF=1 "/home/fotisl/virtualbox/myvm/serial1"
2009/01/01 00:00:00 socat[12345] N successfully connected from local address AF=1 "/x04/b/xAB"
2009/01/01 00:00:00 socat[12345] N successfully connected via /xD0/xA7/x10
2009/01/01 00:00:00 socat[12345] N PTY is /dev/pts/4
2009/01/01 00:00:00 socat[12345] N starting data transfer loop with FDs [3,3] and [4,4]

红字部分就是连接的目标

新开一个窗口打开gdb

gdb ~/vmlinux
GNU gdb (GDB) 6.8.50.20090628-cvs-debian
Copyright (C) 2009 Free Software Foundation, Inc.
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 "i486-linux-gnu". For bug reporting instructions, please see: ...
(gdb) set remotebaud 115200
(gdb) target remote /dev/pts/4
Remote debugging using /dev/pts/4

 

guest linux一定要编译了KGDB

同时设置

# echo ttyS0,115200 > /sys/module/kgdboc/parameters/kgdboc

用# echo g > /proc/sysrq-trigger  出发调试

如果是需要启动时调试,则增加boot参数。

kgdboc=ttyS0,115200 kgdbwait

原创粉丝点击