Skip to content

pampanelson/dtrace-for-linux

Repository files navigation

Linux port of DTrace

June 2009
Paul D. Fox
fox@crisp.demon.co.uk
http://www.twitter.com/crispeditor
http://www.crisp.demon.co.uk

Blog - latest news and stuff about the dtrace project:

   http://www.crisp.demon.co.uk/blog/

Download dtrace tarballs for linux here:

   ftp://crisp.dynalias.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.

It also makes it more of a challenge than Solaris or FreeBSD or
MacOSX, which have dtrace too, since we are trying to support old
and new kernels, 32 and 64 bit kernels, and have to fit in with
Linux's desire to change and evolve. So, if this works for you, great.
If not, feel free to feedback what/why it doesnt work and we
may be able to address the issues.

The goal of this project is to ensure dtrace is everywhere - so
that we can all benefit from faster systems and software, better
kernels and generally be a good citizen to the user and administrators
systems.
  
Licensing
=========

The majority (if not all) of this code falls under Sun's CDDL
license. Some files or headers may originate with GPL code, e.g.
ELF libraries from GLIBC or RedHat. The original files
copyrights are left intact, so please honour those as appropriate.
Any files without an attributed copyright are likely my own
invention and can be placed under the GPLv3, but this is a mixed-mode
project, and it is not *my* right to give Dtrace away under GPL.

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 Sun 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 has gracefully donated to the community a large body
of work.

My efforts are simply in glueing pieces together and as such,
these pieces of work may be considered falling somewhere between
GPL and CDDL. 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. I will not and can not 
ascribe code that does not belong to me.

If the code is useful to you - great. Spread it around and get
people to use, debug and enhance it.

GIT Repository
==============

http://github.com/pmccormick/dtrace-for-linux/tree/master

Thanks to Peter McCormick for setting this up.

   NOTE: This is not the master archive for dtrace. Peter has
   kindly set this up and it may lag the master releases. See
   the links at the top of this document for the current homepage
   data.

Installation
============

Very simple:

	$ make all
	$ make install
	$ make load           (need to be root or have sudo access)

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.

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.

Miscellaneous
=============

This is a pre-alpha, work-in-progress port of Sun's DTrace kernel
debugging tool for Linux. It is not prime-time and much of it
doesnt compile.

I have taken a variety of approaches to get where I am:

custom include dir: 

	- <linux> for user land tools which front-ends /usr/include and
	  /usr/include/sys
	- <sys> for the kernel drivers.

makefiles are incomplete - I use 'makefile' and will clean up Suns
Makefile and Makefile.targ and other extraneous subdirs to simplify things.

make-me is a temporary script to build the kernel drivers.

No top-level makefile at present. In cmd/dtrace/dtrace is a 64-bit dtrace
binary built on RedHat FC8. Will remove that and make it buildable.

Kernel drivers assume access to /usr/src/linux -- needs to be fixed.
kernel drivers dont compile yet. Lots of use of 

	# if defined(sun)
	...
	# endif

for bits we wont want (much cribbed from the FreeBSD port).

Some code has

	# if linux
	...
	#endif

where its definitely Linux time.

No GPL code in here at present; all CDDL.

'tags' files are CRiSP format cross-reference files. If you dont have
CRiSP, delete them and build your own !

If you see 'warn' in a makefile, its a tool which color codes gcc
warnings and errors and makes it easier to read the output. It also
knows how to hide the exceptionally annoying non-warning output lines
which are impossible to fix in real life code without a gazillion
of compiler flags.

INSTALLATION
============

Run 'make' with no arguments to see the current options.

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

For AS4/Centos
==============
	yum install elfutils-libelf-devel

About

Linux port of Sun's Dtrace framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published