Tools & Techniques for Analyzing Legacy Applications

Webinar May 2016
In this webinar, we'll show you how to:
  • Reverse engineer a legacy application's source code
  • Profile the running application for a quick overview and report
  • Visualize run-time behavior to improve understanding and automate documentation

Do you have legacy applications that you need to document and maintain?
Have you inherited a large code base that you simply need to understand?

Ben Constable
Ben Constable

Explore the Example Application Model

We have provided the example Enterprise Architect model and the City Loop sample application code used in the webinar.
Example Model: city-loop-legacy-application-model.eap Download the Enterprise Architect Model of the City Loop Example Application
Application Code: city-loop-cpp-application-code.zip Download the Enterprise Architect Database Engineering Example Model

Questions from the Audience

Click on a question to see the answer.

General

What version of Enterprise Architect will give me what you demonstrated?

I used Enterprise Architect 12.1, Build 1229, though much earlier versions support reverse engineering of code. The Profiler was introduced in version 8, and support for debugging and recording windows native applications was introduced with Enterprise Architect 7.

Significant enhancements have been to these tools have been made in more recent versions of Enterprise Architect.

What edition of Enterprise Architect will do this?

Professional and higher editions enable all the relevant the tools. (I used Ultimate edition for this presentation). You can compare available features against each Enterprise Architect edition on our Compare Editions web page.

Do you know if this functionality will work when running Enterprise Architect on Linux with WINE?

Yes. Our own engineers use the Visual Execution Analyzer routinely on Linux when developing Enterprise Architect itself.

Would you mind providing the source code for that train program?

We have provided the source code in the resources section of this page. You can also find the source code under your Enterprise Architect installation folder. Look for the sub-folder \Code Samples\VEA.

Is there a limit to the size of the project?

There is no limit set by Enterprise Architect itself. The practical limits will depend on the specs of your machine. If you are using a dedicated RDBMS to host your model, your database server and the network speed between your machine and the server may also impose constraints on the maximum possible size of your project.

That said, at Sparx, we routinely work on a shared model with over 100,000 elements and relationships that are contained in thousands of different packages and diagrams. In the context of code engineering, we've found Enterprise Architect performs well, even with extremely large code bases.

Does Sparx Systems have video-based training available?

While we provide short webinars and video demonstration that show you how to apply various tools in Enterprise Architect, we do not consider this formal product training. Professional training is provided by our Service Partners. To find an authorized Sparx Systems Training partner near you, please see our Trainers web page.

Does Enterprise Architect support for Knowledge Discovery Metamodel (KDM) from The OMG?

Not currently.

Could provide your example files for C# and Java?

While the City Loop example was written specifically as a Visual C++ MFC sample, we also provide other examples for C# and Java. These come with the Enterprise Architect installation. To access these examples:

  1. Open Enterprise Architect
  2. From the Help menu, choose Open Example Model
  3. In the Project Browser, navigate to the Execution Analysis View. Under that view, you will find packages named .Net and Java. Each of these contain reverse engineered models of sample applications.
  4. You can find the corresponding source code under your Enterprise Architect installation folder. Look for the sub-folder \Code Samples\VEA.

Reverse Engineering

Where was the import menu option for the source you imported?

I selected a package in Enterprise Architect's Project Browser. Then I right-clicked it and chose the menu Code Engineering | Import Source Directory. You can see this demonstrated in the presentation video from 2:40 minutes onwards.

What languages are supported – only object-oriented languages or are SQL and ETL supported as well?

Enterprise Architect supports 15 programming languages out of the box, some of which are not object-oriented languages. For a complete list, see the Help topic Importing Source Code.

SQL, in the form of DDL files, is not supported by Enterprise Architect's code engineering tools. Instead, you reverse engineer database schemas using Enterprise Architect's Database Builder, which connects to a live database via ODBC to extract the schema and create a corresponding UML model. For a demonstration, see our previous Database Engineering webinar.

Enterprise Architect does not currently provide integrations with ETL (Extract, Transform and Load) tools out of the box.

