Re: dtrace noob: How is it used?
Hello, > Trying to use dtrace on my drm-next kernel that leaks memory to the > extent that all swap space gets filled. > easy enogh: kldload dtraceall > > But which parameters and exactly how am I supposed to capture > afterwards? I assume most useful info would be a) memory leaks per > minute and b) source of leak. Wiki page was not much help for > understanding usage: https://wiki.freebsd.org/DTrace/One-Liners From my understanding, I don't think there are scripts that can explicltly tell you that there have been memory leaks somewhere, but FreeBSD, upon unloading a module will tell you that a given module has leaked X bytes of memory. However, DTrace on FreeBSD has a dtmalloc provider, which lets you inspect quite a bit of things based on named memory in the kernel. You could try using that in order to detect which memory hasn't been freed based on the expected code flow in the kernel. To do this, you would have to look at the kernel code of interest, use the fbt provider in order to instrument the problems you want, and based on that inspect whether or not a given dtmalloc probe has fired with a given memory region (if you have access to it). Aside from that, I'm not aware of any other way to go about it. > * /usr/share/dtrace has scirpts, are those sufficient for the problem > or should I add sysutils/DTraceToolkit? > * Which script(s) would provide adequate info for this problem and how > could I log a per minute (or perhaps per event) output from the probes? The DTrace Toolkit is largely written with Solaris (now illumos) in mind, so there is a chance that some scripts in there might not work. -- Best regards, Domagoj Stolfa signature.asc Description: PGP signature
Re: fbt:kernel:breadn_flags:entry): invalid address (0x0) in action #7
Hello, > Thats exactly what I did. Could you please supply the full script please? It might give some clue as to where the problem is. -- Best regards, Domagoj Stolfa signature.asc Description: PGP signature
Re: fbt:kernel:breadn_flags:entry): invalid address (0x0) in action #7
Hello, > My problem is: The probe fbt:kernel:breadn_flags:entry should fire in > the case args[6] == 0, the case args[6] != 0 works but is not important > to me. What you want is: fbt:kernel:breadn_flags:entry /args[6] == 0/ { ... } Hope it helps! -- Best regards, Domagoj Stolfa signature.asc Description: PGP signature
Re: Versions
Hi Michael: Thanks for making the SCTP probes! The 1.6.3 bit probably comes from the version of the API that D exposes, as seen here: https://github.com/freebsd/freebsd/blob/master/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c#L137. Adding new things should probably be done in the latest version i.e. 1.13 -- but I may be wrong (this is mainly by skimming the dt_pragma.c code to see what "binding" does. — Domagoj > On 12 Jun 2018, at 10:44, Michael Tuexen wrote: > > Dear all, > > I'm implementing dtrace probe for SCTP and have a simple question for you. > > In dtrace files, for example udp.d there are lines like > > #pragma D binding "1.6.3" translator > > The question is: Where does 1.6.3 come from? > > Probably it comes from > http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libdtrace/common/udp.d.in > > I'll derive the SCTP related stuff from the oracle documentation available at > https://docs.oracle.com/cd/E37838_01/html/E61035/glhgu.html#OSDTGgqcjh > > sctp.d is not available in Illumos. Which version number should I use? > > Best regards > Michael > > ___ > freebsd-dtrace@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-dtrace > To unsubscribe, send any mail to "freebsd-dtrace-unsubscr...@freebsd.org" ___ freebsd-dtrace@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-dtrace To unsubscribe, send any mail to "freebsd-dtrace-unsubscr...@freebsd.org"
Re: Include header files in dtrace scripts
Hi Farhan: You should call DTrace with -C, which is the C preprocessor: --- #!/usr/sbin/dtrace -Cs #include #include #include #include --- — Domagoj > On 5 Aug 2018, at 06:43, Farhan Khan wrote: > > Hi all, > > I am trying to run dtrace on some net80211 functions in the kernel. > Rather than recreate my own version of several fairly large structs, > which would be a lot of work, I would like to just include > net80211/ieee80211_var.h and related headers. > > Brendan Gregg's book has examples of using #include, but when I do this: > > --- > #!/usr/sbin/dtrace -s > > #include > #include > #include > #include > --- > > I get this error: > > --- > $ sudo ./newstate.d > dtrace: failed to compile script ./newstate.d: line 3: invalid control > directive: #include > --- > > Is there a way to include header files and get their subsequent structs? > > Thanks, > > -- > Farhan Khan > PGP Fingerprint: B28D 2726 E2BC A97E 3854 5ABE 9A9F 00BC D525 16EE > ___ > freebsd-dtrace@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-dtrace > To unsubscribe, send any mail to "freebsd-dtrace-unsubscr...@freebsd.org" signature.asc Description: Message signed with OpenPGP
Re: Filter out dtrace(1) probes
Hi Farhan: I'm not sure what the question is, but by what I understood it sounds like a predicate with probefunc should do? i.e.: prov:mod:func:name /probefunc != "something_i_dont_care_about"/ { something_here } — Domagoj > On 17 Aug 2018, at 00:49, Farhan Khan wrote: > > Hi all, > > Is it possible to filter out probes? > For example, if I did: > > dtrace -n 'fbt:kernel::entry { something_here }' > > but I specifically do not want fbt:entry:SOMETHING:entry, is that > possible? I know that I can run grep -v, but it still shows the output > from "something_here". > > Thank you, > -- > Farhan Khan > PGP Fingerprint: B28D 2726 E2BC A97E 3854 5ABE 9A9F 00BC D525 16EE > ___ > freebsd-dtrace@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-dtrace > To unsubscribe, send any mail to "freebsd-dtrace-unsubscr...@freebsd.org" signature.asc Description: Message signed with OpenPGP
Re: DTrace bi-weekly discussion today
Depending on my ability to cycle home quickly enough -- I may or may not be late. — Domagoj > On 27 Sep 2018, at 14:57, George Neville-Neil wrote: > > Howdy, > > We'll be having our bi-weekly DTrace conference call today, 27 Sep 2018 at > 12:00 EST. We'll be using Google Hangouts: > > https://www.freebsdfoundation.org/mtg/journal > > Best, > George > ___ > freebsd-dtrace@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-dtrace > To unsubscribe, send any mail to "freebsd-dtrace-unsubscr...@freebsd.org" ___ freebsd-dtrace@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-dtrace To unsubscribe, send any mail to "freebsd-dtrace-unsubscr...@freebsd.org"
Structured/machine-readable output for DTrace
Hi: I've implemented machine-readable output in the form of JSON, XML and HTML into libdtrace, and by extension dtrace(1) using libxo. The goal is not to replace linking to libdtrace in any way when one wishes to build a custom application around it, but rather to supplement it (as it would now also support this form of output by default) and act as a middle-ground between linking directly to libdtrace and parsing the pretty-printed dtrace(1) output that is available today (but not replace it). In order to get it to work, you can simply run dtrace(1) as normal, but add -x oformat=json|xml|html|plain. I've posted the patch up for review if anyone wants to take a look or try it out [1] and posted a hacked up Python program (by no means good Python code) as an example of how this might be used [2]. I would appreciate any feedback you might have. As this patch is still in its early stages however, there isn't much documentation available for it. I aim to address this soon. [1]: https://reviews.freebsd.org/D41745 [2]: https://reviews.freebsd.org/D41745 -- Domagoj
Re: Converting int to a string in DTrace
Hi Mateusz: I believe that lltostr might be what you're looking for? this->unit_number = args[1]->unit_number >= 0 ? lltostr(args[1]->unit_number) : ""; -- Domagoj On 8/30/2022 4:49 PM, Mateusz Piotrowski wrote: Hello everyone, Is it possible to convert an int to a string in DTrace? E.g., I'd like the following script to work (it's an example from dtrace_io(4), but with device unit number added): #!/usr/sbin/dtrace -s #pragma D option quiet io:::start { this->unit_number = args[1]->unit_number >= 0 ? (string)args[1]->unit_number : ""; @[args[1]->device_name, this->unit_number, execname, pid] = sum(args[0]->bio_bcount); } END { printf("%10s%-3s %20s %10s %15s\n", "DEVICE", "", "APP", "PID", "BYTES"); printa("%10s%-3s %20s %10d %15@d\n", @); } (Of course, the `(string)` cast does not work here because it's just not how DTrace works.) Best, Mateusz
Re: Converting int to a string in DTrace
I'm not sure if it's documented anywhere in FreeBSD itself, but it is documented here: https://illumos.org/books/dtrace/chp-actsub.html. -- Domagoj On 8/30/2022 5:01 PM, Mateusz Piotrowski wrote: Hey Domagoj! On 30. Aug 2022, at 17:58, Domagoj Stolfa wrote: this->unit_number = args[1]->unit_number >= 0 ? lltostr(args[1]->unit_number) : ""; This is exactly what I was looking for, thanks! Is it documented somewhere on FreeBSD? Best, Mateusz
Query about work with/on DTrace
Hi: I'm in the process of writing an article for the FreeBSD Journal regarding DTrace and was hoping to get some submissions of what people are working on in what would be called the "exciting new work" part of the article. If you'd like to share your work with a quick summary and link to it for it to be included, feel free to email me! -- Domagoj
Re: USDT support (in build framework)?
Hi: I've done this for bhyve, specifically for virtio-net. I believe this is the whole patch I needed: +OBJS:=bhyve_provider.o ${OBJS} +DTRACE_OBJS=${SRCS:C/\.c/.o/} + +beforelinking: + dtrace -G -s ${BHYVE_SRCDIR}/bhyve_provider.d ${DTRACE_OBJS} + however, it has been a while and I don't 100% recall if anything else was necessary. I had to create a helper DTRACE_OBJS because using OBJS would cause linking to fail later on. I'm sure there are better ways of doing it, but this seems to work for me. Let me know if it fails! The provider itself is: provider netbe { probe tap__recv(char *, void *); probe tap__send(char *, void *); }; and the probes can be called as follows: DTRACE_PROBE2(netbe, tap__recv, g_vmname, mbufidp); Hope this helps! -- Domagoj On 3/23/2023 1:09 AM, Bjoern A. Zeeb wrote: Hi, https://wiki.freebsd.org/DTrace/userland says it is outdated. Do we have any description on how one we would add USDT support to base system applications? Or do we support this at all? /bz