[LLVMdev] how to dump DSA graph in gdb?

Tianwei tianwei.sheng at gmail.com
Wed Apr 23 09:16:06 PDT 2008


On Wed, Apr 23, 2008 at 11:59 PM, John Criswell <criswell at cs.uiuc.edu>
wrote:

> Dear Tianwei,
>
> You can use the -analyze option to the opt tool to tell the DSA passes
> to store their results in files.  When you use the -analyze option, the
> DSA passes will create a separate file for each function (and possible
> one file to hold the globals graph).  For this reason, I recommend
> running opt in a special empty directory because DSA will generate *a
> lot* of files.
>
> Second, to look at these files, you run them through the dot command
> from the GraphViz package to convert them into a graphic format.  For
> example, I use:
>
> dot -Tpng file.dot > file.png
>
> ... to convert the file into a PNG graphic which I can then examine
> using my graphics program of choice.
>

John, thanks so much, but i tried the -analyze option, It didn't produce any
.dot file in my working directory:
opt -analyze -load=/home/stw/llvm/install/lib/libLLVMDataStructure.so
list.bc -o list-opt.bc

also the -analyze option in "-help" result shows that:
  -analyze                                - Only perform analysis, no
optimization

did I misunderstand what your said, or my building problem?

>
> Also, you're aware that the -datastructure pass is just the local
> analysis pass, correct?  The inter-procedural part is in the Bottom Up,
> Complete Bottom Up, and Top Down passes.
>
Ok, I read Chris's thesis, and only knew the basic framework, so i want to
debug the code to
learn that in more depth.

>
> -- John T.
>
> Tianwei wrote:
> > Hi, all:
> >    Recently I am debugging the DSA and want to learn how it work, and
> now I am checking the local datastructure analysis.
> > I use the following command to print the graph:
> > (gdb) p g.dump()
> > digraph DataStructures {
> >     label="Function addG";
> >
> >     Node0xe1f3a0 [shape=record,shape=Mrecord,label="{ i32:
> MRE\n|{<g0>}}"];
> >     Node0xe1f4d0 [shape=record,shape=Mrecord,label="{ i32*:
> SMR\n|{<g0>|<g1>}}"];
> >     Node0xe1f4d0:g0 -> Node0xe1f3a0;
> >     Node0xe20900 [shape=record,shape=Mrecord,label="{ i32: GR\n
> @global\n|{<g0>}}"];
> >     Node0xe16530[  label =" %x_addr"];
> >     Node0xe16530 -> Node0xe1f4d0[arrowtail=tee,color=gray63];
> >     Node0xe162f0[  label =" %x"];
> >     Node0xe162f0 -> Node0xe1f3a0[arrowtail=tee,color=gray63];
> >     Node0xe16950[  label =" %tmp4"];
> >     Node0xe16950 -> Node0xe1f3a0[arrowtail=tee,color=gray63];
> >     Node0xe16730[  label =" %tmp"];
> >     Node0xe16730 -> Node0xe1f3a0[arrowtail=tee,color=gray63];
> > }
> >
> > then I had to copy these lines out into a .dot file and use dot to
> convert it into a ps file.
> > I note that it also provide a lot print and dump functions in
> Printer.cpp, such as
> > void DSGraph::writeGraphToFile(std::ostream &O,
> >                                const std::string &GraphName) const {
> >
> > but i don't know how to use it, also there are other functions:
> > // print - Print out the analysis results...
> > void LocalDataStructures::print(std::ostream &O, const Module *M) const
> {
> >   if (DontPrintAnything) return;
> >   printCollection(*this, O, M, "ds.");
> > }
> > ..........
> > how these functions can be used in gdb? furthermore, are there any
> options which i can type in command line for DSA?, such as:
> > opt -load=xxxxxx  -print_the_local_analysis_result  list.bc -o
> list-opt.bc
> >
> > also any suggestions for how to debug DSA efficiently?
> >
> > Thanks.
> >
> > Tianwei
> >
> >
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>



-- 
Sheng, Tianwei
Inst. of High Performance Computing
Dept. of Computer Sci. & Tech.
Tsinghua Univ.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080424/4763bc67/attachment.html>


More information about the llvm-dev mailing list