Hello all, I have been taking basic steps with DTrace and subscribed today to this list. I have written a simple DTrace script to trace all the function entry/exit from a given function: #pragma D option flowindent pid$1::*mysql_select*:entry { self -> start = vtimestamp ; } pid$1::*mysql_select*:return /self -> start/ { self -> start =0 ; } pid$1:::entry, pid$1:::return /self->start/ { trace (vtimestamp - self->start); } sample output: 0 -> __1cMmysql_select6FpnDTHD_pppnEItem_pnKTABLE_LIST_IrnEList4n0B___p2IpnIst_or der_9D39DXpnNselect_result_pnSst_select_lex_unit_pn 0 0 -> _db_enter_ 340930 0 -> code_state 415816 0 -> my_thread_var_dbug 516399 0 -> pthread_getspecific 597094 0 <- pthread_getspecific 669144 0 <- my_thread_var_dbug . . <please ignore the 3rd column; I need to correct it> Basically, I would like to have a graphical display showing me the call flow between the various functions- starting and ending at the starting function. I have thought about it a bit. I have written a regex to identify the various columns. After some intermediate data storage using a stack, I shall use the information to prepare a ''dot'' file which I plan to feed to ''dotty'' (Graphviz) to give me the call graph. Is this a good approach? Has anybody tried something similar? This blog post http://blogs.sun.com/realneel/entry/visualizing_callstacks_via_dtrace_and by Neelkanth comes closest, but the motives are dissimilar. Initially I tried to tweak it for my purpose. I thought, a ''regex'' based approach would be generic. (I am not sure). I would appreciate any feedback and comments. Thanks, Amit -- Amit Kumar Saha http://amitksaha.blogspot.com http://amitsaha.in.googlepages.com/ Skype: amitkumarsaha
Hi Amit,> Basically, I would like to have a graphical display showing me the > call flow between the various functions- starting and ending at the > starting function. I have thought about it a bit. I have written a > regex to identify the various columns. After some intermediate data > storage using a stack, I shall use the information to prepare a ''dot'' > file which I plan to feed to ''dotty'' (Graphviz) to give me the call > graph. > > Is this a good approach? Has anybody tried something similar?A good while ago now I did exactly this with pretty good results. I put a brief blog together on what was done: http://blogs.sun.com/jonh/entry/dtrace_and_visualisation Simon Ritter improved on this first pass attempt and developed a more interactive experience for generating call graphs: http://blogs.sun.com/simonri/entry/i_m_sorry_dave_i The software that Simon developed (called ''DAVE'') is actually pretty nice. The last time I saw it you could graph Java and native methods together and even do some database related graphing. Over this summer though Simon and I have taken this idea one step further. We''re now using the Java Monkey Engine (a 3D games engine) to visualise the graphs (we''re still obviously using DTrace as the instrumentation technology and the graphviz libraries for the core graph generation). Using the Monkey Engine we can generate interactive 3D call graphs which we can move through and manipulate in 3D object space. In fact, rather gratuitously really, we''ve implemented an anaglyph technique so you can even wear 3D glasses (red/cyan) so the graph comes out the screen at you! All good fun. Jon.
Hello Jon, On Mon, Nov 24, 2008 at 3:21 PM, Jon Haslam <Jonathan.Haslam at sun.com> wrote:> Hi Amit, > >> Basically, I would like to have a graphical display showing me the >> call flow between the various functions- starting and ending at the >> starting function. I have thought about it a bit. I have written a >> regex to identify the various columns. After some intermediate data >> storage using a stack, I shall use the information to prepare a ''dot'' >> file which I plan to feed to ''dotty'' (Graphviz) to give me the call >> graph. >> >> Is this a good approach? Has anybody tried something similar?Thanks for your reply. My comments inline:> > A good while ago now I did exactly this with pretty good results. I put > a brief blog together on what was done: > > http://blogs.sun.com/jonh/entry/dtrace_and_visualisationThis is what exactly what I have in mind. Did you do it the way I am thinking? The ''jzgraph'' project is well but dead. So, probably I shall have to generate a ''dot'' file and then externally feed it to ''dotty''.> > Simon Ritter improved on this first pass attempt and developed a more > interactive experience for generating call graphs: > > http://blogs.sun.com/simonri/entry/i_m_sorry_dave_i > > The software that Simon developed (called ''DAVE'') is actually pretty > nice. The last time I saw it you could graph Java and native methods > together and even do some database related graphing. > > Over this summer though Simon and I have taken this idea one step further. > We''re now using the Java Monkey Engine (a 3D games engine) to visualise > the graphs (we''re still obviously using DTrace as the instrumentation > technology and the graphviz libraries for the core graph generation). > Using the Monkey Engine we can generate interactive 3D call graphs > which we can move through and manipulate in 3D object space. In fact, > rather gratuitously really, we''ve implemented an anaglyph technique so you > can even wear 3D glasses (red/cyan) so the graph comes out the screen at > you! All good fun.Ah awesome fun. Any blog posts/etc? Thanks, Amit -- Amit Kumar Saha http://amitksaha.blogspot.com http://amitsaha.in.googlepages.com/ Skype: amitkumarsaha
> This is what exactly what I have in mind. Did you do it the way I am > thinking? The ''jzgraph'' project is well but dead. So, probably I shall > have to generate a ''dot'' file and then externally feed it to ''dotty''.Firstly, the approach you''re taking is OK but you''ll probably run into some issues with tail calls and recursion. I''ll try and dig up the stuff I originally used and send it to you. You''re right in that the jzgraph project is dead (or at least appears to be). However, if you want/need an API into the dot routing algorithms then it''s still a good piece of software to use. Generating dot files and feeding to dotty will be fine if you just want static images.>> Simon Ritter improved on this first pass attempt and developed a more >> interactive experience for generating call graphs: >> >> http://blogs.sun.com/simonri/entry/i_m_sorry_dave_i >> >> The software that Simon developed (called ''DAVE'') is actually pretty >> nice. The last time I saw it you could graph Java and native methods >> together and even do some database related graphing. >> >> Over this summer though Simon and I have taken this idea one step further. >> We''re now using the Java Monkey Engine (a 3D games engine) to visualise >> the graphs (we''re still obviously using DTrace as the instrumentation >> technology and the graphviz libraries for the core graph generation). >> Using the Monkey Engine we can generate interactive 3D call graphs >> which we can move through and manipulate in 3D object space. In fact, >> rather gratuitously really, we''ve implemented an anaglyph technique so you >> can even wear 3D glasses (red/cyan) so the graph comes out the screen at >> you! All good fun. > > Ah awesome fun. Any blog posts/etc?As usual from me, I haven''t got around to blogging about it yet. I''ll try and get a blog done about it soon and hopefully a video so you can dig your 3D glasses out! Jon.
Hi again! On Mon, Nov 24, 2008 at 5:03 PM, Jon Haslam <Jonathan.Haslam at sun.com> wrote:> >> This is what exactly what I have in mind. Did you do it the way I am >> thinking? The ''jzgraph'' project is well but dead. So, probably I shall >> have to generate a ''dot'' file and then externally feed it to ''dotty''. > > Firstly, the approach you''re taking is OK but you''ll probably > run into some issues with tail calls and recursion. I''ll try and dig > up the stuff I originally used and send it to you. > > You''re right in that the jzgraph project is dead (or at least appears > to be). However, if you want/need an API into the dot routing > algorithms then it''s still a good piece of software to use. Generating > dot files and feeding to dotty will be fine if you just want static > images.Yes. As of now, I need static images. So, i will take a look at ''jzgraph''. I will be waiting for the scripts from you :-)> >>> Simon Ritter improved on this first pass attempt and developed a more >>> interactive experience for generating call graphs: >>> >>> http://blogs.sun.com/simonri/entry/i_m_sorry_dave_i >>> >>> The software that Simon developed (called ''DAVE'') is actually pretty >>> nice. The last time I saw it you could graph Java and native methods >>> together and even do some database related graphing. >>> >>> Over this summer though Simon and I have taken this idea one step >>> further. >>> We''re now using the Java Monkey Engine (a 3D games engine) to visualise >>> the graphs (we''re still obviously using DTrace as the instrumentation >>> technology and the graphviz libraries for the core graph generation). >>> Using the Monkey Engine we can generate interactive 3D call graphs >>> which we can move through and manipulate in 3D object space. In fact, >>> rather gratuitously really, we''ve implemented an anaglyph technique so >>> you >>> can even wear 3D glasses (red/cyan) so the graph comes out the screen at >>> you! All good fun. >> >> Ah awesome fun. Any blog posts/etc? > > As usual from me, I haven''t got around to blogging about it yet. I''ll > try and get a blog done about it soon and hopefully a video so you can > dig your 3D glasses out!Cool :-) -Amit -- Amit Kumar Saha http://amitksaha.blogspot.com http://amitsaha.in.googlepages.com/ Skype: amitkumarsaha