Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Feature Requests
 idea
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

allco
New Member

3 Posts

Posted - Jun 01 2007 :  01:41:20 AM  Show Profile  Reply with Quote
I think, will be very useful: an opportunity of generation of the RECURSIVE list of FUNCTIONS and the NON-LOCAL VARIABLES used in given function (any). It is useful for creation of a threadsafe code, and for future bugfixing.

thanks.

sl@sh
Tomato Guru

Switzerland
204 Posts

Posted - Jun 01 2007 :  07:49:18 AM  Show Profile  Reply with Quote
Although I'm not entirely sure what you mean, I do like the suggestions. Not sure whether this could be done (or done easily) with VA. It probably depends on what kind of behavious exactly you expect.

@recursive functions: simple recursion (a function calling itself) should be easily detectable. It would be a lot more difficult to find call loops, i. e. a serious of functions calling each other and the last one calling the first. Since there is virtually no limit to possible lengths of such loops, analysing code to that end could be extremely time consuming. At the very least this would require a call stack limitation, ideally one a user can modify to fit their (or their projects') needs.

@non-local variables: this is a relative term - 'local' always refers to a scope, and there are various levels of scope in every program. If VA could somehow visibly distinguish symbols defined at various scopes in a meaningful way, this would certainly be a good thing. We'd have to come up with a sensible definition of 'local' or other kind of scope. And we should come up with a workable way to modify the symbols' representation to indicate 'scopyness'.

@'local' scope:
I can think of at least two ways to define scope:
1. absolute levels like function / file / class / namespace / global
2. relative levels like 'within same scope as cursor position' / 'without same scope'

I like the second definition, but that would result in representations that always change dependend on cursor position. And people who scroll text by moving the cursor (instead of e. g. dragging the scroll bar) would probably not like that. The first definition of scope would avoid the 'always changing' problem, but it would require a sensible definition that works for all the languages VA (or the VS IDE) supports. I suppose 'within function' / 'without function' could work, but beyond that?

@scope representation:
How would a 'non-local' symbol be represented? VA already uses various styles (fg color, bg color, bold, underline, italics), and representing a symbol that can already have a combination of those styles in at least two meaningful variations would require the use of yet another style. I can't think of anything suitable at the moment (strikethough style doesn't sound too good an idea ). Maybe someone else can?
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19022 Posts

Posted - Jun 01 2007 :  08:00:22 AM  Show Profile  Reply with Quote
At a very simplistic level try the following:

Turn on VA Options -> Advanced -> Fonts and Colors -> Local symbols in Bold
Pick a nice obvious colour for VA Options -> Advanced -> Fonts and Colors -> Methods

Personally I use a shade of orange for Methods, so that they stand out well. This way as you look over a given piece of code function calls and non local variables are much more obvious. In this sense "local" is defined as parameters or any variable defined inside the function.

Beyond this... this is getting into more serious static code analysis territory.

My initial thought is that simply highlighting all of this on the screen is not going to work. To much information, to complex, and remember that the syntax highlighting code already has problems with "basic" C++ code, since it has to run very fast indeed to keep up with scrolling.

So this would have to be presented as some form of "report", a bit like Find References Results, but rather more complex.

zen is the art of being at one with the two'ness
Go to Top of Page

allco
New Member

3 Posts

Posted - Jun 04 2007 :  10:41:15 AM  Show Profile  Reply with Quote
First for all, please forgive my bad english.


I meant something like this:


int f1() {}
int f2() {f1();}
int f3() {f2();}
int f4() {f3();f2();}

unsignet int main_thread(void* p)
{
f4();
}

I would like, that in refactor menu for function "main_thread"
would be contain somethis like item "Generate Call Tree...".

This command open new popup window (like "VA Find References Result"),
Which would contain tree of functions like this:

" main_thread(...)
" ......|
" ......|------f4()
" ..............|
" ..............|-----f3()
" ..............|.......|
" ..............|.......f2()
" ..............|.......|----f1()
" ..............|
" ..............|-----f2()

Attention! Here function f2 () meets twice, that creates danger of an infinite cycle in a tree.

I offer two decisions:
1. At repeated occurrences of functions in a tree is impossible to expand
(let these elements of a tree have special icon),
only first occurrence of any function in a tree
can be expanded.

2. The tree is initially not expanded. Branches receive the descendants only during a expanding.

----------------------------------------------------------------------------

It would be in addition useful to have an opportunity to receive not a tree
and the LIST of all called functions from "main_thread".

Example:
main_thread
--------f4()
f3()
f2()
f1()

Still it is useful to have the list of all NONLOCAL variables (members of classes, globals) used in the found functions.
============================================================================


All this is necessary for developing and bugfixing of multithreaded applications.
These will allow to quickly find all shared resources (between threads).

Thanks.
Go to Top of Page

sl@sh
Tomato Guru

Switzerland
204 Posts

Posted - Jun 04 2007 :  12:18:21 PM  Show Profile  Reply with Quote
Ok, so there's two things you want VA to help you catching:

1. loops: expanding nested calls would already require some method of catching loops, so you could just as well ask VA to find those loops for you.

2. multithreading issues (reentrant functions): As feline pointed out, VA options already provide means to 'highlight' non-local variables and function calls that might prevent a function from being reentrant. Producing a list of symbols non-local to the current function would be a new functionality.

I suppose both functions are doable, especially if restricted to explicit user requests.
Go to Top of Page

allco
New Member

3 Posts

Posted - Jun 04 2007 :  12:33:49 PM  Show Profile  Reply with Quote
>> .... so you could just as well ask VA to find those loops for you.
how i can do it ?
Go to Top of Page

sl@sh
Tomato Guru

Switzerland
204 Posts

Posted - Jun 04 2007 :  12:43:00 PM  Show Profile  Reply with Quote
Err, I didn't want to imply VA could already do that. I just wanted to point out that asking for a function that just provide you the means to work out whether ot not there is a loop is pointless when VA would need to do what you're actually looking for anyway.

It would be like asking a tool to retrieve a list of items although you only really need one of those items. Best leave it to the developers to decide if they give you that one particular item you want, or a list that you need to scan in a second step. If you're lucky you won't have to do the scan by yourself.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000