CasePlayer2 Tutorial

CasePlayer2 Tutorial
Ver. 1.1
Jan. 2014- 1 -CasePlayer2 Tutorial

Table of Contents
Table of Contents ................................................................................................................................... 1
CasePlayer2 Tutorial .............................................................................................................................. 3
Introduction ......................................................................................................................................... 3
CasePlayer2 Overview .................................................................................................................... 3
System Requirements ..................................................................................................................... 3
1. Start CasePlayer2 ........................................................................................................................... 4
2. Create a New Project ...................................................................................................................... 4
About Other Settings (New Project Dialog) ..................................................................................... 6
Project Type ................................................................................................................................ 6
Parameter File ............................................................................................................................. 6
Language Settings .......................................................................................................................... 6
C Source ...................................................................................................................................... 6
C++ Source ................................................................................................................................. 6
Assembly Source ......................................................................................................................... 6
Enable source subfolders ................................................................................................................ 6
Project Settings File ........................................................................................................................ 6
3. Add Source Files to the Project ...................................................................................................... 7
About Other Settings (Add Source File Dialog) .............................................................................. 8
Look in subfolders ....................................................................................................................... 8
Add to user include path .............................................................................................................. 8
Add source file with folder unit..................................................................................................... 8
4. Create Program Documents (Simple Mode) .................................................................................. 8
View Created Documents ............................................................................................................. 10
Easy Access to and from Program Documents and Source Code ............................................... 11
Assembly Source Code Flowchart ................................................................................................ 13
5. Advanced Mode ............................................................................................................................ 15
Analysis Settings ....................................................................................................................... 15
Create Documents ..................................................................................................................... 16
View the Global Variable List and Global Variable Reference List ........................................... 17
View Additional Variable Reference Information........................................................................... 19
6. MISRA-C Rule Checker ................................................................................................................ 20
Perform the MISRA-C Rule Check ............................................................................................ 20
Display Options ......................................................................................................................... 22
Rule Selection ........................................................................................................................... 22
View Source Code Metrics ........................................................................................................ 23
7. Search Feature ............................................................................................................................. 25
8. Printing Features .......................................................................................................................... 27
9. Create Microsoft Word Format Documents .................................................................................. 28
10. Create HTML Format Documents .............................................................................................. 30
11. Detailed Settings for Advanced Mode ........................................................................................ 32
Preprocessor Settings ................................................................................................................... 32#define (symbol [=value]) .......................................................................................................... 32#undef (Symbol) ........................................................................................................................ 32
Pre-Include File ......................................................................................................................... 32
System Include Path / User Include Path .................................................................................. 33
C Option Parameter ...................................................................................................................... 33
User Keyword ............................................................................................................................ 33
Replacement Keyword .............................................................................................................. 34
Other Settings in C Option Parameter ....................................................................................... 34
12. Conclusion .................................................................................................................................. 34- 2 -CasePlayer2 Tutorial

CasePlayer2 Tutorial
Introduction
At this time we wish to thank you for your interest in GAIO TECHNOLOGY’s static analysis
and program document creation tool, CasePlayer2.
This tutorial includes practice exercises designed for first time users. By following thistutorial and completing the exercises, the user will gain an understanding of CasePlayer2’s
basic usage and features.
Before using this tutorial, CasePlayer2 should be installed. The default installation folder is
C:¥Program Files¥gaio¥Caseplayer2.

CasePlayer2 Overview
CasePlayer2 is an integrated reverse CASE tool that can create program documents suchas flowcharts and MISRA-C reports by analyzing the source code. It includes a Document
Browser for easy access to program documents and source code for review.

CreateProgramDocuments
Flowchart

Program Structure
DiagramGlobal Variable List

MISRA-C Report

StaticAnalysis
Source Code Editor / Document Viewer

System Requirements* IBM Compatible* USB port (for USB license key)
* Windows XP, Windows Vista (32-bit), Windows 7 (32/64-bit)* Hard Drive: 50 MB free space* Microsoft Internet Explorer 5.5 or newer to view HTML format documents* Microsoft Word 2000 or newer to view MS-Word format documents- 3 -CasePlayer2 Tutorial

1. Start CasePlayer2
Start CasePlayer2 from the Windows Start Menu: All Programs -> CasePlayer2 ->CaseViewer.exe.

2. Create a New Project
To begin this tutorial first we will create a new project to manage the source code analysis
and output documents.
1.
2.
3.
4.
5.
6.
7.
8.

From the application menu: File -> New -> Project
Project Name: test
Save Location: (user selected)
Project Type: Create documents only
Language Settings: ANSI-C
Parameter File: Check the Assembly box,
rev file: C:¥Program Files¥gaio¥CasePlayer2¥sample¥Z80¥Z80.rev
Leave other options at default settings
Click OK

