Re: on-line kernel debugging

2018-04-24 Thread Philip Guenther
On Wed, Apr 25, 2018 at 1:54 AM, Il Ka  wrote:
>
> I am also interested in kernel debugging.
> > but we do support running gdb inside a system against its running kernel
> Thank you for this recipe, but is it true that live debug does not work for
> some cases?
> You can't set break point in wsconsole and tty and debug them nor you can
> debug kernel that
> is frozen, and it seems that remote debug
> (like http://www.netbsd.org/docs/kernel/kgdb.html)
> is not supported by obsd, right?
>

Correct.



> Is it because of security reasons?
>

No one was using it, it got in the way of development that was in progress,
and none of the developers was interested in fixing it.  If someone wants
it and can keep it from being in the way of other work, then some form of
it could come back in, but if it would just decay into an impediment then
that would be a waste of time.


Philip Guenther


Re: on-line kernel debugging

2018-04-24 Thread Il Ka
Hello,

I am also interested in kernel debugging.
> but we do support running gdb inside a system against its running kernel
Thank you for this recipe, but is it true that live debug does not work for
some cases?
You can't set break point in wsconsole and tty and debug them nor you can
debug kernel that 
is frozen, and it seems that remote debug 
(like http://www.netbsd.org/docs/kernel/kgdb.html)
is not supported by obsd, right?

Is it because of security reasons?






--
Sent from: 
http://openbsd-archive.7691.n7.nabble.com/openbsd-dev-tech-f151936.html



Re: on-line kernel debugging

2018-02-02 Thread bijan

On 02/02/18 04:31, David Gwynne wrote:

On 28 Jan 2018, at 04:07, bijan  wrote:

Thank you (for the quick response) and sorry if I was not as clear
as I should have been! what I meant and was hoping to find was
a source code debugger support, like gdb[1], where one can debug
a running kernel with full access to the source code in a gdb session
environment from a remote machine.

I'm new to OpenBSD and found kgdb(7)[2] manual from 6.1 describing
the process very similar to what I do daily with FreeBSD but (as I
mentioned earlier) the code seems to be removed since 6.2.

So, is there any alternative for remote debugging a running OpenBSD
kernel using gdb? anyhow, I appreciate it if one can point me to the
right direction and I don't mind any hard work in the process :-)

i dont think we support kgdb anymore, but we do support running gdb inside a 
system against its running kernel. to do this, you need to have the 
kern.allowkmem sysctl set, which is best done via /etc/sysctl.conf.

Great ... Thanks :-) I should definitely try this one

Anyhow, I recently studied the FreeBSD source code for it's 
implementation of kdb and briefly examined the implementation and 
changes of ddb(4) in OpenBSD source code. It seems to me that it's 
possible to add support for multiple debuggers like gdb (as a standalone 
back-end or as a ddb command) to OpenBSD kernel as well (since the 
remote protocol is quiet small and the infrastructures looks pretty much 
the same as FreeBSD to me).


I'm not quiet sure if I'm capable of porting the code, but if no-one is 
interested (or is free to do the job), I will definitely give it a try. 
So, is there anything one should know why such feature is missing? Or 
any reason to prevent such effort in the first place?


Thanks
B.E

after that you'll need a kernel with debug symbols in it. the easiest way to 
get that is just build a kernel. there'll be a bsd.gdb next to the bsd it 
produces. then you can do this:

dlg@v215 GENERIC.MP$ pwd
/usr/obj/sys/arch/sparc64/compile/GENERIC.MP
dlg@v215 GENERIC.MP$ ls bsd bsd.gdb
-rwxrwx---  1 dlg  wobj  10193351 Feb  2 10:58 bsd
-rwxrwx---  1 dlg  wobj  3915 Feb  2 10:58 bsd.gdb
dlg@v215 GENERIC.MP$ cat /etc/sysctl.conf
kern.allowkmem=1
dlg@v215 GENERIC.MP$ sysctl kern.allowkmem
kern.allowkmem=1
dlg@v215 GENERIC.MP$ sudo gdb bsd.gdb
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "sparc64-unknown-openbsd6.2"...
(gdb) target kvm
#0  mi_switch () at /usr/src/sys/kern/sched_bsd.c:410
410 cpu_switchto(p, nextproc);
(gdb) print copyright
$1 = "Copyright (c) 1982, 1986, 1989, 1991, 1993\n\tThe Regents of the University of 
California.  All rights reserved.\nCopyright (c) 1995-2017 OpenBSD. All rights reserved.  
https://www.OpenBSD.org\n";

the important thing is the "target kvm" inside gdb, which relies on allowkmem.

because of the allowkmem requirement, this recommended for use on development 
boxes only.

dlg




Re: on-line kernel debugging

2018-02-01 Thread David Gwynne

> On 28 Jan 2018, at 04:07, bijan  wrote:
> 
> Thank you (for the quick response) and sorry if I was not as clear
> as I should have been! what I meant and was hoping to find was
> a source code debugger support, like gdb[1], where one can debug
> a running kernel with full access to the source code in a gdb session
> environment from a remote machine.
> 
> I'm new to OpenBSD and found kgdb(7)[2] manual from 6.1 describing
> the process very similar to what I do daily with FreeBSD but (as I
> mentioned earlier) the code seems to be removed since 6.2.
> 
> So, is there any alternative for remote debugging a running OpenBSD
> kernel using gdb? anyhow, I appreciate it if one can point me to the
> right direction and I don't mind any hard work in the process :-)

i dont think we support kgdb anymore, but we do support running gdb inside a 
system against its running kernel. to do this, you need to have the 
kern.allowkmem sysctl set, which is best done via /etc/sysctl.conf.

after that you'll need a kernel with debug symbols in it. the easiest way to 
get that is just build a kernel. there'll be a bsd.gdb next to the bsd it 
produces. then you can do this:

dlg@v215 GENERIC.MP$ pwd
/usr/obj/sys/arch/sparc64/compile/GENERIC.MP
dlg@v215 GENERIC.MP$ ls bsd bsd.gdb
-rwxrwx---  1 dlg  wobj  10193351 Feb  2 10:58 bsd
-rwxrwx---  1 dlg  wobj  3915 Feb  2 10:58 bsd.gdb
dlg@v215 GENERIC.MP$ cat /etc/sysctl.conf  
kern.allowkmem=1
dlg@v215 GENERIC.MP$ sysctl kern.allowkmem
kern.allowkmem=1
dlg@v215 GENERIC.MP$ sudo gdb bsd.gdb  
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "sparc64-unknown-openbsd6.2"...
(gdb) target kvm
#0  mi_switch () at /usr/src/sys/kern/sched_bsd.c:410
410 cpu_switchto(p, nextproc);
(gdb) print copyright
$1 = "Copyright (c) 1982, 1986, 1989, 1991, 1993\n\tThe Regents of the 
University of California.  All rights reserved.\nCopyright (c) 1995-2017 
OpenBSD. All rights reserved.  https://www.OpenBSD.org\n";

the important thing is the "target kvm" inside gdb, which relies on allowkmem.

because of the allowkmem requirement, this recommended for use on development 
boxes only.

dlg

> 
> [1]: 
> https://www.freebsd.org/doc/en/books/developers-handbook/kerneldebug-online-gdb.html
> [2]: https://man.openbsd.org/OpenBSD-6.1/kgdb.7
> 
> 
> On 01/27/18 21:00, Todd C. Miller wrote:
>> On Sat, 27 Jan 2018 20:46:18 +0330, bijan wrote:
>> 
>>> does OpenBSD support on-line kernel debugging as FreeBSD does[1]?
>> Yes, see the ddb(4) manual page.
>> 
>>  - todd
> 



Re: on-line kernel debugging

2018-01-27 Thread bijan

Thank you (for the quick response) and sorry if I was not as clear
as I should have been! what I meant and was hoping to find was
a source code debugger support, like gdb[1], where one can debug
a running kernel with full access to the source code in a gdb session
environment from a remote machine.

I'm new to OpenBSD and found kgdb(7)[2] manual from 6.1 describing
the process very similar to what I do daily with FreeBSD but (as I
mentioned earlier) the code seems to be removed since 6.2.

So, is there any alternative for remote debugging a running OpenBSD
kernel using gdb? anyhow, I appreciate it if one can point me to the
right direction and I don't mind any hard work in the process :-)

[1]: 
https://www.freebsd.org/doc/en/books/developers-handbook/kerneldebug-online-gdb.html

[2]: https://man.openbsd.org/OpenBSD-6.1/kgdb.7


On 01/27/18 21:00, Todd C. Miller wrote:

On Sat, 27 Jan 2018 20:46:18 +0330, bijan wrote:


does OpenBSD support on-line kernel debugging as FreeBSD does[1]?

Yes, see the ddb(4) manual page.

  - todd




Re: on-line kernel debugging

2018-01-27 Thread Todd C. Miller
On Sat, 27 Jan 2018 20:46:18 +0330, bijan wrote:

> does OpenBSD support on-line kernel debugging as FreeBSD does[1]?

Yes, see the ddb(4) manual page.

 - todd



on-line kernel debugging

2018-01-27 Thread bijan

Hi! (Don't know if tech@ is the right place to ask such questions, just
hope it is)

does OpenBSD support on-line kernel debugging as FreeBSD does[1]?
The only document I managed to find was a fairly old one[2] by QEMU
over GNU/Linux but it seems kgdb(7) is removed since 6.2 (apparently
for not even working before[3]).

Thank you!

[1]: 
https://www.freebsd.org/doc/en/books/developers-handbook/kerneldebug-online-ddb.html 


[2]: https://markshroyer.com/2013/01/debugging-openbsd-via-qemu/
[3]: https://github.com/openbsd/src/commits/master/sys/sys/kgdb.h