moncontrol(3), gprof(1): write, read gmon profiling data via utrace(2)

2023-06-18 Thread Scott Cheloha
This patch changes libc's _mcleanup() function so it serializes gmon profiling data with utrace(2). gprof(1) is also modified: it can now deserialize that profiling data from a ktrace(2) file. Only apply this patch if you are testing the profclock() patch. Index: lib/libc/gmon/g

Re: patch: profiling using utrace(2) (compatible with pledge and unveil)

2023-05-19 Thread Sebastien Marie
ut then I > noticed that "good" and "bad" data can be gathered for different run > of the same executable. > > Compare for example > > https://ftp.omarpolo.com/tmp/pack-got/profile.got-read-pack.52583.png > (bad) > > and > > https://ftp.omarp

Re: patch: profiling using utrace(2) (compatible with pledge and unveil)

2023-05-08 Thread Job Snijders
Hi Sebastien, Super super interesting stuff! On Tue, Apr 11, 2023 at 09:28:31AM +0200, Sebastien Marie wrote: > ## compile and collect profil information (-tu option on ktrace is optional) > $ cc -static -pg test.c > $ ktrace -di -tu ./a.out > > ## get gmon.out file > $ kdump -u gmon.out | unvis

Re: patch: profiling using utrace(2) (compatible with pledge and unveil)

2023-05-04 Thread Omar Polo
On 2023/04/11 09:28:31 +0200, Sebastien Marie wrote: > Hi, > > After otto@ work on mallocdump using utrace(2), I started to look again at > profiling (see moncontrol(2)). > > The current implementation tries to write a gmon.out file at program exit(3) > time, which

Re: MALLOC_STATS: dump internal state and leak info via utrace(2)

2023-04-15 Thread Otto Moerbeek
n be compiled with MALLOC_STATS > > > > > > > > > defined. If run > > > > > > > > > with option D it dumps its state to a malloc.out file at > > > > > > > > > exit. This > > > > >

Re: MALLOC_STATS: dump internal state and leak info via utrace(2)

2023-04-13 Thread Otto Moerbeek
ate to a malloc.out file at exit. > > > > > > > > This > > > > > > > > state can be used to find leaks amongst other things. > > > > > > > > > > > > > > > > This is not ideal for pledged processes, as

Re: MALLOC_STATS: dump internal state and leak info via utrace(2)

2023-04-11 Thread Otto Moerbeek
compiled with MALLOC_STATS defined. If > > > > > > > run > > > > > > > with option D it dumps its state to a malloc.out file at exit. > > > > > > > This > > > > > > > state can be used to find leaks amongst other thing

Re: patch: profiling using utrace(2) (compatible with pledge and unveil)

2023-04-11 Thread Theo de Raadt
Sebastien Marie wrote: > For post-execution gmon.out extraction, an helper might be needed: ktrace.out > could contain multiple gmon.out files. kdump can be taught to generate the right file.

patch: profiling using utrace(2) (compatible with pledge and unveil)

2023-04-11 Thread Sebastien Marie
Hi, After otto@ work on mallocdump using utrace(2), I started to look again at profiling (see moncontrol(2)). The current implementation tries to write a gmon.out file at program exit(3) time, which isn't compatible with pledge(2) or unveil(2). This diff changes the way the runtime prof

Re: MALLOC_STATS: dump internal state and leak info via utrace(2)

2023-04-09 Thread Sebastien Marie
r 2023 10:16:11 - > @@ -284,10 +284,13 @@ If it has been corrupted, the process is > .It Cm D > .Dq Dump . > .Fn malloc > -will dump statistics to the file > -.Pa ./malloc.out , > -if it already exists, > +will dump statistics using > +.Xr utrace 2 > at exit. &

Re: MALLOC_STATS: dump internal state and leak info via utrace(2)

2023-04-09 Thread Otto Moerbeek
is > > > > > > state can be used to find leaks amongst other things. > > > > > > > > > > > > This is not ideal for pledged processes, as they often have no way > > > > > > to > > > > > > write files. > >

Re: MALLOC_STATS: dump internal state and leak info via utrace(2)

