473,554 Members | 2,920 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2979
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************ *********@g43g2 000cwa.googlegr oups.com>, sv*******@bjerk em.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*******@bjerk em.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(patter n, flags)
--- modulename: sre, funcname: _compile
sre.py(218): cachekey = (type(key[0]),) + key
sre.py(219): p = _cache.get(cach ekey)
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*******@bjerk em.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.g ov)

Cheers, Pieter

Nov 5 '05 #10

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

Similar topics

1
4716
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 from the command line, it will work properly and generate my graph (which gets dumped into a file). If I invoke the script as a cgi script within...
2
2089
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 want to issue a full stack trace and then parse a string every time I wish to Trace source code info!!!!!!!! For you ex-C++ now C# coders I wanna do...
3
2157
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 from an aspx file. Even a page with <%@ Page Language = "c#" Trace="True" %> doesnt show the trace information. If i create an .asp file, the...
2
1751
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. I want to use maximum out of the available trace details . or let me put it like this.... tell me the actual scenario's where these trace details...
4
1803
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 Uri(Assembly.GetExecutingAssembly().CodeBase); string fileName = Path.GetDirectoryName(codeBase.LocalPath); fileName = Path.Combine(fileName, "pmatsiemens_trace" +...
2
7952
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 interested in more detail such as branching and looping within a function. Cheers Brad
4
2916
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. Unfortunately, I am not an SQL guru and was hoping Python could help. Any pointers are appreciated. Thanks!
0
1430
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 application code: FileStream m_Stream = new FileStream(m_logFile, FileMode.Append, FileAccess.Write); myTextListener = new...
2
17131
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 Images were missing. The Doxygen output indicated that it did generate the Call Graph, showing where the images should be in the HTML output, but,...
0
7578
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7497
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7780
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8010
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7530
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6119
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3539
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1111
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
812
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.