101010.pl is one of the many independent Mastodon servers you can use to participate in the fediverse.
101010.pl czyli najstarszy polski serwer Mastodon. Posiadamy wpisy do 2048 znaków.

Server stats:

483
active users

#dtrace

0 posts0 participants0 posts today

If you are using #DTrace on #FreeBSD, then I've got good news for you.

I've added a new manual to FreeBSD. It's called d(7) and it is a short reference of the #D scripting language. Currently, it covers only a subset of all variables and functions, but we'll add more iteratively.

Here are some previews for you:

HTML: people.freebsd.org/~0mp/d.7.ht

MDOC (view with man(1)): people.freebsd.org/~0mp/d.7

Have fun tracing your systems!

people.freebsd.orgD(7)
#osdev#tracing#foss

I've just committed a new manual page to #FreeBSD: tracing(7), an introduction to #tracing and #performance #monitoring facilities.

It'll take a moment before it is available for readers on man.freebsd.org, so for the time being you can grab a copy from here (cgit.freebsd.org/src/plain/sha) and open it with man(1).

cgit.freebsd.orgMaking sure you're not a bot!

I just released a long blog post about using #dtrace on #macOS to debug a thorny bug in the macOS kernel that was breaking #Lix's socket disconnect detection.

It goes through what the fault was, how I found it, where to find information about DTrace on macOS (which is not really well documented), and how the macOS kernel's networking/events system works at a high level. It also explains how one can take an unfamiliar kernel and quickly find relevant code.

jade.fyi/blog/misadventures-in

jade.fyiMisadventures in DTrace: how to debug the macOS kernelcomputers i guess

Enabling DTrace in Python on FreeBSD (again)

antranigv.am/posts/2025/02/dtr

Last night I was running our usual Greybeard AMA on FreeBSD’s Discord server, when someone asked “I’ve been using Linux for years, but I also like FreeBSD. what can I do for FreeBSD, and what can FreeBSD do for me, as a Python Full Stack Developer?”

I started talking about FreeBSD Jails, ZFS, Boot Environments and more, but I also wanted to focus on DTrace. The ability to dynamically trace on production still sounds like magic to me. I know it isn’t, I’ve read the code and the papers, but the fact that I can ask the operating system questions on the fly, without recompiling, is amazing.

So when I was demoing DTrace, I also wanted to show the DTrace integrations with Python. Little did I know that the Python package on FreeBSD was not compiled with the --with-dtrace option.

As a sane person, I setup a Jail (using Jailer, of course), cloned the FreeBSD ports tree and added the --with-dtrace option back. It did not compile.

The first issue that we encountered was the following:

--- Include/pydtrace_probes.h ---dtrace: option requires an argument -- s

ah yes, looking over the Makefile we see the following

Include/pydtrace_probes.h: $(srcdir)/Include/pydtrace.d    $(MKDIR_P) Include    $(DTRACE) $(DFLAGS) -o $@ -h -s $<    : sed in-place edit with POSIX-only tools    sed 's/PYTHON_/PyDTrace_/' $@ > $@.tmp    mv $@.tmp $@

(you can also view the source here)

As far as I can tell, the $< thingie does not work with BSD Make, so how about if we try using gmake instead?

I did the following changes to the Makefile in the FreeBSD Ports tree. Basically adding gmake into USES=.

 USES=          compiler:c11 cpe ncurses pathfix pkgconfig \-               python:${PYTHON_DISTVERSION:R},env readline shebangfix ssl tar:xz+               python:${PYTHON_DISTVERSION:R},env readline shebangfix ssl tar:xz gmake

Now let’s try compiling again.

We get the following errors now:

ld: error: undefined symbol: __dtraceenabled_python___function__entry

Ah yes, linking issues.

After an hour of digging we learned that the DTRACE_OBJS= variable is set to… nothing. But it needs to be set to Python/pydtrace.o. I was not able to fix this issue properly (in configure, configure.ac, or whatever madness that GNU Autotools use), so I just changed the line manually in the Makefile.

Now let’s try compiling again.

We get the following error:

./Python/sysmodule.c:223:24: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]

Someone in the Discord chat recommended that I disable the LTO (Link-Time Optimization) option.

I did make clean, I patched that line again, and here we go, one more time.

It’s compiling, it’s compiling, it’s compiling… aaaaand we’re done! Let’s do make install

