# gdbserver in FreeBSD



## Jusctsch (Jun 15, 2011)

Hello all, 

I noticed that gdbserver isn't fully supported by FreeBSD, which makes it difficult for it to be remotely debugged. Because FreeBSD is commonly used in embedded systems, I feel like a working gdbserver would be greatly useful for debugging outside of the box.

It's not straightforward however. Specifically, one of the issues with FreeBSD's gdbserver, that isn't handled well, is the lack of thread awareness of the gdbserver. It is highly inflexible when handling processes with multiple threads, to the point that it doesn't attach to any additional existing thread, or created thread, beyond the first.

It looks like Linux' flavor of gdbserver can handle multithreading, but it doesn't seem to be very obvious. Has anyone ever tried porting over the Linux version of gdbserver to FreeBSD? And if not, what other obvious changes would have to be made to the existing gdbserver (some flavor of 6.6.2 I think)? 

I think we should try to keep the implementation to 1:1 kernel to process thread to keep it simple - which is the libthr interpretation of pthreads.

Thanks


----------



## SirDice (Jun 15, 2011)

Have a look at this, it might be what you're looking for.

Developer's Handbook: 10.5 On-Line Kernel Debugging Using Remote GDB


----------



## Jusctsch (Jun 15, 2011)

SirDice said:
			
		

> Have a look at this, it might be what you're looking for.
> 
> Developer's Handbook: 10.5 On-Line Kernel Debugging Using Remote GDB



This looks promising. Another aspect of gdbserver is the ability to debug applications currently running on the FreeBSD system; would it be possible to debug in this kgdb, or is it limited to the kernel?

I bet some of the implementation is similar, so it would be a reasonable place to look at code regardless.

Thanks a bunch.


----------

