SlideShare ist ein Scribd-Unternehmen logo
1 von 43
Downloaden Sie, um offline zu lesen
Ast2Cfg - A Framework for CFG-Based Analysis
      and Visualisation of Ada Programs

    Georg Kienesberger - Vienna University of Technology


                       FOSDEM’09
Free and Open Source Software Developers’ European Meeting
           7-8 February 2009 - Brussels, Belgium




   These slides are licensed under a Creative Commons Attribution-Share Alike 3.0 Austria License. http://creativecommons.org   1
1 Overview


2 CFG and AST


3 The Software


4 Live Demonstration of Ast2Cfg, Cfg2Dot


5 Examples




                                           2
Overview




    • Control Flow Graph (CFG) used in many
      analysis/optimisation methods




                                              3
Overview




    • Control Flow Graph (CFG) used in many
      analysis/optimisation methods
    • ISO/IEC 15291:1999 - Ada Semantic Interface Specification
      (ASIS) implemented by ASIS-for-GNAT




                                                                 3
Overview




    • Control Flow Graph (CFG) used in many
      analysis/optimisation methods
    • ISO/IEC 15291:1999 - Ada Semantic Interface Specification
      (ASIS) implemented by ASIS-for-GNAT
    • traverse Abstract Syntax Tree (AST) and build CFG




                                                                 3
Overview




    • Control Flow Graph (CFG) used in many
      analysis/optimisation methods
    • ISO/IEC 15291:1999 - Ada Semantic Interface Specification
      (ASIS) implemented by ASIS-for-GNAT
    • traverse Abstract Syntax Tree (AST) and build CFG
    • Framework




                                                                 3
Control Flow Graph (CFG)




    • directed graph
    • nodes represent statements
    • There is an edge from node u to node v if v can follow u in
      some execution sequence.
    • unique start node called root or initial node




                                                                    4
Example: The Source Code

  procedure Test is
     A: array (1 .. 3) of Natural;
     S: Natural;
     K: Natural;
  begin
     A := (1,2,3);
     S := 0;
     K := A’First;

     loop
        if K <= A’Last then
           S := S + A(K);
           K := K + 1;
        else
           exit;
        end if;
     end loop;
  end Test;


                                     5
Example: The Control Flow Graph (CFG)

                         A := (1,2,3);
                         S := 0;
                         K := A’First;



                                 loop



                         if K <= A’Last



                S := S + A(K);
                                         exit;
                K := K + 1;



                   end if;



                                        end loop;
                                                    6
Example: The Control Flow Graph (CFG)

                         A := (1,2,3);
                         S := 0;
                         K := A’First;



                                 loop



                         if K <= A’Last



                S := S + A(K);
                                         exit;
                K := K + 1;



                   end if;



                                        end loop;
                                                    6
Example: The Control Flow Graph (CFG)

                         A := (1,2,3);
                         S := 0;
                         K := A’First;



                                 loop



                         if K <= A’Last



                S := S + A(K);
                                         exit;
                K := K + 1;



                   end if;



                                        end loop;
                                                    6
Example: The ASIS Abstract Syntax Tree (AST) - 1




                                                   7
Example: The ASIS Abstract Syntax Tree (AST) - 1




                                                   7
Example: The ASIS Abstract Syntax Tree (ASIS) - 2




                                                    8
Example: The ASIS Abstract Syntax Tree (ASIS) - 3




                                                    9
Example: The ASIS Abstract Syntax Tree (AST) - 4




                                                   10
The Software




    • Ast2Cfg - the framework, designed as a library
    • Cfg2Dot - uses Ast2Cfg, outputs the CFG structure in dot
      format
    • Ast2Dot - uses ASIS directly to output the AST in dot format
    • available under GPLv2 (Ast2Dot) or GPLv3 (Ast2Cfg,
      Cfg2Dot)




                                                                     11
The Structure of the Transformation Process




                                                               Transformation
                                         Pre Op




                        Traversal
    .adt




                                                                    Post
                                    Child Has Finished
    File

              AST                       Post Op
            Structure                                    CFG




                                                                                12
Flow World: The Main Data Structure




    • World Object




                                      13
Flow World: The Main Data Structure




    • World Object
    • Flow Object
        • Pkg Object
        • CFG Object
        • Node Object




                                      13
Flow World: The Main Data Structure




    • World Object
    • Flow Object
        • Pkg Object
        • CFG Object
        • Node Object
    • Pkg/CFG Tree (implicit structure)




                                          13
Example: Pkg/CFG Tree

                                     Default_PKG
                                        (body)
  procedure Outer CFG is
    package Outer Pkg is
    end Outer Pkg;
                                      Outer_CFG
    package body Outer Pkg is
                                        (body)
      package Inner Pkg is
      end Inner Pkg;
      procedure Inner CFG is
      begin                     Outer_Pkg    Outer_Pkg
      end Inner CFG;             (spec)       (body)
    end Outer Pkg;
  begin
  end Outer CFG;                      Inner_Pkg     Inner_CFG
                                        (spec)        (body)




                                                                14
Flow World: The Main Data Structure (contd.)




    • World Object
    • Flow Object
        • Pkg Object
        • CFG Object
        • Node Object
    • Pkg/CFG Tree (implicit structure)
    • Parameter Tree (saved in nodes)




                                               15
Example: Parameter Tree

                                                           Assignment Node 1.3.9:

                                                         Idents: V,FuncA,FuncA,FuncB
                                                      V(FuncA(X)) := FuncA(FuncB(0,Y));



                               Parameter Node 1.3.8:        Parameter Node 1.3.13:       Node 1.3.19:

                                   ASSIGN/LHS                   ASSIGN/RHS                CFG END

   V: array(a..b)
     of Integer;             Parameter Node 1.3.10:       Parameter Call Node 1.3.14:
                                  Variable: V                    Dest: FuncA
   V(FuncA(X)) :=                 IDX/COMP                  FUNC/PARAM/ROOT
     FuncA(FuncB(0,Y));

                          Parameter Call Node 1.3.11:      Parameter Call Node 1.3.16:
                                 Dest: FuncA                      Dest: FuncB
                            FUNC/PARAM/ROOT                  FUNC/PARAM/ROOT



                            Parameter Node 1.3.12:         Parameter Node 1.3.17:        Parameter Node 1.3.18:
                                 Variable: X                                                  Variable: Y
                               PARAM/NODE                     PARAM/NODE                    PARAM/NODE




                                                                                                                  16
