UNIVERSITI PUTRA MALAYSIA
DESIGNING A SOFTWARE MAINTENANCE SYSTEM USING A REVERSE ENGINEERING APPROACH
HAMED JASEM AL-FAWAREH
FSAS 1998 35
DESIGNING A SOFfW ARE MAINTENANCE SYSTEM USING A REVERSE ENGINEERING APPROACH
By
HAMED JASEM AL-FA W AREH
Dissertation Submitted in Fulfillment of the Requirements for the Degree of Master of Science in the
Faculty of Science and Environmental Studies University Putra Malaysia
February 1998
Surat Al-Mujadilah (The Disputation). Ayah II.
To My Late Father's Pure Spirit
ACKNOWLEDGMENTS
In the name of Allah, the Beneficent, the Merciful.
I would like to take this opportunity to convey my sincere thanks and deepest
gratitude to my supervisor Dr. Abdul Azim Abdul Ghani. I am very grateful to him for
the help and invaluable guidance, fruitful discussions, patience and continued
encouragement provided to me at every stage of this thesis.
It is also a great honor and pleasure to acknowledge Dr. Ramlan Mahmod and
Dr. Ali Mamat, members of the supervising committee, for their technical support,
helpful suggestions and insight.
In preparing this thesis, a number of individuals have provided helpful for their
suggestions and comments, all of which have been of tremendous help towards the
compilations of this thesis. I would like to convey my appreciation to the Department of
Computer Science, the University Library and Universiti Putra Malaysia for providing
assistance at one time or other. I also, wish to thank all postgraduate students in the
Department of Computer Science.
I am very grateful and wish to thank all my friends from Jordan, especially,
Khalid Al-Tahat, Ibrahim Al-Atoum, Eid Al-Zyoud, Ziad Abu Gadora and Jehad AI
khaldi for their encouragement, help and support. Also, I would like to single out my
friend Idi Fulayi to thank him for his help, encouragement and support. Also, I would like
to thank Dr. Adam Kilicman for his help and encouragement.
Finally and most important, I w01:lld like to express my most sincere and wannest
gratitude to my mother, eldest brother Ali, brothers; Khalid, Mammdoh, Mobarak, Omar,
and Mohammed, sisters, nephews, nieces, uncles, aunts, and cousins for their prayers,
love and generous moral and financial support during my studies.
All praises for the Almighty, without whose will everything would cease to be.
iii
TABLE OF CONTENTS
Page
ACKNOWLEDGEMENTS.................................................................................... 111
LIST OF T ABLES........................................................................................... . . . . .. VII
LIST OF FIGURE........................................................................................... . ..... VIII
LIST OF SYMBOLS........................................................................................ .. . . . X 11
LIST OF RESERVED WORDS IN THE SySTEM....... . . . . . . . . . . . . . . . . . ............ XIII
ABSTRACT .. . . . . . . . . . ... .. ....... . . . . .................................. ...................... ................... . . . . . X IV
ABSTRAK........................................................................................................ . . . . .. x V 1
CHAPTER
I INTRODUCTION . . . . .. . . ...... ..... ....... .. ... ..... ...... . . ... . . ....... . ... . ... . ...... . .... .. . . . .. 1
Background....... . . . . . . . . . . . . ... . . . . . . . . . . . . . . . . . . . . . . . . . ... . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . 1
Logic Fonn Reverse Engineering Approach ......... �..................... . .. . . . ...... 4
Aims of the Research . . .. ....... ..... . :. . . .. . . . . .. . . . . . .. . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Organization of the Thesis. . . . . . . . . . . . . . . . . . .... . . . . . . . . . . . . . . . . . . . . . ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
II SOFTWARE MAINTENANCE: ACTIVITIES AND APPROACHES............. . ..... . ... . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Introduction.. . . . ... . . . . . . . . . . . . ......... . . . .. . . ... ... . . . . . . . ....... . . . . . .. . . ... . . . . . . . . . ... . . . . . . ... . . . . . . . 8
Software Maintenance. . . . . . . . . . . . . . . . . . . . .... . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Emergence Software Maintenance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . 8
Software Maintenance: Definitions and Activity. . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . 1 1
Approaches in Software Maintenance...... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 3
Restructuring.. . .. . . . . . . .. . . . . . . ..... . . . . . . ... .... . . ... . . . . . .. . .............. . . . . . ... ..... . . . . . . . . . 13
Reengtneenng.............. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Reverse Engineering............. . ....... .. . . .. . . . ...... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Reverse Engineering Tools.................. ................................................... . . .. 22
iv
System Analysis and Maintenance System (SAMS) .. . . . . . . . . . . . . . . . . . . . . . . . 22
Data Tool... . . .... . . .. . . . . . . . . . . . ..... . . . . . . .. . . . . . . . . .. . . . . . .... . . . .. . . . .... ... ... . . . . . . .. . . . . . . . . . 25
Extracting and Preserve Low-level Program Too!. . . . . .. . . . . . . . . .... . . . . . . . . 27
Knowledge Base Reverse Engineering Framework Tool. .... . . .. . . . . . .. . . . . 29
Logic and Data Base... . . . . . ....... . . . . ...... . . . . .... . . . . . . . . .. . ... . . . . . . . . . . . . . . . .. . . .. . . . . . .. . . . . ... . 35
Logic Definition ... ... . . . .. . . .. . . �............................................ . . . . . . . . . . . . . . . . . 35
Logic Mathematical. . . . . . ... . . ... . . . . . ... . ... . . . . . . . . . ;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Logic Form. . . . . . . . . . . . ...... .. . . ... . . . .. . . ... . . . . . . . . . . . . .... . . . . ... . . . . .. . . . .. . . . .. . . . . . . ... . . 38
Summary.. . . . . ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
III RESEARCH METHODOLOGy................................ ............................ 41
Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . .. . . . .. . . . . . . .. . . . . . . . . . . . . . . .... . . . . ...... . . . . . . . . 41
Reverse engineering approach. . ... . . . . . . . . . . ... . . . . . . ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Logic-Form Reverse Engineering Tool. ... . . . . . . . . . . . . .. . . . . . . . . .. . . . . . .. . . . . . ... . . . . . . . . . . . 43
Lexical Analysis.. . . . . . . . . . . ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . 43
Syntax Analysis. . . . . . . . . . . . . . . . .. ..
. . . . . . . . . . . . ... . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ... . . . . . . 46
Handling Module. . . . ..... . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Logic Form. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Query Module... . . . . . . .. . .. . . . .. ..... ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Sub Set of C Language ( Minus C ).... . . . . . . . . ...... . . . . . ..... . . . ... . . ... . . . . . . . . . . . . . . . . . . . . 52
Vocabulary. . . . . . . . . . . . .... . . ... . . . . . . . . . .. . . . . . ... . . . . . . . . . . . . . . .... . . . . .... ... . . . . . . . . . . . . . . . . . . . . 55
Conclusion......... . . . .. . . . . . . . . .. . ..... . . . . . ...... . . .... . . .... . . . . .... .... ... . . .... . ... .... . ..... . . . . . . . . . 57
IV LOGIC-BASED REVERSE ENGINEERING SySTEM..................... 58
Introduction. . .... ... . . .. . . ... . . . . . .. . . . . . . . . . .. . ....... . . . . . . . . . ..... . . .. . . . . . . . . . . . . . . . . ... . . . . . . . . . . . . . . . 58
Designing of a Lexical Analyzer. . . . . . .. . . . .... ... . . . ...... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Special Symbol. . .. . . . . ..... . . . . . . . . . . .. . . . . . .. .. . . . ... . . . . . . ....... . . . ... . . . . . . . . . . . . . . . . . . . ... . . 61
Comments and Quotations....... . .... ... . . . .... . . . . . . . .. . . . . . . . .. . . . . ... . . . . . . .. . . . . . . . . . . . 63
Numerical........ ............... . . . ..... . . . ....... ..... ...... . . .... . ... . . . ..... . .... . . . . . . . . . . . . . . . . 64
Identifiers and Reserved Words............. ...... ..... . . ........... ..... . . . ....... . . . . . . 64
v
Symbol table.. ... .. ... . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Errors Function. . . . .... . . . . . . . . . . . . . . . . . . .. . . . . .. . . . . . . . . . . . . . . .. . . . ... .......... 72
Syntax Analyzer Design.......... ... . . . .... . . . . . . . .... . ...... . . . ... ..... . ... .......... ......... . . ... 74
Tokens Processing................. . . . . . . ....... . ......... . . . ....... ....... ... . . . . . . . ........ . .. 74
Parser Architecture...... .... . . . ..... ... .................... . . ...... . .. . . ......... . . ..... . ... . .. 76
Progralluning Header.. . ... . . . . ... . . . . . . . .......... ... .... . . . . . . .... . . ........ . . . . ...... ........ 77
Functions Definition. .. ..... . . . . . . . . . . . .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . 78
Global Variable Declaration. . .. .......... . . . .. ... . . . . .. . . . . . . . .. ... . . . ....... . . . .... ... ... 87
Progranuning Modules. . . . . . . . . .... . . . . ... . . . . . ...... . . . . . . . . . . . . ..... ... . ..... . . . . ..... . . . .. 88
A Top-Down Parser for Sub-C Language... . . . . ... . . ..... . . . . . . ... . . . . ...... ...... 89
Statements.. .... . ......... ... . . .. ..... .......... .... ... .. . . ... . . ... . ... .. .. . . . ... .... . . . . . . . ........ 92
Handling Module Design.... ... ............ . ............ . . . .... . . ..... . . ...... . . . ... ......... .. . .. . . 94
Data Processing... ......... . . . . . ... ..... ..... ...... . . . . ... . ..................... . . . . . . . 94
User Interface... ........ ........ . . . ......... . . ..... . ....... . .. . . . ...... . . ..... . . ... . . . . ... ... . . ..... . .... . 1 09
Conclusion.... . . . ..... . .............. . . . . . .... . . . . . . . .. . ... ...... . .... . . ..... . . ......... . . . ... . . . .... . . . . . . 1 13
V RESULT AND DISCUSSION �........................................................... .... 1 14
Introduction . . . . ... . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . , 1 14
Example1 : Towers ofHanoi..... . . . . . . . . . ....... . . . . . . . . . . . . . . . . . .... ... .... . . . . . . . ..... . . ... . . . . . 1 14
Example2 . . . . . . . . .. . . . . . . . . .. . . . . . . . . . .. . . . . . . . . . . . . .. . . . . . . . ... . . . . . . . . . . . . . .. . . . . .. 1 24
VI CONCLUSION AND FUTURE WORK............................................. . .. 1 29
Conclusion... . . . . . . .... . ....... . . .......... . . . . .. . ... . . . .... .... .... ... . . . .... . . . . . . . .... . . . . . ...... . . . . . . . 129
Future Work.. . . . . .... . . . . . . .................. .... . . . . . . ... . . . . . . ... . . . . . . ..... ...... ..... . ....... . . . . . . . . . 1 32
BIBLIOGRAPHY............................................................................................ . . . . .. 1 34
APPENDIX....................................................................................................... . . . . .. 1 38
A Summary of the C language ( Minus C)... .......................... . .. 139
VITA......................................................................................................................... 143
vi
LIST OF FIGURES
Figure
I Relationship Between the Tenns Restructure, Reengineering, Reverse Engineering and Forward engineering, During a software engineering
Page
Life Cycle......... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2 Software Restructure of COBOL Programming......... .... ..... .... ... ...... . . ... 1 6
3 Architecture of SAMS TooL....... . . . . . . . . ................................................ 23
4 EXaIllple of C Function ........... ..... ..... ............ ... ....... ..... ..... ....... ...... ..... . . 24
5 Display the C Function Using SAMS Tool .......................... ............... . . 24
6 Extracting and Preserving Low-level PrograIll Tool Diagram................ 28
7 Prolog Example (turbo Prolog) .............. . ...... ... . ... .. ...................... . . .. ... . . . 32
8 SaIllple Data for the Example in Figure 7 . . . . . . . . . . . . . . . . . . . ... .... ....... ... 33
9 The Structure of the System .... :......................................................... . ... 45
10 Tree for the Expression A *B+C ..... ........ ........ .... ....... .... ..... ........ ... .... . ... 47
1 1 Syntactic structure of the string A *B+C. ........................ ..................... . . 49
12 General System Design...................................................................... . ... 58
13 Next Symbol Algorithm....... .. ..... ..... ....... ........ ..... ........... ..... ....... ... .... . ... 62
14 Comment and Quotation Algorithms..................................................... 63
15 Numerical algorithm.......................... ................ ............................ ..... . .. 65
16 Alphabetic algorithm......................................... ............ ...................... . .. 65
17 Hash Key Algorithm............................... ............................ ............... . ... 66
1 8 Initialize algorithm.. ...................... ........ ........... .. . . . ... ... ...... .................. . .. 69
19 Search Algorithm............................................................................... .... 70
viii
20 Insert Algorithm..... . . .. . . . . . . . .. . . . .... . ... . . . . . . ... . . . . .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1
2 1 Found Algorithm.... .... . . . . . . . . . . ... ... . . . . . .... . ... . . . . . . ... . ... . . . . . . . . . . ... . ... . . . . . . ... . . . . .. . . 7 1
22 Symbol Table... ..... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ... . . . . . . . 67
23 Error Algorithm . . . . . . .. . . . . ... . . . . . .... . . . . . . . . . . . . . . . . . .... . . . . ... . . . . . . . . ....... ... . . . . . . . . . . . . . . . , 73
24 NextToken algorithm . . . . . . . . .... . . . . ,. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ..... . . . . . . . . . 75
25 Before_Main Algorithm .. . . . . . . . ,. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
26 Function Structure. . . . . . . ....... . . . . . ....... . . . . . . . . . . . . . . . ...... . . . ...... . ... . ... . ... . . . . .. . . . . . . . . 79
27 Data Structure Representation of Function, Parameter, and Local Variable List.. . . . ... . . . . . . . . . . . .. . . . . . ... . . . . . . ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
28 Save the Function in the Data Structure.. . . . . . .... .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
29 main module as a special case.. . . . .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1
3 0 Data Structure for the main Module.. .. . . .. . ... . . . . . ... . . . ... . . . . . ... . . . . . . . . . . . ... .. . . . . . 82
3 1 Function Definition Algorithm.. . . . . . . . . . .. . . . . . . . . . . . . . . . . . . ... . . . . . . . . . . . . . . .. . . . .. . . . . . . . . 82
32 Adding Function Algorithm.. . . .. . . .... . . . . . . . . . . . . ... . . . . . .... . .. . . ... . ...... . . . . . . . . . . . . . ... 82
33 Searching Function Algorithm.. . . . . . . ..... . . . . . . . ...... . . . . ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
34 Parameter Definition Part Algorithm.. . . . . . . . . . ..... . . . . . . ... . . . . . . ... . . . ... . . . ... . . . . . . . 84
35 Parameter Definition Algorithm.. . . . ..... . . . . . . . . . . . . .... . . . . . . . . . ..... . . . . . . . . . . . ..... . . . . . 85
36 Parameter Search Algorithm.. ...... . . . . . . . . ... . . . . . ... . . . . . . . . . . . . . . . . . .. . . . . ..... . . . . . . . . . . . 85
37 Parameter Adding Algorithm...... . . . . . . . . . . ... . . . . . . . . . . . . . . .. . ... . . ... . . ... . . . . . . . . . . . . . . . . 86
38 Data Structure Representation of Global Variable List. . ... . . ... . . . ... ...... . . 88
39 Algorithm Simple Expression Recursive. . . . . . . . . . . . . . ... . . . . . . . . . ... . . . . . . ..... . . . . . . . . 90
40 Simple Expression Parse Tree . . . . . . . . . . . . . . . . . . . . . . . ... . . . . ..... . . . . . . . . . . . ......... . . . . . . . . . . 9 1
41 Statements Algorithm... . . . . . .. . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
ix
42 While Statements Algorithm. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
43 Tree Module Structure. . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . .. . . . . ....... . . . . . . . . . . . . . . . . . . . . . .. . . . . . . 96
44 General Format. . . . . . . . . . . . . . . . . . . . . . . ... . . ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
45 Program Example .... . ..... . . . . . . . . . . . . . . ... ......... , ...... . . . . . .... . . . . . . . . . . . ... . . . ..... . . . . . . 98
46 Tree Representation Modules For Example in Figure 42. . . . . . . . . . . . . . . . . . . . . . . 100
47 A Representation Structure of Module Tree For Example in Figure43.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
48 Continuation of Figure 45. . . . . . . . ....... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .... . . . . ... . . . . . ... 102
49 Adding Module Algorithm.. ........ . . . . . . . . . ... . . . ....... . . . . . .... . . . . . . . . . . . . . . . . . . .. . . . . . . . . 104
50 Scope Browsing ... . . . . . . . . .. . . . , . . .. . . . . . . , . . . . . . ... ,. . . . . . . . . . . . . . . . . . . . . . . . . ... . . . . . . . . . . . . . . . . . . . . 104
51 Variable Browse . . . . . . . . . . . . . . ... . . . . . . . .... . . . . . . . '" ... . .. . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . 1 07
52 Welcome Menu. . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ... . . . . . . . . . . . . . . . . . . . . . ... . . . . . . . . . . 1 1 0
53 Main Menu... . . ..................... .. . . . ...... . . . . . .. . . ...... . . ........... . ....... . . . . . . .. . . ... . . . . . . 1 1 1
54 Variable Menu. . . . . ... . . . . . . . . .. . . . ..... . . . . . . . . . . . . . . . ..... . . . . . .... . . . . . . . . . . . . . . . . . . . .... ... . . . . . . . 1 1 1
55 Output Menu.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 12
56 Generalized Tower of Hanoi Puzzle.. . . . . ..... . . . . . . . . ....... . . . ..... . . . . . ... . . . . . . . .. . . . 1 1 5
57 InputJ Output File Menu... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ... .... . . . . . . . . . . . . . . . . . . . . . . . . ... . . . . . . 1 1 8
58 Error Message Menu. . . . . . . . . . . . . . . . . . . . ... ....... . . . . . ... . . . . . . .. . . . . . . ... . . . . . . .. . . ..... . . ... . . . 1 1 8
59 Parameter Statistical Query. . . . . . . . . ... . . . . . . . . .. . . . . . . . . .. . . ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 19
60 Parameter Statistical Report Output.... . .... . . . . . . . .... ... . . . . . . . .. . . . . . . . . . . . . . . .... . . . . . 120
61 Report Output of Function Callee. ... . . . . . . . . . . . . . .... . . .. . . . . . .............. . . . . ...... .... 121
62 Function Call menu................. .... . .... ............................... ............ . ..... . . . .. 122
63 Logic Menu................................................................................ ....... . . ... 122
x
64 FUnction Call Two Function Move and puzzle Output.. . . . .. . .. . .. . . . . ... 123
65 Output of the Variable x Life Cycle. . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . .. . . . . .. . . . 123
66 Sub-C Program..... . . . . ..... . . . . . . . . . .. . . . . . . . . . . . . . . . . . .. . . .... . . . . . . . . . . ... . . . 124
67 Function Q Call Menu.. . .. .. . ......... . . . . . . . . . . .. . . ........ . . . .. . . . . . . . . . . . . . . 126
68 Function Q Called Output.. . . ... . .. . .. . . . . . . . . . . . . . . . . . . . .. . . . . .. . . . . . . . ... . . . . 127
69 Output of the Variable r. . . . . . . . . . . . . . .. . . . . .. ..... . . . .. . . . .. . . . ..... . . ......... 128
70 Output Logic Function Call..... . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . ... . . . . . 128
xi
Ir;j universal quantifier
3 existential quantifier
And
v Or
Not
Implication
equivalence
LIST OF SYMBOLS
xii
LIST OF THE RESERVED WORDS IN THE SYSTEM
Program Used when the identifiers scopes are all the program.
Function Used to obtain the statistics for the functions.
Parameter Used to obtain statistical account of all parameters in any function.
Variable Used to give a statistical account of all variables.
And The system knows this word as the logic "and" symbol.
Or The system knows this word as the logic " or " symbol.
not The system knows this word as the logic "not" symbol.
xiii
Abstract of thesis presented to the Senate of University Putra Malaysia in fulfillment of the requirements for the degree of Master of Science.
DESIGNING A SOFfW ARE MAINTENANCE SYSTEM USING A REVERSE ENGINEERING APPROACH
By
HAMED JASEM AL-FAWAREH
February 1998
Chairman: Abdul Azim Abd Ghani, Ph.D.
Faculty: Science and Environmental Studies
The aim of the software maintenance is to maintain the software system in
accordance with advancement in software and hardware technology. There are four
activities to software maintenance, namely corrective maintenance, adaptive
maintenance, perfective maintenance, and preventive maintenance. Three approaches are
used in software maintenance, that is restructure, reverse engineering, and reenginering.
Reverse engineering is a process that is currently being used in software
maintenance to extract items of information on software products. This research aims to
produce a new reverse engineering logic-form tool, to help maintainers by giving them a
complete document about the software system. Currently, many tools are used in reverse
engineering, but not all can satisfy the problems faced by the users.
xiv
The thesis describes the design and implementation of an automatic aid system
that uses a logic-fonn reverse engineering approach, with a new data structure called tree
module structure. This tool contains four modules, namely, lexical analyzer module,
syntax analyzer module, handling module, and interface or query module.
xv
Abstrak tesis yang dikemukakan kepada Senat Universiti Putra Malaysia bagi memenuhi keperluan untuk ijazah Master Sains.
MEREKABENTUK SISTEM PERISIAN PENYELENGGARAAN DENGAN MENGGUNAKANPENDEKATANPEREKASAYAAN SONGSANG
Oleh
HAMED JASEM AL-FAWAREH
February 1998
Pengerusi: Dr. Abdul Azim Abd Ghani, Ph.D.
Fakulti: Sains dan Pengajian Alam Sekitar
Matlamat penyelenggaraan perisian adalah untuk menyelenggara sistem perisian
supaya menepati dengan kemajuan dalam teknologi perisian dan perkakasan. Terdapat
aktiviti dalam penyelenggaraan penslan iaitu penyelenggaraan pembetulan,
penyelenggaraan penyesuaian, penyelenggaraan penyempurnaan dan penyelenggaraan
pencegahan. Tiga pendekatan digunakan dalam penyelenggaraan perisian iaitu
penstrukturan semula, perekasayaan songsang, perekasayaan semula.
Perekasayaan songsang adalah suatu proses yang digunakan dalam
penyelenggaraan perisian untuk mengeluarkan butiran maklumat mengenai produk
perisian. Penyelidikan ini bertujuan un� menghasilkan satu peralatan baru perekayasaan
semula berbentuk-logik untuk membantu penyelenggara dengan menyediakan. mereka
satu dokumen lengkap mengenai sistem perisian. Sekarang ini banyak peralatan
xvi
digunakan dalam perekayasaan semula tetapi tidak semua dapat memenuhi masalah yang
dihadapi oleh pengguna.
Tesis ini menerangkan rekabentuk dan implementasi sistem bantuan automatik
yang menggunakan pendekatan perekayasaan semula berbentuk logik dengan kaedah
bam yang dipanggil modul pokok sistem pendekatan. perekayasaan semula berbentuk
logik menggunakan empat modul iaitu modul penganalisis leksikal, modul penganalisis
sintak, modul pengendalian dan modul antara muka atau pertanyaan.
xvii
CHAPTER I
INTRODUCTION
Background
Computer systems have been used in many complex and diverse applications;
they are also applied in critical areas, where the useful of a nation may depend on them.
These computer applications increased with the advance in technology, also, the
complexity has increased a lot in these applications. Each software system may contain
thousands of components which, may be spread over different and large modules. The
relationships between these components make determination of any change between the
diverse parts of the software system very difficult. This problem becomes more
complicated for a large software application. The integration of these modules becomes
tedious and time consuming without the support of aid tools.
During the initial years of computer software and hardware development
programmers concentrated on the production of new software systems for new
applications. These software systems consumed much time and money for the
development.
In the early 1 960s, programmers attention was directed towards in producing new
applications, rather than updating the old software. In the 1 970s, the developments in
computer software and hardware technology caused programmers to maintain the old
1
2
software and increase the life cycle of software systems. Furthermore, attempts to
produce new software during this period was time consuming and costly, so maintainers
tended to maintain the software system by using software maintenance (Glass &
Noleseux 198 1 ).
It is easy to detect a logic error when a maintainer builds a compiler e.g. in C
language when the maintainer forgets a semicolon at the end of a line or omits to close
brackets in a "for statement". The main problem is that the maintainer finds it more
difficult to detect run time errors inside the program. These errors cause the program to
produce incorrect results.
Detecting and correcting errors take much time. For example, in a given function,
a maintainer needs to know all the input and output parameters. To solve these problems;
he needs to trace all the variables and functions called during the execution of a program.
In order to do this, the maintainer needs a list of all local and global variables, and
function calls, to determine the statements that contain errors.
Errors in a complex software system are difficult to correct and detect; software
maintenance aids the maintainer to correct and trace the software system, and, thus,
reduces its cost. When programmers build software systems, the task of detecting and
correcting errors for small software system is simple; but it becomes difficult and
complex for large software systems. One of the software maintenance activities is
concerned with correcting software errors and producing full details about the
components of the program, such as, global variables and local variables.
3
Software maintenance activities modify old software systems, correct errors in
order to improve the performance of these systems, and adapt the software systems to the
changing environment. There are four types of software maintenance activities. First,
corrective maintenance, which deals with testing of large, and huge software systems, to
detect errors, which may need much time to correct as whole contents of the program
need to be traced. The second is adaptive maintenance. This looks into the rapid change
in software environment, such as the operating system, new hardware, and upgrading of
the elements of the system. The functionality of the software however does not change.
The third which, is perfective maintenance deals with the modification and
implementation of the recommendations from users, after the use of the software. The
fourth is preventive maintenance which brings about future enhancement in the software
system.
In general, software maintenance is very expenSIve compared to software
development. The cost of software maintenance became higher after 1970s, and by the
1990s, it constituted more than 62% of the cost (Zuylen, 1993). Three approaches are
used to maintain software. These are the 3RE's namely, reengineering, restructuring, and
reverse engineering (Chikofsky, et. aI., 1 990). Reengineering is concerned with
processing the existing software by producing a new source code without changing the
old system function. Restructuring involves examining the existing software and
rewriting parts of it by changing unstructured, ambiguous and difficult software to a new
structure, that is easier to understand. Reverse engineering is a technique to analyze a
subject system to identify system components and their relationships, in addition to
4
creating representations of the system at a higher level of abstraction. In other words,
reverse engineering is a process of extracting information from a source code concerning
software product design.
In this thesis, the reverse engineering approach will be used to produce a new tool
for helping users to walk through the software system. This system is called "logic form
reverse engineering tools". This system is divided into four modules, namely, lexical
analyzer module, syntax analyzer module, handling module, and interface module.
Logic Form Reverse Engineering Approach
When a developer builds a huge and large software system, detecting and
correcting errors is time consuming. For example, for a function of a given program, the
developer may wish to know all the input and output parameters, these parameters help
the developer to correct software errors. If it is a small program, errors are easy to detect
and correct. However, it becomes difficult and complex in large software.
Software systems are spread over different modules. These modules contain
numerous local and global variables, parameters, and functions, in different level of
abstractions. Program construction in a sub standard C-Ianguage is spread over different
functions. Not only do these functions contain separate variables but also the program
itself contains global and local variables. The overlap between all functions, local, and
global variables, makes the walking tIu:ough inside the program more difficult if it is
5
done manually by the user. The main attention of users is to detect all variables and
functions declared in software system in order to correct errors.
The errors that occur in a software system are of three kinds: implicit error, latent
error, and syntax errors or the easy errors. Syntax errors are the most common. They
occur when the user, for example, forgets the semicolon at the end of line, or forgets to
close the bracket in a "for statement". This error is very easy to detect during execution
of a software system. Implicit error or run time error is difficult to detect because the
system compilation does not detect it. Also, this error may feature incorrect results after
execution of the program. To detect this error, the maintainer needs to walk through the
program and trace all the variables and functions declared in the program. This method is
easy in small programs, but becomes complex when the software system grows large and
huge. When the users use the software system, they write full recommendations to the
maintainer in order to change the software and correct the error, again, software system
need to do program tracing.
F or the above problems we developed a logic form reverse engineering tool. This
tool contains four components, namely: LEXICAL ANAL YZER, SYNTAX
ANALYZER, HANDLING MODULE, and QUERY MODULE. Logic-form reverse
engineering tool assists in enhancing system constituents and their relationships. Also, it
assists in binding the modules and variables in the program. It also helps the' user to
recognize the overlap between modules and variables in the program, and identifies
components and their relationships. Furthermore, it provides information that helps users
6
to correct errors in the program. This tool helps users to walk through all contents of the
program, its functions and its variables without encountering any difficulty for correcting
them. Also, it detects implicit faults so as to get the correct results.
Aims of the Research
The research in this thesis, aims at developing a logic form reverse engineering
system. It is designed to help a maintainer correct the three kinds of errors, by giving a
full documentation for all local and global variables, parameters, and functions used in
the software system. In addition, this system extracts information concerning software
variables and functions and provides information on call graph. This information should
help to control many managerial problems. These problems may occur when building
large software systems for a large number of families of components. For example, let us
consider a database containing thousands of components or modules and thousands of
dependency relationships, and documents. It is beyond the human ability to search
manually such a database to find specific information about specific modules, their
dependencies, and connectivity to other activities in the life cycle of a product. This
system provides all the facilities for browsing the database, and gives all the information
about the components of software systems, such as, global variables, local variables,
functions, and parameters. Furthermore, this tool clears overlapping between the software
system components, variable and functions.
The system developed in this research provides visibility to maintainers, by
allowing them to go through the life cycle of the functions and variables, and increasing
7
the understandability of the software system. Also, the research should help maintainers
to correct programming errors, and achieve more correct results. This system, also,
provides querying and browsing facilities.
Organization of the Thesis
Chapter two provides background infonnation on software maintenance such as
its fundamentals, activities and approaches, which are the focus of this thesis. In addition,
this chapter discusses reverse engineering tools, utilized by previous researches in this
area. Chapter three describes the methodology used in the logic fonn reverse engineering
approach. Chapter four describes the design and implementation of a logic-fonn reverse
engineering system. This system contains four modules: lexical analyzer module, syntax
analyzer module, handling module, and interface module. Furthermore, it describes the
method which, is used in this system that is "tree module". Chapter five discusses the
result of the implementation of the logic-fonn reverse engineering system as well as the
sample of the output, that is capable of responding to certain maintainer queries. Chapter
six provides a conclusion of the approach discussed in this thesis and evaluates the
achievements of this approach. Some suggestions for further work are also discussed at
the end of the chapter.
CHAPTER II
SOFTWARE MAINTENANCE: ACTIVITIES AND APPROACHES
Introduction
This chapter provides an overview of software maintenance system and its
relationship to the 3REs: Restructuring, Reengineering, and Reverse Engineering. It also
explains various reverse engineering tools.
Software Maintenance
Emergence of Software Maintenance
During the period between 1 950s and early 1 960s, software maintenance was
restricted to a very small part of the software life cycle. The main activity of the
programmer was to write new programs for new applications. By the end of the 1 960s
and early 1 970s, most software systems that had been written had become obsolete.
However, it was very difficult and costly to get rid of all these software system. It was
then that software maintenance emerged. Software system life cycle history can be
categorized in two stages: the development and the maintenance stages. During the
development stage, the life cycle was used as a development model whereby
development activities spread in a sequential pattern, beginning from the requirements,
8