aboutsummaryrefslogtreecommitdiff
path: root/cddl/contrib
Commit message (Collapse)AuthorAgeFilesLines
* ctfmerge: fix segfault when building on macOSMark Peek10 days2-30/+5
| | | | | | | | | | | | | The barrier code was using semaphores which have been deprecated in macOS and not working at all, causing a race condition. Since macOS does not have pthread_barrier_*(), this change uses a condition variable instead. PR: 290958 Reported by: wosch MFC after: 2 weeks Reviewed by: imp, markj Differential Revision: https://reviews.freebsd.org/D54018
* dtrace tests: Update names after the syscall::exit probe was renamedMark Johnston10 days4-4/+4
| | | | | MFC after: 1 week Fixes: e7e964cb2ebd ("syscalls: normalize _exit(2) declerations")
* dtrace.1: remove sparcMinsoo Choo10 days1-5/+1
| | | | | | | | Signed-off-by: Minsoo Choo <minsoochoo0122@proton.me> Reviewed by: markj MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/1907
* opensolaris: remove references to sparcMinsoo Choo10 days6-45/+3
| | | | | | | | Signed-off-by: Minsoo Choo <minsoochoo0122@proton.me> Reviewed by: markj MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/1907
* libdtrace: remove sparc codeMinsoo Choo10 days2-458/+0
| | | | | | | | Signed-off-by: Minsoo Choo <minsoochoo0122@proton.me> Reviewed by: markj MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/1907
* dtrace: remove sparc testsMinsoo Choo10 days22-1185/+0
| | | | | | | | Signed-off-by: Minsoo Choo <minsoochoo0122@proton.me> Reviewed by: markj MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/1907
* dtrace_priv.4: Document the DTrace priv providerMateusz Piotrowski2025-11-121-1/+2
| | | | | | Fixes: 6efcc2f26ab0 Add static tracing for privilege checking MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D53630
* dtrace.1: Document DTRACE_DEBUGMateusz Piotrowski2025-11-081-1/+9
| | | | | | Reviewed by: markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D53627
* dtrace.1: Fix mdoc macros around -xMateusz Piotrowski2025-11-061-1/+1
| | | | | | There should be no space between -x's "arg" and "=value". MFC after: 3 days
* dtrace_pid.4: Document the DTrace PID providerMateusz Piotrowski2025-11-061-1/+2
| | | | | MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D51287
* dtrace_callout_execute.4: Document the DTrace callout_execute providerMateusz Piotrowski2025-11-041-1/+2
| | | | | | MFC after: 2 weeks Fixes: 91dd9aae1ab8 Add explicit static DTrace tracing to the callout mechanism Differential Revision: https://reviews.freebsd.org/D51397
* dtrace_vfs.4: Document the DTrace vfs providerMateusz Piotrowski2025-11-031-1/+2
| | | | | | Reviewed by: bcr MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D51317
* dtrace: Use a size_t to represent a buffer size in the printm actionMark Johnston2025-09-101-5/+4
| | | | | | | | | | | | | | | | | | | | printm is specific to the FreeBSD dtrace port. I believe it's effectively the same as tracemem(), though printm apparently predates it. It stores the size of the buffer of traced data inline. Currently it represents that size using a uintptr_t, which isn't really right and poses challenges when porting to CHERI because `DTRACE_STORE(uintptr_t, ...` requires the destination to be suitably aligned, but this isn't necessary since we're just storing a size. Convert to using a size_t. This should be a no-op since sizeof(uintptr_t) == sizeof(size_t) on non-CHERI platforms (and besides that I don't see a reason to use printm() when tracemem() is available and is simpler to use.) Reviewed by: Domagoj Stolfa, avg MFC after: 2 weeks Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D52055
* dtrace.1: Document security.bsd.allow_destructive_dtraceMateusz Piotrowski2025-08-011-1/+24
| | | | | | | | PR: 288284 Reviewed by: bcr, markj MFC after: 3 days Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D51633
* libdtrace: Permit taking the address of an identifier without type infoMark Johnston2025-07-213-3/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | Symbols defined using assembler directives lack type info, but in this case one ought to be able to cast a pointer to the symbol and dereference the pointer to get a value. Without this change, D disallows this trick since it requires all identifiers to have a type. Relax the rules slightly and allow an identifier to have type "void" if we know we're just taking its address. As a result, the following dtrace invocation works: dtrace -n 'tick-1s {printf("%d", *(int *)&`ticks);}' In particular, since commit b2b974f7ef4c ("clock: Simplify subr_ticks and rename"), "ticks" does not have any type info associated with it, so its value couldn't be printed. This trick provides a workaround and is probably generally useful. Add a regression test which exercises this functionality. PR: 287752 Reviewed by: avg MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D51417
* libdtrace: Use a designated array initializer for dt_cook_funcs[]Mark Johnston2025-07-211-24/+24
| | | | | | Also make the array const. No functional change intended. MFC after: 1 week
* dtrace_fbt.4: Document the DTrace fbt providerMateusz Piotrowski2025-07-161-1/+2
| | | | | | | | | Reported by: markj Reviewed by: christos, markj (earlier version), ziaee Obtained from: Mark Johnston, DTrace, FreeBSD Journal, May 2014 Obtained from: https://wiki.freebsd.org/DTrace/One-Liners MFC after: 2 weeks Relnotes: yes
* dtrace.1: Document evaltimeMateusz Piotrowski2025-07-141-1/+47
| | | | | | Reviewed by: christos, ziaee MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D51301
* dtrace_profile.4: Document the DTrace profile providerMateusz Piotrowski2025-07-141-0/+1
| | | | | | | Event: Berlin Hackathon 202507 Reviewed by: bcr, christos Relnotes: yes Differential Revision: https://reviews.freebsd.org/D51278
* d.7: Document the DTrace scripting languageMateusz Piotrowski2025-07-141-1/+2
| | | | | | | Reviewed by: bcr, christos, ziaee Event: Berlin Hackathon 202507 Relnotes: yes Differential Revision: https://reviews.freebsd.org/D51268
* dtrace_dtrace.4: Document the DTrace dtrace providerMateusz Piotrowski2025-07-141-0/+1
| | | | | | | Reviewed by: bcr, christos Event: Berlin Hackathon 202507 Relnotes: yes Differential Revision: https://reviews.freebsd.org/D51267
* dtrace.1: Reference dwatch(1) and tracing(7)Mateusz Piotrowski2025-07-121-1/+3
| | | | | Reviewed by: bcr Event: Berlin 2025 Hackathon
* dtrace: fix symbol address resolutionJiacong Fang2025-07-071-9/+5
| | | | | | | | | | | | | | | Dtrace assumes only ELF sections of type SHT_PROGBITS or SHT_NOBITS occupy memory space. However, sections with SHF_ALLOC flag also consume memory space. Moreover, the symbol address initialization skips symbols at the very beginning of a section in ET_REL KLDs. Fix: Check section flag for calculating section offset, and disable the skipping at the beginning of a section. PR: 288000 Reviewed by: markj MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D51188
* tests: Adapt oclo tests to FreeBSDRicardo Branco2025-07-063-53/+110
| | | | | MFC after: 1 month Pull Request: https://github.com/freebsd/freebsd-src/pull/1698
* tests: Add Illumos oclo tests for O_CLOEXEC & O_CLOFORKRicardo Branco2025-07-063-0/+1640
| | | | | | | | Taken from last commit bb9475a199514dcace79d04d02c1eff05d65b94f from https://github.com/illumos/illumos-gate/tree/master/usr/src/test/os-tests/tests/oclo MFC after: 1 month Pull Request: https://github.com/freebsd/freebsd-src/pull/1698
* dtrace.1: Mention providers in SEE ALSOMateusz Piotrowski2025-06-141-1/+12
| | | | | | | Reviewed by: bnovkov, christos, markj Approved by: bnovkov (mentor), christos (mentor), markj (mentor) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D50852
* dtrace tests: Fix nits in some test programsMark Johnston2025-06-042-5/+7
| | | | | | | | Otherwise these tests fail spuriously, depending on which compiler is installed as cc. MFC after: 2 weeks Sponsored by: Innovate UK
* libdtrace: Fix formatting of messages about dropsMark Johnston2025-04-152-12/+23
| | | | | | | dt_oformat_drop() should only be called when in structured output mode. Reviewed by: Domagoj Stolfa Fixes: 93f27766a7e1 ("dtrace: Add the 'oformat' libdtrace option")
* libdtrace: Fix an off-by-one in CPU ID handlingMark Johnston2025-03-105-11/+23
| | | | | | | | | | | | | | | | The illumos-specific _SC_CPUID_MAX is the largest CPU ID in the system. This was mapped to _SC_NPROCESSORS_CONF, which is the total number of CPUs recognized by the kernel. If CPU IDs are contiguous, as is the case on amd64 and arm64, this value is one greater than the maximum ID. As a result, when consuming per-CPU dtrace buffers, libdtrace tries to fetch from a non-existent CPU. This is mostly harmless in practice, but still wrong. As we don't have a sysconf value for the maximum CPU ID, add a wrapper which fetches it using the kern.smp.maxid sysctl. MFC after: 2 weeks Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D49243
* libdtrace: Fix an off-by-one in the priority queue implementationMark Johnston2025-03-101-3/+3
| | | | | | | | | | | | | | The zero'th index in the array is unused, so a priority queue of N elements needs N+1 array slots. Fix the allocation. Also fix the assertion in dt_pq_insert(): the assertion needs to be checked after incrementing the count of items in the priority queue, otherwise it can miss an overflow. Reported by: CHERI MFC after: 2 weeks Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D49242
* libdtrace: Use designators to initialize the opcode arrayMark Johnston2025-01-291-80/+80
| | | | | | | No functional change intended. MFC after: 2 weeks Sponsored by: Innovate UK
* libdtrace: Generalize handling of data models a bitMark Johnston2025-01-253-5/+11
| | | | | | | | | | Make it easier to support data models other than ILP32 and LP64 by avoiding constructs which assume that it must be one or the other. No functional change intended. MFC after: 2 weeks Sponsored by: Innovate UK
* libdtrace: Use C99 designated initializers for dt_idops_tMark Johnston2025-01-221-24/+24
| | | | | | | No functional change intended. MFC after: 1 week Sponsored by: Innovate UK
* libdtrace: Be less strict when comparing pointer typesMark Johnston2025-01-011-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | If one of two pointers refers to a forward declaration, let the pointers be compatible so long as the referred types have the same name. Otherwise we can get spurious errors. To give a specific example, this can happen when ipfw_nat.ko is loaded before ipfw.ko and /usr/lib/dtrace/ipfw.d is processed. Currently, ipfw_nat.ko does not have a definition for struct inpcb (i.e., none of its files include in_pcb.h), so in the CTF type graph, struct ip_fw_args' "inp" member refers to a forward declaration, represented in CTF with CTF_K_FORWARD. Then, when libdtrace processes the ipfw_match_info_t translator in ipfw.d, it decides that the "inp" field assignment is incorrect because the two pointers are incompatible. However, there's no harm in allowing this assignment. Add some logic to dt_node_is_ptrcompat() to detect this case and declare the pointers as compatible so long as the name of the thing they refer to is the same, similar to how any pointer is compatible with a void *. Reported by: marck Reviewed by: Domagoj Stolfa <domagoj.stolfa@gmail.com> MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D48254
* 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
* libdtrace: Compute the relocation offset for all non-ET_REL objectsMark Johnston2024-07-101-11/+13
| | | | | | | | The use of an ifdef here most likely carries over from when the dtrace port only worked on x86 platforms. MFC after: 2 weeks Sponsored by: Innovate UK
* libdtrace: Use designated initializers for modules ops tablesMark Johnston2024-07-101-8/+8
| | | | | | | No functional change intended. MFC after: 1 week Sponsored by: Innovate UK
* 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
* libdtrace: Work around a warning from flexMark Johnston2024-06-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When compiling dt_lex.l, flex produces warnings of the form: dt_lex.l:413: warning, trailing context made variable due to preceding '|' action dt_lex.l:412: warning, dangerous trailing context dt_lex.l:412: warning, dangerous trailing context Here, trailing context refers to the use of "$", which expands to "/\n". The meaning behind these warnings is described in the first two paragraphs of the flex manual's DEFICIENCIES/BUGS section: Some trailing context patterns cannot be properly matched and generate warning messages ("dangerous trailing context"). These are patterns where the ending of the first part of the rule matches the beginning of the second part, such as "zx*/xy*", where the 'x*' matches the 'x' at the beginning of the trailing context. (Note that the POSIX draft states that the text matched by such patterns is undefined.) For some trailing context rules, parts which are actually fixed-length are not recognized as such, leading to the above mentioned performance loss. In particular, parts using '|' or {n} (such as "foo{3}") are always considered variable-length. Here, the warnings appear to be bogus in this case. The lexer has no problem matching either of the referenced patterns, e.g., printf("foobar or # 1 "asdfasdf Introduce a small amount of code duplication to silence the warning. MFC after: 2 weeks
* ctfmerge: demote "No ctf sections found" to a warningEd Maste2024-02-141-8/+2
| | | | | | | | | | | | | | | | | | | | If there are no CTF sections then ctfmerge just has nothing to do; it should not be an error. Note that ctfmerge has an option to require CTF: -t Make sure that all object files have a CTF section. Before this change, this option explicitly exited without error if none of the object files have CTF sections, with the comment: If we're verifying that C files have CTF, it's safe to assume that in this case, we're building only from assembly inputs. PR: 276930 Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D43878
* ctfmerge: Remove function cast of strcompare() for qsort()Minsoo Choo2024-02-031-1/+1
| | | | | | Reviewed by: emaste MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D43715
* 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-1039-165/+3744
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* ctfconvert: Handle DW_AT_data_bit_offsetMark Johnston2024-01-021-1/+3
| | | | | | | | | This attribute is new in DWARF 4 and supersedes DW_AT_bit_offset. PR: 276059 Reported by: rscheff Tested by: rscheff MFC after: 1 week
* libdtrace: Fix line number reporting in error messagesMark Johnston2023-12-311-0/+2
| | | | MFC after: 1 week
* Trim various $FreeBSD$John Baldwin2023-10-102-4/+0
| | | | | | Approved by: markj (cddl/contrib changes) Reviewed by: imp, emaste Differential Revision: https://reviews.freebsd.org/D41961
* 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