Flow Types: An Overview

                      Flow Object




     CFG Object       Node Object   Pkg Object


         .
         .                 .
                           .            .
                                        .
         .                 .            .




                                        abstract
                                        concrete

                                                   17
Flow Types: Package


                      Pkg Object




      Body Object                  Spec Object


         Def Object                Simple Spec Object


      Simple Body Object              Gen Object


        Prot Object                Single Prot Object
                                                        abstract
                                   Prot Type Object
                                                        concrete




                                                                   18
Flow Types: CFG

                         CFG Object




           Body Object                Spec Object


             Abort Object              Generic Object


             Block Object             Task Type Object


             Entry Object             Single Task Object


            Except Object


             Func Object


             Init Object


             Proc Object
                                                           abstract
             Task Object
                                                           concrete

                                                                      19
Flow Types: Node

     Node Object

                                          Return Node Object
     Call Node Object

                                          Terminate Node Object
       Accept Node Object

                                          Param Node Object
       Entry Call Node Object

                                          Param Alloc Node Object
       Abort Node Object

                                          Loop Node Object
       Param Call Node Object

                                            Finite Loop Node Object
     Jump Node Object

                                            Infinite Loop Node Object
       Goto Jump Node Object

                                          Assign Node Object
       Exit Jump Node Object

                                          Branch Node Object
          Trivial Exit Jump Node Object


          Complex Exit Jump Node Object
                                                                        abstract
                                                                        concrete
                                                                                   20
Usage

  with Ada.Text IO; use Ada.Text IO; with Ast2Cfg.Pkgs; use Ast2Cfg.Pkgs;
  with Ast2Cfg.Control; with Ast2Cfg.Flow World; with Ast2Cfg.Output;
  procedure Run is
          World: Ast2Cfg.Flow World.World Object Ptr;
          Pkgs: Pkg Class Ptr List.Object;
          Pkg: Pkg Class Ptr := null;
  begin
          -- Initialisations
          Ast2Cfg.Output.Set Level(Ast2Cfg.Output.Warning);
          Ast2Cfg.Control.Init("−CN foo.adt bar.adt");
          -- Fill the World with flow data
          World := Ast2Cfg.Control.Generate;

         -- Output the name of all top-level packages
         Pkgs := Ast2Cfg.Flow World.Get Pkgs(World.all);
         Pkg Class Ptr List.Reset(Pkgs);
         while Pkg Class Ptr List.Has Next(Pkgs) loop
                 Pkg Class Ptr List.Get Next(Pkgs, Pkg);
                 Put Line(Get Name(Pkg.all));
         end loop;

          -- Finalisation
          Ast2Cfg.Control.Final;
  end Run;


                                                                       21
Excursus on the Command Line




                               22
Examples: If Statement

                                                                                       Branch Node 1.2.5:

                                                                                             if/case



                                                                           Node 1.2.7:
                                                                                                          Node 1.2.14:
                                                                             Idents: >
                                                                                                         elsif (false) then
                                                                         if (X>10) then

   if (X>10) then
     null;                                       Parameter Node 1.2.8:     Node 1.2.12:                  Node 1.2.16:
   elsif (false) then
     null;                                           STMT/PAR                  null;                          null;
   end if;

                                            Parameter Call Node 1.2.9:                    Node 1.2.6:
                                                     Dest: >
                                             FUNC/PARAM/ROOT                               end if/case



                        Parameter Node 1.2.10:        Parameter Node 1.2.11:              Node 1.2.18:
                             Variable: X
                           PARAM/NODE                    PARAM/NODE                        CFG END




                                                                                                                              23
Examples: Case Statement
                                                       Branch Node 1.3.9:

                                                             Name: Start
                                                              Idents: X
                                                               if/case



                           Node 1.3.11:        Node 1.3.15:
                                                                     Node 1.3.19:
                            Idents: A            Idents: B
  <<Start> case X is
          >                                                         when others =>
                           when A =>            when B =>
    when A =>
      null;
    when B =>                                                              Goto Jump Node 1.3.23:
      null;                Node 1.3.13:        Node 1.3.17:
                                                                                 Target: Start
    when others =>                                                               Idents: Start
      goto Start;             null;                  null;
                                                                                  goto Start;
  end case;

                                      Node 1.3.10:

                                       end if/case



                                      Node 1.3.24:

                                       CFG END

                                                                                                    24
Examples: Loop Statement

                                                   Infinite Loop Node 1.6.12:

                                                         Name: Loop1
                                                         Loop1: loop



                                              Call Node 1.6.15:
                                               Dest: Increment
                                              Idents: Increment
                                                Increment(X);

  Loop1: loop
    Increment(X);                                          C-Exit Jump Node 1.6.20:
    exit Loop1          Parameter Call Node 1.6.16:
                                                                 Target: Loop1
      when Condition;        Dest: Increment
                                                            Idents: Loop1,Condition
  end loop Loop1;         PROC/PARAM/ROOT
                                                          exit Loop1 when Condition;



                          Parameter Node 1.6.17:         Parameter Node 1.6.19:        Node 1.6.22:
                               Variable: X
                             PARAM/NODE                        STMT/PAR                 Loop End



                                                      Parameter Call Node 1.6.21:      Node 1.6.23:
                                                           Dest: Condition
                                                        FUNC/PARAM/ROOT                 CFG END



                                                                                                      25
