aboutsummaryrefslogtreecommitdiff
path: root/cddl/contrib/opensolaris/lib/libdtrace
Commit message (Collapse)AuthorAgeFilesLines
* dtrace: Add the 'oformat' libdtrace optionDomagoj Stolfa2024-01-1011-156/+1612
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* libdtrace: Fix line number reporting in error messagesMark Johnston2023-12-311-0/+2
| | | | MFC after: 1 week
* dtrace: remove dead code for PR_REQUESTEDEric van Gyzen2023-08-011-95/+0
| | | | | | | | | | libproc's PR_REQUESTED is not implemented on FreeBSD. Remove dead code in dtrace that would handle it. Reviewed by: markj MFC after: 1 week Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D41225
* dtrace: do not overload libproc flagsEric van Gyzen2023-08-012-22/+20
| | | | | | | | | | | | | | | | | dtrace stored its PR_RLC and PR_KLC flags in the proc_handle's flags, where they collided with PATTACH_FORCE and PATTACH_RDONLY, respectively. Thus, Psetflags(PR_KLC) effectively also set the PATTACH_RDONLY flag. Since the flags are private to dtrace (at least on FreeBSD), store them in dtrace's own dt_proc structure instead. On FreeBSD, either PR_RLC or PR_KLC was always set, so remove code that would handle the case where neither was set. Reviewed by: markj MFC after: 1 week Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D41121
* dtrace: remove illumos code from dt_proc.cEric van Gyzen2023-08-011-148/+2
| | | | | | | | | | | | The illumos #ifdef's in this file make it harder to read and maintain. There is little change upstream, and increasing changes for FreeBSD. Remove the illumos code with `unifdef`. The only manual changes here are the #includes and #defines at the top, and removing blank lines. Reviewed by: markj MFC after: 1 week Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D41173
* dtrace: prevent forked child from running after an error conditionEric van Gyzen2023-07-121-3/+13
| | | | | | | | | | | | | | | The pid/killonerror test uses an invalid probe specifier to verify that the child process is killed. It occasionally fails because the "date" command is allowed to run long enough to print the date. This is harmless in this case, but is clearly not ideal. When the dt_proc_control thread is about to exit, and the dtrace command forked the child, do not make the child runnable. Reviewed by: markj MFC after: 1 week Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D40976
* dtrace(1): add -d flag to dump D script post-dt_sugarChristos Margiolis2023-05-232-6/+13
| | | | | | | | | | | 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
* libdtrace: get rid of illumos ifdefs in dt_module_update(), fix dm_file and ↵Christos Margiolis2023-05-231-27/+3
| | | | | | | | | | | | | | dm_modid Because dt_module_update() is highly OS-specific, the ifdefs make it hard to read and follow what is going on. Also handle dm_modid, and remove handling of the ".filename" section, since we can easily fetch the filename from the module's pathname (k_stat->pathname). Reviewed by: markj Approved by: markj (mentor) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39177
* libdtrace: Do not set SHF_ALLOC on SUNW_dof relocation sectionsMark Johnston2023-04-041-2/+2
| | | | | | | | | | | | | The section will contain static relocations which do not need to be preserved after linking, and moreover these relocations may reference symbols that end up getting removed. Do not set SHF_ALLOC and instead let the linker decide what needs to be done. PR: 258872 MFC after: 1 week Sponsored by: The FreeBSD Foundation
* libdtrace: fix indendation in dt_printd()Christos Margiolis2023-03-201-1/+1
| | | | | | | | No functional change. Reviewed by: markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D39145
* libdtrace: add riscv supportMitchell Horne2023-02-061-7/+103
| | | | | | | | | | | Largely untested, as we can't really do anything with user probes without an implementation of fasttrap. However, this is enough to generate an embedded dtrace program with `dtrace -G` and link the generated ELF file. Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D38301
* libdtrace: drop remaining mips supportMitchell Horne2023-02-062-28/+2
| | | | | | Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D38300
* dtrace: remove stray {Kristof Provost2023-01-241-1/+1
| | | | | Fixes: da81cc6035f8283b6adda1ef466977e8c1c5389e PR: 269128
* dtrace: conditionally load the systrace_linux klds when loading dtrace.Andrew Gallatin2023-01-241-0/+9
| | | | | | | | | | | | | | | | | | | When dtrace starts, it tries to detect if the dtrace klds are loaded, and if not, it loads them by loading the dtraceall kld. This module depends on most dtrace modules, including systrace for the native freebsd and freebsd32 ABIs. However, it does not depend on the systrace_linux klds, as they in turn depend on the linux ABI klds, and we don't want to load an ABI module that the user has not explicitly requested. This can leave a naive user in a state where they think all syscall providers have been loaded, yet linux ABI syscalls are "invisible" to dtrace. To fix this, check to see if the linux ABI modules are loaded. If they are, then load their systrace klds. Reviewed by: markj, (emaste & jhb, earlier versions) Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D37986
* libdtrace: Change the binding of USDT probe symbols to STB_WEAKMark Johnston2022-12-111-0/+1
| | | | | | | | | | | | | | | | Otherwise, if multiple object files contain references to the same probe, newish lld will refuse to link them by default, raising a duplicate global symbol definition error. Previously, duplicate global symbols with identical absolute st_values were permitted by both lld and GNU ld. Since dtrace has no use for probe function symbols after the relocation performed by dtrace -G, make the symbols weak as well, following a suggestion from MaskRay. Reported by: dim MFC after: 1 week Sponsored by: The FreeBSD Foundation
* libdtrace: Add kinst supportChristos Margiolis2022-10-113-0/+33
| | | | | | | | | | | | kinst does not instantiate its probes automatically, it only does so on demand via an ioctl interface implemented by /dev/kinst. This change modifies libdtrace to perform that work when the script references the kinst provider, similar to the way pid provider probes are implemented. Reviewed by: markj MFC after: 3 months Sponsored by: Google, Inc. (GSoC 2022) Differential Revision: https://reviews.freebsd.org/D36852
* dtrace: Add a "regs" variableMark Johnston2022-10-041-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | This allows invop-based providers (i.e., fbt and kinst) to expose the register file of the CPU at the point where the probe fired. It does not work for SDT providers because their probes are implemented as plain function calls and so don't save registers. It's not clear what semantics "regs" should have for them anyway. This is akin to "uregs", which nominally provides access to the userspace registers. In fact, DIF already had a DIF_VAR_REGS variable defined, it was simply unimplemented. Usage example: print the contents of %rdi upon each call to amd64_syscall(): fbt::amd64_syscall:entry {printf("%x", regs[R_RDI]);} Note that the R_* constants are defined in /usr/lib/dtrace/regs_x86.d. Currently there are no similar definitions for non-x86 platforms. Reviewed by: christos MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D36799
* dtrace: Remove local mips supportBrooks Davis2022-07-011-75/+0
| | | | | | | | Remove the stub pid probe and all the build glue. Reviewed by: imp, jhb Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D35541
* libdtrace: Add a missing newline to an error messageMark Johnston2022-02-231-1/+1
| | | | | MFC after: 1 week Sponsored by: The FreeBSD Foundation
* dtrace: remove unnecessary fflush()Chuck Silvers2022-02-101-1/+0
| | | | | | | | | | | This call was added back in the early days of dtrace porting and no one knows why anymore. The extra flushing causes lots of unnecessary CPU overhead when a script produces lots of output, as well as easily losing output because the command can't keep up. Sponsored by: Netflix Reviewed by: imp, markj Differential Revision: https://reviews.freebsd.org/D34216
* dt_unring_buf: set dtbd_oldest to the start of the first recordAndriy Gapon2022-01-111-1/+1
| | | | | | | | | | | It was set to the start of the buffer and that can be different from the start of teh first record because of a misalignment. This change follows the example of dt_realloc_buf(). Reviewed by: tsoome, markj MFC after: 4 weeks Differential Revision: https://reviews.freebsd.org/D33649
* dtrace: fix an out of bound read and a NULL pointer incrementDomagoj Stolfa2021-06-172-2/+8
| | | | | | | | | | | | | | In dt_cc.c when the provider is an empty string, accessing strlen(pdp->dtpd_provider) - 1 will result in a pdp->dtpd_provider[-1] access. Similarly, in dt_ident.c, if p2 is a NULL pointer, doing a p2++ on it is undefined behaviour. Reviewed by: markj MFC after: 1 week Sponsored by: Google Differential Revision: https://reviews.freebsd.org/D30778
* libdtrace: Trivial style fixes to force dt_lex.c to be regeneratedMark Johnston2021-02-201-9/+10
| | | | | | | | | After commit 8ba333e02e ("libdtrace: Stop relying on lex compatibility"), there have been several reports of incremental buildworlds failing since make does not know that dt_lex.c needs to be regenerated, and I want to avoid this when merging to stable/13. MFC with: 8ba333e02e
* libdtrace: Stop relying on lex compatibilityMark Johnston2021-02-171-1/+1
| | | | | | | | | | It does not appear to be required, and as of commit 6b7e592c215f ("lex: Do not let input() return 0 when end-of-file is reached") it causes input to return 0 instead of EOF when end-of-input is reached. PR: 253440 MFC after: 3 days Sponsored by: The FreeBSD Foundation
* libdtrace: Format USDT symbols correctly based on symbol bindingMark Johnston2021-01-101-4/+10
| | | | | | | | | | | Before we did not handle weak symbols correctly, sometimes resulting in link errors from dtrace -G when processing object files where functions with weak aliases contain USDT probes. Reported by: rlibby Tested by: rlibby MFC after: 1 week Sponsored by: The FreeBSD Foundation
* Merge OpenZFS support in to HEAD.Matt Macy2020-08-254-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The primary benefit is maintaining a completely shared code base with the community allowing FreeBSD to receive new features sooner and with less effort. I would advise against doing 'zpool upgrade' or creating indispensable pools using new features until this change has had a month+ to soak. Work on merging FreeBSD support in to what was at the time "ZFS on Linux" began in August 2018. I first publicly proposed transitioning FreeBSD to (new) OpenZFS on December 18th, 2018. FreeBSD support in OpenZFS was finally completed in December 2019. A CFT for downstreaming OpenZFS support in to FreeBSD was first issued on July 8th. All issues that were reported have been addressed or, for a couple of less critical matters there are pull requests in progress with OpenZFS. iXsystems has tested and dogfooded extensively internally. The TrueNAS 12 release is based on OpenZFS with some additional features that have not yet made it upstream. Improvements include: project quotas, encrypted datasets, allocation classes, vectorized raidz, vectorized checksums, various command line improvements, zstd compression. Thanks to those who have helped along the way: Ryan Moeller, Allan Jude, Zack Welch, and many others. Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D25872 Notes: svn path=/head/; revision=364746
* Fix a typo in r364438 affecting 32-bit platforms.Mark Johnston2020-08-221-4/+4
| | | | | | | | Reported by: antoine MFC with: r364438 Notes: svn path=/head/; revision=364483
* Fix a typo in r364438.Mark Johnston2020-08-201-1/+1
| | | | | | | | Reported by: Jenkins MFC with: r364438 Notes: svn path=/head/; revision=364440
* Enable creation of static userspace probes in incremental builds.Mark Johnston2020-08-203-65/+89
| | | | | | | | | | | | | | | | | | To define USDT probes, dtrace -G makes use of relocations for undefined symbols: the target address is overwritten with NOPs and the location is recorded in the DOF section of the output object file. To avoid link errors, the original relocation is destroyed. However, this means that the same input object file cannot be processed multiple times, as happens during incremental rebuilds. Instead, only set the relocation type to NONE, so that all information required to reconstruct USDT probes is preserved. Reported by: bdrewery MFC after: 3 weeks Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=364438
* Remove non-FreeBSD ifdefs from dt_link.c.Mark Johnston2020-08-201-250/+19
| | | | | | | | | | | | This file is too complicated as it is and has diverged a fair bit from illumos due to toolchain differences, so just drop unused code (including SPARC support). MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=364437
* Fix libdtrace build with zsh as /bin/shAlex Richardson2020-08-114-54/+46
| | | | | | | | | | | | When zsh runs in POSIX sh mode it does not support the -e flag to echo. Use printf instead of echo to avoid the "-e" characters being printed. Obtained from: CheriBSD Reviewed By: markj Differential Revision: https://reviews.freebsd.org/D26026 Notes: svn path=/head/; revision=364124
* Fix -DBUILD_WITH_STRICT_TMPPATH dtrace buildsAlex Richardson2020-08-114-0/+4
| | | | | | | | | | | | | | | | | | | Some of the scripts used for libdtrace invoke nawk instead of awk (for example cddl/contrib/opensolaris/lib/libdtrace/common/mknames.sh). When bootstrapping all tools, we get the nawk -> awk link while building usr.bin/awk, but when linking/copying the dependencies from the host we were only adding awk but not nawk. This was silently generating invalid files when building libdtrace with BUILD_WITH_STRICT_TMPPATH=1 since those scripts invoke nawk instead of awk. In addition to adding the missing link this commit also adds set -e to those scripts to catch errors like this in the future. Reviewed By: markj, emaste Differential Revision: https://reviews.freebsd.org/D26025 Notes: svn path=/head/; revision=364123
* Restore the binary compatibility for link_map l_addr.Konstantin Belousov2020-05-211-1/+7
| | | | | | | | | | | | | | | | | Keep link_map l_addr binary layout compatible, rename l_addr to l_base where rtld returns map base. Provide relocbase in newly added l_addr. This effectively reverts the patch to the initial version of D24918. Reported by: antoine (portmgr) Reviewed by: jhb, markj Tested by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D24946 Notes: svn path=/head/; revision=361349
* Do not load dtraceall.ko if dtrace.ko is already loaded.Mark Johnston2020-02-281-1/+1
| | | | | | | | | | | | This was the intent of the existing code, but instead it would unconditionally load dtraceall.ko because of a stale errno value. Reported by: pho MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=358435
* [PowerPC] [DTrace] Add ELFv2 support in libdtraceBrandon Bergren2020-02-051-4/+10
| | | | | | | | | | | | | | | PPC64 ELFv2 acts like a "normal" platform in that it no longer needs function descriptors. So, ensure we are only enabling them on ELFv1. Additionally, ELFv2 requires that the ELF header have a nonzero e_flags, so ensure that the synthesized ELF header in dt_link.c is setting it. Reviewed by: jhibbits, markj Approved by: gnn Differential Revision: https://reviews.freebsd.org/D22403 Notes: svn path=/head/; revision=357590
* Use a deterministic hash for USDT symbol names.Mark Johnston2020-01-071-5/+22
| | | | | | | | | | | | | | Previously libdtrace used ftok(3), which hashes the inode number of the input object file. To increase reproducibility of builds that embed USDT probes, include a hash of the object file path in the symbol name instead. Reported and tested by: bdrewery Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Notes: svn path=/head/; revision=356477
* Add libdtrace support for arm64 USDT probes.Mark Johnston2019-12-291-8/+70
| | | | | | | | | | | | | arm64 is still lacking a fasttrap implementation, which is required to actually enable userland probes, but this at least allows USDT probes to be linked into userland applications. Submitted by: Klaus Küchemann <maciphone2@googlemail.com> (original) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D22360 Notes: svn path=/head/; revision=356187
* dtrace: avoid gcc9 Walloca-larger-thanRyan Libby2019-12-211-21/+47
| | | | | | | | | | | | gcc9 grew a new warning for unbounded allocas, such as the one in dt_options_load. Remove both uses of alloca in dt_options.c. Reviewed by: markj Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D22880 Notes: svn path=/head/; revision=355973
* MFV r344364:Mark Johnston2019-02-201-4/+3
| | | | | | | | | | | 9058 postmortem DTrace frequently broken under vmware illumos/illumos-gate@793bd7e3617ae7d3d24e8c6b7d6befe35f07ec1f MFC after: 1 week Notes: svn path=/head/; revision=344366
* Disable the D subroutines msgsize() and msgdsize().Mark Johnston2018-08-101-1/+1
| | | | | | | | | | They are specific to illumos and the corresponding DIF subroutines are already disabled on FreeBSD. Reported by: gnn Notes: svn path=/head/; revision=337584
* Given hidden visibility to symbols referenced by the DOF section.Mark Johnston2018-03-191-2/+3
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=331222
* libdtrace: Fix another uninitialized dtt_flags UBConrad Meyer2018-03-161-3/+5
| | | | | | | | | | | | | Like r331073, eliminate a UB by fully initializing the struct with a designated initializer. Note that the similar src_dtt is not fully used, so a similar treatment was not absolutely required. I chose to leave it alone. It wouldn't hurt to do the same thing, though. Reported by: Coverity Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=331076
* libdtrace: Eliminate a minor UB by fully initializing parameter structConrad Meyer2018-03-161-3/+4
| | | | | | | | | | | The dtt_flags value is dereferenced by dt_type_pointer() and must be initialized first. Reported by: Coverity Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=331073
* Add "jid" and "jailname" variables to DTrace.Mark Johnston2018-01-121-2/+6
| | | | | | | | | | | | | | | | | 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
* Fix an off-by-one in dt_opt_setenv().Mark Johnston2018-01-101-9/+10
| | | | | | | | | | | | The bug would cause incorrect behaviour when attempting to override an already set environment variable with -x setenv, as long as the variable is not the last one in the array. Reported by: Samuel Lepetit <slepetit@apple.com> MFC after: 2 weeks Notes: svn path=/head/; revision=327794
* Complete support for dtrace's -x setenv option.Mark Johnston2017-12-033-19/+74
| | | | | | | | | | | | | | 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
* Add an envp argument to proc_create().Mark Johnston2017-12-031-1/+1
| | | | | | | | | This is needed to support dtrace's -x setenv option. MFC after: 2 weeks Notes: svn path=/head/; revision=326498
* Fix the type signature for sx(9) DTrace subroutines.Mark Johnston2017-11-241-1/+1
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=326177
* dt_modtext: return error on archs lacking an implementationEd Maste2017-11-211-4/+4
| | | | | | | | | | | | Reported by: mmel Reviewed by: markj MFC after: 1 week MFC with: r325042 Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D13176 Notes: svn path=/head/; revision=326046
* Take r313504 into account when recomputing the string table length.Mark Johnston2017-11-161-2/+9
| | | | | | | | | | | | | When we encounter a USDT probe in a weak symbol, we emit an alias for the probe function symbol. Such aliases are named differently from the aliases we emit for probes in local functions, so make sure to take that difference into account when resizing the output object file's string table. Otherwise, we underrun the string table buffer. PR: 223680 Notes: svn path=/head/; revision=325886