Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reverse Engineering C++ code using "Enterprise Architect"

It is again a sort of "how to do it properly" question. Sorry if someone is annoyed.

I've got to understand ca 150 TLOCs of C/C++ mixture. I've imported the code in UML-Tool "Enterprise Architect" and got a messy chart. Many Structs and Enums had anonymous names because of this C-ish constructs: typedef struct/enum {...} MyType;

In second run I've converted it to C++ form: struct/enum MyType{...}; but got a bunch of unrelated structs. Unfortunately, Enterprise Architect doesn't resolve typedefs. e.g. no relations between A, B and C were recognized:

struct A;
struct B;
typedef A *PtrA;
typedef List<B> BList;
struct C{ PtrA pA; BList lB; };

Thanks to throughout naming convention, I was able to replace all typedefs by original type like this:

struct C{ A pA; B lB; };

Now importing source-code in "Enterprise Architect" gave a nice diagram with all relations. Of cause, the code doesn't compile, and is not the same. All changes in code require an annoying conversion for making this "pseudo" code understandable by EA again. Therefore my questions:

  1. Is there any possibility to teach EA recognizing the original types?
  2. Do other UML-Tools recognize the types (and create relations between them) more robust?

Thank you very much for any advice! Valentin Heinitz

like image 693
Valentin H Avatar asked Oct 13 '22 19:10

Valentin H


1 Answers

I have Enterprise Architect, and almost invariably for doing what you are attempting on a large code body I use doxygen instead. It generates both class and call graphs. Use it with GraphViz and "UML-style" class diagrams, and you have a reasonably good code navigation and comprehension tool, with flexible configuration to add or exclude detail as necessary.

like image 175
Clifford Avatar answered Oct 18 '22 03:10

Clifford