[Introspector-developers] GCC/UML/XMI extraction (was gcc front end )
Status: Beta
Brought to you by:
mdupont
|
From: James M. D. <mdu...@ya...> - 2002-05-10 14:23:07
|
Praveen, Since no-one has answered your mail yet, I will attempt to. Note that this is just my personal opinion on this matter and in no way does it speak for rest of the gcc community. This being my favorite topic, I will explain the background on this topic and use my answer to present some of ideas on this topic to you and to the gcc mailing list. >>I'm currently trying to make a tool that'll generate >>UML specs from c++ code. I understand your motivation for this request and I have been thinking about similar things myself. I too have been sold on the idea of UML and having nice diagrams of my code. "How come we cannot extract this data from the GCC?" was my the motivating question over 8 years ago. You would like to extract the class structures of a given program into UML, maybe into a XMI like data format? see : http://xml.coverpages.org/xmi.html Like many of the UML tools listed here?: http://directory.google.com/Top/Computers/Programming/Methodologies/Object-Oriented/UML/Tools/?tc=1 That type of extraction or at least the visualization is one of the one of the goals of the introspector project that I started. The problem is that my project is that XML/SQL or *any* intermediate representation of gcc tree structures is a file is not secure enough to prevent abuse of the gcc. Therefore I have started a re-design to cover many new aspects. http://introspector.sourceforge.net. Currently, I am busy re-designing the project to eliminating all xml and sql external data to remove the possibility of third-party abuse of the data and circumvention of the GPL. In my humble opinion, In the long term, an UML like GUI and class browser will be possible to be linked directly into the gcc and the various aspects of programs can be visualized. You should understand that the pure extraction of such information by the gcc to feed to case tools like rational rose and together++ via XMI might not be in the best interests of the GCC/GNU/FSF community. The extraction of compiler data about data structures and feeding them to non-free software like GraphVis/Rational Rose/ TogetherC++ and others does not benefit the free software, but more takes the wind out of the sails of an effort to create free replacements for such tools. One of the difficulties that we are presented with creating case tools with the GCC has is the issue of the usage of the "internal data str." the tree structures. >>I am searching for a library version of GNU's C++ >>front end , and documentation on its interface >>(through which I can query its internal data str.) That library is the core gcc compiler, the tree structures that are connected with the c/c++ language front ends. Now in order for you to create such a tool you will have to create a modified version of the gcc, one that produces the UML, maybe in XMI format. This type of interface would also allow for all types of information to be extracted from the gcc. One of the issues involved here is the licensing of such a tool, it would have to be a GPL licensed tool. The other issue is that of the extracted data, are you interested in extracting just static data structures, or also dynamic UML structures, so that you would also like to see the run-time behavior of the program at hand? Then you will need to extract also the function bodies, and from that UML representation, you could create a brand-new re-factored program. That is of course a very tempting idea and the basis of many of the tools like together++ and rational rose. There is also a tool the provides such a function for java written in java called argo-uml, that includes a Java parser. There is also a tool called DIA that has support for UML diagrams. In the end both tools could be used for a display mechanism, argo-uml is much further along than Dia, but DIA is written in C/C++ and would be easier to use as an add on to the gcc. The other question of graph layout can be tackled by a tool called VCG. That has some good graph layout algorithms, but is GUI is way out of date. Those two tools (DIA and VCG), coupled together with the gcc, statically linked into one program, could serve as the basis for a C++/UML based code browser using the gcc. If you are only interested in only the static structure of c++ functions and classes you might be able to use the xml output from the gcc_xml. http://www.gccxml.org >>Could you please guide me to the correct library and >>where I could download it ? The gcc parsers and code generators are not distributed as libraries for linking into. If you want to create a gcc module, you should create a statically linked program that uses the data needed. >>I explored the links on the gcc pages but could not >>locate these. It is one of the lesser documented and published areas of the gcc. The new chapter 18 of the gcc manual contains a good overview of tree structure. http://gcc.gnu.org/onlinedocs/gccint/Tree-overview.html I would suggest that you define exactly your statement of the how you would like to represent and display the UML. Also you should be willing to put all of your changes and programs under the GPL and not try and export data to non-gpled programs. Doing that will give you the best basis for such an endeavor. It will be a difficult endeavor and a rocky, uphill battle, but I think it will be worth it. Mike ===== James Michael DuPont __________________________________________________ Do You Yahoo!? Yahoo! Shopping - Mother's Day is May 12th! http://shopping.yahoo.com |