> Actually, I want to do a dynamic analysis 
> where I observe a behavior/outputs of a program at runtime.
> So I use CIL to instrument code to print out values of variables 

Yes, using CIL to instrument the source code to do this is one way.
If you are already familiar with it, you should be able to get it
to do what you want (I do not know of existing program
transformations either with CIL or other wise to do exactly what
you want).

Otherwise, you might also want to look at command awatch
in gdb:

Mini:~ $ gcc -O0 -g t.c
Mini:~ $ gdb a.out
GNU gdb 6.3.50-20050815 (Apple version gdb-1469) (Wed May  5 04:36:56 UTC 2010)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared 
libraries .. done

(gdb) awatch x
Hardware access (read/write) watchpoint 1: x
(gdb) r
Starting program: /Users/pascal/a.out 
Reading symbols for shared libraries +. done
Hardware access (read/write) watchpoint 1: x

Old value = 0
New value = 1
main () at t.c:6
6       y=2;
(gdb) c
Continuing.
Hardware access (read/write) watchpoint 1: x

Old value = 1
New value = 2
main () at t.c:9
9       x=z-1;
(gdb) c
Continuing.
Hardware access (read/write) watchpoint 1: x

Value = 2
main () at t.c:10
10      y=4;
(gdb) c
Continuing.

Program exited with code 03.
Mini:~ $ cat t.c

int x, y, z;

main(){
x=1;
y=2;
z=3;
x=y;
x=z-1;
y=4;
return z;
}
Mini:~ $ 

------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Discover what all the cheering's about.
Get your free trial download today. 
http://p.sf.net/sfu/quest-dev2dev2 
_______________________________________________
CIL-users mailing list
CIL-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cil-users

Reply via email to