- 4 -CasePlayer2 Tutorial

The test project folder and related project files will be created in the location selected. The
test.vproj file is the CasePlayer2 project file which may be double-clicked to start
CasePlayer2 and open the project.

- 5 -CasePlayer2 Tutorial

About Other Settings (New Project Dialog)
Project TypeCreate documents only: This mode is used to create program documents from the sourcecode only. The source code files will not be modified in this mode.
(This mode will be used in this tutorial).
Copy comments to source files: This mode is used to create program documents from thesource code, and allows for copying comments added to created program documents to theoriginal source code files. If the Save original source files box is checked, comments will
be copied to duplicate versions of the source files.

Parameter FileC Language: The parameter files used to analyze compiler extension instructions or
ANSI-C non-compliant code. A parameter file does not need to be set if the source code iscompliant with the ANSI-C standard.
Assembly: The parameter files used to analyze the assembly language source files. The
parameter file contains the instruction grouping information for the microprocessor. GAIO
provides sample parameter files for over 40 microprocessor types. Assembly sample code isused for the Z80 microprocessor in this tutorial.

Language Settings
C Source
Select the C language source code type. ANSI-C mode is used in this tutorial.

C++ Source
Enable the Analyze C++ files setting if the source code includes C++ code. This option is
not used in this tutorial.

Assembly Source
Select the assembly macro type for analyzing assembly macro descriptions. XASS-V
Assembler (GAIO) is used in this tutorial.

Enable source subfolders
Subfolders will appear in the file tree view if this option is checked. This option is not used inthis tutorial.

Project Settings File
The project settings may be saved to a project setting file. Use this option if you wish to saveand reuse the selected project settings. This option is not used in this tutorial.

- 6 -CasePlayer2 Tutorial

3. Add Source Files to the Project
After creating a project, next add source files to the project to be analyzed.
1.

Right-click on the test (project icon) in the file tree view, then select Add
Source File to Project -> by Folder.

2.

Select the tutorial sample folder:
C:¥Program Files¥gaio¥CasePlayer2¥sample¥Tutorial

The file with .xas extension is an assembly source file. In this tutorial the Z80 assembly
source file sample.xas is used. Assembly file extension file settings may be changed fromthe project properties dialog accessible from the menu: Project -> Properties.

3.

Click OK.

- 7 -CasePlayer2 Tutorial

About Other Settings (Add Source File Dialog)
Look in subfolders
Check this option to display files located in subfolders.

Add to user include path
Check this option to add the folder for the selected header files to the User Include Path listin the Pre-processor settings.

Add source file with folder unit
Check this option to retain subfolder structure when adding source files to the project. The
Enable source subfolders option in the New Project dialog must be enabled in order to use
this setting.

4. Create Program Documents (Simple Mode)
Now let’s create program documents using the Simple (default) Mode. In this mode program
documents such as flowcharts, module specifications, etc. may be created without setting
any of the advanced settings.
1.

From the application menu select Project -> Re-create all documents.
(this will analyze the source files and then create program documents)

2.

Expand the Documents folder in the file tree view to display a list of createdprogram document types.

- 8 -CasePlayer2 Tutorial

The following document types may be created in Simple Mode:
Flowchart: Shows program flow for the function
Module Specification: Includes module (function) information such as return type,function parameters, etc.
Module Structure Diagram: Shows function call structure
Structure Specification: Includes structure information such as a list of member
variables
Module List: Includes a list of modules (functions) found in the source files
Structure List: Includes a list of structures found in the project
Additional document types require usage of the Advanced Mode (described later in thistutorial).

- 9 -CasePlayer2 Tutorial

View Created Documents
Next let’s take a look at the created Module Structure Diagram.
1.
2.

Select Module Structure Diagram located within the Documents folder ofthe file tree view.
Double-click test.vblk <Entire Project> that appears in the list to the rightof the file tree view.

Scroll to view the document or change the View Scale (zoom in/out) to change the display.

- 10 -

CasePlayer2 Tutorial

Easy Access to and from Program Documents and Source Code
Next let’s view a created flowchart and use the right-click menu feature to goto the sourcecode from the flowchart.
1. Select Flowchart located within the Documents folder of the file tree view.
2. Double-click etos that appears in the list to the right of the file tree view.

3. The flowchart of the function etos() will be displayed. The view scale may
be changed from the pull-down menu.
4. Right-click on a procedure box in the flowchart, then select Goto Sourcefrom the right-click menu.

- 11 -

