The use of kgdb

Environment:

machine 0(target):

sam@sam-VirtualBox:~$ uname -a
Linux sam-VirtualBox 4.8.17 #2 SMP Wed Jun 21 07:51:10 CST 2017 x86_64 x86_64 x86_64 GNU/Linux
sam@sam-VirtualBox:~$ cat /etc/os-release
NAME=”Ubuntu”
VERSION=”16.04.2 LTS (Xenial Xerus)”
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME=”Ubuntu 16.04.2 LTS”
VERSION_ID=”16.04″
HOME_URL=”http://www.ubuntu.com/”
SUPPORT_URL=”http://help.ubuntu.com/”
BUG_REPORT_URL=”http://bugs.launchpad.net/ubuntu/”
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial

sam@sam-VirtualBox:~$ uname -a
Linux sam-VirtualBox 4.8.17 #2 SMP Wed Jun 21 07:51:10 CST 2017 x86_64 x86_64 x86_64 GNU/Linux

You should add a serial port by vmware or virtualbox,like this: 

 

0

And now, you should modify the kernel command line(kgdboc,kgdbwait,kgdbcon), like this:

sam@sam-VirtualBox:~$ cat /proc/cmdline
BOOT_IMAGE=/boot/vmlinuz-4.8.17 root=UUID=d7708b30-87c5-48cf-a665-676abb621887 ro ima_tcb kgdboc=ttyS0,115200 kgdbwait kgdbcon quiet splash

 

machine1(host: running gdb)

sam@sam-VirtualBox:~$ uname -a
Linux sam-VirtualBox 4.8.17 #2 SMP Wed Jun 21 07:51:10 CST 2017 x86_64 x86_64 x86_64 GNU/Linux
sam@sam-VirtualBox:~$ cat /etc/os-release
NAME=”Ubuntu”
VERSION=”16.04.2 LTS (Xenial Xerus)”
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME=”Ubuntu 16.04.2 LTS”
VERSION_ID=”16.04″
HOME_URL=”http://www.ubuntu.com/”
SUPPORT_URL=”http://help.ubuntu.com/”
BUG_REPORT_URL=”http://bugs.launchpad.net/ubuntu/”
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial

sam@sam-VirtualBox:~$ uname -a
Linux sam-VirtualBox 4.8.17 #2 SMP Wed Jun 21 07:51:10 CST 2017 x86_64 x86_64 x86_64 GNU/Linux

Also, you should enable the serial port for host machine.

1

Now, you should start the target machine, it will like below. It means that it is waiting for the remote debug.

3

So in you host machine,  you should run the gdb remote command to start the target machine.

4

Next should run “continue” , and the host machine will start.

5

 

6

Here we go.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s