473,396 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Using graphviz to visualize trace.py output, anybody?

Hi,

has anybody thought of / already used graphviz to convert the output of
trace.py into a graph? I looked at PyUMLGraph, but 1. PyUMLGraph does
not successfully create a dot file, and 2. I don't really want a UML
representation but a compact representation of program execution.

Maybe there is some other tool that I am not aware of which can create
this kind of trace. I use eclipse with pydev plugin on MacOS 10.3.9

Regards,
Svenn

Oct 30 '05 #1
9 2962
Hi!

Under Windows, I call graphwiz from Python via COM, with win32all (PyWin).
Sorry, I don't know the Mac.

@-salutations

Michel Claveau

Oct 30 '05 #2
I was more thinking of converting the output of trace.py to the dot
language in order to get a graphical view of the execution of my
program.

Oct 31 '05 #3
In article <11*********************@g43g2000cwa.googlegroups. com>, sv*******@bjerkem.de wrote:
Hi,

has anybody thought of / already used graphviz to convert the output of
trace.py into a graph? I looked at PyUMLGraph, but 1. PyUMLGraph does
not successfully create a dot file, and 2. I don't really want a UML
representation but a compact representation of program execution.

Maybe there is some other tool that I am not aware of which can create
this kind of trace. I use eclipse with pydev plugin on MacOS 10.3.9

Regards,
Svenn


Take a look at:
http://dkbza.org/pydot.html

It's a python interface which can produce dot format files (based on its internal
graph API) and run graphviz for you.

I'm not sure which trace.py you're referring to, but I assume it dumps some output file.
You have a couple of obvious ways to get what you want:

1) modify trace.py to create a pydot graph structure then write to file
2) make a script that parses the trace.py output to create a pydot graph structure then write to file

Dave
Oct 31 '05 #4
I am referring to the trace.py which comes with python2.3 which is
installed on Panther by default. (I found it with 'locate trace.py'
after reading about its existence here)

I was thinking in the direction of your suggestion 2) but before I
reinvent the wheel, I would like to know if someone has already
invented it. As it doesn't seem like anybody has, I will have to go do
it myself. If somebody happen to finish before me I would be happy to
get a notice.

--
Svenn

Oct 31 '05 #5
sv*******@bjerkem.de wrote:
Hi,

has anybody thought of / already used graphviz to convert the output of
trace.py into a graph?


Thanks for the pointer to trace.py. I hadn't seen that before.

Are you thinking about a call-graph or sequence diagram, based on
the output from trace.py --trace? I suspect it might be easiest to
do that by modifying trace.py, so that it gives clearer hints about
when it performs a call, and when it returns from a call. (Could
it do that? Does trace.py have a clue about that?)

E.g. from running trace.py --trace trace.py in Python 2.3 I get:

....
--- modulename: trace, funcname: ?
....
trace.py(104): PRAGMA_NOCOVER = "#pragma NO COVER"
trace.py(107): rx_blank = re.compile(r'^\s*(#.*)?$')
--- modulename: sre, funcname: compile
sre.py(179): return _compile(pattern, flags)
--- modulename: sre, funcname: _compile
sre.py(218): cachekey = (type(key[0]),) + key
sre.py(219): p = _cache.get(cachekey)
sre.py(220): if p is not None:
sre.py(221): return p
trace.py(109): class Ignore:
--- modulename: trace, funcname: Ignore
trace.py(109): class Ignore:
....

That should cause something like:

trace.GLOBAL
|->sre.compile
| |->sre._compile
|->trace.Ignore

Finding the relevant nodes in the graph seems trivial. It's
the ' --- modulename:...' rows. Figuring out the origin of
the edges to these nodes seems error-prone. How do you know
that the above isn't really...

trace.GLOBAL
|->sre.compile
|->sre._compile
|->trace.Ignore

....for instance? Looking at the output, we can see that it's
not, and we know that sre won't call trace in _compile, but I'm
not sure how to write a parser that would detect all such cases.
I imagine that loops, callbacks etc might turn out to be tricky.

Both calls and returns can look very different in Python, the
program flow can move back and forth a lot, both modules and
callables might have a different name than the one that appears
in the source code where it's called (e.g. re => sre above) etc.

