270 likes | 280 Views
Extracting Sequence Diagram from Execution Trace of Java Program. Koji Taniguchi *, Takashi Ishio*,Toshihiro Kamiya**, Shinji Kusumoto*, Katsuro Inoue* *Osaka University, Japan **Japan Science and Technology Agency, Japan. Documents of Evolving Software.
E N D
Extracting Sequence Diagram from Execution Trace of Java Program Koji Taniguchi *, Takashi Ishio*,Toshihiro Kamiya**, Shinji Kusumoto*, Katsuro Inoue* *Osaka University, Japan **Japan Science and Technology Agency, Japan
Documents of Evolving Software • Software is being changed by fixing bugs, modifying functions or adding new functions • Owing to such changes • No documents may represent the behavior of the software correctly because the software is repeatedly changed but the documents are not updated • It makes understanding of program behavior difficult. • Especially in object oriented programs • We need reverse engineering techniques to recover some documents from a program.
Object Oriented Program Understanding • Features of Object Oriented Program • Many objects are concerned with a function • Owing to dynamic binding and extending, dynamic behavior of a program differs from static description • Message exchanges become more compress as increases of objects • It is difficult to understand dynamic behavior of objects from source codes • We need some documents that show dynamic behavior of objects
1:A 2:B 3:C 4:D 5:D Method Call Object Generation Visualizing Dynamic Behavior of Objects • UML: Sequence Diagram • It shows two kind of messages • MethodCall • Object Generation • Showing this diagram, we can understand dynamic behavior of objects • We try to extract sequence diagram by dynamic analysis of a program
A Problem of Dynamic Analysis • The amount of information of an execution trace is very huge • Because an execution trace is recorded all method calls which occurred in loop and recursive call structures. • If we show all of them in a diagram, we can not understand easily • We need a method to reduce information • We propose a method that detects some repetition patterns from execution trace and abstracts them by replacing with a representative of a repetition
How to Extract Sequence Diagram • Get the execution trace • Compact the execution trace • Draw the Sequence Diagrams from the compacted execution trace
Step1: Execution Traces • The execution trace records the two event “Enter Method” and “Exit Method” • we treat the constructor as the one kind of the method • Recorded information • When a “Enter Method” event occurred • Package name, Class name and Object-ID of a callee object • Signature of a method. • When a “Exit Method” event occurred • The method exit mark
Step2: Compaction of Execution Trace • Since an execution trace records many information, we need a method to reduce it • Our method detects some repetitions from execution trace and abstracts them by replacing with a representative of repetition • To compact the execution trace, we propose four Compaction Rules • Rules that compact some repetition patterns • R1 : Completely same repetition • R2 : Allowing different objects repetition • R3 : Lack of method calls repetition • Rule that compacts recursive calls • R4 : Recursive call structure
void C.c() void C.c() int B.b() void A.a() int B.b() void A.a() int B.b() void A.a() void C.c() 1 2 3 2 3 1 1 2 3 2 representative of the repetition Rule R1: Completely Same Repetition • R1 compacts a repetition of completely same method call structure first time of the repetition second time of the repetition
void C.c() void C.c() int B.b() void A.a() int B.b() void A.a() int B.b() void A.a() void C.c() 4 2 6 5 3 1 1,4 2,5 3,6 2 representative of the repetition Rule R2: Allowing Different Objects Repetition • R2 compacts a repetition of method call structure whose objects may be different first time of the repetition second time of the repetition
void A.a() int B.b() void C.c() void C.c() void A.a() int B.b() void C.c() void A.a() 1,4 6 3 2 2 1 3,6 4 ? 2 representative of the repetition Rule R3: Lack of Method Calls Repetition • R3 compacts a repetition of method call structure some of whose method calls may be lacked first time of the repetition second time of the repetition
int B.b() void A.a() int B.b() void A.a() void A.a() void A.a() int B.b() void A.a() int B.b() 1,2,3 6 1,2,3 4 1 4,5,6 3 2 5 R Rule R4: Recursive Call Structure • R4 compacts recursive call structure by reconstructing it to be simple • R4 also not considers object ID
Step3:Drawing Sequence Diagram • Draw a sequence diagram from a compacted execution trace • We define annotation symbols for each compaction rule • Compacted parts are drawn with them in the sequence diagram
void A.a() int B.b() 1 2 A:1 B:2 a() b() int How to draw non-compacted parts
int B.b() int B.b() void A.a() void A.a() int B.b() 2 2 1 2 1 A:1 B:2 a() b() 2 Annotation for R1 R1 2
void A.a() int B.b() int B.b() void A.a() int B.b() 1 1 3 2 2,3 2 Annotation for R2 R2 2 A:1 B:2,3 a() b()
Annotation for R3 int C.c() int C.c() int B.b() void A.a() int B.b() void A.a() int B.b() 2,3 4 3 1 2 1 4 A:1 B:2,3 C:4 a() b() 2 ?c() 2 R3 ?
Annotation for R4 int B.b() void A.a() void A.a() void A.a() int B.b() void A.a() int B.b() 1 4 2 3 1,2 1,2 3,4 R4 R ? A:1,2 B:3,4 rec a() a() rec a() b()
Case Study • Case study processes as followings • Get execution traces from four Java program • jEdit:Text Editor • Gemini:Code clone analyzer • Scheduler:Schedule management tool • LogCompactor:The module of our tool that compacts execution traces • Apply four rules to four execution traces. • The order of applying rules is R4→R1→R2→R3 • Generate Sequence Diagrams
Sequence Diagram Over View of the Diagram
Unified objects Repetition
Summary • For Object Oriented program understanding • It is necessary to understand dynamic behavior of objects. • We try to make sequence diagrams from execution trace • The amount of the program execution trace tends to be very large • We proposed a method to reduce information by compacting repetition part of the execution trace. • Draw the sequence diagram from the compacted execution trace • We can extract the simple sequence diagram that shows dynamic behavior of objects
Time Compaction (3) Method • The prot of the methods which recorded the compacted execution trace of Gemini • The execution trace of Gemini was most compacted one. • But we can see some repetition of the method calls remain. • We need the more effective compaction rules
Method calls which do not exist in the design diagram Objects which do not exist in the design