On 2006-05-11, jacob navia <ja***@jacob.re mcomp.fr> wrote:
pi***@tin.it a écrit : vim+ctags :)
ctags will give you all usage of a variable within a function?
How do you do that?
I don't know if you can do that with ctags, but cscope can give you all
the references to a variable, and, in some versions, all the assignments
to a variable.
But the OP's problem is much harder than this:
OP> My problem is: To discover the portion of code that depends on(deals
OP> with) a number of specified structures and variables. Sample:
OP> void funct(struct header* h)
OP> {
OP> ....
OP>
OP> memcpy(buff,h,s izeof(struct header));
OP> func2(buff)
OP> ....
OP> a kind of other code....
OP>
OP> }
OP> The idea is to detect all the code that depends on or deals with "h"
The type of buff isn't given, but let's assume it's char * for the sake
of argument.
So now anything that deals with buff deals with *h, and we have to follow
a memcpy to see this.
I think a runtime tool would be an easier task than a static tool here.
What's needed is a kind of "radioactiv e data" where the actual bytes
comprising *h can be made to glow in the dark so we can follow them
through the system.
You could possibly set something up with a combination of gdb's
watchpoints and commands, but if *h is big this might be difficult.
DTrace from Solaris may be able to do the job:
http://www.sun.com/bigadmin/content/dtrace/