I wrote somthing like this to analyze COBOL source code about a
year ago, and that was trivial, but Python is so dynamic and
varied compared to COBOL where I only had to look for "CALL
something" if my memory serves me right.

Perhaps you should make a simple parser that does the very easy
part, essentially something like:

? -> sre.compile;
? -> sre._compile;
? -> trace.Ignore;

Then you can massage the resulting dot-files manually until they
give you the output you want. You should really do this with non-
trivial code of the kind you would like to analyze, and make sure
that you are able to create meaningful graphs.

For instance, you probably want to show something other than just
the output of...

trace.__main__ -> sre.compile;
sre.compile -> sre._compile;
trace.__main__ -> trace.Ignore;

....since this wouldn't give you any meaningful image of the sequence.
Or perhaps you just want collaboration diagrams?

Actually, even if you end up doing manual work with every dot-file,
it might turn out to be less work that other ways of doing graphs,
at least if you can get typical edges right in your program and just
fix occational ambiguities. I'm not so sure that it's so easy to
get any pretty graphs at all from this approach though. I guess it
requires some experimentation.

Nov 1 '05 #6
> Maybe there is some other tool that I am not aware of which can create
this kind of trace. I use eclipse with pydev plugin on MacOS 10.3.9


kcachegrind

http://kcachegrind.sourceforge.net/cgi-bin/show.cgi

--
Toby Dickenson
Nov 1 '05 #7
I was originally thinking of piping the output of trace.py into a text
file and then have python massage that text file into a dot file for
graphviz to visualize.

Some formatting is possible with graphviz, but I would expect the graph
to be very dependent on how the program under test runs so I have
little idea what to expect.

I think a counter would be needed to show the progress of the execution
of the program as some parts of code are visited at intervalls.

--
Svenn

Nov 1 '05 #8
This looks like something, but I have to introspect myself to accept
fink on my mac. Thanks for the pointer.
--
Svenn

Nov 1 '05 #9

sv*******@bjerkem.de wrote:
I was originally thinking of piping the output of trace.py into a text
file and then have python massage that text file into a dot file for
graphviz to visualize.

Some formatting is possible with graphviz, but I would expect the graph
to be very dependent on how the program under test runs so I have
little idea what to expect.


To mangle graphs and their drawing via graphviz on multilple platforms,
you might also want to try networkx combined with pygraphviz
(available from networkx.lanl.gov)

Cheers, Pieter

Nov 5 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sergio | last post by:
I'm writing a cgi script that uses graphviz (the dot program) to generate a graph and I'm banging my head against the wall trying to get it to work properly. Currently, if I run the script directly...
2
by: Richard | last post by:
Hi, I would like to output the source code module name and line number in some of my Trace.Writeline() calls. The information that I need is in the Environment.StackTrace string however I DO NOT...
3
by: Bruno Paquette | last post by:
I have installed visual studio .net and now i started to write the first few examples from the 70-315 book by Kalani. It looks like all server side code that i put between <% %> doesnt process...
2
by: deepukutty | last post by:
Hi all, I know tht we can do tracing in two ways.one in application level and the other is at Page level. I am able to see the details of trace either on the page itself or .../trace.axd page....
4
by: Christoph Wienands | last post by:
Hey guys, I just got some really weird behavior. I put the following code into the Application_Start event in Global.asax: // init some trace listeners Uri codeBase = new...
2
by: bradphelan | last post by:
Hi all, Does anybody know of open source reverse engineering tools that can flowchart C/C++ code? I've checked Red Hat source-navigator but the resolution is only at the call tree level and I am...
4
by: kyosohma | last post by:
Hi All, Can Python parse a trace file created with MS SQL's profiler? There are a few thousand lines in the trace file and I need to find the insert statements and the stored procedures....
0
by: =?Utf-8?B?YWtz?= | last post by:
I've configured Trace switch in my app.config file: DebugLevel = new TraceSwitch("DebugLevel", "Trace Level for Entire Application"); and have created and initialized a trace listener in my...
2
by: Peter Olcott | last post by:
http://www-scf.usc.edu/~peterchd/doxygen/ The above is an example of what the output should look like. I ran Doxygen on a simple program that I wrote to test Doxygen, and all of the Call Graph...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.