NetBSD Problem Report #53125

From www@NetBSD.org  Sat Mar 24 10:28:43 2018
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id B1D6C7A183
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 24 Mar 2018 10:28:43 +0000 (UTC)
Message-Id: <20180324102841.DDF6F7A202@mollari.NetBSD.org>
Date: Sat, 24 Mar 2018 10:28:41 +0000 (UTC)
From: utkarsh009@yandex.com
Reply-To: utkarsh009@yandex.com
To: gnats-bugs@NetBSD.org
Subject: sys/timevar.h is absent in installed systems.
X-Send-Pr-Version: www-1.0

>Number:         53125
>Category:       lib
>Synopsis:       sys/timevar.h is absent in installed systems.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Mar 24 10:30:00 +0000 2018
>Closed-Date:    Wed Mar 28 16:53:40 +0000 2018
>Last-Modified:  Thu Mar 29 08:20:00 +0000 2018
>Originator:     Utkarsh Anand
>Release:        NetBSD 8.0_BETA
>Organization:
>Environment:
NetBSD  8.0_BETA NetBSD 8.0_BETA (GENERIC) #1: Mon Mar 12 19:41:15 IST 2018  root@Microknoppix:/extra/netbsd-8/sys/arch/amd64/compile/GENERIC amd64
>Description:
I was compiling a file on NetBSD where I needed to #define _KERNEL, but it requires sys/timevar.h to be present, but it isn't present anywhere on installed systems. Although, it is present in src/sys/sys.
>How-To-Repeat:
Try compiling a C file with the following content:
#define _KERNEL
#include <sys/time.h>
int main(){
    return 0;
}
>Fix:

>Release-Note:

>Audit-Trail:
From: Manuel Bouyer <bouyer@antioche.eu.org>
To: gnats-bugs@NetBSD.org
Cc: lib-bug-people@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: lib/53125: sys/timevar.h is absent in installed systems.
Date: Sat, 24 Mar 2018 11:33:23 +0100

 On Sat, Mar 24, 2018 at 10:30:01AM +0000, utkarsh009@yandex.com wrote:
 > >How-To-Repeat:
 > Try compiling a C file with the following content:
 > #define _KERNEL
 > #include <sys/time.h>
 > int main(){
 >     return 0;
 > }

 Why do you want to do this ? _KERNEL code is not available to userland
 for good reasons, you're probably doing something wrong.

 -- 
 Manuel Bouyer <bouyer@antioche.eu.org>
      NetBSD: 26 ans d'experience feront toujours la difference
 --

From: Utkarsh Anand <utkarsh009@yandex.com>
To: "gnats-bugs@NetBSD.org" <gnats-bugs@netbsd.org>,
	"lib-bug-people@netbsd.org" <lib-bug-people@netbsd.org>,
	"gnats-admin@netbsd.org" <gnats-admin@netbsd.org>,
	"netbsd-bugs@netbsd.org" <netbsd-bugs@netbsd.org>
Cc: 
Subject: Re: lib/53125: sys/timevar.h is absent in installed systems.
Date: Sat, 24 Mar 2018 16:47:24 +0530

 >  Why do you want to do this ? _KERNEL code is not available to userland
 If this builds, I wouldn't need to define _KERNEL:

 #define _KMEMUSER
 #include <uvm/uvm_map.h>
 int main(){
     return 0;
 }

 NB: vaddr_t, vsize_t etc. are defined in <machine/types.h>. Maybe including those in the files under uvm/, that need them, might help.
 >  for good reasons, you're probably doing something wrong.
 >
 >  --
 >  Manuel Bouyer <bouyer@antioche.eu.org>
 >       NetBSD: 26 ans d'experience feront toujours la difference
 >  --

From: Utkarsh Anand <utkarsh009@yandex.com>
To: "gnats-bugs@NetBSD.org" <gnats-bugs@netbsd.org>,
	"lib-bug-people@netbsd.org" <lib-bug-people@netbsd.org>,
	"gnats-admin@netbsd.org" <gnats-admin@netbsd.org>,
	"netbsd-bugs@netbsd.org" <netbsd-bugs@netbsd.org>
Cc: 
Subject: Re: lib/53125: sys/timevar.h is absent in installed systems.
Date: Sat, 24 Mar 2018 16:54:16 +0530

 24.03.2018, 16:47, "Utkarsh Anand" <utkarsh009@yandex.com>:

 > If this builds, I wouldn't need to define _KERNEL:
 >
 > #define _KMEMUSER
 > #include <uvm/uvm_map.h>
 > int main(){
 >     return 0;
 > }
 >
 > NB: vaddr_t, vsize_t etc. are defined in <machine/types.h>. Maybe including those in the files under uvm/, that need them, might help.

 Actually, I don't even think it would build with _KERNEL defined, because uvm/uvm_pager.h doesn't include any file (let alone conditional inclusion) but needs to have vaddr_t. So, I'd probably get the same error even with _KERNEL defined and timevar.h present. I think including <machine/types.h> in those files should help.

