Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Remote kernel debugging question

160 views
Skip to first unread message

Nidal Khalil

unread,
Jul 21, 2014, 3:23:10 PM7/21/14
to freebsd...@freebsd.org
Hello All,
I am somewhat new to BSD kernel but I am trying to debug a kernel module
using remote debugging.
I am using 9.2 RELEASE.
I setup and compiled the kernel with the following:

makeoptions DEBUG=-g
options KDB
options KDB_TRACE
options DDB_CTF
options DDB
options GDB
options ALT_BREAK_TO_DEBUGGER

I setup the uart for serial1 flags to 0x90 and I can read and write to the
serial from either machine
Both machines have the same kernel booted.
I can enter ddb but I can not launch gdb
The remote GDB backend could not be selected.
sysctl -a | grep debug.kdb

debug.kdb.available: ddb
Is that correct or it should be:
debug.kdb.available: ddb gdb
How do I enable gdb backend. I appreciate the help.

Nidal
_______________________________________________
freebsd...@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hacke...@freebsd.org"

Benjamin Kaduk

unread,
Jul 21, 2014, 5:56:13 PM7/21/14
to Nidal Khalil, freebsd...@freebsd.org
On Mon, 21 Jul 2014, Nidal Khalil wrote:

> Hello All,
> I am somewhat new to BSD kernel but I am trying to debug a kernel module
> using remote debugging.
> I am using 9.2 RELEASE.
> I setup and compiled the kernel with the following:
>
> makeoptions DEBUG=-g
> options KDB
> options KDB_TRACE
> options DDB_CTF
> options DDB
> options GDB
> options ALT_BREAK_TO_DEBUGGER
>
> I setup the uart for serial1 flags to 0x90 and I can read and write to the
> serial from either machine
> Both machines have the same kernel booted.
> I can enter ddb but I can not launch gdb
> The remote GDB backend could not be selected.
> sysctl -a | grep debug.kdb
>
> debug.kdb.available: ddb
> Is that correct or it should be:
> debug.kdb.available: ddb gdb
> How do I enable gdb backend. I appreciate the help.

I do not think I have actually used remote GDB kernel debugging on my own
machines, but I wanted to make sure that you had seen the documentation
for doing so, available at
http://www.freebsd.org/doc/en/books/developers-handbook/kerneldebug-online-gdb.html
If it is incorrect, we should update it to be correct.

Thanks,

Ben Kaduk

Nidal Khalil

unread,
Jul 21, 2014, 5:58:34 PM7/21/14
to Benjamin Kaduk, freebsd...@freebsd.org
Hi Ben,
Yes I am familiar with the doc. As
> books/developers-handbook/kerneldebug-online-gdb.html . If it is

Navdeep Parhar

unread,
Jul 21, 2014, 6:22:41 PM7/21/14
to Nidal Khalil, freebsd...@freebsd.org
On 07/21/14 12:22, Nidal Khalil wrote:
> Hello All,
> I am somewhat new to BSD kernel but I am trying to debug a kernel module
> using remote debugging.
> I am using 9.2 RELEASE.
> I setup and compiled the kernel with the following:
>
> makeoptions DEBUG=-g
> options KDB
> options KDB_TRACE
> options DDB_CTF
> options DDB
> options GDB
> options ALT_BREAK_TO_DEBUGGER
>
> I setup the uart for serial1 flags to 0x90 and I can read and write to the
> serial from either machine
> Both machines have the same kernel booted.
> I can enter ddb but I can not launch gdb
> The remote GDB backend could not be selected.
> sysctl -a | grep debug.kdb
>
> debug.kdb.available: ddb
> Is that correct or it should be:
> debug.kdb.available: ddb gdb

The latter.

> How do I enable gdb backend. I appreciate the help.

All this on a recent HEAD. If your problem is 9.2 specific then this
may not help, but at least we can compare notes. You did say you set
flags to 0x90 for your serial port but it's not clear how. I have this
in /boot/loader.conf:
hint.uart.0.flags="0x90"

When the system boots I see this right around when loader hands off to
the kernel.

GDB: debug ports: uart
GDB: current port: uart
KDB: debugger backends: ddb gdb
KDB: current backend: ddb
Copyright (c) 1992-2014 The FreeBSD Project.
..

After the system boots I see both ddb and gdb in the available debug
backends and all is well.

# sysctl debug.kdb.available
debug.kdb.available: ddb gdb
# sysctl debug.kdb.current
debug.kdb.current: ddb
# sysctl debug.kdb.current=gdb
debug.kdb.current: ddb -> gdb
# sysctl debug.kdb.current
debug.kdb.current: gdb

Regards,
Navdeep

Nidal Khalil

unread,
Jul 21, 2014, 6:35:11 PM7/21/14
to Navdeep Parhar, freebsd...@freebsd.org
The documentation states to put hint.uart.0.flags="0x90" in
/boot/device.hits
However you hit on a good point. I see some parameters in boot/loader.conf.
Can you please email this file
I think that I need to do more configuration to this file. I will do it by
comparison. Thanks

Nidal
> ...

Navdeep Parhar

unread,
Jul 21, 2014, 6:40:20 PM7/21/14
to Nidal Khalil, freebsd...@freebsd.org
On 07/21/14 15:35, Nidal Khalil wrote:
> The documentation states to put hint.uart.0.flags="0x90" in
> /boot/device.hits

Putting it in device.hints should have worked too. In fact, that's
where uart(4) has it. You haven't spelled it "hits" on your filesystem
like you did here, have you?

> However you hit on a good point. I see some parameters in
> boot/loader.conf. Can you please email this file
> I think that I need to do more configuration to this file. I will do it
> by comparison. Thanks

That's all there was in the file.

Regards,
Navdeep

Nidal Khalil

unread,
Jul 21, 2014, 6:44:32 PM7/21/14
to Navdeep Parhar, freebsd...@freebsd.org
No, I have not .
It is hint.uart.0.flags="0x90"
Thanks
My question is how do I get gdb to show up as part of available debuggers
in this node:
debug.kdb.available: ddb
Thanks

Nidal

Pokala, Ravi

unread,
Jul 22, 2014, 1:32:28 PM7/22/14
to freebsd...@freebsd.org
> hint.uart.0.flags="0x90"

Is this an i386 or amd64 system? If so, shouldn't it be sio(4) rather than
uart(4)? I thought uart(4) only became the default serial port driver for
i386/amd64 as part of 10.

-Ravi
0 new messages