intelligent variable window (was Re: Debugging with KDevelop)

Francesco Montorsi f18m_cpp217828 at yahoo.it
Wed Oct 26 00:38:38 UTC 2005


Hi,

Vladimir Prus wrote:
> On Monday 24 October 2005 00:33, Sascha Cunz wrote:
> 
>>>1) You cannot define any "expansion rule"
>>
>>Here you really have a point! 
>>
>>Maybe Vladimir can have a look, if it's posible to solve this. However,
>>autoexp.dat always seemed a little mystic to me, if we can implement the
>>backend, we should also implement a nice frontend to it.
> 
> 
> My thoughts are in http://bugs.kde.org/show_bug.cgi?id=94313
> Essentially, it's not possible to reliable implement automatic pretty-printing 
> of anything, because gdb helpfully includes variables that were not 
> initialized in "info locals" output. Example:
> 
>      string s = "fooo";
>      // lots of code
>      QUrl url = ....;
> 
> when inside <lots of code>, gdb will still report 'url' as live, and trying to
> call QUrl::prettyURL on an uninitialized object will lead to segfault. It's 
> possible to ignore that, but then the program might randomly crash.
I think that some modifications could be asked to GDB dev team to flag the variables which 
are not truly "living" yet as "dirty" (if this is not already available in GDB internals; 
look at my other post "integrating GDB").

Then a good & reliable pretty-printing system could be implemented, but not only.

A major thing I forgot to list in my wish-list is that MSVC6 has an "intelligent" variable 
window: when you are looking at a piece of code like:

1   int A=3, C=4, D=6, E=8;
2   work_on(A,C);
3   work_on(C,D);
4   work_on(D,E);
5   myClass *Z;
6   Z=new myClass();

and you step on the 4th line, MSVC shows you in the variable window only the variables 
which are used by the 3rd line and the ones used by 4th line.
This is *very* useful since when you have many variables in a piece of code, you cannot 
scroll all times a 200-variables list and find the one you're working on.
Also adding the variables in the Watch expression requires time and is a useless loss of 
time when you just need to see their value once.

Also, MSVC when you are on line 1-5 shows the "Z" variable (not in the intelligent 
variable list but you can see it in the list of all scoped vars) as dirty and thus doesn't 
try to access its memory even if a pretty-printing rule is defined for that type of vars.

(NOTE: to be honest you can easily make MSVC crash defining your own insecure expansion 
rules but if you are careful to what you do, you can safely avoid debugger crashes)


I think that an "intelligent variable window" should have these 2 features:
1) supports pretty-printing of user's defined vars (possibly *not* using GDB macro 
language - maybe Python or what else ;))
2) detects the currently used variables and show them (only)

it would be wonderful if this could be done; maybe asking some changes to GDB devteam...



>>>2) You cannot see the return values of the functions. This is a bit
>>>problematic specially when the returned value is used directly in other
>>>expressions, without storing it in a variable...
>>
>>I've no clue if that is posible with GDB at all, but maybe Vladimir can
>>enlighten us here.
> 
> 
> Yes, it's possible. As I say in another email, user interface is the only 
> question.
maybe that a dummy variable item (like "foo()_returnvalue") could be created into the 
variables window so that the user doesn't need to switch to another window tab...


Francesco





More information about the KDevelop-devel mailing list