How does Enterprise Architect handle very large code bases?

We've used Enterprise Architect to successfully reverse engineer large-scale applications, including our own extremely large C++ code base. Enterprise Architect's advanced reverse engineering capability combined with a highly scalable database-driven model repository allows users to import very large code bases, while retaining a responsive, high-performance modeling environment.

What about distributed apps?

Reverse engineering the static structure of your code should be the same as for other application code bases. When using the VEA tools to analyze the running application, however, keep in mind that the Profiler, Recorder and Debugger can only attach to one instance of your executing code. This may limit your analysis if your distributed application involves multiple instances of your application running on different servers / processors.

Does Enterprise Architect store the source code or does it rely on the source being available on the machine? How does this work in a shared environment where the source may not be on the machine that the Enterprise Architect model is being viewed on?

Generally, Enterprise Architect does not store the source code. It retains a path to the imported code, which can refer to your local machine or a shared resource.

When your model is used in a shared environment, or in a scenario where the copies of the code base reside on different machines for different model editors, Enterprise Architect's Local Paths feature is helpful. It allows you to represent the first part of the source code path as a symbol. This may represent the drive or server name and the initial part of the folder path on that device. Each model author can resolve that symbol, Local Path ID, to a different location on their machine. And you can later change the location of the code on your machine, simply updating Local Path value so that Enterprise Architect can continue to trace from model to code.

I live in a COBOL world. Do you have any tools for that?

No, currently Enterprise Architect does not support reverse engineering of COBOL.

Is it possible to reverse engineer PL/SQL on Oracle?

Not currently.

Can multiple file types be imported, for example, .java and .jsp files?

You can import code bases from multiple languages into a single Enterprise Architect model. You do not, however, import from multiple languages at the same time. Using the Import Source Directory dialog, you can only choose one target language, or source type. That source type may have multiple associated file extensions, but they are still all for the same language.

Also note: Enterprise Architect does not currently support code engineering for JSP.

Can you import source code from IBM i RPG programs?

No.

Are there any plans to add support for Progress OpenEdge ABL language?

Currently there are no plans for implementing support for OpenEdge ABL. There exists the possibility for users to construct custom code reverse engineering grammars for Enterprise Architect to import unsupported programming languages, however this requires a considerable investment of time to complete. For details, see the Help Guide topic Grammar Framework.

I need to reverse engineer from a NoSQL (json) file. Any plan to update the Database Builder?

There are no immediate plans to support NoSQL in the Database Builder.

I used Enterprise Architect to reverse engineer C++ and C#. What new features added to C# support since 2011?

We have released numerous updates to Enterprise Architect's support for C++ and C# code import, including enhancements that accommodate new language constructs. For details on specific updates, you could search Enterprise Architect's release history: From the Help menu in Enterprise Architect, choose the Read Me option.

Note: The most recent versions of both C# and C++ introduce syntax that Enterprise Architect 12.1 doesn't support. We expect that the next major release of Enterprise Architect will bring support for both of these languages up to date.

Is there a way to suppress macros (preprocessor directives) in the imported?

Yes. For instructions, see the Help topic Language Macros.

Can you generate a sequence diagram by pointing to a method?

Not directly from the UML Class model, because it represents the application's static structure. You generate sequence diagrams using Enterprise Architect's Visual Execution Analyzer tools, such as the Profiler and Recorder. These tools generate sequence diagrams based on your application's run-time behavior.

Can you import source code into SysML blocks instead of UML?

No, this is not supported. You might, however, apply the SysML block stereotype as a post-processing step after importing your code.

Are you planning improvements related to Delphi, as the parser appears broken to me?

If you attempted to import some Delphi code and it failed, I recommend emailing our technical support (support@sparxsystems.com) with a sample of your code.

Any plans to support Objective-C or Swift?

Currently there are no plans for implementing support for Objective-C or Swift.

Are you planning to support JavaScript or TypeScript?

Currently there are no plans for implementing support for JavaScript or TypeScript.

