D trace kde4presentation
-
Upload
manish-chakravarty -
Category
Documents
-
view
838 -
download
3
Transcript of D trace kde4presentation
![Page 1: D trace kde4presentation](https://reader034.fdocuments.in/reader034/viewer/2022052504/5549becfb4c905e5048b5167/html5/thumbnails/1.jpg)
Dynamically TracingKDE
Manish ChakravartyThoughtWorks Studios
1
![Page 2: D trace kde4presentation](https://reader034.fdocuments.in/reader034/viewer/2022052504/5549becfb4c905e5048b5167/html5/thumbnails/2.jpg)
Agenda
• Learn about DTrace
• Learn what and where to Trace
• Trace!
2
![Page 3: D trace kde4presentation](https://reader034.fdocuments.in/reader034/viewer/2022052504/5549becfb4c905e5048b5167/html5/thumbnails/3.jpg)
I. What is DTrace?
While I go through the slides, please start copying the VM!
3
![Page 4: D trace kde4presentation](https://reader034.fdocuments.in/reader034/viewer/2022052504/5549becfb4c905e5048b5167/html5/thumbnails/4.jpg)
DTrace is..
• a comprehensive Dynamic Tracing framework created by Sun Microsystems for troubleshooting kernel and application problems in real time.
4
![Page 5: D trace kde4presentation](https://reader034.fdocuments.in/reader034/viewer/2022052504/5549becfb4c905e5048b5167/html5/thumbnails/5.jpg)
Excuse me?
5
![Page 6: D trace kde4presentation](https://reader034.fdocuments.in/reader034/viewer/2022052504/5549becfb4c905e5048b5167/html5/thumbnails/6.jpg)
• Dtrace enables us to “look into” the internals of a running production application and allows us to instrument it
• It can do very neat stuff in the kernel as well, but that’s not the point of this session
6
![Page 7: D trace kde4presentation](https://reader034.fdocuments.in/reader034/viewer/2022052504/5549becfb4c905e5048b5167/html5/thumbnails/7.jpg)
So how does DTrace work?
7
![Page 8: D trace kde4presentation](https://reader034.fdocuments.in/reader034/viewer/2022052504/5549becfb4c905e5048b5167/html5/thumbnails/8.jpg)
• Dtrace allows you to dynamically modify the operating system kernel and user processes to record additional data that you specify at locations of interest, called probes
8
![Page 9: D trace kde4presentation](https://reader034.fdocuments.in/reader034/viewer/2022052504/5549becfb4c905e5048b5167/html5/thumbnails/9.jpg)
• Dtrace probes come from a set of kernel modules called providers, each of which performs a particular type of instrumentation to create probes
9
![Page 10: D trace kde4presentation](https://reader034.fdocuments.in/reader034/viewer/2022052504/5549becfb4c905e5048b5167/html5/thumbnails/10.jpg)
Provider:Module:Function:Name
10
![Page 11: D trace kde4presentation](https://reader034.fdocuments.in/reader034/viewer/2022052504/5549becfb4c905e5048b5167/html5/thumbnails/11.jpg)
ProviderThe name of the DTrace provider that is publishing this
probe
11
![Page 12: D trace kde4presentation](https://reader034.fdocuments.in/reader034/viewer/2022052504/5549becfb4c905e5048b5167/html5/thumbnails/12.jpg)
ModuleIf this probe corresponds to a specific program
location, the name of the module which the probe is located
The name is either the name of a kernel module or a user library
12
![Page 13: D trace kde4presentation](https://reader034.fdocuments.in/reader034/viewer/2022052504/5549becfb4c905e5048b5167/html5/thumbnails/13.jpg)
FunctionIf this probe corresponds to a specific program
location, the name of the program function in which the probe is located
13
![Page 14: D trace kde4presentation](https://reader034.fdocuments.in/reader034/viewer/2022052504/5549becfb4c905e5048b5167/html5/thumbnails/14.jpg)
NameThe final component of the probe name is a name that gives you some idea of the probe’s semantic meaning
such as BEGIN or END
14
![Page 15: D trace kde4presentation](https://reader034.fdocuments.in/reader034/viewer/2022052504/5549becfb4c905e5048b5167/html5/thumbnails/15.jpg)
Thus:Provider:Module:Function:Name
15
![Page 16: D trace kde4presentation](https://reader034.fdocuments.in/reader034/viewer/2022052504/5549becfb4c905e5048b5167/html5/thumbnails/16.jpg)
DTrace Architecture16
![Page 17: D trace kde4presentation](https://reader034.fdocuments.in/reader034/viewer/2022052504/5549becfb4c905e5048b5167/html5/thumbnails/17.jpg)
Let’s start Tracing!
17
![Page 18: D trace kde4presentation](https://reader034.fdocuments.in/reader034/viewer/2022052504/5549becfb4c905e5048b5167/html5/thumbnails/18.jpg)
manish@belenix-KDE4:~/WorkOut/DTraceTutorial$ pfexec dtrace -n BEGIN
dtrace: description 'BEGIN' matched 1 probe
CPU ID FUNCTION:NAME
0 1 :BEGIN
^C
18
![Page 19: D trace kde4presentation](https://reader034.fdocuments.in/reader034/viewer/2022052504/5549becfb4c905e5048b5167/html5/thumbnails/19.jpg)
manish@belenix-KDE4:~/WorkOut/DTraceTutorial$ pfexec dtrace -n BEGIN -n END
dtrace: description 'BEGIN' matched 1 probe
dtrace: description 'END' matched 1 probe
CPU ID FUNCTION:NAME
0 1 :BEGIN
^C
0 2 :END 19
![Page 20: D trace kde4presentation](https://reader034.fdocuments.in/reader034/viewer/2022052504/5549becfb4c905e5048b5167/html5/thumbnails/20.jpg)
• The probe BEGIN fires every time you start a new tracing request
• The probe END fires every time you exit DTrace. In this case hitting Ctrl-C triggered it.
20
![Page 21: D trace kde4presentation](https://reader034.fdocuments.in/reader034/viewer/2022052504/5549becfb4c905e5048b5167/html5/thumbnails/21.jpg)
Hello, World!
21
![Page 22: D trace kde4presentation](https://reader034.fdocuments.in/reader034/viewer/2022052504/5549becfb4c905e5048b5167/html5/thumbnails/22.jpg)
BEGIN
{
trace("hello, world");
exit(0);
}
22
![Page 23: D trace kde4presentation](https://reader034.fdocuments.in/reader034/viewer/2022052504/5549becfb4c905e5048b5167/html5/thumbnails/23.jpg)
manish@belenix-KDE4:~/WorkOut/DTraceTutorial/1-HelloWorld$ pfexec dtrace -s hello.d
dtrace: script 'hello.d' matched 1 probe
CPU ID FUNCTION:NAME
0 1 :BEGIN hello, world
Output..
23
![Page 24: D trace kde4presentation](https://reader034.fdocuments.in/reader034/viewer/2022052504/5549becfb4c905e5048b5167/html5/thumbnails/24.jpg)
61,809DTrace probes on the system!
pfexec dtrace -l | wc -l
24
![Page 25: D trace kde4presentation](https://reader034.fdocuments.in/reader034/viewer/2022052504/5549becfb4c905e5048b5167/html5/thumbnails/25.jpg)
DTrace ArchitectureSource: http://wikis.sun.com/download/attachments/10390716/architecture.gif
25
![Page 26: D trace kde4presentation](https://reader034.fdocuments.in/reader034/viewer/2022052504/5549becfb4c905e5048b5167/html5/thumbnails/26.jpg)
II. What / Where / How
26
![Page 27: D trace kde4presentation](https://reader034.fdocuments.in/reader034/viewer/2022052504/5549becfb4c905e5048b5167/html5/thumbnails/27.jpg)
• Navigate to the directory having the Qt source code
• Find out a good place in QObject to put one
• Start writing probes!
27
![Page 28: D trace kde4presentation](https://reader034.fdocuments.in/reader034/viewer/2022052504/5549becfb4c905e5048b5167/html5/thumbnails/28.jpg)
Hack!
28