Examples: A few words on the word static


                                         Infinite Loop Node 1.1.5:

                                                   loop

   procedure Not A Loop is
      I: Integer := 0;
   begin                                  T-Exit Jump Node 1.1.8:

      loop                                         exit;
         exit;
         I := I + 1;
      end loop;
                                               Node 1.1.16:
   end Not A Loop;
                                                Loop End



                                               Node 1.1.17:

                                                CFG END

   not a loop.adb:7:09: warning: unreachable code
                                                                     26
Examples: A few words on the word static (2)

                                       Infinite Loop Node 1.1.5:

                                                   loop



                                                   C-Exit Jump Node 1.1.8:
   procedure Not A Loop 2 is
      I: Integer := 10;                                   Idents: >=
   begin
                                                      exit when I >= 10;
      loop
         exit when I >= 10;
         I := I + 1;
      end loop;                Assignment Node 1.1.14:
                                                              Node 1.1.19:
   end Not A Loop 2;                 Idents: I,+
                                                                Loop End
                                     I := I + 1;



                                                              Node 1.1.20:

                                                               CFG END


                                                                             27
Examples: Tasks
                                                                     Node 1.3.1:

                                                                        select/acc



                                                                                     Node 1.4.4:
  −− Caller Object                                        Node 1.3.4:
  Task Object.Entry1;                                                          Idents: Condition
                                                            select
                            Entry Call Node1.6.7:                                      or
  −− Called Object        Dest: Task_Object.Entry1
  select                 Idents: Task_Object.Entry1
    accept Entry1 do        Task_Object.Entry1;
      null;                                           Accept Node1.3.8:         Accept Node1.4.8:
    end Entry1;                                       Dest: CFG[1.4.0]          Dest: CFG[1.5.0]
  or                                                   accept Entry1 do          accept Entry2 do
    when Condition =>           Node 1.6.9:
      accept Entry2 do
         null;                  CFG END
      end Entry2;                                                    Node 1.3.3:
  end select;
                                                                        end select



                                                                     Node 1.5.4:

                                                                        CFG END

                                                                                                    28
Examples: Protected Objects


   package body Prot Pkg is
                                         Prot_Pkg
    protected body                         (body)
      Prot Type is                       --VARS--                          Entry Call Node2.2.3:
                                 Prot_Obj: {ST: Prot_Type}                 Dest: Prot_Obj.Entry1
       entry Entry1                                                       Idents: Prot_Obj.Entry1
         (A: in Integer)                                                    Prot_Obj.Entry1(0);
         when True is
         begin                   Prot_Type       Init_CFG
                                   (body)          (body)    Parameter Call Node 2.2.4:     Node 2.2.6:
           null;                                               Dest: Prot_Obj.Entry1
         end Entry1;                                           PROC/PARAM/ROOT              CFG END

      end Prot Type;
                                  Entry1                       Parameter Node 2.2.5:
     Prot Obj: Prot Type;         (body)
                               --PARAMS--                         PARAM/NODE
   begin                      A: {ST: Integer}
     Prot Obj.Entry1(0);
   end Prot Pkg;




                                                                                                          29
Examples: Types
                                              Types
                                              (spec)
                                           --TYPES--
                                          Rec_Type_0
                                       [COMPONENTS]
                                         F: {CT: Float}
                                       B: {CT: Boolean}
   package Types is               Rec_Type_1 {ST: Rec_Type_0}

    type Rec Type 0 is
      tagged                                    F
       record                                 INIT
         F: Float := abs(3.14);
         B: Boolean;
       end record;
                                      Parameter Node 1.0.2:

    type Rec Type 1 is                     INIT/NODE
      new Rec Type 0
      with null record;
                                    Parameter Call Node 1.0.4:
   end Types;                               Dest: abs
                                     FUNC/PARAM/ROOT



                                      Parameter Node 1.0.5:

                                         PARAM/NODE


                                                                 30
Further Information & Downloads


    • http://cfg.w3x.org
    • For comments, bug reports and feature requests please
      contact us:
        • cfg@w3x.org




                                                              31
Further Information & Downloads


    • http://cfg.w3x.org
    • For comments, bug reports and feature requests please
        contact us:
           • cfg@w3x.org
    •   Raul Fechete and Georg Kienesberger. Generating control flow graphs for Ada
        programs. Technical Report 183/1-139, Department of Automation, TU
        Vienna, September 2007.




                                                                                     31
Further Information & Downloads


    • http://cfg.w3x.org
    • For comments, bug reports and feature requests please
        contact us:
           • cfg@w3x.org
    •   Raul Fechete and Georg Kienesberger. Generating control flow graphs for Ada
        programs. Technical Report 183/1-139, Department of Automation, TU
        Vienna, September 2007.

    •   Raul Fechete, Georg Kienesberger, and Johann Blieberger. A Framework for
        CFG-based Static Program Analysis of Ada Programs. In Ada-Europe’2008
        International Conference on Reliable Software Technologies, pages 130-143,
        Venice, Italy, June 2008.




                                                                                     31
Further Information & Downloads


    • http://cfg.w3x.org
    • For comments, bug reports and feature requests please
        contact us:
           • cfg@w3x.org
    •   Raul Fechete and Georg Kienesberger. Generating control flow graphs for Ada
        programs. Technical Report 183/1-139, Department of Automation, TU
        Vienna, September 2007.

    •   Raul Fechete, Georg Kienesberger, and Johann Blieberger. A Framework for
        CFG-based Static Program Analysis of Ada Programs. In Ada-Europe’2008
        International Conference on Reliable Software Technologies, pages 130-143,
        Venice, Italy, June 2008.

    • updated documentation in the next few months



                                                                                     31
The End

                     Thank you very much!


                                  Any questions?


                                         http://cfg.w3x.org


      These slides are licensed under a Creative Commons Attribution-Share Alike 3.0 Austria License. http://creativecommons.org

                                                                                                                                   32

Weitere ähnliche Inhalte

Was ist angesagt?