===>  Installing for python311-3.11.11===>  Checking if python311 is already installed===>   Registering installation for python311-3.11.11[python.srv0.hackerspace.am] Installing python311-3.11.11...

good! now let’s try DTrace with Python!

In one terminal, I ran Python, and in another one I got the following

# dtrace -l -n 'python*:::'   ID   PROVIDER            MODULE                          FUNCTION NAME85302 python8737 libpython3.11.so.1.0                         sys_audit audit85303 python8737 libpython3.11.so.1.0                  sys_audit_tstate audit85304 python8737 libpython3.11.so.1.0          _PyEval_EvalFrameDefault function-entry85305 python8737 libpython3.11.so.1.0            dtrace_function_return function-return85306 python8737 libpython3.11.so.1.0          _PyEval_EvalFrameDefault function-return85307 python8737 libpython3.11.so.1.0                   gc_collect_main gc-done85308 python8737 libpython3.11.so.1.0                   gc_collect_main gc-start85309 python8737 libpython3.11.so.1.0  PyImport_ImportModuleLevelObject import-find-load-done85310 python8737 libpython3.11.so.1.0  PyImport_ImportModuleLevelObject import-find-load-start85311 python8737 libpython3.11.so.1.0          _PyEval_EvalFrameDefault line

Woohoo! Now I’m happy!

Okay, so what did we learn?

  • There’s a little bit of GNUMake-ism in Python’s Makefile. Either we have to use gmake in FreeBSD when building Python or we need to submit an alternative to the upstream
  • Die GNU Autotools… I mean… the GNU Autotools usage in Python has an issue, where the generated Makefile does not set the DTRACE_OBJS correctly. Can anyone help with this? As a Pascal guy, reading GNU configure files makes me wanna die.
  • LTO is problematic. Solutions?

The real question is, how can we enable DTrace by default in FreeBSD packages for Python. DTrace is one of our market advantages and we should find a way to enable it everywhere we can.

This was a fun Greybeard AMA, where we touched multiple parts of the system. Looking forward for next week!

That’s all folks…

Reply via email.

antranigv.amEnabling DTrace in Python on FreeBSD (again) | Antranig Vartanian
More from Antranig Vartanian

Today I am hugely thankful that #NetBSD has #DTrace. It is making debugging this #bhyve UART issue significantly easier when I can see things clearly from the guest side.

That said, it's a little frustrating that I can't trace bus_space_*() as they are implemented in assembly without DTrace hooks, and the functions that call them are inlined away.

Seeing a _very_ strange issue since upgrading to #macOS Sonoma.

I mentioned the other day that the check-portability script was taking too much CPU time.

Well, it fails every single time inside a bulk build, but only in lang/rust. The cputime soft limit is being set to 3600, but the process is always killed after only a few seconds.

I'm even running #dtrace to confirm that setrlimit is only ever being called with rlim_cur=3600.

No source code, so can't trace what's happening in the kernel :(

We're hiring!

mnxsolutions.com/careers/senio

Come and help us maintain and enhance a fully open-source operating system and cloud stack that has been battle-tested in very large production environments.

There are plenty of interesting problems to solve, all the way from writing device drivers and debugging early boot issues, to writing new UIs in Rust.

I think we're a pretty friendly team to work alongside too ;)

Happy to answer any questions.

www.mnxsolutions.comSenior Backend Developer - MNX Solutions | Monroe MISenior Backend Developer for Triton DataCenter

I was wondering why my macOS pkgsrc builds were running slower than usual. clang running very slowly and burning CPU. Time to break out DTrace!

dtrace: failed to grab pid 290: DTrace cannot instrument translated processes

Um, wat? It can't be translated, these are all native ARM64 processes!

$ arch
arm64
$ chroot /chroot/pkgsrc-macos11-trunk-arm64 arch
i386

Sigh.

No idea what's changed recently to cause that, but at least 'arch -arm64e chroot' fixes it.

Continued thread

I forgot one other fix, this time to our internal build infrastructure.

We use -msave-args in all of our package builds so that we get proper #DTrace and #mdb function arguments.

Unfortunately this does not work with clang, and there are a few packages that specify clang as their compiler.

So now github.com/TritonDataCenter/pk ensures we don't use GCC-only flags in those packages.

GitHubRemove GCC-only args from packages using clang. · TritonDataCenter/pkgbuild@2bd348dpkgsrc build infrastructure. Contribute to TritonDataCenter/pkgbuild development by creating an account on GitHub.