From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: lib/53125: sys/timevar.h is absent in installed systems.
Date: Sat, 24 Mar 2018 18:40:17 +0700

     Date:        Sat, 24 Mar 2018 10:30:01 +0000 (UTC)
     From:        utkarsh009@yandex.com
     Message-ID:  <20180324103001.2B4777A267@mollari.NetBSD.org>

   | I was compiling a file on NetBSD where I needed to #define _KERNEL,

 Are you compiling part of the kernel?   If not, you should not be defining 
 that.   If you are, then src/sys/sys should be in the include path, and
 _KERNEL should be defined without needing a #define

   | Try compiling a C file with the following content:
   | #define _KERNEL
   | #include <sys/time.h>

 Are you sure that you don't just want <time.h> ?

 kre

From: Utkarsh Anand <utkarsh009@yandex.com>
To: "gnats-bugs@NetBSD.org" <gnats-bugs@netbsd.org>,
	"lib-bug-people@netbsd.org" <lib-bug-people@netbsd.org>,
	"gnats-admin@netbsd.org" <gnats-admin@netbsd.org>,
	"netbsd-bugs@netbsd.org" <netbsd-bugs@netbsd.org>
Cc: 
Subject: Re: lib/53125: sys/timevar.h is absent in installed systems.
Date: Sat, 24 Mar 2018 17:24:21 +0530

 24.03.2018, 17:15, "Robert Elz" <kre@munnari.oz.au>:
 > The following reply was made to PR lib/53125; it has been noted by GNATS.
 >
 > From: Robert Elz <kre@munnari.OZ.AU>
 > To: gnats-bugs@NetBSD.org
 > Cc:
 > Subject: Re: lib/53125: sys/timevar.h is absent in installed systems.
 > Date: Sat, 24 Mar 2018 18:40:17 +0700
 >
 >      Date: Sat, 24 Mar 2018 10:30:01 +0000 (UTC)
 >      From: utkarsh009@yandex.com
 >      Message-ID: <20180324103001.2B4777A267@mollari.NetBSD.org>
 >
 >    | I was compiling a file on NetBSD where I needed to #define _KERNEL,
 >
 >  Are you compiling part of the kernel? If not, you should not be defining
 >  that. If you are, then src/sys/sys should be in the include path, and
 >  _KERNEL should be defined without needing a #define

 No. I am trying to compile a general purpose application that is not available in pkgsrc.
 Thanks for the information, but the plan has changed (see previous mail for reasons).
 I want to do it by defining _KMEMUSER. 
 Any thoughts on including <machine/types.h> in uvm/* files that need them?
 That should solve the problem and I can commit the changes if others agree.
 >
 >    | Try compiling a C file with the following content:
 >    | #define _KERNEL
 >    | #include <sys/time.h>
 >
 >  Are you sure that you don't just want <time.h> ?
 It's there only because of nested inclusions. I don't need it directly. I need sys/sysctl.h
 >
 >  kre

From: mlelstv@serpens.de (Michael van Elst)
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: lib/53125: sys/timevar.h is absent in installed systems.
Date: Sat, 24 Mar 2018 15:43:37 -0000 (UTC)

 utkarsh009@yandex.com (Utkarsh Anand) writes:

 >NB: vaddr_t, vsize_t etc. are defined in <machine/types.h>. Maybe including those in the files under uvm/, that need them, might help.

 Or it might be intentional to prevent regular program from relying on
 kernel interna.

 -- 
 -- 
                                 Michael van Elst
 Internet: mlelstv@serpens.de
                                 "A potential Snark may lurk in every tree."

From: mlelstv@serpens.de (Michael van Elst)
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: lib/53125: sys/timevar.h is absent in installed systems.
Date: Sat, 24 Mar 2018 15:46:26 -0000 (UTC)

 utkarsh009@yandex.com (Utkarsh Anand) writes:

 >No. I am trying to compile a general purpose application that is not available in pkgsrc.

 Apparently it is not general purpose and hasn't been ported to NetBSD.

 -- 
 -- 
                                 Michael van Elst
 Internet: mlelstv@serpens.de
                                 "A potential Snark may lurk in every tree."

From: Manuel Bouyer <bouyer@antioche.eu.org>
To: Utkarsh Anand <utkarsh009@yandex.com>
Cc: "gnats-bugs@NetBSD.org" <gnats-bugs@netbsd.org>,
        "lib-bug-people@netbsd.org" <lib-bug-people@netbsd.org>,
        "gnats-admin@netbsd.org" <gnats-admin@netbsd.org>,
        "netbsd-bugs@netbsd.org" <netbsd-bugs@netbsd.org>
Subject: Re: lib/53125: sys/timevar.h is absent in installed systems.
Date: Sat, 24 Mar 2018 17:28:34 +0100

 On Sat, Mar 24, 2018 at 04:47:24PM +0530, Utkarsh Anand wrote:
 > 
 > > Why do you want to do this ? _KERNEL code is not available to userland
 > If this builds, I wouldn't need to define _KERNEL:
 > 
 > #define _KMEMUSER
 > #include <uvm/uvm_map.h>
 > int main(){
 >     return 0;
 > }

 You still don't explain what you want to do. _KMEMUSER use is restricted
 even in the kernel, it's in no way designed to be used in userland.

 -- 
 Manuel Bouyer <bouyer@antioche.eu.org>
      NetBSD: 26 ans d'experience feront toujours la difference
 --

From: Joerg Sonnenberger <joerg@bec.de>
To: gnats-bugs@NetBSD.org
Cc: lib-bug-people@netbsd.org, gnats-admin@netbsd.org,
	netbsd-bugs@netbsd.org, utkarsh009@yandex.com
Subject: Re: lib/53125: sys/timevar.h is absent in installed systems.
Date: Sat, 24 Mar 2018 17:37:42 +0100

 On Sat, Mar 24, 2018 at 04:30:01PM +0000, Manuel Bouyer wrote:
 >  You still don't explain what you want to do. _KMEMUSER use is restricted
 >  even in the kernel, it's in no way designed to be used in userland.

 That's not true. It is restricted for programs that use /dev/kmem and/or
 core dumps. It is not meant for random userland programs and generally a
 sign of a bug if a program depends on it.

 Joerg

From: Utkarsh Anand <utkarsh009@yandex.com>
To: "gnats-bugs@NetBSD.org" <gnats-bugs@netbsd.org>,
	"lib-bug-people@netbsd.org" <lib-bug-people@netbsd.org>,
	"gnats-admin@netbsd.org" <gnats-admin@netbsd.org>,
	"netbsd-bugs@netbsd.org" <netbsd-bugs@netbsd.org>
Cc: 
Subject: Re: lib/53125: sys/timevar.h is absent in installed systems.
Date: Sat, 24 Mar 2018 22:23:44 +0530

 24.03.2018, 21:20, "Michael van Elst" <mlelstv@serpens.de>:

 >  Apparently it is not general purpose and hasn't been ported to NetBSD.
 Yes it is. I'm trying to port https://github.com/neovim/neovim
 (Yes, I was using `vi` to edit and view tons of files and I'll most probably 
 have nothing to edit after I port it.)
 Currently, I'm stuck with this: http://termbin.com/scy2
 This patch (along with a small edit in an untracked folder that is generated 
 dynamically after downloading dependencies) helped me reach that far:
 http://termbin.com/6ibia
 I was surprised to see that including <machine/types.h> has no effect 
 whatsoever but declaring those in any of the dependent files removes
 errors for all the files deeper down the nesting.
 As for the implicit declaration warning, I don't get it when I compile it in linux.
 In fact I don't get a single error in Linux? Could it be a problem in the compiler/
 gmake/cmake in pkgsrc?


 24.03.2018, 21:58, "Manuel Bouyer" <bouyer@antioche.eu.org>:

 > You still don't explain what you want to do. _KMEMUSER use is restricted
 > even in the kernel, it's in no way designed to be used in userland.
 >

 I have explained it above. It doesn't look like a bug in that application. Apparently, other 
 operating systems provide access to `struct kinfo_proc` even to non _KMEMUSERs.

From: Utkarsh Anand <utkarsh009@yandex.com>
To: "gnats-bugs@NetBSD.org" <gnats-bugs@netbsd.org>
Cc: 
Subject: Re: lib/53125: sys/timevar.h is absent in installed systems.
Date: Sat, 24 Mar 2018 22:35:55 +0530

 24.03.2018, 22:23, "Utkarsh Anand" <utkarsh009@yandex.com>:
 > I was surprised to see that including <machine/types.h> has no effect
 > whatsoever but declaring those in any of the dependent files removes
 > errors for all the files deeper down the nesting.
 Although when I create a small test file for testing the effects of including
 <machine/types.h> it works just fine.

From: =?UTF-8?B?SmFyb23DrXIgRG9sZcSNZWs=?= <jaromir.dolecek@gmail.com>
To: Utkarsh Anand <utkarsh009@yandex.com>
Cc: "gnats-bugs@NetBSD.org" <gnats-bugs@netbsd.org>
Subject: Re: lib/53125: sys/timevar.h is absent in installed systems.
Date: Sat, 24 Mar 2018 18:17:02 +0100

 --f403045d57329e975805682bb538
 Content-Type: text/plain; charset="UTF-8"

 2018-03-24 17:53 GMT+01:00 Utkarsh Anand <utkarsh009@yandex.com>:

 > > You still don't explain what you want to do. _KMEMUSER use is restricted
 > > even in the kernel, it's in no way designed to be used in userland.
 > >
 >
 > I have explained it above. It doesn't look like a bug in that application.
 > Apparently, other
 > operating systems provide access to `struct kinfo_proc` even to non
 > _KMEMUSERs.
 >

 I think Manuel wanted to know what particular information you need to get,
 i.e. why are you looking into this kinfo_proc at all.

 Perhaps there is other suitable interface, or some set of headers which
 need to be included. Groweling through kernel internal structures is
 usually bad sign, and it's almost always non-portable, and tends to break
 between OS versions. We provide binary-safe interfaces in order to make it
 simpler to keep the apps working.

 So what is the purpose of the code you are trying to get to compile and
 run, what kind of information do you need to get, why the standard POSIX
 interfaces are not sufficient?

 Jaromir

 --f403045d57329e975805682bb538
 Content-Type: text/html; charset="UTF-8"
 Content-Transfer-Encoding: quoted-printable

 <div dir=3D"ltr">2018-03-24 17:53 GMT+01:00 Utkarsh Anand <span dir=3D"ltr"=
 >&lt;<a href=3D"mailto:utkarsh009@yandex.com" target=3D"_blank">utkarsh009@=
 yandex.com</a>&gt;</span>:<br><div class=3D"gmail_extra"><div class=3D"gmai=
 l_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;borde=
 r-left:1px #ccc solid;padding-left:1ex"><span class=3D"">&gt; You still don=
 &#39;t explain what you want to do. _KMEMUSER use is restricted<br>
 &gt; even in the kernel, it&#39;s in no way designed to be used in userland=
 .<br>
 &gt;<br>
 <br>
 </span>I have explained it above. It doesn&#39;t look like a bug in that ap=
 plication. Apparently, other<br>
 operating systems provide access to `struct kinfo_proc` even to non _KMEMUS=
 ERs.<br></blockquote><div><br></div><div>I think Manuel wanted to know what=
  particular information you need to get, i.e. why are you looking into this=
  kinfo_proc at all.</div><div><br></div><div>Perhaps there is other suitabl=
 e interface, or some set of headers which need to be included. Groweling th=
 rough kernel internal structures is usually bad sign, and it&#39;s almost a=
 lways non-portable, and tends to break between OS versions. We provide bina=
 ry-safe interfaces in order to make it simpler to keep the apps working.</d=
 iv><div><br></div><div>So what is the purpose of the code you are trying to=
  get to compile and run, what kind of information do you need to get, why t=
 he standard POSIX interfaces are not sufficient?</div><div><br></div><div>J=
 aromir=C2=A0</div></div></div></div>

 --f403045d57329e975805682bb538--

From: Manuel Bouyer <bouyer@antioche.eu.org>
To: Utkarsh Anand <utkarsh009@yandex.com>
Cc: "gnats-bugs@NetBSD.org" <gnats-bugs@netbsd.org>,
        "lib-bug-people@netbsd.org" <lib-bug-people@netbsd.org>,
        "gnats-admin@netbsd.org" <gnats-admin@netbsd.org>,
        "netbsd-bugs@netbsd.org" <netbsd-bugs@netbsd.org>
Subject: Re: lib/53125: sys/timevar.h is absent in installed systems.
Date: Sat, 24 Mar 2018 18:21:52 +0100

 On Sat, Mar 24, 2018 at 10:23:44PM +0530, Utkarsh Anand wrote:
 > 
 > 
 > 24.03.2018, 21:20, "Michael van Elst" <mlelstv@serpens.de>:
 > 
 > > Apparently it is not general purpose and hasn't been ported to NetBSD.
 > Yes it is. I'm trying to port https://github.com/neovim/neovim

 Why would this need to access kernel memory internals ????

 there's something wrong here.

 -- 
 Manuel Bouyer <bouyer@antioche.eu.org>
      NetBSD: 26 ans d'experience feront toujours la difference
 --

From: Utkarsh Anand <utkarsh009@yandex.com>
To: =?utf-8?B?SmFyb23DrXIgRG9sZcSNZWs=?= <jaromir.dolecek@gmail.com>
Cc: "gnats-bugs@NetBSD.org" <gnats-bugs@netbsd.org>
Subject: Re: lib/53125: sys/timevar.h is absent in installed systems.
Date: Sat, 24 Mar 2018 23:12:59 +0530

 24.03.2018, 22:47, "Jaromír Doleček" <jaromir.dolecek@gmail.com>:
 > 2018-03-24 17:53 GMT+01:00 Utkarsh Anand <utkarsh009@yandex.com>:
 >>> You still don't explain what you want to do. _KMEMUSER use is restricted
 >>> even in the kernel, it's in no way designed to be used in userland.
 >>>
 >>
 >> I have explained it above. It doesn't look like a bug in that application. Apparently, other
 >> operating systems provide access to `struct kinfo_proc` even to non _KMEMUSERs.
 >
 > I think Manuel wanted to know what particular information you need to get, i.e. why are you looking into this kinfo_proc at all.
 As shown here: https://github.com/neovim/neovim/blob/be67d926c5eec3b90cf906471f4b81ed21223c1f/src/nvim/os/process.c#L167
 It wants to get a list of all processes and separate those processes that match parent process id. It seems to build in Linux, FreeBSD, and MacOSX.
 >
 > Perhaps there is other suitable interface, or some set of headers which need to be included. Groweling through kernel internal structures is usually bad sign, and it's almost always non-portable, and tends to break between OS versions. We provide binary-safe interfaces in order to make it simpler to keep the apps working.
 Nice!
 >
 > So what is the purpose of the code you are trying to get to compile and run, what kind of information do you need to get, why the standard POSIX interfaces are not sufficient?
 Umm.. maybe there's a way and I couldn't find it. FreeBSD is in the list of supported OSes too.
 >
 > Jaromir

From: Utkarsh Anand <utkarsh009@yandex.com>
To: =?utf-8?B?SmFyb23DrXIgRG9sZcSNZWs=?= <jaromir.dolecek@gmail.com>
Cc: "gnats-bugs@NetBSD.org" <gnats-bugs@netbsd.org>
Subject: Re: lib/53125: sys/timevar.h is absent in installed systems.
Date: Sat, 24 Mar 2018 23:25:17 +0530

 >>  So what is the purpose of the code you are trying to get to compile and run, what kind of information do you need to get, why the standard POSIX interfaces are not sufficient?

 >>  Jaromir
 Sorry, I forgot mentioning the purpose. It's a text editor, so the purpose was to edit files. It's a nice text editor with lots of plugins and themes (like https://github.com/mhartington/oceanic-next) along with all vim commands/macros.
 Moreover,
 I was just ricing all my systems.
 https://imgur.com/lfBeoY3
 https://imgur.com/2WFToGV
 So I thought maybe let's rice NetBSD too.
 Currently, it looks like this on virtualbox:
 https://imgur.com/L9hiCBQ

From: Utkarsh Anand <utkarsh009@yandex.com>
To: =?utf-8?B?SmFyb23DrXIgRG9sZcSNZWs=?= <jaromir.dolecek@gmail.com>
Cc: "gnats-bugs@NetBSD.org" <gnats-bugs@netbsd.org>
Subject: Re: lib/53125: sys/timevar.h is absent in installed systems.
Date: Sat, 24 Mar 2018 23:31:26 +0530

 24.03.2018, 23:12, "Utkarsh Anand" <utkarsh009@yandex.com>:

 > As shown here: https://github.com/neovim/neovim/blob/be67d926c5eec3b90cf906471f4b81ed21223c1f/src/nvim/os/process.c#L167
 > It wants to get a list of all processes and separate those processes that match parent process id. It seems to build in Linux, FreeBSD, and MacOSX.
 *those processes, whose parents match the parent process id.

From: =?UTF-8?B?SmFyb23DrXIgRG9sZcSNZWs=?= <jaromir.dolecek@gmail.com>
To: Utkarsh Anand <utkarsh009@yandex.com>
Cc: "gnats-bugs@NetBSD.org" <gnats-bugs@netbsd.org>
Subject: Re: lib/53125: sys/timevar.h is absent in installed systems.
Date: Sat, 24 Mar 2018 19:07:14 +0100

 --f403045d57322676d105682c6961
 Content-Type: text/plain; charset="UTF-8"

 2018-03-24 18:55 GMT+01:00 Utkarsh Anand <utkarsh009@yandex.com>:
 >
 >
 > >>  So what is the purpose of the code you are trying to get to compile
 and run, what kind of information do you need to get, why the standard
 POSIX interfaces are not sufficient?
 >
 > >>  Jaromir
 > Sorry, I forgot mentioning the purpose. It's a text editor, so the
 purpose was to edit files. It's a nice text editor with lots of plugins and
 themes (like https://github.com/mhartington/oceanic-next) along with all
 vim commands/macros.


 Thanks. I see it's editor.

 But why is the editor so special that the code needs to peek at kinfo_proc
 and growel kernel structures? Can you explain which particular field of
 that structure the code attemps to use, and for what exact purpose? Does it
 just need to show name of process which created lock file for example, or
 what exactly does it use the information from kinfo_proc for?

 It is possible there is truly portable interface for that purpose already.
 Maybe it was conceived in darker times when there was no other way than to
 peek through internal system headers, and now there maybe exists better way.

 Jaromir

 --f403045d57322676d105682c6961
 Content-Type: text/html; charset="UTF-8"
 Content-Transfer-Encoding: quoted-printable

 <div dir=3D"ltr">2018-03-24 18:55 GMT+01:00 Utkarsh Anand &lt;<a href=3D"ma=
 ilto:utkarsh009@yandex.com">utkarsh009@yandex.com</a>&gt;:<br>&gt;<br>&gt;<=
 br>&gt; &gt;&gt; =C2=A0So what is the purpose of the code you are trying to=
  get to compile and run, what kind of information do you need to get, why t=
 he standard POSIX interfaces are not sufficient?<br>&gt;<br>&gt; &gt;&gt; =
 =C2=A0Jaromir<br>&gt; Sorry, I forgot mentioning the purpose. It&#39;s a te=
 xt editor, so the purpose was to edit files. It&#39;s a nice text editor wi=
 th lots of plugins and themes (like <a href=3D"https://github.com/mhartingt=
 on/oceanic-next">https://github.com/mhartington/oceanic-next</a>) along wit=
 h all vim commands/macros.<br><br><br>Thanks. I see it&#39;s editor.<br><br=
 >But why is the editor so special that the code needs to peek at kinfo_proc=
  and growel kernel structures? Can you explain which particular field of th=
 at structure the code attemps to use, and for what exact purpose? Does it j=
 ust need to show name of process which created lock file for example, or wh=
 at exactly does it use the information from kinfo_proc for?<div><br></div><=
 div>It is possible there is truly portable interface for that purpose alrea=
 dy. Maybe it was conceived in darker times when there was no other way than=
  to peek through internal system headers, and now there maybe exists better=
  way.<br><br>Jaromir<br></div></div>

 --f403045d57322676d105682c6961--

From: Joerg Sonnenberger <joerg@bec.de>
To: gnats-bugs@NetBSD.org
Cc: lib-bug-people@netbsd.org, gnats-admin@netbsd.org,
	netbsd-bugs@netbsd.org, utkarsh009@yandex.com
Subject: Re: lib/53125: sys/timevar.h is absent in installed systems.
Date: Sat, 24 Mar 2018 19:08:38 +0100

 On Sat, Mar 24, 2018 at 06:05:01PM +0000, Utkarsh Anand wrote:
 >  24.03.2018, 23:12, "Utkarsh Anand" <utkarsh009@yandex.com>:
 >  
 >  > As shown here: https://github.com/neovim/neovim/blob/be67d926c5eec3b90cf906471f4b81ed21223c1f/src/nvim/os/process.c#L167
 >  > It wants to get a list of all processes and separate those processes that match parent process id. It seems to build in Linux, FreeBSD, and MacOSX.
 >  *those processes, whose parents match the parent process id.

 kvm_getproc2(3)

 Joerg

State-Changed-From-To: open->feedback
State-Changed-By: jdolecek@NetBSD.org
State-Changed-When: Sat, 24 Mar 2018 18:43:57 +0000
State-Changed-Why:
Does kvm_getproc2() resolve your need?


From: mlelstv@serpens.de (Michael van Elst)
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: lib/53125: sys/timevar.h is absent in installed systems.
Date: Sun, 25 Mar 2018 00:01:58 -0000 (UTC)

 bouyer@antioche.eu.org (Manuel Bouyer) writes:

 >You still don't explain what you want to do. _KMEMUSER use is restricted
 >even in the kernel, it's in no way designed to be used in userland.

 _KMEMUSER is meant for userland programs that peek kernel data structures.

 Most such programs have been adapted to use a sysctl interface instead,
 but even those may fall back to libkvm to analyse crash dumps and
 need access to internal kernel data structures.



 -- 
 -- 
                                 Michael van Elst
 Internet: mlelstv@serpens.de
                                 "A potential Snark may lurk in every tree."

From: mlelstv@serpens.de (Michael van Elst)
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: lib/53125: sys/timevar.h is absent in installed systems.
Date: Sun, 25 Mar 2018 00:07:36 -0000 (UTC)

 utkarsh009@yandex.com (Utkarsh Anand) writes:

 >In fact I don't get a single error in Linux?

 Indeed, part of the program needs to be ported to NetBSD.

 -- 
 -- 
                                 Michael van Elst
 Internet: mlelstv@serpens.de
                                 "A potential Snark may lurk in every tree."

From: Utkarsh Anand <utkarsh009@yandex.com>
To: "gnats-bugs@NetBSD.org" <gnats-bugs@netbsd.org>
Cc: 
Subject: Re: lib/53125: sys/timevar.h is absent in installed systems.
Date: Sun, 25 Mar 2018 06:36:16 +0530

 25.03.2018, 05:40, "Michael van Elst" <mlelstv@serpens.de>:

 >  Indeed, part of the program needs to be ported to NetBSD.
 I'll see what needs to be done and also check if kvm_getproc2() solves the issue and report back after sometime.

From: Utkarsh Anand <utkarsh009@yandex.com>
To: "gnats-bugs@NetBSD.org" <gnats-bugs@netbsd.org>
Cc: 
Subject: Re: lib/53125: sys/timevar.h is absent in installed systems.
Date: Sun, 25 Mar 2018 11:41:51 +0530

 25.03.2018, 06:36, "Utkarsh Anand" <utkarsh009@yandex.com>:
 > I'll see what needs to be done and also check if kvm_getproc2() solves the issue and report back after sometime.
 https://github.com/neovim/neovim/blob/f8d2aef4f20887bb5a407b5a34cd5dc29fc6771c/src/nvim/os/process.c#L169
 The above line feeds in all the constants/macros (which seek to extract out all the processes), and populates p_list with all the processes (which we want to be of kinfo_proc2()) 
 https://github.com/neovim/neovim/blob/f8d2aef4f20887bb5a407b5a34cd5dc29fc6771c/src/nvim/os/process.c#L179
 The above line intends to find out if the parent (i.e. the the process having its process id equal to `ppid' variable in the program) exists in the list of processes (p_list). If not it will  return with an exit code of 1 right here: https://github.com/neovim/neovim/blob/f8d2aef4f20887bb5a407b5a34cd5dc29fc6771c/src/nvim/os/process.c#L187
 https://github.com/neovim/neovim/blob/f8d2aef4f20887bb5a407b5a34cd5dc29fc6771c/src/nvim/os/process.c#L180
 The above line checks if the process in the current iteration has a parent process id equal to `ppid' (i.e. it is, if it is an immediate child of the parent). If so, it stores its pid in `temp' and increases `proc_count' by 1.
 The problem with kvm_getproc2() is that it requires the first argument to be of type kvm_t (which should hold the list of processes which is to be bifurcated). Where should we get that argument from? Furthermore, the man page says that we can get a list of all the processes by using `KERN_PROC_ALL' and https://nxr.netbsd.org/xref/src/lib/libkvm/kvm_proc.c#496 confirms that we don't need `name' to get it because we already have those extra constants/macros in there. So, the only problem seems to be to figure out what the rest of the arguments should be, and then we can replace sysctl(). The next snippet (which I've described above this paragraph), should remain the same.
 https://github.com/neovim/neovim/blob/f8d2aef4f20887bb5a407b5a34cd5dc29fc6771c/src/nvim/os/process.c#L155
 The above macros should automatically detect the required members, so now we don't need any special conditionals.

 Do note, however, that I am yet to test these changes. I will report back once after today's power cut is over (There's a festival today that requires power cut for, in worst case, until evening).

From: Utkarsh Anand <utkarsh009@yandex.com>
To: "gnats-bugs@NetBSD.org" <gnats-bugs@netbsd.org>
Cc: 
Subject: Re: lib/53125: sys/timevar.h is absent in installed systems.
Date: Wed, 28 Mar 2018 10:33:52 +0530

 Not sure what's happening when I try to compile this:
 //#define _KMEMUSER
 #include <stdio.h>
 #include <kvm.h>
 #include <sys/sysctl.h>
 #include <sys/param.h>
 #include <sys/fcntl.h>

 int main(){
 const char t[1] = {'\0'};
 kvm_t *kd = kvm_open(NULL,NULL,NULL,O_RDWR,t);
 int b;
 int *c = &b;
 struct kinfo_proc2 *a = kvm_getproc2(kd,KERN_PROC_ALL,0,9999999,c);
 printf("%d\n",a[0].p_pid);
 return 0;
 }

 Error:
 /var/tmp/temp-eb1f46.o: In function `main':
 temp.c:(.text+0x2e): undefined reference to `kvm_open'
 temp.c:(.text+0x5e): undefined reference to `kvm_getproc2'
 clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)

 With -v:
 clang version 5.0.0 (tags/RELEASE_500/final)
 Target: x86_64-unknown-netbsd8.0
 Thread model: posix
 InstalledDir: /usr/pkg/bin
  "/usr/pkg/bin/clang-5.0" -cc1 -triple x86_64-unknown-netbsd8.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name temp.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -v -dwarf-column-info -debugger-tuning=gdb -resource-dir /usr/pkg/lib/clang/5.0.0 -fdebug-compilation-dir /root/neovim -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gnustep -fdiagnostics-show-option -o /var/tmp/temp-07c81f.o -x c temp.c
 clang -cc1 version 5.0.0 based upon LLVM 5.0.0 default target x86_64-unknown-netbsd8.0
 #include "..." search starts here:
 #include <...> search starts here:
  /usr/pkg/lib/clang/5.0.0/include
  /usr/include
 End of search list.
  "/usr/bin/ld" --eh-frame-hdr -dynamic-linker /libexec/ld.elf_so -o temp /usr/lib/crt0.o /usr/lib/crti.o /usr/lib/crtbegin.o /var/tmp/temp-07c81f.o -lc /usr/lib/crtend.o /usr/lib/crtn.o
 /var/tmp/temp-07c81f.o: In function `main':
 temp.c:(.text+0x2e): undefined reference to `kvm_open'
 temp.c:(.text+0x5e): undefined reference to `kvm_getproc2'
 clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)

From: Thomas Klausner <wiz@NetBSD.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: lib/53125: sys/timevar.h is absent in installed systems.
Date: Wed, 28 Mar 2018 08:42:28 +0200

 On Wed, Mar 28, 2018 at 05:05:01AM +0000, Utkarsh Anand wrote:
 >  Not sure what's happening when I try to compile this:
 ...
 >  Error:
 >  /var/tmp/temp-eb1f46.o: In function `main':
 >  temp.c:(.text+0x2e): undefined reference to `kvm_open'
 >  temp.c:(.text+0x5e): undefined reference to `kvm_getproc2'
 >  clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)

 # man kvm_open
 NAME
      kvm_open, kvm_openfiles, kvm_close -- initialize kernel virtual memory
      access

 LIBRARY
      Kernel Data Access Library (libkvm, -lkvm)
 ...

 -> you need to link against libkvm.
  Thomas

From: =?UTF-8?B?SmFyb23DrXIgRG9sZcSNZWs=?= <jaromir.dolecek@gmail.com>
To: "gnats-bugs@NetBSD.org" <gnats-bugs@netbsd.org>
Cc: Utkarsh Anand <utkarsh009@yandex.com>
Subject: Re: lib/53125: sys/timevar.h is absent in installed systems.
Date: Wed, 28 Mar 2018 10:24:14 +0200

 Besides linking against libkvm, I'd suggest to also do other thing
 suggested by the kvm_open(3) manpage, and use use KVM_NO_FILES flags
 for kvm_open().
 And maybe consider using kvm_openfiles() - rationale is in the manpage also.

 Jaromir

 2018-03-28 8:45 GMT+02:00 Thomas Klausner <wiz@netbsd.org>:
 > The following reply was made to PR lib/53125; it has been noted by GNATS.
 >
 > From: Thomas Klausner <wiz@NetBSD.org>
 > To: gnats-bugs@NetBSD.org
 > Cc:
 > Subject: Re: lib/53125: sys/timevar.h is absent in installed systems.
 > Date: Wed, 28 Mar 2018 08:42:28 +0200
 >
 >  On Wed, Mar 28, 2018 at 05:05:01AM +0000, Utkarsh Anand wrote:
 >  >  Not sure what's happening when I try to compile this:
 >  ...
 >  >  Error:
 >  >  /var/tmp/temp-eb1f46.o: In function `main':
 >  >  temp.c:(.text+0x2e): undefined reference to `kvm_open'
 >  >  temp.c:(.text+0x5e): undefined reference to `kvm_getproc2'
 >  >  clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)
 >
 >  # man kvm_open
 >  NAME
 >       kvm_open, kvm_openfiles, kvm_close -- initialize kernel virtual memory
 >       access
 >
 >  LIBRARY
 >       Kernel Data Access Library (libkvm, -lkvm)
 >  ...
 >
 >  -> you need to link against libkvm.
 >   Thomas
 >

From: Utkarsh Anand <utkarsh009@yandex.com>
To: "gnats-bugs@NetBSD.org" <gnats-bugs@netbsd.org>
Cc: 
Subject: Re: lib/53125: sys/timevar.h is absent in installed systems.
Date: Wed, 28 Mar 2018 16:21:46 +0530

 Thanks to all for your inputs. I have created a pull request here: https://github.com/neovim/neovim/pull/8197 and filed a bug report here: https://github.com/neovim/neovim/issues/8196
 Please comment at the respective places if you'd like to.

From: Utkarsh Anand <utkarsh009@yandex.com>
To: "gnats-bugs@NetBSD.org" <gnats-bugs@netbsd.org>
Cc: 
Subject: Re: lib/53125: sys/timevar.h is absent in installed systems.
Date: Wed, 28 Mar 2018 17:10:26 +0530

 Has anybody already asked about this problem on IRC/gitter: https://github.com/neovim/neovim/issues/8196
 The owner of the repository says so. If yes, please let me know about it ASAP.

State-Changed-From-To: feedback->closed
State-Changed-By: utkarsh009@NetBSD.org
State-Changed-When: Wed, 28 Mar 2018 16:53:40 +0000
State-Changed-Why:
Although libkvm solves the issue, it was decided that we use sysctl() with kinfo_proc2.

From: Utkarsh Anand <utkarsh009@yandex.com>
To: "gnats-bugs@NetBSD.org" <gnats-bugs@netbsd.org>
Cc: 
Subject: Re: lib/53125: sys/timevar.h is absent in installed systems.
Date: Thu, 29 Mar 2018 13:27:35 +0530

 Looks like the pull request is going to be merged soon. Meanwhile, would anyone
 like to create a package for it?

From: Leonardo Taccari <leot@NetBSD.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: lib/53125: sys/timevar.h is absent in installed systems.
Date: Thu, 29 Mar 2018 10:18:53 +0200

 Hello Utkarsh,

 Utkarsh Anand writes:
 >  Looks like the pull request is going to be merged soon. Meanwhile, woul=
 d anyone
 >  like to create a package for it?

 For neovim? In pkgsrc-wip there are neovim-git and neovim packages (no
 idea about the current status of it though) and ATM we're in freeze for
 2018Q1.

 As a side note I think it's better to move further discussion about
 neovim and its porting to tech-pkg@.


 Thank you!

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.