NetBeans 6.7 C/C++ Pack introduced new feature Observability Tool.
This tutorial demonstrates how to use new feature of C/C++ Development Pack: Observability Tool.
This feature works for Solaris and Linux OS, but you can use this feature from your Windows or MacOS laptop using C/++ Remote Development feature
|NetBeans IDE (including C/C++ support)||Version 6.7|
|Java Development Kit||Version 6 or version 5|
|C/C++ compilers (Sun Studio, GCC or MinGW)||any version|
Solaris as a development platform
To demonstrate this feature we will use sample project ProfilingDemo. Create Sample Project and run it.
I have created new ProfilingDemo sample project and ran it on my OpenSolaris x86 workstation. New Run Monitor component with nice indicators occurred.
I can see some pictures for ¨CPU usage¨ and for ¨Threads usage¨ indicators, but for ¨Memory usage¨ I do not see graph I can see message that I should add SunStudio to Build Tools Collection. OK, I will add Sun Studio Compilers and Tools to the Build Tools Collection
and see what happened.
Now we can view the details of the information for each indicator in the Detailed View component which can be opened with the mouse click in the indicator. To navigate from the details to the source code use context menu action ¨Go To Source¨ our double mouse click. While project ProfilingDemo was running I have clicked on ¨Thread usage¨ indicator and saw the message ¨Looking for thread lock problems..¨.
Note: When I have seen this message first time I was sure that when some thread synchronization problems will occur I will automatically see the data in the ¨Thread Synchronization Details¨ window but no.. In the reality I should click on ¨Thread usage¨ indicator to update view as it will not be updated automatically. The same notice can be applied to ¨Monitor usage¨ and ¨CPU usage¨ indicators
I had to add SunStudio Compiler Collections to enable ¨Memory usage¨ indicator and details view, is there some other providers I can use on my Solaris machine? The answer is YES.
Open Project Properties Profile node.
In the ¨Data Provider¨ combo box I see 3 items (on my Solaris): Sun Studio (which is selected by default on Solaris), DTrace and Simple(Indicators Only). That means I can try to use DTrace, I am not a local user (if I would be a local user I would have enough privileges to use DTrace), but let's try and see what will happen....
¨CPU usage¨ and ¨Thread usage¨ monitors works just fine but for ¨Memory Monitor¨ we can see the message that I do not have privileges enough to run use this indicator, but there is a chance to fix this problem: ¨Repair¨ button! And I will try to fix the issue.
Please note that in case you are local user of the Solaris development machine ¨Memory usage¨ indicator will work for you just fine
If you are lucky and know the root password input it. If not... You cans ask your system administrator to grant you DTrace privileges.
To use DTrace as a Data Provide for C/C++ Observability Tool, your user account must have the dtrace_user, dtrace_proc, and dtrace_kernel privileges or your user account can be local.
To check your user privileges, type /bin/ppriv -v $$ | grep dtrace at a shell prompt. If your account doesn't have the required privileges, consult your system administrator. If you have root access to your system, you can grant your user account the required privileges.
To permanently grant required DTrace privileges to a user account:
- Make sure the user account whose privileges you want to modify is logged out of the system.
- Become superuser (root).
- Type the following:
$ usermod -K defaultpriv=basic,dtrace_kernel,dtrace_user,dtrace_proc user-name
To temporarily grant required DTrace privileges to a user account:
- Type the following to determint the process ID of the shell's process: $ echo $$
- Become superuser (root).
- In another shell, type the following:
$ ppriv -s I+dtrace_user,dtrace_proc,dtrace_kernel process-ID
All commands typed in the shell with the process-id inherit the required privileges.
Let's back to the NetBeans
When we have granted DTrace privileges we have seen the following picture
And now let's rerun the project..
Great!!! Everything works!
Linux as a development platform
Now let's run NetBeans on the Linux platform. We can see nice graphs for all indicators but if we will try to see details we will see the following picture
Adding Sun Studio Compilers and Tools and selecting SunStudio as a Data Provider in the Profile Project Properties will change the picture
On Linux we can use Sun Studio Compilers and Tools or Simple (Indicators only) Data Provider which deliver information for indicators only
Windows and MacOS as a development platform
And now let's try to run C/C++ Observability Tool on Windows.
I have created new Fractal sample project and pushed Run button. The project was ran. No "Run Monitor" component was occurred.
I am wrong. It is here. It was just not popuped. Let's click on it..
Does it mean I cannot use C/C++ Observability Tool on Windows or MacOS?
The answer is "It doesn't. You still can use C/C++ Observability Tool on Windows or MacOS" if you will use C/++ Remote Development feature|http://www.netbeans.org/kb/docs/cnd/remotedev-tutorial.html].
To demonstrate it I have add new Solaris x86machine to the list of my development hosts and will run ProfilingDemo on that remote Solaris x86 machine using Secure Copy as a synchronization mode (I have no SAMBA on my Windows machine)
Where to go
- Have you any questions you can use CND mailing list email@example.com.
- Some issues found? Please file them as a DEFECT (you should have netbeans account) http://cnd.netbeans.org/issues/enter_bug.cgi?component=cnd against profile subcomponent
- Have you any enhancement? Please file them (you should have netbeans account) as an ENHANCEMENT http://cnd.netbeans.org/issues/enter_bug.cgi?component=cnd against profile subcomponent