Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 13 Dec 2025 12:12:12 -0800
From:      Steve Kargl <kargls@comcast.net>
To:        Ahmad Khalifa <ahmadkhalifa570@gmail.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: profiling a user executable?
Message-ID:  <fab8d9ea-2640-43ed-96e5-8cd90b0c620e@comcast.net>
In-Reply-To: <CAMLT6uBhCTz3W6LN4M-oqp2B8A8_oPswJ%2BK5SyCxcXsim94waw@mail.gmail.com>
References:  <f32da5eb-1c80-48a2-a990-c762a8258495@comcast.net> <CAMLT6uBhCTz3W6LN4M-oqp2B8A8_oPswJ%2BK5SyCxcXsim94waw@mail.gmail.com>

index | next in thread | previous in thread | raw e-mail

On 12/12/25 14:14, Ahmad Khalifa wrote:
> On Thu Dec 11, 2025 at 8:13 PM +0200, Steve Kargl wrote:
>> In the days of yore, one could add the '-pg' option to
>> the compilers options to generate profiling information,
>> which could be consumed by gprof(1).
>>
>> FreeBSD stopped shipping libc_p.a, libm_p.m, etc
>> (disabled in fe52b7f60ef4 and deleted in 3750ccefb8).
>> This breaks all lang/gcc* ports if one uses '-pg'.  It is
>> not too difficult to fix lang/gcc* to avoid the missing
>> *_p.a files, but this seems to lead to invalid *.gmon files.
>> At least, for a Fortran application that I would like to
>> profile (compiled with gfortran), procedures in my libfoo_p.a,
>> appear in the profile, which I know with 100% certainty are
>> not referenced.
>>
>> So, how does one in modern FreeBSD, as mere normal user,
>> profile an executable?  A google search suggests pmcstat(8)
>> may be of use, but all attempts to use it lead to a usage
>> message printed to the terminal.  I'm simply trying to
>> determine where my code is spending all of its time.
> 
> Just throwing in another option, you can use dtrace's profile-n probes.
> 

dtrace appears to be a useless for a mere user.

% dtrace -n 'profile-99 /execname == "../../build/bin/tier -q"/ \
    { @[ustack()] = count(); }'
dtrace: failed to initialize dtrace: DTrace requires
    additional privileges

Interestingly, dtrace(1) seems to lack a discussion about privilege.
At least, 'man dtrace' with a search on 'priv' and 'group' reveals
nothing useful.

-- 
steve



help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?fab8d9ea-2640-43ed-96e5-8cd90b0c620e>