在配置KGDB时,必须通过串口才能调试一台测试Linux, 如果通过本机是Linux的话, 就可以使用应用直接链接上VMware的linux,进行通讯.
1 2 3 4 5 6 7 8 9 |
|
在配置KGDB时,必须通过串口才能调试一台测试Linux, 如果通过本机是Linux的话, 就可以使用应用直接链接上VMware的linux,进行通讯.
1 2 3 4 5 6 7 8 9 |
|
Host机:一个装有Ubuntu12.04-x86-64的主机
Target机:运行在vmware上的 Ubuntu12.04-server-x86-64 的Linux.
内核编译选项CONFIG_DEBUG_RODATA,会对kernel text做write protect。 那么kgdb就不能设置断点了。
编辑kernel source目录下生成的.config文件, 禁用CONFIG_DEBUG_RODATA=n (read only data)重新编译即可
http://www.mail-archive.com/kgdb-bugreport@lists.sourceforge.net/msg03464.html
Hi Folks,
I’m wondering if anyone has had issues with setting breakpoints. I’m
able to break into the kernel, access data, do a backtrace, etc, but
when I attempt to set a breakpoint, then continue, I get the following error:Cannot insert breakpoint 1.
Error accessing memory address 0xffffffff81310931: Unknown error 4294967295.I’m attaching a sample session, I had set remote debug to 1
Thanks!
Pat Thomson
Hi Thomson,
It seems that your problem is the CONFIG_DEBUG_RODATA option was
enabled, It is recommend to turn CONFIG_DEBUG_RODATA off when using kgdb.
From the kgdb document(DocBook/kgdb.tmpl):
If the architecture that you are using supports the kernel option
CONFIG_DEBUG_RODATA, you should consider turning it off. This
option will prevent the use of software breakpoints because it
marks certain regions of the kernel's memory space as read-only.
If kgdb supports it for the architecture you are using, you can
use hardware breakpoints if you desire to run with the
CONFIG_DEBUG_RODATA option turned on, else you need to turn off
this option.
Thanks, Dongdong
You can set up the virtual serial ports in two virtual machines to connect to each other. This is useful, for example, if you want to use an application in one virtual machine to capture debugging information sent from the other virtual machine’s serial port.
To install a direct serial connection between two virtual machines (a server and a client), take the following steps:
在系统内核开发中,经常会用到串口调试,利用VMware的Virtual Machine更是为调试系统内核如虎添翼。那么怎么搭建串口调试环境呢?
Virtual Machine 主要有三种串口调试技术,可以在serial port的配置界面找到:
因为前两种相对简单易用就不具体介绍了,这里主要说第三种用命名管道调试方法。命名管道,在Linux中是进程间通信(IPC)的一种方式,两个进 程可以通过读写管道来交换数据。这里就是运用了这种技术,通过把串口绑定一个有名管道,对有名管道的读写交换串口数据。也有两种方式:1. 宿主机与虚拟机之间, 2. 在同一宿主机上,两虚拟机间通过绑定同一个宿主机上的有名管道。问题的关键在于如何把虚拟机串口绑定到宿主机的某一有名管道,而第一种方式则需要找到一种 方式使得主机如何读写有名管道来交互,经过一阵Google终于找到分别在Linux和Windows分别试验成功的工具。
在Windows中有名管道式通过路径//./pipe/namedpipe来创建的,当然你可以指定到其他机子如//192.168.1.10 /pipe/namedpipe,而在Linux中,/tmp/mypipe就可以了。创建好有名管道后,就是如何和管道交互了。目前,无论是 Windows还是Linux,似乎都没有一款工具可以直接读写有名管道的,而我找到的两个工具都是通过把有名管道和Socket绑定,通过读写 Socket来间接读写管道。
1 2 3 4 5 6 7 8 9 10 11 |
|
Trouble Shoot: 有时候会遇到错误Connection closed by foreign host,或者telnet一开,socat就能退出,很可能是你没power on虚拟机,有名管道还没创建,你就socat,这样也会创建一个名为isocket的文件但只是普通文件。具体的细节请看socat help
start Virtual Machine first, than run the socat, and telnet
(Note you must have permission to all resource, /tmp/socket, VM and so on)
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
如果你使用的是vmwaregateway.exe这个小工具,这里的管道名就必须是vmwaredebug,除非你把它的源代码download下来自己改改。
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|