aboutsummaryrefslogtreecommitdiff
path: root/cddl/contrib/opensolaris/cmd/dtrace
Commit message (Collapse)AuthorAgeFilesLines
* dtrace tests: Add a test case which validates FBT probe argumentsMark Johnston2024-09-192-0/+37
| | | | | | Reviewed by: avg MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D46674
* sdt: Implement SDT probes using hot-patchingMark Johnston2024-06-191-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The idea here is to avoid a memory access and conditional branch per probe site. Instead, the probe is represented by an "unreachable" unconditional function call. asm goto is used to store the address of the probe site (represented by a no-op sled) and the address of the function call into a tracepoint record. Each SDT probe carries a list of tracepoints. When the probe is enabled, the no-op sled corresponding to each tracepoint is overwritten with a jmp to the corresponding label. The implementation uses smp_rendezvous() to park all other CPUs while the instruction is being overwritten, as this can't be done atomically in general. The compiler moves argument marshalling code and the sdt_probe() function call out-of-line, i.e., to the end of the function. Per gallatin@ in D43504, this approach has less overhead when probes are disabled. To make the implementation a bit simpler, I removed support for probes with 7 arguments; nothing makes use of this except a regression test case. It could be re-added later if need be. The approach taken in this patch enables some more improvements: 1. We can now automatically fill out the "function" field of SDT probe names. The SDT macros let the programmer specify the function and module names, but this is really a bug and shouldn't have been allowed. The intent was to be able to have the same probe in multiple functions and to let the user restrict which probes actually get enabled by specifying a function name or glob. 2. We can avoid branching on SDT_PROBES_ENABLED() by adding the ability to include blocks of code in the out-of-line path. For example: if (SDT_PROBES_ENABLED()) { int reason = CLD_EXITED; if (WCOREDUMP(signo)) reason = CLD_DUMPED; else if (WIFSIGNALED(signo)) reason = CLD_KILLED; SDT_PROBE1(proc, , , exit, reason); } could be written SDT_PROBE1_EXT(proc, , , exit, reason, int reason; reason = CLD_EXITED; if (WCOREDUMP(signo)) reason = CLD_DUMPED; else if (WIFSIGNALED(signo)) reason = CLD_KILLED; ); In the future I would like to use this mechanism more generally, e.g., to remove branches and marshalling code used by hwpmc, and generally to make it easier to add new tracepoint consumers without having to add more conditional branches to hot code paths. Reviewed by: Domagoj Stolfa, avg MFC after: 2 months Differential Revision: https://reviews.freebsd.org/D44483
* dtrace tests: Catch up with ping(8) output changesMark Johnston2024-01-101-1/+1
| | | | MFC after: 1 week
* dtrace tests: Stop hard-coding an incorrect path to sleep(1)Mark Johnston2024-01-104-4/+4
| | | | MFC after: 1 week
* dtrace tests: Run ksh with -pMark Johnston2024-01-1010-10/+10
| | | | | | | | In particular, avoid loading the user's .profile file, since that can have undesirable side effects. Most tests were already careful to do this. MFC after: 1 week
* dtrace: Add the 'oformat' libdtrace optionDomagoj Stolfa2024-01-1028-9/+2132
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This option can be used to specify a format to use in DTrace output. The following formats are supported: - json - xml - html - none (default DTrace output) This is implemented using libxo and integrated into libdtrace. Client code only works with the following API: - dtrace_oformat_setup(dtrace_hdl_t *) -- to be called when output is starting. - dtrace_oformat_teardown(dtrace_hdl_t *) -- to be called when output is finished - dtrace_oformat(dtrace_hdl_t *) -- check if oformat is enabled. - dtrace_set_outfp(FILE *) -- sets the output file for oformat. - Ensure that oformat is correctly checked in the drop handler and record processing callbacks. This commit also adds tests which check if the generated output is valid (JSON, XML) and extends the dtrace(1) describing the structured output. Reviewed by: markj Discussed with: phil MFC after: 2 months Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D41745
* Trim various $FreeBSD$John Baldwin2023-10-101-2/+0
| | | | | | Approved by: markj (cddl/contrib changes) Reviewed by: imp, emaste Differential Revision: https://reviews.freebsd.org/D41961
* dtrace: move kinst tests to commonChristos Margiolis2023-07-041-0/+0
| | | | | | | Reviewed by: markj Approved by: markj (mentor) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D40414
* kinst: fix memcpy() tracing crashChristos Margiolis2023-05-261-0/+1
| | | | | | | | | | | | Tracing memcpy() would crash the kernel, because we'd also trace the memcpy() calls from kinst_invop(). To fix this, introduce kinst_memcpy() whose arguments are 'volatile', so that we avoid having the compiler replace it with a regular memcpy(). Reviewed by: markj Approved by: markj (mentor) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D40284
* dtrace.1: fix mandoc -TlintChristos Margiolis2023-05-231-5/+5
| | | | | | Reviewed by: markj Approved by: markj (mentor) Differential Revision: https://reviews.freebsd.org/D40230
* dtrace(1): add -d flag to dump D script post-dt_sugarChristos Margiolis2023-05-232-4/+15
| | | | | | | | | | | By specifying the -d flag, libdtrace will dump the D script after it has applied syntactical sugar transformations (e.g if/else). This is useful for both understanding what dt_sugar does, as well as debugging it. Reviewed by: markj Approved by: markj (mentor) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D38732
* dtrace tests: Extend the kinst regression testMark Johnston2022-12-081-0/+1
| | | | Trace a function which disables interrupts.
* kinst: Add a rudimentary regression test caseMark Johnston2022-10-111-0/+46
| | | | | | | The test instruments a number of large, frequently called kernel functions while generating load in the background. MFC after: 3 months
* dtrace tests: Rename some test type names to avoid a conflictMark Johnston2022-08-031-6/+6
| | | | | MFC after: 1 week Sponsored by: The FreeBSD Foundation
* dtrace tests: Override RLIMIT_CORE for a test which triggers a core dumpMark Johnston2022-08-031-1/+1
| | | | | MFC after: 1 week Sponsored by: The FreeBSD Foundation
* dtrace tests: Fix expected outout for tst.system.dLi-Wen Hsu2022-03-091-6/+6
| | | | | | | This is follow up of d500a85e640d1cd270747c12e17c511b53864436 PR: 262415 Sponsored by: The FreeBSD Foundation
* dtrace: Disable getf() as it is broken on FreeBSDDomagoj Stolfa2021-12-171-1/+1
| | | | | | | | | | | | | | | | | | getf() on FreeBSD calls _sx_slock(), _sx_sunlock() and fget_locked(). Furthermore, it does not set the per-core fault flag, meaning it usually ends up in a double fault panic once getf() does get called, especially from fbt. Reviewing the DTrace Toolkit + a number of other scripts scattered around FreeBSD, I have not been able to find one use of getf(). Given how broken the implementation currently is, we disable it until it can be implemented properly. Also comment out a test in aggs/tst.subr.d for getf(). Reviewed by: markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D33378
* dtrace.1: Document a couple of preprocessor-related optionsMark Johnston2021-09-071-0/+11
| | | | | | Suggested by: swills MFC after: 1 week Sponsored by: The FreeBSD Foundation
* dtrace.1: Document -x ldpathMark Johnston2021-09-071-1/+9
| | | | | MFC after: 1 week Sponsored by: The FreeBSD Foundation
* dtrace tests: Fix tst.system.d after ping/ping6 unificationMark Johnston2021-04-231-3/+3
| | | | | MFC after: 1 week Sponsored by: The FreeBSD Foundation
* dtrace: Document the libdir, nolibs and syslibdir optionsDomagoj Stolfa2021-04-021-1/+9
| | | | | MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D29541
* dtrace tests: fix prototypes for gcc buildRyan Libby2021-01-114-6/+9
| | | | | | | | | - quiet -Wstrict-prototypes - provide prototypes for weak aliases Reviewed by: markj Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D28036
* dtrace: honor LC_NUMERIC for %'d and alike, and LC_TIME for %TAndriy Gapon2020-12-031-0/+9
| | | | | | | | | | | | | Note that the public documentation on dtrace.org fails to mention %T and incorrectly documents %Y. The latter actually uses format "%Y %b %e %T" where %b is always in C locale. Discussed with: markj MFC after: 1 month Sponsored by: Panzura Notes: svn path=/head/; revision=368300
* Address compiler warnings in C code used by the DTrace test suite.Mark Johnston2020-09-1933-112/+105
| | | | | | | | Reported by: Jenkins MFC after: 1 week Notes: svn path=/head/; revision=365907
* Add HISTORY sections to ZFS and dtrace manpageGordon Bergling2020-06-141-1/+6
| | | | | | | | | | Reviewed by: bcr (mentor) Approved by: bcr (mentor) MFC after: 7 days Differential Revision: https://reviews.freebsd.org/D23833 Notes: svn path=/head/; revision=362170
* Fix inconsistencies in anonymous DOF files.Mark Johnston2019-11-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | The DOF file output by dtrace -A contains only the loadable sections. However, as it was created by a call to dtrace_dof_create() without flags, the original DOF was created with the loadable sections. The result is that the DOF includes the section headers for the unloadable sections (COMMENTS and UTSNAME) without these sections actually being present. This is inconsistent. A simple change to anon_prog() ensures that the missing sections are present in the outputted DOF. Alternatively, the call to dtrace_dof_create() could pass the DTRACE_D_STRIP flag stripping out the loadable sections. As the unloadable sections contain info useful for debugging purposes they haven't been stripped. Submitted by: Graeme Jenkinson <graeme.jenkinson@cl.cam.ac.uk> MFC after: 1 week Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D21875 Notes: svn path=/head/; revision=354822
* Fix dtrace test case after r351423 due to ping6(8) options changedLi-Wen Hsu2019-08-311-1/+1
| | | | | | | | | | Failure test case: cddl.usr.sbin.dtrace.common.ip.t_dtrace_contrib.tst_ipv6localicmp_ksh Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=351644
* Fix tests use /etc/motd after r350184 by using an always existing fileLi-Wen Hsu2019-08-313-3/+3
| | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=351643
* DTrace: create an amd64 test suitMariusz Zaborski2019-06-053-0/+161
| | | | | | | | | | | | | Create two tests checking if we can read urgs registers and if the rax register returns a correct number. Reviewed by: markj Discussed with: lwhsu MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D20364 Notes: svn path=/head/; revision=348706
* Add a trailing empty line to match the test code outputLi-Wen Hsu2019-04-291-0/+1
| | | | | | | | | | | This is added for letting these long failing test case pass, and for consistency. The test code should be fixed later to not output this extra empty line. Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=346873
* Some test scripts use ncat --sctp --listen port to run an SCTP discardMichael Tuexen2019-04-282-36/+68
| | | | | | | | | | | | | | | | | | | server in the background. However, when running in the background, stdin is closed and ncat initiates a graceful shutdown of the SCTP association. This is not expected by the client. Therefore, the ncat-based discard server is replaced by a perl-based one. In addition, to remove the dependency from ncat, which needs to be installed via the nmap port, also the code testing for a free SCTP port is changed to use the perl-based client. Finally, remove some debug output from the report generated. Reviewed by: lwhsu@ Differential Revision: https://reviews.freebsd.org/D20086 Notes: svn path=/head/; revision=346854
* Ensure that we use a 64-bit value for the last mmap() argument.Mark Johnston2019-03-201-1/+2
| | | | | | | | | | | | When using __syscall(2), the offset argument is passed on the stack on amd64. Previously only 32 bits were written, so the upper 32 bits were garbage and could cause the test to fail. MFC after: 3 days Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=345355
* dtrace(1): remove reference to dtruss that was removed from baseYuri Pankov2018-10-311-2/+1
| | | | | | | | | | | | system in r300226. PR: 211618 Reviewed by: gnn, markj, 0mp Approved by: kib (mentor, implicit) Differential Revision: https://reviews.freebsd.org/D17762 Notes: svn path=/head/; revision=339956
* Add support for send, receive and state-change DTrace providers forMichael Tuexen2018-08-229-7/+623
| | | | | | | | | | | | SCTP. They are based on what is specified in the Solaris DTrace manual for Solaris 11.4. Reviewed by: 0mp, dteske, markj Relnotes: yes Differential Revision: https://reviews.freebsd.org/D16839 Notes: svn path=/head/; revision=338213
* Add partial documentation for dtrace(1)'s -x configuration options.Mark Johnston2018-08-161-2/+111
| | | | | | | | | | | | | Some options are still missing descriptions, but they can be filled in over time. Submitted by: raichoo <raichoo@googlemail.com> Reviewed by: 0mp (previous version) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D16671 Notes: svn path=/head/; revision=337926
* Add a dtrace provider for UDP-Lite.Michael Tuexen2018-07-314-0/+250
| | | | | | | | | | | | | | The dtrace provider for UDP-Lite is modeled after the UDP provider. This fixes the bug that UDP-Lite packets were triggering the UDP provider. Thanks to dteske@ for providing the dwatch module. Reviewed by: dteske@, markj@, rrs@ Relnotes: yes Differential Revision: https://reviews.freebsd.org/D16377 Notes: svn path=/head/; revision=337018
* Improve TCP related tests for dtrace.Michael Tuexen2018-07-224-43/+37
| | | | | | | | | | | | | | Ensure that the TCP connections are terminated gracefully as expected by the test. Use appropriate numbers for sent/received packets. In addition, enable tst.localtcpstate.ksh, which should pass, but doesn't until https://reviews.freebsd.org/D16369 is committed. Reviewed by: markj@ Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D16288 Notes: svn path=/head/; revision=336597
* Test that the dtrace UDP receive probe fires.Michael Tuexen2018-07-202-6/+14
| | | | | | | | | | | | | This test ensures that the fix committed in https://svnweb.freebsd.org/changeset/base/336551 actually works. Reviewed by: dteske@, markj@, rrs@ Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D16046 Notes: svn path=/head/; revision=336552
* Adjust comment to reality since r286171.Michael Tuexen2018-07-151-2/+1
| | | | | | | Sponsored by: Netflix, Inc. Notes: svn path=/head/; revision=336317
* Don't require a local sshd for the local TCP state dtrace testMichael Tuexen2018-07-151-6/+17
| | | | | | | | | | | | | | This change is similar to the one done in r286171 for tst.ipv4localtcp.ksh. This not only reduces the requirements on the system used for testing but results also in a graceful teardown of the TCP connection. Reviewed by: gnn@ Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D16276 Notes: svn path=/head/; revision=336316
* Fix the UDP tests for dtrace.Michael Tuexen2018-07-152-11/+59
| | | | | | | | | | | | | | | | | The code imported from opensolaris was depending on ping supporting UDP for sending probes. Since this is not supported by ping on FreeBSD use a perl script instead. The remote test requires the usage of ksh93, so state that in the sheband. Enable the local test, but keep the remote test disabled, since it requires a remote machine on the LAN. Reviewed by: markj@, gnn@ Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D16268 Notes: svn path=/head/; revision=336315
* Return the intended return code.Michael Tuexen2018-07-141-1/+1
| | | | | | | | | | This bug was spotted by markj@ in D16268 because I copied this code part and used it there. So fix it. Sponsored by: Netflix, Inc. Notes: svn path=/head/; revision=336293
* Fix shebangs and execute bit of test scripts.Michael Tuexen2018-07-148-8/+8
| | | | | | | | | | | | | | Since we don't have /usr/bin/ksh, use a generic way of specifying ksh. Some of the tests only run with ksh93, so use this shell for these tests. Two of the tests don't have the execute bit set, so fix this, too. Reviewed by: markj@ Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D16270 Notes: svn path=/head/; revision=336291
* Use __syscall(2) rather than syscall(2) in syscall/tst.args.c.Mark Johnston2018-03-181-1/+1
| | | | | | | | | Some of mmap(2)'s arguments are 64 bits wide. MFC after: 3 days Notes: svn path=/head/; revision=331135
* Add "jid" and "jailname" variables to DTrace.Mark Johnston2018-01-122-0/+88
| | | | | | | | | | | | | | | | | These return the jail ID and jail name for the traced process, respectively, and are analogous to "zonename" on Solaris/illumos. "zonename" is now aliased to "jailname". Also add some stress tests for the new variables. Submitted by: Domagoj Stolfa <domagoj.stolfa@gmail.com> Reviewed by: dteske (previous version) MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D13877 Notes: svn path=/head/; revision=327888
* Add a regression test for r327794.Mark Johnston2018-01-102-0/+36
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=327795
* Complete support for dtrace's -x setenv option.Mark Johnston2017-12-0312-0/+225
| | | | | | | | | | | | | | This allows one to override the environment for processes created with dtrace -c. By default, the environment is inherited. This support was originally merged from illumos in r249367 but was lost when the commit was later reverted and then brought back piecemeal. Reported by: Samuel Lepetit <slepetit@apple.com> MFC after: 2 weeks Notes: svn path=/head/; revision=326499
* Revert r326181 for now.Mark Johnston2017-11-271-1/+1
| | | | | | | | | We can't link an executable using -m32 until the lib32 phase of a buildworld, though the build works fine when executing make from cddl/usr.sbin/dtrace/tests. Some other solution will need to be found. Notes: svn path=/head/; revision=326285
* Compile one of the uctf test programs with -m32.Mark Johnston2017-11-241-1/+1
| | | | | | | | | The err.user64mode.ksh test expects it to run as a 32-bit process. MFC after: 1 week Notes: svn path=/head/; revision=326181
* Don't assume that we can resolve "main" in the ksh executable.Mark Johnston2017-11-211-1/+1
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=326061