-
August 8th, 2019, 12:16 PM
#1
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 '=='
Last edited by alwaystudent; August 9th, 2019 at 06:48 AM.
Reason: misspelling
-
August 8th, 2019, 03:22 PM
#2
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?
-
August 8th, 2019, 04:58 PM
#3
Re: How to find where a variable takes value? gdb - watch- is time consuming, ineffec
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
-
August 8th, 2019, 05:16 PM
#4
Re: How to find where a variable takes value? gdb - watch- is time consuming, ineffec
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.
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.
-
August 9th, 2019, 06:50 AM
#5
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 '=='
-
August 9th, 2019, 07:12 AM
#6
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.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|