How to find all assignments the values to variables,by '=' or by func or as ref value
How to find where a variable takes value (preferably c++ source and grep,awk&sed and regex tools, variable is Integer,char* and string can get value by =, or arbitrary function without =)
-We're dealing with a great deal of code and watch- in debugger- can be done but in many cases it is time consuming and ineffective.
for direct assignments we can write:
$grep -nE '^\s*i\s*=' directory_of_code | grep -v '=='
Re: How to find where a variable takes value? gdb - watch- is time consuming, ineffec
What is making using the debugger so difficult? Do you have extremely large functions? Quite a few global variables? Both?
Re: How to find where a variable takes value? gdb - watch- is time consuming, ineffec
Quote:
Originally Posted by
jlb1
What is making using the debugger so difficult? Do you have extremely large functions? Quite a few global variables? Both?
In fact,both of them, but let me explain my request,
Is there any static code analysing tool to make file base on source, to give us where a variable takes value
Re: How to find where a variable takes value? gdb - watch- is time consuming, ineffec
Quote:
In fact,both of them
Then perhaps you should work on fixing these issues. If you eliminate the global variables and properly pass variables back and forth to your functions as required you will find that locating where a variable gets changed will get orders of magnitude easier. Also if your functions are small doing one thing well you will find that they will not need so many parameters and will be much easier to debug.
Quote:
Is there any static code analysing tool to make file base on source, to give us where a variable takes value
Probably, you mentioned grep, what do you find that is lacking with this tool. It should be able to show every location where a variable is referenced.
Re: How to find where a variable takes value? gdb - watch- is time consuming, ineffec
,for simple case, the direct assignments we have:
grep -nE '^\s*i\s*=' directory_of_code | grep -v '=='
Re: How to find where a variable takes value? gdb - watch- is time consuming, ineffec
That really doesn't answer the question of "what do you find that is lacking with this tool".
But if you're looking to see where a particular variable is possibly being changed I would expect to see a variable name somewhere in your grep expression.