Reputation: 55
I have a HP Pavilion 15 laptop with Ubuntu 22.04.3 LTS installed. I was using 6.2.0-39-generic kernel version. I compiled the 6.7.0-rc8-next-20240103 kernel version from source after creating a new branch from the tag next-20240103
. I followed the official kernel docs and found that the kernel config for debugging were already set using make localmodconfig
. I was able to boot into this linux-next kernel successfully.
Now to solve a bug in the 6.7.0-rc8-next-20240103 kernel, I thought of debugging the kernel using gdb
. Basically I need to find in which function a particular NULL pointer (which should not be a NULL pointer) was assigned and where, how and why I was getting the NULL pointer dereference in the first place. Note this bug occurs on waking up from suspension.
In one terminal tab, I ran:
$ gdbserver --attach :1234 1
I think ACPI driver is initialzed by init (pid 1).
In another tab, I ran:
$ cd src/linux-next
$ gdb vmlinux
Reading symbols from vmlinux...
(gdb) tar remote :1234
warning: Build ID mismatch between current exec-file /home/username/src/linux-next/vmlinux
and automatically determined exec-file /usr/lib/systemd/systemd
exec-file-mismatch handling is currently "ask"
Load new symbol table from "/usr/lib/systemd/systemd"? (y or n) n
(gdb) hbreak drivers/acpi/acpica/evregion.c:131
Hardware assisted breakpoint 1 at 0xffffffff8197e240: drivers/acpi/acpica/evregion.c:131. (2 locations)
(gdb) step
warning: Remote failure reply: E01
Ignoring packet error, continuing...
Ignoring packet error, continuing...
Ignoring packet error, continuing...
Ignoring packet error, continuing...
Ignoring packet error, continuing...
Ignoring packet error, continuing...
The last state of gdbserver was as follows:
$ sudo gdbserver --attach :1234 1
Attached; pid = 1
Listening on port 1234
Remote debugging from host 127.0.0.1, port 52364
gdbserver: Couldn't write debug register: Invalid argument.
Listening on port 1234
input_interrupt, count = 1 c = 36 ('$')
First, the breakpoint 1 should only be at 1 location. Second, I don't get why there is error on step command in both gdb
and gdbserver
.
Is it the right way to do remote kernel debugging on the same machine? If not, what is the right way?
I have a MacBook Pro too as my second machine. If needed, I can use it to run gdb
. I really need to debug and solve this ACPI error.
Upvotes: 2
Views: 467