Advanced computer architecture
Advanced computer architectureAdvanced computer architecture
Advanced computer architectureMd. Mahedi Mahfuj
 
GeneIndex: an open source parallel program for enumerating and locating words...
GeneIndex: an open source parallel program for enumerating and locating words...GeneIndex: an open source parallel program for enumerating and locating words...
GeneIndex: an open source parallel program for enumerating and locating words...PTIHPA
 
Push down automata
Push down automataPush down automata
Push down automataSomya Bagai
 
Logical Instructions used in 8086 microprocessor
Logical Instructions used in 8086 microprocessorLogical Instructions used in 8086 microprocessor
Logical Instructions used in 8086 microprocessorRabin BK
 
Re-engineering Eclipse MDT/OCL for Xtext
Re-engineering Eclipse MDT/OCL for XtextRe-engineering Eclipse MDT/OCL for Xtext
Re-engineering Eclipse MDT/OCL for XtextEdward Willink
 
Ridge-based Profiled Differential Power Analysis
Ridge-based Profiled Differential Power AnalysisRidge-based Profiled Differential Power Analysis
Ridge-based Profiled Differential Power AnalysisPriyanka Aash
 
TMPA-2017: Modeling of PLC-programs by High-level Coloured Petri Nets
TMPA-2017: Modeling of PLC-programs by High-level Coloured Petri NetsTMPA-2017: Modeling of PLC-programs by High-level Coloured Petri Nets
TMPA-2017: Modeling of PLC-programs by High-level Coloured Petri NetsIosif Itkin
 
Range Extended Second Order Digital Phase Locked Loop
Range Extended Second Order Digital Phase Locked LoopRange Extended Second Order Digital Phase Locked Loop
Range Extended Second Order Digital Phase Locked LoopIDES Editor
 
8086 Microprocessor Instruction set
8086 Microprocessor Instruction set8086 Microprocessor Instruction set
8086 Microprocessor Instruction setVijay Kumar
 
Multiplication & division instructions microprocessor 8086
Multiplication & division instructions microprocessor 8086Multiplication & division instructions microprocessor 8086
Multiplication & division instructions microprocessor 8086University of Gujrat, Pakistan
 
1344 Alp Of 8086
1344 Alp Of 80861344 Alp Of 8086
1344 Alp Of 8086techbed
 
Integrating R with C++: Rcpp, RInside and RProtoBuf
Integrating R with C++: Rcpp, RInside and RProtoBufIntegrating R with C++: Rcpp, RInside and RProtoBuf
Integrating R with C++: Rcpp, RInside and RProtoBufRomain Francois
 
Liszt los alamos national laboratory Aug 2011
Liszt los alamos national laboratory Aug 2011Liszt los alamos national laboratory Aug 2011
Liszt los alamos national laboratory Aug 2011Ed Dodds
 
Vortex Dissipation Due to Airfoil-Vortex Interaction
Vortex Dissipation Due to Airfoil-Vortex InteractionVortex Dissipation Due to Airfoil-Vortex Interaction
Vortex Dissipation Due to Airfoil-Vortex InteractionMasahiro Kanazaki
 

Was ist angesagt? (20)

Advanced computer architecture
Advanced computer architectureAdvanced computer architecture
Advanced computer architecture
 
Pda
PdaPda
Pda
 
GeneIndex: an open source parallel program for enumerating and locating words...
GeneIndex: an open source parallel program for enumerating and locating words...GeneIndex: an open source parallel program for enumerating and locating words...
GeneIndex: an open source parallel program for enumerating and locating words...
 
Push down automata
Push down automataPush down automata
Push down automata
 
Logical Instructions used in 8086 microprocessor
Logical Instructions used in 8086 microprocessorLogical Instructions used in 8086 microprocessor
Logical Instructions used in 8086 microprocessor
 
optimization c code on blackfin
optimization c code on blackfinoptimization c code on blackfin
optimization c code on blackfin
 
Exploring Petri Net State Spaces
Exploring Petri Net State SpacesExploring Petri Net State Spaces
Exploring Petri Net State Spaces
 
Re-engineering Eclipse MDT/OCL for Xtext
Re-engineering Eclipse MDT/OCL for XtextRe-engineering Eclipse MDT/OCL for Xtext
Re-engineering Eclipse MDT/OCL for Xtext
 
Ridge-based Profiled Differential Power Analysis
Ridge-based Profiled Differential Power AnalysisRidge-based Profiled Differential Power Analysis
Ridge-based Profiled Differential Power Analysis
 
TMPA-2017: Modeling of PLC-programs by High-level Coloured Petri Nets
TMPA-2017: Modeling of PLC-programs by High-level Coloured Petri NetsTMPA-2017: Modeling of PLC-programs by High-level Coloured Petri Nets
TMPA-2017: Modeling of PLC-programs by High-level Coloured Petri Nets
 
Range Extended Second Order Digital Phase Locked Loop
Range Extended Second Order Digital Phase Locked LoopRange Extended Second Order Digital Phase Locked Loop
Range Extended Second Order Digital Phase Locked Loop
 
8086 Microprocessor Instruction set
8086 Microprocessor Instruction set8086 Microprocessor Instruction set
8086 Microprocessor Instruction set
 
[ASM]Lab4
[ASM]Lab4[ASM]Lab4
[ASM]Lab4
 
Multiplication & division instructions microprocessor 8086
Multiplication & division instructions microprocessor 8086Multiplication & division instructions microprocessor 8086
Multiplication & division instructions microprocessor 8086
 
A petri-net
A petri-netA petri-net
A petri-net
 
1344 Alp Of 8086
1344 Alp Of 80861344 Alp Of 8086
1344 Alp Of 8086
 
Integrating R with C++: Rcpp, RInside and RProtoBuf
Integrating R with C++: Rcpp, RInside and RProtoBufIntegrating R with C++: Rcpp, RInside and RProtoBuf
Integrating R with C++: Rcpp, RInside and RProtoBuf
 
