aboutsummaryrefslogtreecommitdiff
path: root/sys/cddl/dev/dtrace
Commit message (Collapse)AuthorAgeFilesLines
...
* dtrace_getarg: remove stray return statement on amd64, powerpcAndriy Gapon2015-09-292-2/+0
| | | | | | | MFC after: 10 days Notes: svn path=/head/; revision=288361
* Remove the arg0 field from struct amd64_frame. Its existence was a bug,Mark Johnston2015-09-111-1/+1
| | | | | | | | | | | | | | | since on amd64 the first argument to a function is generally not on the stack. Revert an old DTrace bug fix to some code that assumed that sizeof(struct amd64_frame) == 16. Reviewed by: jhb, kib Sponsored by: EMC / Isilon Storage Division Differential Revision: https://reviews.freebsd.org/D3255 Notes: svn path=/head/; revision=287644
* When checking for the valid value of the frame pointer, verify that itKonstantin Belousov2015-07-162-8/+8
| | | | | | | | | | | | | | | belongs to the kernel stack address range for the thread. Right now, code checks that new frame is not farther then KSTACK_PAGES pages from the current frame, which allows the address to point past the top of the stack. Reviewed by: andrew, emaste, markj Differential revision: https://reviews.freebsd.org/D3108 Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Notes: svn path=/head/; revision=285643
* Use single instance of the identical INKERNEL() and PMC_IN_KERNEL()Konstantin Belousov2015-07-021-3/+0
| | | | | | | | | | | | | | | | macros on amd64 and i386. Move the definition to machine/param.h. kgdb defines INKERNEL() too, the conflict is resolved by renaming kgdb version to PINKERNEL(). On i386, correct the lowest kernel address. After the shared page was introduced, USRSTACK no longer points to the last user address + 1 [*] Submitted by: Oliver Pinter [*] Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=285041
* First cut of DTrace for AArch64.Ruslan Bukin2015-07-014-0/+822
| | | | | | | | | Reviewed by: andrew, emaste Sponsored by: ARM Limited Differential Revision: https://reviews.freebsd.org/D2738 Notes: svn path=/head/; revision=285009
* Don't re-define LOCORE when dtrace is built-in to the kernel.Ruslan Bukin2015-06-101-1/+0
| | | | Notes: svn path=/head/; revision=284213
* Remove unused references to calltrap.Mark Johnston2015-05-252-4/+0
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=283509
* Remove some commented-out upstream code for handling traps from usermodeMark Johnston2015-05-102-224/+0
| | | | | | | DTrace probes. This handling is already done in trap() on i386 and amd64. Notes: svn path=/head/; revision=282744
* Fix DTrace's panic() action.Mark Johnston2015-04-246-477/+0
| | | | | | | | | | | | | | | It would previously call into some unfinished Solaris compatibility code and return without actually calling panic(9). The compatibility code is unneeded, however, so just remove it and have dtrace_panic() call vpanic(9) directly. Differential Revision: https://reviews.freebsd.org/D2349 Reviewed by: avg MFC after: 2 weeks Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=281916
* libdtrace: add support for lazyload mode.Mark Johnston2015-04-081-3/+4
| | | | | | | | | | | | | | Passing "-x lazyload" to dtrace -G during compilation causes dtrace(1) to not link drti.o into the output object file, so the USDT probes are not created during process startup. Instead, dtrace(1) will automatically discover and create probes on the process' behalf when attaching. Differential Revision: https://reviews.freebsd.org/D2203 Reviewed by: rpaulo MFC after: 1 month Notes: svn path=/head/; revision=281257
* Import a missing piece of commit b8fac8e162eda7e98d from illumos-gate.Mark Johnston2015-03-302-2/+44
| | | | | | | | | | | | This adds an upper bound, dtrace_ustackdepth_max, to the number of frames traversed when computing the userland stack depth. Some programs - notably firefox - are otherwise able to trigger an infinite loop in dtrace_getustack_common(), causing a panic. MFC after: 1 week Notes: svn path=/head/; revision=280834
* On ARM, unlike some other architectures, saved $pc values from in-kernelRobert Watson2015-03-151-6/+6
| | | | | | | | | | | | traps do appear in the regular call stack, rather than only in a special trap frame, so we don't need to inject the trap-frame $pc into a returned stack trace in DTrace. MFC after: 3 days Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=280038
* Add support for walltimestamp to DTrace on ARM.George V. Neville-Neil2015-03-071-3/+4
| | | | Notes: svn path=/head/; revision=279721
* dtrace_cas32 and dtrace_casptr should retrn the data loaded from targetAndrew Turner2015-03-051-5/+3
| | | | | | | | | not the new value. Sponsored by: ABT Systems Ltd Notes: svn path=/head/; revision=279669
* Add the MD parts of dtrace needed to use fbt on ARM. For this we need toAndrew Turner2015-03-051-6/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | emulate the instructions used in function entry and exit. For function entry ARM will use a push instruction to push up to 16 registers to the stack. While we don't expect all 16 to be used we need to handle any combination the compiler may generate, even if it doesn't make sense (e.g. pushing the program counter). On function return we will either have a pop or branch instruction. The former is similar to the push instruction, but with care to make sure we update the stack pointer and program counter correctly in the cases they are either in the list of registers or not. For branch we need to take the 24-bit offset, sign-extend it, and add that number of 4-byte words to the program counter. Care needs to be taken as, due to historical reasons, the address the branch is relative to is not the current instruction, but 8 bytes later. This allows us to use the following probes on ARM boards: dtrace -n 'fbt::malloc:entry { stack() }' and dtrace -n 'fbt::free:return { stack() }' Differential Revision: https://reviews.freebsd.org/D2007 Reviewed by: gnn, rpaulo Sponsored by: ABT Systems Ltd Notes: svn path=/head/; revision=279667
* Fix build after unifying DAR/DEAR storage in trap frame.Nathan Whitehorn2015-03-051-1/+1
| | | | Notes: svn path=/head/; revision=279665
* Fix the dtrace ARM atomic compare-and-set functions. These functions areAndrew Turner2015-03-012-31/+22
| | | | | | | | | | | | | | expected to return the data in the memory location pointed at by target after the operation. The FreeBSD atomic functions previously used return either 0 or 1 to indicate if the comparison succeeded or not respectively. With this change these functions only support ARMv6 and later are supported by these functions. Sponsored by: ABT Systems Ltd Notes: svn path=/head/; revision=279483
* Use the ARM unwinder with dtrace to extract the stack when asked. With thisAndrew Turner2015-02-191-89/+28
| | | | | | | | | | | | | | | | | | | | | | | | | dtrace is able to display a stack trace similar to the one below. # dtrace -p 603 -n 'tcp:kernel::receive { stack(); }' 0 70 :receive kernel`ip_input+0x140 kernel`netisr_dispatch_src+0xb8 kernel`ether_demux+0x1c4 kernel`ether_nh_input+0x3a8 kernel`netisr_dispatch_src+0xb8 kernel`ether_input+0x60 kernel`cpsw_intr_rx+0xac kernel`intr_event_execute_handlers+0x128 kernel`ithread_loop+0xb4 kernel`fork_exit+0x84 kernel`swi_exit kernel`swi_exit Tested by: gnn Sponsored by: ABT Systems Ltd Notes: svn path=/head/; revision=278997
* Initial version of DTrace on ARM32.George V. Neville-Neil2015-02-104-0/+871
| | | | | | | | Submitted by: Howard Su based on work by Oleksandr Tymoshenko Reviewed by: ian, andrew, rpaulo, markj Notes: svn path=/head/; revision=278529
* MFV r266993:Pedro F. Giffuni2015-02-032-16/+0
| | | | | | | | | | | | | | | 4469 DTrace helper tracing should be dynamic Reference: https://illumos.org/issues/4469 Obtained from: Illumos Phabric: D1551 Reviewed by: markj MFC after: 2 weeks Notes: svn path=/head/; revision=278166
* Mechanically convert cddl sun #ifdef's to illumosSteven Hartland2015-01-174-17/+17
| | | | | | | | | | | | | | | Since the upstream for cddl code is now illumos not sun, mechanically convert all sun #ifdef's to illumos #ifdef's which have been used in all newer code for some time. Also do a manual pass to correct the use if #ifdef comments as per style(9) as well as few uses of #if defined(__FreeBSD__) vs #ifndef illumos. MFC after: 1 month Sponsored by: Multiplay Notes: svn path=/head/; revision=277300
* Restore the trap type argument to the DTrace trap hook, removed in r268600.Mark Johnston2014-12-234-10/+8
| | | | | | | | | It's redundant at the moment since it can be obtained from the trapframe on the architectures where DTrace is supported, but this won't be the case with ARM. Notes: svn path=/head/; revision=276142
* Fix multiple incorrect SYSCTL arguments in the kernel:Hans Petter Selasky2014-10-211-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Wrong integer type was specified. - Wrong or missing "access" specifier. The "access" specifier sometimes included the SYSCTL type, which it should not, except for procedural SYSCTL nodes. - Logical OR where binary OR was expected. - Properly assert the "access" argument passed to all SYSCTL macros, using the CTASSERT macro. This applies to both static- and dynamically created SYSCTLs. - Properly assert the the data type for both static and dynamic SYSCTLs. In the case of static SYSCTLs we only assert that the data pointed to by the SYSCTL data pointer has the correct size, hence there is no easy way to assert types in the C language outside a C-function. - Rewrote some code which doesn't pass a constant "access" specifier when creating dynamic SYSCTL nodes, which is now a requirement. - Updated "EXAMPLES" section in SYSCTL manual page. MFC after: 3 days Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=273377
* Fix the stack tracing for dtrace/powerpc.Justin Hibbits2014-09-171-19/+121
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Fix the stack tracing for dtrace/powerpc by using the trapexit/asttrapexit return address sentinels instead of checking within the kernel address space. As part of this, I had to add new inline functions. FBT traces the kernel, so we have to have special case handling for this, since a trap will create a full new trap frame, and there's no way to pass around the 'real' stack. I handle this by special-casing 'aframes == 0' with the trap frame. If aframes counts out to the trap frame, then assume we're looking for the full kernel trap frame, so switch to the real stack pointer. Test Plan: Tested on powerpc64 Reviewers: rpaulo, markj, nwhitehorn Reviewed By: markj, nwhitehorn Differential Revision: https://reviews.freebsd.org/D788 MFC after: 3 week Relnotes: Yes Notes: svn path=/head/; revision=271697
* Use a C wrapper for trap() instead of checking and calling the DTrace trapMark Johnston2014-07-191-3/+1
| | | | | | | | | | | hook in assembly. Suggested by: kib Reviewed by: kib (original version) X-MFC-With: r268600 Notes: svn path=/head/; revision=268869
* Invoke the DTrace trap handler before calling trap() on amd64. This matchesMark Johnston2014-07-144-19/+18
| | | | | | | | | | | | | | the upstream implementation and helps ensure that a trap induced by tracing fbt::trap:entry is handled without recursively generating another trap. This makes it possible to run most (but not all) of the DTrace tests under common/safety/ without triggering a kernel panic. Submitted by: Anton Rang <anton.rang@isilon.com> (original version) Phabric: D95 Notes: svn path=/head/; revision=268600
* Pull in r267961 and r267973 again. Fix for issues reported will follow.Hans Petter Selasky2014-06-281-2/+1
| | | | Notes: svn path=/head/; revision=267992
* Revert r267961, r267973:Glen Barber2014-06-271-1/+2
| | | | | | | | | | | | | These changes prevent sysctl(8) from returning proper output, such as: 1) no output from sysctl(8) 2) erroneously returning ENOMEM with tools like truss(1) or uname(1) truss: can not get etype: Cannot allocate memory Notes: svn path=/head/; revision=267985
* Extend the meaning of the CTLFLAG_TUN flag to automatically check ifHans Petter Selasky2014-06-271-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | there is an environment variable which shall initialize the SYSCTL during early boot. This works for all SYSCTL types both statically and dynamically created ones, except for the SYSCTL NODE type and SYSCTLs which belong to VNETs. A new flag, CTLFLAG_NOFETCH, has been added to be used in the case a tunable sysctl has a custom initialisation function allowing the sysctl to still be marked as a tunable. The kernel SYSCTL API is mostly the same, with a few exceptions for some special operations like iterating childrens of a static/extern SYSCTL node. This operation should probably be made into a factored out common macro, hence some device drivers use this. The reason for changing the SYSCTL API was the need for a SYSCTL parent OID pointer and not only the SYSCTL parent OID list pointer in order to quickly generate the sysctl path. The motivation behind this patch is to avoid parameter loading cludges inside the OFED driver subsystem. Instead of adding special code to the OFED driver subsystem to post-load tunables into dynamically created sysctls, we generalize this in the kernel. Other changes: - Corrected a possibly incorrect sysctl name from "hw.cbb.intr_mask" to "hw.pcic.intr_mask". - Removed redundant TUNABLE statements throughout the kernel. - Some minor code rewrites in connection to removing not needed TUNABLE statements. - Added a missing SYSCTL_DECL(). - Wrapped two very long lines. - Avoid malloc()/free() inside sysctl string handling, in case it is called to initialize a sysctl from a tunable, hence malloc()/free() is not ready when sysctls from the sysctl dataset are registered. - Bumped FreeBSD version to indicate SYSCTL API change. MFC after: 2 weeks Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=267961
* MFV illumos r266986:Rui Paulo2014-06-261-0/+1
| | | | | | | | | | | 2915 DTrace in a zone should see "cpu", "curpsinfo", et al 2916 DTrace in a zone should be able to access fds[] 2917 DTrace in a zone should have limited provider access MFC after: 2 weeks Notes: svn path=/head/; revision=267929
* Continue the crusade towards a dev_clone()-free kernel, removing itsDavide Italiano2014-06-254-84/+1
| | | | | | | | | | | | usage from dtrace. The dtrace code already uses cdevpriv(9) since FreeBSD 8, so this change should be quite harmless. Reviewed by: markj Approved by: markj MFC after: never Notes: svn path=/head/; revision=267851
* Fix some bugs when fetching probe arguments in i386. Firstly ensure thatMark Johnston2014-06-232-10/+5
| | | | | | | | | | | | | | the 4 byte-aligned dtrace_invop_callsite can be found and that it immediately follows the call to dtrace_invop(). Secondly, fix some pointer arithmetic to account for differences between struct i386_frame and illumos' struct frame. Finally, ensure that dtrace_getarg() isn't inlined. It works by following a fixed number of frame pointers to the probe site, so inlining breaks it. MFC after: 3 weeks Notes: svn path=/head/; revision=267761
* Fix a couple of bugs on amd64 when fetching probe arguments beyond theMark Johnston2014-06-231-10/+11
| | | | | | | | | | | | | | | | first five for probes entered through a UD fault (i.e. FBT probes). Specifically, handle the fact that dtrace_invop_callsite must be 16 byte-aligned and thus may not immediately follow the call to dtrace_invop() in dtrace_invop_start(). Also fetch register arguments and the stack pointer through a struct trapframe instead of a struct reg. PR: 191260 Submitted by: luke.tw@gmail.com MFC after: 3 weeks Notes: svn path=/head/; revision=267759
* Update dis_tables.c to the latest Illumos version.Peter Grehan2014-05-151-17/+188
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This includes decodes of recent Intel instructions, in particular VT-x and related instructions. This allows the FBT provider to locate the exit points of routines that include these new instructions. Illumos issues: 3414 Need a new word of AT_SUN_HWCAP bits 3415 Add isainfo support for f16c and rdrand 3416 Need disassembler support for rdrand and f16c 3413 isainfo -v overflows 80 columns 3417 mdb disassembler confuses rdtscp for invlpg 1518 dis should support AMD SVM/AMD-V/Pacifica instructions 1096 i386 disassembler should understand complex nops 1362 add kvmstat for monitoring of KVM statistics 1363 add vmregs[] variable to DTrace 1364 need disassembler support for VMX instructions 1365 mdb needs 16-bit disassembler support This corresponds to Illumos-gate (github) version eb23829ff08a873c612ac45d191d559394b4b408 Reviewed by: markj MFC after: 1 week Notes: svn path=/head/; revision=266103
* DTrace's pid provider works by inserting breakpoint instructions at probeMark Johnston2014-04-141-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sites and installing a hook at the kernel's trap handler. The fasttrap code will emulate the overwritten instruction in some common cases, but otherwise copies it out into some scratch space in the traced process' address space and ensures that it's executed after returning from the trap. In Solaris and illumos, this (per-thread) scratch space comes from some reserved space in TLS, accessible via the fs segment register. This approach is somewhat unappealing on FreeBSD since it would require some modifications to rtld and jemalloc (for static TLS) to ensure that TLS is executable, and would thus introduce dependencies on their implementation details. I think it would also be impossible to safely trace static binaries compiled without these modifications. This change implements the functionality in a different way, by having fasttrap map pages into the target process' address space on demand. Each page is divided into 64-byte chunks for use by individual threads, and fasttrap's process descriptor struct has been extended to keep track of any scratch space allocated for the corresponding process. With this change it's possible to trace all libc functions in a program, e.g. with pid$target:libc.so.*::entry {@[probefunc] = count();} Previously this would generally cause the victim process to crash, as tracing memcpy on amd64 requires the functionality described above. Tested by: Prashanth Kumar <pra_udupi@yahoo.co.in> (earlier version) MFC after: 6 weeks Notes: svn path=/head/; revision=264434
* Expose a few DTrace parameters as sysctls under kern.dtrace and addMark Johnston2014-03-012-3/+14
| | | | | | | | | | | descriptions for several existing sysctls. PR: 187027 Submitted by: Fedor Indutny <fedor@indutny.com> (original version) MFC after: 2 weeks Notes: svn path=/head/; revision=262665
* Fix the struct reg mappings for i386 and amd64, which differ between illumosMark Johnston2014-02-271-0/+51
| | | | | | | | | | and FreeBSD. Submitted by: Prashanth Kumar <pra_udupi@yahoo.co.in> MFC after: 2 weeks Notes: svn path=/head/; revision=262543
* Move some files that are identical on i386 and amd64 to an x86 subdirectoryMark Johnston2014-02-276-5078/+0
| | | | | | | | | | rather than keeping duplicate copies. Discussed with: avg MFC after: 1 week Notes: svn path=/head/; revision=262542
* Allocate the probe ID unrhdr before the DTrace kld_* event handlers areMark Johnston2013-12-311-2/+2
| | | | | | | | | | registered. Otherwise there is a small window during which probe IDs may be allocated before the unrhdr is allocated. MFC after: 2 weeks Notes: svn path=/head/; revision=260132
* Revert r260091. The vmem calls seem to be slower than the *_unr() calls thatMark Johnston2013-12-312-4/+3
| | | | | | | | they replaced, which is important considering that probe IDs are allocated during process startup for USDT probes. Notes: svn path=/head/; revision=260131
* Now that vmem(9) is available, use vmem arenas to allocate probe andMark Johnston2013-12-302-3/+4
| | | | | | | | | | | aggregation IDs, as is done in the upstream illumos code. This still requires some FreeBSD-specific code, as our vmem API is not identical to the one in illumos. Submitted by: Mike Ma <mikemandarine@gmail.com> Notes: svn path=/head/; revision=260091
* dtrace sdt: remove the ugly sname parameter of SDT_PROBE_DEFINEAndriy Gapon2013-11-261-1/+1
| | | | | | | | | | | In its stead use the Solaris / illumos approach of emulating '-' (dash) in probe names with '__' (two consecutive underscores). Reviewed by: markj MFC after: 3 weeks Notes: svn path=/head/; revision=258622
* - For kernel compiled only with KDTRACE_HOOKS and not any lock debuggingAttilio Rao2013-11-251-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | option, unbreak the lock tracing release semantic by embedding calls to LOCKSTAT_PROFILE_RELEASE_LOCK() direclty in the inlined version of the releasing functions for mutex, rwlock and sxlock. Failing to do so skips the lockstat_probe_func invokation for unlocking. - As part of the LOCKSTAT support is inlined in mutex operation, for kernel compiled without lock debugging options, potentially every consumer must be compiled including opt_kdtrace.h. Fix this by moving KDTRACE_HOOKS into opt_global.h and remove the dependency by opt_kdtrace.h for all files, as now only KDTRACE_FRAMES is linked there and it is only used as a compile-time stub [0]. [0] immediately shows some new bug as DTRACE-derived support for debug in sfxge is broken and it was never really tested. As it was not including correctly opt_kdtrace.h before it was never enabled so it was kept broken for a while. Fix this by using a protection stub, leaving sfxge driver authors the responsibility for fixing it appropriately [1]. Sponsored by: EMC / Isilon storage division Discussed with: rstone [0] Reported by: rstone [1] Discussed with: philip Notes: svn path=/head/; revision=258541
* Remove references to an unused fasttrap probe hook, and remove theMark Johnston2013-10-311-8/+0
| | | | | | | | | | | corresponding x86 trap type. Userland DTrace probes are currently handled by the other fasttrap hooks (dtrace_pid_probe_ptr and dtrace_return_probe_ptr). Discussed with: rpaulo Notes: svn path=/head/; revision=257417
* ELF PowerPC64 ABI puts the LR save word at 16 byte offset, not 8.Justin Hibbits2013-10-251-1/+2
| | | | Notes: svn path=/head/; revision=257081
* When fetching function arguments out of a frame on amd64, explicitly selectMark Johnston2013-10-211-1/+21
| | | | | | | | | | | | | the register based on the argument index rather than relying on the fields in struct reg to be in the right order. This assumption is incorrect on FreeBSD and generally led to bogus argument values for the sixth argument of PID and USDT probes; the first five are passed directly to dtrace_probe() via the fasttrap trap handler and so were correctly handled. MFC after: 2 weeks Notes: svn path=/head/; revision=256822
* Add a function, memstr, which can be used to convert a buffer ofMark Johnston2013-10-161-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | null-separated strings to a single string. This can be used to print the full arguments of a process using execsnoop (from the DTrace toolkit) or with the following one-liner: dtrace -n 'syscall::execve:return {trace(curpsinfo->pr_psargs);}' Note that this relies on the process arguments being cached via the struct proc, which means that it will not work for argvs longer than kern.ps_arg_cache_limit. However, the following rather non-portable script can be used to extract any argv at exec time: fbt::kern_execve:entry { printf("%s", memstr(args[1]->begin_argv, ' ', args[1]->begin_envv - args[1]->begin_argv)); } The debug.dtrace.memstr_max sysctl limits the maximum argument size to memstr(). Thanks to Brendan Gregg for helpful comments on freebsd-dtrace. Tested by: Fabian Keil (earlier version) MFC after: 2 weeks Notes: svn path=/head/; revision=256571
* Initialize and free the DTrace taskqueue in the dtrace module load/unloadMark Johnston2013-10-082-0/+4
| | | | | | | | | | | | | | | handlers rather than in the dtrace device open/close methods. The current approach can cause a panic if the device is closed which the taskqueue thread is active, or if a kernel module containing a provider is unloaded while retained enablings are present and the dtrace device isn't opened. Submitted by: gibbs (original version) Reviewed by: gibbs Approved by: re (glebius) MFC after: 2 weeks Notes: svn path=/head/; revision=256148
* - Use make_dev_credf(MAKEDEV_REF) instead of the race-prone make_dev()+Davide Italiano2013-09-071-5/+1
| | | | | | | | | | | dev_ref() in the clone handlers that still use it. - Don't set SI_CHEAPCLONE flag, it's not used anywhere neither in devfs (for anything real) Reviewed by: kib Notes: svn path=/head/; revision=255359
* Whitespace cleanup.Justin Hibbits2013-09-021-46/+46
| | | | Notes: svn path=/head/; revision=255161