Expression Evaluation

Studio 12, SPARC Solaris 9

There is an article in the IDE Help titled "Evaluating an Expression" and says:

To evaluate an expression:

1. Start a debugging session.

2. Choose Run > Evaluate Expression (Ctrl-F9) from the main window.

3. Type the expression in the Expression drop-down and click Evaluate. The result is shown in the Results window.

I can't find this menu item nor ctrl-F9 works. Do I have to configure something or is this feature not implemented?

What other possibilities are there for avaluating an expression?

[579 byte] By [mriba] at [2007-11-27 6:42:35]
# 1

I can't find neither the article with such title nor Evaluate menu item either.

Here's what I'd do in order to evaluate an expression:

- start debugging session,

- open "Watches" tab and choose "New Watch" from pop-up menu (right-click somewhere in this tab),

- type your expression and hit OK button,

or

- open Dbx Console and issue

print <expression>

MaximKartasheva at 2007-7-12 18:12:44 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 2

Thanks for the reply.

In most cases where I need to evaluate an expression is when I have a pointer to an array of structs.

The watches are not very flexible. The index range I can give is pretty small (depends on the size of the structure) and I have to delete and add a new watch each time.

Is there a better way to work with (allocated) arrays than with watches?

mriba at 2007-7-12 18:12:44 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 3

If I understand you right, you need smth like this:

watch arr[10..40]

where arr is array of structures, right?

If range of indices and/or size of structure is too large, you can supply -L parameter to watch (or print, or display) commands. It looks like this option is not accessible from the GUI, but you can type watch command directly in the dbx console. For example, this worked for me:

(dbx) watch -L array[20..50]

Note that this will slow down the debugger so use with caution.

I didn't understand why you have to re-create new watch each time. Is it because watched expression is re-parsed every time the app stops on an event of interest? In this case, you can use 'display' command (again, no GUI support, you need to type it in and then the expression appears in Watches tab).

MaximKartasheva at 2007-7-12 18:12:44 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 4
The reason for re-creating watches is to see some specific items in a (large) array. It would be great just to edit the index number.It looks like I have to learn dbx commands...Anyway, thank you very much for your help.
mriba at 2007-7-12 18:12:44 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 5
Ah, yes, this lack of ability to *change* the expression puzzles me too. I'll ask around if there's already an RFE (Request For Enhancement) and file one if needed.
MaximKartasheva at 2007-7-12 18:12:44 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 6
By the way, it appears that there already is a bug filed about a problem with watching large variables. This bug is fixed and fixes should be available with first patch. It will be possible to set maximum size of watched object according to your needs.
MaximKartasheva at 2007-7-12 18:12:44 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 7
Okay, two RFEs (Request For Enhancement) filed:6567781: Make watch values be editable in the watch view etc.and6567784: improve single and multi-dimensional array inspectionThey should be visible through bugs.sun.com within next 24 hours.
MaximKartasheva at 2007-7-12 18:12:44 > top of Java-index,Development Tools,Solaris and Linux Development Tools...