When we use Enterprise Architect to reverse engineer C# code, we have to manually draw the link between modules or projects. Is there a feature in Enterprise Architect that will automatically show the link between modules?

Assuming the linking you require is a set of dependencies between the UML Packages that were created as part of the code import: There currently is no feature built into Enterprise Architec to do this automatically.

What about external references while importing – are they converted to classes or how are they represented inside Enterprise Architect?

It depends on the nature of the reference. In most cases the reference will be maintained as a type name, without an underlying classifier. For example, consider a class A, with member variable (UML attribute) v1, of type B, which is an external class, not defined within the imported source code. This scenario is illustrated as follows:

Attribute v1 has an external, unresolved reference to Class B. Only the type name, "B" is modeled.

Notice the UML Attribute type for A.v1 is B. The type name, B, may be resolved to another classifier after a subsequent code import that contains the definition of class B.

The reference to B from v1 can be resolved later by importing the code containing the definition of class B.

Similarly, for unresolved parent-child relationships, the base class (parent) name will be held as a string. As illustrated here, class B has an external reference to its parent class C.

Classes with unresolved external references to a parent class display the parent class name only

The base class name can be resolved later to a specific class in the model if the relevant code definition is imported. At that time the simple name string representing the base class name will be replaced by a UML Inheritance relationship drawn from the child class to the base class.

External references to parent classes can be resolved later by importing the code with the parent class definition

Does Enterprise Architect support a mix of procedural and class-based code for Visual C++ 6.0?

When you reverse engineer C++ code, only the class-based code is imported, which includes structs and typedefs. There is also support for importing C code that makes use of header files, and mapping that to a UML class model. However, you cannot import the code as a pure C target and as a C++ target at the same time.

I tried importing PHP code, and since it wasn't written in an object oriented form, it didn't import anything at all.

It is correct that Enterprise Architect only imports object-oriented PHP code, which can be mapped to a UML model.

Does Enterprise Architect support reverse engineering for applications on Android or iOS?

You can reverse engineer and debug Java applications, as described in the Help topic The Android Debugger. Reverse engineering of iOS applications is not currently supported.

By synchronizing code it's possible to accidentally delete operations and attributes in the model. Is there a way to prevent this?

Yes, you can tell Enterprise Architect not to delete attributes and methods when updating the model during code synchronization:

  1. Invoke the Options dialog from the main menu using Tools | Options.
  2. Open the Attribute/Operations options tab from Source Code Engineering | Attribute/Operations.
  3. Uncheck the following two options:
    • On reverse synch, delete model attributes not in code
    • On reverse synch, delete model methods not in code
  4. Click the Close button.

Profiling

What does Inclusive Hit% mean?

This figure is listed beside each function in the Profiler summary. It represents the percentage of samples where the Profiler found that function was being executed, including when the sample involved other functions that were invoked as part of that function's execution. (In terms of a call stack, the inclusive hits for a given function includes all functions below it as well.)

Also note: The inclusive hits figure for each function represents the combined invocations of that function (and others it invokes) across all threads spawned by the profiled process.

For more information on how hit counts relate to call stacks, see the Help topic Profiling.

Can web applications be profiled?

Yes, if the application is run from your local machine.

I didn't see a list of supported project types. Will the Profiler work for web apps or windows service/daemon type apps?

Yes, as long as the application or service is run from your local machine.

How does the Profiler work to profile a website?

The Profiler is not designed to profile websites. It can, however, profile a locally run web application.

Can you filter/exclude some classes/functions that you don't want to see in your generated diagrams? For example, some functions are too low-level.

No. Filtering such functions in the Profiler, would have the potential of actually making the report misleading, if not fallacious. Remember, the Profile’s reports and its generated diagrams, rely on statistical analysis of the samples taken from the call stack. Contrast this with the Recorder and its generated diagrams, where you can effectively 'zoom out' of the program's execution by filtering low-level functions.

Does this tool support profile information from C++/GCC?

No, the Profiler does not support programs built with GCC. The Recorder and Debugger, however, both support GCC-compiled applications. In that scenario, you would select GDB as the debugger in your analyzer script.

