From d476c3a0dadb47c69f08dafce2b1a400cda49a58 Mon Sep 17 00:00:00 2001 From: Logan O'Sullivan Bruns Date: Sun, 8 Feb 2015 03:38:34 +0000 Subject: [PATCH 01/39] Kernel 3.10 also appears to not have the store_gdt call either The current #ifdef says for 3.11 and above but 3.10 also does not appear to have the store_gdt call. This fixes a build issue on CentOS 7 which includes the 3.10 kernel. --- driver/intr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/driver/intr.c b/driver/intr.c index b3bc0ef..87967ef 100644 --- a/driver/intr.c +++ b/driver/intr.c @@ -48,7 +48,7 @@ #define store_idt(ptr) asm volatile("sidt %0":"=m" (*ptr)) #endif -#if !defined(store_gdt) && LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0) +#if !defined(store_gdt) && LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) /***********************************************/ /* Xen removed this - oh, so nice of you. */ /* Not! We want the GDT to debug dtrace, so */ From cffbd428ee71b11a6482d49da9b34706fd9fe1d9 Mon Sep 17 00:00:00 2001 From: Logan O'Sullivan Bruns Date: Sun, 8 Feb 2015 03:41:51 +0000 Subject: [PATCH 02/39] Add dwarf_loclist to libdw vs. libdwarf check On CentOS 7 libdw does not include dwarf_loclist but libdwarf does. This changes adds checking for dwarf_loclist to the check to determine whether to use libdw instead of libdwarf. --- tools/mkport.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/mkport.pl b/tools/mkport.pl index 11b4990..419dfb4 100755 --- a/tools/mkport.pl +++ b/tools/mkport.pl @@ -326,6 +326,7 @@ sub check_dwarf_h void main(int argc, char **argv) { dwarf_begin(); + dwarf_loclist(); } EOF $fh->close(); From 8ee119b297aa0b30d99ac5817b99d342bf7edab5 Mon Sep 17 00:00:00 2001 From: Logan O'Sullivan Bruns Date: Sun, 8 Feb 2015 03:44:13 +0000 Subject: [PATCH 03/39] Added libdwarf.a deps install for fedora/rhel/centos script --- tools/get-deps-fedora.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/get-deps-fedora.sh b/tools/get-deps-fedora.sh index b6b4718..08204d3 100755 --- a/tools/get-deps-fedora.sh +++ b/tools/get-deps-fedora.sh @@ -14,6 +14,7 @@ yum install \ kernel-devel \ libdwarf \ libdwarf-devel \ + libdwarf-static \ libgcc.i686 \ make \ perl \ From 1f73b553931047479793311dc9b545e79e59bf89 Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Thu, 19 Mar 2015 22:18:44 +0000 Subject: [PATCH 04/39] Fix issue with broken gcc 4.6 compiler on 3.2 kernels. --- driver/systrace.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/driver/systrace.c b/driver/systrace.c index 42350bc..264d2c9 100644 --- a/driver/systrace.c +++ b/driver/systrace.c @@ -1217,7 +1217,8 @@ dtrace_systrace_syscall_execve(uintptr_t flags, uintptr_t stack_start, uintptr_t regs, uintptr_t stack_size, uintptr_t parent_tidptr, uintptr_t child_tidptr) { dtrace_id_t id; - struct pt_regs *regs = task_pt_regs(current); + + regs = task_pt_regs(current); TRACE_BEFORE(__NR_execve, flags, stack_start, regs, stack_size, parent_tidptr, child_tidptr); From eab1916b904fbac198ff0f4e4e87c8b60dfd67cc Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Wed, 8 Apr 2015 21:31:30 +0100 Subject: [PATCH 05/39] Make README readable on github --- README | 244 --------------------------------------------------------- 1 file changed, 244 deletions(-) delete mode 100644 README diff --git a/README b/README deleted file mode 100644 index 09fdc62..0000000 --- a/README +++ /dev/null @@ -1,244 +0,0 @@ -Linux port of DTrace - -Mar 2015 -Paul D. Fox -paul.d.fox@gmail.com -http://www.twitter.com/crispeditor -http://www.crisp.demon.co.uk - -Blog - latest news and stuff about the dtrace project: - - http://crtags.blogspot.com/ - http://www.crisp.demon.co.uk/blog/ - -Download dtrace tarballs for linux here: - - https://github.com/dtrace4linux/linux - ftp://crisp.publicvm.com/pub/release/website/dtrace - -Introduction -============ - -This is a port of the Sun DTrace user and kernel code to Linux. -No linux kernel code is touched in this build, but what is -produced is a dynamically loadable kernel module. This avoids -licensing issues and allows people to load and update dtrace as -they desire. - -The goal of this project is to make available DTrace for the -Linux platforms. By making it available for everyone, they can -use it to optimise their systems and tools, and in return, I -get to benefit from their work. - -PayPal -====== -If you want to make a donation for this software, feel free to -do so. Nothing is asked of you - it is genuinely free software, -but it can help guage interest and appreciation if you do. - -You can pay by visiting the link below and clicking on -"Donate", or use this reference for donations: - - foxpaypal@crisp.demon.co.uk - -Licensing -========= - -The original DTrace is licensed under Sun's (now Oracle) CDDL -license. Original copyrights are left intact. No GPL code is -incorporated into the release, to avoid legal conflicts. - -Any mistakes or omissions in copyright attribution will be my -mistake, so please let me know if there are such cases. - -The linux kernel was referred to in order to engineer the glue -for dtrace behavior, and there is no intention of making this -code fall under anything other than CDDL. (If Oracle migrate to -a GPL friendly license, then this port of dtrace can follow). I -do not own the license or assert any rights on the licensing -other than that expected of me as a consumer/supplier. - -I have no political affiliation or preference for a licensing -scheme, simply that Sun/Oracle has gracefully donated to the -community a large body of work. - -I reserve the right to change the licensing model for my own -code at a later date, when and if someone puts forward a case -as to the correct license agreement. - -If the code is useful to you - great. Spread it around and get -people to use, debug and enhance it. - -GIT Repository -============== - - https://github.com/dtrace4linux/linux - -(Theres an older and orphaned github repository under -Peter McCormicks name, please ignore this as it has not been -updated in a long while and is no longer active). - -Installation -============ - -You may need to grab some extra packages for building DTrace. -Use either of the following to download extra packages. This -list may be incomplete depending on the version of your kernel/distro. - - $ tools/get-deps-arch.sh # if using ArchLinux - $ tools/get-deps.pl # if using Ubuntu - $ tools/get-deps-fedora.sh # RedHat/Fedora - - $ make all - $ make install - $ make load (need to be root or have sudo access) - -If the libdwarf package installed on the system is to old -it still compiles without any problem, but you will get -runtime errors from the io.d and/or sched.d files due to -undefined kernel structure definitions. - -If you get a undefined struct definition such as dtrace_cpu_t -when running, please upgrade it. - -Tested successfully with version 20100214 (whereas 20080409 -is to old). - -More details -============ - -Building is done in a build/ directory. The makefiles allow -you to compile for alternate kernel releases in the same tree, -which is useful for cross-version checking. - -The result is: - - build/dtrace User land executable - build/drti.o Object file for USDT apps - build/driver/dtracedrv.ko Kernel loadable module - -Installing will copy them to Solaris compliant locations: - - /usr/sbin/dtrace - /usr/lib/dtrace/64/drti.o - -You dont need to 'install' to run dtrace, but you will need -to load the driver. - -Kernel versioning -================= -dtrace relies on a kernel module and so a binary is needed -per system you deploy to, or kernel version. - -dtrace is sensitive to the kernel - and attempts to cater for that, -but very old, or very new kernels may not have been validated. -Please feed back if that is the case. - -A kernel strack trace is expected when loading the module, due to -currently unknown reasons (the current theory is that the kernel -ftrace mechanism which probes dtrace as its loaded gets confused -by what it sees). - -If you get a stack trace something like this in the logs when -loading the module, this can safely be ignore (it appears to -be no harm (unless you use system-tap and dtrace at the same -time, then there could be a conflict): - - [ 182.556392] dtracedrv: module license 'CDDL' taints kernel. - [ 182.556396] Disabling lock debugging due to kernel taint - [ 184.760136] CPU: 5 PID: 11008 Comm: dtrace Tainted: P O 3.12.0+scst+tf.1 #5 - [ 184.760140] Hardware name: To be filled by O.E.M. To be filled by O.E.M./SABERTOOTH 990FX, BIOS 0901 11/24/2011 - [ 184.760142] ffffffffa093c8a0 ffffffff813c18b9 ffff8800dacdaa80 ffffffffa08f28ed - [ 184.760146] 755f6f745f646162 ffff8800dacdaa80 ffff88040acbbb9c 0000000000000020 - [ 184.760149] 0000000000000001 ffffffffa09370c0 ffff8800dd020a80 ffffffffa08e7f3e - [ 184.760151] Call Trace: - [ 184.760156] [] ? dump_stack+0x41/0x58 - [ 184.760165] [] ? mutex_enter_common+0x2d/0xeb [dtracedrv] - [ 184.760172] [] ? par_alloc+0x20/0xd0 [dtracedrv] - [ 184.760178] [] ? instr_provide_module+0x31/0x1f5 [dtracedrv] - [ 184.760184] [] ? sdt_open+0x3/0x3 [dtracedrv] - [ 184.760189] [] ? mutex_enter_common+0xc0/0xeb [dtracedrv] - [ 184.760195] [] ? dtrace_probe_provide+0xcd/0xf7 [dtracedrv] - [ 184.760201] [] ? dtrace_open+0x55/0x10f [dtracedrv] - [ 184.760203] [] ? kobj_lookup+0xfc/0x133 - [ 184.760209] [] ? dtracedrv_open+0x4c/0x51 [dtracedrv] - [ 184.760212] [] ? misc_open+0x107/0x168 - [ 184.760216] [] ? chrdev_open+0x129/0x148 - [ 184.760218] [] ? cdev_put+0x1a/0x1a - [ 184.760220] [] ? do_dentry_open+0x16c/0x22b - [ 184.760221] [] ? finish_open+0x2c/0x35 - [ 184.760224] [] ? do_last+0x9fd/0xc4a - [ 184.760226] [] ? path_openat+0x25f/0x5bd - [ 184.760228] [] ? mntput_no_expire+0x1b/0x16c - [ 184.760230] [] ? do_filp_open+0x2d/0x75 - [ 184.760233] [] ? kmem_cache_alloc+0x114/0x194 - [ 184.760235] [] ? _raw_spin_unlock+0x9/0xb - [ 184.760237] [] ? __alloc_fd+0xfa/0x10c - [ 184.760239] [] ? do_sys_open+0x146/0x1d6 - [ 184.760241] [] ? ia32_do_call+0x13/0x13 - -No Linux Kernel source modifications required -============================================= - -This is important for a number of reasons -- unless dtrace -is accepted into the kernel, it has to live with changes to header -files and data structures. Also, from a licensing perspective it -is not valid for dtrace to touch your sources. It is also much -easier to not even require kernel sources - so long as -a kernel build environment is available. - -INSTALLATION -============ - -Run 'make' with no arguments to see the current options. You -may need to run one of the tools/get-deps scripts for your OS -flavor to ensure you have the tools and kernel build -environment for your kernel. - -make all - to compile the drivers and user space commands. Check the file - Packages, for hints on what you need (not much, but libelf, kernel - source, flex/yacc -- bison will do). - -make install - Copy dtrace binary and driver to correct install location. - -make load - To load the drivers, and then you can play with cmd/dtrace/dtrace. - -make unl - to unload the drivers. - -make test - To run the userland cmd/dtrace regression test - -To build the userland (command and object file etc) and the -kernel module for different architectures, set the environment -variable BUILD_ARCH appropriately and then use the make targets -separately. - -This example is for building on a system with a 64-bit kernel, -but with 32-bit userland: - - BUILD_ARCH=i386 make cmds - BUILD_ARCH=x86_64 make kernel - -Dependencies -============ -To build dtrace for linux requires a number of tools - mostly -the basic Unix development tools, plus you will need the kernel -source/build tree. dtrace does not affect or touch your kernel -sources, but it needs the normal header files for creating a -loadable module. - -Examine the following scripts to help identify missing packages: - - tools/get-deps-arch.sh - tools/get-deps-fedora.sh - tools/get-deps.pl - -Internet scripts -================ -Many scripts on the 'Net won't work since they tend to assume a -Solaris kernel, but if you look at them and read them to learn, -then they can mostly be adapted for Linux. From 913ba6f961c601e5930f55f8b0bd0237ae6b3f40 Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Fri, 1 May 2015 22:51:05 +0100 Subject: [PATCH 06/39] Change to www.crispeditor.co.uk contact address Rename README.md for githubs benefit. --- README.md | 244 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 244 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..16461a9 --- /dev/null +++ b/README.md @@ -0,0 +1,244 @@ +Linux port of DTrace + +Mar 2015 +Paul D. Fox +paul.d.fox@gmail.com +http://www.twitter.com/crispeditor +http://www.crispeditor.co.uk + +Blog - latest news and stuff about the dtrace project: + + http://crtags.blogspot.com/ + http://www.crispeditorco.uk/blog/ + +Download dtrace tarballs for linux here: + + https://github.com/dtrace4linux/linux + ftp://crisp.publicvm.com/pub/release/website/dtrace + +Introduction +============ + +This is a port of the Sun DTrace user and kernel code to Linux. +No linux kernel code is touched in this build, but what is +produced is a dynamically loadable kernel module. This avoids +licensing issues and allows people to load and update dtrace as +they desire. + +The goal of this project is to make available DTrace for the +Linux platforms. By making it available for everyone, they can +use it to optimise their systems and tools, and in return, I +get to benefit from their work. + +PayPal +====== +If you want to make a donation for this software, feel free to +do so. Nothing is asked of you - it is genuinely free software, +but it can help guage interest and appreciation if you do. + +You can pay by visiting the link below and clicking on +"Donate", or use this reference for donations: + + foxpaypal@crisp.demon.co.uk + +Licensing +========= + +The original DTrace is licensed under Sun's (now Oracle) CDDL +license. Original copyrights are left intact. No GPL code is +incorporated into the release, to avoid legal conflicts. + +Any mistakes or omissions in copyright attribution will be my +mistake, so please let me know if there are such cases. + +The linux kernel was referred to in order to engineer the glue +for dtrace behavior, and there is no intention of making this +code fall under anything other than CDDL. (If Oracle migrate to +a GPL friendly license, then this port of dtrace can follow). I +do not own the license or assert any rights on the licensing +other than that expected of me as a consumer/supplier. + +I have no political affiliation or preference for a licensing +scheme, simply that Sun/Oracle has gracefully donated to the +community a large body of work. + +I reserve the right to change the licensing model for my own +code at a later date, when and if someone puts forward a case +as to the correct license agreement. + +If the code is useful to you - great. Spread it around and get +people to use, debug and enhance it. + +GIT Repository +============== + + https://github.com/dtrace4linux/linux + +(Theres an older and orphaned github repository under +Peter McCormicks name, please ignore this as it has not been +updated in a long while and is no longer active). + +Installation +============ + +You may need to grab some extra packages for building DTrace. +Use either of the following to download extra packages. This +list may be incomplete depending on the version of your kernel/distro. + + $ tools/get-deps-arch.sh # if using ArchLinux + $ tools/get-deps.pl # if using Ubuntu + $ tools/get-deps-fedora.sh # RedHat/Fedora + + $ make all + $ make install + $ make load (need to be root or have sudo access) + +If the libdwarf package installed on the system is to old +it still compiles without any problem, but you will get +runtime errors from the io.d and/or sched.d files due to +undefined kernel structure definitions. + +If you get a undefined struct definition such as dtrace_cpu_t +when running, please upgrade it. + +Tested successfully with version 20100214 (whereas 20080409 +is to old). + +More details +============ + +Building is done in a build/ directory. The makefiles allow +you to compile for alternate kernel releases in the same tree, +which is useful for cross-version checking. + +The result is: + + build/dtrace User land executable + build/drti.o Object file for USDT apps + build/driver/dtracedrv.ko Kernel loadable module + +Installing will copy them to Solaris compliant locations: + + /usr/sbin/dtrace + /usr/lib/dtrace/64/drti.o + +You dont need to 'install' to run dtrace, but you will need +to load the driver. + +Kernel versioning +================= +dtrace relies on a kernel module and so a binary is needed +per system you deploy to, or kernel version. + +dtrace is sensitive to the kernel - and attempts to cater for that, +but very old, or very new kernels may not have been validated. +Please feed back if that is the case. + +A kernel strack trace is expected when loading the module, due to +currently unknown reasons (the current theory is that the kernel +ftrace mechanism which probes dtrace as its loaded gets confused +by what it sees). + +If you get a stack trace something like this in the logs when +loading the module, this can safely be ignore (it appears to +be no harm (unless you use system-tap and dtrace at the same +time, then there could be a conflict): + + [ 182.556392] dtracedrv: module license 'CDDL' taints kernel. + [ 182.556396] Disabling lock debugging due to kernel taint + [ 184.760136] CPU: 5 PID: 11008 Comm: dtrace Tainted: P O 3.12.0+scst+tf.1 #5 + [ 184.760140] Hardware name: To be filled by O.E.M. To be filled by O.E.M./SABERTOOTH 990FX, BIOS 0901 11/24/2011 + [ 184.760142] ffffffffa093c8a0 ffffffff813c18b9 ffff8800dacdaa80 ffffffffa08f28ed + [ 184.760146] 755f6f745f646162 ffff8800dacdaa80 ffff88040acbbb9c 0000000000000020 + [ 184.760149] 0000000000000001 ffffffffa09370c0 ffff8800dd020a80 ffffffffa08e7f3e + [ 184.760151] Call Trace: + [ 184.760156] [] ? dump_stack+0x41/0x58 + [ 184.760165] [] ? mutex_enter_common+0x2d/0xeb [dtracedrv] + [ 184.760172] [] ? par_alloc+0x20/0xd0 [dtracedrv] + [ 184.760178] [] ? instr_provide_module+0x31/0x1f5 [dtracedrv] + [ 184.760184] [] ? sdt_open+0x3/0x3 [dtracedrv] + [ 184.760189] [] ? mutex_enter_common+0xc0/0xeb [dtracedrv] + [ 184.760195] [] ? dtrace_probe_provide+0xcd/0xf7 [dtracedrv] + [ 184.760201] [] ? dtrace_open+0x55/0x10f [dtracedrv] + [ 184.760203] [] ? kobj_lookup+0xfc/0x133 + [ 184.760209] [] ? dtracedrv_open+0x4c/0x51 [dtracedrv] + [ 184.760212] [] ? misc_open+0x107/0x168 + [ 184.760216] [] ? chrdev_open+0x129/0x148 + [ 184.760218] [] ? cdev_put+0x1a/0x1a + [ 184.760220] [] ? do_dentry_open+0x16c/0x22b + [ 184.760221] [] ? finish_open+0x2c/0x35 + [ 184.760224] [] ? do_last+0x9fd/0xc4a + [ 184.760226] [] ? path_openat+0x25f/0x5bd + [ 184.760228] [] ? mntput_no_expire+0x1b/0x16c + [ 184.760230] [] ? do_filp_open+0x2d/0x75 + [ 184.760233] [] ? kmem_cache_alloc+0x114/0x194 + [ 184.760235] [] ? _raw_spin_unlock+0x9/0xb + [ 184.760237] [] ? __alloc_fd+0xfa/0x10c + [ 184.760239] [] ? do_sys_open+0x146/0x1d6 + [ 184.760241] [] ? ia32_do_call+0x13/0x13 + +No Linux Kernel source modifications required +============================================= + +This is important for a number of reasons -- unless dtrace +is accepted into the kernel, it has to live with changes to header +files and data structures. Also, from a licensing perspective it +is not valid for dtrace to touch your sources. It is also much +easier to not even require kernel sources - so long as +a kernel build environment is available. + +INSTALLATION +============ + +Run 'make' with no arguments to see the current options. You +may need to run one of the tools/get-deps scripts for your OS +flavor to ensure you have the tools and kernel build +environment for your kernel. + +make all + to compile the drivers and user space commands. Check the file + Packages, for hints on what you need (not much, but libelf, kernel + source, flex/yacc -- bison will do). + +make install + Copy dtrace binary and driver to correct install location. + +make load + To load the drivers, and then you can play with cmd/dtrace/dtrace. + +make unl + to unload the drivers. + +make test + To run the userland cmd/dtrace regression test + +To build the userland (command and object file etc) and the +kernel module for different architectures, set the environment +variable BUILD_ARCH appropriately and then use the make targets +separately. + +This example is for building on a system with a 64-bit kernel, +but with 32-bit userland: + + BUILD_ARCH=i386 make cmds + BUILD_ARCH=x86_64 make kernel + +Dependencies +============ +To build dtrace for linux requires a number of tools - mostly +the basic Unix development tools, plus you will need the kernel +source/build tree. dtrace does not affect or touch your kernel +sources, but it needs the normal header files for creating a +loadable module. + +Examine the following scripts to help identify missing packages: + + tools/get-deps-arch.sh + tools/get-deps-fedora.sh + tools/get-deps.pl + +Internet scripts +================ +Many scripts on the 'Net won't work since they tend to assume a +Solaris kernel, but if you look at them and read them to learn, +then they can mostly be adapted for Linux. From 8c47599c0666a475ccab0fbcac55cb3b4a05efdd Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Wed, 6 May 2015 20:32:52 +0100 Subject: [PATCH 07/39] 864* README Status.txt archive.sh cmd/ctfconvert/barrier.c cmd/ctfconvert/makefile driver/Makefile driver/ctl.c driver/dtrace.c driver/dtrace_asm.c driver/dtrace_linux.c driver/dtrace_linux.h driver/fbt_linux.c driver/instr_linux.c driver/intr.c driver/intr_x86-64.S driver/prov_proc.c driver/systrace.c driver/systrace_asm.S driver/taskq.c driver/toxic.c driver/x_call.c driver-kmem/Makefile driver-kmem/dtrace_kmem.c driver-kmem/mk libdtrace/dt_names.c makefile s/README s/all s/clone s/execve s/fork s/iopl s/rt_sigreturn s/sigaltstack s/sigreturn s/vfork s/vm86 s/z s/z1 s/z11 s/z2 s/z3 s/z4 s/z5 s/z6 s/z7 s/z8 s/z9 tests/syscalls.c tests/tests.d tools/build.pl tools/kcore.c tools/load.pl tools/mkdriver.pl tools/mkport.pl tools/mksyscall.pl tools/sudo tools/tests.pl Archive: 1.0155 --- .release | 6 +++--- driver/dtrace.c | 2 +- tools/bug.sh | 7 +++---- tools/get-deps.pl | 2 +- tools/mkrelease.pl | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.release b/.release index 7bf6d94..f5cd91c 100644 --- a/.release +++ b/.release @@ -1,3 +1,3 @@ -date=Fri Mar 6 20:00:45 GMT 2015 -release=dtrace-20150306 -build=484 +date=Wed May 6 20:32:38 BST 2015 +release=dtrace-20150506 +build=485 diff --git a/driver/dtrace.c b/driver/dtrace.c index c83ba3b..e35db1e 100644 --- a/driver/dtrace.c +++ b/driver/dtrace.c @@ -16785,7 +16785,7 @@ PRINT_CASE(DTRACEIOC_DOFGET); } else { buf = &state->dts_aggbuffer[desc.dtbd_cpu]; } -printk("snap cpu=%d flags=%x sz=%x\n", desc.dtbd_cpu, buf->dtb_flags, buf->dtb_offset); +//printk("snap cpu=%d flags=%x sz=%x\n", desc.dtbd_cpu, buf->dtb_flags, buf->dtb_offset); if (buf->dtb_flags & (DTRACEBUF_RING | DTRACEBUF_FILL)) { size_t sz = buf->dtb_offset; diff --git a/tools/bug.sh b/tools/bug.sh index 53f51a9..e547963 100755 --- a/tools/bug.sh +++ b/tools/bug.sh @@ -24,18 +24,16 @@ cat <$file 2>&1 +echo "File: $file - send to Crisp.Editor@gmail.com" touch .dtrace.nobug exit 1 diff --git a/tools/get-deps.pl b/tools/get-deps.pl index a5a39bf..ef2d691 100755 --- a/tools/get-deps.pl +++ b/tools/get-deps.pl @@ -16,7 +16,7 @@ if [ ! -e ${DISTRIBUTION} ]; then echo "\n==== Downloading DTrace for Linux ====\n" curl -O -ftp://crisp.dyndns-server.com/pub/release/website/dtrace/${DISTRIBUTION}.tar.bz2 +ftp://crispeditor.co.uk/pub/release/website/dtrace/${DISTRIBUTION}.tar.bz2 tar jxvf ${DISTRIBUTION}.tar.bz2 fi } diff --git a/tools/mkrelease.pl b/tools/mkrelease.pl index e384f79..5925134 100755 --- a/tools/mkrelease.pl +++ b/tools/mkrelease.pl @@ -117,7 +117,7 @@ sub main spawn("mv /tmp/dtrace-$rel.tar.bz2 $ENV{HOME}/release/dtrace"); if (!$opts{nocopy}) { - spawn("twit 'Release: dtrace-b$vars{build} on ftp://crisp.dyndns-server.com/pub/release/website/dtrace/dtrace-$rel.tar.gz'"); + spawn("twit 'Release: dtrace-b$vars{build} on ftp://crispeditor.co.uk/pub/release/website/dtrace/dtrace-$rel.tar.gz'"); chdir($pwd); spawn("git commit -F /tmp/msg ."); spawn("git push -u origin master"); From dbd2fabcf1c80ebae95182c0864e499a52f21043 Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Wed, 6 May 2015 20:33:32 +0100 Subject: [PATCH 08/39] 864* README Status.txt archive.sh cmd/ctfconvert/barrier.c cmd/ctfconvert/makefile driver/Makefile driver/ctl.c driver/dtrace.c driver/dtrace_asm.c driver/dtrace_linux.c driver/dtrace_linux.h driver/fbt_linux.c driver/instr_linux.c driver/intr.c driver/intr_x86-64.S driver/prov_proc.c driver/systrace.c driver/systrace_asm.S driver/taskq.c driver/toxic.c driver/x_call.c driver-kmem/Makefile driver-kmem/dtrace_kmem.c driver-kmem/mk libdtrace/dt_names.c makefile s/README s/all s/clone s/execve s/fork s/iopl s/rt_sigreturn s/sigaltstack s/sigreturn s/vfork s/vm86 s/z s/z1 s/z11 s/z2 s/z3 s/z4 s/z5 s/z6 s/z7 s/z8 s/z9 tests/syscalls.c tests/tests.d tools/build.pl tools/kcore.c tools/load.pl tools/mkdriver.pl tools/mkport.pl tools/mksyscall.pl tools/sudo tools/tests.pl Archive: 1.0155 --- .release | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.release b/.release index f5cd91c..fe27d29 100644 --- a/.release +++ b/.release @@ -1,3 +1,3 @@ -date=Wed May 6 20:32:38 BST 2015 -release=dtrace-20150506 -build=485 +date=Wed May 6 20:33:11 BST 2015 +release=dtrace-20150506a +build=486 From b88571b5b7d1ec7a4336a54789c5b3b93388a0f1 Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Tue, 12 May 2015 23:23:11 +0100 Subject: [PATCH 09/39] Fix for Centos 5.4 systems where we hit a catch-22 during the mkport.pl build phase, because we need the temporary driver-kmem driver (due to broken kernels and /proc/kcore). --- makefile | 4 +++- tools/build.pl | 10 +++++++++- tools/mkdriver.pl | 2 +- tools/mkport.pl | 11 +++++++++-- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/makefile b/makefile index 76829d7..e97c886 100644 --- a/makefile +++ b/makefile @@ -64,7 +64,9 @@ beta: tools/mkrelease.pl -nocopy $$REL all: - BUILD_DIR=$(BUILD_DIR) tools/build.pl $(BUILD_DIR) $(UNAME_M) + BUILD_DIR=$(BUILD_DIR) \ + tools/mkdriver.pl driver-kmem ; \ + tools/build.pl $(BUILD_DIR) $(UNAME_M) cmds: BUILD_DIR=$(BUILD_DIR) tools/build.pl -make do_cmds $(BUILD_DIR) $(UNAME_M) diff --git a/tools/build.pl b/tools/build.pl index 3424669..a88854e 100755 --- a/tools/build.pl +++ b/tools/build.pl @@ -92,7 +92,9 @@ sub main # Some precursors to check us out. # ############################################### spawn("tools/check_dep.pl"); - spawn("tools/mkport.pl"); + if (spawn("tools/mkport.pl")) { + die "FATAL ERROR: build.pl aborting\n"; + } spawn("tools/libgcc.pl"); if ($uname_m =~ /x86.*64/) { @@ -174,8 +176,14 @@ sub usage build.pl: dtrace build rule Usage: build.pl \$BUILD_DIR \$UNAME_M + Script to invoke the build. We use 'make' to run build.pl where + all the logic to ensure environment variables, flags, and autodetection + takes place. + Switches: + -help This text. + -i Run 'make -i' so we can carry on even with errors. EOF exit(1); diff --git a/tools/mkdriver.pl b/tools/mkdriver.pl index 6fab12e..9df7146 100755 --- a/tools/mkdriver.pl +++ b/tools/mkdriver.pl @@ -35,7 +35,7 @@ sub main # really need this since all volatile # # stuff is in the build.* dirs anyhow. # ############################################### - if ($cmd eq 'clean') { + if ($cmd && $cmd eq 'clean') { if (!defined($ENV{BUILD_DIR})) { return system("rm -rf build*"); } diff --git a/tools/mkport.pl b/tools/mkport.pl index 3eb2579..2ed25cd 100755 --- a/tools/mkport.pl +++ b/tools/mkport.pl @@ -137,9 +137,16 @@ sub main print "old_rsp=$old_rsp\n"; if ($old_rsp) { $inc .= "# define OLD_RSP_VAL 0x$old_rsp\n"; + } else { + print STDERR < Date: Tue, 12 May 2015 23:24:03 +0100 Subject: [PATCH 10/39] 864* README Status.txt archive.sh cmd/ctfconvert/barrier.c cmd/ctfconvert/makefile driver/Makefile driver/ctl.c driver/dtrace.c driver/dtrace_asm.c driver/dtrace_linux.c driver/dtrace_linux.h driver/fbt_linux.c driver/instr_linux.c driver/intr.c driver/intr_x86-64.S driver/prov_proc.c driver/systrace.c driver/systrace_asm.S driver/taskq.c driver/toxic.c driver/x_call.c driver-kmem/Makefile driver-kmem/dtrace_kmem.c driver-kmem/mk libdtrace/dt_names.c makefile s/README s/all s/clone s/execve s/fork s/iopl s/rt_sigreturn s/sigaltstack s/sigreturn s/vfork s/vm86 s/z s/z1 s/z11 s/z2 s/z3 s/z4 s/z5 s/z6 s/z7 s/z8 s/z9 tests/syscalls.c tests/tests.d tools/build.pl tools/kcore.c tools/load.pl tools/mkdriver.pl tools/mkport.pl tools/mksyscall.pl tools/sudo tools/tests.pl Archive: 1.0155 --- .release | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.release b/.release index fe27d29..620635f 100644 --- a/.release +++ b/.release @@ -1,3 +1,3 @@ -date=Wed May 6 20:33:11 BST 2015 -release=dtrace-20150506a -build=486 +date=Tue May 12 23:23:46 BST 2015 +release=dtrace-20150512 +build=487 From eaede4189c9f3cb2c77ed3222ce339f33b8729a9 Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Tue, 19 May 2015 21:21:39 +0100 Subject: [PATCH 11/39] 865* driver/prov_proc.c Fix for 3.18/19 kernels (not sure I got the change right - 3.16 is not affected, but 3.19 - Ubuntu 15.04 - is). Tue Mar 3 22:33:03 2015 fox --- .release | 6 +++--- Changes | 6 ++++++ driver/prov_proc.c | 9 +++++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.release b/.release index 620635f..e6cf942 100644 --- a/.release +++ b/.release @@ -1,3 +1,3 @@ -date=Tue May 12 23:23:46 BST 2015 -release=dtrace-20150512 -build=487 +date=Tue May 19 21:21:25 BST 2015 +release=dtrace-20150519 +build=488 diff --git a/Changes b/Changes index 3641a89..e1dc4bf 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,9 @@ +Tue May 19 21:20:33 2015 fox + + 865* driver/prov_proc.c + Fix for 3.18/19 kernels (not sure I got the change right - 3.16 + is not affected, but 3.19 - Ubuntu 15.04 - is). + Tue Mar 3 22:33:03 2015 fox 864* README diff --git a/driver/prov_proc.c b/driver/prov_proc.c index e9e4b77..0e25a87 100644 --- a/driver/prov_proc.c +++ b/driver/prov_proc.c @@ -7,7 +7,7 @@ /*--------------------------------------------------------------------*/ /* Description: proc::: provider callbacks */ /*--------------------------------------------------------------------*/ -/* $Header: Last edited: 15-Feb-2015 1.2 $ */ +/* $Header: Last edited: 19-May-2015 1.3 $ */ /**********************************************************************/ #include @@ -42,8 +42,13 @@ psinfo_arg(int n, struct pt_regs *regs) ps->pr_egid = current->egid; #endif ps->pr_addr = current; + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0) + ps->pr_start.tv_sec = current->start_time / (1000 * 1000 * 1000); + ps->pr_start.tv_nsec = current->start_time % (1000 * 1000 * 1000); +#else ps->pr_start = current->start_time; - +#endif return (uintptr_t) ps; } From 22dd1f986dadcacf4947fe53d2f996909da27eb0 Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Tue, 19 May 2015 21:34:37 +0100 Subject: [PATCH 12/39] 865* driver/prov_proc.c Fix for 3.18/19 kernels (not sure I got the change right - 3.16 is not affected, but 3.19 - Ubuntu 15.04 - is). Tue Mar 3 22:33:03 2015 fox --- .release | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.release b/.release index e6cf942..af07905 100644 --- a/.release +++ b/.release @@ -1,3 +1,3 @@ -date=Tue May 19 21:21:25 BST 2015 -release=dtrace-20150519 -build=488 +date=Tue May 19 21:34:27 BST 2015 +release=dtrace-20150519a +build=489 From c25a79dc8d7ac1c46d9e65f6f728f59cf2608fef Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Thu, 21 May 2015 21:28:26 +0100 Subject: [PATCH 13/39] Fix to avoid core dump when compiling Ruby. Not really a fix but we should avoid core dumping. --- libdtrace/drti.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libdtrace/drti.c b/libdtrace/drti.c index fb224b1..12e3236 100644 --- a/libdtrace/drti.c +++ b/libdtrace/drti.c @@ -198,7 +198,19 @@ dtrace_dof_init(void) #endif dh.dofhp_dof = (uintptr_t)dof; +#if defined(linux) + /***********************************************/ + /* Avoid causing a core dump, as reported */ + /* by Martin Englund when compiling Ruby. */ + /***********************************************/ + if (lmp == NULL) { + dprintf1(1, "drti: lmp is null - giving up"); + return; + } dh.dofhp_addr = elf->e_type == ET_DYN ? lmp->l_addr : 0; +#else + dh.dofhp_addr = elf->e_type == ET_DYN ? lmp->l_addr : 0; +#endif if (lmid == 0) { (void) snprintf(dh.dofhp_mod, sizeof (dh.dofhp_mod), From 093cb804380a75237a9490f7dc2964a35bc0c3a0 Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Thu, 21 May 2015 21:29:01 +0100 Subject: [PATCH 14/39] 865* driver/prov_proc.c Fix for 3.18/19 kernels (not sure I got the change right - 3.16 is not affected, but 3.19 - Ubuntu 15.04 - is). Tue Mar 3 22:33:03 2015 fox --- .release | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.release b/.release index af07905..791b301 100644 --- a/.release +++ b/.release @@ -1,3 +1,3 @@ -date=Tue May 19 21:34:27 BST 2015 -release=dtrace-20150519a -build=489 +date=Thu May 21 21:28:46 BST 2015 +release=dtrace-20150521 +build=490 From 50dc1d955c3bd585494dcf5a6c2fd2690b9f5eac Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Wed, 29 Jul 2015 23:42:54 +0100 Subject: [PATCH 15/39] change paypal address --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 16461a9..17e956b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ Linux port of DTrace -Mar 2015 +July 2015 Paul D. Fox paul.d.fox@gmail.com http://www.twitter.com/crispeditor @@ -14,7 +14,7 @@ Blog - latest news and stuff about the dtrace project: Download dtrace tarballs for linux here: https://github.com/dtrace4linux/linux - ftp://crisp.publicvm.com/pub/release/website/dtrace + ftp://crispeditor.co.uk/pub/release/website/dtrace Introduction ============ @@ -39,7 +39,7 @@ but it can help guage interest and appreciation if you do. You can pay by visiting the link below and clicking on "Donate", or use this reference for donations: - foxpaypal@crisp.demon.co.uk + paul.d.fox@gmail.com Licensing ========= From 4fcd426e2b1ed782d4799d616b2c3c017c23391f Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Wed, 29 Jul 2015 23:44:00 +0100 Subject: [PATCH 16/39] 865* driver/prov_proc.c Fix for 3.18/19 kernels (not sure I got the change right - 3.16 is not affected, but 3.19 - Ubuntu 15.04 - is). Tue Mar 3 22:33:03 2015 fox --- .release | 6 +++--- tools/mkrelease.pl | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.release b/.release index 791b301..933fe25 100644 --- a/.release +++ b/.release @@ -1,3 +1,3 @@ -date=Thu May 21 21:28:46 BST 2015 -release=dtrace-20150521 -build=490 +date=Wed Jul 29 23:43:52 BST 2015 +release=dtrace-20150729 +build=491 diff --git a/tools/mkrelease.pl b/tools/mkrelease.pl index 5925134..56f58f5 100755 --- a/tools/mkrelease.pl +++ b/tools/mkrelease.pl @@ -111,7 +111,7 @@ sub main rename("dtrace-$rel", "dtrace"); if (!$opts{nocopy}) { - spawn("rcp /tmp/dtrace-$rel.tar.bz2 minny:release/website/dtrace"); + spawn("rcp /tmp/dtrace-$rel.tar.bz2 crispgw:release/website/dtrace"); } spawn("ls -l /tmp/dtrace-$rel.tar.bz2"); spawn("mv /tmp/dtrace-$rel.tar.bz2 $ENV{HOME}/release/dtrace"); From c8de1a6bba731a170d2f88a4ffd02eb3f6bcfce0 Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Thu, 30 Jul 2015 23:25:08 +0100 Subject: [PATCH 17/39] add proper paypal link in markdown syntax --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 17e956b..e518243 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ You can pay by visiting the link below and clicking on "Donate", or use this reference for donations: paul.d.fox@gmail.com + [Paypal](https://www.paypal.com/cgi-bin/webscr?business=paul.d.fox@gmail.com&cmd=_xclick¤cy_code=GBP&amount=40&item_name=DTrace) Licensing ========= From 8a28200d3dbe137e436c2490599f452b7e3e9408 Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Thu, 30 Jul 2015 23:25:27 +0100 Subject: [PATCH 18/39] 865* driver/prov_proc.c Fix for 3.18/19 kernels (not sure I got the change right - 3.16 is not affected, but 3.19 - Ubuntu 15.04 - is). Tue Mar 3 22:33:03 2015 fox --- .release | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.release b/.release index 933fe25..dae5d47 100644 --- a/.release +++ b/.release @@ -1,3 +1,3 @@ -date=Wed Jul 29 23:43:52 BST 2015 -release=dtrace-20150729 -build=491 +date=Thu Jul 30 23:25:20 BST 2015 +release=dtrace-20150730 +build=492 From eed4508b383bc80f5a67e4eb069b80946a47cf9b Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Fri, 6 Nov 2015 14:38:37 +0000 Subject: [PATCH 19/39] changes for linux 4.2 (Ubuntu 15.10/wily) --- README.md | 4 ++-- driver/intr_x86-64.S | 2 +- driver/systrace.c | 4 ++-- driver/systrace_asm.S | 2 +- driver/x_call.c | 5 +++++ tools/load.pl | 1 + tools/mkport.pl | 15 +++++++++++++++ 7 files changed, 27 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e518243..c37e673 100644 --- a/README.md +++ b/README.md @@ -39,8 +39,8 @@ but it can help guage interest and appreciation if you do. You can pay by visiting the link below and clicking on "Donate", or use this reference for donations: - paul.d.fox@gmail.com - [Paypal](https://www.paypal.com/cgi-bin/webscr?business=paul.d.fox@gmail.com&cmd=_xclick¤cy_code=GBP&amount=40&item_name=DTrace) + * paul.d.fox@gmail.com + * [Paypal](https://www.paypal.com/cgi-bin/webscr?business=paul.d.fox@gmail.com&cmd=_xclick¤cy_code=GBP&amount=15&item_name=DTrace) Licensing ========= diff --git a/driver/intr_x86-64.S b/driver/intr_x86-64.S index acdba57..298259e 100644 --- a/driver/intr_x86-64.S +++ b/driver/intr_x86-64.S @@ -53,7 +53,7 @@ #include #include -#include +/*#include */ #include #ifdef CONFIG_PARAVIRT # include diff --git a/driver/systrace.c b/driver/systrace.c index 264d2c9..a0f3339 100644 --- a/driver/systrace.c +++ b/driver/systrace.c @@ -304,8 +304,8 @@ static int64_t (*sys32_sigreturn_ptr)(uintptr_t, uintptr_t, uintptr_t, uintptr_t static int64_t (*sys_vfork_ptr)(uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t); char *int_ret_from_sys_call_ptr; -static char *ptregscall_common_ptr; -static char *ia32_ptregs_common_ptr; +char *ptregscall_common_ptr; +char *ia32_ptregs_common_ptr; # if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) # define HAVE_SAVE_REST 1 static char *save_rest_ptr; diff --git a/driver/systrace_asm.S b/driver/systrace_asm.S index 4fd5a63..76a49c0 100644 --- a/driver/systrace_asm.S +++ b/driver/systrace_asm.S @@ -20,7 +20,7 @@ #include #include #include -#include +/*#include */ #include #include #include diff --git a/driver/x_call.c b/driver/x_call.c index d767508..3a7e809 100644 --- a/driver/x_call.c +++ b/driver/x_call.c @@ -50,6 +50,11 @@ typedef struct apic_ops apic_t; typedef struct apic apic_t; #endif +# if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0) +# define cpus_clear(x) cpumask_clear(&(x)) +# define cpu_set(c, mask) cpumask_set_cpu(c, &(mask)) +#endif + apic_t *hello_apic; /* Define this because apic.h is broken when facing a */ /* non-GPL driver. We get an undefined, so define it. */ /* We use dynamic lookup instead. */ diff --git a/tools/load.pl b/tools/load.pl index c2fd935..cae7a42 100755 --- a/tools/load.pl +++ b/tools/load.pl @@ -256,6 +256,7 @@ sub main __module_text_address add_timer_on old_rsp:optional + rsp_scratch:optional /) { my $done = 0; my $amd64 = 0; diff --git a/tools/mkport.pl b/tools/mkport.pl index 2ed25cd..1019941 100755 --- a/tools/mkport.pl +++ b/tools/mkport.pl @@ -134,6 +134,13 @@ sub main ############################################### my $old_rsp = `tools/sudo $ENV{BUILD_DIR}/kcore`; chomp($old_rsp); + ############################################### + # 4.2 and above kernels renamed this # + # symbol. # + ############################################### + if (!$old_rsp) { + $old_rsp = get_symbol("rsp_scratch"); + } print "old_rsp=$old_rsp\n"; if ($old_rsp) { $inc .= "# define OLD_RSP_VAL 0x$old_rsp\n"; @@ -454,6 +461,14 @@ sub find_dump_trace_args } return ""; } +sub get_symbol +{ my $name = shift; + + my $sym = `tools/sudo grep -w $name /proc/kallsyms`; + return if !$sym; + $sym =~ s/ .*$//; + return $sym; +} ###################################################################### # Grep a file to see if something is where we want it. # ###################################################################### From fbd8847a7c07addfd898bc228ba7d7f57cc0c402 Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Fri, 6 Nov 2015 14:39:02 +0000 Subject: [PATCH 20/39] 865* driver/prov_proc.c Fix for 3.18/19 kernels (not sure I got the change right - 3.16 is not affected, but 3.19 - Ubuntu 15.04 - is). Tue Mar 3 22:33:03 2015 fox --- .release | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.release b/.release index dae5d47..15f0163 100644 --- a/.release +++ b/.release @@ -1,3 +1,3 @@ -date=Thu Jul 30 23:25:20 BST 2015 -release=dtrace-20150730 -build=492 +date=Fri Nov 6 14:38:53 GMT 2015 +release=dtrace-20151106 +build=493 From a0dbb3abc21a77b389c0f0bf1f78a99870a77ab1 Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Mon, 28 Dec 2015 19:26:09 +0000 Subject: [PATCH 21/39] Fix SIGSEGV when using "-n pidNNN:::entry" due to sillyism in not catering for basename of the module. --- README.md | 4 ++-- libproc/common/Psymtab.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c37e673..ca2bd83 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ Linux port of DTrace -July 2015 +Dec 2015 Paul D. Fox paul.d.fox@gmail.com http://www.twitter.com/crispeditor @@ -94,7 +94,7 @@ list may be incomplete depending on the version of your kernel/distro. $ make install $ make load (need to be root or have sudo access) -If the libdwarf package installed on the system is to old +If the libdwarf package installed on the system is too old it still compiles without any problem, but you will get runtime errors from the io.d and/or sched.d files due to undefined kernel structure definitions. diff --git a/libproc/common/Psymtab.c b/libproc/common/Psymtab.c index f84e46a..9b91e0b 100644 --- a/libproc/common/Psymtab.c +++ b/libproc/common/Psymtab.c @@ -371,6 +371,7 @@ map_iter(const rd_loadobj_t *lop, void *cd) #if defined(linux) fptr->file_lname = strdup((char *) lop->rl_nameaddr); + fptr->file_lbase = basename(fptr->file_lname); /*printf("filename=%s\n", fptr->file_lname);*/ #else if (Pread_string(P, buf, sizeof (buf), lop->rl_nameaddr) > 0) { From ad534df1581d25bde0c4ff7ee3954360b9dbf171 Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Mon, 28 Dec 2015 19:48:12 +0000 Subject: [PATCH 22/39] Fix system_unbound_workq vs system_unbound_wq in mkport.pl -- was causing a voluntary panic due to missing feature. --- Changes | 15 +++++++++++++++ tools/mkport.pl | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index e1dc4bf..113b556 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,18 @@ +Mon Dec 28 19:47:46 2015 fox + + 866* README.md + driver/intr_x86-64.S + driver/systrace.c + driver/systrace_asm.S + driver/x_call.c + libdtrace/drti.c + libproc/common/Psymtab.c + tools/load.pl + tools/mkport.pl + tools/mkrelease.pl + Fix for system_unbound_workq vs system_unbound_wq. + Fix silly in Psymtab.c leading to SIGSEGV. + Tue May 19 21:20:33 2015 fox 865* driver/prov_proc.c diff --git a/tools/mkport.pl b/tools/mkport.pl index 1019941..9fbf306 100755 --- a/tools/mkport.pl +++ b/tools/mkport.pl @@ -157,7 +157,8 @@ sub main ############################################### # For taskq.c # ############################################### - if (have("system_unbound_workq", $kallsyms)) { + if (have("system_unbound_workq", $kallsyms) || + have("system_unbound_wq", $kallsyms)) { $inc .= "# define HAVE_WORK_CPU_UNBOUND 1\n"; } else { $inc .= "# define HAVE_WORK_CPU_UNBOUND 0\n"; From 6abe29e628d53542844e07483111fc5df1cc8751 Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Mon, 28 Dec 2015 21:25:44 +0000 Subject: [PATCH 23/39] Fixes for fasttrap (pid provider): dtrace -n pidXXXX:::entry will work but *WILL* cause any fork/cloned child to terminate with a SIGTRAP event because we dont latch onto the children and remove the embedded breakpoints. (Needs more R&D to determine how to do this in Linux). This should work, but if it fails, send me a dmesg output - the patching of the page tables may/will fail when allocating a private buffer - but this may depend on VM, Xen or real HW. --- Changes | 16 ++++++++++++++++ driver/dtrace.c | 2 +- driver/dtrace_linux.c | 8 +++++++- driver/fasttrap_isa.c | 6 ++++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/Changes b/Changes index 113b556..ed049df 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,21 @@ Mon Dec 28 19:47:46 2015 fox + 867* driver/dtrace.c + driver/dtrace_linux.c + driver/fasttrap_isa.c + Fixes for fasttrap (pid provider): + + dtrace -n pidXXXX:::entry + + will work but *WILL* cause any fork/cloned child to terminate + with a SIGTRAP event because we dont latch onto the children + and remove the embedded breakpoints. (Needs more R&D to determine + how to do this in Linux). + + This should work, but if it fails, send me a dmesg output - + the patching of the page tables may/will fail when allocating + a private buffer - but this may depend on VM, Xen or real HW. + 866* README.md driver/intr_x86-64.S driver/systrace.c diff --git a/driver/dtrace.c b/driver/dtrace.c index e35db1e..22430ec 100644 --- a/driver/dtrace.c +++ b/driver/dtrace.c @@ -11123,7 +11123,7 @@ dtrace_buffer_switch(dtrace_buffer_t *buf) ASSERT(!(buf->dtb_flags & DTRACEBUF_RING)); cookie = dtrace_interrupt_disable(); -dtrace_printf("buffersw\n"); +//dtrace_printf("buffersw\n"); buf->dtb_tomax = xamot; buf->dtb_xamot = tomax; buf->dtb_xamot_drops = buf->dtb_drops; diff --git a/driver/dtrace_linux.c b/driver/dtrace_linux.c index 560d8ac..ed3f518 100644 --- a/driver/dtrace_linux.c +++ b/driver/dtrace_linux.c @@ -1472,7 +1472,13 @@ static pte_t *(*lookup_address)(void *, int *); } addr = (unsigned long) addr & ~(PAGESIZE-1); - kpte = lookup_address((void *) addr, &level); + /***********************************************/ + /* Avoid panic if we can help it. */ + /***********************************************/ + if ((kpte = lookup_address((void *) addr, &level)) == NULL) { + printk("mem_set_perms: %p - not found\n", addr); + return 0; + } old_pte = *kpte; new_prot = pte_pgprot(old_pte); pgprot_val(new_prot) |= _PAGE_RW; diff --git a/driver/fasttrap_isa.c b/driver/fasttrap_isa.c index 5b69ac6..4420cf6 100644 --- a/driver/fasttrap_isa.c +++ b/driver/fasttrap_isa.c @@ -1002,6 +1002,7 @@ fasttrap_do_seg(fasttrap_tracepoint_t *tp, struct regs *rp, uintptr_t *addr) /**********************************************************************/ /* Temporary hack. */ /**********************************************************************/ +/* #undef fasttrap_copyout int z = 0; int fff(void *a, void *b, int c, int line) @@ -1013,6 +1014,7 @@ int fff(void *a, void *b, int c, int line) return 0; } #define fasttrap_copyout(a,b, c) fff(a, b, c, __LINE__) +*/ int fasttrap_pid_probe(struct regs *rp) @@ -1601,6 +1603,10 @@ PRINT_CASE(FASTTRAP_T_COMMON); up_write(¤t->mm->mmap_sem); } printk("private-alloc %p\n", p->p_private_page); + /***********************************************/ + /* Bad news if we cannot allocate the */ + /* private page. */ + /***********************************************/ addr = (uintptr_t) p->p_private_page; } From 7dd105614011fec4021b10ed8360edac06b59f53 Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Mon, 28 Dec 2015 21:26:43 +0000 Subject: [PATCH 24/39] 867* driver/dtrace.c driver/dtrace_linux.c driver/fasttrap_isa.c Fixes for fasttrap (pid provider): --- .release | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.release b/.release index 15f0163..534f951 100644 --- a/.release +++ b/.release @@ -1,3 +1,3 @@ -date=Fri Nov 6 14:38:53 GMT 2015 -release=dtrace-20151106 -build=493 +date=Mon Dec 28 21:26:33 GMT 2015 +release=dtrace-20151228 +build=494 From 04eeca9659973c82397d29a1b18543abb7760eed Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Mon, 11 Jan 2016 21:17:37 +0000 Subject: [PATCH 25/39] 868* driver/intr.c Handle 3.10 (centos 7) kernels for store_gdt. --- .release | 6 +++--- Changes | 5 +++++ driver/intr.c | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.release b/.release index 534f951..0ef5aaa 100644 --- a/.release +++ b/.release @@ -1,3 +1,3 @@ -date=Mon Dec 28 21:26:33 GMT 2015 -release=dtrace-20151228 -build=494 +date=Mon Jan 11 21:17:28 GMT 2016 +release=dtrace-20160111 +build=495 diff --git a/Changes b/Changes index ed049df..bc57312 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,8 @@ +Mon Jan 11 21:17:16 2016 fox + + 868* driver/intr.c + Handle 3.10 (centos 7) kernels for store_gdt. + Mon Dec 28 19:47:46 2015 fox 867* driver/dtrace.c diff --git a/driver/intr.c b/driver/intr.c index 7956278..5c2483e 100644 --- a/driver/intr.c +++ b/driver/intr.c @@ -7,7 +7,7 @@ /* */ /* License: CDDL */ /* */ -/* $Header: Last edited: 12-Oct-2013 1.18 $ */ +/* $Header: Last edited: 11-Jan-2016 1.19 $ */ /**********************************************************************/ #include @@ -48,7 +48,7 @@ #define store_idt(ptr) asm volatile("sidt %0":"=m" (*ptr)) #endif -#if !defined(store_gdt) && LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0) +#if !defined(store_gdt) && LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) /***********************************************/ /* Xen removed this - oh, so nice of you. */ /* Not! We want the GDT to debug dtrace, so */ From 1a71e5bb5d57c4d04c2db3617bd84669828f2d80 Mon Sep 17 00:00:00 2001 From: sjas Date: Wed, 20 Jan 2016 16:25:05 +0100 Subject: [PATCH 26/39] readme indent fix --- README.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index ca2bd83..f8d10d4 100644 --- a/README.md +++ b/README.md @@ -191,31 +191,31 @@ a kernel build environment is available. INSTALLATION ============ -Run 'make' with no arguments to see the current options. You -may need to run one of the tools/get-deps scripts for your OS +Run `make` with no arguments to see the current options. You +may need to run one of the `tools/get-deps` scripts for your OS flavor to ensure you have the tools and kernel build environment for your kernel. -make all - to compile the drivers and user space commands. Check the file - Packages, for hints on what you need (not much, but libelf, kernel - source, flex/yacc -- bison will do). + make all + to compile the drivers and user space commands. Check the file + Packages, for hints on what you need (not much, but libelf, kernel + source, flex/yacc -- bison will do). -make install - Copy dtrace binary and driver to correct install location. + make install + Copy dtrace binary and driver to correct install location. -make load - To load the drivers, and then you can play with cmd/dtrace/dtrace. + make load + To load the drivers, and then you can play with cmd/dtrace/dtrace. -make unl - to unload the drivers. + make unl + to unload the drivers. -make test - To run the userland cmd/dtrace regression test + make test + To run the userland cmd/dtrace regression test To build the userland (command and object file etc) and the kernel module for different architectures, set the environment -variable BUILD_ARCH appropriately and then use the make targets +variable `BUILD_ARCH` appropriately and then use the make targets separately. This example is for building on a system with a 64-bit kernel, From e6ba1511f19ec0c87906c4f918093ae8dce9e42d Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Sun, 6 Mar 2016 15:49:22 +0000 Subject: [PATCH 27/39] fix typo in crispeditor.co.uk reference. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f8d10d4..a9b7c46 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ http://www.crispeditor.co.uk Blog - latest news and stuff about the dtrace project: http://crtags.blogspot.com/ - http://www.crispeditorco.uk/blog/ + http://www.crispeditor.co.uk/blog/ Download dtrace tarballs for linux here: From 6d54bfa8293445b1ac6c64875b4e43869ca6ce68 Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Sun, 6 Mar 2016 15:49:43 +0000 Subject: [PATCH 28/39] 868* driver/intr.c Handle 3.10 (centos 7) kernels for store_gdt. --- .release | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.release b/.release index 0ef5aaa..df9f16e 100644 --- a/.release +++ b/.release @@ -1,3 +1,3 @@ -date=Mon Jan 11 21:17:28 GMT 2016 -release=dtrace-20160111 -build=495 +date=Sun Mar 6 15:49:34 GMT 2016 +release=dtrace-20160306 +build=496 From 21f266e283c4ec519ab30825d551bdcc7ce030cd Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Wed, 23 Mar 2016 20:49:35 +0000 Subject: [PATCH 29/39] fix the prior/broken merge commit. --- tools/mkport.pl | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tools/mkport.pl b/tools/mkport.pl index d61c71a..0cd8a86 100755 --- a/tools/mkport.pl +++ b/tools/mkport.pl @@ -361,11 +361,8 @@ sub check_dwarf_h int main(int argc, char **argv) { dwarf_begin(); -<<<<<<< HEAD - return 0; -======= dwarf_loclist(); ->>>>>>> 8ee119b297aa0b30d99ac5817b99d342bf7edab5 + return 0; } EOF $fh->close(); From af0f44351a9689d54ad0d4c6d251a6ea633a6472 Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Wed, 23 Mar 2016 20:50:08 +0000 Subject: [PATCH 30/39] 868* driver/intr.c Handle 3.10 (centos 7) kernels for store_gdt. --- .release | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.release b/.release index df9f16e..d281df7 100644 --- a/.release +++ b/.release @@ -1,3 +1,3 @@ -date=Sun Mar 6 15:49:34 GMT 2016 -release=dtrace-20160306 -build=496 +date=Wed Mar 23 20:49:46 GMT 2016 +release=dtrace-20160323 +build=497 From 8488b1948c1097af2e17b041b2047b31057021f1 Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Wed, 23 Mar 2016 20:53:04 +0000 Subject: [PATCH 31/39] fix for 4.4 kernels where __GFP_WAIT got renamed to __GFP_RECLAIM. --- driver/ctf_subr.c | 3 +++ driver/taskq.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/driver/ctf_subr.c b/driver/ctf_subr.c index 527aca6..867a4ee 100644 --- a/driver/ctf_subr.c +++ b/driver/ctf_subr.c @@ -42,6 +42,9 @@ void * ctf_data_alloc(size_t size) { +# if !defined(__GFP_WAIT) +# define __GFP_WAIT __GFP_RECLAIM +# endif void *buf = kmalloc(size, GFP_KERNEL & ~__GFP_WAIT); if (buf == NULL) diff --git a/driver/taskq.c b/driver/taskq.c index f82b04e..99b15b4 100644 --- a/driver/taskq.c +++ b/driver/taskq.c @@ -272,6 +272,9 @@ taskq_dispatch2(taskq_t *tq, task_func_t func, void *arg, uint_t flags, unsigned if (!taskq_enabled) return 0; +# if !defined(__GFP_WAIT) +# define __GFP_WAIT __GFP_RECLAIM +# endif work = (my_work_t *)kmalloc(sizeof(my_work_t), GFP_KERNEL & ~__GFP_WAIT); if (work == NULL) { printk("taskq_dispatch: couldnt alloc work buffer\n"); From 7f12a78a5c23cefbc2e109a270dedb4243068c7b Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Wed, 23 Mar 2016 20:53:31 +0000 Subject: [PATCH 32/39] 868* driver/intr.c Handle 3.10 (centos 7) kernels for store_gdt. --- .release | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.release b/.release index d281df7..a6c7deb 100644 --- a/.release +++ b/.release @@ -1,3 +1,3 @@ -date=Wed Mar 23 20:49:46 GMT 2016 -release=dtrace-20160323 -build=497 +date=Wed Mar 23 20:53:22 GMT 2016 +release=dtrace-20160323a +build=498 From 8840497d4e6064aa97d7f6649f6f50b2119664d7 Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Mon, 13 Jun 2016 22:42:01 +0100 Subject: [PATCH 33/39] Fixes for linux-4.4 kernel. Seems to panic when loaded, but at least it compiles. --- driver/fbt_linux.c | 25 +++++++++++++++++++++++-- driver/instr_linux.c | 18 ++++++++++++++++-- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/driver/fbt_linux.c b/driver/fbt_linux.c index f9b0448..78a4492 100644 --- a/driver/fbt_linux.c +++ b/driver/fbt_linux.c @@ -388,10 +388,16 @@ fbt_provide_module(void *arg, struct modctl *ctl) { int i; struct module *mp = (struct module *) ctl; char *modname = mp->name; + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) + char *str = mp->kallsyms->strtab; +#else char *str = mp->strtab; +#endif char *name; par_module_t *pmp; int ret; + unsigned nsyms; # if 0 struct module *mp = ctl->mod_mp; @@ -459,12 +465,22 @@ TODO(); return; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) + nsyms = mp->kallsyms->num_symtab; +#else + nsyms = mp->num_symtab; +#endif + if (dtrace_here) - printk("%s(%d):modname=%s num_symtab=%u\n", dtrace_basename(__FILE__), __LINE__, modname, (unsigned) mp->num_symtab); + printk("%s(%d):modname=%s num_symtab=%u\n", dtrace_basename(__FILE__), __LINE__, modname, nsyms); - for (i = 1; i < mp->num_symtab; i++) { + for (i = 1; i < nsyms; i++) { uint8_t *instr, *limit; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) + Elf_Sym *sym = (Elf_Sym *) &mp->kallsyms->symtab[i]; +#else Elf_Sym *sym = (Elf_Sym *) &mp->symtab[i]; +#endif int dtrace_here = 0; if (strcmp(modname, "dummy") == 0) dtrace_here = 1; @@ -577,11 +593,16 @@ if (strcmp(modname, "dummy") == 0) dtrace_here = 1; /* if that page is now used by some other */ /* driver. */ /***********************************************/ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) + if (within_module_init(instr, mp)) + continue; +#else if (mp->module_init && mp->init_size && instr >= (uint8_t *) mp->module_init && instr < (uint8_t *) mp->module_init + mp->init_size) { continue; } +#endif /***********************************************/ /* We do have syms that appear to point to */ diff --git a/driver/instr_linux.c b/driver/instr_linux.c index a72b7c6..4e87628 100644 --- a/driver/instr_linux.c +++ b/driver/instr_linux.c @@ -292,8 +292,13 @@ instr_provide_module(void *arg, struct modctl *ctl) { int i; struct module *mp = (struct module *) ctl; char *modname = mp->name; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) + char *str = mp->kallsyms->strtab; +#else char *str = mp->strtab; +#endif char *name; + unsigned nsyms; par_module_t *pmp; int init; @@ -312,14 +317,23 @@ instr_provide_module(void *arg, struct modctl *ctl) return; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) + nsyms = mp->kallsyms->num_symtab; +#else + nsyms = mp->num_symtab; +#endif if (dtrace_here) - printk("%s(%d):modname=%s num_symtab=%u\n", __FILE__, __LINE__, modname, (unsigned) mp->num_symtab); + printk("%s(%d):modname=%s num_symtab=%u\n", __FILE__, __LINE__, modname, nsyms); if (strcmp(modname, "dtracedrv") == 0) return; - for (i = 1; i < mp->num_symtab; i++) { + for (i = 1; i < nsyms; i++) { uint8_t *instr, *limit; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) + Elf_Sym *sym = (Elf_Sym *) &mp->kallsyms->symtab[i]; +#else Elf_Sym *sym = (Elf_Sym *) &mp->symtab[i]; +#endif int dtrace_here = 0; if (strcmp(modname, "dummy") == 0) dtrace_here = 1; From 7f5185be9d29a0d1230518368a944626c5a15ae5 Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Mon, 13 Jun 2016 23:20:49 +0100 Subject: [PATCH 34/39] Fix for hrtimer_start_range_ns which replaces hrtimer_start. --- driver/cyclic_linux.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/driver/cyclic_linux.c b/driver/cyclic_linux.c index 08f9c93..2e13eff 100644 --- a/driver/cyclic_linux.c +++ b/driver/cyclic_linux.c @@ -111,6 +111,9 @@ static int (*fn_hrtimer_init)(struct hrtimer *timer, clockid_t which_clock, static int (*fn_hrtimer_cancel)(struct hrtimer *); static int (*fn_hrtimer_start)(struct hrtimer *timer, ktime_t tim, const enum hrtimer_mode mode); +static int (*fn_hrtimer_start_range_ns)(struct hrtimer *timer, ktime_t tim, + unsigned long delta_ns, + const enum hrtimer_mode mode); static u64 (*fn_hrtimer_forward)(struct hrtimer *timer, ktime_t now, ktime_t interval); #define TMR_ALIVE 1 @@ -144,10 +147,10 @@ init_cyclic() fn_hrtimer_cancel = get_proc_addr("hrtimer_cancel"); fn_hrtimer_init = get_proc_addr("hrtimer_init"); fn_hrtimer_start = get_proc_addr("hrtimer_start"); - fn_hrtimer_start = get_proc_addr("hrtimer_start"); + fn_hrtimer_start_range_ns = get_proc_addr("hrtimer_start_range_ns"); fn_hrtimer_forward = get_proc_addr("hrtimer_forward"); - if (fn_hrtimer_start == NULL) { + if (fn_hrtimer_start == NULL && fn_hrtimer_start_range_ns == NULL) { printk(KERN_WARNING "dtracedrv: Cannot locate hrtimer in this kernel\n"); return FALSE; } @@ -226,7 +229,10 @@ static void cyclic_tasklet_func(unsigned long arg) #else ptr->expires = ktime_add_ns(ptr->expires, kt.tv64); #endif - fn_hrtimer_start(&cp->c_htp, kt, HRTIMER_MODE_REL); + if (fn_hrtimer_start) + fn_hrtimer_start(&cp->c_htp, kt, HRTIMER_MODE_REL); + else if (fn_hrtimer_start_range_ns) + fn_hrtimer_start(&cp->c_htp, kt, 0, HRTIMER_MODE_REL); # endif cp->c_state = TMR_ALIVE; } @@ -331,7 +337,10 @@ cyclic_add(cyc_handler_t *hdrl, cyc_time_t *t) /* cp->c_htp.cb_mode = HRTIMER_CB_SOFTIRQ;*/ cp->c_htp.function = be_callback; - fn_hrtimer_start(&cp->c_htp, kt, HRTIMER_MODE_REL); + if (fn_hrtimer_start) + fn_hrtimer_start(&cp->c_htp, kt, HRTIMER_MODE_REL); + else + fn_hrtimer_start_range_ns(&cp->c_htp, kt, 0, HRTIMER_MODE_REL); return (cyclic_id_t) cp; } From 007eaf3c664e02d8a80ea4f7051ad27ce56a8246 Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Mon, 13 Jun 2016 23:21:16 +0100 Subject: [PATCH 35/39] 868* driver/intr.c Handle 3.10 (centos 7) kernels for store_gdt. --- .release | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.release b/.release index a6c7deb..0885d1b 100644 --- a/.release +++ b/.release @@ -1,3 +1,3 @@ -date=Wed Mar 23 20:53:22 GMT 2016 -release=dtrace-20160323a -build=498 +date=Mon Jun 13 23:21:08 BST 2016 +release=dtrace-20160613 +build=499 From 077cf9545d3b22ee22c2e9dda7325feb99772fdf Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Thu, 18 Aug 2016 22:24:49 +0100 Subject: [PATCH 36/39] update info. --- Status.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Status.txt b/Status.txt index 19a25b3..a76320c 100644 --- a/Status.txt +++ b/Status.txt @@ -3,6 +3,10 @@ a very good suggestion, so that people dont have to figure out from my titbits in the blog (http://www.crtags.blogspot.com), what works and what doesnt work. +20160818 PDF + + o Verified it works on Ubuntu 16.04 - 4.4 kernel. + 20150306 PDF o Took out broken "break" which caused xcall to randomly not work, @@ -22,7 +26,7 @@ doesnt work. Working Features - o Works on AS4/64 bit kernels, Ubuntu 8.xx - 14.xx (32-bit and 64-bit). + o Works on AS4/64 bit kernels, Ubuntu 8.xx - 16.xx (32-bit and 64-bit). Not every kernel version tested, but should build on at least 2.6.12 onwards. o Tested up to 3.16 kernels, but not proven/tested under later kernels. From fb9f0e0fe56434a458d9808476d72efaca732a81 Mon Sep 17 00:00:00 2001 From: David Kedves Date: Thu, 9 Mar 2017 10:20:18 +0100 Subject: [PATCH 37/39] Kernel module compilation fixes for Linux 4.9.x --- driver/vminfo.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/driver/vminfo.c b/driver/vminfo.c index d89ad20..f408616 100644 --- a/driver/vminfo.c +++ b/driver/vminfo.c @@ -109,18 +109,30 @@ void vminfo_init(void) sdt_add_locator(vm_event_addr(PGDEACTIVATE), "vminfo:::pgdeactivate"); sdt_add_locator(vm_event_addr(PGFAULT), "vminfo:::pgfault"); sdt_add_locator(vm_event_addr(PGMAJFAULT), "vminfo:::pgmajfault"); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0) + sdt_add_locator(vm_event_addr(PGREFILL), "vminfo:::pgrefill"); +#else sdt_add_locator(vm_event_addr(PGREFILL_NORMAL), "vminfo:::pgrefill"); sdt_add_locator(vm_event_addr(PGREFILL_MOVABLE), "vminfo:::pgrefill"); +#endif # if LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0) sdt_add_locator(vm_event_addr(PGSTEAL_NORMAL), "vminfo:::pgsteal"); sdt_add_locator(vm_event_addr(PGSTEAL_MOVABLE), "vminfo:::pgsteal"); sdt_add_locator(vm_event_addr(KSWAPD_STEAL), "vminfo:::kswapd_steal"); #endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0) + sdt_add_locator(vm_event_addr(PGSCAN_KSWAPD), "vminfo:::pgscan_kswapd"); +#else sdt_add_locator(vm_event_addr(PGSCAN_KSWAPD_NORMAL), "vminfo:::pgscan_kswapd"); sdt_add_locator(vm_event_addr(PGSCAN_KSWAPD_MOVABLE), "vminfo:::pgscan_kswapd"); +#endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0) + sdt_add_locator(vm_event_addr(PGSCAN_DIRECT), "vminfo:::pgscan_direct"); +#else sdt_add_locator(vm_event_addr(PGSCAN_DIRECT_NORMAL), "vminfo:::pgscan_direct"); sdt_add_locator(vm_event_addr(PGSCAN_DIRECT_MOVABLE), "vminfo:::pgscan_direct"); +#endif #ifdef CONFIG_NUMA sdt_add_locator(vm_event_addr(PGSCAN_ZONE_RECLAIM_FAILED), "vminfo:::pgscan_zone_reclaim_failed"); @@ -138,8 +150,13 @@ void vminfo_init(void) /*sdt_add_locator(vm_event_addr(KSWAPD_SKIP_CONGESTION_WAIT), "vminfo:::kswapd_skip_congestion_wait");*/ #endif sdt_add_locator(vm_event_addr(PAGEOUTRUN), "vminfo:::pageoutrun"); - sdt_add_locator(vm_event_addr(ALLOCSTALL), "vminfo:::allocstall"); sdt_add_locator(vm_event_addr(PGROTATED), "vminfo:::pgrotated"); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0) + sdt_add_locator(vm_event_addr(ALLOCSTALL_NORMAL), "vminfo:::allocstall"); + sdt_add_locator(vm_event_addr(ALLOCSTALL_MOVABLE), "vminfo:::allocstall"); +#else + sdt_add_locator(vm_event_addr(ALLOCSTALL), "vminfo:::allocstall"); +#endif #ifdef CONFIG_COMPACTION #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 8, 0) @@ -173,7 +190,11 @@ void vminfo_init(void) sdt_add_locator(vm_event_addr(THP_FAULT_FALLBACK), "vminfo:::thp_fault_fallback"); sdt_add_locator(vm_event_addr(THP_COLLAPSE_ALLOC), "vminfo:::thp_collapse_alloc"); sdt_add_locator(vm_event_addr(THP_COLLAPSE_ALLOC_FAILED), "vminfo:::thp_collapse_alloc_failed"); + #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0) + sdt_add_locator(vm_event_addr(THP_SPLIT_PAGE), "vminfo:::thp_split"); + #else sdt_add_locator(vm_event_addr(THP_SPLIT), "vminfo:::thp_split"); + #endif # endif dtrace_parse_kernel(PARSE_GS_INC, vminfo_instr_callback, 0); # endif /* if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38) */ From 154a999d0d4822c03d1a94505dc3201cbb9043d2 Mon Sep 17 00:00:00 2001 From: Matheus Marchini Date: Fri, 1 Sep 2017 11:54:17 -0300 Subject: [PATCH 38/39] Fix build for Kernel 4.10 or higher Build wasn't working on Kernel 4.10 or higher because of some changes on their headers, this patch fixes it without breaking build on previous kernel versions. --- driver/cyclic_linux.c | 17 ++++++++++++----- driver/dtrace_linux.c | 3 +-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/driver/cyclic_linux.c b/driver/cyclic_linux.c index 2e13eff..c16de60 100644 --- a/driver/cyclic_linux.c +++ b/driver/cyclic_linux.c @@ -190,7 +190,11 @@ static void cyclic_tasklet_func(unsigned long arg) break; ptr = &cp->c_htp; - kt.tv64 = cp->c_time.cyt_interval; + #if(LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0)) + kt.tv64 = cp->c_time.cyt_interval; + #else + kt = cp->c_time.cyt_interval; + #endif /***********************************************/ /* Invoke the callback. */ /***********************************************/ @@ -326,11 +330,15 @@ cyclic_add(cyc_handler_t *hdrl, cyc_time_t *t) } cnt_timer_add++; - kt.tv64 = t->cyt_interval; + #if(LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0)) + kt.tv64 = t->cyt_interval; + #else + kt = t->cyt_interval; + #endif cp->c_hdlr = *hdrl; cp->c_time = *t; - cp->c_sec = kt.tv64 / (1000 * 1000 * 1000); - cp->c_nsec = kt.tv64 % (1000 * 1000 * 1000); + cp->c_sec = ktime_to_ns(kt) / (1000 * 1000 * 1000); + cp->c_nsec = ktime_to_ns(kt) % (1000 * 1000 * 1000); cp->c_state = TMR_ALIVE; fn_hrtimer_init(&cp->c_htp, CLOCK_MONOTONIC, HRTIMER_MODE_REL); @@ -471,4 +479,3 @@ cyclic_remove(cyclic_id_t id) } } # endif - diff --git a/driver/dtrace_linux.c b/driver/dtrace_linux.c index ed3f518..84f2af1 100644 --- a/driver/dtrace_linux.c +++ b/driver/dtrace_linux.c @@ -762,7 +762,7 @@ dtrace_linux_init(void) } # if defined(__arm__) ktime_get_ptr = (ktime_t (*)(void)) get_proc_addr("ktime_get"); - # define rdtscll(t) t = ktime_get_ptr().tv64 + # define rdtscll(t) t = ktime_to_ns(ktime_get_ptr()) # define __flush_tlb_all() local_flush_tlb_all() # define _PAGE_NX 0 # define _PAGE_RW 0 @@ -3246,4 +3246,3 @@ static void __exit dtracedrv_exit(void) } module_init(dtracedrv_init); module_exit(dtracedrv_exit); - From 8f602789963f2979c9547efc52ec1d7a55217a1b Mon Sep 17 00:00:00 2001 From: Paul D Fox Date: Sun, 22 Sep 2019 12:14:45 +0100 Subject: [PATCH 39/39] fix some warnings and some compile errors. --- libctf/makefile | 19 +++++++------- libdtrace/makefile | 11 ++++---- liblinux/makefile | 1 + libproc/common/Pgcore.c | 3 +++ libproc/common/makefile | 1 + libproc/common/proc_arg.c | 4 +-- librtld/makefile | 4 +-- librtld/rtld_db.c | 3 ++- linux/sys/signal.h | 4 +++ tests/syscalls.c | 53 ++++++++++++++++++++++++--------------- 10 files changed, 64 insertions(+), 39 deletions(-) diff --git a/libctf/makefile b/libctf/makefile index b839337..2c7e259 100644 --- a/libctf/makefile +++ b/libctf/makefile @@ -5,6 +5,7 @@ CPPFLAGS += -I../common -I../common/ctf -I../uts/common/ \ -I../linux -DCTF_OLD_VERSIONS $(PTR32) CPPFLAGS += -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 BINDIR = ../$(BUILD_DIR) +ARFLAGS=Urv COMMON_OBJS = \ ctf_create.o \ @@ -36,47 +37,47 @@ $(BINDIR)/libctf.a: \ $(BINDIR)/libctf.a(ctf_create.o): $(COMMON)/ctf_create.c $(CC) $(CPPFLAGS) -c $< - $(AR) rv $(BINDIR)/libctf.a ctf_create.o + $(AR) $(ARFLAGS) $(BINDIR)/libctf.a ctf_create.o rm -f ctf_create.o $(BINDIR)/libctf.a(ctf_error.o): $(COMMON)/ctf_error.c $(CC) $(CPPFLAGS) -c $< - $(AR) rv $(BINDIR)/libctf.a ctf_error.o + $(AR) $(ARFLAGS) $(BINDIR)/libctf.a ctf_error.o rm -f ctf_error.o $(BINDIR)/libctf.a(ctf_hash.o): $(COMMON)/ctf_hash.c $(CC) $(CPPFLAGS) -c $< - $(AR) rv $(BINDIR)/libctf.a ctf_hash.o + $(AR) $(ARFLAGS) $(BINDIR)/libctf.a ctf_hash.o rm -f ctf_hash.o $(BINDIR)/libctf.a(ctf_labels.o): $(COMMON)/ctf_labels.c $(CC) $(CPPFLAGS) -c $< - $(AR) rv $(BINDIR)/libctf.a ctf_labels.o + $(AR) $(ARFLAGS) $(BINDIR)/libctf.a ctf_labels.o rm -f ctf_labels.o $(BINDIR)/libctf.a(ctf_lookup.o): $(COMMON)/ctf_lookup.c $(CC) $(CPPFLAGS) -c $< - $(AR) rv $(BINDIR)/libctf.a ctf_lookup.o + $(AR) $(ARFLAGS) $(BINDIR)/libctf.a ctf_lookup.o rm -f ctf_lookup.o $(BINDIR)/libctf.a(ctf_open.o): $(COMMON)/ctf_open.c $(CC) $(CPPFLAGS) -c $< - $(AR) rv $(BINDIR)/libctf.a ctf_open.o + $(AR) $(ARFLAGS) $(BINDIR)/libctf.a ctf_open.o rm -f ctf_open.o $(BINDIR)/libctf.a(ctf_types.o): $(COMMON)/ctf_types.c $(CC) $(CPPFLAGS) -c $< - $(AR) rv $(BINDIR)/libctf.a ctf_types.o + $(AR) $(ARFLAGS) $(BINDIR)/libctf.a ctf_types.o rm -f ctf_types.o $(BINDIR)/libctf.a(uncompress.o): uncompress.c $(CC) $(CPPFLAGS) -c $< - $(AR) rv $(BINDIR)/libctf.a uncompress.o + $(AR) $(ARFLAGS) $(BINDIR)/libctf.a uncompress.o rm -f uncompress.o $(BINDIR)/libctf.a(ctf_util.o): $(COMMON)/ctf_util.c $(CC) $(CPPFLAGS) -c $< - $(AR) rv $(BINDIR)/libctf.a ctf_util.o + $(AR) $(ARFLAGS) $(BINDIR)/libctf.a ctf_util.o rm -f ctf_util.o clean: diff --git a/libdtrace/makefile b/libdtrace/makefile index c56a583..77e62e0 100644 --- a/libdtrace/makefile +++ b/libdtrace/makefile @@ -1,3 +1,4 @@ +ARFLAGS=Urv CC=gcc -g $(BUILD_BITS) CPPFLAGS += -I. \ -I../../common/ctf \ @@ -88,14 +89,14 @@ $(BINDIR)/dt_grammar.h $(LIB)(dt_grammar.o): dt_grammar.y $(H) mv y.tab.h $(BINDIR)/dt_grammar.h mv y.tab.c dt_grammar.c $(CC) -DYYDEBUG=1 -DYYERROR_VERBOSE $(CPPFLAGS) -c dt_grammar.c - ar rv $(LIB) dt_grammar.o + ar $(ARFLAGS) $(LIB) dt_grammar.o -rm -f dt_grammar.c dt_grammar.o #dt_grammar.h: $(LIB)(dt_grammar.o) $(LIB)(dt_lex.o): $(BINDIR)/dt_grammar.h $(BINDIR)/dt_lex.c $(H) $(CC) $(CPPFLAGS) -c $(BINDIR)/dt_lex.c - ar rv $(LIB) dt_lex.o + ar $(ARFLAGS) $(LIB) dt_lex.o -rm -f dt_lex.o $(BINDIR)/dt_lex.c: dt_lex.l lex -t -v dt_lex.l > $(BINDIR)/dt_lex.c @@ -106,16 +107,16 @@ $(BINDIR)/drti.o: drti.c $(H) $(LIB)(dis_tables.o): ../driver/dis_tables.c $(H) $(CC) $(CPPFLAGS) -Ii386 -I../driver -c ../driver/dis_tables.c - ar rv $(LIB) dis_tables.o + ar $(ARFLAGS) $(LIB) dis_tables.o -rm -f dis_tables.o $(LIB)(dt_names.o): dt_names.c $(CC) $(CPPFLAGS) -c dt_names.c - ar rv $(LIB) dt_names.o + ar $(ARFLAGS) $(LIB) dt_names.o -rm -f dt_names.o $(LIB)(dt_isadep.o): i386/dt_isadep.c $(H) $(CC) $(CPPFLAGS) -Ii386 -I../driver -c i386/dt_isadep.c - ar rv $(LIB) dt_isadep.o + ar $(ARFLAGS) $(LIB) dt_isadep.o -rm -f dt_isadep.o clean: -rm -f dt_errtags.c dt_names.c dt_grammar.h dt_lex.c *.o *.a diff --git a/liblinux/makefile b/liblinux/makefile index fa8c00d..3cf5a13 100644 --- a/liblinux/makefile +++ b/liblinux/makefile @@ -1,3 +1,4 @@ +ARFLAGS=Urv CC=gcc -g $(BUILD_BITS) CPPFLAGS += -I../libproc/common \ -I../common/ctf \ diff --git a/libproc/common/Pgcore.c b/libproc/common/Pgcore.c index 43c7ea2..3d2bc33 100644 --- a/libproc/common/Pgcore.c +++ b/libproc/common/Pgcore.c @@ -83,6 +83,9 @@ typedef struct { shstrtab_t pgc_shstrtab; } pgcore_t; +void bzero(void *, size_t); +void bcopy(const void *src, void *dest, size_t n); + static void shstrtab_init(shstrtab_t *s) { diff --git a/libproc/common/makefile b/libproc/common/makefile index 2c64df1..369a0e9 100644 --- a/libproc/common/makefile +++ b/libproc/common/makefile @@ -1,3 +1,4 @@ +ARFLAGS=Urv CC=gcc -g $(BUILD_BITS) CPPFLAGS += -I../common \ -I../../common/ctf \ diff --git a/libproc/common/proc_arg.c b/libproc/common/proc_arg.c index b85c8f2..d4758ac 100644 --- a/libproc/common/proc_arg.c +++ b/libproc/common/proc_arg.c @@ -459,7 +459,7 @@ proc_walk(proc_walk_f *func, void *arg, int flag) continue; /* PR_WALK_PROC case */ (void) snprintf(pidstr, sizeof (pidstr), - "%s/%ld/psinfo", procfs_path, pid); + "%s/%ld/psinfo", procfs_path, (long) pid); fd = open(pidstr, O_RDONLY); if (fd < 0) continue; @@ -475,7 +475,7 @@ proc_walk(proc_walk_f *func, void *arg, int flag) } /* PR_WALK_LWP case */ (void) snprintf(pidstr, sizeof (pidstr), - "%s/%ld/lpsinfo", procfs_path, pid); + "%s/%ld/lpsinfo", procfs_path, (long) pid); fd = open(pidstr, O_RDONLY); if (fd < 0) continue; diff --git a/librtld/makefile b/librtld/makefile index 3d3fca4..2fb8e6e 100644 --- a/librtld/makefile +++ b/librtld/makefile @@ -22,13 +22,13 @@ $(LIB): \ $(LIB)(rd_elf32.o): rd_elf.c $(CC) $(CPPFLAGS) -c rd_elf.c mv rd_elf.o rd_elf32.o - ar rv $(LIB) rd_elf32.o + ar $(ARFLAGS) $(LIB) rd_elf32.o rm -f rd_elf32.o $(LIB)(rd_elf64.o): rd_elf.c $(CC) $(CPPFLAGS) -D_ELF64 -c rd_elf.c mv rd_elf.o rd_elf64.o - ar rv $(LIB) rd_elf64.o + ar $(ARFLAGS) $(LIB) rd_elf64.o rm -f rd_elf64.o clean: -rm -f *.o *.a diff --git a/librtld/rtld_db.c b/librtld/rtld_db.c index cb06c21..dd01a27 100644 --- a/librtld/rtld_db.c +++ b/librtld/rtld_db.c @@ -27,6 +27,7 @@ #include +#include #include #include #include @@ -260,7 +261,7 @@ rd_errstr(int rderr) rd_err_e rd_event_addr(rd_agent_t *rdap, rd_event_e event, rd_notify_t *notify) { - printf("proc-stub:%s addr=%p\n", __func__, rdap->rda_addr); + printf("proc-stub:%s addr=%p\n", __func__, (void *) rdap->rda_addr); notify->type = RD_NOTIFY_BPT; notify->u.bptaddr = rdap->rda_addr; diff --git a/linux/sys/signal.h b/linux/sys/signal.h index b8fb2cf..f978c95 100644 --- a/linux/sys/signal.h +++ b/linux/sys/signal.h @@ -69,7 +69,9 @@ #define SIGILL 4 #define SIGTRAP 5 #define SIGABRT 6 +# if !defined(SIGIOT) #define SIGIOT 6 +# endif #define SIGBUS 7 #define SIGFPE 8 #define SIGKILL 9 @@ -95,7 +97,9 @@ #define SIGVTALRM 26 #define SIGPROF 27 #define SIGWINCH 28 +# if !defined(SIGIO) #define SIGIO 29 +# endif #define SIGPOLL SIGIO #define SIGCANCEL 36 /* reserved signal for thread cancellation */ diff --git a/tests/syscalls.c b/tests/syscalls.c index e99bdfe..4e5d8e3 100644 --- a/tests/syscalls.c +++ b/tests/syscalls.c @@ -5,11 +5,25 @@ /* problems. */ /**********************************************************************/ # include +# include # include # include # include # include # include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include /*# include */ static int cnt; @@ -108,8 +122,8 @@ int main(int argc, char **argv) x += getuid(); x += getgid(); x += setsid(); - x += seteuid(); - x += setegid(); + x += seteuid(0); + x += setegid(0); lseek(0, 0, -1); kill(0, 0); signal(99, 0); @@ -118,36 +132,36 @@ int main(int argc, char **argv) // *(int *) 0 = 0; pipe(0); munmap(0, 0); - mincore(0, 0); - shmget(0); - shmat(0); + mincore(0, 0, 0); + shmget(0, 0, 0); + shmat(0, 0, 0); line = __LINE__; - poll(-1, 0, 0); + poll((void *) -1, 0, 0); signal(SIGSEGV, SIG_IGN); // ppoll(-1, -1, -1, 0); signal(SIGSEGV, SIG_DFL); sched_yield(); - readv(-1, 0, 0, 0); - writev(-1, 0, 0, 0); + readv(-1, 0, 0); + writev(-1, 0, 0); msync(0, 0, 0); fsync(-1); fdatasync(-1); semget(0, 0, 0); semctl(0, 0, 0); - uselib(NULL); +// uselib(NULL); pivot_root(0, 0); personality(-1); setfsuid(-1); flock(-1, 0); - shmdt(0, 0, 0); + shmdt(0); times(0); mremap(0, 0, 0, 0, 0); madvise(0, 0, 0); fchown(-1, 0, 0); - lchown(0, 0, 0); - setreuid(); - setregid(); + lchown("", 0, 0); + setreuid(0, 0); + setregid(0, 0); link("/nonexistant", "/also-nonexistant"); do_slow(); @@ -156,11 +170,10 @@ int main(int argc, char **argv) rename("/", "/"); mkdir("/junk/stuff////0", 0777); geteuid(); - getsid(); - getpgid(); + getsid(0); + getpgid(0); getresuid(); getresgid(); - getpgid(); ptrace(-1, 0, 0, 0); semop(0, 0, 0); capget(0, 0); @@ -170,7 +183,7 @@ int main(int argc, char **argv) settimeofday(0, 0); dup(-1); dup2(-1, -1); - shmctl(0, 0, 0, 0); + shmctl(0, 0, 0); execve("/bin/nothing", "/bin/nothing", 0); alarm(9999); bind(0, 0, 0); @@ -199,7 +212,7 @@ int main(int argc, char **argv) sigprocmask(0, 0, 0); x += open("/nothing", 0); x += chdir("/nothing"); - x += mknod("/nothing/nothing", 0); + x += mknod("/nothing/nothing", 0, 0); x += ioctl(); execve("/nothing", NULL, NULL); line = __LINE__; @@ -213,7 +226,7 @@ int main(int argc, char **argv) brk(0); sbrk(0); line = __LINE__; - mmap(0, 0, 0, 0, 0); + mmap(0, 0, 0, 0, 0, 0); line = __LINE__; uname(0); line = __LINE__; @@ -226,7 +239,7 @@ int main(int argc, char **argv) umount(0, 0, 0); swapon(0, 0); swapoff(0); - sethostname(0); + sethostname(0, 0); line = __LINE__; time(NULL); unlink("/nothing");