CasePlayer2 Tutorial

The source code line corresponded to the selected procedure box will be displayed.

Since program documents and the source code are linked each other, the user may easily
open program documents and source code from the right-click menu.

Example: Move from Module Specification to other documents.

- 12 -

CasePlayer2 Tutorial

Example: Move from Module Structure Diagram to other documents.

Assembly Source Code Flowchart
CasePlayer2 can also create program documents from assembly source code. Included inthis tutorial project is assembly source code (sample.xas) for a Z80 device:- 13 -

CasePlayer2 Tutorial

In order to view the flowchart for sample.xas:
1. Click on sample.xas located within the Source File folder of the file tree
view (File tab selected).
2. Double-click START Flowchart that appears in the list to the right of the filetree view.

The flowchart of the assembly routine START will be displayed.
Note: Since assembly instructions may differ depending on the MPU, the appropriate
assembly parameter file (*.rev) should be specified when creating the project (see page 5).

Additional sample rev files are located in C:¥Program Files¥gaio¥CasePlayer2¥sample
for a variety of typical MPUs. If created program documents do not appear correctly for theselected assembly MPU, the .rev parameter file may require modification to match with yourassembly code

- 14 -

CasePlayer2 Tutorial

5. Advanced Mode
Additional program documents, such as global variable lists and structurereference/assignment lists, may be created using the advanced mode. These documents
provide a quick reference, and may be useful for locating unexpected read/write global
variable and structure related errors.
In the advanced mode all compilable source and header files for the project should be
added for analysis. In depth settings are not required in this tutorial project due to thesimplicity of the sample code used. However, for actual embedded development projects
with a large number of source and header files, detail settings such as pre-processor
settings and C-option parameters may need to be set in order to avoid analysis errors
caused by language description conflicts. These settings are discussed toward the end of
the tutorial.
Using the Advanced Mode, the following documents may be created in addition to the
documents creatable in Simple Mode.
Global Variable List
typedef list
#define list
Include Relation Diagram
Global Variable Reference List
Function Reference List
Structure Reference List
Member Reference List

Analysis Settings
In order to enable the Advanced Mode:
3.
4.

Click on the Settings tab located in the lower portion of the file tree view.
Double-click on Analysis Settings in the settings list.

- 15 -

CasePlayer2 Tutorial

5.
6.

Check all Advanced Mode options.
Click OK.

Create Documents
Now analyze the source code and re-create documents by selecting Project -> Re-create
all documents in the application menu.

- 16 -

CasePlayer2 Tutorial

View the Global Variable List and Global Variable Reference List
The operation to view created program documents is the same as in Simple Modementioned previously.
1. Return to the File tab view.
2. Select Global Variable List located within the Documents folder of the filetree view.
3. Double-click test.vvlt <Entire Project> that appears in the list to the rightof the file tree view.

4. Right-click on kcode in the Global Variable List.
5. Select Goto Global Variable Reference List from the right-click menu.

- 17 -

CasePlayer2 Tutorial

The Global Variable Reference List shows a list of references to the global variable kcode
including the source file, line number and function name. Right-click on an item in the list inorder to goto the location where kcode is referred to within each document.

- 18 -

CasePlayer2 Tutorial

View Additional Variable Reference Information
Additional variable reference information will be added to the Module Specification
document when using the Advanced Mode.
1.
2.

Select Module Specification located within the Documents folder of thefile tree view.
Double-click main that appears in the list to the right of the file tree view.

The following additional sections are included when documents are created using theAdvanced Mode: Referenced Global Variables, Local Variable, and Subfunctions.

This completes the program document creation portion of the tutorial. Topics covered
included the two analysis modes, Simple Mode and Advanced Mode, and moving to andfrom program documents and source code files using the right-click menu.

- 19 -

CasePlayer2 Tutorial

6. MISRA-C Rule Checker
MISRA-C is a software development standard for the C programming language developedby MISRA (Motor Industry Software Reliability Association) to facilitate code safety,
portability and reliability in the embedded software.
This portion of the tutorial will discuss the MISRA-C rule check features in CasePlayer2.
MISRA-C rule sets supported include MISRA-C 1998 and MISRA-C 2004.

Perform the MISRA-C Rule Check
The MISRA-C rule check feature requires that the CasePlayer2 analysis setting to be set toAdvanced Mode which was performed previously in this tutorial. We will continue to use thesame sample project (test.vproj) setup in the steps prior to this section of the tutorial.

1.

From the application menu select Project -> Re-check all files (MISRA-C).

2.

The rule check results will be created in the MISRA-C Report folder in thefile tree view.

3.

Double-click MISRA-C:2004 Report to open the report for viewing.

