Dynamic
Object Flow Analysis
            PhD defense
      Adrian Lienhard




      Advisor: Oscar Nierstrasz
2
3
4
5
6
image:Image                     copy:Image
               a1                      a2

                         :File
     ...
image:Image                copy:Image
               a1                 a2

                       :File
                 ...
image:Image                copy:Image
               a1                 a2

                       :File
                 ...
image:Image                copy:Image
               a1                 a2

                       :File
                 ...
Dynamic Control Flow Analysis




                                11
Dynamic Control Flow Analysis




                          delete


upload




                                   12
Dynamic Control Flow Analysis




                                                delete


  upload




Feature "Upload" F...
Dynamic Control Flow Analysis




                         ?                     delete


  upload




Feature "Upload" Fe...
Dynamic Data Analysis




image:Image                     copy:Image
        a1                      a2

                 ...
Dynamic Data Analysis


    Reference Patterns            Ownership Trees




[De Pauw, Sevitsky ECOOP’99]   [Hill, Noble,...
Dynamic Data Analysis




image:Image                     copy:Image
        a1                      a2

                 ...
Dynamic Data Analysis




image:Image         ?           copy:Image
        a1                      a2

                 ...
Dynamic Analysis

control flow    data       data flow
     !           !           ?
   method     reference   reference
  ...
Dynamic Analysis

control flow    data       data flow
     !           !           ?
   method     reference   reference
  ...
Thesis
Object references must be
captured and modeled explicitly.




                                   21
image:Image           copy:Image
Runtime               a1            a2

                            :File




Object Flow...
image:Image           copy:Image
Runtime               a1            a2

                            :File




Object Flow...
image:Image                 copy:Image
Runtime               a1                   a2

                              :File
...
image:Image                     copy:Image
Runtime                    a1                   a2

                           ...
Runtime




Object Flow
Metamodel

                0..1   *    *             1
                                   *
      ...
Runtime



                      caller
                      0..1
                          Activation
Object Flow       ...
Runtime



                      caller
                      0..1
                          Activation
Object Flow       ...
delete


              upload
                                            duplicate
Runtime



                           ...
Object Flow




              30
Visualizing   Feature              Test
Object Flows Dependencies        Blueprints




                                  ...
Visualizing   Feature              Test
Object Flows Dependencies        Blueprints




                                  ...
Visualizing   Feature              Test
Object Flows Dependencies        Blueprints




                                  ...
Visualizing   Feature              Test
Object Flows Dependencies        Blueprints




                                  ...
Visualizing   Feature              Test
Object Flows Dependencies        Blueprints




                                  ...
Visualizing   Feature              Test
Object Flows Dependencies        Blueprints




                                  ...
Detecting flows between classes




                 Activation
                     1 context


          0..1   *    *
  ...
Detecting flows between classes




                     Method
                      1


                     *
          ...
Detecting flows between classes

Class A                        Class
                                1

                  ...
Detecting flows between classes

Class A                        Class
                                1

                  ...
Inter-unit Flow View




                       41
Chronological
 propagation




                42
Chronological
 propagation




                42
Chronological
 propagation




                42
Spanning flows
Parser (4)




                             43
Spanning flows




IRBuilder




                            44
Visualizing   Feature                    Test
Object Flows Dependencies              Blueprints




                      ...
Visualizing   Feature              Test
Object Flows Dependencies        Blueprints




                                  ...
Feature "Upload"   Feature "Duplicate"     Feature "Delete"



                                 [Salah and Mancoridis ICSM...
Feature "Upload"   Feature "Duplicate"   Feature "Delete"



image:
   a1
      :File




                                ...
Feature "Upload"   Feature "Duplicate"    Feature "Delete"



image:              image:         copy:
   a1              ...
Feature "Upload"   Feature "Duplicate"     Feature "Delete"



image:              image:         copy:   image:        co...
Feature "Upload"       Feature "Duplicate"   Feature "Delete"




             0..1
         *                      *     ...
delete


  upload
                                  duplicate




Feature "Upload"         Feature "Duplicate"      Featur...
IRC client dependencies

         Open
         Setup
       Connect
        MOTD
   Join Channel
  Send Message
Receive M...
Object Dependency Graph
of feature Receive Message




                  Open       Join Channel
                  Connect...
Object Dependency Graph
of feature Receive Message




                  Open       Join Channel
                  Connect...
Object Dependency Graph
of feature Receive Message




                  Open       Join Channel
                  Connect...
Object Dependency Graph
of feature Receive Message




                  Open       Join Channel
                  Connect...
Visualizing   Feature                      Test
Object Flows Dependencies                Blueprints




                  ...
Visualizing   Feature              Test
Object Flows Dependencies        Blueprints




                                  ...
Writing a Unit Test

     1. Setup
     2. Invoke
     3. Assert




                      60
duplicate




            61
duplicate




       Test Blueprint                  Objects
                                       :Image    existing
:Im...
duplicate




               Test Blueprint                  Objects
                                               :Image...
duplicate




               Test Blueprint                       Objects
                                                ...
duplicate




               Test Blueprint                       Objects
                                                ...
duplicate




         caller
         0..1
     *          Activation
          context

                     target para...
IRBuilder>>add:              2   FunctionScope>>lookupVar:
      1




                                          NonClosur...
Execution Trace   Test Blueprint

                                   68
Initial Study I
           Let a developer use the tool:
                   12 tests in 2h




Execution Trace            ...
Initial Study II
   Rewrote assertions of 14 existing tests:
    72 identical, 12 missed, 5 additional




Execution Trace...
Visualizing   Feature              Test
Object Flows Dependencies        Blueprints




                                  ...
Visualizing   Feature              Test
Object Flows Dependencies        Blueprints




                                  ...
Visualizing   Feature              Test
Object Flows Dependencies        Blueprints




                                  ...
74
Specification of object flow tracking
by extending language semantics




                                      75
Example execution

                       Computer           Dynamic
 Source Code
                   (formal semantics)   ...
Example execution

                       Computer           Dynamic
 Source Code
                   (formal semantics)   ...
Example execution

                       Computer           Dynamic
 Source Code
                   (formal semantics)   ...
Example execution

                       Computer           Dynamic
 Source Code
                   (formal semantics)   ...
Visualizing   Feature              Test
Object Flows Dependencies        Blueprints




                                  ...
Visualizing   Feature              Test
Object Flows Dependencies        Blueprints




                                  ...
Problem of conventional debuggers




In 50% of the cases the execution stack contains
essentially no information about th...
Back-in-time debugging




  Challenges
  1. amount of data
  2. execution overhead

                          83
Approaches

Omniscient            Trace-oriented             Trace-oriented
Debugger              debugger (partial)      ...
Approaches

     Omniscient         Trace-oriented        Trace-oriented
     Debugger
                      Our approach
...
Delete history when it
   gets irrelevant




 History of origins of objects
 Previous field values of objects
 Call stacks...
Before deletion




                  87
Before deletion




After deletion




                  88
Object Flow VM

           regular objects                           alias

  header                              header
 ...
Capturing historical object state
t1                   t2                 t3
image := Image new   image height: 17   image...
Capturing historical object state
t1                        t2                 t3
image := Image new        image height: ...
Capturing historical object state
t1                        t2                   t3
image := Image new        image height...
Capturing historical object state
t1                        t2                   t3
image := Image new        image height...
Capturing historical object state
t1                        t2                                t3
image := Image new       ...
Evaluation memory usage (1)
2.5e+09                                                              1e+07
                Num...
Evaluation memory usage (2)
 7e+06                                                                50
              Number ...
Evaluation memory usage (3)
 1e+07
          Number of aliases allocated
 9e+06   Number of aliases in memory
         Num...
Evaluation run-time overhead


                    Overhead       GC
    Recording off       1.15      1.6%
    Recording ...
Visualizing   Feature              Test
Object Flows Dependencies        Blueprints




                                  ...
Visualizing   Feature              Test
Object Flows Dependencies        Blueprints




                                  ...
Upcoming SlideShare
Loading in …5
×

Dynamic Object Flow Analysis (PhD Defense)

1,029 views

Published on

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,029
On SlideShare
0
From Embeds
0
Number of Embeds
57
Actions
Shares
0
Downloads
22
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Dynamic Object Flow Analysis (PhD Defense)

  1. 1. Dynamic Object Flow Analysis PhD defense Adrian Lienhard Advisor: Oscar Nierstrasz
  2. 2. 2
  3. 3. 3
  4. 4. 4
  5. 5. 5
  6. 6. 6
  7. 7. image:Image copy:Image a1 a2 :File name = 'cat.jpg' image := Image newFor: file. // creates a1 copy := image duplicate. // creates a2 7
  8. 8. image:Image copy:Image a1 a2 :File name = nil image := Image newFor: file. // creates a1 copy := image duplicate. // creates a2 copy delete // file.name := nil 8
  9. 9. image:Image copy:Image a1 a2 :File name = nil image := Image newFor: file. // creates a1 copy := image duplicate. // creates a2 copy delete // file.name := nil image display // file.name asUrl NullPointerException 9
  10. 10. image:Image copy:Image a1 a2 :File name = nil image := aliasing is a problem because a1 Object Image newFor: file. // creates copy := image duplicate. // creates a2 it introduces hidden dependencies. copy delete // file.name := nil image display // file.name asUrl NullPointerException 10
  11. 11. Dynamic Control Flow Analysis 11
  12. 12. Dynamic Control Flow Analysis delete upload 12
  13. 13. Dynamic Control Flow Analysis delete upload Feature "Upload" Feature "Duplicate" Feature "Delete" [Salah and Mancoridis ICSM'04] 13
  14. 14. Dynamic Control Flow Analysis ? delete upload Feature "Upload" Feature "Duplicate" Feature "Delete" 14
  15. 15. Dynamic Data Analysis image:Image copy:Image a1 a2 :File name = 'cat.jpg' 15
  16. 16. Dynamic Data Analysis Reference Patterns Ownership Trees [De Pauw, Sevitsky ECOOP’99] [Hill, Noble, Potter JVLC’02] 16
  17. 17. Dynamic Data Analysis image:Image copy:Image a1 a2 :File name = 'cat.jpg' 17
  18. 18. Dynamic Data Analysis image:Image ? copy:Image a1 a2 :File name = 'cat.jpg' 18
  19. 19. Dynamic Analysis control flow data data flow ! ! ? method reference reference execution structure transfer 19
  20. 20. Dynamic Analysis control flow data data flow ! ! ? method reference reference execution structure transfer 20
  21. 21. Thesis Object references must be captured and modeled explicitly. 21
  22. 22. image:Image copy:Image Runtime a1 a2 :File Object Flow Metamodel 22
  23. 23. image:Image copy:Image Runtime a1 a2 :File Object Flow Metamodel Object 23
  24. 24. image:Image copy:Image Runtime a1 a2 :File Object Flow Metamodel * 1 Alias Object value 24
  25. 25. image:Image copy:Image Runtime a1 a2 :File Object Flow Metamodel 0..1 * 1 * Alias Object origin value 25
  26. 26. Runtime Object Flow Metamodel 0..1 * * 1 * Alias Object origin value 26
  27. 27. Runtime caller 0..1 Activation Object Flow * Metamodel 0..1 * 1 * Alias Object origin value 27
  28. 28. Runtime caller 0..1 Activation Object Flow * 1 context Metamodel 0..1 * * 1 * Alias Object origin value 28
  29. 29. delete upload duplicate Runtime caller 0..1 Activation Object Flow * 1 context Metamodel 0..1 * * 1 * Alias Object origin value 29
  30. 30. Object Flow 30
  31. 31. Visualizing Feature Test Object Flows Dependencies Blueprints Runtime Monitoring in the VM Metamodel Activation Alias Object origin Object Tracking 31
  32. 32. Visualizing Feature Test Object Flows Dependencies Blueprints Runtime Monitoring in the VM Metamodel Activation Alias Object origin Object Tracking 32
  33. 33. Visualizing Feature Test Object Flows Dependencies Blueprints Runtime Monitoring in the VM Metamodel Activation Alias Object origin Object Tracking 33
  34. 34. Visualizing Feature Test Object Flows Dependencies Blueprints Runtime Monitoring in the VM Metamodel Activation Alias Object origin Object Tracking 34
  35. 35. Visualizing Feature Test Object Flows Dependencies Blueprints Runtime Monitoring in the VM Metamodel Activation Alias Object origin Object Tracking 35
  36. 36. Visualizing Feature Test Object Flows Dependencies Blueprints Runtime Monitoring in the VM Metamodel Activation Alias Object origin Object Tracking 36
  37. 37. Detecting flows between classes Activation 1 context 0..1 * * * 1 Alias Object origin value 37
  38. 38. Detecting flows between classes Method 1 * Activation 1 context 0..1 * * * 1 Alias Object origin value 38
  39. 39. Detecting flows between classes Class A Class 1 * Method Class B 1 * Activation 1 context Class C 0..1 * * * 1 Alias Object origin value 39
  40. 40. Detecting flows between classes Class A Class 1 * Method Class B 1 * Activation 1 context Class C 0..1 * * * 1 Alias Object origin value 40
  41. 41. Inter-unit Flow View 41
  42. 42. Chronological propagation 42
  43. 43. Chronological propagation 42
  44. 44. Chronological propagation 42
  45. 45. Spanning flows Parser (4) 43
  46. 46. Spanning flows IRBuilder 44
  47. 47. Visualizing Feature Test Object Flows Dependencies Blueprints Runtime Monitoring in the VM l. ard eta [ Lienh AN'09] L COM Metamodel Activation Alias Object origin Object Tracking 45
  48. 48. Visualizing Feature Test Object Flows Dependencies Blueprints Runtime Monitoring in the VM Metamodel Activation Alias Object origin Object Tracking 46
  49. 49. Feature "Upload" Feature "Duplicate" Feature "Delete" [Salah and Mancoridis ICSM'04] 47
  50. 50. Feature "Upload" Feature "Duplicate" Feature "Delete" image: a1 :File 48
  51. 51. Feature "Upload" Feature "Duplicate" Feature "Delete" image: image: copy: a1 a1 a2 :File :File 49
  52. 52. Feature "Upload" Feature "Duplicate" Feature "Delete" image: image: copy: image: copy: a1 a1 a2 a1 a2 :File :File :File 50
  53. 53. Feature "Upload" Feature "Duplicate" Feature "Delete" 0..1 * * 1 Activation Feature 1 context * * 1 0..1 * Alias Object origin value 51
  54. 54. delete upload duplicate Feature "Upload" Feature "Duplicate" Feature "Delete" 0..1 * * 1 Activation Feature 1 context * * 1 0..1 * Alias Object origin value 52
  55. 55. IRC client dependencies Open Setup Connect MOTD Join Channel Send Message Receive Message New Console Disconnect 0 5 10 15 20 25 30 35 Our approach Salah et al. 53
  56. 56. Object Dependency Graph of feature Receive Message Open Join Channel Connect Send Message 54
  57. 57. Object Dependency Graph of feature Receive Message Open Join Channel Connect Send Message 55
  58. 58. Object Dependency Graph of feature Receive Message Open Join Channel Connect Send Message 56
  59. 59. Object Dependency Graph of feature Receive Message Open Join Channel Connect Send Message 57
  60. 60. Visualizing Feature Test Object Flows Dependencies Blueprints Runtime Monitoring in the VM ta l. ard e Lienh 07 ' ICPC Metamodel Activation Alias Object origin Object Tracking 58
  61. 61. Visualizing Feature Test Object Flows Dependencies Blueprints Runtime Monitoring in the VM Metamodel Activation Alias Object origin Object Tracking 59
  62. 62. Writing a Unit Test 1. Setup 2. Invoke 3. Assert 60
  63. 63. duplicate 61
  64. 64. duplicate Test Blueprint Objects :Image existing :Image (target) :Image (return) :Image new References existing :File new 62
  65. 65. duplicate Test Blueprint Objects :Image existing :Image (target) :Image (return) :Image new References existing :File new 1 file := File named: 'cat.jpg'. 2 image := Image new. 3 image file: file. 63
  66. 66. duplicate Test Blueprint Objects :Image existing :Image (target) :Image (return) :Image new References existing :File new 1 file := File named: 'cat.jpg'. 4 copy := image duplicate. 2 image := Image new. 3 image file: file. 64
  67. 67. duplicate Test Blueprint Objects :Image existing :Image (target) :Image (return) :Image new References existing :File new 1 file := File named: 'cat.jpg'. 4 copy := image duplicate. 2 image := Image new. 3 image file: file. 5 self assert: copy class = Image. 6 self assert: copy file == file 65
  68. 68. duplicate caller 0..1 * Activation context target parameters * 1 * 0..1 * 1 Alias Object origin value 66
  69. 69. IRBuilder>>add: 2 FunctionScope>>lookupVar: 1 NonClosureScopeFixer>>acceptVarNode: InstanceScope>>newMethodScope 4 3 ace Test Blueprint 67
  70. 70. Execution Trace Test Blueprint 68
  71. 71. Initial Study I Let a developer use the tool: 12 tests in 2h Execution Trace Test Blueprint 69
  72. 72. Initial Study II Rewrote assertions of 14 existing tests: 72 identical, 12 missed, 5 additional Execution Trace Test Blueprint 70
  73. 73. Visualizing Feature Test Object Flows Dependencies Blueprints Runtime Monitoring in the VM al. a rd et Lienh '08 R CSM Metamodel Activation Alias Object origin Object Tracking 71
  74. 74. Visualizing Feature Test Object Flows Dependencies Blueprints Runtime Monitoring in the VM Metamodel Activation Alias Object origin Object Tracking 72
  75. 75. Visualizing Feature Test Object Flows Dependencies Blueprints Runtime Monitoring in the VM Metamodel Activation Alias Object origin Object Tracking 73
  76. 76. 74
  77. 77. Specification of object flow tracking by extending language semantics 75
  78. 78. Example execution Computer Dynamic Source Code (formal semantics) Analysis Data f := new File ... return f 76
  79. 79. Example execution Computer Dynamic Source Code (formal semantics) Analysis Data f := new File allocation ... return f 77
  80. 80. Example execution Computer Dynamic Source Code (formal semantics) Analysis Data f := new File allocation ... field-write return f 78
  81. 81. Example execution Computer Dynamic Source Code (formal semantics) Analysis Data f := new File allocation ... field-write return f return 79
  82. 82. Visualizing Feature Test Object Flows Dependencies Blueprints Runtime Monitoring in the VM Metamodel Activation Alias Object origin Object Tracking 80
  83. 83. Visualizing Feature Test Object Flows Dependencies Blueprints Runtime Monitoring in the VM Metamodel Activation Alias Object origin Object Tracking 81
  84. 84. Problem of conventional debuggers In 50% of the cases the execution stack contains essentially no information about the bug's cause. [Liblit etal. PLDI'05] 82
  85. 85. Back-in-time debugging Challenges 1. amount of data 2. execution overhead 83
  86. 86. Approaches Omniscient Trace-oriented Trace-oriented Debugger debugger (partial) debugger (full) loss of old history loss of selected history complete history overhead 100x overhead 10x overhead 100x 84
  87. 87. Approaches Omniscient Trace-oriented Trace-oriented Debugger Our approach debugger (partial) debugger (full) low overhead relevant history loss of old history loss of history complete history overhead 100x overhead 10x overhead 100x 85
  88. 88. Delete history when it gets irrelevant History of origins of objects Previous field values of objects Call stacks in which above appear 86
  89. 89. Before deletion 87
  90. 90. Before deletion After deletion 88
  91. 91. Object Flow VM regular objects alias header header header header field_1 field_1 header ... value field_2 field_2 ... context .... .... field_n pointer field_n origin predecessor ... Typical model Object Flow VM 89
  92. 92. Capturing historical object state t1 t2 t3 image := Image new image height: 17 image height: 42 90
  93. 93. Capturing historical object state t1 t2 t3 image := Image new image height: 17 image height: 42 height image: @t1 nil 91
  94. 94. Capturing historical object state t1 t2 t3 image := Image new image height: 17 image height: 42 @t1 nil predecessor height image: @t2 17 92
  95. 95. Capturing historical object state t1 t2 t3 image := Image new image height: 17 image height: 42 @t1 nil predecessor @t2 17 predecessor height image: @t3 42 93
  96. 96. Capturing historical object state t1 t2 t3 image := Image new image height: 17 image height: 42 @t1 nil predecessor @t2 17 predecessor height image: @t3 42 predecessor 0..1 0..1 Alias Object origin * 1 fields 94
  97. 97. Evaluation memory usage (1) 2.5e+09 1e+07 Number of aliases allocated (left Y-axis) Number of aliases in memory (right Y-axis) Number of objects in memory (right Y-axis) 2e+09 8e+06 1.5e+09 6e+06 1e+09 4e+06 5e+08 2e+06 0 0 0 200 400 600 800 1000 #classes 95
  98. 98. Evaluation memory usage (2) 7e+06 50 Number of aliases allocated Number of aliases in memory 6e+06 Number of objects in memory Ratio between aliases in 40 memory and allocated 5e+06 30 4e+06 % 3e+06 20 2e+06 10 1e+06 0 0 0 2 4 6 8 10 12 14 16 18 #samples 96
  99. 99. Evaluation memory usage (3) 1e+07 Number of aliases allocated 9e+06 Number of aliases in memory Number of objects in memory 8e+06 7e+06 6e+06 5e+06 4e+06 3e+06 2e+06 1e+06 0 5 10 15 20 25 #requests 97
  100. 100. Evaluation run-time overhead Overhead GC Recording off 1.15 1.6% Recording on 3.84 27.6% Largest overhead: 6.9 98
  101. 101. Visualizing Feature Test Object Flows Dependencies Blueprints Runtime Monitoring in the VM Metamodel Activation Alias Object origin al. a rd et Object Tracking Lienh P'08 O ECO 99
  102. 102. Visualizing Feature Test Object Flows Dependencies Blueprints Runtime Monitoring in the VM Metamodel Activation Alias Object origin Object Tracking

×