Liszt los alamos national laboratory Aug 2011
Liszt los alamos national laboratory Aug 2011Liszt los alamos national laboratory Aug 2011
Liszt los alamos national laboratory Aug 2011
 
MSc_thesis
MSc_thesisMSc_thesis
MSc_thesis
 
Vortex Dissipation Due to Airfoil-Vortex Interaction
Vortex Dissipation Due to Airfoil-Vortex InteractionVortex Dissipation Due to Airfoil-Vortex Interaction
Vortex Dissipation Due to Airfoil-Vortex Interaction
 

Andere mochten auch

Andere mochten auch (7)

Developing Software that Matters (condensed)
Developing Software that Matters (condensed)Developing Software that Matters (condensed)
Developing Software that Matters (condensed)
 
Ada 95 - Distributed systems
Ada 95 - Distributed systemsAda 95 - Distributed systems
Ada 95 - Distributed systems
 
Programming Languages and Software Construction
Programming Languages and Software ConstructionProgramming Languages and Software Construction
Programming Languages and Software Construction
 
SIGAda Hibachi Workshop Presentation
SIGAda Hibachi Workshop PresentationSIGAda Hibachi Workshop Presentation
SIGAda Hibachi Workshop Presentation
 
Ada at Barco avionics
Ada at Barco avionicsAda at Barco avionics
Ada at Barco avionics
 
Turing machine
Turing machineTuring machine
Turing machine
 
Turing machine by_deep
Turing machine by_deepTuring machine by_deep
Turing machine by_deep
 

Ähnlich wie Ast2Cfg - A Framework for CFG-Based Analysis and Visualisation of Ada Programs

Blocks & GCD
Blocks & GCDBlocks & GCD
Blocks & GCDrsebbe
 
design-compiler.pdf
design-compiler.pdfdesign-compiler.pdf
design-compiler.pdfFrangoCamila
 
Digital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECEDigital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECERamesh Naik Bhukya
 
Start Wrap Episode 11: A New Rope
Start Wrap Episode 11: A New RopeStart Wrap Episode 11: A New Rope
Start Wrap Episode 11: A New RopeYung-Yu Chen
 
Atmosphere Conference 2015: Need for Async: In pursuit of scalable internet-s...
Atmosphere Conference 2015: Need for Async: In pursuit of scalable internet-s...Atmosphere Conference 2015: Need for Async: In pursuit of scalable internet-s...
Atmosphere Conference 2015: Need for Async: In pursuit of scalable internet-s...PROIDEA
 
How it's made: C++ compilers (GCC)
How it's made: C++ compilers (GCC)How it's made: C++ compilers (GCC)
How it's made: C++ compilers (GCC)Sławomir Zborowski
 
The State of Lightweight Threads for the JVM
The State of Lightweight Threads for the JVMThe State of Lightweight Threads for the JVM
The State of Lightweight Threads for the JVMVolkan Yazıcı
 
Bolt C++ Standard Template Libary for HSA by Ben Sanders, AMD
Bolt C++ Standard Template Libary for HSA  by Ben Sanders, AMDBolt C++ Standard Template Libary for HSA  by Ben Sanders, AMD
Bolt C++ Standard Template Libary for HSA by Ben Sanders, AMDHSA Foundation
 
The Need for Async @ ScalaWorld
The Need for Async @ ScalaWorldThe Need for Async @ ScalaWorld
The Need for Async @ ScalaWorldKonrad Malawski
 
A whirlwind tour of the LLVM optimizer
A whirlwind tour of the LLVM optimizerA whirlwind tour of the LLVM optimizer
A whirlwind tour of the LLVM optimizerNikita Popov
 
Graal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT CompilerGraal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT CompilerKoichi Sakata
 
