dtrace

dTrace scripts and tools

I've recently began using dTrace and have noticed just how awesome it is. Its the perfect tool for profiling without placing the burden on programmers to set up hundreds of probes in their applications. I've found some nice one liner and sample scripts here and there, but I was wondering about what scripts, tools and links others might ...

Pointers to learn how to use DTrace

When I asked for tools to profile Rails apps, someone pointed at DTrace. Since I work on MacOSX stations and deploy on OpenSolaris, it is a valid way to go. But I have little knowledge of DTrace. Besides the usual suspect, Sun DTrace page and the avaliable info there, is there any other killer pointer to learn Dtrace out there? ...

Monitor Cocoa apps for execution of external utilities (e.g., ffmpeg) on Mac OS X ?

There are Mac GUI applications which provide a front-end to more geeky commandline tools (often included as a part of the application package). I would like to look at what is happening under the hood of such GUIs. How to "attach" to an application, monitor it for calls to command line utilities and log a filename and command line param...

Creating dtrace probes for plugins using single provider name

Note that this is for Mac OS X, although I imagine my problem would exist on any dtrace-capable OS. I have an app that utilizes a lot of plugins. I'm adding userland probes to it, in both the core application and in the plugins themselves. The issue is that if I use the same provider name in the plugins that the main app is using, tho...

What is the programming paradigm of Dtrace?

I've been using Dtrace for a while, and as time goes by I've began to wonder what's the programming paradigm of the D language used in Dtrace. It's not an imperative language, I guess, so that means it's some sort of declarative functional language, but I'm no expert in language taxonomy, so what should the D language officially (or s...

Setting my own probes with Dtrace in C++

I have some custom dtrace probes in a C-library, and when linking and using the library with a C application my probes work fine, however when linked against C++ it says it can't find them. The reason seems to be because of C++ mangling, and trying to get it to work has become a duck chase. Any ideas? Note: Using gcc ...

How to redirect Dtrace output when using the -c flag?

How can I redirect only Dtrace's output when running a script with the -C flag? like in this case: dscript.d -s myscript.d -c date Note: I found the answer to my question before posting it, but I'm putting it here so it's part of SO. ...

Is is possible to use DTrace to view the arguments passed to strncpy?

I know I could write an interposer to watch the arguments being passed to the strncpy library call, but it seems like this should be easy to do with DTrace. ...

How to use hotspot probes in dtrace on Mac OS X Leopard?

My Leopard system has dtrace built in. I also have Java 6 installed, using the Apple-provided installer: $ java -version java version "1.6.0_13" Java(TM) SE Runtime Environment (build 1.6.0_13-b03-211) Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02-83, mixed mode) Nevertheless, dtrace shows no hotspot probes when listing probes: $ ...

DTrace on Leopard: No probes specified, even when I specify probes

% sudo dtrace -p 2446 'objc$target:NSObject:-init:entry { trace(); }' dtrace: no probes specified The manpage suggests that this is the correct format with which to specify a probe on an Objective-C method. I tried -Z, but (unsurprisingly) that just didn't print anything. [Added] It's not even specific to Objective-C probes. I tried i...

Why does DTrace give me invalid-address errors some times and not others?

My program: typedef struct objc_class { struct objc_class *isa; struct objc_class *super_class; char *name; long version; long info; long instance_size; void *ivars; void *methodLists; void *cache; void *protocols; } *Class; struct objc_object { Class isa; }; /* Code to extract the class name from arg0 based on a snippet by ...

How to trace a program from its very beginning without running it as root

I'm writing a tool that calls through to DTrace to trace the program that the user specifies. If my tool uses dtrace -c to run the program as a subprocess of DTrace, not only can I not pass any arguments to the program, but the program runs with all the privileges of DTrace—that is, as root (I'm on Mac OS X). This makes certain things t...

How to measure mutex contention?

I have some threaded code using PThreads on Linux that, I suspect, is suffering from excessive lock contention. What tools are available for me to measure this? Solaris has DTrace and plockstat. Is there something similar on Linux? (I know about a recent DTrace port for Linux but it doesn't seem to be ready for prime time yet.) ...

ltrace equivalent for osx?

osx has the really powerful dtrace/ktrace/dtruss tools - however i'm not willing to invest the time necessary to learn dealing with them right now. what's the easiest way to get the equivalent functionality of linux ltrace (and possibly strace) on OSX? ...

Pthread id from pthread_self() doesn't match data from dtrace script

I'm using this dtrace script from here to try to find when context switches occur for the threads of a java program. I'm trying to match the data gathered from the script with trace data gathered from the running program (things like method entry/exit). I get the pthread id of the running thread using a short JNI method that simply ret...

How do I print a CFStringRef in a DTrace action?

I have a DTrace probe catching calls to a function, and one of the function's arguments is a CFStringRef. This is private structure that holds a pointer to a unicode string. But the CFStringRef is not itself a char*, so normal DTrace methods like copyinstr() just return ?cp?, which isn't exactly helpful. So how can I print out the strin...

How to view call stack with dtrace

Question: How to view call stack, return value and arguments of the simply program below, with dtrace /** Trival code **/ #include <stdio.h> int foo (int *a, int *b) { *a = *b; *b = 4; return 0; } int main (void) { int a, b; a = 1; b = 2; foo (&a, &b); printf ("Value a: %d, Value b...

How to get a string from memory into DTrace script

I have a char* in my DTrace script that I know points to a zero-terminated string. How to access this string? Is there some function like copyin() that handles zero-terminated strings? ...

Equivalent of strace -feopen < command > on mac os X

This is useful for debugging (hence programming related). On linux, we can use the command strace -feopen python myfile.py to figure out which python modules and shared objects are loaded. Is there an equivalent one-liner on macOS X? ...

What's an alternative for DTrace on Linux?

From what I can see, a DTrace implementation on Linux is held up by licensing and politics. What are the alternatives currently? ...