Title: Using AspectJ to Collect Value Spectra
1Using AspectJ to Collect Value Spectra
- Mohamed Mansour
- SATM 2003
2Outline
- Value Spectra
- Empirical Evaluation
- Future Work
- QA
3Value Spectra
- Value spectra is the range of values program
variables acquire during program execution - Used in
- Invariant detection
- Fault detection and localization
- Other uses?
4Value Spectra
- Follow the Xie and Notkin approach
- Log values of all arguments at function entry and
exit (include global variables)
5Challenges
- OO languages
- Encapsulation
- Polymorphism
- Dynamic Binding
- Exceptions
- Size of log files
- Performance overhead
6Solution
- AspectJ
- Efficient Encoding Techniques
7AspectJ
- An open source extension to Java
- Java-like syntax for inserting code blocks at
arbitrary program points - Call sites
- Return sites
- Exception throw and catch sites
- And more
- Byte-code weaving using the ajc compiler
8Encoding - Plain Format
- Log fully qualified function name
- Log values of each variable on the argument list
- On entry
- On exit
- Log return value (if any)
9Object Logging
- Log values of each data member
- Primitive data types are logged as is
- Object data members are recursively logged using
the same approach
10Example I
int foo (SimpleClass arg1) arg1._a 5
arg1._b 10 return 25
//SimpleClass x x._a 0 x._b 0 foo(x)
class SimpleClass int _a int _b
int fooClass.foo(SimpleClass) SimpleClass0,
0SimpleClass SimpleClass5, 10SimpleClass 25
11Example II
int bar (ComplexClass arg1) arg1._sc._a
5 arg1._sc._b 10 arg1._f 20.5
return 25
//ComplexClass x x._sc._a 0 x._sc._b
0 x._f 0 foo(x)
class SimpleClass int _a int _b
class ComplexClass SimpleClass _sc float
_f
int barClass.bar(ComplexClass) ComplexClassSimp
leClass0, 0SimpleClass, 0.0ComplexClass Comp
lexClassSimpleClass5, 10SimpleClass,
20.5ComplexClass 25
12Encoding Other techniques
- Factorize long strings, save them to external
files - Log the index of a string instead of the full
string
13Factorization Function Signature
int fooClass.foo(SimpleClass) SimpleClass0,
0SimpleClass SimpleClass5, 10SimpleClass 25
int barClass.bar(ComplexClass) ComplexClassSimp
leClass0, 0SimpleClass, 0.0ComplexClass Comp
lexClassSimpleClass5, 10SimpleClass,
20.5ComplexClass 25
0 SimpleClass0, 0SimpleClass SimpleClass5,
10SimpleClass 25 1 ComplexClassSimpleClass0,
0SimpleClass, 0.0ComplexClass ComplexClass
SimpleClass5, 10SimpleClass,
20.5ComplexClass 25
14Factorization Class Signature
0 SimpleClass0, 0SimpleClass SimpleClass5,
10SimpleClass 25 1 ComplexClassSimpleClass0,
0SimpleClass, 0.0ComplexClass ComplexClass
SimpleClass5, 10SimpleClass,
20.5ComplexClass 25
SimpleClass ComplexClass
0 00, 00 05, 100 25 1 100, 00,
0.01 105, 100, 20.51 25
15Factorization Object Signature
0 00, 00 05, 100 25 1 100, 00,
0.01 105, 100, 20.51 25
00, 00 05,100 1lt0gt, 0.01 1lt1gt,
20.51
0 lt0gt lt1gt 25 1 lt2gt lt3gt 25
16Evaluation
- Quasi Experiment
- What is the most effective encoding technique
- Single subject Nano-XML 2.2.3
- Control variable
- encoding technique
- Dependent variables
- files size
- runtime performance
17Size of Log Files
18Runtime Performance
19Stats
- Total methods 257
- Total method calls 8279
- Jar file before weaving41305
- Jar file after weaving 70069
20Future Work
- Log values of global variables
- Handle container objects
- Experiment with larger programs from several
domains - Compare to byte-code rewriting techniques
- Apply the collected value spectra to invariant
detection techniques
21 Q A
22public aspect BaseAspect pointcut myTrace()
within(BaseAspect) pointcut javaCode()
within(java..)
call( java..(..)) pointcut methodExec()
execution( net..(..))
!javaCode() !myTrace() before
() methodExec() String enter
getValueSpectra(thisJoinPoint)
stack.push(enter) after () returning
(Object t) methodExec() String enter
stack.pop() String exit
getValueSpectra(thisJoinPoint, t)
log(enter, exit)
23Micro Benchmarks