2023-04-09 Thread Sebastien Marie
On Sun, Apr 09, 2023 at 10:08:25AM +0200, Claudio Jeker wrote: > On Sun, Apr 09, 2023 at 09:15:12AM +0200, Otto Moerbeek wrote: > > On Sun, Apr 09, 2023 at 08:20:43AM +0200, Otto Moerbeek wrote: > > I would prefer if every utrace() call is a full line (in other words ulog > should be line buffered

Re: MALLOC_STATS: dump internal state and leak info via utrace(2)

2023-04-09 Thread Claudio Jeker
e compiled with MALLOC_STATS defined. If run > > > > > with option D it dumps its state to a malloc.out file at exit. This > > > > > state can be used to find leaks amongst other things. > > > > > > > > > > This is not ideal for pledged pr

Re: MALLOC_STATS: dump internal state and leak info via utrace(2)

2023-04-09 Thread Sebastien Marie
.Op Fl t Ar trstr > +.Op Fl u Ar word I would use the term 'label' (instead of 'word'), as it is the way it is called inside utrace(2) man page. > .Sh DESCRIPTION > .Nm > displays the kernel trace files produced with > @@ -106,6 +107,18 @@ See the > opt

Re: MALLOC_STATS: dump internal state and leak info via utrace(2)

2023-04-09 Thread Otto Moerbeek
at exit. This > > > > state can be used to find leaks amongst other things. > > > > > > > > This is not ideal for pledged processes, as they often have no way to > > > > write files. > > > > > > > > This changes malloc to

Re: MALLOC_STATS: dump internal state and leak info via utrace(2)

2023-04-08 Thread Otto Moerbeek
> > This is not ideal for pledged processes, as they often have no way to > > > write files. > > > > > > This changes malloc to use utrace(2) for that. > > > > > > As kdump has no nice way to show those lines without all extras it > > > no

Re: MALLOC_STATS: dump internal state and leak info via utrace(2)

2023-04-08 Thread Sebastien Marie
TATS defined. If run > > with option D it dumps its state to a malloc.out file at exit. This > > state can be used to find leaks amongst other things. > > > > This is not ideal for pledged processes, as they often have no way to > > write files. > > > > This

Re: MALLOC_STATS: dump internal state and leak info via utrace(2)

2023-04-07 Thread Otto Moerbeek
ption D it dumps its state to a malloc.out file at exit. This > state can be used to find leaks amongst other things. > > This is not ideal for pledged processes, as they often have no way to > write files. > > This changes malloc to use utrace(2) for that. > > As kdu

MALLOC_STATS: dump internal state and leak info via utrace(2)

2023-04-05 Thread Otto Moerbeek
ongst other things. This is not ideal for pledged processes, as they often have no way to write files. This changes malloc to use utrace(2) for that. As kdump has no nice way to show those lines without all extras it normally shows, so add two options to it to just show the lines. To use, compil

unlock utrace(2) syscall

2023-02-15 Thread Claudio Jeker
The following diff should allow most of utrace to run without kernel lock. It makes utrace() less expensive if ktrace is not used. -- :wq Claudio Index: kern/kern_ktrace.c === RCS file: /cvs/src/sys/kern/kern_ktrace.c,v retrieving r

Re: utrace(2)

2011-07-18 Thread Otto Moerbeek
On Mon, Jul 18, 2011 at 11:35:42AM +0200, Otto Moerbeek wrote: > On Tue, Jul 12, 2011 at 05:52:09PM +0200, Otto Moerbeek wrote: > > > Hi, > > > > The diff below implements utrace(2), a syscall to introduce data into > > a ktrace stream from a userland program. &

Re: utrace(2)

2011-07-18 Thread Kristaps Dzonsons
Hi, Index: lib/libc/sys/utrace.2 === RCS file: lib/libc/sys/utrace.2 diff -N lib/libc/sys/utrace.2 --- /dev/null 1 Jan 1970 00:00:00 - +++ lib/libc/sys/utrace.2 18 Jul 2011 09:28:15 - @@ -0,0 +1,93

Re: utrace(2)

2011-07-18 Thread Otto Moerbeek
On Tue, Jul 12, 2011 at 05:52:09PM +0200, Otto Moerbeek wrote: > Hi, > > The diff below implements utrace(2), a syscall to introduce data into > a ktrace stream from a userland program. > > The interface is taken from netbsd, freebsd also has a utrace(2) > syscall, but lac

Re: utrace(2)

2011-07-12 Thread Ariane van der Steldt
On Tue, Jul 12, 2011 at 05:52:09PM +0200, Otto Moerbeek wrote: > The diff below implements utrace(2), a syscall to introduce data into > a ktrace stream from a userland program. > > The interface is taken from netbsd, freebsd also has a utrace(2) > syscall, but lacks the label argu

Re: utrace(2)

2011-07-12 Thread Matthew Dempsky
#x27;t want to have to add another stub to the ramdisk build bits...) Agreed, I think utrace(2) should always be implemented, and just not do anything if the kernel's compiled without KTRACE.

Re: utrace(2)

2011-07-12 Thread Philip Guenther
On Tue, Jul 12, 2011 at 8:52 AM, Otto Moerbeek wrote: ... > diff -u -p -r1.117 syscalls.master > --- sys/kern/syscalls.master9 Jul 2011 05:46:26 - 1.117 > +++ sys/kern/syscalls.master12 Jul 2011 14:59:03 - > @@ -572,3 +572,9 @@ >int flag); } > 326

Re: utrace(2)

2011-07-12 Thread Ted Unangst
On Tue, Jul 12, 2011, Otto Moerbeek wrote: > The diff below implements utrace(2), a syscall to introduce data into > a ktrace stream from a userland program. > Index: sys/kern/kern_ktrace.c > === > RCS file: /c

utrace(2)

2011-07-12 Thread Otto Moerbeek
Hi, The diff below implements utrace(2), a syscall to introduce data into a ktrace stream from a userland program. The interface is taken from netbsd, freebsd also has a utrace(2) syscall, but lacks the label argument. You could uise this as a debugging aid, to get tarce information intermixed