Does the Profiler work with C++ Builder apps?

No.

Can you connect the Profiler to a remote Java web application on Linux?

No. The Profiler does not attach to remote applications, but you can profile a web application, daemon or service on your local machine.

Also note: Unlike the Profiler, the Recorder and Debugger are both able to target either a local or remote application.

Can the data be exported to a text file for reporting outside of Enterprise Architect?

Yes. You can export the data to an XML file as described in the Help topic Generate, Save and Load Profile Reports.

Can you please take a Java code example and show how to use the Profiler?

We will consider producing a short video showing the Profiler working on a Java example. In the meantime, you can explore the Java example we provide with the Enterprise Architect installation. For instructions, see the earlier question about C# and Java code examples.

How can I profile an application that is running on an embedded target, such as BeagleBone?

Currently, there is no profiling support for embedded software. We are considering adding support to our Visual Execution Analyzer (VEA) for embedded software in future.

I am specifically interested in using Enterprise Architect to profile applications in a cross-compiled environment, where the development and analysis tools run on Linux and the application code runs on an embedded Linux system.

We do find the Profiler and other VEA tools useful in a cross-compiled scenario where, for example, a Windows application is run and profiled on Linux. (Enterprise Architect and its VEA tools work well on Linux using WINE). Unfortunately profiling an application running on an embedded system is not yet supported.

Is it possible to profile specific modules of a larger application? Do I have to import all source code or are there techniques to concentrate on certain modules?

Modules cannot be discriminated. You do not, however, have to import any source code to use the Profiler.

How about complex multi-tier application when the presentation layer uses JavaScript run in a browser?

The VEA tools cannot deal with JavaScript in browsers / apps. When we investigated this previously, we found the debugging API is browser-dependent (so different for Chrome, Opera, Firefox and Internet Explorer) and not published. The exception was Internet Explorer, though Microsoft is withdrawing support for their process debug manager 'scripting', which allowed you to intercept the script engine in any process.

Recording

Can you export the generated diagrams in formats such as HTML, DOCX, or PDF?

Yes. These formats are all supported. For more information see the Help topic Report Generation.

You might also be interested in the following webinars:

How does the code link to the state machine? (As in picking up a variable that gives the state for display)

Firstly, you define a state machine under a particular class. Enterprise Architect can then relate that state machine to a particular class in the code base.

Furthermore, each state in the state machine contains constraints with references to member variables defined in the code of that class. The constraints stipulate what values the variables must have to be in that state and to enable the transition to the next state. (In the sample model provided, you can see these constraints by opening the properties of a State element and looking under the Constraints tab. The state machine and its diagram are defined under the CTrain class.)

During recording, the Recorder will compare your modeled values for the class variables against the actual values used in the executing code, highlighting any illegal changes in state (according to the state machine). For more details see the Help topic Reporting a State Machine.

How could the generated sequence diagram (Stations) show which state each object is in?

As mentioned in the previous response, the state machine is modeled under a particular UML class in your model – effectively binding the state machine to that class in code as well. Enterprise Architect can then compare variable values in that class against the values specified in the state element's constraints. For more details see the Help topic Reporting a State Machine.

Debug Platform Support

A link to a C# demo would be appreciated.

Please see our earlier webinar on the Visual Execution Analyzer, which featured an example C# application: Using the Visual Execution Analyzer in Enterprise Architect.

I would really like to analyze embedded applications – say something built for an ARM platform using IAR, or TI's Jacinto processor running a real-time operating system (RTOS) like Nucleus or QNX. Is that possible?

Profiling and recording of embedded software is being considered for a future release. Also real-time operating systems are not currently supported by Enterprise Architect's VEA toolset.

Can I analyze Java-based code?

Yes. For more details see the Help topic Visual Execution Analysis.

Are both Delphi Frameworks, Fire Monkey and VCL, supported by Enterprise Architect?

These frameworks are not supported by the VEA tools. You can, however, reverse engineer Delphi code, which should work independently of the Delphi framework that your application uses.