aboutsummaryrefslogtreecommitdiff
path: root/cddl/contrib/opensolaris
Commit message (Collapse)AuthorAgeFilesLines
* kinst: fix memcpy() tracing crashChristos Margiolis9 days1-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 Margiolis12 days1-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 Margiolis12 days4-10/+28
| | | | | | | | | | | 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 Margiolis12 days1-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
* ctf: Remove unused function prototype for getpname()Zhenlei Huang2023-02-261-2/+0
| | | | | | | | This function prototype should have been removed along with the implementation. Fixes: 3dd552426409 ctfdump: Use getprogname() MFC after: 1 day
* lockstat: Use gelf.h instead of playing games with the preprocessorMark Johnston2023-02-251-13/+8
| | | | | | | This reverts a portion of 1477dd823ee ("Merge OpenZFS support in to HEAD."). No functional change intended. MFC after: 1 week
* lockstat: Use the correct type for a symbol sizeMark Johnston2023-02-251-1/+1
| | | | | | No functional change intended. MFC after: 1 week
* ctfdump: Use getprogname()Zhenlei Huang2023-02-232-25/+1
| | | | | | | | Also remove no longer used function `getpname()`. Reviewed by: markj MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D38740
* 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
* 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
* 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
* ctfconvert: Actually use the asprintf() helperMark Johnston2022-08-031-1/+1
| | | | Fixes: 1165fc9a5266 ("ctfconvert: Give bitfield types names distinct from the base type")
* ctfconvert: Give bitfield types names distinct from the base typeMark Johnston2022-08-033-3/+19
| | | | | | | | | | | | | | | | | | CTF integers have an explicit width and so can be used to represent bitfields. Bitfield types emitted by ctfconvert(1) share the name of the base integer type, so a struct field with type "unsigned int : 15" will have a type named "unsigned int". To avoid ambiguity when looking up types by name, add a suffix to names of bitfield types to distinguish them from the base type. Then, if ctfmerge happens to order bitfield types before the corresponding base type in a CTF file, a name lookup will return the base type, which is always going to be the desired behaviour. PR: 265403 Reported by: cy MFC after: 1 week Sponsored by: The FreeBSD Foundation
* 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
* lockstat: Fix construction of comparision predicatesKornel Dulęba2022-07-041-2/+2
| | | | | | | | | | | | | | Passing "0x%p" to sprintf results in double "0x" being printed. This causes a dtrace script compilation failure when "-d" flag is specified. Fix that by removing the extraneous "0x". Reviewed by: markj Approved by: mw(mentor) Obtained from: Semihalf Sponsored by: Alstom MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D35690
* 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
* ctfdump: Remove definitions of warn() and vwarn()Mark Johnston2022-04-213-31/+2
| | | | | | | | | | | The presence of the latter causes a link error when building a statically linked ctfdump(1) because libc defines the same symbol. libc's warn() is defined as a weak symbol and so does not cause the same problem, but let's just use libc's version. Reported by: stephane rochoy <stephane.rochoy@stormshield.eu> MFC after: 1 week Sponsored by: The FreeBSD Foundation
* libctf: Fix recursive descent into anonymous SOU fieldsMark Johnston2022-04-121-2/+2
| | | | | | | | PR: 262412 Tested by: dhw, gallatin Fixes: a6fb86917362 ("libctf: Handle CTFv3 containers") MFC after: 3 days 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
* zfs: merge openzfs/zfs@a86e08941 (master) into mainMartin Matuska2022-03-081-2/+2
| | | | | | | | | | | | | | | | | | | | Notable upstream pull request merges: #9078: log xattr=sa create/remove/update to ZIL #11919: Cross-platform xattr user namespace compatibility #13014: Report dnodes with faulty bonuslen #13016: FreeBSD: Fix zvol_cdev_open locking #13019: spl: Don't check FreeBSD rwlocks for double initialization #13027: Fix clearing set-uid and set-gid bits on a file when replying a write #13031: Add enumerated vdev names to 'zpool iostat -v' and 'zpool list -v' #13074: Enable encrypted raw sending to pools with greater ashift #13076: Receive checks should allow unencrypted child datasets #13098: Avoid dirtying the final TXGs when exporting a pool #13172: Fix ENOSPC when unlinking multiple files from full pool Obtained from: OpenZFS OpenZFS commit: a86e089415679cf1b98eb424a159bb36aa2c19e3
* ctf: Avoid passing a caddr_t to roundup2()Mark Johnston2022-03-071-1/+1
| | | | | | | For some reason I can't reproduce this locally, but Jenkins complains. Reported by: Jenkins Fixes: bdf290cd3e1a ("ctf: Add v3 support to CTF tools, ctf{convert,dump,merge}")
* ctf: Fix a -Wunused-but-set-variable warningMark Johnston2022-03-071-2/+0
| | | | | MFC after: 1 month Sponsored by: The FreeBSD Foundation
* ctf: Add v3 support to CTF tools, ctf{convert,dump,merge}Mark Johnston2022-03-073-271/+472
| | | | | | | | | ctfdump handles v2 and v3. ctfconvert now emits only CTFv3, whereas ctfmerge can merge v2 and v3 containers into v3 containers. MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D34364
* libctf: Handle CTFv3 containersMark Johnston2022-03-078-421/+895
| | | | | | | | | | | | | | | In general, the patch adds indirection to minimize the amount of code that needs to know about differences between v2 and v3. Specifically, some new ctf_get_ctt_* functions are added, and new LCTF_* macros are added to use the underlying container's version to do the right thing. CTF containers can have parent/child relationships, wherein a type ID in one container refers to a type in the parent. It is permitted for the parent and child to have different versions. MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D34363
* ctf: Add definitions for CTFv3Mark Johnston2022-03-071-94/+114
| | | | | | | | | | | | | | | | | | | | | | | | | | These are based on definitions added to binutils' libctf. Specifically: - Type IDs are now encoded in 32 bits rather than 16, changing the layout of ctf_type_t, ctf_array_t, ctf_member_t and ctf_lmember_t. - Type info is encoded in 32 bits rather than 16. The type "kind" is extended from 5 bits to 6, and the type "vlen" is extended from 10 bits to 25. The main upside is that we remove the current limit, imposed by CTFv2, of 2^{15} distinct types in the main kernel executable. Other limits, such as that on the number of elements in an enum, imposed by the vlen limit, are also raised. This change adds v2 and v3 flavours of macros and type definitions which differ between the two versions. Compatibility is preserved for now by having generic names refer to the v2 definitions, so, e.g., ctf_type_t is still a v2 type. No functional change intended. Reviewed by: Domagoj Stolfa MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D34360
* ctf: Import ctf.h from OpenBSDMark Johnston2022-03-071-1/+1
| | | | | | | | | | | | | | | | | Use it instead of the existing ctf.h from OpenSolaris. This makes it easier to use CTF in the core kernel, and to extend the CTF format to support wider type IDs. The imported ctf.h is modified to depend only on _types.h, and also to provide macros which use the "parent" bit of a type ID to refer to types in a parent CTF container. No functional change intended. Reviewed by: Domagoj Stolfa, emaste MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D34358
* libctf: Use const ctf_file_t references in string lookup routinesMark Johnston2022-02-232-5/+5
| | | | | MFC after: 1 week Sponsored by: The FreeBSD Foundation
* libdtrace: Add a missing newline to an error messageMark Johnston2022-02-231-1/+1
| | | | | MFC after: 1 week Sponsored by: The FreeBSD Foundation
* libctf: Remove checks for CTFv1Mark Johnston2022-02-232-13/+8
| | | | | | | | Per commit 7db423d69273 ("libctf: Rip out CTFv1 support") this support is obsolete. MFC after: 1 week Sponsored by: The FreeBSD Foundation
* ctfconvert: Rip out STABS supportMark Johnston2022-02-106-1825/+0
| | | | | | | | | It is unused on FreeBSD and complicates some efforts to modify the CTF format to permit wider type IDs, so remove it. No functional change intended. MFC after: 1 week Sponsored by: The FreeBSD Foundation
* libctf: Rip out CTFv1 supportMark Johnston2022-02-101-35/+1
| | | | | | | | | CTFv1 was obsolete before libctf was imported into FreeBSD, and ctfconvert/ctfmerge can emit only CTFv2. Make ctf.h a bit easier to maintain by ripping v1 support out. No functional change intended. MFC after: 1 week Sponsored by: The FreeBSD Foundation
* libctf: Use ctf_type_t instead of struct ctf_typeMark Johnston2022-02-101-1/+1
| | | | | | | | For consistency with other CTF toolchain code. No functional change intended. Fixes: 105fd928b0b5 ("libctf: Improve check for duplicate SOU definitions in ctf_add_type()") MFC after: 1 week
* 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
* ctfconvert: Handle arrays of empty structsMark Johnston2021-12-311-2/+10
| | | | | | | | | | | Members with such a type will legitimately have a size of zero, so don't emit a warning. PR: 260818 Reviewed by: bz MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D33700
* 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
* libctf: Improve check for duplicate SOU definitions in ctf_add_type()Mark Johnston2021-10-041-27/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When copying a struct or union from one CTF container to another, ctf_add_type() checks whether it matches an existing type in the destination container. It does so by looking for a type with the same name and kind as the new type, and if one exists, it iterates over all members of the source type and checks whether a member with matching name and offset exists in the matched destination type. This can produce false positives, for example because member types are not compared, but this is not expected to arise in practice. If the match fails, ctf_add_type() returns an error. The procedure used for member comparison breaks down in the face of anonymous struct and union members. ctf_member_iter() visits each member in the source definition and looks up the corresponding member in the desination definition by name using ctf_member_info(), but this function will descend into anonymous members and thus fail to match. Fix the problem by introducing a custom comparison routine which does not assume member names are unique. This should also be faster for types with many members; in the previous scheme, membcmp() would perform a linear scan of the desination type's members to perform a lookup by name. The new routine steps through the members of both types in a single loop. PR: 258763 MFC after: 2 weeks Sponsored by: The FreeBSD Foundation
* 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: 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
* dtrace tests: Fix tst.system.d after ping/ping6 unificationMark Johnston2021-04-231-3/+3
| | | | | MFC after: 1 week Sponsored by: The FreeBSD Foundation