Reverse engineer c++ to UML

Started by
13 comments, last by Shannon Barber 16 years, 8 months ago
Hello, what tool do you guys use for reverse engineering? I have not yet been able to find a tool that properly reverse engineer C++ code to UML. The best I found was StarUML but it still has many problems and is unusable with most projects. What are your thoughts on this matter? Thank you!
Advertisement
Tried UML tools from Visio for Enterprise Architects VSS-plugin to IBM Rational Rose in the past. The C++ reverse-engineering results for a large project were very suboptimal.

In my opinion one is better off modelling important parts of your project with the required granularity manually.

C++ isnt easy to parse, i guess thats why most free UML tools only support C# or Java for reverse-engineering.
Quote:Original post by Fred@ss
I have not yet been able to find a tool that properly reverse engineer C++ code to UML.


Define "properly".
If you want some diagrams you are interested in, just draw them from scratch; they will be better than anything reverse-engineered, and often drawing them will be faster and less tedious that cleaning up a generated diagram.

If you want roundtrip extraction and regeneration of general C++, even if you had a tool that with absurdly large, complex and extension-laden diagrams was capable of this extraordinary feat without bugs and limitations, not using it and just editing C++ code would be far more efficient.

Plausible and useful UML/MDA technology stops at generating decent code from a specific subset of all possible UML models, with some way to customize generated code and possibly reverse engineering of small changes to generated code.

Omae Wa Mou Shindeiru

Well, I usually use (or would use!) reverse engineering for studying others project. For exemple, I was having a look at Geometric tools's Wild Magic, inside which most class are declared as follows: class WM4_CLASS TheClass{...}. The tools I tried all fail with this syntax, they think the class name is WM4_CLASS and most of the parsing is screwed... Unfortunately most of the stuff I want to reverse engineer tend to use this type of syntax.

I do not want to reverse engineer complete projects. I only take the header files relevant to the part I am curious about.

Thanks!

Fred
Attempting to learn from source code is usually a seriously bad idea. Source code is a very, very, very poor source of educational material (this is not based upon subjective "learning style" wishwash, this is based on the objective fact that source code rarely if ever provides the problem-solving context within which the code was written, why design choices were made, and what their implications were -- there is just not enough information, and it is far too easy to "learn" completely incorrect things from code, even if that code is 100% correct. Which it never is).

This is especially poor for things like Wild Magic, which have had entire books written about them by the author and are quite well documented there.
My question was about reverse engineering tools. Not about the pertinence of my learning methods.

But, for the sake of arguing ;), in my opinion, when you have experience in one topic, you can generate many new design ideas by looking at the architecture of existing systems. No solution is perfect and while thinking about a new architecture, looking at the existing ones is very benific. It often helps you see constraints and limitations you were not aware of. And I believe that UML is a great way of doing so.

And, for the record, I own and read both of David Eberly's book on wild magic. Still if find it much more convinient to look at a UML diagram than to go through 100 pages of text.

Fred
You missed the point, I think. This isn't a subjective matter. Source code is source code, it lacks everything but the vaguest shred of contextual information as to why systems are built the way they are built, or have the constraints they have, or the limitations they have. There might be no reason at all. Without that context, all you are "learning" from the system is what you already know, you're just reflecting your own thoughts through a mirror of somebody else's construction. You're jumping to conclusions; none of those are good things, none of them are things you'd want to base your own designs on. Source code is narrow-band.

You might "learn" something you were already subconsciously leaning towards, but this imparts no real understanding of the why.


EDIT:
Oh, and I meant to say this before, but "reverse engineering tools" are not exactly what you seem to be looking for. It sounds like you're looking for a tool to parse a C++ header file and its included dependancies and convert that to a UML diagram; "reverse engineering tools" generally describe tools that convert from, say, compiled code back to source code (Reflector for C#, disassemblers for native code, et cetera). Something "UML generation tool" might be something you're after.
What I am looking for is exactly what you said, a tool that parses c++ headers and gives you the uml diagram. In all the softwares I tried this function was called Reverse Engineer from C++, so I used that term.

To each his own, but I do understand a lot of things looking a the architecture of existing system, not only things my subconscious already knew ;) You get to see how other people splited and linked their different subsystem, which makes you rethink yours. It also raises a lot of questions, which in the end leads to further understanding of the system, concepts and limitations at hand. Not looking at what has already been done before doing something similar goes against all my engineering principles. You will ultimately run and the same problems that everybody has.

Quote:Source code is source code, it lacks everything but the vaguest shred of contextual information as to why systems are built the way they are built, or have the constraints they have, or the limitations they have.


UML already gives a much better view of the links between the modules in a system and source code sometime contains very useful comments about the whys of the design.

Out of curiosity, what do you do the learn from what already exists?
Quote:Original post by jpetrie
Oh, and I meant to say this before, but "reverse engineering tools" are not exactly what you seem to be looking for. It sounds like you're looking for a tool to parse a C++ header file and its included dependancies and convert that to a UML diagram; "reverse engineering tools" generally describe tools that convert from, say, compiled code back to source code (Reflector for C#, disassemblers for native code, et cetera). Something "UML generation tool" might be something you're after.


Actually, "reverse engineering" is the universally accepted term for this particular feature of general UML modeling tools; such tools are fundamentally document-centric, with models comprising related UML diagrams as their documents, and generating models from code or code from models are two optional features (if a tool does both, it is said to have "roundtrip engineering").

The style of UML modeling we are talking about is considering models as a kind of source code of usual source code, with future magical tools (or, more realistically, flunkies) able to deterministically produce Java, C++, etc. from models; from this flawed point of view generating models from code is "reverse engineering" exactly like disassembling object code to Java or C#.

Omae Wa Mou Shindeiru

Quote:Original post by Fred@ss
Well, I usually use (or would use!) reverse engineering for studying others project. For exemple, I was having a look at Geometric tools's Wild Magic, inside which most class are declared as follows: class WM4_CLASS TheClass{...}. The tools I tried all fail with this syntax, they think the class name is WM4_CLASS and most of the parsing is screwed... Unfortunately most of the stuff I want to reverse engineer tend to use this type of syntax.

I do not want to reverse engineer complete projects. I only take the header files relevant to the part I am curious about.


I don't share the categorical dislike of jbourrie for what you are doing (some code can be worth studying for some purposes, e.g. a reference implementation of a vaguely specified protocol), but:

1) Reverse engineering of C++ to UML is an hopeless enterprise. As you found out, tools are not good enough (you found only one of the most formidable obstacles, namely macros), and tripping them by using random portions of source code instead of complete compilation units doesn't help.

2) No matter how much you insist, the usefulness of reading messy, complex and mutilated reverse-engineered UML diagrams is questionable. Typical analysis relies on simply reading code, following cross references and searching for something's usages, debugging the program to watch its operation in stop motion, verifying theories with tests, etc.

Omae Wa Mou Shindeiru

This topic is closed to new replies.

Advertisement