- 20 -

CasePlayer2 Tutorial

The report shows a list of the MISRA-C incompatibilities including rule #, source filename,source line number, and a description. Double-click on an item in the list in order to goto thesource code line.

- 21 -

CasePlayer2 Tutorial

Display Options
Sort by - Rule Number: The report will be sorted by rule number.
Sort by - Source Point: The report will be sorted by source line number for each source file.
View Mode – All: All rule information will be displayed.
View Mode – Simple: Displays a simplified version of the rule information.
View Mode - Part Message: Displays check information per selected rule number. Note:
this option is only available when using the Sort by – Rule Number option.

Rule Selection
The rules to be checked for may be selected using the following dialog.
1.
2.

Double-click on the MISRA-C:2004 Report (skip this step if already open).
From the application menu select Tool -> Set Display Rule.

Select a category on the left side to only display rules related to that category.
Rules checked in the dialog will be checked for in the MISRA-C rule check report. Rules
unchecked will not be displayed in the MISRA-C rule check report.

- 22 -

CasePlayer2 Tutorial

View Source Code Metrics
MISRA source code metrics may be viewed by double-clicking on Source Metrics locatedwithin the MISRA-C Report folder of the file tree view.

The following information is displayed for each function in the source metrics report:
Function: Function name.
File: Source file name.
Line: Source file line number the function is defined at.
Cyclomatic Complexity: Number of linearly independent paths through the function.
Myer's Interval: Cyclomatic Complexity plus ‘?;’ , ‘&&’ and ‘||’ operators.
Nesting: Maximum number of nests.
Code Size: Number of lines from ‘{‘ to ‘}’ of the function.
Line (including comment): Number of comment lines.
Comment Rate (%): The rate (percentage) of lines that are comment lines.
Static Path Count: The maximum number of possible paths in the function.

- 23 -

CasePlayer2 Tutorial

The results may be filtered by setting a minimum threshold for the various metrics by clicking
Tool -> Display Option from the application menu.
For example, only check the Static path count option, and set the value to 50 to only show
items that have a static path count of 50 or greater in the source metrics list.

The filtered result will be displayed as:

This completes the MISRA-C rule check portion of the tutorial.

- 24 -

CasePlayer2 Tutorial

7. Search Feature
The Detail Specification Browser makes it possible to easily search for a variety of items.
1.
2.
3.
4.
5.

Open the tutorial project test.vproj used throughout this tutorial.
From the application menu select Tool -> Goto Tool Browser...
Select Function as the Type.
Leave the Name field blank.
Click the Find button.

The functions located in the project will be displayed.

6.

Select getchar from the function list and click OK- 25 -

CasePlayer2 Tutorial

Information regarding the getchar function will be displayed such as thedefinition/declaration location and reference/assignments. Double-click on a result to display
the relevant source file line.

A variety of other items may be searched for by selecting the appropriate type in the DetailSpecification Browser.

- 26 -

CasePlayer2 Tutorial

8. Printing Features
CasePlyer2 includes a Print Preview feature for customizing and verifying the print layout
before actually printing. In particular this can be useful for minimizing wasted white spaceand preventing documents from using multiple pages.
1.
2.
3.
4.
5.

Click on the File tab located in the lower portion of the file tree view.
Click on Flowchart within the Documents folder.
Double-click on etos in the right selection box.
From the Flowchart Viewer’s menu select File -> Print Preview.
Click the Two Page button located under the menu bar.

6.

To the right of the Print Scale selection, click the (+) or (-) magnifier buttons
in order to increase or decrease the scale.

The print preview will be automatically updated to reflect the print scale setting as it ismodified. This way the user may verify the print view prior to printing.

- 27 -

CasePlayer2 Tutorial

9. Create Microsoft Word Format Documents
Using a built in feature, CasePlayer2 created program documents may be converted to
MS-Word .doc files using the following method:
1.
2.
3.

From the application menu select Project -> Convert to Word…
Add the type of documents to convert to the <<Convert>> list to the right.
Click OK.

4.
5.

Expand the External File folder in the file tree view.
Double-click on Word.

- 28 -

CasePlayer2 Tutorial

A word document with links to the word format program documents will be opened. Holddown the CTRL key and click on a link to open the linked document.

Notes:
Microsoft Word must be installed in order to use this feature.
Close all Microsoft word documents before performing the word conversion operation.
If a <Template List> error occurs during conversion, change the Microsoft Word security
settings as described below.

Enable the Trust Access to Visual Basic Project option from MS Word menu: Tools ->Macro -> Security -> Trusted Publishers.

- 29 -

CasePlayer2 Tutorial

