You are on page 1of 2

KGDB

You require two servers for KGDB.

1. Debugger (which is going to debug)


2. Target (which is going to be debugged)

At Target side (RHEL 7.0 GA 64 bits):

1. Verify these flags are enabled or not for kgdb by going in /boot/config-$(uname –r)
CONFIG_KGDB=y
CONFIG_KGDB_SERIAL_CONSOLE=y
CONFIG_DEBUG_INFO = y
CONFIG_FRAME_POINTER=y
2. Now download a new kernel for making the CuW drivers part of the kernel.
a. $ wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.10.1.tar.xz
b. $ tar -xvJf linux-3.10.1.tar.xz
c. $ cd linux-3.10.1
d. Now copy the folder of bnxt_en-0.1.12.tar.gz from
Z:\projects\ccx\EC\DEV\vmware\Cumulus_Latest_Drivers_Firmwares\Linux to the home
directory
e. $ tar -xzvf bnxt_en-0.1.12.tar.gz /linux-3.10.1/drivers/net/ethernet/broadcom/
f. cd /linux-3.10.1/drivers/net/ethernet/broadcom/
g. Now modify the Makefile to compile the bnxt_en drivers along with the kernel
h. $ vim Makefile  add obj-y += bnxt_en-0.1.12/
i. $ vim bnxt_en-0.1.12/Makefile  modify obj-m += bnxt_en.o to obj-y += bnxt_en.o
j. $ cp /boot/config-$(uname –r) ./.config
k. $ make menuconfig
l. $ make –j 20
m. $ make modules
n. $ make modules_install
o. $ make install
p. Now $ vim System.map and search for bnx to determine whether the bnxt_en are included in
kernel symbol mapping or not.
q. Copy vmlinux file and System.map file to the target system

3. Now add this lines to enable kgdb at specified serial port with specified Baudrate and to
enable kgdb wait at the boot time to the configuration file of the grub
a. vim /etc/default/grub
b. Add “kgdbwait kgdboc=ttyS1,57600” to the end of GRUB_CMDLINE_LINUX. This file
should be look like this:

GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="nomodeset rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap vconsole.keymap=us crashkernel=auto
vconsole.font=latarcyrheb-sun16 rhgb quiet kgdbwait kgdboc=ttyS1,57600"
GRUB_DISABLE_RECOVERY="true"
c. Now you need to update the grub using : grub2-mkconfig -o /boot/grub2/grub.cfg
4. Now reboot the system and boot from the new compile will put the kernel in kgdwait
mode and will wait until the HOST through the serial initiate the communication and
continue it from the waiting state

At Debugger side (CENTOS- 6.5 64 bits ): (Z:\projects\OSInstall_Scratch\OS_images\centOS)

1. Vmlinux and System.map file should be copied from target system to the working
directory
2. Go to the working directory
3. gdb vmlinux : This will open a gdb prompt on the terminal

[root@localhost linux-3.13.10]# gdb vmlinux


GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-51.el7

Copyright (C) 2013 Free Software Foundation, Inc.

License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

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-redhat-linux-gnu".

For bug reporting instructions, please see:

<http://www.gnu.org/software/gdb/bugs/>...

Reading symbols from /root/Desktop/Kshitij/Debug/linux-3.13.10/vmlinux...done.

(gdb)

4. Write these commands for setting up and debugging up the target system

(gdb) set remotebaud 57600

(gdb) target remote /dev/ttyS0

Remote debugging using /dev/ttyS0

breakpoint () at kernel/kgdb.c:1212

1212 atomic_set(&kgdb_setting_breakpoint, 0);

warning: shared library handler failed to enable breakpoint

(gdb) C

Continuing.

You might also like