Java/Scala Lab: Руслан Шевченко - Implementation of CSP (Communication Sequen...
Java/Scala Lab: Руслан Шевченко - Implementation of CSP (Communication Sequen...Java/Scala Lab: Руслан Шевченко - Implementation of CSP (Communication Sequen...
Java/Scala Lab: Руслан Шевченко - Implementation of CSP (Communication Sequen...GeeksLab Odessa
 
CLaSH HIW 2014
CLaSH HIW 2014CLaSH HIW 2014
CLaSH HIW 2014baaijcpr
 
Integrating Cache Oblivious Approach with Modern Processor Architecture: The ...
Integrating Cache Oblivious Approach with Modern Processor Architecture: The ...Integrating Cache Oblivious Approach with Modern Processor Architecture: The ...
Integrating Cache Oblivious Approach with Modern Processor Architecture: The ...Tokyo Institute of Technology
 
Memory Management with Java and C++
Memory Management with Java and C++Memory Management with Java and C++
Memory Management with Java and C++Mohammad Shaker
 
Building Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCCBuilding Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCCKernel TLV
 
Practical file
Practical filePractical file
Practical filerajeevkr35
 

Ähnlich wie Ast2Cfg - A Framework for CFG-Based Analysis and Visualisation of Ada Programs (20)

Blocks & GCD
Blocks & GCDBlocks & GCD
Blocks & GCD
 
design-compiler.pdf
design-compiler.pdfdesign-compiler.pdf
design-compiler.pdf
 
Digital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECEDigital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECE
 
Start Wrap Episode 11: A New Rope
Start Wrap Episode 11: A New RopeStart Wrap Episode 11: A New Rope
Start Wrap Episode 11: A New Rope
 
Atmosphere Conference 2015: Need for Async: In pursuit of scalable internet-s...
Atmosphere Conference 2015: Need for Async: In pursuit of scalable internet-s...Atmosphere Conference 2015: Need for Async: In pursuit of scalable internet-s...
Atmosphere Conference 2015: Need for Async: In pursuit of scalable internet-s...
 
How it's made: C++ compilers (GCC)
How it's made: C++ compilers (GCC)How it's made: C++ compilers (GCC)
How it's made: C++ compilers (GCC)
 
The State of Lightweight Threads for the JVM
The State of Lightweight Threads for the JVMThe State of Lightweight Threads for the JVM
The State of Lightweight Threads for the JVM
 
Bolt C++ Standard Template Libary for HSA by Ben Sanders, AMD
Bolt C++ Standard Template Libary for HSA  by Ben Sanders, AMDBolt C++ Standard Template Libary for HSA  by Ben Sanders, AMD
Bolt C++ Standard Template Libary for HSA by Ben Sanders, AMD
 
The Need for Async @ ScalaWorld
The Need for Async @ ScalaWorldThe Need for Async @ ScalaWorld
The Need for Async @ ScalaWorld
 
verilog ppt .pdf
verilog ppt .pdfverilog ppt .pdf
verilog ppt .pdf
 
A whirlwind tour of the LLVM optimizer
A whirlwind tour of the LLVM optimizerA whirlwind tour of the LLVM optimizer
A whirlwind tour of the LLVM optimizer
 
Graal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT CompilerGraal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT Compiler
 
15757597 (1).ppt
15757597 (1).ppt15757597 (1).ppt
15757597 (1).ppt
 
Java/Scala Lab: Руслан Шевченко - Implementation of CSP (Communication Sequen...
Java/Scala Lab: Руслан Шевченко - Implementation of CSP (Communication Sequen...Java/Scala Lab: Руслан Шевченко - Implementation of CSP (Communication Sequen...
Java/Scala Lab: Руслан Шевченко - Implementation of CSP (Communication Sequen...
 
CLaSH HIW 2014
CLaSH HIW 2014CLaSH HIW 2014
CLaSH HIW 2014
 
Integrating Cache Oblivious Approach with Modern Processor Architecture: The ...
Integrating Cache Oblivious Approach with Modern Processor Architecture: The ...Integrating Cache Oblivious Approach with Modern Processor Architecture: The ...
Integrating Cache Oblivious Approach with Modern Processor Architecture: The ...
 
Alfonso Senatore
Alfonso SenatoreAlfonso Senatore
Alfonso Senatore
 
Memory Management with Java and C++
Memory Management with Java and C++Memory Management with Java and C++
Memory Management with Java and C++
 
Building Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCCBuilding Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCC
 
Practical file
Practical filePractical file
Practical file
 

Mehr von Gneuromante canalada.org (9)

Ada 95 - Programming in the large
Ada 95 - Programming in the largeAda 95 - Programming in the large
Ada 95 - Programming in the large
 
Ada 95 - Object orientation
Ada 95 - Object orientationAda 95 - Object orientation
Ada 95 - Object orientation
 
Ada 95 - Structured programming
Ada 95 - Structured programmingAda 95 - Structured programming
Ada 95 - Structured programming
 
Ada 95 - Introduction
Ada 95 - IntroductionAda 95 - Introduction
Ada 95 - Introduction
 
Ada 95 - Generics
Ada 95 - GenericsAda 95 - Generics
Ada 95 - Generics
 
Developing Software That Matters I
Developing Software That Matters IDeveloping Software That Matters I
Developing Software That Matters I
 
Developing Software that Matters II
Developing Software that Matters IIDeveloping Software that Matters II
Developing Software that Matters II
 
Introduction to Ada
Introduction to AdaIntroduction to Ada
Introduction to Ada
 
Ada in Debian GNU/Linux
Ada in Debian GNU/LinuxAda in Debian GNU/Linux
Ada in Debian GNU/Linux
 

Kürzlich hochgeladen

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 

Kürzlich hochgeladen (20)

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 

Ast2Cfg - A Framework for CFG-Based Analysis and Visualisation of Ada Programs

  • 1. Ast2Cfg - A Framework for CFG-Based Analysis and Visualisation of Ada Programs Georg Kienesberger - Vienna University of Technology FOSDEM’09 Free and Open Source Software Developers’ European Meeting 7-8 February 2009 - Brussels, Belgium These slides are licensed under a Creative Commons Attribution-Share Alike 3.0 Austria License. http://creativecommons.org 1
  • 2. 1 Overview 2 CFG and AST 3 The Software 4 Live Demonstration of Ast2Cfg, Cfg2Dot 5 Examples 2
  • 3. Overview • Control Flow Graph (CFG) used in many analysis/optimisation methods 3
  • 4. Overview • Control Flow Graph (CFG) used in many analysis/optimisation methods • ISO/IEC 15291:1999 - Ada Semantic Interface Specification (ASIS) implemented by ASIS-for-GNAT 3
  • 5. Overview • Control Flow Graph (CFG) used in many analysis/optimisation methods • ISO/IEC 15291:1999 - Ada Semantic Interface Specification (ASIS) implemented by ASIS-for-GNAT • traverse Abstract Syntax Tree (AST) and build CFG 3
  • 6. Overview • Control Flow Graph (CFG) used in many analysis/optimisation methods • ISO/IEC 15291:1999 - Ada Semantic Interface Specification (ASIS) implemented by ASIS-for-GNAT • traverse Abstract Syntax Tree (AST) and build CFG • Framework 3
  • 7. Control Flow Graph (CFG) • directed graph • nodes represent statements • There is an edge from node u to node v if v can follow u in some execution sequence. • unique start node called root or initial node 4
  • 8. Example: The Source Code procedure Test is A: array (1 .. 3) of Natural; S: Natural; K: Natural; begin A := (1,2,3); S := 0; K := A’First; loop if K <= A’Last then S := S + A(K); K := K + 1; else exit; end if; end loop; end Test; 5
  • 9. Example: The Control Flow Graph (CFG) A := (1,2,3); S := 0; K := A’First; loop if K <= A’Last S := S + A(K); exit; K := K + 1; end if; end loop; 6
  • 10. Example: The Control Flow Graph (CFG) A := (1,2,3); S := 0; K := A’First; loop if K <= A’Last S := S + A(K); exit; K := K + 1; end if; end loop; 6
  • 11. Example: The Control Flow Graph (CFG) A := (1,2,3); S := 0; K := A’First; loop if K <= A’Last S := S + A(K); exit; K := K + 1; end if; end loop; 6
  • 12. Example: The ASIS Abstract Syntax Tree (AST) - 1 7
  • 13. Example: The ASIS Abstract Syntax Tree (AST) - 1 7
  • 14. Example: The ASIS Abstract Syntax Tree (ASIS) - 2 8
  • 15. Example: The ASIS Abstract Syntax Tree (ASIS) - 3 9
  • 16. Example: The ASIS Abstract Syntax Tree (AST) - 4 10
  • 17. The Software • Ast2Cfg - the framework, designed as a library • Cfg2Dot - uses Ast2Cfg, outputs the CFG structure in dot format • Ast2Dot - uses ASIS directly to output the AST in dot format • available under GPLv2 (Ast2Dot) or GPLv3 (Ast2Cfg, Cfg2Dot) 11
  • 18. The Structure of the Transformation Process Transformation Pre Op Traversal .adt Post Child Has Finished File AST Post Op Structure CFG 12
  • 19. Flow World: The Main Data Structure • World Object 13
  • 20. Flow World: The Main Data Structure • World Object • Flow Object • Pkg Object • CFG Object • Node Object 13
  • 21. Flow World: The Main Data Structure • World Object • Flow Object • Pkg Object • CFG Object • Node Object • Pkg/CFG Tree (implicit structure) 13
  • 22. Example: Pkg/CFG Tree Default_PKG (body) procedure Outer CFG is package Outer Pkg is end Outer Pkg; Outer_CFG package body Outer Pkg is (body) package Inner Pkg is end Inner Pkg; procedure Inner CFG is begin Outer_Pkg Outer_Pkg end Inner CFG; (spec) (body) end Outer Pkg; begin end Outer CFG; Inner_Pkg Inner_CFG (spec) (body) 14
  • 23. Flow World: The Main Data Structure (contd.) • World Object • Flow Object • Pkg Object • CFG Object • Node Object • Pkg/CFG Tree (implicit structure) • Parameter Tree (saved in nodes) 15
  • 24. Example: Parameter Tree Assignment Node 1.3.9: Idents: V,FuncA,FuncA,FuncB V(FuncA(X)) := FuncA(FuncB(0,Y)); Parameter Node 1.3.8: Parameter Node 1.3.13: Node 1.3.19: ASSIGN/LHS ASSIGN/RHS CFG END V: array(a..b) of Integer; Parameter Node 1.3.10: Parameter Call Node 1.3.14: Variable: V Dest: FuncA V(FuncA(X)) := IDX/COMP FUNC/PARAM/ROOT FuncA(FuncB(0,Y)); Parameter Call Node 1.3.11: Parameter Call Node 1.3.16: Dest: FuncA Dest: FuncB FUNC/PARAM/ROOT FUNC/PARAM/ROOT Parameter Node 1.3.12: Parameter Node 1.3.17: Parameter Node 1.3.18: Variable: X Variable: Y PARAM/NODE PARAM/NODE PARAM/NODE 16
  • 25. Flow Types: An Overview Flow Object CFG Object Node Object Pkg Object . . . . . . . . . abstract concrete 17
  • 26. Flow Types: Package Pkg Object Body Object Spec Object Def Object Simple Spec Object Simple Body Object Gen Object Prot Object Single Prot Object abstract Prot Type Object concrete 18
  • 27. Flow Types: CFG CFG Object Body Object Spec Object Abort Object Generic Object Block Object Task Type Object Entry Object Single Task Object Except Object Func Object Init Object Proc Object abstract Task Object concrete 19
  • 28. Flow Types: Node Node Object Return Node Object Call Node Object Terminate Node Object Accept Node Object Param Node Object Entry Call Node Object Param Alloc Node Object Abort Node Object Loop Node Object Param Call Node Object Finite Loop Node Object Jump Node Object Infinite Loop Node Object Goto Jump Node Object Assign Node Object Exit Jump Node Object Branch Node Object Trivial Exit Jump Node Object Complex Exit Jump Node Object abstract concrete 20
  • 29. Usage with Ada.Text IO; use Ada.Text IO; with Ast2Cfg.Pkgs; use Ast2Cfg.Pkgs; with Ast2Cfg.Control; with Ast2Cfg.Flow World; with Ast2Cfg.Output; procedure Run is World: Ast2Cfg.Flow World.World Object Ptr; Pkgs: Pkg Class Ptr List.Object; Pkg: Pkg Class Ptr := null; begin -- Initialisations Ast2Cfg.Output.Set Level(Ast2Cfg.Output.Warning); Ast2Cfg.Control.Init("−CN foo.adt bar.adt"); -- Fill the World with flow data World := Ast2Cfg.Control.Generate; -- Output the name of all top-level packages Pkgs := Ast2Cfg.Flow World.Get Pkgs(World.all); Pkg Class Ptr List.Reset(Pkgs); while Pkg Class Ptr List.Has Next(Pkgs) loop Pkg Class Ptr List.Get Next(Pkgs, Pkg); Put Line(Get Name(Pkg.all)); end loop; -- Finalisation Ast2Cfg.Control.Final; end Run; 21
  • 30. Excursus on the Command Line 22
  • 31. Examples: If Statement Branch Node 1.2.5: if/case Node 1.2.7: Node 1.2.14: Idents: > elsif (false) then if (X>10) then if (X>10) then null; Parameter Node 1.2.8: Node 1.2.12: Node 1.2.16: elsif (false) then null; STMT/PAR null; null; end if; Parameter Call Node 1.2.9: Node 1.2.6: Dest: > FUNC/PARAM/ROOT end if/case Parameter Node 1.2.10: Parameter Node 1.2.11: Node 1.2.18: Variable: X PARAM/NODE PARAM/NODE CFG END 23
  • 32. Examples: Case Statement Branch Node 1.3.9: Name: Start Idents: X if/case Node 1.3.11: Node 1.3.15: Node 1.3.19: Idents: A Idents: B <<Start> case X is > when others => when A => when B => when A => null; when B => Goto Jump Node 1.3.23: null; Node 1.3.13: Node 1.3.17: Target: Start when others => Idents: Start goto Start; null; null; goto Start; end case; Node 1.3.10: end if/case Node 1.3.24: CFG END 24
  • 33. Examples: Loop Statement Infinite Loop Node 1.6.12: Name: Loop1 Loop1: loop Call Node 1.6.15: Dest: Increment Idents: Increment Increment(X); Loop1: loop Increment(X); C-Exit Jump Node 1.6.20: exit Loop1 Parameter Call Node 1.6.16: Target: Loop1 when Condition; Dest: Increment Idents: Loop1,Condition end loop Loop1; PROC/PARAM/ROOT exit Loop1 when Condition; Parameter Node 1.6.17: Parameter Node 1.6.19: Node 1.6.22: Variable: X PARAM/NODE STMT/PAR Loop End Parameter Call Node 1.6.21: Node 1.6.23: Dest: Condition FUNC/PARAM/ROOT CFG END 25
  • 34. Examples: A few words on the word static Infinite Loop Node 1.1.5: loop procedure Not A Loop is I: Integer := 0; begin T-Exit Jump Node 1.1.8: loop exit; exit; I := I + 1; end loop; Node 1.1.16: end Not A Loop; Loop End Node 1.1.17: CFG END not a loop.adb:7:09: warning: unreachable code 26
  • 35. Examples: A few words on the word static (2) Infinite Loop Node 1.1.5: loop C-Exit Jump Node 1.1.8: procedure Not A Loop 2 is I: Integer := 10; Idents: >= begin exit when I >= 10; loop exit when I >= 10; I := I + 1; end loop; Assignment Node 1.1.14: Node 1.1.19: end Not A Loop 2; Idents: I,+ Loop End I := I + 1; Node 1.1.20: CFG END 27
  • 36. Examples: Tasks Node 1.3.1: select/acc Node 1.4.4: −− Caller Object Node 1.3.4: Task Object.Entry1; Idents: Condition select Entry Call Node1.6.7: or −− Called Object Dest: Task_Object.Entry1 select Idents: Task_Object.Entry1 accept Entry1 do Task_Object.Entry1; null; Accept Node1.3.8: Accept Node1.4.8: end Entry1; Dest: CFG[1.4.0] Dest: CFG[1.5.0] or accept Entry1 do accept Entry2 do when Condition => Node 1.6.9: accept Entry2 do null; CFG END end Entry2; Node 1.3.3: end select; end select Node 1.5.4: CFG END 28
  • 37. Examples: Protected Objects package body Prot Pkg is Prot_Pkg protected body (body) Prot Type is --VARS-- Entry Call Node2.2.3: Prot_Obj: {ST: Prot_Type} Dest: Prot_Obj.Entry1 entry Entry1 Idents: Prot_Obj.Entry1 (A: in Integer) Prot_Obj.Entry1(0); when True is begin Prot_Type Init_CFG (body) (body) Parameter Call Node 2.2.4: Node 2.2.6: null; Dest: Prot_Obj.Entry1 end Entry1; PROC/PARAM/ROOT CFG END end Prot Type; Entry1 Parameter Node 2.2.5: Prot Obj: Prot Type; (body) --PARAMS-- PARAM/NODE begin A: {ST: Integer} Prot Obj.Entry1(0); end Prot Pkg; 29
  • 38. Examples: Types Types (spec) --TYPES-- Rec_Type_0 [COMPONENTS] F: {CT: Float} B: {CT: Boolean} package Types is Rec_Type_1 {ST: Rec_Type_0} type Rec Type 0 is tagged F record INIT F: Float := abs(3.14); B: Boolean; end record; Parameter Node 1.0.2: type Rec Type 1 is INIT/NODE new Rec Type 0 with null record; Parameter Call Node 1.0.4: end Types; Dest: abs FUNC/PARAM/ROOT Parameter Node 1.0.5: PARAM/NODE 30
  • 39. Further Information & Downloads • http://cfg.w3x.org • For comments, bug reports and feature requests please contact us: • cfg@w3x.org 31
  • 40. Further Information & Downloads • http://cfg.w3x.org • For comments, bug reports and feature requests please contact us: • cfg@w3x.org • Raul Fechete and Georg Kienesberger. Generating control flow graphs for Ada programs. Technical Report 183/1-139, Department of Automation, TU Vienna, September 2007. 31
  • 41. Further Information & Downloads • http://cfg.w3x.org • For comments, bug reports and feature requests please contact us: • cfg@w3x.org • Raul Fechete and Georg Kienesberger. Generating control flow graphs for Ada programs. Technical Report 183/1-139, Department of Automation, TU Vienna, September 2007. • Raul Fechete, Georg Kienesberger, and Johann Blieberger. A Framework for CFG-based Static Program Analysis of Ada Programs. In Ada-Europe’2008 International Conference on Reliable Software Technologies, pages 130-143, Venice, Italy, June 2008. 31
  • 42. Further Information & Downloads • http://cfg.w3x.org • For comments, bug reports and feature requests please contact us: • cfg@w3x.org • Raul Fechete and Georg Kienesberger. Generating control flow graphs for Ada programs. Technical Report 183/1-139, Department of Automation, TU Vienna, September 2007. • Raul Fechete, Georg Kienesberger, and Johann Blieberger. A Framework for CFG-based Static Program Analysis of Ada Programs. In Ada-Europe’2008 International Conference on Reliable Software Technologies, pages 130-143, Venice, Italy, June 2008. • updated documentation in the next few months 31
  • 43. The End Thank you very much! Any questions? http://cfg.w3x.org These slides are licensed under a Creative Commons Attribution-Share Alike 3.0 Austria License. http://creativecommons.org 32