9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "Devon H. O'Dell" <devon.odell@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] dtrace for plan 9
Date: Mon,  9 Nov 2009 22:08:18 -0500	[thread overview]
Message-ID: <9ab217670911091908u25e0a23bk838bd67c460492ac@mail.gmail.com> (raw)
In-Reply-To: <8dc3b4a146dde183a3896542f92e9507@coraid.com>

2009/11/9 erik quanstrom <quanstro@coraid.com>:
>> > I keep hearing this brought up, but (while I am not an expert) AFAICT, the
>> > runtime for each D hook should be strictly bounded by the number of
>> > instructions lobbed in, since D does not (without root override, perhaps?)
>> > support backwards jumps.  Am I mistaken in my understanding of DTrace?
>>
>> You are right. I don't think runtime is unbounded. At the same time,
>> I'm still trying to locate example scripts to get an idea of how
>> complex it is. I'm talking to people at sun to get a handle on the
>> question.

D doesn't do loops or conditionals. You can't branch. But you can get
around that with some tricks, like aggregations and predicates. For
what you'd typically use it for, it should be ok. That said, my
knowledge of DTrace internals greatly surpasses my knowledge of how to
actually use it, so I'll let Roman help out on that front :)

> before we go all crazy, has anyone else tried ron's
> great tracing?

It's good, I read the paper and played around with it while I was
doing some 9vx work. But it's not really the same. Devtrace implements
a subset of DTrace's functionality.

DTrace does more than syscalls, and a lot of the talk on this thread
seems to be focused around that, so please let me clarify a bit. This
is partially due to compiling binaries with CTF (Compact C Type Format
-- when I asked the guys about this, they laughed and said it was so
compact that they cut off a C from the acronym). CTF stores type /
name / size information about symbols in a program, but is not as
heavy as DWARF: no line information is stored, no file references,
etc. The data is stored in an extended ELF header, compressed with
zlib.

DTrace by itself is pretty lame. It needs providers to be interesting.
By itself, it's a very limited interpreter that supports BEGIN and
END, and a couple other tiny things (ERROR, maybe?). Devtrace would be
analogous to the syscall provider for DTrace, from my understanding.

Because of CTF, DTrace also has providers to do function boundary
tracing (function entries / exits) on any executable (including a live
kernel) that has been compiled with CTF symbols. The fasttrap (or PID)
provider allows for instruction level tracing by inserting a
breakpoint at a given location, catching it, executing what was
previously at the breakpoint, executing the relevant D code (which may
in turn be traced by DTrace up to a finite amount of recursion), until
it comes back up the stack. The USDT providers allow userland
applications -- languages such as Perl, PHP, or Python for instance --
to register DTrace hooks. Once a userland app has done this, you can
follow e.g. a Python function call from the script, through Python,
through libc, through a syscall, all the way to a device driver... and
back up again.

It's also fairly easy to do this. I was at a party with the Sun guys
at OSCon in 2005. Wez Furlong wrote a DTrace provider for PHP in about
30 minutes with Bryan Cantrill, who then rather excitedly ran to me
explaining how I needed to come look (this is a gross understatement
for brevity). It was pretty cool, and the code needed for the DTrace
hooking was smaller than the PHP module skeleton code.

While extending it may be done relatively easy, it is quite big. When
I was working on porting it to FreeBSD (before jb@ essentially usurped
the project, anyway), I spent 3 weeks getting CTF and the base DTrace
provider ported over. Granted, I was much less experienced than now,
but it is a significant amount of work to reproduce all the
functionality. I'd estimate a finished version to be about the size of
the Plan 9 kernel.

--me



  reply	other threads:[~2009-11-10  3:08 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <<9ab217670911010852h46cc32a0k2e3ef99323287595@mail.gmail.com>
2009-11-01 16:58 ` erik quanstrom
2009-11-01 18:44   ` Nathaniel W Filardo
2009-11-03 15:30     ` Iruata Souza
2009-11-03 18:29       ` Lyndon Nerenberg
2009-11-03 18:50         ` Iruata Souza
2009-11-07 10:45       ` Ethan Grammatikidis
2009-11-07 17:44         ` ron minnich
2009-11-08 14:19         ` dave.l
2009-11-09  0:07           ` dave.l
2009-11-09  0:27             ` hiro
2009-11-09  0:56             ` ron minnich
2009-11-10  0:33             ` Nathaniel W Filardo
2009-11-10  0:46               ` ron minnich
2009-11-10  1:00                 ` Roman Shaposhnik
2009-11-10 20:21                   ` dave.l
2009-11-10 23:38                     ` Roman Shaposhnik
2009-11-13 23:47                       ` dave.l
2009-11-10  2:37                 ` erik quanstrom
2009-11-10  3:08                   ` Devon H. O'Dell [this message]
2009-11-10  4:20                     ` Roman Shaposhnik
2009-11-10  0:47               ` Roman Shaposhnik
     [not found] <<9ab217670911091908u25e0a23bk838bd67c460492ac@mail.gmail.com>
2009-11-10  3:26 ` erik quanstrom
2009-11-10  4:05   ` Devon H. O'Dell
     [not found] <<13426df10911081656q75a7b5aawd01dc9df71beca08@mail.gmail.com>
2009-11-09 14:28 ` erik quanstrom
2009-11-09 15:45   ` ron minnich
2009-11-09 16:01     ` erik quanstrom
     [not found] <<Pine.BSI.4.64.0911011858540.4700@malasada.lava.net>
2009-11-02  5:03 ` erik quanstrom
2009-11-02 15:59   ` David Leimbach
     [not found] <<4AEDB3DD.2010205@maht0x0r.net>
2009-11-01 16:19 ` erik quanstrom
2009-11-01 16:52   ` Devon H. O'Dell
2009-11-01 17:19     ` ron minnich
     [not found] <<e763acc10910312200k4fe66aa8q557dcfe3a1d73ff3@mail.gmail.com>
2009-11-01 13:25 ` erik quanstrom
2009-11-01 16:14   ` matt
2009-11-02  4:59   ` Tim Newsham
     [not found] <<13426df10910271720t7679d169k84fb7d4b9a9cefc5@mail.gmail.com>
2009-10-28  1:49 ` erik quanstrom
2009-10-28  2:23   ` ron minnich
2009-10-28  2:38     ` Jeff Sickel
2009-11-01  3:01       ` dave.l
2009-11-01  3:26         ` ron minnich
2009-11-01  5:00           ` Roman Shaposhnik
2009-10-28  0:20 ron minnich
2009-10-28  0:52 ` Devon H. O'Dell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9ab217670911091908u25e0a23bk838bd67c460492ac@mail.gmail.com \
    --to=devon.odell@gmail.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).