Questions tagged [kgdb]

KGDB is a source level debugger for the linux kernel. It is used along with gdb to debug linux kernels. It requires two machines that are connected via a serial connection.

Kernel developers can debug a kernel similar to application programs with use of KGDB. It makes it possible to place breakpoints in kernel code, step through the code and observe variables.

Two machines are required for using KGDB. One of these machines is a development machine and the other is a test machine. The machines are connected through a serial line, a null-modem cable which connects their serial ports. The kernel to be debugged runs on the test machine. gdb runs on the development machine. The serial line is used by gdb to communicate with the kernel being debugged.

KGDB is available for i386, x86_64, ppc and s390 architectures.

KGDB is a kernel patch. It has to be applied to a linux kernel to enable kernel debugging. KGDB adds the following components to a kernel.

  • gdb stub - The gdb stub is the heart of the debugger. It is the part that handles requests coming from gdb on the development machine. It has control of all processors in the target machine when the kernel running on it is inside the debugger.
  • modifications to fault handlers - Kernel gives control to debugger when an unexpected fault occurs. A kernel which does not contain gdb panics on unexpected faults. Modifications to fault handles allow kernel developers to analyze unexpected faults.
  • serial communication - This component uses a serial driver in the kernel and offers an interface to gdb stub in the kernel. It is responsible for sending and receiving data from a serial line. This component is also responsible for handling control break requests sent by gdb.

Project site

66 questions
14
votes
2 answers

Android: Kernel Debugging with KGDB

I'm trying to do kernel debugging for my Nexus One, and have been following instructions from http://bootloader.wikidot.com/android:kgdb. I was wondering if someone has actually got this to work? And has anyone done a more up to date solution for…
Hank
  • 3,367
  • 10
  • 48
  • 86
14
votes
2 answers

How to use kgdb on ARM??

Im using ARMv7 as a target machine. I have compiled the Linux source 2.6.34.13 for target. Target is connected with Host(Linux Development machine) through serial port using minicom. Target is loaded with new kernel and KGDB is enabled in command…
Jeyaram
  • 9,158
  • 7
  • 41
  • 63
10
votes
1 answer

solib-absolute-prefix vs. solib-search-path in GDB

I read the description of both but I don't yet understand the difference. Can anyone help me understand the differences? set solib-absolute-prefix - Specifies the local directory that contains copies of target libraries in the corresponding…
ransh
  • 1,589
  • 4
  • 30
  • 56
8
votes
1 answer

How to change executing thread in gdb?

I'm currently debugging kernel code using KGDB. Whenever I break in I naturally jump to the interrupt handler for kgdb. Under GDB I ran the following command. info threads and the output would be 7 Thread 7 (rcu_sched) 0x0000000000000000 in…
RandomGuy
  • 4,949
  • 4
  • 16
  • 15
8
votes
2 answers

problems to connect GDB over an serial port to an KGDB build Kernel

i want to debug an MIPS linux driver from my 64bit suse machine over serial ttyS0. The used gdb works greate over LAN with the debugging of applications but not with kgdb over serial. I used this page and a few more to start the debugging but…
user2021481
  • 81
  • 1
  • 1
  • 4
6
votes
1 answer

sysrq-g wont break kernel

I am trying to setup linux kernel module debugging, using two machines - target and host. On target machine, I have compiled and installed a 3.5.0 kernel with CONFIG_MAGIC_SYSRQ=y flag and other flags for over the serial console debugging. When I…
Naveen Rawat
  • 81
  • 2
  • 6
5
votes
0 answers

FreeBSD module debugging - cannot access memory at address

I am trying to hack/understand the nullfs kernel module (on FreeBSD) so to that end, I do the following: On the target machine: kldstat gives: Id Refs Address Size Name 1 10 0xffffffff80200000 17e10c8 kernel 2 1…
AjB
  • 890
  • 13
  • 34
5
votes
1 answer

KGDB remote debugging connection issue via USB and Serial connection

I am having issues with serial and usb connection between host and target. Below is my setup. Both host and target do NOT have any serial (DB9) ports. Host : Running windows + VMshare + Ubuntu Target: Running linux kernel 3.19 . Has a MINI usb port…
dee
  • 95
  • 1
  • 7
5
votes
2 answers

Debugging Linux kernel code on Android platforms

It seems this subject doesn't have a nice fully one place documentation. Here are references without any solution. Can anyone contribute his knowledge for how to debug and trace in linux kernel and Android platform. Some Links The State of Kernel…
0x90
  • 39,472
  • 36
  • 165
  • 245
4
votes
2 answers

Linux kernel remote debugging: Can not break back into debugger

I am debugging linux ubuntu kernel using kgdb / remote gdb. I have 2 computers - ubuntu target and windows host. Computers are connected using serial port and null-modem cable. KGDB support is enabled in target ubuntu system, command options fro…
3
votes
0 answers

Does Eclipse support kernel debugging (KGDB)?

Can I use Eclipse GUI for kernel debugging with KGDB?
ransh
  • 1,589
  • 4
  • 30
  • 56
3
votes
0 answers

Debugging a linux kernel module using serial port

I'm trying to setup simple kernel debugging, I have a 3.2.6 kernel on VM (ESXi), which I declared a serial port (I manage to connect to the serial ) Debugger: Debuggee: I followed this tutorial on how to setup gdb, and I seem to be getting…
huhu
  • 31
  • 2
2
votes
0 answers

Wrong line number in stack-trace in debugging Linux kernel using kgdb

I am trying to debug a driver for an Ethernet-MAC in the Linux kernel using kgdb over serial. I halt the execution by making a call to "kgdb_breakpoint()" at the desired location in the code and recompile the kernel. But after the code halts, as…
HungryFoolish
  • 542
  • 1
  • 9
  • 27
2
votes
1 answer

In kgdb, I cannot set the breakpoint

I'm using kgdb to debug the kernel. I'm using qemu 2.11.0, and ubuntu 16.04.3 server version for guest. I installed the kernel 4.16.0-rc6(mainline) and boot the guest os with this kernel with kgdb options(kgdbwait kgdboc=ttyS0,115200). The gdb can…
Joontaek Oh
  • 152
  • 9
2
votes
0 answers

How to configure kgdb with Grub2?

I need to setup a kernel debug session so that I can peek & poke some registers on a PCIe HW device. I am using Ubuntu 12.04, which uses Grub2. Based on my /boot/config-3.5.0-23-generic file, the kernel was already built with KGDB support, but…
Matt M
  • 259
  • 3
  • 6
1
2 3 4 5