10. Create HTML Format Documents
Using a built in feature, CasePlayer2 created program documents may be converted to.html
files using the following method:
1.
2.
3.

From the application menu select Project -> Convert to HTML…
Add the type of documents to convert to the <<Convert>> list to the right.
Click OK.

4.
5.

Expand the External File folder in the file tree view.
Double-click on HTML in the file tree view.

- 30 -

CasePlayer2 Tutorial

An HTML file with links to the HTML format program documents will be opened. Click on thelinks in order to open the linked HTML files.

- 31 -

CasePlayer2 Tutorial

11. Detailed Settings for Advanced Mode
As additional reference this section will explain some of the detailed settings for use with theAdvanced (document creation) Mode. These settings are not required for the tutorial project
due to the simplicity of the sample code used. However, for actual embedded development
projects these detailed settings may be required.

Preprocessor Settings
In order to analyze source code that includes header files, preprocessor settings configuredin the IDE will be required for CasePlayer2 as well. These includes the #define definition andthe include path information.
1. Click on the Settings tab located in the lower portion of the file tree view.
2. Double-click on Preprocessor.

#define (symbol [=value])
Define macros should be specified here. After entering an item click the Add button or press
CTRL + ENTER in order to go to a new line to add additional items.

#undef (Symbol)
Existing #define macros may be undefined by entering them here.

Pre-Include FileEnter a header file here in order to include it before other source files. A pre-include file that
describes implicit definitions may be entered in order to avoid CasePlayer2 analysis errors
when the cross compiler has implicit key words or definitions.

- 32 -

CasePlayer2 Tutorial

System Include Path / User Include PathEnter system include paths or user include paths in these fields. The paths may be selectedusing the tree view to the right then clicking the Add button. Since Subfolders are notincluded each folder must be specified individually.

C Option ParameterC-option parameters may need to be set in order to avoid the analysis errors caused byincompatibilities in the code with the ANSI-C standard. To access the C Option Parametersettings:
1.
2.

Click on the Settings tab located in the lower portion of the file tree view.
Double-click on C Option Parameter.

User Keyword
ANSI-C incompatibilities or compiler specific keywords may be fixed here. The following
examples are typical settings to avoid the analysis errors:
Example #1: int near p1;
Using the TYPEATT style for the near keyword will cause near keywords to beanalyzed as a type instruction modifier.
Keyword: near, Style: TYPEATT, Postfix Notation: [**leave blank**]
Example #2: direct int array[100];
Using the STRAGE style for the direct keyword will cause the direct keyword to beanalyzed as a storage class instruction modifier.
Keyword: direct, Style: STRAGE, Postfix Notation: [**leave blank**]
Example #3: __asm (“ ....... “)Using the ASM style for the __asm keyword will cause the __asm keyword to beanalyzed as an inline assembler description.
Keyword: __asm, Style: ASM, Postfix Notation: (EXPRESSION)
Example #4: __except ( ....... )Using the IGNORE style for the __except keyword will cause the __except keyword
to be ignored during analysis.
Keyword: __except, Style: IGNORE, Postfix Notation: (EXPRESSION)- 33 -

CasePlayer2 Tutorial

Example #5: INT32 val;
Using the TYPE style for the INT32 keyword will cause the INT32 keyword to beanalyzed as a type definition.
Keyword: INT32, Style: TYPE, Postfix Notation: [**leave blank**]

Replacement Keyword
Use to replace keywords in the code.
Example #1: typedef __WCHAR_T_TYPE__ _Wchart;__WCHAR_T_TYPE__ can be replaced by int in order to avoid errors.
New Keyword: int, Existing Keyword: __WCHAR_T_TYPE__
Example #2: typedef __SIZE_T_TYPE___Sizet;__SIZE_T_TYPE__ can be replaced by int in order to avoid errors.
New Keyword: int, Existing Keyword: __SIZE_T_TYPE__

Other Settings in C Option Parameter
Most errors can be fixed using the above described User Keywords and Replacement
Keywords. Additional settings found in C Option Parameter include:
Non-selection Comment
Module Specification/Sampling definition of Outline
Structure Specification/Sampling definition of Outline#pragma Definition

12. Conclusion
This concludes the CasePlayer2 tutorial. We hope that the information provided in thistutorial has helped aid you in better understanding how to use GAIO’s CasePlayer2 static
analysis and program document creation tool.

Copyright Notice and Disclaimer
This document is copyright of GAIO TECHNOLOGY CO., LTD. All rights reserved.
The content of this document is subject to change without notice.
We assume no responsibility for any losses or damages that may occur from errors in thisdocument.

- 34 -