# Debugging Optimized Code Steven Osman. Debugging Optimized Code is Hard … Un-optimized code has a correlation between source and object code Optimizing.

## Presentation on theme: "Debugging Optimized Code Steven Osman. Debugging Optimized Code is Hard … Un-optimized code has a correlation between source and object code Optimizing."— Presentation transcript:

Debugging Optimized Code Steven Osman

Debugging Optimized Code is Hard … Un-optimized code has a correlation between source and object code Optimizing compilers rearrange, add and remove code. This results in: Code location problems Data value problems

Talk Overview Understanding the problems Introducing Source-Level Debugging of Scalar Optimized Code Classifying data-value problems Identifying data-value problems What ’ s next?

The Code Location Problem Source S1: y=0; S2: a=b+c; S3: x=2; S4: y=z*3; Optimized Assembly I1: ld r1, b I2: ld r2, c I3: ld r5, z I4: mul r6, r5, 3 I5: mov r4, 2 I6: add r3, r1, r2 We want a breakpoint at S2

The Data-Value Problem Source S1: y=0; S2: a=b+c; S3: x=2; S4: y=z*3; Optimized Assembly I1: ld r1, b I2: ld r2, c I3: ld r5, z I4: mul r6, r5, 3 I5: mov r4, 2 I6: add r3, r1, r2 What is the value of y at S2?

Source-Level Debugging of Scalar Optimized Code By Ali-Reza Adl-Tabatabai and Thomas Gross Identifies data-value problems No changes to the optimized code Uses knowledge of optimizations

Some Simple Terminology Expected value = value a variable should have Actual value = value stored in register Current = Actual value IS expected value (true for all in unoptimzed code) Endangered = Not current Noncurrent = Actual IS NOT expected Suspect = Actual may be expected

Code Hoisting E 0 : x=u-v E 1 : x=y+zBkpt1 Bkpt2 E 2 : x=y+z Bkpt3

Code Hoisting E 0 : x=u-v E 1 : x=y+zE 3 : x=y+z Bkpt1 Bkpt2 E 2 : x=y+z Bkpt3 E 2 =RedCopy(E 3 )

Hoist Reaches E 0 : x=u-v E 1 : x=y+zE 3 : x=y+z Bkpt1 Bkpt2 E 2 : x=y+z Bkpt3 E 2 =RedCopy(E 3 )

Dead Code Elimination E 0 : x=y+z Bkpt1 Bkpt2 Bkpt3 E 1 : …=x Bkpt4 Bkpt5 E 2 : x=u-v Bkpt6

Dead Code Elimination E 0 : x=y+z Bkpt1 Bkpt2 Bkpt3 E 3 : x=y+z E 1 : …=x Bkpt4 Bkpt5 E 2 : x=u-v Bkpt6

E 0 : x=y+z Bkpt1 Bkpt2 Bkpt3 E 3 : x=y+z E 1 : …=x Bkpt4 Bkpt5 E 2 : x=u-v Bkpt6 Dead Reaching

What ’ s Next? Good paper, but it only warns programmer Suggestions about how to get the expected value Alok Ladsariya ’ s talk …

Download ppt "Debugging Optimized Code Steven Osman. Debugging Optimized Code is Hard … Un-optimized code has a correlation between source and object code Optimizing."

Similar presentations