Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Linux Tools Project/Profiling/User Guide"

(New page: = Introduction = The Linux Tools project provides a number of tools to profile a C/C++ application. For example, the Valgrind plug-in provides the ability to profile an application's mem...)
 
(Introduction)
Line 1: Line 1:
 
= Introduction =
 
= Introduction =
  
The Linux Tools project provides a number of tools to profile a C/C++ application.  For example, the Valgrind plug-in provides the ability
+
The Linux Tools project provides Eclipse interfaces to a number of system tools sufficient to profile a C/C++ application.  For example, the Valgrind plug-in provides the ability
to profile an application's memory usage while the Perf plug-in allows an end-user to get the amount of time taken in various functions. Each tool
+
to profile an application's memory usage while the Perf plug-in allows an end-user to acquire details regarding the amount of time taken in various functions or methods.
contributes a profiling launch configuration that can be used to directly select an individual tool.  There, an end-user can set optional parameters,
+
From the user point-of-view, the user wants to profile a C/C++ executable and this is available via the Profile as.. right-click context menu or via the Profile Configurations... dialog or via
the executable being run, arguments passed to the executable, etc... For details on how to do this, see the appropriate user-guide for the profiling
+
the Profile button found next to the Debug and Run buttons at the top of the Eclipse Window.
plug-in of interest.
+
  
To simplify usage for end-users who are not so familiar with the individual tools, a set of launch short-cuts have been provided that are based on the
+
Support exists for:
categories of profiling tasks desiredAt present there are the following categories:
+
* Valgrind (memcheck, massif, cachegrind, and helgrind sub-tools)
#Snapshot - this measure the amount of time taken in functions and methods
+
* OProfile
 +
* Perf
 +
* SystemTap (using a set script to get call-graph)
 +
* Gcov (code coverage)
 +
* GProf
 +
 
 +
== Profiling Categories ==
 +
 
 +
In the past, some of the Linux Tools profiling plug-ins, such as Valgrind, would add a default launch short-cut.  The launch short-cut would use a set of default
 +
parameters for the profiling tool and would launch the selected executable appropriately.  In the case of Valgrind, the short-cut would use the memcheck tool for checking
 +
memory leaks and would set up some reasonable default parameters.  Each launch short-cut results in a separate entry under the Profile as... context menu due to the
 +
design of the Eclipse platform launch frameworkFor example, there are short-cuts for Perf, OProfile, and Valgrind which show up as Profile With Perf, Profile With OProfile,
 +
and Profile With Valgrind, respectively.
 +
 
 +
This can be confusing to end-users who are not familiar with the various tools that are out there and what they can do.  To alleviate this, the current profiling tools have been
 +
grouped into the following task categories:
 +
#Time - this measure the amount of time taken in functions and methods
 
#Memory - this profiles heap/stack/cache usage for an application
 
#Memory - this profiles heap/stack/cache usage for an application
 
#Coverage - this measures how much of the code gets exercised in a run
 
#Coverage - this measures how much of the code gets exercised in a run
  
 +
Third-party tools may not fit into any of the above categories and so the mechanism is flexible to add new categories in the future.
 +
 +
Each tool in a category is prioritized and the tool installed with the highest priority is the default for that category.  For example, the Perf tool is the default
 +
for profiling the time taken within an application, if installed.  Valgrind memcheck is the default for profiling memory and Gcov is the default
 +
for profiling code coverage, again, if their respective plug-ins are installed.
 +
 +
 +
The defaults for each category can be changed via the Profiling preferences page located from the Window->Preferences menu item.  Each tool installed will show up
 +
under its category as a radio button as shown below.
 +
 +
As mentioned, in the past, multiple tools would add a Profiling launch short-cut, but is inconsistent with the Eclipse launch framework design which poses the task as
 +
Profile as..., Run as..., or Debug as....  The "as" refers to how the executable is to be launched rather than the tool being used.  For example, the CDT contributes a
 +
"Local C/C++ Executable" short-cut.
 +
The short-cuts share parameters such as program arguments and environment variables, allowing the end-user to set these once and re-use on subsequent runs.
 +
 +
As such, the Linux Tools profiling design has been changed to add a single short-cut for "Local C/C++ Executable". 
 +
 +
 +
 +
So an end-user need not know too much detail regarding the underlying tools to perform these profiling tasks.
 
To that end, there may be multiple plug-ins that fall into an individual category.  For example,
 
To that end, there may be multiple plug-ins that fall into an individual category.  For example,
 
Linux Tools provides the OProfile plug-in, the GProf plug-in, and the Perf plug-in.  All of these provide timing profiling support.
 
Linux Tools provides the OProfile plug-in, the GProf plug-in, and the Perf plug-in.  All of these provide timing profiling support.

Revision as of 14:33, 26 September 2012

Introduction

The Linux Tools project provides Eclipse interfaces to a number of system tools sufficient to profile a C/C++ application. For example, the Valgrind plug-in provides the ability to profile an application's memory usage while the Perf plug-in allows an end-user to acquire details regarding the amount of time taken in various functions or methods. From the user point-of-view, the user wants to profile a C/C++ executable and this is available via the Profile as.. right-click context menu or via the Profile Configurations... dialog or via the Profile button found next to the Debug and Run buttons at the top of the Eclipse Window.

Support exists for:

  • Valgrind (memcheck, massif, cachegrind, and helgrind sub-tools)
  • OProfile
  • Perf
  • SystemTap (using a set script to get call-graph)
  • Gcov (code coverage)
  • GProf

Profiling Categories

In the past, some of the Linux Tools profiling plug-ins, such as Valgrind, would add a default launch short-cut. The launch short-cut would use a set of default parameters for the profiling tool and would launch the selected executable appropriately. In the case of Valgrind, the short-cut would use the memcheck tool for checking memory leaks and would set up some reasonable default parameters. Each launch short-cut results in a separate entry under the Profile as... context menu due to the design of the Eclipse platform launch framework. For example, there are short-cuts for Perf, OProfile, and Valgrind which show up as Profile With Perf, Profile With OProfile, and Profile With Valgrind, respectively.

This can be confusing to end-users who are not familiar with the various tools that are out there and what they can do. To alleviate this, the current profiling tools have been grouped into the following task categories:

  1. Time - this measure the amount of time taken in functions and methods
  2. Memory - this profiles heap/stack/cache usage for an application
  3. Coverage - this measures how much of the code gets exercised in a run

Third-party tools may not fit into any of the above categories and so the mechanism is flexible to add new categories in the future.

Each tool in a category is prioritized and the tool installed with the highest priority is the default for that category. For example, the Perf tool is the default for profiling the time taken within an application, if installed. Valgrind memcheck is the default for profiling memory and Gcov is the default for profiling code coverage, again, if their respective plug-ins are installed.


The defaults for each category can be changed via the Profiling preferences page located from the Window->Preferences menu item. Each tool installed will show up under its category as a radio button as shown below.

As mentioned, in the past, multiple tools would add a Profiling launch short-cut, but is inconsistent with the Eclipse launch framework design which poses the task as Profile as..., Run as..., or Debug as.... The "as" refers to how the executable is to be launched rather than the tool being used. For example, the CDT contributes a "Local C/C++ Executable" short-cut. The short-cuts share parameters such as program arguments and environment variables, allowing the end-user to set these once and re-use on subsequent runs.

As such, the Linux Tools profiling design has been changed to add a single short-cut for "Local C/C++ Executable".


So an end-user need not know too much detail regarding the underlying tools to perform these profiling tasks. To that end, there may be multiple plug-ins that fall into an individual category. For example, Linux Tools provides the OProfile plug-in, the GProf plug-in, and the Perf plug-in. All of these provide timing profiling support. A plug-in may support multiple tools or options that fall into the same category. The Linux Tools Valgrind plug-in supports the Valgrind Memcheck, Massif, Cachegrind, and Helgrind tools. Each is different, but would ultimately fall into the Memory category.

Thus, a default mechanism is used to determine which profiling tool is ultimately used for a profiling launch short-cut. The short-cut includes which tool is used plus a set of default settings.

At installation, each Linux Tools profiling tool contributes to at least one of the profiling categories a profiling launch short-cut. The short-cuts are prioritized and this allows Eclipse to determine which short-cut should be set up as a default choice. The setting is customizable via the 'Preferences' view. This view can be accessed via the 'Window -> Preferences' menu item.

In the 'Preferences' dialog, under the 'Profiling' category is a list of the supported categories currently contributed by Linux Tools plug-ins. Each category creates a Preference page that has a set of radio buttons for each of the contributed profiling short-cuts. The first time opening this page will have the default selected. If there is more than one choice, the end-user may select whatever profiling short-cut is desired.

For example, the default for Memory profiling is using the Valgrind Memcheck tool which validates heap function calls (e.g. finds memory leaks and invalid usage of freed memory). An end-user may rather default memory profiling to use the Valgrind Massif tool which simply tracks heap usage for the lifetime of the application.

Back to the top