+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+
+
+
+
+
+
\ No newline at end of file
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/HA_data_analysis.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/HA_data_analysis.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
Data Analysis with Heap Analyser
+
+
+
+
+
Data Analysis with Heap Analyser
+
+
When analysing a single heap dump, Heap Analyser displays information about
+the heap visually. The information is divided into six tabbed views:
+
+
+
+
+
Tip : Tooltips are displayed when you hover over a View Type
+selection. They give a very basic overview of the purpose of each view type.
+
+
Note : The Cell List ,
+Objects , Relationships , and Cell Size
+Distributions tabs present much the same information as the
+Heap View , only in simple list or table form.
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/associated_binary.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/associated_binary.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,32 @@
+
+
+
+
+
Associated Binary
+
+
+
+
+
Associated Binary
+
+
The Associated Binary view is an alternative statistical representation of
+the Parent Binary Heap View, in the style of the Objects tab. This view can
+offer a quick way to establish which module is the greatest contributor to heap
+allocation when aggregating all that module’s defined classes.
+
+
+
+
Related references
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/cell_lenght.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/cell_lenght.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,32 @@
+
+
+
+
+
Cell Lenght
+
+
+
+
+
Cell Lenght
+
+
The Cell Length view is much like the Object Type in terms
+of labelling, but it differs based on the allocated length of each object with
+the intent to make it easier to quickly pick out the largest objects.
+
+
+
+
Related references
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/cell_list.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/cell_list.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,30 @@
+
+
+
+
+
Cell List
+
+
+
+
+
Cell List
+
+
In the Cell List view, you can display a simple tabular representation of
+all the cells in the heap displaying cell number, status (allocated/free),
+address, length, and type when known. Double-clicking on a cell takes you to
+its representation in the Heap View . The drop down box allows
+you to filter by type.
+
+
+
+
Related references
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/cell_overhead.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/cell_overhead.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,31 @@
+
+
+
+
+
Cell Overhead
+
+
+
+
+
Cell Overhead
+
+
Cell Overhead is a graphical representation of the space costs for the
+heap’s book-keeping data. The smaller the objects in the heap are on
+average, the greater the book-keeping data overheap will be as a percentage.
+
+
+
+
Related references
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/cell_size.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/cell_size.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,28 @@
+
+
+
+
+
Cell Size Distributions
+
+
+
+
+
Cell Size Distributions
+
+
The Cell Size Distributions view displays a type-independent statistical
+breakdown of the heap by cell size, both for free and allocated cells. This
+view can be useful e.g. when evaluating heap fragmentation issues.
+
+
+
+
Related references
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/cell_type.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/cell_type.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,74 @@
+
+
+
+
+
Cell Type
+
+
+
+
+
Cell Type
+
+
The Cell Type view is a low-level view of the layout of the heap. It is
+useful for getting a quick feel for fragmentation, for example, but the other
+views are more commonly used.
+
+
+
+
The Cell Type view breaks down the heap into word-sized (4 byte) blocks,
+each represented by a coloured square. The following colour-coding is applied
+to each related group of words for easy identification:
+
+ White : Contains a header word, used by the heap
+ allocator for book-keeping.
+ Red/Orange : Contains the data of an allocated object
+ whose class has been identified via its vtable pointer.
+ Yellow : Contains the data of a heap-allocated
+ descriptor.
+ Purple/Brown : Contains the data of an allocated object
+ whose type cannot be identified, usually a raw data buffer.
+ Blue : A free area of the heap that does not currently
+ contain an allocated object.
+
+
+
The colour fade between the start and end of a group of words makes it
+easier for you to pick out the beginning and the end of cells.
+
+
If you highlight a cell by hovering the mouse over it (the whole of the
+associated cell is highlighted), you get a pop-up summary of its contents as a
+tool-tip. You can also right-click to bring up a context menu of options.
+
+
If you click on a cell to select it, or navigate to it using the cursor keys
+or the Previous / Next buttons, or search for it by address in
+the Search box, then that cell will be selected and you will
+get a summary in the Information box below.
+
+ Address is the start of the cell, including book-keeping
+ info.
+ Payload is the address range of the actual data stored
+ in the cell.
+ Nesting level and Allocation number
+ info for a cell are only maintained by the debug (UDEB) version of RHeap,
+ and rarely used as a result.
+
+
+
If you double-click on a cell, a floating memory inspector window will be
+displayed, showing you the cell contents. Cells that contain references to
+other memory locations are highlighted. Double-clicking a highlighted value
+jumps to the referenced location.
+
+
Related references
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/free_cell_size.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/free_cell_size.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,32 @@
+
+
+
+
+
Free Cell Size and Allocated Cell Size
+
+
+
+
+
Free Cell Size and Allocated Cell Size
+
+
The Free Cell Size and Allocated Cell Size graphs display graphical
+representations of free cell fragmentation and allocated cell size distribution
+respectively.
+
+
+
+
+
+
Related references
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/graphs.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/graphs.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,31 @@
+
+
+
+
+
Graphs
+
+
+
+
+
Graphs
+
+
The Graphs view yields a course-grain statistical breakdown of the behaviour
+and representation efficiency of the heap. It can be useful for identifying
+problematic allocation patterns, bad interactions between allocation patterns
+and the RHeap free cell reuse algorithms, and also the effectiveness of changes
+to heap algorithms and client allocation patterns. See the following sections
+for more details:
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/heap_analyser_overview.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/heap_analyser_overview.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,50 @@
+
+
+
+
+
Overview
+
+
+
+
+
Heap Analyser overview
+
+
Heap Analyser is PC application used to graphically inspect and analyse
+Symbian OS heap objects. It is the PC-side complement to the heap capture
+technology of MemSpy and MemSpy Carbide.c++
+Extension . Use MemSpy or MemSpy Carbide Extension to capture heap
+data, and then Heap Analyser to display and analyse the contents.
+
+
Heap Analyser contains the following features:
+
+ Full graphical rendering of heap
+ Includes object names, parent binary, cell age (fragmentation)
+ Heap statistics
+ Graphing
+ "Save as Zip" feature for sharing your heap information with others (e.g.
+ error reports)
+ HTML output
+
+
+
Related references
+
+
+
Related tasks
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/heap_view.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/heap_view.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,29 @@
+
+
+
+
+
Heap View
+
+
+
+
+
Heap View
+
+
In the Heap View, you can view information about the header and contents of
+individual cell heaps. You can also search heaps by address or allocation
+number. Double-clicking a cell displays detailed stack information. See the
+following sections for more details:
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/isolation.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/isolation.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,55 @@
+
+
+
+
+
Isolation and Pervasiveness
+
+
+
+
+
Isolation and Pervasiveness
+
+
The Isolation and Pervasiveness views are about highlighting reference
+density.
+
+
The Isolation view shades objects from cold (blue) to hot
+(more red) based on how “popular” they are with other objects. The
+actual incoming reference count is also displayed in the box at the start of
+each object. Darkest blue objects with a red zero count indicate objects that
+have no references at all within the heap itself. That does not necessarily
+mean they are orphans that have been leaked; they could be referenced from the
+stack or from static variables instead. However, if you do think you may have a
+memory leak then these zero count objects are a good place to start looking.
+
+
+
+
The Pervasiveness view is the inverse of the Isolation
+view. In Pervasiveness view, objects are shaded from cold (blue) to hot (more
+red) based on how many other objects they are “interested” in. The
+actual outgoing reference count is also displayed in the box at the start of
+the object. The other highlighted boxes within cells are the actual locations
+of the potential outgoing references Heap Analyser has identified. As pure data
+datatypes with no outgoing references, descriptors are distinguished in yellow
+here. If you have a memory leak, bright red objects may be worth investigating
+as the potential home to an abnormally large number of references. For example,
+the buffer object within a large array of pointers may be highlighted in this
+view, and in some cases could be the source of a leak e.g. due to forgetting to
+delete objects from the array when they’re no longer needed.
+
+
+
+
Related references
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/object_type.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/object_type.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,79 @@
+
+
+
+
+
Object Type
+
+
+
+
+
Object Type
+
+
The Object Type view presents the objects on the heap and their position
+within it, just as in the Cell Type view, but by tagging them
+with their C++ type name so that you can easily recognize the objects from your
+own code. Determining an object’s type for display is usually possible
+for the majority of objects in the heap, but not for them all. An
+object’s type can usually be determined if
+
+ it is an instance of a C++ class with at least one (directly defined or
+ inherited) virtual function, or
+ it is a descriptor.
+
+
+
If the object type cannot be determined, but there is a unique referrer for
+the object type, or if all referrers are of the same known type, [Part of
+XXX] is displayed, where XXX is the type of the referrer.
+
+
Otherwise, [Unknown] is displayed.
+
+
A virtual function in a class means each instance of that class will contain
+a vtable pointer. The vtable pointer can be used, in combination with the
+symbolic information provided at startup, to determine the name of the class
+associated with the vtable for presentation. Symbian’s CBase defines a
+virtual destructor, so all conventional C-prefixed classes in Symbian will have
+a vtable and so be identifiable in this way.
+
+
There are a number of possibilities, but an [Unknown] or [Part
+of XXX] object is typically either a raw (non-descriptor) data buffer, or
+sometimes a T-class allocated on the heap. Because such an object is often
+owned and encapsulated by an identifiable C-class, one effective strategy for
+identifying objects, which type cannot be determined, is to use the incoming
+reference information Heap Analyser constructs. If an otherwise unknown object
+type has this reference information, it is displayed in the view as [Part
+of XXX] , where XXX is the type of the referrer. In addition, if you
+right-click an object and select Go to… >
+Incoming reference , the context menu will display the types of
+the objects that refer to the object. In fact there are a number of
+ways of visualizing object reference relationships available from the
+right-click context menu, including drawing the link relationships between
+objects as an overlay of dotted lines (right click and select
+Relationships… > Incoming >
+Breadcrumbs ).
+
+
Colours are chosen arbitrarily on a type-by-type basis in this view, with
+the exception of descriptors (Yellow), [Unknown] and [Part of
+XXX] (Red), and free space (Blue). The colour allocation can be viewed and
+refined by clicking Set Filters . This filter settings panel is
+also useful for focusing down on just object types of particular interest;
+click Enable None , then selectively enable just the types you
+are interested in. To get an overview, select View >
+Size > Small .
+
+
+
+
Related references
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/objects.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/objects.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,29 @@
+
+
+
+
+
Objects
+
+
+
+
+
Objects
+
+
The Objects view breaks down the identified objects in the heap
+statistically by type. This is the quickest way to determine which types of
+objects are dominating allocated memory. Note that this tab cannot represent
+[Unknown] objects..
+
+
+
+
Related references
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/parent_binary.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/parent_binary.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,46 @@
+
+
+
+
+
Parent Binary
+
+
+
+
+
Parent Binary
+
+
The Parent Binary view is effectively the same as the Object
+Type view, except that instead of displaying each object’s type,
+it displays the name of the object file that defined that type’s
+vtable .
+
+
What this view does not do is record the logical allocation point of an
+object, since that is simply not recoverable from the information available.
+For example, if some of your own code contains a CFoo::NewL() where
+CFoo is imported from a dll, then it will be an object file in the dll
+that is displayed for the resulting allocated cell, not the object file
+containing the call to NewL .
+
+
This view can be useful to quickly find a module that is contributing into a
+heap objects that are unexpectedly large, or that you do not expect to be
+there.
+
+
+
+
+
+
Related references
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/prerequisites_for_HA.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/prerequisites_for_HA.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,33 @@
+
+
+
+
+
Prerequisites for using Heap Analyser
+
+
+
+
+
Prerequisites for using Heap Analyser
+
+
Heap Analyser is distributed together with the MemSpy Carbide.c++ Extension
+in the SymSEE delivery.
+
+
Heap Analyser requires the Microsoft .NET Framework v2.0.50727 or newer. You
+can download the .NET Framework 2.0 installation package from http://www.microsoft.com/downloads/details.aspx?familyid=0856eacb-4362-4b0d-8edd-aab15c5e04f5&displaylang=en .
+
+
The Compare functionality requires also Microsoft Office Excel 2003 or
+newer.
+
+
Related references
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/references.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/references.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
References
+
+
+
+
+
References
+
+
The following references are available for this tool:
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/relationships.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/relationships.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,28 @@
+
+
+
+
+
Relationships
+
+
+
+
+
Relationships
+
+
The Relationships view is like Cell List, but when you select a cell from
+the Cells table, its incoming and outgoing references can be viewed in the
+bottom half of the view.
+
+
+
+
Related references
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/saving_HA_reports.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/saving_HA_reports.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,41 @@
+
+
+
+
+
Saving Heap Analyser reports
+
+
+
+
+
Saving Heap Analyser reports
+
+
In Heap Analyser, you can save heap dump logs to several formats for further
+analysis.
+
+
Select File > Save As , and then one of
+the file formats:
+
+ As Zip creates a zip file that contains the source data,
+ and the complete heap in comma-separated Excel (CSV) and text format (see
+ figure below).
+
+
+ As CSV creates a comma-separated Excel file (CSV) of the
+ complete heap
+ As Text creates a text file of the complete heap.
+ As HTML creates four HTML files that represent the heap.
+ Open the file index.htm to inspect details.
+
+
+
Related references
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/size_by_cell_index.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/size_by_cell_index.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,33 @@
+
+
+
+
+
Size by Cell Index
+
+
+
+
+
Size by Cell Index
+
+
The Size by Cell Index graph displays a cell’s position in the heap
+set against its size. An uneven distribution here may tell you something about
+the phases and allocation patterns of the program under investigation. Note,
+though, that while often aligned to a degree, a cell’s index is not an
+indicator of age along the execution timeline due to cell re-use.
+
+
+
+
Related references
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/toolbar.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/toolbar.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,55 @@
+
+
+
+
+
+
Toolbar
+
+
+
+
+
+
Toolbar
+
The toolbar in the MemSpy view contains the following icons:
+
+
+
+
+
+
+
+
+
+Button
+Description
+
+
+
+
+Launch SWMT Analyser.
+
+
+
+
+Compare two selected files, or import a file and compare it to a selected file.
+
+
+
+
+
+Launch Heap Analyser and analyse the selected file(s).
+
+
+
+
+Launch MemSpy Import Wizard.
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/troubleshooting.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/reference/troubleshooting.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,115 @@
+
+
+
+
+
Troubleshooting
+
+
+
+
+
Troubleshooting
+
+
MemSpy
+
+
The MemSpy> Carbide.c++ Extension error messages are listed below:
+
+
+
+
+
+
+
+ Message
+ Description
+
+
+ MemSpy extension was unable to receive response from MemSpy
+ S60-application.
+ The target device does not respond to requests sent from the MemSpy
+ Carbide.c++ Extension. Restart the target device. If you are using an
+ USB connection, make sure you have activated trace sending in
+ TraceSwitch or TraceCoreUserApp.
+
+
+ MemSpy s60-application was not found from your device.
+ Your device has MemSpy Launcher, but not MemSpy S60 application
+ installed. Install MemSpy S60 application to the device and restart the
+ device.
+
+
+ Received log files are corrupt.
+ The heap dump or SWMT log files are missing lines. If you are using
+ an USB connection, increase the buffer size in TraceSwitch or
+ TraceCoreUserApp.
+
+
+ No Heap Found.
+ The selected thread is missing, probably because it has terminated.
+ Reload the thread list. If this does not help, restart the device.
+
+
+ Selected heap's heap type is wrong (needs to be Symbian OS
+ RHeap).
+ The heap of the selected thread is not supported, and the heap dump
+ cannot be retrieved by MemSpy.
+
+
+ Invalid heap dump file. The file doesn't contain any threads with
+ binary data information.
+ The file you are trying to import does not contain any threads with
+ binary data information, or contains a binary data error. The file will
+ not be imported.
+
+
+
+
+
SWMT Analyser
+
+
The SWMT Analyser error messages are listed below:
+
+
+
+
+
+
+
+ Message
+ Description
+
+
+ xyz.xls file is already exists and opened, could not overwrite.
+ Please close it and try again.
+ The Excel XLS file is already opened in the target folder.
+ Close the Excel file and try exporting to Excel again.
+
+
+ Invalid order of the log files. The selected files must be in
+ consecutive order and must start from the cycle 1.
+ The selected files in the MemSpy view are not in consecutive order,
+ starting from cycle 1.
+ Select the log files and make sure that they are in consecutive order
+ and starting from cycle 1.
+
+
+ This is a delta file. It does not contain the complete
+ information. Do you still want to continue?
+ You tried to open a single file which has a cycle number other than
+ 1.
+ Click Yes to continue, or No to cancel.
+
+
+ The file is invalid.
+ SWMT Analyser cannot read the data from the log file. This may occur
+ if there are typos or other manual edits in the log file.
+ Please check the filename and the line number shown in the error
+ message, and act accordingly.
+
+
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/release_notes.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/release_notes.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,210 @@
+
+
+
+
+
Release Notes
+
+
+
+
+
+
Release Notes
+
+
MemSpy Carbide.c++ Extension – Version 1.6.0
+
+
Released 21st April 2010
+
+
+
Product description
+
+
The MemSpy extension for Carbide.c++ is a tool for importing heap dumps and
+System Wide Memory Tracking logs from a device to PC and analyzing them.
+
+
MemSpy can be started either by selecting Carbide > MemSpy , or
+from File > Import > Carbide Extensions > MemSpy .
+
+
Main features
+
+ Importing heap dump and SWMT log files either from a file or from a
+ target via TraceViewer connection.
+ Heap Analyser for heap dump file analysis and comparison.
+ SWMT Analyser for SWMT log file analysis.
+
+
+
What's new
+
+ Feature : Added checking for invalid heap dump files that
+ do not contain any threads with binary data information, or contain a
+ binary data error.
+ Feature : In Heap Analyser's Object type view: If there
+ is a unique referrer for the object type, or if all referrers are of the
+ same known type, the object is no longer named [Unknown] but instead [Part
+ of XXX] is now displayed, where XXX is the type of the referrer.
+ Fix : Corrected some paths in exported HTML files to use
+ JavaScript functions and display tooltips also in Heap Data and Cell
+ Associations sections.
+ Change: Heap Analyser documentation has been integrated to the MemSpy
+ Help in Carbide.
+
+
+
Installation notes
+
+
+
System requirements
+
+
Basic requirements:
+
+ Windows 2000, Windows XP
+ Carbide.c++.
+ Minimum SDK build PC.
+ Normal SDK build PC.
+
+
+
Additional requirements:
+
+ TraceViewer Carbide.c++ Extension
+ .NET Framework v2.0.50727 or newer is needed for Heap Analyser
+ functionalities
+
+
+
Compatibility issues
+
+
+
Known issues
+
+
+
Version history
+
+
Version 1.5.0 – 11th December 2009
+
+ Feature: Added possibility to receive Heap Dump s when fetching
+ SWMT logs from device.
+ Feature: Added profiles for SWMT Tracked Categories .
+ Feature: Added the Copy context menu to graphs in SWMT
+ Analyser .
+ Feature: Added the Copy context menu to SWMT Analyser 's
+ data tables.
+ Change: PDF report layout improved in SWMT Analyser 's
+ Analysis tab.
+ Change: Graphs are drawn only when a thread/chunk is alive in SWMT
+ Analyser .
+ Change: Close MemSpy Symbian Agent Between Cycles has been moved
+ to Custom Categories and Advanced Options dialog.
+ Change: Harmonized Advanced filter options... drop-down list item
+ and Customized options... button to use similar wording; these are
+ now using Custom filter and Set Custom filter .
+ Change: Improved error handling in S60 MemSpy launching
+ functionality.
+ Fix: The heap compare functionality does not work if the workstation's
+ regional settings are set to other than English issue is now fixed.
+
+
+
Version 1.4.0 – 5th October 2009
+
+ Feature: Added the checkbox Close MemSpy Symbian agent between
+ cycles to the System Wide Memory Tracking Wizard which makes
+ possible to get full SWMT snapshot for each data fetch cycle (instead of
+ getting only delta information).
+ Feature: Added the Copy context menu to SWMT Analyser 's
+ data tables in the Graphs tab.
+ Change: X-axis time units in SWMT graphs has been adjusted to match the
+ analyzed/shown time interval.
+ Change: The usage of an incompatible version of MemSpy Launcher is now
+ detected and an error-specific message is shown instead of a generic error
+ message.
+ Change: The Zoom In /Zoom Out context menu items are now
+ disabled in the SWMT graph context menu in case the maximum/minimum zoom
+ factor is achieved.
+ Fix: The Issue of showing just an empty dialog when launching of
+ HeapAnalyser.exe fails because of missing .NET framework is now fixed.
+ Fix: The Tracked Categories group should be disabled after the
+ first SWMT cycle is fetched from device issue is now fixed.
+ Fix: The data table contents is not updated when the filter string search
+ match type is changed between 'Contains' and 'Starts with' issue is now
+ fixed.
+
+
+
Version 1.3.0 – 19th August 2009
+
+ Feature: Added option to save the SWMT Analyser graph as image
+ into a local file system.
+ Feature: Added option to generate PDF report for the issues found with
+ SWMT Analyser .
+ Feature: Added provision to view the SWMT Analyser graph for the
+ selected issues in the analysis tab itself.
+ Feature: Provided advanced filter options to filter the issues found with
+ SWMT Analyser .
+ Feature: Added support for analysing SWMT Analyser log files even
+ if they do not have consecutive cycle numbers. i.e., now the log files will
+ be ordered based on the time of the cycle. Note however that cycle1 must be
+ available for the analysis.
+ Feature: Added possibility to select tracked SWMT categories in System
+ Wide Memory Tracking Wizard .
+
+
+
Version 1.2.1 – 14th August 2009
+
+ Fix: Heap Analyser export-to-excel crashed when using Microsoft Office
+ 2007 Excel issue is now fixed.
+ Fix: Maximum wait time for getting SWMT logs from device is too tight
+ issue is now fixed.
+ Fix: MemSpy S60 Launcher application installation fails because invalid
+ path name issue is now fixed.
+
+
+
Version 1.2.0 – 24th June 2009
+
+ Feature: Added a new tab in the SWMT Analyser Editor View for
+ representing the exported data in a graphical format.
+ Feature: Added functionality to SWMT Analyser to analyse log data using
+ graphs
+ Feature: Added a new tab Analysis in the SWMT Analyser Editor view
+ for displaying issues found in analysis.
+ Change: Added thread list filtering based on the thread name into
+ Import Heap Wizard page.
+
+
+
Version 1.1.0 – 9th April 2009
+
+ Feature: Added new tab for SWMT Analyser Editor View to represent the
+ exported data in graphical format.
+ Feature: Added functionality to SWMT Analyser to analyse log data using
+ graphs.
+
+
+
Version 1.0.0 – 16th February 2009
+
+
The first version.
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/tasks/analyse_data_using_graphs.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/tasks/analyse_data_using_graphs.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,38 @@
+
+
+
+
+
Using SWMT Analyser
+
+
+
+
+
Analysing data using graphs
+
SWMT Analyser represents the log data in a graphical format for the selected events and elements on the Graphs tab. The Graphs tab contains two tabs called Events and Graphed items .
+
+
+
+ The Events tab contains a list of events and a list of elements for each event. Events are grouped into categories such as Chunks , Disks , Files , Heap , HPAS , RAM and System_info . Select All_events to view all event types.
+ When you select an event from the list, a list of elements for the selected event will be displayed on the list on the right side of the window. The appropriate tab will be enabled and all other tabs will be disabled. Note that you can select elements from only one list at a time, and you can search elements by using the filter text. Each selected element is represented with an assigned colour on the graph.
+ Note that raw text data from the list on the right side of the window can be selected and copied to the clipboard by using the Copy context menu item.
+ At each event selection change, the element selections and graphs will be cleared. All the selected and plotted graphs will be moved to Graphed items tab.
+
+
+ The Graphed items tab contains a list of graph items that were previously drawn in the Events tab. The graphed items have four properties called Colour , Element name , Event selected and Element type . The graph will be plotted for the selected items, and all these items will be selected by default.
+
+
+
+
+
Related tasks
+
+
+
+
+
\ No newline at end of file
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/tasks/compare_two_heaps.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/tasks/compare_two_heaps.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,68 @@
+
+
+
+
+
Importing and comparing two heap dump files
+
+
+
+
+
Importing and comparing two heap dump files
+
+ Click the icon to start the MemSpy
+ Import Wizard.
+ Select to Import heap and compare logs with Heap Analyser , and
+ click Next .
+ Select whether to get the heap dumps From File System or
+ From Device via TraceViewer , and select the heap dump files to
+ import and compare.
+
+ If you selected From File System , define the first heap dump
+ file location and then a heap, and click Next . Select the second
+ file and heap in the same way, and click Next . Note that you can
+ only compare two dumps from the same thread.
+ If you selected From Device via TraceViewer , click
+ Load/Refresh Thread List to get a thread list from the device,
+ select the first heap to compare, click Get Selected Heap Now ,
+ and click Next . Similarly, select the second heap to compare,
+ and click Next .
+ You can also filter the thread list by using the Starts with and
+ Contains selections.
+
+ If this fails, click Connection Settings and configure connection
+ settings.
+
+ Define an output file location and name for the report file, and click
+ Next . The report is an MS Excel sheet (XLS) file.
+ Define the location of symbol and map files. You have to define at least
+ one symbol file. Defining map files is optional. For more information, see
+ Symbol and Map files .
+ Click Finish . A MemSpy tab appears in the Carbide.c++ Tabbed View
+ Area with a file list populated.
+ A confirmation dialog opens, asking if you want to view the generated
+ file in Excel. See the figure below for an example of the outfile in
+ Excel.
+
+
+
Related references
+
+
+
Related tasks
+
+
+
Related concepts
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/tasks/connection_settings.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/tasks/connection_settings.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,58 @@
+
+
+
+
+
Configuring connection settings
+
+
+
+
Configuring connection settings
+
If the connection to the target device fails, check and configure your connections settings:
+
+In the step 1 of the MemSpy Import Wizard , click Connection
+Settings . This takes you to the connection settings of the TraceViewer Carbide.c++ Extension .
+In Use connection , select an existing connection to use and click OK , or click New... to create a new connection or Edit to edit an existing one. Follow the next steps if you selected to create a new connection or to edit an existing one.
+In Connection name , enter a unique name for this connection.
+In Connection type , select a connection method:
+
+PlatSim if you are using a PlatSim connection between the PC and the target device.
+TCP/IP Musti if you are using an XTI connection between the PC and the
+target device.
+USB if you are using a USB cable connection between the PC and
+the target device.
+
+Click Next .
+
+
+Modify the connection settings:
+
+Click OK to save and exit.
+
+
+
Related tasks
+
+
+
+
+
\ No newline at end of file
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/tasks/generate_pdf_report.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/tasks/generate_pdf_report.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,38 @@
+
+
+
+
+
Using SWMT Analyser
+
+
+
+
+
Generating PDF reports
+
+Go to the Analysis tab and click Generate report . This opens the Create Report dialog where you can select report options.
+Select the type of report to be created:
+
+If you select to Create report for the selected issues option, the report will contain a graph for the selected issues, and the graph area in the analysis tab is captured and written to the PDF file. Expand the graph area to get a clear graph. If no issues are selected in the Analysis tab, an error message will be displayed explaining that you need to select some issues in the analysis view.
+If you select to Create overview report , a graph and only the overview of all the types of issues will be captured and written to the PDF file.
+
+
+(Optional) Enter comments that will appear at the end of the PDF report.
+Enter a file path for the report file.
+Click Finish .
+
+
+
+
+
Related tasks
+
+
+
+
+
\ No newline at end of file
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/tasks/tasks.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/tasks/tasks.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,30 @@
+
+
+
+
+
+
Tasks
+
+
+
+
Tasks
+
The following tasks are available for the MemSpy Carbide.c++ Extension:
+
+
+
+
+
\ No newline at end of file
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/tasks/understanding_excel_data.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/tasks/understanding_excel_data.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,161 @@
+
+
+
+
+
Using SWMT Analyser
+
+
+
+
+
Understanding the Excel data
+
Because reading and analyzing SWMT log files is difficult, SWMT Analyser tool can write the log file data to an Excel sheet in an appropriate manner so that you can easily understand and analyse the data.
+
Excel contains different worksheets to represent various data such as heap-chunks, non heap-chunks, RAM and disk memory, and total heap size.
+
+
The Excel tabs and the information displayed in them are explained in the following table.
+
+
+
+
+
+
+
+Tab
+Description
+
+
+
+Overview
+
+
+Cycle numbers, that is, numbers of selected log files to export, Time Period and Time Duration.
+Total delta of various fields like Heap Size, Free Cell Count, Allocated Cell Count, Free Space, Allocated Space, Slack Space, Total files, and Total P&S Handles for all the threads.
+Status of each thread in the last cycle and delta of various attributes for each thread.
+
+Note : Stack size will be displayed for all threads which are alive.
+
+
+
+
+RAM and Disk Memory
+
+
+Specifies the amount of used RAM and disk memory of all drives in bytes and for each cycle in seconds.
+Shows how the used memory varies between RAM and other drives in each cycle.
+
+
+
+
+
+Non-Heap Chunk Size
+
+
+Specifies the non-heap chunk sizes for all the threads that contain heap in bytes and for each cycle in seconds.
+Shows the difference between the first and the last cycle value.
+
+
+
+
+
+Global Chunk Size
+
+
+Specifies the global chunk sizes for all the threads that contain heap in bytes and for each cycle in seconds.
+Shows the difference between the first and the last cycle value.
+
+
+
+
+
+Total Heap Size
+
+
+Specifies the heap sizes for each thread and for each cycle.
+Shows the difference between the first and the last cycle value.
+
+
+
+
+
+Total Heap Allocated Space
+
+
+Specifies the toal heap allocated space for each thread in bytes and for each cycle in seconds.
+Shows the difference between the first and the last cycle value.
+
+
+
+
+
+Total Heap Free Space
+
+
+Specifies the toal heap free space for each thread in bytes and for each cycle in seconds.
+Shows the difference between the first and the last cycle value.
+
+
+
+
+
+Allocated Heap Cell Count
+
+
+Specifies the allocated heap cell count for each thread in bytes and for each cycle in seconds.
+Shows the difference between the first and the last cycle value.
+
+
+
+
+
+Free Heap Cell Count
+
+
+Specifies the free heap cell count for each thread in bytes and for each cycle in seconds.
+Shows the difference between first and the last cycle value.
+
+
+
+
+
+Slack Space Size
+
+
+Specifies the free slack size for each thread in bytes and for each cycle in seconds.
+Shows the difference between first and the last cycle value.
+
+
+
+
+
+Largest Allocated Cell Size in Heap
+
+
+Specifies the largest allocated cell size in heap for each thread in bytes and for each cycle in seconds.
+Shows the difference between the first and the last cycle value.
+
+
+
+
+
+Largest Free Cell Size in Heap
+
+
+Specifies the largest free cell size in heap for each thread in bytes and for each cycle in seconds.
+Shows the difference between the first and the last cycle value.
+
+
+
+
+
+
Related tasks
+
+
+
+
+
\ No newline at end of file
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/tasks/use_swmt_analyser.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/tasks/use_swmt_analyser.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,59 @@
+
+
+
+
+
Using SWMT Analyser
+
+
+
+
+
Using SWMT Analyser
+
You can start the tool in any of the following ways:
+
+When you finish the SWMT Wizard , that is, when logs are imported to the MemSpy Carbide.c++ Extension from the MemSpy S60 application.
+In the MemSpy Carbide.c++ Extension, select the SWMT log files you want to analyse and click Launch SWMT Analyser , or right-click the SWMT log files and select Analyse with SWMT Analyser .
+
+
+
Preconditions
+
If more than one files are selected, check that the following requirements are met:
+
+All the selected log files must be generated on the same device.
+ROM Version and ROM Checksum must be the same for all the selected log files.
+The cycle number of the first log file must be 1.
+
+
+
SWMT Analyser will open in Carbide.c++ with two tabs called Overview and Graphs . In addition, an Analysis tab will be displayed only when there are issues found in the analysis. The Graphs tab will be displayed only when you have more than one file selected. When you have only one file selected, the Overview tab is displayed with the following information:
+
+
+Properties of the selected log files:
+
+ Number of cycles.
+ Time period (time of the first cycle and time of the last cycle).
+ Time duration (time difference between the first and the last cycle).
+
+
+ROM details of the log files:
+
+ ROM Checksum
+ ROM Version
+
+
+Export options. You can export the combined log file data into an Excel sheet. There are two options for exporting the log files. You can export either all selected log files or only the selected number of cycles.
+Analysis overview. The Overview page list the top 5 issues found in analysis.
+
+
+
+
Related tasks
+
+
+
+
+
\ No newline at end of file
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/tasks/view_heap.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/tasks/view_heap.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,66 @@
+
+
+
+
+
Importing and analyzing heap dump files
+
+
+
+
+
Importing and analyzing heap dump files
+
+ Click the icon to start the MemSpy
+ Import Wizard.
+ Select to Import heap and analyse log with Heap Analyser , and
+ click Next .
+ Select whether to get the heap dumps From File System or
+ From Device via TraceViewer , select file(s) to import, and click
+ Next .
+
+ If you selected From File System , define the heap dump file
+ location and then a heap.
+
+
+ If you selected From Device via TraceViewer , click
+ Load/Refresh Thread List to get a thread list from the device,
+ select a heap, and click Get Selected Heap Now .
+ You can also filter the thread list by using the Starts with and
+ Contains selections.
+
+
+
+ If this fails, click Connection Settings and configure connection
+ settings.
+
+ Define the location of symbol and map files. You have to define at least
+ one symbol file. Defining map files is optional. For more information, see
+ Symbol and Map files .
+ Click Finish . A MemSpy tab appears in the Carbide.c++
+ Tabbed View Area with a file list populated, and Heap Analyser is
+ launched if you selected to import only one file. For more information, see
+ Data analysis with Heap
+ Analyser .
+
+
+
Related references
+
+
+
Related tasks
+
+
+
Related concepts
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/tasks/view_issues_on_the_analysis_tab.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/tasks/view_issues_on_the_analysis_tab.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,45 @@
+
+
+
+
+
Using SWMT Analyser
+
+
+
+
+
Viewing issues on the Analysis tab
+
SWMT Analyser tool will analyse the data internally and list the issues found. The issues will be displayed in a tree format in three groups: RAM and Disk Memory , Threads , and SystemData .
+
The tool internally analyses some events for items such as RAM, Disks, Threads, Chunks and etc. The analysis finds the growth of these events based on some calculations and uses that as the growing factor. All issues displayed in the Analysis tab would be sorted in the descending order of the growing factor by default.
+
Each issue has four fields:
+
+Thread/Chunk/Item name : Name of the item that the issue is related to.
+Event name : Name of the event.
+Delta : Difference between the first and the last cycle values.
+Severity : Shows red if the growing factor is high, yellow if the growing factor is normal, and green if the growing factor is low. There is one dropdown to filter the issues based on its type like All, High, Normal, Low.
+Severity column can be sorted and issues will be ordered by their growing factor.
+
+
+
A graph illustrating the checked issues will be automatically displayed on the top of the Analysis tab.
+
+
You can filter the issues by using the Severity dropdown or Select Custom filter in the drop-down menu.
+
You can save a graph as an image by using the Save graph… option in the context menu of the graph.
+
+
Note that the Overview tab will also display the top 5 issues.
+
If the thread dies and restarts again then that would be treated as separate instances, those thread instances will be respresented like 'thread_name(01)' and 'thread_name(02)'.
+For example, assume that there are 100 cycles and a thread starts at cycle 1 and dies at cycle 10. And the same thread starts again at cycle 20. Then this thread will be considered as having two instances.
+And those instances will be shown as 'thread_name(01)' and 'thread_name(02)' in Analysis tab. However, in Graphs tab this will be shown as single thread with 'thread_name'.
+
+
+
Related tasks
+
+
+
+
+
\ No newline at end of file
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/tasks/view_swmt_log.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/tasks/view_swmt_log.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,68 @@
+
+
+
+
+
Importing and analyzing System Wide Memory Tracking log files
+
+
+
+
+
Importing and analyzing System Wide Memory Tracking log files
+
+ Click the icon to start the MemSpy
+ Import Wizard.
+ Select to Import System Wide Memory Tracking logs and analyse them
+ with SWMT Analyser , and click Next .
+ Select whether to get the SWMT log files From File System or
+ From Device via TraceViewer .
+
+
+ If you selected From File System , define the SWMT log file
+ location and then a log file, and click Next .
+ If you selected From Device via TraceViewer , click Get
+ SWMT Log Now to get an SWMT log file from the device. After this
+ you can set a timer interval to get log files automatically at defined
+ intervals. Select the interval and click Start Timer . Note that
+ each log added with a timer or by clicking Get SWMT Log Now
+ contains only changes since the last received log. To stop the timer,
+ click Stop Timer .
+
+
+ In Tracked Categories and Advanced Options , select a
+ predefined set of categories, or select Custom Categories and
+ Advanced Options and click Edit . In the Advanded
+ Options , you can select categories for SWMT logging and customise
+ the logging options.
+ To stop the S60 MemSpy application in the target device between log
+ cycles, select the option Close MemSpy Symbian Agent Between
+ Cycles . Closing the agent between cycles makes it possible to get
+ full SWMT snapshot for each data fetch cycle (instead of getting only
+ delta information).
+ To include in the SWMT log cycle heap dumps for later analysis in
+ Heap Analyser , select the option Get Heap Dumps for Threads
+ to Analyse with Heap Analyser .
+ To use a thread heap filter, type the filter name (such as Akn )
+ in the Heap Data Thread Filter field.
+
+
+
+ If the connection to the target device fails, click Connection
+ Settings and configure connection settings.
+
+ Click Finish . A MemSpy tab appears in the Carbide.c++
+ Tabbed View Area with a file list populated. The received log files appear
+ in the file list.
+
+
+
Related tasks
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/tocConcepts.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/tocConcepts.xml Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/tocGettingStarted.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/tocGettingStarted.xml Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/tocReference.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/tocReference.xml Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/tocTasks.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/tocTasks.xml Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/tool.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/tool.htm Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,32 @@
+
+
+
+
+
+
Carbide.c++ User Guide
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
+ License: http://www.eclipse.org/legal/epl-v10.html
+
+
+
+ MemSpy User Guide
+ Version 1.6.0; April, 2010
+
+
+
+
\ No newline at end of file
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/toolTOC.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/html/toolTOC.xml Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy.help/plugin.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy.help/plugin.xml Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/.classpath
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/.classpath Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/.settings/org.eclipse.jdt.core.prefs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/.settings/org.eclipse.jdt.core.prefs Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,7 @@
+#Tue Jul 07 08:43:46 EEST 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/META-INF/MANIFEST.MF
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/META-INF/MANIFEST.MF Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,22 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Carbide.c++ Extensions - MemSpy
+Bundle-SymbolicName: com.nokia.s60tools.memspy;singleton:=true
+Bundle-Version: 1.6.0
+Bundle-Activator: com.nokia.s60tools.memspy.plugin.MemSpyPlugin
+Bundle-Vendor: Nokia
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ com.nokia.s60tools.ui;bundle-version="1.5.0",
+ com.nokia.s60tools.sdk;bundle-version="1.2.1",
+ com.nokia.s60tools.heapanalyser;bundle-version="1.0.0",
+ com.nokia.s60tools.util;bundle-version="1.1.12",
+ com.nokia.s60tools.swmtanalyser;bundle-version="1.0.0",
+ org.eclipse.core.resources;bundle-version="3.4.1"
+Bundle-ActivationPolicy: lazy
+Export-Package: com.nokia.s60tools.memspy.export,
+ com.nokia.s60tools.memspy.interfaces;x-friends:="com.nokia.s60tools.memspy.tests",
+ com.nokia.s60tools.memspy.model;x-friends:="com.nokia.s60tools.memspy.tests"
+Import-Package: org.eclipse.core.filesystem,
+ org.eclipse.ui.ide
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/about.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/about.html Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,22 @@
+
+
+
+
About
+
+
+
+
About This Content
+
+
Dec 11, 2009
+
+
Copyright
+
+
+
+
Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
+License: http://www.eclipse.org/legal/epl-v10.html .
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/about.ini
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/about.ini Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,45 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+#
+#
+#
+# about.ini
+# contains information about a feature
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# "%key" are externalized strings defined in about.properties
+# This file does not need to be translated.
+
+# Property "aboutText" contains blurb for "About" dialog (translated)
+# This text is shown in Feature Details -dialog when feature is selected.
+aboutText=%productBlurb
+
+# Property "windowImage" contains path to window icon (16x16)
+# needed for primary features only
+
+# Property "featureImage" contains path to feature image (32x32)
+# Not using this in here because we do not want the icon to
+# show on about dialog. Only using aboutText above.
+#featureImage=icons/appdep.png
+
+# Property "aboutImage" contains path to product image (500x330 or 115x164)
+# needed for primary features only
+
+# Property "appName" contains name of the application (translated)
+# needed for primary features only
+
+# Property "welcomePerspective" contains the id of the perspective in which the
+# welcome page is to be opened.
+# optional
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/about.mappings
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/about.mappings Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+#
+#
+# about.mappings
+# contains fill-ins for about.properties
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# This file does not need to be translated.
+
+# The following should contain the build version.
+# e.g. "0=20020612"
+0=0
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/about.properties
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/about.properties Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,31 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+#
+# about.properties
+# contains externalized strings for about.ini
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# fill-ins are supplied by about.mappings
+# This file should be translated.
+
+productBlurb=Carbide.c++ Extensions - MemSpy \n\
+\n\
+Version: 1.6\n\
+Build id: {0}\n\
+\n\
+\n\
+Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.\n\
+License: "http://www.eclipse.org/legal/epl-v10.html".\n\
+\n\
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/build.properties
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/build.properties Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,13 @@
+javacSource=1.5
+javacTarget=1.5
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ bin/,\
+ icons/,\
+ about.html,\
+ about.ini,\
+ about.mappings,\
+ about.properties
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/icons/Analyse_Heap.png
Binary file sysperfana/memspyext/com.nokia.s60tools.memspy/icons/Analyse_Heap.png has changed
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/icons/Compare_2_Heaps.png
Binary file sysperfana/memspyext/com.nokia.s60tools.memspy/icons/Compare_2_Heaps.png has changed
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/icons/Export_To_html.png
Binary file sysperfana/memspyext/com.nokia.s60tools.memspy/icons/Export_To_html.png has changed
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/icons/Heap_Dump_File.png
Binary file sysperfana/memspyext/com.nokia.s60tools.memspy/icons/Heap_Dump_File.png has changed
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/icons/Launch_SWMT.png
Binary file sysperfana/memspyext/com.nokia.s60tools.memspy/icons/Launch_SWMT.png has changed
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/icons/Memspy_16.png
Binary file sysperfana/memspyext/com.nokia.s60tools.memspy/icons/Memspy_16.png has changed
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/icons/Memspy_45.png
Binary file sysperfana/memspyext/com.nokia.s60tools.memspy/icons/Memspy_45.png has changed
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/icons/SWMT_Log_File.png
Binary file sysperfana/memspyext/com.nokia.s60tools.memspy/icons/SWMT_Log_File.png has changed
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/plugin.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/plugin.xml Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,56 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/schema/traceprovider.exsd
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/schema/traceprovider.exsd Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,98 @@
+
+
+
+
+
+
+
+
+ This extension point can be used to provide trace data for MemSpy.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Trace provider instance's class implementing ITraceProvider interface
+
+
+
+
+
+
+
+
+
+ Name of the trace provider instance
+
+
+
+
+
+
+
+
+
+
+
+ 1.6.0
+
+
+
+
+
+
+
+
+
+
+
+ Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+All rights reserved.
+This component and the accompanying materials are made available
+under the terms of "Eclipse Public License v1.0"
+which accompanies this distribution, and is available
+at the URL "http://www.eclipse.org/legal/epl-v10.html".
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/common/Product.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/common/Product.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+package com.nokia.s60tools.memspy.common;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * Class for getting properties from product.properties file, located in same package.
+ */
+public class Product {
+ private static final String BUNDLE_NAME = "com.nokia.s60tools.memspy.common.product"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
+ .getBundle(BUNDLE_NAME);
+
+ private Product() {
+ }
+ /**
+ * @param key to product.properties -file
+ * @return a String from product.properties -file
+ */
+ public static String getString(String key) {
+ try {
+ return RESOURCE_BUNDLE.getString(key);
+ } catch (MissingResourceException e) {
+ return '!' + key + '!';
+ }
+ }
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/common/ProductInfoRegistry.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/common/ProductInfoRegistry.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,59 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+package com.nokia.s60tools.memspy.common;
+
+/**
+ * This class stores product information such as product name,
+ * version, console view name etc.
+ * The idea is to have the product information in one place.
+ */
+public class ProductInfoRegistry {
+
+
+ /**
+ * @return Returns the Console window name.
+ */
+ public static String getConsoleWindowName() {
+ return getProductName() + " " + Product.getString("ProductInfoRegistry.Console_Window_Name_Postfix"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ /**
+ * @return Returns the Product name.
+ */
+ public static String getProductName() {
+ return Product.getString("ProductInfoRegistry.Product_Name"); //$NON-NLS-1$
+ }
+
+ /**
+ * @return Returns the images directory.
+ */
+ public static String getImagesDirectoryName() {
+ return Product.getString("ProductInfoRegistry.Images_Directory"); //$NON-NLS-1$
+ }
+
+ /**
+ * @return Returns the required MemSpy Launcher data version.
+ */
+ public static int getRequiredMemSpyLauncherDataVersion() {
+ String versionStr = Product.getString("ProductInfoRegistry.Required_MemSpyLauncherS60DataVersion"); //$NON-NLS-1$
+ int version = Integer.parseInt(versionStr);
+ return version;
+ }
+
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/common/product.properties
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/common/product.properties Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,22 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+#
+
+ProductInfoRegistry.Product_Name=MemSpy
+ProductInfoRegistry.Console_Window_Name_Postfix=Console
+ProductInfoRegistry.Images_Directory=icons
+#For Required_MemSpyLauncherS60DataVersion use format 'n' e.g. =1
+ProductInfoRegistry.Required_MemSpyLauncherS60DataVersion=1
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/containers/SWMTLogInfo.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/containers/SWMTLogInfo.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,97 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+package com.nokia.s60tools.memspy.containers;
+
+import java.util.Date;
+
+/**
+ *
+ * class SWMTLogInfo
+ * SWMTLogInfo class that contains info from one System Wide Memory Tracking log file or directory.
+ *
+ */
+public class SWMTLogInfo {
+
+ /**
+ * Enum about what type the log is
+ */
+ public enum SWMTLogType{ DEVICE, FILE };
+ private SWMTLogType type;
+
+ // Path of file
+ private String path;
+
+ // Date when file has been imported.
+ private Date date;
+
+ /**
+ * SWMTLogInfo.
+ * constructor.
+ */
+ public SWMTLogInfo(){
+ }
+
+
+ /**
+ * Get the log type
+ * @return type
+ */
+ public SWMTLogType getType() {
+ return type;
+ }
+ /**
+ * Set the log type
+ * @param type
+ */
+ public void setType(SWMTLogType type) {
+ this.type = type;
+ }
+ /**
+ * Get file path where log file is located
+ * @return path
+ */
+ public String getPath() {
+ return path;
+ }
+ /**
+ * Set file path where log file is located
+ * @param path
+ */
+ public void setPath(String path) {
+ this.path = path;
+ }
+ /**
+ * Get date when log file is created
+ * @return date
+ */
+ public Date getDate() {
+ return date;
+ }
+ /**
+ * Set date when log file is created
+ * @param date
+ */
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/containers/ThreadInfo.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/containers/ThreadInfo.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,191 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+package com.nokia.s60tools.memspy.containers;
+
+import java.util.Date;
+
+
+
+
+/**
+ * threadInfo
+ * thread info from one thread
+ */
+public class ThreadInfo {
+
+ /**
+ * Enum about what type the log is
+ */
+ public enum HeapDumpType{ DEVICE, FILE };
+ private HeapDumpType type;
+
+ // Name of the thread
+ private String threadName;
+
+ // ID-number of thread
+ private String threadID;
+
+ // File path of file
+ private String threadFilePath;
+
+ // Date when file has been imported.
+ private Date date;
+
+ // Status when heap from thread has been imported,
+ // or "-" if it has not been imported.
+ private String status;
+
+
+ /**
+ * ThreadInfo
+ * constructor
+ */
+ public ThreadInfo(){
+ threadName = "";
+ threadID = "";
+ threadFilePath = "";
+ date = new Date();
+ status = "-";
+ }
+
+ /**
+ * Private constructor for clone method. Status is set as empty.
+ * @param threadName Name of the thread
+ * @param threadID ID-number of thread
+ * @param threadFilePath File path of file
+ * @param date Date when file has been imported.
+ * @param type Enum of which type info.
+ */
+ private ThreadInfo(String threadName, String threadID, String threadFilePath, Date date, HeapDumpType type){
+ this.threadName = threadName;
+ this.threadID = threadID;
+ this.threadFilePath = threadFilePath;
+ this.date = date;
+ this.type = type;
+
+ this.status = "-";
+ }
+
+ /**
+ * Clone this object.
+ * @return New {@link ThreadInfo} object made from this ThreadInfo. Status is as default value.
+ */
+ public ThreadInfo clone() {
+ ThreadInfo clone = new ThreadInfo(threadName, threadID, threadFilePath, date, type);
+ return clone;
+ }
+
+
+ /**
+ * Get thread name
+ * @return thread name
+ */
+ public String getThreadName() {
+ return threadName;
+ }
+
+ /**
+ * Set thread name
+ * @param threadName
+ */
+ public void setThreadName(String threadName) {
+ this.threadName = threadName;
+ }
+
+ /**
+ * Get thread id
+ * @return thread id
+ */
+ public String getThreadID() {
+ return threadID;
+ }
+
+ /**
+ * Set thread id
+ * @param threadID
+ */
+ public void setThreadID(String threadID) {
+ this.threadID = threadID;
+ }
+
+ /**
+ * Get date
+ * @return date
+ */
+ public Date getDate() {
+ return date;
+ }
+
+ /**
+ * Set date when log was created
+ * @param date
+ */
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+ /**
+ * Get absolute file path where log file is located
+ * @return file path
+ */
+ public String getThreadFilePath() {
+ return threadFilePath;
+ }
+
+ /**
+ * Set absolute file path where log file is located
+ * @param threadFilePath
+ */
+ public void setThreadFilePath(String threadFilePath) {
+ this.threadFilePath = threadFilePath;
+ }
+
+ /**
+ * Get the type of this log
+ * @return type
+ */
+ public HeapDumpType getType() {
+ return type;
+ }
+
+ /**
+ * Set the type of this log
+ * @param type
+ */
+ public void setType(HeapDumpType type) {
+ this.type = type;
+ }
+
+ /**
+ * Get status
+ * @return status
+ */
+ public String getStatus() {
+ return status;
+ }
+
+ /**
+ * Set status
+ * @param status
+ */
+ public void setStatus(String status) {
+ this.status = status;
+ }
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/export/ITraceClientNotificationsIf.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/export/ITraceClientNotificationsIf.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+package com.nokia.s60tools.memspy.export;
+
+/**
+ * Callback interface reporting trace related error information from trace source side.
+ */
+public interface ITraceClientNotificationsIf {
+
+ /**
+ * Notifies informative message from trace source.
+ * @param message message
+ */
+ public void notifyInformation(String message);
+
+ /**
+ * Notifies warning from trace source.
+ * @param message message
+ */
+ public void notifyWarning(String message);
+
+ /**
+ * Notifies error from trace source.
+ * @param message message
+ */
+ public void notifyError(String message);
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/export/ITraceDataProcessor.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/export/ITraceDataProcessor.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+package com.nokia.s60tools.memspy.export;
+
+/**
+ * Data processor interfacing for handling trace output data from device.
+ */
+public interface ITraceDataProcessor {
+
+ /**
+ * Handles a single trace data line.
+ * @param traceDataLine trade data line
+ */
+ public void processDataLine(String traceDataLine);
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/export/ITraceProvider.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/export/ITraceProvider.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,86 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+package com.nokia.s60tools.memspy.export;
+
+/**
+ * Interface for binding external trace data providers for MemSpy.
+ * Only a single trace data provider instance at a time is supported.
+ * In case more that a single trace data providers are available
+ * the selection among them is undeterministic.
+ */
+public interface ITraceProvider {
+
+ /**
+ * Connects to trace source.
+ * @param traceClient Client to send information about changes in connectivity status and errors etc.
+ * @return true
on success, otherwise false
+ */
+ public boolean connectTraceSource(ITraceClientNotificationsIf traceClient);
+
+ /**
+ * Disconnects to trace source.
+ */
+ public void disconnectTraceSource();
+
+ /**
+ * Sends current usage context-specific integer data to launcher.
+ * Integer data can contain values that can be expressed with 10 bytes
+ * i.e. only 10 lower bytes are taken into account when setting data.
+ * @param integerData integer data to be sent
+ * @return false
if failed to send integer data, otherwise true
+ */
+ public boolean sendIntData(int integerData);
+
+ /**
+ * Sends current usage context-specific string message to launcher.
+ * @param stringData string data to send
+ * @return true
on success, otherwise false
+ */
+ boolean sendStringData( String stringData);
+
+ /**
+ * Activates trace with given group ID.
+ * @param traceGroupID trace group ID
+ * @return true
on success, otherwise false
+ */
+ boolean activateTrace(String traceGroupID);
+
+ /**
+ * Starts trace data listening
+ * @param dataProcessor data processor that further handles trace data at MemSpy side.
+ * @return true
in case data processor is registered properly, otherwise false
+ */
+ public boolean startListenTraceData(ITraceDataProcessor dataProcessor);
+
+ /**
+ * Stops trace data listening
+ */
+ public void stopListenTraceData();
+
+ /**
+ * Gets preference page ID for the user trace source.
+ * @return preference page ID for the user trace source
+ */
+ public String getTraceSourcePreferencePageId();
+
+ /**
+ * Gets current connections display name.
+ * @return current connections display name
+ */
+ public String getDisplayNameForCurrentConnection();
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/files/HeapDumpFile.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/files/HeapDumpFile.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+package com.nokia.s60tools.memspy.files;
+
+/**
+ * class HeapDumpFile.
+ * This class represents one Heap Dump.
+ */
+
+public class HeapDumpFile extends MemSpyFile {
+
+ /* path of XML-file*/
+ private String xmlPath;
+
+ /**
+ * HeapDumpFile.
+ * constructor
+ * @param filePath files path
+ * @param xmlPath xml files path
+ */
+ public HeapDumpFile( String filePath, String xmlPath ) {
+ super(filePath);
+ this.xmlPath = xmlPath;
+ }
+
+ /**
+ * Read's file variables from file that is defined in filePath
+ * @param folder folder where files are searched
+ * @return New HeapDumpFile
+ */
+ static public HeapDumpFile read( String folder ){
+
+ String xmlPath = findFile(folder, "xml");
+ String heapPath = findFile(folder, "txt");
+
+ if ( xmlPath == null || heapPath == null ){
+ return null;
+ }
+ HeapDumpFile heapFile = new HeapDumpFile( heapPath, xmlPath );
+ heapFile.doRead();
+ heapFile.setFileType("Heap Dump");
+ return heapFile;
+ }
+
+ /**
+ * Get XML file path
+ * @return path of xml-file
+ */
+ public String getXmlPath() {
+ return xmlPath;
+ }
+
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/files/MemSpyFile.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/files/MemSpyFile.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,209 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+package com.nokia.s60tools.memspy.files;
+
+import java.io.File;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+
+import org.xml.sax.helpers.DefaultHandler;
+
+import com.nokia.s60tools.memspy.model.MemSpyFileOperations;
+
+/**
+ * This is a base class for all MemSpy file types.
+ *
+ */
+public class MemSpyFile extends DefaultHandler{
+
+ /* files path */
+ protected String filePath = "";
+
+ /* files name */
+ protected String fileName = "";
+
+ /* time code from file */
+ protected String time = "";
+
+ /* date time code from file */
+ private Date dateTime = null;
+
+ /* type of the file */
+ protected String fileType = "";
+
+ /**
+ * MemSpyFile.
+ * constructor
+ * @param filePath Path of file
+ */
+ public MemSpyFile( String filePath ){
+ this.filePath = filePath;
+ }
+
+ /**
+ * doRead.
+ * Read's file variables from file that is defined in filePath
+ */
+ public void doRead(){
+ File f = new File(filePath);
+
+ //if file exists
+ if (f.exists() && f.isFile()) {
+
+ //Get date
+ Date date = new Date(f.lastModified());
+ setDateTime(date);
+ SimpleDateFormat formatter = new SimpleDateFormat ( MemSpyFileOperations.DATEFORMAT );
+ time = formatter.format(date);
+
+ // get File name
+ fileName = f.getName();
+ } else {
+ fileName = "";
+ }
+ }
+
+ /**
+ * findFiles.
+ * Finds all files with defined extension.
+ * @param folder folder where from files are searched
+ * @param extension file extension
+ * @return arraylist that contains found file names
+ */
+ protected static ArrayList findFiles(String folder, String extension) {
+
+ ArrayList retVal = new ArrayList();
+ if ( !extension.startsWith(".") ){
+ extension = "." + extension;
+ }
+ File cFolder = new File(folder);
+ if (cFolder.isDirectory() && cFolder.exists()) {
+ File[] files = cFolder.listFiles();
+ if (files != null) {
+ for (int i = 0; i < files.length; i++) {
+ File file = files[i];
+ if (file.getName().endsWith(extension)) {
+ retVal.add( file.getAbsolutePath() );
+ }
+ }
+ }
+ }
+
+ return retVal;
+ }
+
+ /**
+ * findFile
+ * Finds file with defined extension.
+ * @param folder folder where file is searched
+ * @param extension file extension
+ * @return fileName
+ */
+ protected static String findFile(String folder, String extension) {
+ if ( !extension.startsWith(".") ){
+ extension = "." + extension;
+ }
+ File cFolder = new File(folder);
+ if (cFolder.isDirectory() && cFolder.exists()) {
+ File[] files = cFolder.listFiles();
+ if (files != null) {
+ for (int i = 0; i < files.length; i++) {
+ File file = files[i];
+ if (file.getName().endsWith(extension)) {
+ return file.getAbsolutePath();
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+
+
+ /**
+ * Get file name
+ * @return file name
+ */
+ public String getFileName() {
+ return fileName;
+ }
+ /**
+ * Set file name
+ * @param fileName
+ */
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+ /**
+ * Get time when log file was created
+ * @return time
+ */
+ public String getTime() {
+ return time;
+ }
+ /**
+ * Set time when log file was created
+ * @param time
+ */
+ public void setTime(String time) {
+ this.time = time;
+ }
+ /**
+ * Get type of log file
+ * @return type
+ */
+ public String getFileType() {
+ return fileType;
+ }
+ /**
+ * Set type of log file
+ * @param fileType
+ */
+ public void setFileType(String fileType) {
+ this.fileType = fileType;
+ }
+
+ /**
+ * Get absolute file path
+ * @return file path
+ */
+ public String getFilePath() {
+ return filePath;
+ }
+
+ /**
+ * Set date time
+ * @param dateTime the dateTime to set
+ */
+ private void setDateTime(Date dateTime) {
+ this.dateTime = dateTime;
+ }
+
+ /**
+ * Get date time read from file
+ * @return the dateTime
+ */
+ public Date getDateTime() {
+ return dateTime;
+ }
+
+
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/files/SWMTFile.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/files/SWMTFile.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+package com.nokia.s60tools.memspy.files;
+
+import java.util.ArrayList;
+
+/**
+ * class SWMTFile.
+ * This class represents one System Wide Memory Tracking log.
+ */
+
+public class SWMTFile extends MemSpyFile {
+
+
+
+ /**
+ * SWMTFile.
+ * Constructor
+ * @param filePath path of file
+ */
+ private SWMTFile(String filePath) {
+ super(filePath);
+ }
+
+ /**
+ * read.
+ * Reads searches swmt-file from given folder
+ * @param folder
+ * @return new SWMTFile
+ */
+ static public SWMTFile read( String folder ){
+
+ ArrayList filePaths = findFiles(folder, "txt");
+ String xmlFile = findFile(folder, "xml");
+
+
+ if ( filePaths.size() == 0 || xmlFile != null ){
+ return null;
+ }
+ SWMTFile swmtFile = new SWMTFile( filePaths.get(0) );
+ swmtFile.doRead();
+ swmtFile.setFileType("SWMT-Log");
+ return swmtFile;
+ }
+
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/interfaces/IAnalyseHeapJobListener.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/interfaces/IAnalyseHeapJobListener.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+package com.nokia.s60tools.memspy.interfaces;
+
+
+/**
+ * IAnalyseHeapJobListener.
+ * interface for Heap Analyser launcher listener.
+ */
+public interface IAnalyseHeapJobListener {
+
+ /**
+ * heapAnalyserFinished.
+ * Methot that is called when Heap Aanalyser finishes
+ * @param returnValue return value of Heap Analyser
+ */
+ public void heapAnalyserFinished(final int returnValue);
+
+ /**
+ * heapAnalyserFinished.
+ * Methot that is called when Heap Aanalyser finishes
+ * @param returnValue return value of Heap Analyser
+ * @param outputFilePath file path of output file
+ */
+ public void heapAnalyserFinished(final int returnValue, String outputFilePath);
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/interfaces/IMemSpyTraceListener.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/interfaces/IMemSpyTraceListener.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,115 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+package com.nokia.s60tools.memspy.interfaces;
+
+import com.nokia.s60tools.memspy.containers.SWMTLogInfo;
+
+
+/**
+ * interface MemSpyTraceListener
+ * MemSpy trace listener interface that all MemSpy Trace listeners implement
+ *
+ */
+
+public interface IMemSpyTraceListener {
+
+ /**
+ * MemSpy Launchers actions.
+ */
+ public enum LauncherAction{
+ START_MEMSPY_THREAD_LIST,
+ GET_THREAD_LIST,
+ GET_HEAP_DUMP,
+ SWMT_UPDATE,
+ TIMED_SWMT_UPDATE
+ };
+
+ /**
+ * Launch error types.
+ */
+ public enum LauncherErrorType{
+
+ // The order of 4 first launcher error enumerators should not be changed because the error codes
+ // sent from launcher side must match enumerator ordinals.
+
+ GENERAL_LAUNCHER_ERROR, // This is general launcher error when there is no error code, only error description.
+ MEMSPY_NOT_RUNNING, // error code/ordinal=1, MemSpy is not running on device as should have been at the state of execution
+ MEMSPY_NOT_FOUND, // error code/ordinal=2, MemSpywas not installed on device
+ HEAP_NOT_FOUND, // error code/ordinal=3, Requested heap was not found from device
+
+ // Ordinals of other errors are not used as error codes at launcher side,
+ // and therefore they can be freely re-organized if needed.
+
+ HEAP_TYPE_WRONG, //
+ NO_ANSWER_FROM_DEVICE, //
+ DUMPED_TRACES, //
+ ACTIVATION, // Activation of MemSpy functionality via MemSpyLauncher has failed
+ FILE, //
+ CATEGORIES_NOT_SUPPORTED, // MemSpy installed on the device does not support setting of custom categories
+ TOO_OLD_MEMSPY_LAUNCHER_DATAVERSION // MemSpyLauncher installed supports only older data version
+ };
+
+ public final static String ERROR_HEAP_TYPE = "Selected heap's heap type is wrong(needs to be Symbian OS RHeap).";
+ public final static String ERROR_NO_RESPONSE = "MemSpy extension was unable to receive response from MemSpy S60-application.";
+ public final static String ERROR_POSSIBLE_REASONS = "Following reason(s) might be causing this problem: ";
+ public final static String ERROR_MEMSPY = "MemSpy Error";
+ public final static String ERROR_USB_TRACE_ENABLED = "\n- Trace data sending is not activated from your TraceSwitch application.";
+ public final static String ERROR_INSTALL_MEMSPY_LAUNCHER = "\n- MemSpy Launcher application is not installed in your device, or the installed launcher version is not up-to-date.\n\n(Installing MemSpy Launcher requires that Nokia PC suite is found from this computer and device is connected with usb-cable.) ";
+ public final static String ERROR_CONNECTION_BROKEN = "\n- Network connection between workstation and Musti box does not work properly.";
+ public final static String ERROR_MEMSPY_NOT_RUNNING = "MemSpy is not running on device. MemSpy will be restarted when you perform next operation. ";
+ public final static String ERROR_MEMSPY_NOT_FOUND = "MemSpy s60-application was not found from your device.";
+ public final static String ERROR_HEAP_NOT_FOUND = "Requested heap not found from device.( Perhaps thread has been terminated after loading of thread list, try reloading thread list. )";
+ public final static String ERROR_DUMPED_TRACES = "Received Heap Dump/SWMT-log is corrupted. See help for more information.";
+ public final static String ERROR_SWMT_NEEDS_RESET = "\n\nSince last imported log was missed, logs cannot be imported anymore before removing all logs.";
+ public final static String ERROR_ACTIVATION_NOT_SUCCESFUL = "Unable to send activation messages to TraceCore. Check connection settings.";
+ public final static String ERROR_FILE_OPERATIONS_NOT_SUCCESSFUL= "MemSpy was unable to write data to hard drive. Please make sure that MemSpy has sufficient user rights to Carbide's workspace.";
+ public final static String ERROR_CONNECTION = "Cannot connect to trace. Check connection settings.";
+ public final static String ERROR_CATEGORIES_NOT_SUPPORTED = "SWMT category setting feature is not supported by the MemSpy installed on the device and will be disabled for the rest of the session. Re-run the operation without category support.";
+ public final static String ERROR_TOO_OLD_MEMSPY_LAUNCHER_VERSION = "Installed launcher version is not up-to-date.\n\n(Installing MemSpy Launcher requires that Nokia PC suite is found from this computer and device is connected with usb-cable.";
+ public static final String ERROR_GENERAL_LAUNCHER_ERROR = "An unexpected error occurred in launcher component. See console log for detailed error information.";
+ public final static String ERROR_SEE_CONSOLE_LOG = "\n\nSee console log for additional error information.";
+ public final static String ERROR_LAUNCHER_ERROR_DETAILS = "S60 MemSpy Launcher error details: ";
+
+ /**
+ * deviceError.
+ * method that is called whenever errors occur.
+ * @param error error code
+ */
+ public void deviceError( LauncherErrorType error );
+
+ /**
+ * operationFinished.
+ * @param action which action was finished
+ */
+ public void operationFinished( LauncherAction action );
+
+ /**
+ * operationFinished.
+ * @param action which action was finished
+ * @param swmtLog that was received
+ */
+ public void operationFinished( LauncherAction action, SWMTLogInfo swmtLogInfo, boolean timerRunning );
+
+ /**
+ * startedReceivingSWMTLog.
+ * notification that is sent to interface when swmtReceiving is started.
+ */
+ public void startedReceivingSWMTLog();
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/interfaces/INewMemSpyFilesObserver.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/interfaces/INewMemSpyFilesObserver.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+package com.nokia.s60tools.memspy.interfaces;
+
+/**
+ * interface INewMemSpyFilesObserver.
+ * interface for MemSpy file observer.
+ *
+ */
+
+public interface INewMemSpyFilesObserver {
+
+ /**
+ * memSpyFilesUpdated.
+ * Method that is called when MemSPy file scan is complete.
+ */
+ public void memSpyFilesUpdated();
+
+ /**
+ * setOutputFilePath.
+ * sets output file's path
+ * @param outputFilePath new outputFilePath
+ */
+ public void setOutputFilePath(String outputFilePath);
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/model/AnalyseHeapJob.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/model/AnalyseHeapJob.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,112 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+package com.nokia.s60tools.memspy.model;
+
+
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+
+import com.nokia.s60tools.heapanalyser.interfaces.HeapAnalyserLauncher;
+import com.nokia.s60tools.memspy.interfaces.IAnalyseHeapJobListener;
+
+
+/**
+ * This class is responsible for launching Heap Analyser and waiting for it to stop.
+ * If Heap Analyser returns with and error code, error code is passed to job listener
+ */
+public class AnalyseHeapJob extends Job {
+
+
+ /* path of the configuration file */
+ private String configurationFile;
+
+ /* path of output file */
+ private String analyseOutputFile;
+
+ /* Job listener(MemSpy main view */
+ private IAnalyseHeapJobListener listener;
+
+ /**
+ * Constructor
+ * @param name Name of the process
+ * @param listener listener that is notified if errors occur.
+ */
+ public AnalyseHeapJob(String name, IAnalyseHeapJobListener listener ) {
+ super(name);
+ this.listener = listener;
+ analyseOutputFile = null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ protected IStatus run(IProgressMonitor arg0) {
+
+ // launch heap analyser and wait for it to stop
+ int retVal = HeapAnalyserLauncher.launchHeapAnalyser( configurationFile );
+
+ // if output file was generated return it as attchment to main view.
+ if( analyseOutputFile != null ){
+ listener.heapAnalyserFinished( retVal, analyseOutputFile );
+ }
+ else{
+ listener.heapAnalyserFinished( retVal );
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * Launches Heap Analyser.
+ */
+ public void refresh() {
+ try {
+ setPriority(Job.LONG);
+ setUser(false);
+ schedule(100);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ }
+ }
+
+
+ /**
+ * setter for configurationFiles path
+ * @param configurationFile
+ */
+ public void setConfigurationFile(String configurationFile) {
+ this.configurationFile = configurationFile;
+ }
+
+ /**
+ * setAnalyseOutputFile.
+ * @param analyseOutputFile file path of analyse file output.
+ */
+ public void setAnalyseOutputFile(String analyseOutputFile) {
+ this.analyseOutputFile = analyseOutputFile;
+ }
+
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/model/AnalyserXMLGenerator.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/model/AnalyserXMLGenerator.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,574 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+package com.nokia.s60tools.memspy.model;
+
+import java.io.BufferedWriter;
+import java.io.IOException;
+
+/**
+ * AnalyserXMLGenerator.
+ * XML file generator that writes configuration XML-files for Heap Analyser and
+ * Crash Analyser based on parameters it has received.
+ *
+ * AnalyserXMLGenerator can be used for example like this:
+ *
+ * AnalyserXMLGenerator generator = new AnalyserXMLGenerator(XMLGeneratorAction.ANALYSE_HEAP, "c:\\temp\\source.txt", "c:\\directory\\", null, null, "thread", "c:\\temp\\output.xls", null, null);
+ * File filename = new File("c:\\temp\\testxml.xml");
+ * BufferedWriter writer = null;
+ * try {
+ * writer = new BufferedWriter(new FileWriter(filename));
+ * generator.GenerateXML(writer);
+ * } catch (IOException e) {
+ * e.printStackTrace();
+ * }
+ * finally {
+ * try {
+ * if (writer != null) {
+ * writer.flush();
+ * writer.close();
+ * }
+ * }
+ * catch (IOException ex) {
+ * ex.printStackTrace();
+ * return false;
+ * }
+ * }
+ *
+ */
+
+public class AnalyserXMLGenerator {
+
+ /**
+ * Enumeration for Heap Analyser actions
+ */
+ public enum XMLGeneratorAction {
+ ANALYSE_HEAP, COMPARE_HEAPS, ANALYSE_CRASH_SUMMARY, ANALYSE_CRASH_FULL
+ }
+
+ private XMLGeneratorAction XMLAction;
+ private String[] XMLSourceFile;
+ private String XMLSourceDirectory;
+ private String[] XMLDebugMetaDataFile = null;
+ private String XMLDebugMetaDataDirectory;
+ private String XMLThreadName;
+ private String XMLExtension;
+ private String XMLAnalyseFileOutput;
+ private String XMLAnalyseDirectoryOutput;
+
+
+ //Commands for XML
+
+ private final static String COMMAND_VIEWER = "Viewer";
+ private final static String COMMAND_COMPARE_HEAPS = "CompareTwoHeaps";
+ private final static String COMMAND_SUMMARY = "Summary";
+ private final static String COMMAND_FULL_ANALYSIS = "Full";
+
+ // XML-tags
+
+ private final static String CRASH_ANALYSER_START = "";
+ private final static String CRASH_ANALYSER_END = " ";
+
+ private final static String HEAP_ANALYSER_START = "";
+ private final static String HEAP_ANALYSER_END = " ";
+
+ private final static String SOURCE_START = " ";
+ private final static String SOURCE_END = " ";
+
+ private final static String DEBUG_META_DATA_START = " ";
+ private final static String DEBUG_META_DATA_END = " ";
+
+ private final static String FILE_START = " ";
+
+ private final static String DIRECTORY_START = " ";
+
+ private final static String PARAMETERS_START = " ";
+ private final static String PARAMETERS_END = " ";
+
+ private final static String THREAD_START = " ";
+ private final static String THREAD_END = " ";
+
+ private final static String COMMAND_START = " ";
+ private final static String COMMAND_END = " ";
+
+ private final static String OUTPUT_START = " ";
+ private final static String OUTPUT_END = " ";
+
+ private final static String EXTENSION_START = " ";
+
+
+
+ /**
+ * XMLGenerator()
+ * Constructor
+ */
+ public AnalyserXMLGenerator() {
+
+ XMLAction = null;
+ XMLSourceFile = null;
+ XMLSourceDirectory = null;
+ XMLDebugMetaDataFile = null;
+ XMLDebugMetaDataDirectory = null;
+ XMLThreadName = null;
+ XMLAnalyseFileOutput = null;
+ XMLExtension = null;
+
+ }
+
+ /**
+ * AnalyserXMLGenerator()
+ * Constructor for XMLGenerator
+ *
+ * @param action
+ * @param sourceFile file that is added into -section under -tag
+ * @param sourceDirectory directory that is added into -section under -tag
+ * @param debugMetaDataFile file that is added into -section under -tag
+ * @param debugMetaDataDirectory directory that is added into -section under -tag
+ * @param threadName thread name that is added into -section under -tag
+ * @param extension extension text that is is added into -section under -tag
+ * @param analyseFileOutput file name that is added into -section under -tag
+ * @param analyseDirectoryOutput file name that is added into -section under -tag
+ */
+
+ public AnalyserXMLGenerator( XMLGeneratorAction action,
+ String[] sourceFile,
+ String sourceDirectory,
+ String[] debugMetaDataFile,
+ String debugMetaDataDirectory,
+ String threadName,
+ String analyseFileOutput,
+ String analyseDirectoryOutput,
+ String extension ) {
+
+ XMLAction = action;
+ XMLSourceFile = sourceFile;
+ XMLSourceDirectory = sourceDirectory;
+ XMLDebugMetaDataFile = debugMetaDataFile;
+ XMLDebugMetaDataDirectory = debugMetaDataDirectory;
+ XMLThreadName = threadName;
+ XMLAnalyseFileOutput = analyseFileOutput;
+ XMLAnalyseDirectoryOutput = analyseDirectoryOutput;
+ XMLExtension = extension;
+ }
+
+ /**
+ * GenerateXML()
+ * Writes XML file.
+ * @param writer BufferedWriter stream where XML is written.
+ * @throws IOException if something goes when writing to stream
+ */
+
+ public void GenerateXML( BufferedWriter writer ) throws IOException{
+
+
+ if( XMLAction != null ) {
+ // Begin XML
+ switch( XMLAction ){
+ case ANALYSE_CRASH_FULL:
+ case ANALYSE_CRASH_SUMMARY:
+ writer.write(CRASH_ANALYSER_START);
+ break;
+ case ANALYSE_HEAP:
+ case COMPARE_HEAPS:
+ writer.write(HEAP_ANALYSER_START);
+ break;
+ default:
+ break;
+ }
+
+ writer.newLine();
+ writer.newLine();
+ }
+ // Write Sources
+ this.writeSource(writer);
+
+
+ // Write debug meta data
+ this.writeDebugMetaData(writer);
+
+ // Write parameters
+ this.writeParameters(writer);
+
+ // Write output location
+ this.writeOutput(writer);
+
+ // End XML
+ if( XMLAction != null ) {
+ switch(XMLAction){
+ case ANALYSE_CRASH_SUMMARY:
+ case ANALYSE_CRASH_FULL:
+ writer.write(CRASH_ANALYSER_END);
+ break;
+ case ANALYSE_HEAP:
+ case COMPARE_HEAPS:
+ writer.write(HEAP_ANALYSER_END);
+ break;
+ default:
+ break;
+ }
+ writer.newLine();
+ }
+
+
+ }
+
+ /**
+ * writeSource()
+ * Writes source - parameters
+ * @param writer BufferedWriter stream where XML is written.
+ */
+ private void writeSource( BufferedWriter writer ) throws IOException{
+
+
+ // Start Source definition
+ writer.write(SOURCE_START);
+ writer.newLine();
+
+ if( XMLSourceFile != null ){
+ // File Definition
+ for(int i = 0; i < XMLSourceFile.length; i++ ){
+ writer.write( FILE_START );
+ writer.write( XMLSourceFile[i] );
+ writer.write( FILE_END );
+ writer.newLine();
+ }
+ }
+ if( XMLSourceDirectory != null ) {
+ writer.write( DIRECTORY_START );
+ writer.write( XMLSourceDirectory );
+ writer.write( DIRECTORY_END );
+ writer.newLine();
+ }
+
+ // End Source definition
+ writer.write(SOURCE_END);
+ writer.newLine();
+ writer.newLine();
+ }
+
+ /**
+ * writeDebugMetaData()
+ * Writes debug_meta_data - parameters
+ * @param writer BufferedWriter stream where XML is written.
+ * @throws IOException
+ */
+ private void writeDebugMetaData( BufferedWriter writer ) throws IOException{
+ // Start Debug meta data definition
+
+ if( XMLDebugMetaDataFile != null ||
+ XMLDebugMetaDataDirectory != null ){
+
+ writer.write(DEBUG_META_DATA_START);
+ writer.newLine();
+
+ // File Definition
+ if( XMLDebugMetaDataFile != null ){
+ for(int i = 0; i < XMLDebugMetaDataFile.length; i++ ){
+ writer.write( FILE_START );
+ writer.write( XMLDebugMetaDataFile[i] );
+ writer.write( FILE_END );
+ writer.newLine();
+ }
+ }
+ if( XMLDebugMetaDataDirectory != null ) {
+ writer.write( DIRECTORY_START );
+ writer.write( XMLDebugMetaDataDirectory );
+ writer.write( DIRECTORY_END );
+ writer.newLine();
+ }
+
+ // End Debug meta data definition
+ writer.write(DEBUG_META_DATA_END);
+ writer.newLine();
+ writer.newLine();
+ }
+ }
+
+
+
+ /**
+ * writeParameters(
+ * Writes parameters - parameters
+ * @param writer BufferedWriter stream where XML is written.
+ * @throws IOException
+ */
+
+ private void writeParameters( BufferedWriter writer ) throws IOException {
+
+ if( XMLThreadName != null || XMLAction != null || XMLExtension != null){
+
+
+ // Start parameter definition
+ writer.write(PARAMETERS_START);
+ writer.newLine();
+
+
+ if( XMLThreadName != null ){
+ // Add thread info
+ writer.write( THREAD_START );
+ writer.write( XMLThreadName );
+ writer.write( THREAD_END );
+ writer.newLine();
+
+ }
+
+ if( XMLAction != null ){
+ // Command
+
+ writer.write(COMMAND_START);
+
+ // Begin XML
+ switch(XMLAction){
+ case ANALYSE_CRASH_SUMMARY:
+ writer.write(COMMAND_SUMMARY);
+ break;
+ case ANALYSE_CRASH_FULL:
+ writer.write(COMMAND_FULL_ANALYSIS);
+ break;
+ case ANALYSE_HEAP:
+ writer.write(COMMAND_VIEWER);
+ break;
+ case COMPARE_HEAPS:
+ writer.write(COMMAND_COMPARE_HEAPS);
+ break;
+ default:
+ break;
+ }
+ writer.write(COMMAND_END);
+ writer.newLine();
+ }
+
+ if( XMLExtension != null ){
+ // extension
+ writer.write( EXTENSION_START );
+ writer.write( XMLExtension );
+ writer.write( EXTENSION_END );
+ writer.newLine();
+ }
+
+
+
+ // End parameter definition
+ writer.write(PARAMETERS_END);
+ writer.newLine();
+ writer.newLine();
+ }
+
+
+ }
+
+
+ /**
+ * Writes output - parameters
+ * @param writer BufferedWriter stream where XML is written.
+ * @throws IOException
+ */
+ private void writeOutput( BufferedWriter writer ) throws IOException{
+
+ if( XMLAnalyseFileOutput != null || XMLAnalyseDirectoryOutput != null ){
+ writer.write(OUTPUT_START);
+ writer.newLine();
+
+ // Output file
+ if( XMLAnalyseFileOutput != null ){
+ writer.write(FILE_START);
+ writer.write(XMLAnalyseFileOutput);
+ writer.write(FILE_END);
+ writer.newLine();
+ }
+ // Output directory
+ if( XMLAnalyseDirectoryOutput != null ) {
+ writer.write(DIRECTORY_START);
+ writer.write(XMLAnalyseDirectoryOutput);
+ writer.write(DIRECTORY_END);
+ writer.newLine();
+ }
+
+ writer.write(OUTPUT_END);
+ writer.newLine();
+ writer.newLine();
+
+
+ }
+ }
+
+
+
+
+
+ /**
+ * Get file name parameters
+ * @return XMLSourceFile
+ */
+ public String[] getXMLSourceFile() {
+ return XMLSourceFile;
+ }
+
+ /**
+ * Set file name parameters
+ * @param sourceFile the XMLSourceFile to set
+ */
+ public void setXMLSourceFile(String[] sourceFile) {
+ XMLSourceFile = sourceFile;
+ }
+
+ /**
+ * Get symbol or map files
+ * @return XMLDebugMetaDataFile
+ */
+ public String[] getXMLDebugMetaDataFile() {
+ return XMLDebugMetaDataFile;
+ }
+
+ /**
+ * Set symbol or map files
+ * @param XMLDebugMetaDataFile to set
+ */
+ public void setXMLDebugMetaDataFile(String[] debugMetaDataFile) {
+ XMLDebugMetaDataFile = debugMetaDataFile;
+ }
+
+ /**
+ * Check if XMLDebugMetaDataFile has been set
+ * @return XMLDebugMetaDataFile
+ */
+ public boolean hasXMLDebugMetaDataFile() {
+ boolean isXMLSet = XMLDebugMetaDataFile!=null;
+ if(isXMLSet){
+ isXMLSet = XMLDebugMetaDataFile.length > 0;
+ }
+ return isXMLSet;
+ }
+
+ /**
+ * Get thread parameter
+ * @return XMLThreadName
+ */
+ public String getXMLThreadName() {
+ return XMLThreadName;
+ }
+
+ /**
+ * Set thread parameter
+ * @param XMLThreadName to set
+ */
+ public void setXMLThreadName(String threadName) {
+ XMLThreadName = threadName;
+ }
+
+ /**
+ * Get analyse output file
+ * @return XMLAnalyseFileOutput
+ */
+ public String getXMLAnalyseFileOutput() {
+ return XMLAnalyseFileOutput;
+ }
+
+ /**
+ * Set analyse output file
+ * @param XMLAnalyseFileOutput to set
+ */
+ public void setXMLAnalyseFileOutput(String analysefileOutput) {
+ XMLAnalyseFileOutput = analysefileOutput;
+ }
+
+ /**
+ * Get current action
+ * @return XMLAction
+ */
+ public XMLGeneratorAction getXMLAction() {
+ return XMLAction;
+ }
+
+ /**
+ * Set action
+ * @param action the XMLGeneratorAction to set
+ */
+ public void setXMLAction(XMLGeneratorAction action) {
+ XMLAction = action;
+ }
+
+ /**
+ * Get directory parameter
+ * @return XMLSourceDirectory
+ */
+ public String getXMLSourceDirectory() {
+ return XMLSourceDirectory;
+ }
+
+ /**
+ * Set directory parameter
+ * @param XMLSourceDirectory to set
+ */
+ public void setXMLSourceDirectory(String sourceDirectory) {
+ XMLSourceDirectory = sourceDirectory;
+ }
+
+ /**
+ * Get debug metadata directory. In UI it's shown as Map file folder.
+ * @return XMLDebugMetaDataDirectory
+ */
+ public String getXMLDebugMetaDataDirectory() {
+ return XMLDebugMetaDataDirectory;
+ }
+
+ /**
+ * Set debug metadata directory. In UI it's shown as Map file folder.
+ * @param XMLDebugMetaDataDirectory to set
+ */
+ public void setXMLDebugMetaDataDirectory(String debugMetaDataDirectory) {
+ XMLDebugMetaDataDirectory = debugMetaDataDirectory;
+ }
+
+ /**
+ * Get extension parameter
+ * @return XMLExtension
+ */
+ public String getXMLExtension() {
+ return XMLExtension;
+ }
+
+ /**
+ * Set extension parameter
+ * @param extension the XMLExtension to set
+ */
+ public void setXMLExtension(String extension) {
+ XMLExtension = extension;
+ }
+
+ /**
+ * Get output directory
+ * @return XMLAnalyseDirectoryOutput
+ */
+ public String getXMLAnalyseDirectoryOutput() {
+ return XMLAnalyseDirectoryOutput;
+ }
+
+ /**
+ * Set output directory
+ * @param analyseDirectoryOutput the XMLAnalyseDirectoryOutput to set
+ */
+ public void setXMLAnalyseDirectoryOutput(String analyseDirectoryOutput) {
+ XMLAnalyseDirectoryOutput = analyseDirectoryOutput;
+ }
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/model/AnalyserXMLParser.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/model/AnalyserXMLParser.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,140 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+package com.nokia.s60tools.memspy.model;
+
+import java.io.BufferedReader;
+import java.util.ArrayList;
+
+
+/**
+ * class AnalyserXMLParser.
+ * class that parses symbol and thread name information from debug configuration file.
+ *
+ */
+
+public class AnalyserXMLParser {
+
+ static final String DEBUG_META_DATA_START_TAG = "";
+ static final String DEBUG_META_DATA_END_TAG = " ";
+ static final String THREAD_TAG = "";
+ static final String FILE_NAME = "file name";
+ static final String DIRECTORY_NAME = "directory name";
+
+
+ /**
+ * Add wanted lines from given input to XML generator and returns the generator.
+ * @param reader
+ * @return XML generator
+ */
+ public static AnalyserXMLGenerator parseXML( BufferedReader reader ){
+ AnalyserXMLGenerator retVal = new AnalyserXMLGenerator();
+
+ boolean readingDebugMetaData = false;
+ ArrayList debugMetaDataFiles = new ArrayList();
+ String debugMetaDataDirectory = null;
+ String threadName = "";
+
+ try{
+ String line = "";
+
+ // Go thru file in loop and search for lines that contain debugMetaData -text.
+ // If text is found, save meta data file information into AnalyserXMLGenerator-object.
+
+ while( reader.ready() ){
+
+ line = reader.readLine();
+
+ if( line == null){
+ break;
+ }
+
+ // Search for debug meta data start and end tags.
+ if( line.contains(DEBUG_META_DATA_START_TAG) ){
+ readingDebugMetaData = true;
+ }
+ else if( line.contains(DEBUG_META_DATA_END_TAG) ){
+ readingDebugMetaData = false;
+ }
+
+ // if between debug meta data start and end tags, search for debug meta data info.
+ if( readingDebugMetaData ){
+ if(line.contains(FILE_NAME)){
+ debugMetaDataFiles.add( getMetaDataInfo(line) );
+ }
+ if(line.contains(DIRECTORY_NAME)){
+ debugMetaDataDirectory = getMetaDataInfo(line);
+ }
+ }
+
+ // search for thread name tag.
+ if( line.contains(THREAD_TAG) ){
+ threadName = getThreadName(line);
+ }
+ }
+
+ }
+ catch (Exception e){
+ e.printStackTrace();
+ return null;
+ }
+
+ if(threadName.equals("") ){
+ return null;
+ }
+
+ // check that thread name and at least one symbol file was found.
+ if( debugMetaDataFiles.size() != 0 ){
+ // set found data into AnalyserXMLGenerator-object.
+ retVal.setXMLDebugMetaDataFile(debugMetaDataFiles.toArray(new String [debugMetaDataFiles.size()]));
+ }
+
+ if( !threadName.equals("")){
+ retVal.setXMLDebugMetaDataDirectory(debugMetaDataDirectory);
+ }
+ retVal.setXMLThreadName(threadName);
+
+ return retVal;
+
+ }
+
+ /**
+ * getMetaDataInfo.
+ * @param line String that is parsed
+ * @return string between quotation marks
+ */
+ private static String getMetaDataInfo( String line ) {
+ int firstIndex = line.indexOf("\"") + 1 ;
+ int secondIndex = line.indexOf(("\""), firstIndex );
+ return line.substring(firstIndex, secondIndex);
+ }
+
+
+ /**
+ * getThreadName.
+ * @param line String that is parsed
+ * @return string between threas tags
+ */
+ private static String getThreadName(String line){
+ int firstIndex = line.indexOf("=\"thread\">") + 10;
+ int secondIndex = line.indexOf(" ");
+ return line.substring(firstIndex, secondIndex);
+ }
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/model/CategoryProfile.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/model/CategoryProfile.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,115 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+package com.nokia.s60tools.memspy.model;
+
+import java.util.Iterator;
+import java.util.List;
+
+import com.nokia.s60tools.memspy.ui.dialogs.SWMTCategoryEntry;
+
+/**
+ * Class for one Category Profile
+ */
+public class CategoryProfile {
+
+ private String name;
+
+ private int categories = 0;
+
+ /**
+ * Create a new Category Profile
+ * @param name Profile name
+ */
+ public CategoryProfile(String name) {
+ this.setName(name);
+ }
+
+ /**
+ *
+ * @param name Profile name
+ * @param categories Categories for profile
+ */
+ public CategoryProfile(String name, int categories) {
+ this.categories = categories;
+ this.setName(name);
+ }
+
+ /**
+ * Get profile name
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Set profile name
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Add one or more category to categories
+ * @param categories the categories to set
+ */
+ public void addCategory(int category) {
+ categories = categories & category;
+ }
+
+ /**
+ * Get categories
+ * @return the categories
+ */
+ public int getCategories() {
+ return categories;
+ }
+
+ /**
+ * Get all SWMT categories for this profile
+ * @return the categories
+ */
+ public List getCategoryEntrys() {
+
+ SWMTCategorys cat = SWMTCategorys.getInstance();
+ List categoryEntries = cat.getCategoryEntries(getCategories());
+
+ return categoryEntries;
+ }
+
+ /**
+ * Get names of the Categories added to this profile.
+ * @return list of Category names
+ */
+ public String [] getCategoryEntryNames(){
+ List categoryEntrys = getCategoryEntrys();
+ if(categoryEntrys.isEmpty()){
+ return new String[0];
+ }
+ String[] names = new String[categoryEntrys.size()];
+ int i = 0;
+ for (Iterator iterator = categoryEntrys.iterator(); iterator.hasNext();) {
+ SWMTCategoryEntry entry = (SWMTCategoryEntry) iterator
+ .next();
+ names[i] = entry.getCategoryName();
+ i++;
+ }
+ return names;
+ }
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/model/ImportEngine.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/model/ImportEngine.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,391 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+package com.nokia.s60tools.memspy.model;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import com.nokia.s60tools.memspy.containers.SWMTLogInfo;
+import com.nokia.s60tools.memspy.containers.ThreadInfo;
+import com.nokia.s60tools.memspy.containers.SWMTLogInfo.SWMTLogType;
+import com.nokia.s60tools.memspy.model.AnalyserXMLGenerator.XMLGeneratorAction;
+import com.nokia.s60tools.memspy.ui.views.MemSpyMainView;
+
+/**
+ * Class that is used when importing MemSpy data.
+ * ImportEngine takes care of copying files into predefined file structure that Main View is able to read.
+ */
+public class ImportEngine {
+
+ /* MemSpy's Main View */
+ private MemSpyMainView view;
+
+ /**
+ * Import Engine constructor.
+ * @param view MemSpy's main view
+ */
+ public ImportEngine( MemSpyMainView view ){
+ this.view = view;
+ }
+
+ /**
+ * Imports Heap Dump file(s) and starts heap analyser if only one file was imported. Method also shows
+ * error message if some of operations was not successful.
+ * @param importedHeaps list of imported files
+ * @param symbols symbol information that is used.
+ * @return true, if importing was successful.
+ */
+ public boolean importAndAnalyseHeap( ArrayList importedHeaps, AnalyserXMLGenerator xmlGenerator, boolean startHeapAnalyser ){
+ return importAndAnalyseHeap( importedHeaps, xmlGenerator, startHeapAnalyser, true);
+ }
+
+ /**
+ * Imports Heap Dump file(s) and starts heap analyser if only one file was imported. Method also shows
+ * error message if some of operations was not successful.
+ * @param importedHeaps list of imported files
+ * @param symbols symbol information that is used.
+ * @param deleteTempFiles if temp files and folder should be deleted after import
+ * @return true, if importing was successful.
+ */
+ public boolean importAndAnalyseHeap( ArrayList importedHeaps, AnalyserXMLGenerator xmlGenerator, boolean startHeapAnalyser, boolean deleteTempFiles ){
+
+ boolean importFailed = false;
+
+ // Set xmlGenerators action type correct.
+ xmlGenerator.setXMLAction( XMLGeneratorAction.ANALYSE_HEAP );
+ String fileName = "";
+ for ( ThreadInfo threadInfo : importedHeaps ){
+ fileName = this.moveHeapToImportedFolder( threadInfo );
+ if( fileName != null ){
+ // save new filepath into threadInfo-variable.
+ threadInfo.setThreadFilePath( fileName );
+
+ if( !generateViewConfigurationFile( fileName, threadInfo.getThreadName(), xmlGenerator) ){
+ importFailed = true;
+ }
+
+ }
+ else{
+ importFailed = true;
+ }
+ }
+
+ // if importing was failed, show error message.
+ if( importFailed ){
+ view.showErrorMessage( MemSpyMainView.ERROR_IMPORT_HEADER, MemSpyMainView.ERROR_HEAP_IMPORT_FAILED );
+ return false;
+ }
+
+ // Start heap analyser if only one heap was imported.
+ if( importedHeaps.size() == 1 && startHeapAnalyser ){
+
+ // get configuration files path
+ String analyserFileOutput = importedHeaps.get(0).getThreadFilePath().substring( 0, fileName.lastIndexOf("\\") + 1);
+ analyserFileOutput = analyserFileOutput + "configuration.xml";
+
+ // launch Heap Analyser
+ view.launchHeapAnalyser( analyserFileOutput, null, xmlGenerator.getXMLThreadName(), true );
+
+ }
+
+
+ // Refresh main view so that newly imported files are shown.
+ view.refreshContentAndViewAsync();
+
+ // delete temp folder
+ if(deleteTempFiles){
+ MemSpyFileOperations.deleteTempMemSpyFiles();
+ }
+
+ return true;
+ }
+
+ /**
+ * Move imported heap from temporary file into import directory
+ * @param threadInfo imported heap
+ * @return true if file operations were successful
+ */
+
+ private String moveHeapToImportedFolder( ThreadInfo threadInfo ){
+
+ // Get new file name for imported file.
+ String newFileName = MemSpyFileOperations.getFileNameForHeapDump( threadInfo.getThreadFilePath() );
+
+ if( newFileName == null ){
+ return null;
+ }
+
+ // Move heap dump from temp folder into Heap Dumps-folder
+ if( MemSpyFileOperations.moveFile(new File(threadInfo.getThreadFilePath()), new File(newFileName)) ){
+ return newFileName;
+ }
+ else{
+ return null;
+ }
+ }
+
+ /**
+ * Starts comparing two heap dump files.
+ * @param firstHeap first heap dump
+ * @param secondHeap second heap dump
+ */
+ public void compareHeaps( ThreadInfo firstHeap, ThreadInfo secondHeap, AnalyserXMLGenerator xmlGenerator, String output ){
+
+ boolean importFailed = false;
+
+ // get file paths of heap dumps.
+ String firstHeapFile = firstHeap.getThreadFilePath();
+ String secondHeapFile = secondHeap.getThreadFilePath();
+
+ if( firstHeapFile != null && secondHeapFile != null ){
+
+ // generate compare heaps configuration file.
+ xmlGenerator.setXMLAnalyseFileOutput( output );
+ if( this.generateCompareConfigurationFile( new String[]{ firstHeapFile, secondHeapFile}, firstHeap.getThreadName(), xmlGenerator) ){
+
+ // launch Heap Analyser
+ view.launchHeapAnalyser( MemSpyFileOperations.getCompareConfigurationFilePath(), xmlGenerator.getXMLAnalyseFileOutput(), xmlGenerator.getXMLThreadName(), false );
+ }
+ else{
+ importFailed = true;
+ }
+ }
+ if( importFailed ){
+ view.showErrorMessage( MemSpyMainView.ERROR_IMPORT_HEADER, MemSpyMainView.ERROR_HEAP_IMPORT_FAILED);
+ }
+
+ }
+
+
+ /**
+ * Imports SystemWide Memory Tracking logs and starts swmt viewer.
+ * @param importedLogs imported swmt logs.
+ */
+ public void importSWMTLogs( final ArrayList importedLogs ){
+ importSWMTLogs( importedLogs, true);
+ }
+
+ /**
+ * Imports SystemWide Memory Tracking logs and starts swmt viewer.
+ * @param importedLogs imported swmt logs.
+ * @param deleteTempFiles if temp files and folder should be deleted after import
+ */
+ public void importSWMTLogs( final ArrayList importedLogs, boolean deleteTempFiles){
+
+ boolean isImportedFromDevice = false;
+ boolean importFailed = false;
+
+ // check if files were imported from device.
+ if( importedLogs.size() > 0 ){
+ if (importedLogs.get(0).getType() == SWMTLogType.DEVICE ){
+ isImportedFromDevice = true;
+ }
+ }
+
+ ArrayList directories = new ArrayList();
+
+ // If files were imported from device, move those files into imported directory.
+ if( isImportedFromDevice ){
+
+ for( SWMTLogInfo swmtLogInfo : importedLogs){
+
+ // Get next free directory
+ String directory = MemSpyFileOperations.getNextFreeDirectory();
+ directory = MemSpyFileOperations.addSlashToEnd( directory );
+
+ // Add directory to arraylist
+ directories.add( directory );
+
+ if( !MemSpyFileOperations.copyFileToDirectory( swmtLogInfo.getPath(), directory ) ){
+
+ // if operations fail show error message and remove all imported files.
+ importFailed = true;
+ MemSpyFileOperations.deleteDir( new File( directory ) );
+ break;
+ }
+ }
+ }
+ else{// if importing log from file system, copy files into imported directory
+
+ for( SWMTLogInfo swmtLogInfo : importedLogs){
+
+ // if file
+ if( swmtLogInfo.getType() == SWMTLogType.FILE ){
+
+ // Get next free directory
+ String directory = MemSpyFileOperations.getNextFreeDirectory();
+ directory = MemSpyFileOperations.addSlashToEnd( directory );
+
+ // Add directory to arraylist
+ directories.add( directory );
+
+ if( !MemSpyFileOperations.copyFileToDirectory( swmtLogInfo.getPath(), directory ) ){
+
+ // if operation fails show error message and remove all imported files.
+ importFailed = true;
+ MemSpyFileOperations.deleteDir( new File( directory ) );
+ break;
+ }
+ }
+
+
+ }
+
+ }
+ // if error occurred show error message
+ if( importFailed ){
+ view.showErrorMessage( MemSpyMainView.ERROR_IMPORT_HEADER, MemSpyMainView.ERROR_SWMT_IMPORT_FAILED);
+ }
+ else{
+ // Get ArrayList of imported files.
+ ArrayList files = new ArrayList();
+ try{
+ for( String item : directories ){
+ // Get filename from Log file from each directory that is saved into directories-ArrayList.
+ File directory = new File(item);
+ String fileName = directory.list()[0];
+ fileName = item + fileName;
+ files.add( fileName );
+ }
+ view.launchSWMTAnalyser( files );
+
+ }
+ catch( Exception e ){
+ view.showErrorMessage( MemSpyMainView.ERROR_IMPORT_HEADER, MemSpyMainView.ERROR_LAUNCH_SWMT_ANALYSER );
+ }
+
+ }
+
+ // Refresh main view so that newly imported files are shown.
+ view.refreshContentAndViewAsync();
+
+ // delete temp folder
+ if(deleteTempFiles){
+ MemSpyFileOperations.deleteTempMemSpyFiles();
+ }
+
+
+
+
+ }
+
+
+ /**
+ * Uses AnalyserXMLGenerator to generate configuration file for viewing heap with Heap Analyser
+ * @param name of the source file
+ * @param threadName thread's name
+ * @param xmlGenerator XML generator that is used.
+ * @return true if file was generated successfully
+ */
+ public boolean generateViewConfigurationFile( String fileName, String threadName, AnalyserXMLGenerator xmlGenerator ){
+
+ xmlGenerator.setXMLAction(XMLGeneratorAction.ANALYSE_HEAP);
+ xmlGenerator.setXMLSourceFile( new String[]{ fileName } );
+ xmlGenerator.setXMLThreadName( threadName );
+
+ // get filenames path
+ String analyserFileOutput = fileName.substring( 0, fileName.lastIndexOf("\\") + 1);
+ analyserFileOutput = analyserFileOutput + "configuration.xml";
+
+ // generate xml-file
+
+ File filename = new File( analyserFileOutput );
+ BufferedWriter writer = null;
+
+ try {
+ // Construct FileWriter and print xml into that stream
+ writer = new BufferedWriter(new FileWriter(filename));
+ xmlGenerator.GenerateXML(writer);
+ }
+ catch (IOException e) {
+
+ e.printStackTrace();
+ return false;
+ }
+ finally {
+ try {
+ if (writer != null) {
+ writer.flush();
+ writer.close();
+ return true;
+ }
+ }
+ catch (IOException ex) {
+ ex.printStackTrace();
+ return false;
+ }
+
+ }
+ return false;
+ }
+
+ /**
+ * Uses AnalyserXMLGenerator to generate configuration file for comparing two heap's with Heap Analyser
+ * @param fileName names of the source files.
+ * @param threadName thread's name
+ * @param xmlGenerator XML generator that is used.
+ * @return true if file was generated successfully
+ */
+ public boolean generateCompareConfigurationFile( String[] fileName, String threadName, AnalyserXMLGenerator xmlGenerator ){
+ xmlGenerator.setXMLAction(XMLGeneratorAction.COMPARE_HEAPS);
+ xmlGenerator.setXMLSourceFile( fileName );
+ xmlGenerator.setXMLThreadName( threadName );
+
+ String analyserFileOutput = MemSpyFileOperations.getCompareConfigurationFilePath();
+
+ // generate xml-file
+ File filename = new File( analyserFileOutput );
+
+
+ BufferedWriter writer = null;
+
+ try {
+ // Construct FileWriter and print xml into that stream
+ writer = new BufferedWriter(new FileWriter(filename));
+ xmlGenerator.GenerateXML(writer);
+ }
+ catch (IOException e) {
+
+ e.printStackTrace();
+ return false;
+ }
+ finally {
+ try {
+ if (writer != null) {
+ writer.flush();
+ writer.close();
+ return true;
+ }
+ }
+ catch (IOException ex) {
+ ex.printStackTrace();
+ return false;
+ }
+
+ }
+ return false;
+
+ }
+
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/model/MemSpyFileBundle.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/model/MemSpyFileBundle.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,414 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+package com.nokia.s60tools.memspy.model;
+
+
+import java.io.File;
+import java.util.Date;
+
+import com.nokia.s60tools.memspy.files.HeapDumpFile;
+import com.nokia.s60tools.memspy.files.SWMTFile;
+
+/**
+ * MemSpyBundle class bundles up one folder under MemSpy plugin's folder. I.e. one
+ * MemSpyFileBundle is one row in MainView. A Bundle can contain an Heap Dump file or
+ *
+ * SWMT-log file. All of the file listed above are found e.g. from
+ * c:\my_carbide_workspace\.metadata\.plugins\com.nokia.s60tools.memspy\ImportedFiles[bundle folder]
+ *
+ * Bundle can also be a waiting bundle, so that 'Loading files. Please wait' row can be shown in MainView.
+ *
+ */
+public class MemSpyFileBundle {
+
+ public static final int INDEX_FILE_TYPE = 0;
+ public static final int INDEX_FILE_NAME = 1;
+ public static final int INDEX_TIME = 2;
+
+
+ /*
+ * Heap Dump file
+ */
+ private HeapDumpFile heapDumpFile = null;
+
+ /*
+ * SWMT-log file
+ */
+ private SWMTFile swmtFile = null;
+
+ /**
+ * Bundle name for an empty or waiting bundle
+ */
+ private String bundleName = "";
+
+ /**
+ * Folder where all bundle's files can be found from
+ */
+ private String bundleFolder = "";
+
+ /**
+ * If true, bundle is an empty or waiting bundle
+ */
+ private boolean emptyFile = false;
+
+ /**
+ * Used for creating an empty or waiting bundle
+ * @param empty If true
, an empty bundle is created. If false
, a waiting bundle is created.
+ */
+ public MemSpyFileBundle(boolean empty) {
+ if (empty)
+ bundleName = "No Crash Files Found.";
+ else
+ bundleName = "Loading files. Please wait.";
+ emptyFile = true;
+ }
+
+ /**
+ * Creates a bundle from folder
+ * @param folder Bundle folder. Bundle's file will be read from here.
+ */
+ public MemSpyFileBundle( String folder ) {
+ bundleFolder = MemSpyFileOperations.addSlashToEnd(folder);
+
+ heapDumpFile = HeapDumpFile.read( folder );
+ swmtFile = SWMTFile.read( folder );
+
+ }
+
+ /**
+ * Create dummy bundle.
+ * @param folder where files are searched.
+ * @return returns new bundle.
+ */
+ public static MemSpyFileBundle createDummyBundle(String folder) {
+ return new MemSpyFileBundle(folder);
+ }
+
+ /**
+ * MainView can use this to get description for each column in the grid
+ * @param index index of the column
+ * @return value for asked column
+ */
+ public String getText(int index) {
+ String retval = "";
+ switch (index) {
+ case INDEX_TIME:
+ retval = this.getTime();
+ break;
+
+ case INDEX_FILE_NAME:
+ retval = this.getFileName();
+ break;
+
+ case INDEX_FILE_TYPE:
+ retval = this.getFileType();
+ break;
+
+ default:
+ break;
+ }
+
+ return retval;
+ }
+
+ /**
+ * Get file type.
+ * @return type of file.
+ */
+ public String getFileType() {
+ if (emptyFile)
+ return bundleName;
+
+ String retval = "";
+
+ if ( this.heapDumpFile != null) {
+ retval = heapDumpFile.getFileType();
+ }
+
+ if( swmtFile != null ){
+ retval = this.swmtFile.getFileType();
+ }
+
+ return retval;
+ }
+
+
+ /**
+ * Returns the file name for this bundle. File name depends on what types
+ * of files this bundle contains (or if this bundle is an empty or waiting bundle).
+ *
+ * @return the file name for this bundle.
+ */
+ public String getFileName() {
+ if (emptyFile)
+ return bundleName;
+
+ String retval = "";
+
+ if ( this.heapDumpFile != null) {
+ retval = heapDumpFile.getFileName();
+ }
+ else if( swmtFile != null ){
+ retval = this.swmtFile.getFileName();
+ }
+
+ return retval;
+ }
+
+ /**
+ * Get the Cycle number from FileName.
+ * E.g. if file name is: "MemSpy SWMT-log 12.08.2009 08-40-22 Cycle 3"
+ * will return '3'.
+ *
+ * @return the cycle number from file name for this bundle, or -1 if can't found.
+ */
+ public int getCycleNumberFromFileName() {
+ int retval = -1;
+ if (emptyFile){
+ return retval;
+ }
+
+ String fileName = "";
+
+ if ( this.heapDumpFile != null) {
+ fileName = heapDumpFile.getFileName();
+ }
+ else if( swmtFile != null ){
+ fileName = this.swmtFile.getFileName();
+ }
+
+ if(fileName != null && fileName.indexOf(MemSpyFileOperations.CYCLE) != -1){
+ int index = fileName.indexOf(MemSpyFileOperations.CYCLE);
+ String cycle = fileName.substring((index + MemSpyFileOperations.CYCLE.length())).trim();
+ cycle = cycle.substring(0, cycle.indexOf('.'));
+ try {
+ retval = Integer.parseInt(cycle);
+ } catch (NumberFormatException e) {
+ e.printStackTrace();
+ retval = -1;
+ }
+ }
+
+ return retval;
+ }
+
+ /**
+ * Get Time
+ * @return time of file creation.
+ */
+ public String getTime() {
+ if (emptyFile)
+ return "";
+ String retval = "";
+
+ if( heapDumpFile != null ){
+ retval = this.heapDumpFile.getTime();
+ }
+ else if( swmtFile != null ){
+ retval = this.swmtFile.getTime();
+ }
+
+
+ return retval;
+ }
+
+ /**
+ * Get time as long
+ * @return time of file creation as long.
+ */
+ public long getTimeAsLong(){
+ long time = -1;
+ Date date = null;
+ if( heapDumpFile != null ){
+ date = this.heapDumpFile.getDateTime();
+ }
+ else if( swmtFile != null ){
+ date = this.swmtFile.getDateTime();
+ }
+
+ if(date != null){
+ time = date.getTime();
+ }
+
+ return time;
+ }
+
+
+ /**
+ * Get XML file.
+ * @return XML-files path
+ */
+ public String getXMLFilePath() {
+ if( heapDumpFile != null ){
+ return this.heapDumpFile.getXmlPath();
+ }
+ else{
+ return null;
+ }
+ }
+
+ /**
+ * Get file path.
+ * @return Files complete path.
+ */
+ public String getFilePath(){
+ if (emptyFile)
+ return "";
+ String retval = "";
+
+ if( heapDumpFile != null ){
+ retval = this.heapDumpFile.getFilePath();
+ }
+
+ if( swmtFile != null ){
+ retval = this.swmtFile.getFilePath();
+ }
+
+
+ return retval;
+ }
+
+
+ /**
+ * Returns whether this is an empty or waiting bundle.
+ * @return true if bundle is empty or waiting, false if not.
+ */
+ public boolean isEmpty() {
+ return emptyFile;
+ }
+
+
+
+ /**
+ * Returns whether this bundle contains any files.
+ * @return true if bundle contains files, false if not
+ */
+ public boolean hasFiles() {
+ if ( heapDumpFile != null || swmtFile != null )
+ return true;
+
+ return false;
+ }
+
+
+
+ /**
+ * Tests whether this bundle still exists in the drive.
+ * If bundle is empty or waiting, true is always returned.
+ *
+ * @return true
if bundle exists, false
if not.
+ */
+ public boolean exists() {
+ if (isEmpty())
+ return true;
+
+ try {
+ File f = new File(bundleFolder);
+ if (f.isDirectory() && f.exists())
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+
+ return false;
+ }
+
+
+
+ /**
+ * Returns this bundle's folder
+ * @return bundle's folder or empty
+ */
+ protected String getBundleFolder() {
+ return bundleFolder;
+ }
+
+
+ /**
+ * Has this bundle a SWMT log file.
+ * @return true
if this bundle has SWMT-log false
otherwise.
+ */
+ public boolean hasSWMTLogFile(){
+ if( swmtFile != null ){
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Has this bundle a heap dump file
+ * @return true
if this bundle has Heap Dump false
otherwise.
+ */
+ public boolean hasHeapDumpFile(){
+
+ if( heapDumpFile != null ){
+ return true;
+
+ }
+ return false;
+
+ }
+
+ /**
+ * Deletes this bundle. I.e deletes all files under this
+ * bundle's folder and finally deletes the bundle folder.
+ */
+ public boolean delete() {
+ if (!"".equals(bundleFolder)) {
+ return !MemSpyFileOperations.deleteDir( new File( bundleFolder ) );
+ }
+ else{
+ return false;
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString(){
+ if(swmtFile != null){
+ return swmtFile.getFilePath();
+ }
+ else{
+ return null;
+ }
+ }
+
+ /**
+ * Checks if bundles are equal. Two bundles are equal if
+ * their bundleFolder is the same.
+ */
+ public boolean equals(Object other) {
+ if (this == other)
+ return true;
+
+ if (!(other instanceof MemSpyFileBundle))
+ return false;
+
+ MemSpyFileBundle othr = (MemSpyFileBundle)other;
+ if (bundleFolder.compareToIgnoreCase(othr.getBundleFolder()) == 0)
+ return true;
+ return false;
+ }
+
+
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/model/MemSpyFileManager.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/model/MemSpyFileManager.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,207 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+package com.nokia.s60tools.memspy.model;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.ILock;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.swt.widgets.Display;
+
+import com.nokia.s60tools.memspy.interfaces.INewMemSpyFilesObserver;
+
+
+/**
+ * This class is responsible for providing MemSpy files to MainView's content provider.
+ * This class read workspace specific files from disk and prepares them for main view.
+ */
+public class MemSpyFileManager extends Job {
+ private List memSpyFiles = null;
+ private INewMemSpyFilesObserver filesObserver = null;
+ private ILock accessLock = null;
+ private boolean restart = false;
+ private boolean jobRunning = false;
+
+
+ /**
+ * Constructor.
+ * @param observer, which is notified when reading is finished.
+ */
+ public MemSpyFileManager( INewMemSpyFilesObserver observer ) {
+ super("MemSpy - Reading Files");
+ filesObserver = observer;
+ memSpyFiles = null;
+ accessLock = Job.getJobManager().newLock();
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ protected IStatus run(IProgressMonitor monitor) {
+ accessLock.acquire();
+ try {
+ jobRunning = true;
+ if (memSpyFiles == null) {
+ memSpyFiles = new ArrayList();
+ } else {
+
+ // remove no longer existing files
+ for (int i = 0; i < memSpyFiles.size(); i++) {
+ MemSpyFileBundle file = memSpyFiles.get(i);
+ if (!file.exists()) {
+ memSpyFiles.remove(i);
+ i--;
+ }
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ accessLock.release();
+ }
+
+ //get directory
+ File cFilesFolder = new File( MemSpyFileOperations.getImportedDirectory() );
+
+ if (cFilesFolder.exists() && cFilesFolder.isDirectory()) {
+
+ // get folders and files in imported directory
+ File[] folders = cFilesFolder.listFiles();
+ if (folders != null) {
+ for (int j = 0; j < folders.length; j++) {
+ File cFolder = folders[j];
+ if (cFolder.isDirectory()) {
+ accessLock.acquire();
+ try {
+
+ MemSpyFileBundle dummy = MemSpyFileBundle.createDummyBundle(cFolder.getAbsolutePath());
+ if (!memSpyFiles.contains(dummy)) {
+ accessLock.release();
+ MemSpyFileBundle bundle = new MemSpyFileBundle(cFolder.getAbsolutePath());
+ if (bundle.hasFiles()) {
+ accessLock.acquire();
+ memSpyFiles.add(bundle);
+ }
+ }
+ else {
+ accessLock.release();
+ MemSpyFileBundle bundle = new MemSpyFileBundle(cFolder.getAbsolutePath());
+ if (bundle.hasFiles()) {
+ accessLock.acquire();
+ memSpyFiles.remove(dummy);
+ memSpyFiles.add(bundle);
+ }
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ finally {
+ accessLock.release();
+ }
+ }
+ }
+ }
+ }
+
+ filesObserver.memSpyFilesUpdated();
+
+ accessLock.acquire();
+ if (restart) {
+ restart = false;
+ accessLock.release();
+ reSchedule();
+ }
+ else {
+ jobRunning = false;
+ accessLock.release();
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * Re schelude this job
+ * @see Job#schedule()
+ */
+ void reSchedule() {
+ Runnable refreshRunnable = new Runnable(){
+ public void run(){
+ schedule(100);
+ }
+ };
+
+ Display.getDefault().asyncExec(refreshRunnable);
+ }
+
+ /**
+ * Get all MemSpy files for main view to use
+ * @return files
+ */
+ public MemSpyFileBundle[] getmemSpyFiles() {
+ // files have not yet been read, start reading process
+ if (memSpyFiles == null) {
+ if(jobRunning == false){
+ jobRunning = true;
+ setPriority(Job.LONG);
+ setUser(false);
+ schedule(100);
+ }
+ MemSpyFileBundle[] cFiles = new MemSpyFileBundle[1];
+ cFiles[0] = new MemSpyFileBundle(false);
+ return cFiles;
+ }
+ else{
+ return memSpyFiles.toArray(new MemSpyFileBundle[memSpyFiles.size()]);
+ }
+
+ }
+
+
+ /**
+ * Refresh content. Reads files from disk again.
+ * @see MemSpyFileManager#run(IProgressMonitor)
+ */
+ public void refresh() {
+
+ accessLock.acquire();
+ try {
+ if (jobRunning) {
+ restart = true;
+ } else {
+ setPriority(Job.LONG);
+ setUser(false);
+ schedule(100);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ accessLock.release();
+ }
+ }
+
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/model/MemSpyFileNameFilter.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/model/MemSpyFileNameFilter.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+package com.nokia.s60tools.memspy.model;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+/**
+ * File name filter for MemSpy log files(*.log, *.txt)
+ */
+public class MemSpyFileNameFilter implements FilenameFilter{
+
+ /* (non-Javadoc)
+ * @see java.io.FilenameFilter#accept(java.io.File, java.lang.String)
+ */
+ public boolean accept(File dir, String name) {
+ if( name.endsWith(".txt") || name.endsWith(".log") ){
+ return true;
+ }
+ else{
+ return false;
+ }
+ }
+}
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/model/MemSpyFileOperations.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/model/MemSpyFileOperations.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,372 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+package com.nokia.s60tools.memspy.model;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Platform;
+
+import com.nokia.s60tools.memspy.plugin.MemSpyPlugin;
+
+/**
+ * Utilities for handling MemSpy specific file operation
+ */
+public class MemSpyFileOperations {
+
+ private static final String TEMP = "\\Temp";
+
+ /**
+ * Cycle
+ */
+ public static final String CYCLE = "Cycle";
+
+ /**
+ * Date format "dd.MM.yyyy HH:mm:ss"
+ */
+ public final static String DATEFORMAT = "dd.MM.yyyy HH:mm:ss";
+
+ private final static String SWMT_LOG_TEXT = "MemSpy SWMT-log";
+ private final static String CONFIGURATION_DIRECTORY_NAME = "ConfigurationFiles";
+ private final static String IMPORTED_DIRECTORY_NAME = "ImportedData";
+
+
+ /**
+ * Generates file name for new temporary heap dump file based on threads name and current time
+ * @param threadName Name of the thread
+ * @param date date when log has been imported
+ * @return new file name
+ */
+ public static String getFileNameForTempHeapDump( String threadName, Date date){
+
+
+ // Format the current time.
+ SimpleDateFormat formatter = new SimpleDateFormat ( DATEFORMAT );
+ String dateString = formatter.format(date);
+ String threadFileName = threadName + " " + dateString + ".txt" ;
+
+ // replace :'s with -'s as :'s cannot be on file names.
+ threadFileName = threadFileName.replace(':', '-');
+
+ //String folder = Platform.getConfigurationLocation().getURL().getFile() + "memspy\\Temp";
+ String folder = MemSpyFileOperations.getPluginWorkingLocation() + TEMP;
+
+ // create directory if needed
+ File file1 = new File(folder);
+ if( !file1.exists() ){
+ if( !file1.mkdirs() ){
+ return null;
+ }
+ }
+
+ // combine directory and filename
+ String filePath = folder + "\\"+ threadFileName;
+ return filePath;
+ }
+
+
+
+
+ /**
+ * Copies file into another location
+ * @param inputFile input file where file is currently found
+ * @param outputFile output file where file is copied
+ * @return true if file operations were successful
+ */
+ public static boolean copyFile( File inputFile, File outputFile ){
+ FileReader in;
+ try {
+
+ // create file reader and writer
+ in = new FileReader(inputFile);
+ FileWriter out = new FileWriter(outputFile);
+ int c;
+
+ // Read line from input file and write it into output file.
+ while ((c = in.read()) != -1){
+ out.write(c);
+ }
+
+ // close files
+ in.close();
+ out.close();
+ }
+ catch (FileNotFoundException e) {
+ return false;
+ }
+ catch (IOException e) {
+ return false;
+ }
+ return true;
+
+ }
+
+
+ /**
+ * Moves file into another location
+ * @param inputFile input file where file is currently found
+ * @param outputFile output file where file is moved
+ * @return true
if file operations were successful false
otherwise.
+ * @see File#renameTo(File)
+ */
+ public static boolean moveFile(File inputFile, File outputFile ){
+
+ // Move file into new directory
+ return inputFile.renameTo(outputFile);
+ }
+
+
+ /**
+ * Generates file name for new heap dump file based on threads name and current time
+ * @param currentFileName current temporary file name
+ * @return new file name
+ */
+ public static String getFileNameForHeapDump(String currentFileName){
+
+ // Get Filename
+ String threadFileName = currentFileName.substring( currentFileName.lastIndexOf("\\") +1 );
+ String folder = MemSpyFileOperations.getNextFreeDirectory();
+ if( folder == null){
+ return null;
+ }
+
+ folder = addSlashToEnd( folder );
+ folder = folder + threadFileName;
+
+ return folder;
+ }
+
+ /**
+ * Returns a path where Crash Analyser plugin can do various tasks (located under workspace).
+ * @return E.g. C:\My_Workspace\.metadata\.plugins\[plugin name]\
+ */
+ public static String getPluginWorkingLocation() {
+ IPath location = Platform.getStateLocation( MemSpyPlugin.getDefault().getBundle());
+ return location.toOSString();
+ }
+
+ /**
+ * Deletes directory and everything inside.
+ * @param dir directory name
+ * @return true if file operations were successful
+ */
+ public static boolean deleteDir(File dir) {
+ boolean isAllDeleted = deleteFiles(dir);
+ // after everything inside directory is deleted, remove directory itself.
+ return dir.delete() && isAllDeleted;
+ }
+
+
+
+
+ /**
+ * Delete files from dir, but leave the dir as it is.
+ * @param dir
+ * @return true
if all files and subdirectories was deleted successfully, false
otherwise.
+ */
+ public static boolean deleteFiles(File dir) {
+ boolean isAllDeleted = true;
+ if ( dir.isDirectory() ) {
+
+ // get list of everything inside file.
+ String[] children = dir.list();
+
+ // go thru file list and call this function recursively.
+ for ( int i=0; i < children.length; i++) {
+ boolean success = deleteDir(new File(dir, children[i]));
+ if (!success) {
+ isAllDeleted = false;
+ }
+ }
+ }
+ return isAllDeleted;
+ }
+
+ /**
+ * Returns all list of all log files(*.txt and *.log) from directory
+ * @param directory where from list is received
+ * @return files found in directory
+ */
+ public static File[] getFilesFromDirectory(File directory){
+ FilenameFilter filter = new MemSpyFileNameFilter();
+ return directory.listFiles( filter );
+ }
+
+ /**
+ * Get temporary SWMT file name with path
+ * @param cycleNumber cycle number or received heap
+ * @param date current date
+ * @return temp file name, null if operation was failed.
+ */
+ public static String getTempFileNameForSWMTLog( int cycleNumber, Date date ) {
+
+
+ // Format the current time.
+ SimpleDateFormat formatter = new SimpleDateFormat ( DATEFORMAT );
+ String dateString = formatter.format(date);
+
+ String fileName = SWMT_LOG_TEXT + " " + dateString + " " + CYCLE + " " + Integer.toString(cycleNumber) + ".txt";
+
+ // replace :'s with -'s as :'s cannot be on file names.
+ fileName = fileName.replace(':', '-');
+
+ String folder = MemSpyFileOperations.getPluginWorkingLocation() + TEMP;
+
+ // create directory if needed
+ File file1 = new File(folder);
+ if( !file1.exists() ){
+ if( !file1.mkdirs() ){
+ return null;
+ }
+ }
+ String filePath = file1.toString() + "\\"+ fileName;
+ return filePath;
+ }
+
+ /**
+ * Deletes MemSpy's temp directory and everything inside it
+ * @return true
if operation was successful false
otherwise.
+ */
+ public static boolean deleteTempMemSpyFiles(){
+ File folder = new File( MemSpyFileOperations.getPluginWorkingLocation() + TEMP );
+ return deleteDir(folder);
+
+ }
+
+
+ /**
+ * Creates next free directory for MemSpy data files
+ * @return next free directory where files can be copied.
+ */
+ public static String getNextFreeDirectory(){
+
+ // Get fileList from importedHeaps-directory
+ String directory = MemSpyFileOperations.getImportedDirectory();
+ File file = new File( directory );
+ String[] fileList = file.list();
+ directory = MemSpyFileOperations.addSlashToEnd( directory );
+
+
+ int i = 0;
+
+ File newFile = null;
+
+
+ // if ImportedHeaps-directory is found
+ if( fileList != null ){
+ // Go thru directory in a loop and find search for first free integer value for directory name.
+ while( i <= fileList.length ){
+
+ newFile = new File( directory + Integer.toString(i) );
+ if ( !newFile.isDirectory() )
+ {
+ break;
+ }
+ i++;
+ }
+ }
+ else{
+ newFile = new File( directory + "0" );
+ }
+
+ // if directories are created successfully, return path, if not return null
+ if( newFile.mkdirs() ){
+ String newFileString = MemSpyFileOperations.addSlashToEnd( newFile.toString() );
+ return newFileString;
+ }
+ else{
+ return null;
+ }
+
+ }
+
+ /**
+ * If the last character of the given path is not backslash, it is added
+ * and path with backslash is returned.
+ * @param path Path to which backslash is added
+ * @return Path which last character is backslash
+ */
+ public static String addSlashToEnd(String path) {
+ if (path.endsWith(File.separator)){
+ return path;
+ }
+ else{
+ return path + File.separator;
+ }
+ }
+
+ /**
+ * Get imported files directory
+ * @return path of the imported-directory
+ */
+ public static String getImportedDirectory(){
+ // get imported-directory
+ String directory = MemSpyFileOperations.getPluginWorkingLocation();
+ directory = MemSpyFileOperations.addSlashToEnd( directory );
+ return directory + IMPORTED_DIRECTORY_NAME;
+ }
+
+ /**
+ * Get configuration file path
+ * @return path of the configuration file, if file does not exist yet, method creates it.
+ */
+ public static String getCompareConfigurationFilePath(){
+ // get imported-directory
+ String directory = MemSpyFileOperations.getPluginWorkingLocation();
+ directory = MemSpyFileOperations.addSlashToEnd( directory );
+ directory = directory + CONFIGURATION_DIRECTORY_NAME;
+
+ File file = new File(directory);
+ if( !file.exists() ){
+ if( !file.mkdirs() ){
+ return null;
+ }
+ }
+ directory = MemSpyFileOperations.addSlashToEnd(directory);
+ directory = directory + "input.xml";
+ return directory;
+
+ }
+
+ /**
+ * Copies file to another directory with same filename
+ * @param filePath file that is copied
+ * @param directory output directory
+ * @return true
if operation was successful false
otherwise.
+ */
+ public static boolean copyFileToDirectory( String filePath, String directory){
+
+ String fileName = filePath.substring( filePath.lastIndexOf("\\") +1 );
+ String directoryTo = directory + fileName;
+
+ return copyFile( new File( filePath ), new File( directoryTo ) );
+
+ }
+
+
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/model/MemSpyLogParserEngine.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/model/MemSpyLogParserEngine.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,213 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+package com.nokia.s60tools.memspy.model;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Date;
+
+import com.nokia.s60tools.memspy.containers.ThreadInfo;
+import com.nokia.s60tools.memspy.containers.ThreadInfo.HeapDumpType;
+
+/**
+ * Heap Dump parser that is used when parsing heap dump file.
+ */
+public class MemSpyLogParserEngine {
+
+ // Writer that writes into file
+ private PrintWriter plainOutput;
+
+ private boolean fileOpen;
+
+ /**
+ *
+ * Checks that at least one heap info with binary data information is found from file given as parameter.
+ * Function also saves thread names from heap dump file into ArrayList what
+ * was given as parameter threadNames.
+ *
+ * @param file
+ * @param threadNames
+ * Arraylist where thread names are saved.
+ * @return true if threads containing binary data information were found from this file.
+ */
+ public boolean isFileHeapDumpFile(File file,
+ ArrayList threadNames) {
+
+ boolean heapFound = false;
+ boolean heapDataFound = false;
+ boolean heapDataErrorFound = false;
+
+ try {
+ String heapInfo = "HEAP INFO FOR THREAD";
+ String heapData = "Heap Data";
+ String heapDataError = "Heap error";
+
+ BufferedReader reader = new BufferedReader(new FileReader(file));
+ String line = "";
+
+ // Go thru file in loop and search for lines that contain HEAP
+ // INFO-text. If text is found, save thread names into array list
+ // threadNames. If the thread doesn't contain any binary heap data information,
+ // the thread is removed from this array list.
+
+ while (reader.ready()) {
+ line = reader.readLine();
+ if (line.contains(heapInfo)) {
+
+ if ((heapDataFound && heapDataErrorFound) || !heapDataFound) {
+ if (threadNames.size() > 0) {
+ threadNames.remove(threadNames.size() - 1);
+ }
+ }
+
+ heapDataFound = false;
+ heapDataErrorFound = false;
+
+ if (line.contains("'")) {
+ String name = line.substring(line.indexOf("'") + 1);
+ if (name.contains("'")) {
+ String thread = name
+ .substring(0, name.indexOf("'"));
+ ThreadInfo threadInfo = new ThreadInfo();
+ threadInfo.setThreadName(thread);
+ Date date = new Date();
+ threadInfo.setDate(date);
+ threadInfo.setType(HeapDumpType.FILE);
+ String fName = MemSpyFileOperations
+ .getFileNameForTempHeapDump(thread, date);
+ threadInfo.setThreadFilePath(fName);
+ threadNames.add(threadInfo);
+
+ if (fileOpen) {
+ plainOutput.flush();
+ plainOutput.close();
+ }
+ if (!this.openFile(fName)) {
+ return false;
+ }
+ }
+ }
+ }
+
+ // Checking if the line contains binary heap data header
+ if (line.contains(heapData)) {
+ heapDataFound = true;
+ }
+
+ // Checking if the line contains binary heap data error
+ if (line.contains(heapDataError)) {
+ heapDataErrorFound = true;
+ }
+
+ if (fileOpen) {
+ plainOutput.write(line + "\n");
+ }
+ }
+
+ // Check for the last thread in file, because if the last thread is found and if it
+ // contains heap data with error or no heap data at all, it wouldn't be removed
+ // so it needs to be done here
+ if ((heapDataFound && heapDataErrorFound) || !heapDataFound) {
+ if (threadNames.size() > 0) {
+ threadNames.remove(threadNames.size() - 1);
+ }
+ }
+
+ if (threadNames.size() > 0) {
+ heapFound = true;
+ } else {
+ heapFound = false;
+ }
+
+ if (fileOpen) {
+ plainOutput.close();
+ fileOpen = false;
+ }
+ } catch (Exception e) {
+ return false;
+ }
+ return heapFound;
+ }
+
+ /**
+ * openFile creates new print writer into given path and saves it into
+ * member variable plainOutput
+ *
+ * @param fName
+ * file name
+ * @return true if file operation was successful
+ */
+ private boolean openFile(String fName) {
+ // If file needs to be opened, open it.
+
+ try {
+ plainOutput = new PrintWriter(new FileWriter(fName));
+ } catch (IOException e) {
+ return false;
+ }
+ this.fileOpen = true;
+ return true;
+ }
+
+ /**
+ * Check if this file is a SWMT log file
+ *
+ * @param file
+ * @return true
if file contains a SWMT tag:
+ * {@link TraceCoreDataHandler#LAUNCHER_SWMT_LOG_START}
+ * false
otherwise.
+ */
+ static public boolean isFileSWMTLog(File file) {
+ try {
+ String SWMTTag = TraceCoreDataHandler.LAUNCHER_SWMT_LOG_START;
+ BufferedReader reader = new BufferedReader(new FileReader(file));
+ String line = "";
+ int count = 0;
+
+ // Go thru file in loop and check if first line of file contains
+ // swmt-tag.
+
+ while (reader.ready() && count < 200) {
+ line = reader.readLine();
+ count++;
+
+ // if line contains tag, conclude that file is swmt-log
+ if (line.contains(SWMTTag)) {
+ return true;
+ }
+
+ // if line is other than empty, conclude that file is not
+ // swmt-log
+ if (line.length() > 0) {
+ return false;
+ }
+ }
+
+ } catch (Exception e) {
+ return false;
+ }
+
+ // if first 200 lines were empty, conclude that file is not SWMT-log
+ return false;
+ }
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/model/SWMTCategoryConstants.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/model/SWMTCategoryConstants.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,145 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+package com.nokia.s60tools.memspy.model;
+
+import com.nokia.s60tools.util.debug.DbgUtility;
+
+/**
+ * Lists all the category constants that can be used with SWMT
+ */
+public class SWMTCategoryConstants {
+ public static final int CATEGORY_NONE = 0x0; // This is not used currently anywhere, but however available for use
+ public static final int CATEGORY_FILESERVERCACHE = 0x0001;
+ public static final int CATEGORY_BITMAPHANDLES = 0x0002;
+ public static final int CATEGORY_USERHEAP = 0x0004;
+ public static final int CATEGORY_KERNELHEAP = 0x0008;
+ public static final int CATEGORY_LOCALCHUNKS = 0x0010;
+ public static final int CATEGORY_GLOBALCHUNKS = 0x0020;
+ public static final int CATEGORY_RAMDRIVE = 0x0040;
+ public static final int CATEGORY_USERSTACKS = 0x0080;
+ public static final int CATEGORY_GLOBALDATA = 0x0100;
+ public static final int CATEGORY_RAMLOADEDCODE = 0x0200;
+ public static final int CATEGORY_KERNELHANDLES = 0x0400;
+ public static final int CATEGORY_OPENFILES = 0x0800;
+ public static final int CATEGORY_DISKUSAGE = 0x1000;
+ public static final int CATEGORY_SYSTEMMEMORY = 0x2000;
+ public static final int CATEGORY_WINDOWGROUPS = 0x4000;
+ public static final int CATEGORY_ALL = 0xFFFF; // This is default value in case user has not skipped any categories
+
+ /**
+ * Category profile constant for Basic Profile
+ */
+ public static final int PROFILE_BASIC = CATEGORY_USERHEAP | CATEGORY_USERSTACKS | CATEGORY_GLOBALDATA | CATEGORY_SYSTEMMEMORY;
+
+ /**
+ * Category profile constant for Ram & Disk Profile
+ */
+ public static final int PROFILE_RAM_DISK = CATEGORY_DISKUSAGE | CATEGORY_OPENFILES | CATEGORY_RAMLOADEDCODE | CATEGORY_RAMDRIVE;
+
+ /**
+ * Category profile constant for Ram, Disk & Heap Profile
+ */
+ public static final int PROFILE_RAM_DISK_HEAP = PROFILE_RAM_DISK | CATEGORY_USERHEAP | CATEGORY_KERNELHEAP;
+
+ /**
+ * Category profile constant for Ram, Disk, Heap & Handles Profile
+ */
+ public static final int PROFILE_RAM_DISK_HEAP_HANDLES = PROFILE_RAM_DISK_HEAP | CATEGORY_BITMAPHANDLES | CATEGORY_FILESERVERCACHE | CATEGORY_SYSTEMMEMORY;
+
+ /**
+ * Window Groups
+ */
+ public static final String WINDOW_GROUPS_TXT = "Window Groups";
+ /**
+ * Bitmap Handles
+ */
+ public static final String BITMAP_HANDLES_TXT = "Bitmap Handles";
+ /**
+ * FileServer Cache
+ */
+ public static final String FILE_SERVER_CACHE_TXT = "FileServer Cache";
+ /**
+ * RAM Drive
+ */
+ public static final String RAM_DRIVE_TXT = "RAM Drive";
+ /**
+ * Global Chunks
+ */
+ public static final String GLOBAL_CHUNKS_TXT = "Global Chunks";
+ /**
+ * Local Chunks
+ */
+ public static final String LOCAL_CHUNKS_TXT = "Local Chunks";
+ /**
+ * System Memory
+ */
+ public static final String SYSTEM_MEMORY_TXT = "System Memory";
+ /**
+ * RAM-loaded code
+ */
+ public static final String RAM_LOADED_CODE_TXT = "RAM-loaded code";
+ /**
+ * Open Files
+ */
+ public static final String OPEN_FILES_TXT = "Open Files";
+ /**
+ * Disk usage
+ */
+ public static final String DISK_USAGE_TXT = "Disk usage";
+ /**
+ * Global Data
+ */
+ public static final String GLOBAL_DATA_TXT = "Global Data";
+ /**
+ * User Stacks
+ */
+ public static final String USER_STACKS_TXT = "User Stacks";
+ /**
+ * Kernel Heap
+ */
+ public static final String KERNEL_HEAP_TXT = "Kernel Heap";
+ /**
+ * User Heap
+ */
+ public static final String USER_HEAP_TXT = "User Heap";
+
+
+ /**
+ * Debug prints those bits that are set in the category setting
+ * @param categories category settings to be debugged.
+ */
+ public static void debugPrintSWMTCategorySetting(int categories){
+ if((categories & CATEGORY_FILESERVERCACHE) != 0) DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "- CATEGORY_FILESERVERCACHE"); //$NON-NLS-1$
+ if((categories & CATEGORY_BITMAPHANDLES) != 0) DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "- CATEGORY_BITMAPHANDLES"); //$NON-NLS-1$
+ if((categories & CATEGORY_USERHEAP) != 0) DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "- CATEGORY_USERHEAP"); //$NON-NLS-1$
+ if((categories & CATEGORY_KERNELHEAP) != 0) DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "- CATEGORY_KERNELHEAP"); //$NON-NLS-1$
+ if((categories & CATEGORY_LOCALCHUNKS) != 0) DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "- CATEGORY_LOCALCHUNKS"); //$NON-NLS-1$
+ if((categories & CATEGORY_GLOBALCHUNKS) != 0) DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "- CATEGORY_GLOBALCHUNKS"); //$NON-NLS-1$
+ if((categories & CATEGORY_RAMDRIVE) != 0) DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "- CATEGORY_RAMDRIVE"); //$NON-NLS-1$
+ if((categories & CATEGORY_USERSTACKS) != 0) DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "- CATEGORY_USERSTACKS"); //$NON-NLS-1$
+ if((categories & CATEGORY_GLOBALDATA) != 0) DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "- CATEGORY_GLOBALDATA"); //$NON-NLS-1$
+ if((categories & CATEGORY_RAMLOADEDCODE) != 0) DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "- CATEGORY_RAMLOADEDCODE"); //$NON-NLS-1$
+ if((categories & CATEGORY_KERNELHANDLES) != 0) DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "- CATEGORY_KERNELHANDLES"); //$NON-NLS-1$
+ if((categories & CATEGORY_OPENFILES) != 0) DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "- CATEGORY_OPENFILES"); //$NON-NLS-1$
+ if((categories & CATEGORY_DISKUSAGE) != 0) DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "- CATEGORY_DISKUSAGE"); //$NON-NLS-1$
+ if((categories & CATEGORY_SYSTEMMEMORY) != 0) DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "- CATEGORY_SYSTEMMEMORY"); //$NON-NLS-1$
+ if((categories & CATEGORY_WINDOWGROUPS) != 0) DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "- CATEGORY_WINDOWGROUPS"); //$NON-NLS-1$
+ }
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/model/SWMTCategorys.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/model/SWMTCategorys.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,180 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+package com.nokia.s60tools.memspy.model;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import com.nokia.s60tools.memspy.ui.dialogs.SWMTCategoryEntry;
+
+/**
+ * Singleton Class for holding SWMT Category profiles
+ */
+public class SWMTCategorys {
+
+
+ private static SWMTCategorys instance=null;
+
+
+ /**
+ * Private constructor
+ */
+ private SWMTCategorys(){
+ initializeCategoryEntries();
+ initializeCategoryProfiles();
+ }
+
+
+
+ /**
+ * Stores the category entries.
+ */
+ private List categoryEntries;
+
+ private List categoryProfiles;
+
+ /**
+ * Get only instance of this object
+ * @return instance
+ */
+ public static SWMTCategorys getInstance(){
+ if(instance==null){
+ instance = new SWMTCategorys();
+ }
+ return instance;
+ }
+
+ private void initializeCategoryProfiles() {
+ categoryProfiles = new ArrayList();
+
+ CategoryProfile profile0 = new CategoryProfile("Basic", SWMTCategoryConstants.PROFILE_BASIC);
+ getCategoryProfiles().add(profile0);
+
+ CategoryProfile profile1 = new CategoryProfile("RAM & Disk Profile", SWMTCategoryConstants.PROFILE_RAM_DISK);
+ getCategoryProfiles().add(profile1);
+
+ CategoryProfile profile2 = new CategoryProfile("RAM, Disk & Heap Profile", SWMTCategoryConstants.PROFILE_RAM_DISK_HEAP);
+ getCategoryProfiles().add(profile2);
+
+ CategoryProfile profile3 = new CategoryProfile("RAM, Disk, Heap & Handles Profile", SWMTCategoryConstants.PROFILE_RAM_DISK_HEAP_HANDLES);
+ getCategoryProfiles().add(profile3);
+
+ CategoryProfile profile4 = new CategoryProfile("All", SWMTCategoryConstants.CATEGORY_ALL);
+ getCategoryProfiles().add(profile4);
+
+ }
+
+
+
+ /**
+ * Initializes category entry list.
+ */
+ private void initializeCategoryEntries() {
+ // Creating entry array
+ categoryEntries = new ArrayList< SWMTCategoryEntry>();
+ // Initializing value for the array
+ categoryEntries.add( new SWMTCategoryEntry(SWMTCategoryConstants.CATEGORY_USERHEAP, SWMTCategoryConstants.USER_HEAP_TXT));
+ categoryEntries.add( new SWMTCategoryEntry(SWMTCategoryConstants.CATEGORY_KERNELHEAP, SWMTCategoryConstants.KERNEL_HEAP_TXT));
+ categoryEntries.add( new SWMTCategoryEntry(SWMTCategoryConstants.CATEGORY_USERSTACKS, SWMTCategoryConstants.USER_STACKS_TXT));
+ categoryEntries.add( new SWMTCategoryEntry(SWMTCategoryConstants.CATEGORY_GLOBALDATA, SWMTCategoryConstants.GLOBAL_DATA_TXT));
+ categoryEntries.add( new SWMTCategoryEntry(SWMTCategoryConstants.CATEGORY_DISKUSAGE, SWMTCategoryConstants.DISK_USAGE_TXT));
+ categoryEntries.add( new SWMTCategoryEntry(SWMTCategoryConstants.CATEGORY_OPENFILES, SWMTCategoryConstants.OPEN_FILES_TXT));
+ categoryEntries.add( new SWMTCategoryEntry(SWMTCategoryConstants.CATEGORY_RAMLOADEDCODE, SWMTCategoryConstants.RAM_LOADED_CODE_TXT));
+ categoryEntries.add( new SWMTCategoryEntry(SWMTCategoryConstants.CATEGORY_SYSTEMMEMORY, SWMTCategoryConstants.SYSTEM_MEMORY_TXT));
+ categoryEntries.add( new SWMTCategoryEntry(SWMTCategoryConstants.CATEGORY_LOCALCHUNKS, SWMTCategoryConstants.LOCAL_CHUNKS_TXT));
+ categoryEntries.add( new SWMTCategoryEntry(SWMTCategoryConstants.CATEGORY_GLOBALCHUNKS, SWMTCategoryConstants.GLOBAL_CHUNKS_TXT));
+ categoryEntries.add( new SWMTCategoryEntry(SWMTCategoryConstants.CATEGORY_RAMDRIVE, SWMTCategoryConstants.RAM_DRIVE_TXT));
+ categoryEntries.add( new SWMTCategoryEntry(SWMTCategoryConstants.CATEGORY_FILESERVERCACHE, SWMTCategoryConstants.FILE_SERVER_CACHE_TXT));
+ categoryEntries.add( new SWMTCategoryEntry(SWMTCategoryConstants.CATEGORY_BITMAPHANDLES, SWMTCategoryConstants.BITMAP_HANDLES_TXT));
+ categoryEntries.add( new SWMTCategoryEntry(SWMTCategoryConstants.CATEGORY_WINDOWGROUPS, SWMTCategoryConstants.WINDOW_GROUPS_TXT));
+
+ }
+
+
+ /**
+ * Get all category entries exist
+ * @return the categoryEntries
+ */
+ public List getCategoryEntries() {
+ return categoryEntries;
+ }
+
+ /**
+ * Get a category entry by ID
+ * @return the categoryEntry or null
if not found
+ */
+ public SWMTCategoryEntry getCategoryEntry(int entryID) {
+
+
+ for (Iterator iterator = categoryEntries.iterator(); iterator.hasNext();) {
+ SWMTCategoryEntry entry = (SWMTCategoryEntry) iterator.next();
+ if(entry.getCategoryId() == entryID){
+ return entry;
+ }
+ }
+
+ return null;
+ }
+
+
+ /**
+ * Get all category profiles created
+ * @return the categoryProfiles
+ */
+ public List getCategoryProfiles() {
+ return categoryProfiles;
+ }
+
+ /**
+ * Get wanted SWMT Categorys by IDs
+ * @param categories
+ * @return {@link List} of {@link SWMTCategoryEntry}'s
+ */
+ public List getCategoryEntries(int categories) {
+
+ List wantedCategories = new ArrayList();
+ for (Iterator iterator = categoryEntries.iterator(); iterator.hasNext();) {
+ SWMTCategoryEntry entry = (SWMTCategoryEntry) iterator.next();
+ if((entry.getCategoryId() & categories) != 0){
+ wantedCategories.add(entry);
+ }
+ }
+ return wantedCategories;
+ }
+
+ /**
+ * Get profile by it's name
+ * @param profileName
+ * @return profile int or null
if not found
+ */
+ public CategoryProfile getProfile(String profileName){
+
+ for (Iterator iterator = categoryProfiles.iterator(); iterator
+ .hasNext();) {
+ CategoryProfile profile = (CategoryProfile) iterator.next();
+ if(profileName.equals(profile.getName())){
+ return profile;
+ }
+
+ }
+ return null;
+ }
+
+
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/model/TraceCoreDataHandler.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/model/TraceCoreDataHandler.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,595 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+package com.nokia.s60tools.memspy.model;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.regex.Pattern;
+
+import com.nokia.s60tools.memspy.containers.ThreadInfo;
+import com.nokia.s60tools.memspy.export.ITraceDataProcessor;
+import com.nokia.s60tools.memspy.interfaces.IMemSpyTraceListener.LauncherErrorType;
+import com.nokia.s60tools.memspy.util.MemSpyConsole;
+import com.nokia.s60tools.util.debug.DbgUtility;
+
+
+/**
+ * Monitors data received from TraceCore and acts based on it.
+ */
+public final class TraceCoreDataHandler implements ITraceDataProcessor {
+
+ // Count of lines
+ private int lineCount;
+
+ // boolean value that is used when parsing thread list
+ private boolean lastWasName;
+
+ // Array, where found thread names and id's are written
+ private ArrayList threadArray = null;
+
+ // ThreadInfo-object where info is collected
+ private ThreadInfo threadInfo;
+
+ // boolean value that is set to true, when trace-lines are lost
+ private boolean dumpedTraces;
+
+ // boolean value that is set to false, when heap type is not symbian OS Rheap
+ private boolean heapTypeCorrect;
+
+ // boolean value that is true when some information is written to file
+ private boolean writeFile;
+
+ // boolean value that true when file is open
+ private boolean fileOpen;
+
+
+ // Writer that writes to file
+ private PrintWriter plainOutput;
+
+ // Writer that writes to file
+ private PrintWriter swmtHeadDumpOutput = null;
+
+
+ // boolean value that is true when some memspy operations are on-going.
+ private boolean logging;
+
+ // Trace engine.
+ private TraceCoreEngine engine;
+
+
+ //Strings
+ private final static String LAUNCHER_READY = "";
+ private final static String MEMSPY_LAUNCHER_VERSION_PREFIX = "
+ private final static String END_TAG = ">";
+ private final static String LAUNCHER_COLON = "::";
+ private final static String LAUNCHER_THREAD_ID = "Thread Id";
+ private final static String LAUNCHER_TYPE = "Type:";
+ private final static String LAUNCHER_SYMBIAN_OS_RHEAP = "Symbian OS RHeap";
+ private final static String LAUNCHER_HEAP_DUMP_START = "SYSTEM WIDE MEMORY TRACKER tag
+ */
+ public final static String LAUNCHER_SWMT_LOG_START = "";
+
+ private final static String LAUNCHER_SWMT_LOG_END = " ";
+ private final static String LAUNCHER_SWMTDATA = "[SMT ";
+ private final static String LAUNCHER_CATEGORY_NOT_SUPPORTED = "";
+
+ private ThreadInfo swmtHeadDumpThreadInfo;
+
+ /**
+ * Constructor.
+ * @param engine engine that uses handler
+ */
+ public TraceCoreDataHandler(TraceCoreEngine engine){
+ this.engine = engine;
+ lastWasName = false;
+ heapTypeCorrect = false;
+ writeFile = false;
+ lineCount = 0;
+ }
+
+ /**
+ * Method that is called when trace logging is started.
+ * @param fName Name of the file, where needed information is printed.
+ * @param fileOpen boolean value that is true when file needs to be opened.
+ */
+ public boolean startLogging(String fName, boolean fileOpen) {
+ logging = true;
+ lineCount = 0;
+
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreDataHandler.startLogging/fName=" + fName + ", fileOpen=" + fileOpen); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // If file needs to be opened, open it.
+ this.fileOpen = fileOpen;
+ if( fileOpen ){
+ try {
+ plainOutput = new PrintWriter(new FileWriter( fName ));
+ }
+ catch (IOException e) {
+
+ engine.launcherError(LauncherErrorType.FILE);
+ return false;
+ }
+
+ }
+ return true;
+ }
+
+ /**
+ * Stops logging and closes file if needed.
+ */
+ public void stopLogging() {
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreDataHandler.stopLogging"); //$NON-NLS-1$
+ this.logging = false;
+ if( this.fileOpen ){
+ plainOutput.flush();
+ plainOutput.close();
+ }
+ stopSWMTHeadDumpLogging();
+ }
+
+ /**
+ * Flush and Close swmtHeadDumpOutput
+ */
+ private void stopSWMTHeadDumpLogging() {
+ if(swmtHeadDumpOutput != null){
+ swmtHeadDumpOutput.flush();
+ swmtHeadDumpOutput.close();
+ }
+ }
+
+ /**
+ * Open FileWriter for swmtHeadDumpOutput
+ */
+ private void startSWMTHeadDumpLogging(){
+ try {
+ File file = new File(swmtHeadDumpThreadInfo.getThreadFilePath());
+ File path = file.getParentFile();
+ if(!path.exists()){
+ path.mkdirs();
+ }
+ file.createNewFile();
+ if(swmtHeadDumpThreadInfo != null){
+ swmtHeadDumpOutput = new PrintWriter(new FileWriter( swmtHeadDumpThreadInfo.getThreadFilePath() ));
+ }
+ }
+ catch (IOException e) {
+ engine.launcherError(LauncherErrorType.FILE);
+ }
+ }
+
+ /**
+ * Processes trace data that is received. This method is called every time trace
+ * data is received when logging is on.
+ * @param traceLineStr trace data line
+ */
+ public void processDataLine(String traceLineStr) {
+
+ if (logging) {
+
+ if (traceLineStr != null) {
+
+ if(isMemSpyRelatedLine(traceLineStr)){
+ lineCount++;
+ }
+ // Reset timer every 10 MemSpy related lines.
+ if( lineCount > 10 ){
+ engine.restartErrorTimer();
+ lineCount = 0;
+ }
+
+ // If Line contains launcher error message
+ if( traceLineStr.contains( LAUNCHER_ERROR ) ){
+ handleLauncherErrorLine(traceLineStr);
+ }
+
+ // If line contains message of dumped traces
+ else if( traceLineStr.contains( DUMPED_TC_TRACES )){
+ handleDumpTCTracesLine();
+ }
+
+ // If line contains confirmation that Launcher is ready to receive new command
+ else if ( traceLineStr.contains(LAUNCHER_READY) ) {
+ handleLauncherReadyLine();
+ }
+ else if(traceLineStr.contains(MEMSPY_LAUNCHER_VERSION_PREFIX)){
+ handleLauncherVersionLine(traceLineStr);
+ }
+ //If launcher sends an progress message, restarting error timer so the timer wont reset progress
+ //this is done because of long taking progress was causing time outs.
+ else if(traceLineStr.contains(MEMSPY_PROGRESS)){
+ engine.restartErrorTimer();
+ }
+
+ // If receiving heap dump
+ else if( engine.getFirstTask() == TraceCoreEngine.MEMSPY_GET_HEAP_DUMP ){
+ handleHeadDumpLine(traceLineStr);
+ }
+
+ // If receiving SWMT log
+ else if( engine.getFirstTask() == TraceCoreEngine.MEMSPY_SWMT_UPDATE
+ || engine.getFirstTask() == TraceCoreEngine.MEMSPY_SWMT_RESET ){
+ handleSWMTLine(traceLineStr);
+ }
+
+ // If receiving thread info
+ else if( engine.getFirstTask() == TraceCoreEngine.MEMSPY_THREAD_INFO ){
+ handleThreadInfoLine(traceLineStr);
+ }
+
+ // Setting SWMT category low bits
+ else if( engine.getFirstTask() == TraceCoreEngine.MEMSPY_SET_CATEGORIES_LOW ){
+ handleCategoriesLowLine(traceLineStr);
+ }
+
+ // Setting SWMT category high bits
+ else if( engine.getFirstTask() == TraceCoreEngine.MEMSPY_SET_CATEGORIES_HIGH ){
+ handleCategoriesHighLine(traceLineStr);
+ }
+
+ // If Receiving thread list
+ else if( engine.getFirstTask() == TraceCoreEngine.MEMSPY_THREAD_LIST ){
+ handleThreadListLine(traceLineStr);
+ }
+
+ }
+ }
+
+ }
+
+ /**
+ * Checks that line has something to do with MemSpy related data.
+ * @param str line sting
+ * @return true
if MemSpy related data, otherwise false
.
+ */
+ private boolean isMemSpyRelatedLine(String str) {
+ return str.contains("HeapData") || str.contains("MemSpy");
+ }
+
+ private void handleLauncherVersionLine(String str) {
+ DbgUtility.println(DbgUtility.PRIORITY_LOOP, "TraceCoreDataHandler.processData/MEMSPY_LAUNCHER_VERSION_PREFIX"); //$NON-NLS-1$
+ String version = cutString(MEMSPY_LAUNCHER_VERSION_PREFIX, END_TAG, str);
+ engine.setMemSpyLauncherVersion(version);
+ }
+
+ private void handleLauncherReadyLine() {
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreDataHandler.processData/LAUNCHER_READY"); //$NON-NLS-1$
+ engine.memSpyReady();
+ }
+
+ private void handleDumpTCTracesLine() {
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreDataHandler.processData/DUMPED_TC_TRACES"); //$NON-NLS-1$
+ this.dumpedTraces = true;
+ }
+
+ private void handleLauncherErrorLine(String str) {
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreDataHandler.processData/LAUNCHER_ERROR"); //$NON-NLS-1$
+ if( str.contains("'") ){
+ str = str.substring( str.indexOf("'")+1 );
+ if( str.contains("'") ){
+ String error = str.substring( 0, str.indexOf("'") );
+ LauncherErrorType type = getErrorById(error);
+ engine.launcherError(type);
+ }
+ }
+ else{
+ // If no error code present, then parsing custom error message and sending information to console
+ String additionalErrorInfo = "";
+ // Getting error message string portion
+ String[] splitArr = str.split(Pattern.quote(":"));
+ if(splitArr.length == 2){
+ additionalErrorInfo = additionalErrorInfo + splitArr[1].trim();
+ }
+ // Passing launcher error forwards generic launcher error
+ engine.launcherError(LauncherErrorType.GENERAL_LAUNCHER_ERROR, additionalErrorInfo);
+ }
+ }
+
+ private void handleThreadListLine(String str) {
+ // If line contains "::" create new ThreadInfo-object
+ if ( str.contains( LAUNCHER_COLON ) ) {
+
+ threadInfo = new ThreadInfo();
+ threadInfo.setThreadName(str);
+ lastWasName = true;
+
+ }
+
+ // Save threadID into latest ThreadInfo-object and add info into thread list
+ if ( str.contains( LAUNCHER_THREAD_ID ) ){
+ if ( lastWasName ){
+ String threadID = str.substring( str.indexOf( LAUNCHER_THREAD_ID ) + LAUNCHER_THREAD_ID.length() );
+ threadID = threadID.trim();
+ threadInfo.setThreadID( threadID );
+ threadArray.add( threadInfo );
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreDataHandler.processData/LAUNCHER_THREAD_ID/id=" + threadInfo.getThreadID() + ", name=" + threadInfo.getThreadName()); //$NON-NLS-1$ //$NON-NLS-2$
+ lastWasName = false;
+ }
+ }
+ }
+
+ private void handleCategoriesHighLine(String str) {
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreDataHandler.processData/MEMSPY_SET_CATEGORIES_HIGH: " + str); //$NON-NLS-1$
+ }
+
+ private void handleCategoriesLowLine(String str) {
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreDataHandler.processData/MEMSPY_SET_CATEGORIES_LOW: " + str); //$NON-NLS-1$
+ if(str.contains(LAUNCHER_CATEGORY_NOT_SUPPORTED)){
+ //LAUNCHER_CATEGORY_NOT_SUPPORTED error
+ engine.launcherError(LauncherErrorType.CATEGORIES_NOT_SUPPORTED);
+ }
+ }
+
+ private void handleThreadInfoLine(String str) {
+ // Check for threads heap type
+ if ( str.contains( LAUNCHER_TYPE ) ){
+ if ( str.contains(LAUNCHER_SYMBIAN_OS_RHEAP) ){
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreDataHandler.processData/MEMSPY_THREAD_INFO"); //$NON-NLS-1$
+ heapTypeCorrect = true;
+ }
+ }
+ }
+
+ private void handleSWMTLine(String str) {
+ // Check for start tag
+ if ( str.contains( LAUNCHER_SWMT_LOG_START ) ) {
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreDataHandler.processData/LAUNCHER_SWMT_LOG_START"); //$NON-NLS-1$
+ this.writeFile = true;
+ engine.restartErrorTimer(); // Resetting error time instantly when getting start event of the logging
+ }
+
+ // If writing to file
+ if ( this.writeFile && str.contains(LAUNCHER_SWMTDATA) ){
+ this.writeLine( str );
+ }
+
+
+ // If we receive a Heap Dump line during SWMT logging
+ if ( this.writeFile &&
+ (str.contains(LAUNCHER_HEAPDATA)
+ || str.contains(LAUNCHER_HEAP_DUMP_START) || str.contains(LAUNCHER_HEAP_DUMP_END))){
+ handleHeapDumpDuringSWMTLogging(str);
+ }
+
+ // Check for end tag
+ if ( str.contains( LAUNCHER_SWMT_LOG_END ) ) {
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreDataHandler.processData/LAUNCHER_SWMT_LOG_END"); //$NON-NLS-1$
+ this.writeFile = false;
+ engine.restartErrorTimer(); // Resetting error time instantly when getting end event of the logging
+ }
+ }
+
+ /**
+ * Handling a Heap Dump line during SWMT logging
+ * @param str
+ */
+ private void handleHeapDumpDuringSWMTLogging(String str) {
+
+ //If we receiving a start point of Dump..
+ if(str.contains(LAUNCHER_HEAP_DUMP_START)){
+ DbgUtility.println(DbgUtility.PRIORITY_LOOP, "TraceCoreDataHandler.processData/Start SWMT Head Dump"); //$NON-NLS-1$
+ swmtHeadDumpThreadInfo = new ThreadInfo();
+ if(threadArray == null){
+ setThreadArray(new ArrayList());
+ }
+ }
+ //If we receiving a Thread name of Dump, we create a new file for dump, and start dumping it
+ else if(str.contains(LAUNCHER_HEAP_INFO_FOR_THREAD)){
+
+ String threadName = getThreadNameFromInfo(str);
+ swmtHeadDumpThreadInfo.setThreadName(threadName);
+ DbgUtility.println(DbgUtility.PRIORITY_LOOP, "TraceCoreDataHandler.processData/SWMT Head Dump Thread name received: " +threadName); //$NON-NLS-1$
+
+ //String threadName, String threadID, String threadFilePath, Date date, HeapDumpType type
+ // Get file name for heap dump from engine
+ String filePath = MemSpyFileOperations.getFileNameForTempHeapDump(
+ swmtHeadDumpThreadInfo.getThreadName(), swmtHeadDumpThreadInfo.getDate());
+ swmtHeadDumpThreadInfo.setThreadFilePath(filePath);
+ startSWMTHeadDumpLogging();
+ writeSWMTHeadDumpLine(str);
+
+ DbgUtility.println(DbgUtility.PRIORITY_LOOP, "TraceCoreDataHandler.processData/SWMT Head Dump Thread file created: " +filePath); //$NON-NLS-1$
+
+ //Heap info's will act as start point for new Head dump, when Head Dumps are received during SWMT logging
+ //E.g. following Heap info is received:
+ //HeapData - mc_isiserver::Main - HEAP INFO FOR THREAD 'mc_isiserver::Main'
+ }
+
+ //If we receiving a end point of Dump...
+ else if(str.contains(LAUNCHER_HEAP_DUMP_END)){
+ DbgUtility.println(DbgUtility.PRIORITY_LOOP, "TraceCoreDataHandler.processData/End SWMT Head Dump"); //$NON-NLS-1$
+ threadArray.add( swmtHeadDumpThreadInfo );
+ stopSWMTHeadDumpLogging();
+ }
+
+ //Else we receiving a dump line, and writing it to the Dump file, not to SWMT file
+ else if(swmtHeadDumpThreadInfo != null && swmtHeadDumpOutput != null){
+ writeSWMTHeadDumpLine(str);
+ }
+ else{
+ DbgUtility.println(DbgUtility.PRIORITY_LOOP, "TraceCoreDataHandler.processData/LAUNCHER_HEAPDATA & MEMSPY_SWMT_UPDATE unknown line occured: " +str);
+ }
+ }
+
+ /**
+ * Get Thread name from Heap Info line
+ * @param str
+ * @return Thread name
+ */
+ private String getThreadNameFromInfo(String str) {
+ String name = str.substring(
+ (str.indexOf(LAUNCHER_HEAP_INFO_FOR_THREAD) + LAUNCHER_HEAP_INFO_FOR_THREAD.length()));
+ String separator = "'";
+ name = name.substring((name.indexOf(separator) + separator.length()), name.lastIndexOf(separator)).trim();
+ return name;
+ }
+
+ private void handleHeadDumpLine(String str) {
+ // Check for heap end tag
+ if ( str.contains( LAUNCHER_HEAP_DUMP_END ) ) {
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreDataHandler.processData/MEMSPY_GET_HEAP_DUMP/LAUNCHER_HEAP_DUMP_END"); //$NON-NLS-1$
+ this.writeFile = false;
+ }
+
+ // If writing to file
+ if ( this.writeFile && str.contains(LAUNCHER_HEAPDATA) ){
+ this.writeLine( str );
+ }
+
+ // Check for heap start tag
+ if ( str.contains( LAUNCHER_HEAP_DUMP_START ) ) {
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreDataHandler.processData/MEMSPY_GET_HEAP_DUMP/LAUNCHER_HEAP_DUMP_START"); //$NON-NLS-1$
+ this.writeFile = true;
+ }
+ }
+
+ /**
+ * Cut string from startTag to endTag
+ * @param startTag
+ * @param endTag
+ * @param str
+ * @return cutted string or str given if start and end tags does not found from given str
+ */
+ private static String cutString(String startTag, String endTag,
+ String str) {
+ if(!str.contains(startTag) && !str.contains(endTag)){
+ return str;
+ }
+ String ret = str.substring(str.indexOf(startTag) + startTag.length());
+ ret = ret.substring(0,ret.indexOf(endTag));
+ return ret;
+ }
+
+ /**
+ * Writes one line into opened file.
+ * @param line, Line that is written to file
+ */
+ private void writeLine(String line){
+ plainOutput.write(line + "\n");
+ }
+
+ /**
+ * Writes one line into opened file.
+ * @param line, Line that is written to file
+ */
+ private void writeSWMTHeadDumpLine(String line){
+ swmtHeadDumpOutput.write(line + "\n");
+ }
+
+
+ //
+ // Getters and setters for member variables
+ //
+
+ /**
+ * Set thread array
+ * @param threadArray
+ */
+ public void setThreadArray(ArrayList threadArray) {
+ this.threadArray = threadArray;
+ }
+
+ /**
+ * Check if {@link TraceCoreDataHandler#LAUNCHER_COLON} was found in line
+ * @param lastWasName
+ */
+ public void setLastWasName(boolean lastWasName) {
+ this.lastWasName = lastWasName;
+ }
+
+ /**
+ * Check if heap type was correct
+ * @return true
if heap type was correct, false
otherwise.
+ */
+ public boolean isHeapTypeCorrect() {
+ return heapTypeCorrect;
+ }
+
+ /**
+ * Set heap type as correct
+ * @param heapTypeCorrect
+ */
+ public void setHeapTypeCorrect(boolean heapTypeCorrect) {
+ this.heapTypeCorrect = heapTypeCorrect;
+ }
+
+ /**
+ * Set dump traces
+ * @param dumpedTraces
+ */
+ public void setDumpedTraces(boolean dumpedTraces) {
+ this.dumpedTraces = dumpedTraces;
+ }
+
+ /**
+ * Check if trace was containing {@link TraceCoreDataHandler#DUMPED_TC_TRACES} lines
+ * @return true
if dumped lines was found, false
otherwise.
+ */
+ public boolean isDumpedTraces() {
+ return dumpedTraces;
+ }
+
+ /**
+ * Returns {@link LauncherErrorType} by its ordinal
+ * @param errorCodeAsString Error number as string
+ * @return {@link LauncherErrorType} or {@link LauncherErrorType#ACTIVATION} if no matching item found.
+ */
+ private LauncherErrorType getErrorById(String errorCodeAsString){
+
+ try {
+ int errorCode = Integer.parseInt(errorCodeAsString);
+ LauncherErrorType [] values = LauncherErrorType.values();
+ for (int i = 0; i < values.length; i++) {
+ if(errorCode == values[i].ordinal()){
+ return values[i];
+ }
+ }
+ } catch (NumberFormatException e) {
+ //If occurs, it's an internal error, MemSpy S60 side is giving id in wrong format.
+ e.printStackTrace();
+ MemSpyConsole.getInstance().printStackTrace(e);
+ }
+
+ return LauncherErrorType.ACTIVATION;
+ }
+
+ /**
+ * Get imported SWMT Heap Dumps
+ * @return imported SWMT Heap Dumps
+ */
+ public ArrayList getImportedSWMTHeaps() {
+ return threadArray;
+ }
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/model/TraceCoreEngine.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/model/TraceCoreEngine.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,1093 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+package com.nokia.s60tools.memspy.model;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+import java.util.Date;
+
+import javax.swing.Timer;
+
+import com.nokia.s60tools.memspy.common.ProductInfoRegistry;
+import com.nokia.s60tools.memspy.containers.SWMTLogInfo;
+import com.nokia.s60tools.memspy.containers.ThreadInfo;
+import com.nokia.s60tools.memspy.containers.SWMTLogInfo.SWMTLogType;
+import com.nokia.s60tools.memspy.export.ITraceClientNotificationsIf;
+import com.nokia.s60tools.memspy.interfaces.IMemSpyTraceListener;
+import com.nokia.s60tools.memspy.interfaces.IMemSpyTraceListener.LauncherAction;
+import com.nokia.s60tools.memspy.interfaces.IMemSpyTraceListener.LauncherErrorType;
+import com.nokia.s60tools.memspy.plugin.MemSpyPlugin;
+import com.nokia.s60tools.memspy.preferences.MemSpyPreferences;
+import com.nokia.s60tools.memspy.ui.wizards.DeviceOrFileSelectionPage;
+import com.nokia.s60tools.memspy.util.MemSpyConsole;
+import com.nokia.s60tools.util.console.IConsolePrintUtility;
+import com.nokia.s60tools.util.debug.DbgUtility;
+
+
+/**
+ * TraceCoreEngine
class offers public services for starting operations for
+ * getting heap dump and SWMT log data. It creates and manages list of sub tasks
+ * are requested sequentially until main operation chain is over (either successfully
+ * or with error).
+ *
+ * This class is tightly coupled with TraceCoreDataHandler
class
+ * that parses trace data and passes flow control back to TraceCoreEngine
+ * between individual sub tasks.
+ *
+ * @see com.nokia.s60tools.memspy.model.TraceCoreDataHandler.java
+ */
+public class TraceCoreEngine implements ActionListener, ITraceClientNotificationsIf {
+
+ /**
+ * Enumerator for upper level operation progress status. Ordinal order of the operations should not be changed.
+ * Once operation status is advanced to EProgressMemSpyOperationDone
+ * the progress status is not initialized until wizard re-start, connection setting are changed, or an error occurs.
+ *
+ * The enumerator is used in order being able to give user best possible guidance on time-out error when we know
+ * the context in which the error has occurred.
+ */
+ public enum ProgressStatus{
+ EPROGRESS_INITIAL, // Initial status with no progress so far during current session
+ EPROGRESS_MEMSPY_LAUNCHED, // MemSpy has been launched successfully
+ EPROGRESS_FIRST_TASK_LAUNCHED, // First actual task for MemSpy is triggered (i.e. non-MemSpy launch task)
+ EPROGRESS_FIRST_TASK_DONE // First actual task for MemSpy completed successfully (i.e. non-MemSpy launch task)
+ }
+
+ // GroupIDs that are used
+ public final static String MEMSPY_LAUNCH = "10";
+ public final static String MEMSPY_THREAD_LIST = "11";
+ public final static String MEMSPY_THREAD_INFO = "12";
+ public final static String MEMSPY_GET_HEAP_DUMP = "13";
+ public final static String MEMSPY_SWMT_UPDATE = "14";
+ public final static String MEMSPY_SWMT_RESET = "16";
+ public final static String MEMSPY_STOP = "17";
+ public final static String MEMSPY_SET_CATEGORIES_LOW = "19";
+ public final static String MEMSPY_SET_CATEGORIES_HIGH = "20";
+ public final static String MEMSPY_SET_SWMT_HEAP_DUMP = "21";
+ public final static String MEMSPY_SET_HEAP_NAME_FILTER = "SUBSCRIBE_COMM_EVENT_SET_HEAP_NAME_FILTER";
+
+ // Time that device waits for line.
+ private final int SECOND = 1000;
+ private final int DEFAULT_WAIT_TIME = 20 * SECOND; // seconds
+ private final int MAX_WAIT_TIME = 60 * SECOND; // seconds
+ private int currentWaitTime;
+
+ /**
+ * Indicate that MemSpy Launcher data version is not received.
+ */
+ private static final int MEMSPY_LAUNCHER_VERSION_NOT_DEFINED = -1;
+
+ /* timer that is used in error correction */
+ private Timer errorTimer;
+
+ /* boolean value that is true when MemSpy is running */
+ private boolean MemSpyRunning;
+
+ /* Cycle number of swmt logs that is received next time */
+ private int cycleNumber;
+
+ /* interval between swmt logs */
+ private int interval;
+
+ /* timer that is used when receiving SWMT-logs via timer */
+ private Timer intervalTimer;
+
+ /* info of swmt-log that is currently received */
+ private SWMTLogInfo swmtLogInfo;
+
+ // Trace data handler
+ private TraceCoreDataHandler handler;
+
+ // Id of threads that is currently received
+ int threadID;
+
+ // Task list
+ private ArrayList taskList;
+
+ // WizardPage, that is notified when operations are done.
+ private IMemSpyTraceListener wizardPage;
+
+ // Name of the file where heap dumps and SWMT-logs are written.
+ private String currentFile;
+
+ /**
+ * If S60 MemSpy is to be closed between cycles
+ */
+ private boolean resetBetweenCycles = false;
+
+ /**
+ * Stores MemSpy launcher communication version.
+ */
+ private int receivedMemSpyLauncherDataVersion = MEMSPY_LAUNCHER_VERSION_NOT_DEFINED;
+
+ /**
+ * Upper level operation progress status. Ordinal order of the operations should not be changed.
+ * Once operation status is advanced to EProgressMemSpyOperationDone
+ * the progress status is not initialized until wizard re-start, connection setting are changed, or an error occurs.
+ */
+ private ProgressStatus progressStatus = ProgressStatus.EPROGRESS_INITIAL;
+
+ /**
+ * Provides possibly additional error information about the occurred error.
+ */
+ private String additionalErrorInformation;
+
+ /**
+ * Constructor.
+ */
+ public TraceCoreEngine(){
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreEngine() Construct START"); //$NON-NLS-1$
+ this.MemSpyRunning = false;
+ this.handler = new TraceCoreDataHandler(this);
+ this.taskList = new ArrayList();
+ this.errorTimer = null;
+ this.cycleNumber = 1;
+ this.interval = 0;
+ this.swmtLogInfo = null;
+ this.currentWaitTime = DEFAULT_WAIT_TIME;
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreEngine() Construct END"); //$NON-NLS-1$
+ }
+
+ /**
+ * Request thread list from MemSpyLauncher.
+ * @param threadArray array where thread names and id's are written
+ * @param wizard page which is notified when request is finished
+ * @return true, if connection to TraceCore established successfully, else false
+ */
+
+ public boolean requestThreadList( ArrayList threadArray, DeviceOrFileSelectionPage wizard ){
+ this.wizardPage = wizard;
+
+ // Set handler values correct
+ handler.setLastWasName( false );
+ handler.setThreadArray( threadArray );
+
+ // if connection established successfully, return true
+ if( this.connect() ){
+
+ // Set handler values correct
+ handler.setLastWasName( false );
+ handler.setThreadArray( threadArray );
+
+ if( !this.MemSpyRunning ){
+ taskList.add( MEMSPY_LAUNCH );
+ }
+ taskList.add( MEMSPY_THREAD_LIST );
+ return this.runNextTask();
+ }
+ else{
+ return false;
+ }
+
+
+ }
+
+ /**
+ * Request Heap Dump from device and write it into text file
+ * @param threadID ID of thread which is requested from device
+ * @param wizardPage page which is notified when request is finished
+ * @param currentFile path of the file where Heap Dump is written
+ * @return true, if connection to TraceCore established successfully, else false
+ */
+ public boolean requestHeapDump( int threadID, IMemSpyTraceListener wizardPage, String currentFile ){
+
+ this.currentFile = currentFile;
+ this.wizardPage = wizardPage;
+ this.threadID = threadID;
+
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreEngine.requestHeapDump/threadID=" + threadID); //$NON-NLS-1$
+
+ if( this.connect() ){
+
+ // Reset heap type value
+ handler.setHeapTypeCorrect( false );
+
+ // Send id to trace,
+ if( !this.sendIntegerDataToLauncher(threadID) ){
+ launcherError(LauncherErrorType.ACTIVATION);
+ return false;
+ }
+ else{
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreEngine.requestHeapDump/activateId => OK"); //$NON-NLS-1$
+ }
+
+ if( !this.MemSpyRunning ){
+ taskList.add( MEMSPY_LAUNCH );
+ }
+
+ // Add tasks into task list
+ taskList.add( MEMSPY_THREAD_INFO );
+ taskList.add( MEMSPY_GET_HEAP_DUMP );
+
+ // start running tasks
+ return this.runNextTask();
+ }
+ else{
+ return false;
+ }
+ }
+
+ /**
+ * Request Heap Dump from device and write it into text file
+ * @param threadID ID of thread which is requested from device
+ * @param wizardPage page which is notified when request is finished
+ * @param currentFile path of the file where Heap Dump is written
+ * @return true, if connection to TraceCore established successfully, else false
+ */
+ public boolean requestHeapDump( String threadID, IMemSpyTraceListener wizardPage, String currentFile ){
+
+ return requestHeapDump( Integer.parseInt(threadID), wizardPage, currentFile );
+
+ }
+
+ /**
+ * Request SWMT-log from device and write it into file
+ * @param wizardPage page which is notified when request is finished
+ * @param currentFile path of the file where Heap Dump is written
+ * @param resetCycles should cycles be reseted
+ * @return true, if connection to TraceCore established successfully, else false
+ */
+ public boolean requestSWMTLog( IMemSpyTraceListener wizardPage, String currentFile, boolean resetCycles){
+ this.currentFile = currentFile;
+ this.wizardPage = wizardPage;
+
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreEngine.requestSWMTLog(resetCycles=" + resetCycles + ")/currentFile: " + currentFile); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // if connection established successfully, return true
+ if( this.connect() ){
+
+ // stop and start MemSpy so that logging is reseted.
+ if( resetCycles == true ){
+ taskList.add( MEMSPY_STOP );
+ taskList.add( MEMSPY_LAUNCH );
+ }
+
+ // If MemSpy is not running launch it
+ if( !this.MemSpyRunning ){
+ taskList.add( MEMSPY_LAUNCH );
+ }
+
+ //Adding category settings requests, if the feature is supported
+ if(MemSpyPlugin.getDefault().isSWMTCategorySettingFeatureEnabled()){
+ taskList.add( MEMSPY_SET_CATEGORIES_LOW ); //LOW bytes has to be written always before high bytes
+ taskList.add( MEMSPY_SET_CATEGORIES_HIGH ); //HIGH bytes has to be written always after low bytes
+ }
+
+
+ // Set the name filter for User Heap SWMT category
+ if(MemSpyPreferences.isSWMTHeapDumpSelected() && !MemSpyPreferences.isProfileTrackedCategoriesSelected()) {
+ taskList.add( MEMSPY_SET_SWMT_HEAP_DUMP );
+ taskList.add( MEMSPY_SET_HEAP_NAME_FILTER );
+ }
+
+ taskList.add( MEMSPY_SWMT_UPDATE );
+
+ // start running tasks
+ return this.runNextTask();
+ }
+ else{
+ return false;
+ }
+ }
+
+ /**
+ * Starts timer based SWMT logging.
+ * @param wizardPage page which is notified when request is finished
+ * @param currentFile path of the file where Heap Dump is written
+ * @param resetInStart should cycles be reseted
+ * @param resetBetweenCycles if MemSpy S60 application is to be reseted between every cycle
+ * @param interval poll interval
+ * @return true, if connection to TraceCore established successfully, else false
+ */
+ public boolean startSWMTTimer( IMemSpyTraceListener wizardPage, int cycleNumber,
+ boolean resetInStart, boolean resetBetweenCycles, int interval ){
+ this.wizardPage = wizardPage;
+ this.resetBetweenCycles = resetBetweenCycles;
+
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreEngine.startSWMTTimer"); //$NON-NLS-1$
+
+ // if connection established successfully, return true
+ if( this.connect() ){
+ this.cycleNumber = cycleNumber - 1;
+ this.interval = interval;
+
+
+ if( resetInStart == true ){
+ taskList.add( MEMSPY_STOP );
+ taskList.add( MEMSPY_LAUNCH );
+
+ }
+
+ this.runNextTimedTask();
+
+ return true;
+ }
+ else{
+ return false;
+ }
+
+
+ }
+
+
+ /**
+ * Stops SWMT timer
+ * @return true if timer was stopped immediately, false if MemSpy operation was on-going and timer is stopped after after operations are done.
+ */
+ public boolean stopSWMTTimer(){
+
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreEngine.stopSWMTTimer"); //$NON-NLS-1$
+
+ // other variables to zero.
+ this.interval = 0;
+ this.cycleNumber = 1;
+
+ // if timer is, running stop it
+ if( intervalTimer != null && intervalTimer.isRunning() ){
+ intervalTimer.stop();
+ this.swmtLogInfo = null;
+ return true;
+ }
+ else{
+ return false;
+ }
+ }
+
+ /**
+ * addNextTimedTask.
+ * Adds next timed tasks into taskList if needed
+ */
+ private void runNextTimedTask(){
+
+ cycleNumber++;
+
+ // get new SWMT-object and set filename correct
+ swmtLogInfo = this.getNewSWMTInfo();
+ this.currentFile = swmtLogInfo.getPath();
+
+ // If MemSpy is not running launch it
+ if( !this.MemSpyRunning ){
+ taskList.add( MEMSPY_LAUNCH );
+ }
+ //If memSpy is running and we want to reset it between cycles
+ else if(this.MemSpyRunning && resetBetweenCycles == true ){
+ taskList.add( MEMSPY_STOP );
+ taskList.add( MEMSPY_LAUNCH );
+
+ }
+
+ //Adding category settings requests, if the feature is supported
+ if(MemSpyPlugin.getDefault().isSWMTCategorySettingFeatureEnabled()){
+ taskList.add( MEMSPY_SET_CATEGORIES_LOW ); //LOW bytes has to be written always before high bytes
+ taskList.add( MEMSPY_SET_CATEGORIES_HIGH ); //HIGH bytes has to be written always after low bytes
+ }
+
+ // Set the name filter for User Heap SWMT category
+ if(MemSpyPreferences.isSWMTHeapDumpSelected() && !MemSpyPreferences.isProfileTrackedCategoriesSelected()) {
+ taskList.add( MEMSPY_SET_SWMT_HEAP_DUMP );
+ taskList.add( MEMSPY_SET_HEAP_NAME_FILTER );
+ }
+
+
+ // Requesting SWMT update
+ taskList.add( MEMSPY_SWMT_UPDATE );
+
+ // start runnings tasks
+ this.runNextTask();
+ }
+
+ /**
+ * Function that handles calls when MemSpys operation is finished successfully
+ * This method is called from DataHandler every time tag -tag received.
+ */
+ public void memSpyReady(){
+
+
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreEngine.memSpyReady"); //$NON-NLS-1$
+
+ //Check Launcher data version
+ checkMemSpyLauncherDataVersion();
+ //MemSpy launcher data version is received always before -tag is received
+ //When version number is checked, returning -1 to received value
+ receivedMemSpyLauncherDataVersion = MEMSPY_LAUNCHER_VERSION_NOT_DEFINED;
+
+ // Stop logging trace data
+ handler.stopLogging();
+ // Stop listening trace data
+ MemSpyPlugin.getTraceProvider().stopListenTraceData();
+ // Stop timer
+ errorTimer.stop();
+
+ // Checking an updating progress status based on the completed task type
+ checkTaskForCurrentProgressStatus(this.taskList.get(0));
+
+ if( this.taskList.get(0) == MEMSPY_LAUNCH ){
+ //Setting timer value to MAX here when known that MemSpy Launcher in S60 target is OK
+ //(last successfully run command is MemSpy launch).
+ this.currentWaitTime = MAX_WAIT_TIME;
+
+ // MemSpy started successfully, update status
+ this.MemSpyRunning = true;
+
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreEngine.memSpyReady/MEMSPY_LAUNCH/MemSpyRunning=true"); //$NON-NLS-1$
+ if( this.taskList.size() >= 2 && this.taskList.get(1) == MEMSPY_THREAD_INFO ){
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreEngine.memSpyReady/MEMSPY_LAUNCH/activateId( threadID: "+ threadID); //$NON-NLS-1$
+ if( !this.sendIntegerDataToLauncher(threadID) ){
+ launcherError(LauncherErrorType.ACTIVATION);
+ }
+ else{
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "T raceCoreEngine.memSpyReady/MEMSPY_LAUNCH/activateId => OK"); //$NON-NLS-1$
+ }
+ }
+ }
+ else if( this.taskList.get(0) == MEMSPY_THREAD_LIST ){
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreEngine.memSpyReady/MEMSPY_THREAD_LIST"); //$NON-NLS-1$
+ this.wizardPage.operationFinished( LauncherAction.GET_THREAD_LIST );
+ }
+ else if( this.taskList.get(0) == MEMSPY_THREAD_INFO ){
+ // Heap info received
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreEngine.memSpyReady/MEMSPY_THREAD_INFO"); //$NON-NLS-1$
+
+ // If heap type is not correct, reset tasklist and return error
+ if( !handler.isHeapTypeCorrect() ){
+ this.taskList.clear();
+ this.wizardPage.deviceError( LauncherErrorType.HEAP_TYPE_WRONG );
+ }
+
+ // ignore dumped traces-messages.
+ if( handler.isDumpedTraces() ){
+ handler.setDumpedTraces( false );
+ }
+ }
+ else if( this.taskList.get(0) == MEMSPY_GET_HEAP_DUMP ){
+ // Heap Dump received
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreEngine.memSpyReady/MEMSPY_GET_HEAP_DUMP"); //$NON-NLS-1$
+
+ if( handler.isDumpedTraces() == false ){
+ // Tell wizard that request is finished
+ this.wizardPage.operationFinished( LauncherAction.GET_HEAP_DUMP );
+ }
+ else{
+ handler.setDumpedTraces( false );
+ this.launcherError(LauncherErrorType.HEAP_NOT_FOUND);
+ }
+ }
+ else if( this.taskList.get(0) == MEMSPY_SWMT_UPDATE || this.taskList.get(0) == MEMSPY_SWMT_RESET ){
+ // if SWMT log received
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreEngine.memSpyReady/MEMSPY_SWMT_UPDATE || MEMSPY_SWMT_RESET"); //$NON-NLS-1$
+
+ if( handler.isDumpedTraces() == false ){
+ // Tell wizard that request is finished
+
+ // if timed swmt-logging is on request notification after interval
+ if( swmtLogInfo != null ){
+
+ boolean timerRunning = false;
+
+ // if interval is more that zero, start counter and set timerRunning variable correct.
+ if( interval > 0 ){
+ intervalTimer = new Timer( interval * SECOND, this );
+ intervalTimer.start();
+ timerRunning = true;
+ }
+
+ // tell wizard that one log file has been received.
+ this.wizardPage.operationFinished( LauncherAction.TIMED_SWMT_UPDATE, swmtLogInfo, timerRunning);
+ swmtLogInfo = null;
+
+ }
+ else{
+ this.wizardPage.operationFinished( LauncherAction.SWMT_UPDATE );
+ }
+ }
+ else{
+ //Reset SWMT timer values.
+ this.stopSWMTTimer();
+
+ handler.setDumpedTraces( false );
+ this.launcherError(LauncherErrorType.HEAP_NOT_FOUND);
+ }
+ }
+ else if( this.taskList.get(0) == MEMSPY_STOP ){
+ MemSpyRunning = false;
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreEngine.memSpyReady/MEMSPY_STOP"); //$NON-NLS-1$
+ }
+
+ // Remove first task from list.
+ if(taskList.size() > 0){
+ this.taskList.remove(0);
+ // Updating progress status to next task launched status
+ // (only updated in case this is progress to previous situation).
+ setProgressStatus(ProgressStatus.EPROGRESS_FIRST_TASK_LAUNCHED);
+ }
+ // run next task
+ this.runNextTask();
+
+
+ }
+
+ /**
+ * Updates progress status based on given task id.
+ * Used setter method takes care that update is done only
+ * if there has been progress compared to previous situation.
+ * @param taskId task event for the task that was just completed
+ */
+ private void checkTaskForCurrentProgressStatus(String taskId) {
+ if( taskId == MEMSPY_LAUNCH ){
+ setProgressStatus(ProgressStatus.EPROGRESS_MEMSPY_LAUNCHED);
+ }
+ else{
+ // In case of other than launch task first task has been executed properly
+ setProgressStatus(ProgressStatus.EPROGRESS_FIRST_TASK_DONE);
+ }
+ }
+
+ /**
+ * Handles calls when launcher prints error message into trace.
+ * @param error error code
+ * @param clientContextErrorString provides optionally additional information about the error occurred
+ */
+ public void launcherError( LauncherErrorType error, String clientContextErrorString ){
+
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreEngine.launcherError/error: " + error); //$NON-NLS-1$
+
+ additionalErrorInformation = clientContextErrorString;;
+
+ handler.stopLogging();
+ // Stop listening trace data
+ MemSpyPlugin.getTraceProvider().stopListenTraceData();
+
+ // Stop timer
+ if( errorTimer != null ){
+ errorTimer.stop();
+ //Setting timer value to default when error occurred
+ this.currentWaitTime = DEFAULT_WAIT_TIME;
+ }
+
+ // if wizard has been shut down, don't send error message.
+ if( taskList.size() == 1 && taskList.get(0) == MEMSPY_STOP ){
+ return;
+ }
+ this.taskList.clear();
+ // Stop logging trace data
+
+ //
+ //When there are special handling about error, founding error codes and then call the wizard.
+ //But in default case, we just pass the error code to wizard to show the error.
+ //
+
+ // MemSpy not running.
+ if( error == LauncherErrorType.MEMSPY_NOT_RUNNING ){
+ wizardPage.deviceError( LauncherErrorType.MEMSPY_NOT_RUNNING );
+ this.MemSpyRunning = false;
+ }
+ else if( error == LauncherErrorType.NO_ANSWER_FROM_DEVICE ){
+ // No answer from device can happen because
+ if( handler.isDumpedTraces() ){
+ // Input data is corrupted and traces are dumped...
+ handler.setDumpedTraces( false );
+ wizardPage.deviceError( LauncherErrorType.DUMPED_TRACES );
+ }
+ else{
+ //..or connection is broken and we really has'nt got any response from device
+ wizardPage.deviceError( LauncherErrorType.NO_ANSWER_FROM_DEVICE );
+ }
+ }
+ else {
+ wizardPage.deviceError( error);
+ }
+
+ }
+
+
+ /**
+ * Function that is called when response from launcher is not received within reasonable time.
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ */
+ public void actionPerformed(ActionEvent e) {
+
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreEngine.actionPerformed/e.getSource(): " + e.getSource().toString()); //$NON-NLS-1$
+
+ if( e.getSource() == errorTimer ){
+ // This function is called if MemSpy operation does not respond in time stored in currentWaitTime member variable.
+ // I.e. no answer has been received from the device in expected maximum time.
+ this.launcherError(LauncherErrorType.NO_ANSWER_FROM_DEVICE);
+ }
+ else if( e.getSource() == intervalTimer ){
+ this.runNextTimedTask();
+ // Notify wizard that SWMT receiving is started
+ wizardPage.startedReceivingSWMTLog();
+ intervalTimer.stop();
+ }
+
+ }
+
+
+ /**
+ * Shuts down MemSpy application. If some MemSpy operation is on-going schedule shutdown after that.
+ */
+ public void shutDownMemSpy(){
+
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreEngine.shutDownMemSpy"); //$NON-NLS-1$
+
+ // if MemSpy is running, send stop request
+ if( this.MemSpyRunning ) {
+ this.taskList.add( MEMSPY_STOP );
+ }
+
+ // If timer is not running( MemSpy is not currently operating ), run next task
+ if( errorTimer != null && !errorTimer.isRunning() ){
+ this.runNextTask();
+ }
+ disconnectTrace();
+ }
+
+ /**
+ * Check if MemSpy is running
+ * @return true
if MemSpy is Running false
otherwise.
+ */
+ public boolean isMemSpyRunning() {
+ return MemSpyRunning;
+ }
+
+ /**
+ * Establishes connection between plugin and device.
+ * @return true, is connection established successfully
+ */
+ private boolean connect(){
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreEngine.connect"); //$NON-NLS-1$
+ return MemSpyPlugin.getTraceProvider().connectTraceSource(this);
+ }
+
+ /**
+ * Disconnects connection between plugin and device if connection was started
+ * for this MemSpy run. Leaving connection up, if TraceViewer was already connected.
+ */
+ public void disconnectTrace() {
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreEngine.disconnectTrace"); //$NON-NLS-1$
+ MemSpyPlugin.getTraceProvider().disconnectTraceSource();
+ }
+
+ /**
+ * Sends current usage context-specific integer data to launcher.
+ * Integer data can contain values that can be expressed with 10 bytes
+ * i.e. only 10 lower bytes are taken into account when setting data.
+ * @param integerData integer data to be sent
+ * @return false
if failed to send integer data, otherwise true
+ */
+ private boolean sendIntegerDataToLauncher(int integerData)
+ {
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "sendIntegerDataToLauncher: id=" + integerData); //$NON-NLS-1$
+ return MemSpyPlugin.getTraceProvider().sendIntData(integerData);
+ }
+
+ /**
+ * Sends current usage context-specific string message to launcher.
+ * @param stringData string data to send
+ * @param writesFile set to true
if set trace handler needs to write some data into file
+ * @return true
on success, otherwise false
+ */
+ private boolean sendStringDataToLauncher(String stringData, boolean writesFile){
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreEngine.sendMessage/message=" + stringData); //$NON-NLS-1$
+
+ if(! addDataProcessorAndSetupLogging(writesFile)){
+ return false;
+ }
+
+ if(! MemSpyPlugin.getTraceProvider().sendStringData(stringData)){
+ return false;
+ }
+
+ startErrorTimer();
+ return true;
+ }
+
+ /**
+ * activateTrace
+ * Sends activation/deactivation message via TraceCore
+ * @param group GroupID
+ * @param writesFile true, if set trace handler needs to write some data into file.
+ * return false if trace activation was not successful.
+ */
+ private boolean activateTrace( String group, boolean writesFile ){
+
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreEngine.activateTrace/group=" + group + ", writesFile=" + writesFile); //$NON-NLS-1$ //$NON-NLS-2$
+
+ if(! addDataProcessorAndSetupLogging(writesFile)){
+ return false;
+ }
+
+ if(! MemSpyPlugin.getTraceProvider().activateTrace(group)){
+ return false;
+ }
+
+ startErrorTimer();
+ return true;
+
+ }
+
+ /**
+ * Starts error time after request.
+ */
+ private void startErrorTimer() {
+ // Start Timer
+ errorTimer = new Timer( currentWaitTime, this );
+ errorTimer.start();
+ }
+
+ /**
+ * Adds dataprocessor and sets-up logging.
+ * @param writesFile true, if set trace handler needs to write some data into file.
+ * @return true
in case of success, and false
in case of some failure.
+ */
+ private boolean addDataProcessorAndSetupLogging(boolean writesFile) {
+
+ //Add DataProcessor to TraceViewer
+ if(! MemSpyPlugin.getTraceProvider().startListenTraceData(handler)){
+ return false;
+ }
+
+ // Start logging
+ if( !handler.startLogging(currentFile, writesFile ) ){
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * runNextTask
+ * Gets next task from list and sends it to TraceCore.
+ * @return false if operation fails.
+ */
+ private boolean runNextTask(){
+
+ try {
+ if( taskList.size() > 0 ){
+ String nextTask = taskList.get(0);
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreEngine.runNextTask/taskList.get(0)=" + nextTask); //$NON-NLS-1$
+
+ // Confirming that all necessary preparations for running the next task has been done.
+ prepareRunNextTask();
+
+ // Set writeFile value as false when task needs to write some data into file
+ if( nextTask == MEMSPY_GET_HEAP_DUMP || nextTask == MEMSPY_SWMT_UPDATE || nextTask == MEMSPY_SWMT_RESET ){
+ if( !activateTrace( nextTask, true ) ){
+ this.launcherError(LauncherErrorType.ACTIVATION);
+ return false;
+ }
+ }
+ else if(nextTask == MEMSPY_SET_HEAP_NAME_FILTER){
+ // This task used subscribe communication, instead of group IDs
+ // Send SWMT heap filter before activating command group
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreEngine.memSpyReady/MEMSPY_SET_HEAP_NAME_FILTER/sendMessage"); //$NON-NLS-1$
+ if( !this.sendStringDataToLauncher(getHeapNameFilterForSWMT(), false)){
+ launcherError(LauncherErrorType.ACTIVATION);
+ }
+ else{
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreEngine.memSpyReady/MEMSPY_SET_HEAP_NAME_FILTER/sendMessage => OK"); //$NON-NLS-1$
+ }
+ }
+ else{
+ if( !activateTrace( nextTask, false) ){
+ this.launcherError(LauncherErrorType.ACTIVATION);
+ return false;
+ };
+
+ }
+ }
+ else{
+ DbgUtility.println(DbgUtility.PRIORITY_LOOP, "TraceCoreEngine.runNextTask/empty taskList"); //$NON-NLS-1$
+ //Setting timer value to default when there are no tasks to run
+ this.currentWaitTime = DEFAULT_WAIT_TIME;
+ }
+ return true;
+
+ } catch (Exception e) {
+ String errMsg = "Unexpected exception in encountered in TraceCoreEngine.runNextTask: " + e;
+ MemSpyConsole.getInstance().println(errMsg , IConsolePrintUtility.MSG_ERROR);
+ return false;
+ }
+
+ }
+
+
+ /**
+ * Confirms that all necessary preparations for running the next task has been done.
+ */
+ private void prepareRunNextTask() {
+ if(this.taskList.get(0) == MEMSPY_SET_CATEGORIES_LOW ){
+ // Setting SWMT low bits data before activating command group
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreEngine.prepareRunNextTask/activateId( getCategoriesForSWMTLowBits(): "+ getCategoriesForSWMTLowBits()); //$NON-NLS-1$
+ if( !this.sendIntegerDataToLauncher( getCategoriesForSWMTLowBits()) ){
+ launcherError(LauncherErrorType.ACTIVATION );
+ }
+ else{
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreEngine.prepareRunNextTask/MEMSPY_SET_CATEGORIES_HIGH/activateId => OK"); //$NON-NLS-1$
+ }
+ }
+ else if( this.taskList.get(0) == MEMSPY_SET_CATEGORIES_HIGH ){
+ // Setting SWMT high bits data before activating command group
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreEngine.prepareRunNextTask/MEMSPY_SET_CATEGORIES_HIGH/activateId( getCategoriesForSWMTHighBits(): "+ getCategoriesForSWMTHighBits()); //$NON-NLS-1$
+ if( !this.sendIntegerDataToLauncher( getCategoriesForSWMTHighBits()) ){
+ launcherError(LauncherErrorType.ACTIVATION );
+ }
+ else{
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreEngine.prepareRunNextTask/MEMSPY_SET_CATEGORIES_HIGH/activateId => OK"); //$NON-NLS-1$
+ }
+ }
+ }
+
+ /**
+ * getNewSWMTInfo.
+ * Creates a new SWMTLogInfo object and sets correct filename and time into it.
+ * @return SWMTLogInfo-object
+ */
+ private SWMTLogInfo getNewSWMTInfo(){
+
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "TraceCoreEngine.getNewSWMTInfo"); //$NON-NLS-1$
+
+ // Create new SWMTLogInfo item.
+ SWMTLogInfo newItem = new SWMTLogInfo();
+
+ // set date correct
+ Date date = new Date();
+ newItem.setDate(date);
+
+
+ // set filename correct
+ newItem.setPath( MemSpyFileOperations.getTempFileNameForSWMTLog(cycleNumber, date) );
+
+ // set type
+ newItem.setType( SWMTLogType.DEVICE );
+
+ return newItem;
+ }
+
+ /**
+ * Get first task.
+ * @return first task from taskList.
+ */
+ public String getFirstTask(){
+ if( taskList.size() > 0 ){
+ return taskList.get(0);
+ }
+ else{
+ return null;
+ }
+ }
+
+ /**
+ * Gets lower 10 bits for SWMT categories that user wants to include into SWMT log.
+ * @return lower 10 bits for SWMT categories that user wants to include into SWMT log.
+ */
+ public int getCategoriesForSWMTLowBits() {
+ int lowBits = getCategoriesForSWMTWithKernelHandles() & 0x3ff; // ANDs away all the other that lower 10 bits
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "getCategoriesForSWMTLowBits(): " + String.format("0x%x", lowBits)); //$NON-NLS-1$
+ return lowBits;
+ }
+
+ /**
+ * Gets higher bits for SWMT categories that user wants to include into SWMT log.
+ * @return higher bits for SWMT categories that user wants to include into SWMT log.
+ */
+ public int getCategoriesForSWMTHighBits() {
+ int highBits = getCategoriesForSWMTWithKernelHandles()>>10;
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "getCategoriesForSWMTHighBits(): " + String.format("0x%x", highBits)); //$NON-NLS-1$
+ return highBits;
+ }
+
+ /**
+ * Gets SWMT categories that user wants to include into SWMT log.
+ * Includes always {@link SWMTCategoryConstants#CATEGORY_KERNELHANDLES} with it because SWMT Analyser
+ * needs it to be functional
+ * @return SWMT categories that user wants to include into SWMT log.
+ */
+ private int getCategoriesForSWMTWithKernelHandles() {
+ // CATEGORY_KERNELHANDLES is always included into fetched categories because data is required by SWMT analyser plug-in
+ //If SWMT Analyzer is modified so that Kernel Handles is not always needed then SWMTCategoryConstants.CATEGORY_KERNELHANDLES can be removed.
+ return getCategoriesForSWMT() | SWMTCategoryConstants.CATEGORY_KERNELHANDLES;
+ }
+
+
+ /**
+ * Gets SWMT categories that user wants to include into SWMT log.
+ * @return SWMT categories that user wants to include into SWMT log.
+ */
+ public int getCategoriesForSWMT() {
+ int sessionSpecificSWMTCategorySetting = MemSpyPreferences.getSWMTCategorySetting();
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "getCategoriesForSWMT(): " + String.format("0x%x", sessionSpecificSWMTCategorySetting)); //$NON-NLS-1$
+ SWMTCategoryConstants.debugPrintSWMTCategorySetting(sessionSpecificSWMTCategorySetting);
+ return sessionSpecificSWMTCategorySetting;
+ }
+
+ /**
+ * Sets SWMT categories that user wants to include into SWMT log.
+ * @param categoriesForSWMT SWMT categories that user wants to include into SWMT log.
+ * @param isProfileSettings true
if these settings are profile settings
+ * false
if these are custom settings
+ */
+ public void setCategoriesForSWMT(int categoriesForSWMT, boolean isProfileSettings) {
+ MemSpyPreferences.setSWMTCategorySetting(categoriesForSWMT, isProfileSettings);
+ }
+
+ /**
+ * Sets if User has select a Profile or not
+ * @param isProfileCategoriesSelected
+ */
+ public void setProfileTrackedCategoriesSelected(boolean isProfileCategoriesSelected) {
+ MemSpyPreferences.setProfileTrackedCategoriesSelected(isProfileCategoriesSelected);
+ }
+
+ /**
+ * Gets if User has select a Profile or not
+ * @return true
if one of the profiles has been selected
+ */
+ public boolean isProfileTrackedCategoriesSelected() {
+ return MemSpyPreferences.isProfileTrackedCategoriesSelected();
+ }
+
+ /**
+ * Gets SWMT HeapNameFilter to filter User Heaps in SWMT log.
+ * @return SWMT HeapNameFilter that user wants to include into SWMT log.
+ */
+ public String getHeapNameFilterForSWMT() {
+ String filter = MemSpyPreferences.getSWMTHeapNameFilter();
+
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "getHeapNameFilterForSWMT(): " + filter); //$NON-NLS-1$
+ return filter;
+ }
+
+ /**
+ * Sets SWMT HeapNameFilter to filter User Heaps in SWMT log.
+ * @param HeapNameFilter SWMT HeapNameFilter that user wants to include into SWMT log.
+ */
+ public void setHeapNameFilterForSWMT(String heapNameFilterForSWMT) {
+ MemSpyPreferences.setSWMTHeapNameFilter(heapNameFilterForSWMT);
+ }
+
+ /**
+ * Restarts error timer
+ */
+ public void restartErrorTimer() {
+ if( errorTimer != null && errorTimer.isRunning() ){
+ errorTimer.restart();
+ }
+ }
+
+ /**
+ * Notify about MemSpy Launcher S60 application version
+ * @param version in format "x", e.g "1".
+ */
+ public void setMemSpyLauncherVersion(String version) {
+ String msg = "MemSpy Launcher data version: '" +version +"' detected in S60 target.";
+ DbgUtility.println(DbgUtility.PRIORITY_LOOP, msg);
+ MemSpyConsole.getInstance().println(msg);
+
+ receivedMemSpyLauncherDataVersion = Integer.parseInt(version);
+ }
+
+ /**
+ * Check if received MemSpy Launcher data version is at least required version
+ */
+ private void checkMemSpyLauncherDataVersion() {
+ int requiredVersion = ProductInfoRegistry.getRequiredMemSpyLauncherDataVersion();
+ DbgUtility.println(DbgUtility.PRIORITY_LOOP, "Required MemSpy Launcher data version: " +requiredVersion);
+ if(requiredVersion > receivedMemSpyLauncherDataVersion){
+ this.launcherError(LauncherErrorType.TOO_OLD_MEMSPY_LAUNCHER_DATAVERSION);
+ }
+ }
+
+ /**
+ * Get Heap Dump files that has been imported during SWMT logging.
+ * @return list about imported Heap Dumps.
+ */
+ public ArrayList getImportedSWMTHeaps() {
+ return handler.getImportedSWMTHeaps();
+ }
+
+ /**
+ * Gets progress status for current wizard session with current connection settings.
+ * @return Progress status for current wizard session with current connection settings.
+ */
+ public ProgressStatus getProgressStatus() {
+ return progressStatus;
+ }
+
+ /**
+ * Sets progress status if there has been further progress after recent progress status update.
+ * @param progressStatus the progressStatus to set
+ */
+ private void setProgressStatus(ProgressStatus progressStatus) {
+ if(progressStatus.ordinal() > this.progressStatus.ordinal()){
+ this.progressStatus = progressStatus;
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "setProgressStatus: " + this.progressStatus.name()); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Resets progress status back into initial value.
+ */
+ public void resetProgressStatus() {
+ this.progressStatus = ProgressStatus.EPROGRESS_INITIAL;
+ }
+
+ /**
+ * Delegates launcher error info further without any additional information
+ * @param generalLauncherError launcher error occurred
+ */
+ public void launcherError(LauncherErrorType launcherError) {
+ launcherError(launcherError, "");
+ }
+
+ /**
+ * Gets possible additional information related to occurred error.
+ * @return string containing additional information related to occurred error
+ */
+ public String getAdditionalErrorInformation() {
+ return additionalErrorInformation;
+ }
+
+ /* (non-Javadoc)
+ * @see com.nokia.s60tools.memspy.export.ITraceClientNotificationsIf#notifyError(java.lang.String)
+ */
+ public void notifyError(String message) {
+ // Currently only showing trace errors on console
+ MemSpyConsole.getInstance().println(message, MemSpyConsole.MSG_ERROR);
+ }
+
+ /* (non-Javadoc)
+ * @see com.nokia.s60tools.memspy.export.ITraceClientNotificationsIf#notifyInformation(java.lang.String)
+ */
+ public void notifyInformation(String message) {
+ // Currently only showing trace informative messages on console
+ MemSpyConsole.getInstance().println(message, MemSpyConsole.MSG_NORMAL);
+ }
+
+ /* (non-Javadoc)
+ * @see com.nokia.s60tools.memspy.export.ITraceClientNotificationsIf#notifyWarning(java.lang.String)
+ */
+ public void notifyWarning(String message) {
+ // Currently only showing trace warnings on console
+ MemSpyConsole.getInstance().println(message, MemSpyConsole.MSG_WARNING);
+ }
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/model/UserEnteredData.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/model/UserEnteredData.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,373 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+package com.nokia.s60tools.memspy.model;
+
+import org.eclipse.jface.dialogs.IDialogSettings;
+
+import com.nokia.s60tools.memspy.plugin.MemSpyPlugin;
+
+/**
+ * This class is used to save and restore data which is entered by user in
+ * wizard pages.
+ *
+ */
+public class UserEnteredData {
+
+ // sections names for each wizard page
+ private static final String SECTION_SELECT_ACTION = "SelectActionPage";
+ private static final String SECTION_IMPORT_HEAP = "SelectDeviceOrFile";
+ private static final String SECTION_COMPARE_HEAPS_FIRST = "CompareHeapsFirst";
+ private static final String SECTION_COMPARE_HEAPS_SECOND = "CompareHeapsSecond";
+ private static final String SECTION_DEFINE_OUTPUT = "OutputFile";
+ private static final String SECTION_IMPORT_SWMT = "SWMT";
+ private static final String SECTION_PARAMETER_FILES = "ParameterFiles";
+
+
+ // Item key names.
+ private static final String PREVIOUS_RADIO_BUTTON_SELECTION = "PreviousRadioButtonSelection";
+ private static final String PREVIOUS_IMPORTED_FILES = "PreviousFiles";
+ private static final String PREVIOUS_INTERVAL = "Interval";
+
+ /**
+ * How many previously entered values are saved
+ */
+ public static final int MAX_SAVED_VALUES = 5;
+
+
+ /**
+ * Enumeration for actions available
+ */
+ public static enum ValueTypes { SELECT_ACTION,
+ IMPORT_HEAP,
+ COMPARE_HEAP_FIRST_HEAP,
+ COMPARE_HEAP_SECOND_HEAP,
+ SWMT,
+ OUTPUT_FILE}
+
+ /**
+ * Returns previous radio button selection from given valuetype
+ * @param valueType what radio button selection is requested
+ * @return previous radio button selection
+ */
+ public int getPreviousRadioButtonSelection( ValueTypes valueType) {
+ try {
+ int retval = 0;
+
+ // Get int from that section where value is saved.
+
+ switch(valueType){
+ case SELECT_ACTION:{
+ IDialogSettings section = getSection(SECTION_SELECT_ACTION);
+ if (section != null) {
+ retval = section.getInt(PREVIOUS_RADIO_BUTTON_SELECTION);
+
+ }
+ break;
+ }
+ case IMPORT_HEAP:{
+ IDialogSettings section = getSection(SECTION_IMPORT_HEAP);
+ if (section != null) {
+ retval = section.getInt(PREVIOUS_RADIO_BUTTON_SELECTION);
+ }
+ break;
+ }
+ case COMPARE_HEAP_FIRST_HEAP:{
+ IDialogSettings section = getSection(SECTION_COMPARE_HEAPS_FIRST);
+ if (section != null) {
+ retval = section.getInt(PREVIOUS_RADIO_BUTTON_SELECTION);
+
+ }
+ break;
+ }
+ case COMPARE_HEAP_SECOND_HEAP:{
+ IDialogSettings section = getSection(SECTION_COMPARE_HEAPS_SECOND);
+ if (section != null) {
+ retval = section.getInt(PREVIOUS_RADIO_BUTTON_SELECTION);
+
+ }
+ break;
+ }
+ case SWMT:{
+ IDialogSettings section = getSection(SECTION_IMPORT_SWMT);
+ if (section != null) {
+ retval = section.getInt(PREVIOUS_RADIO_BUTTON_SELECTION);
+
+ }
+ break;
+ }
+ default:{
+ break;
+ }
+ }
+ return retval;
+ } catch (Exception e) {
+ return 0;
+ }
+ }
+
+ /**
+ * Saves radio button selection into correct section
+ * @param valueType type of radio button
+ * @param value radio button value
+ */
+ public void saveRadioButtonSelection(ValueTypes valueType, int value) {
+ try {
+
+ // Save integer into correct section.
+
+ switch(valueType){
+ case SELECT_ACTION:{
+ IDialogSettings section = getSection(SECTION_SELECT_ACTION);
+ if (section != null) {
+ section.put(PREVIOUS_RADIO_BUTTON_SELECTION, value);
+ }
+ break;
+ }
+ case IMPORT_HEAP:{
+ IDialogSettings section = getSection(SECTION_IMPORT_HEAP);
+ if (section != null) {
+ section.put(PREVIOUS_RADIO_BUTTON_SELECTION, value);
+ }
+ break;
+ }
+ case COMPARE_HEAP_FIRST_HEAP:{
+ IDialogSettings section = getSection(SECTION_COMPARE_HEAPS_FIRST);
+ if (section != null) {
+ section.put(PREVIOUS_RADIO_BUTTON_SELECTION, value);
+ }
+ break;
+ }
+ case COMPARE_HEAP_SECOND_HEAP:{
+ IDialogSettings section = getSection(SECTION_COMPARE_HEAPS_SECOND);
+ if (section != null) {
+ section.put(PREVIOUS_RADIO_BUTTON_SELECTION, value);
+ }
+
+ break;
+ }
+ case SWMT:{
+ IDialogSettings section = getSection(SECTION_IMPORT_SWMT);
+ if (section != null) {
+ section.put(PREVIOUS_RADIO_BUTTON_SELECTION, value);
+ }
+ break;
+ }
+ default:{
+ break;
+ }
+ }
+
+
+ } catch (Exception E) {
+ // No actions needed
+ }
+ }
+
+ /**
+ * Returns wanted section
+ * @param section name of the wanted section
+ * @return wanted section
+ */
+ protected IDialogSettings getSection(String section) {
+ IDialogSettings retVal = null;
+ if (MemSpyPlugin.getDefault().getDialogSettings() != null) {
+ retVal = MemSpyPlugin.getDefault().getDialogSettings().getSection(section);
+ if (retVal == null) {
+ retVal = MemSpyPlugin.getDefault().getDialogSettings().addNewSection(section);
+ }
+ }
+ return retVal;
+ }
+
+
+ /**
+ * Returns values user has previously entered to wizard pages.
+ * @param valueType type of the values
+ * @return user's previous values
+ */
+ public String[] getPreviousValues(ValueTypes valueType) {
+ try {
+ String[] retVal = null;
+
+ // get value from correct section
+ switch (valueType) {
+ case IMPORT_HEAP: {
+ retVal = getPreviousPaths(SECTION_IMPORT_HEAP, PREVIOUS_IMPORTED_FILES);
+ break;
+ }
+ case COMPARE_HEAP_FIRST_HEAP: {
+ retVal = getPreviousPaths(SECTION_COMPARE_HEAPS_FIRST, PREVIOUS_IMPORTED_FILES);
+ break;
+ }
+ case COMPARE_HEAP_SECOND_HEAP: {
+ retVal = getPreviousPaths(SECTION_COMPARE_HEAPS_SECOND, PREVIOUS_IMPORTED_FILES);
+ break;
+ }
+ case OUTPUT_FILE:{
+ retVal = getPreviousPaths(SECTION_DEFINE_OUTPUT, PREVIOUS_IMPORTED_FILES);
+ break;
+ }
+ case SWMT:{
+ retVal = getPreviousPaths(SECTION_IMPORT_SWMT, PREVIOUS_INTERVAL);
+ break;
+ }
+ default:{
+ break;
+ }
+ }
+
+ return retVal;
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ /**
+ * Saves user's latest value.
+ * @param pathType value type
+ * @param value value to be saved
+ */
+ public void saveValue(ValueTypes pathType, String value) {
+ if (value.trim().length() < 1)
+ return;
+
+ try {
+ switch (pathType) {
+ case IMPORT_HEAP: {
+ savePath(value, PREVIOUS_IMPORTED_FILES, getSection(SECTION_IMPORT_HEAP));
+ break;
+ }
+
+ case COMPARE_HEAP_FIRST_HEAP: {
+ savePath(value, PREVIOUS_IMPORTED_FILES, getSection(SECTION_COMPARE_HEAPS_FIRST));
+
+ break;
+ }
+ case COMPARE_HEAP_SECOND_HEAP:{
+ savePath(value, PREVIOUS_IMPORTED_FILES, getSection(SECTION_COMPARE_HEAPS_SECOND));
+
+ break;
+ }
+ case OUTPUT_FILE:{
+ savePath(value, PREVIOUS_IMPORTED_FILES, getSection(SECTION_DEFINE_OUTPUT));
+ break;
+ }
+ case SWMT:{
+ savePath(value, PREVIOUS_INTERVAL, getSection(SECTION_IMPORT_SWMT));
+ break;
+ }
+ default:{
+ break;
+ }
+ }
+ } catch (Exception E) {
+ // No actions needed
+ }
+ }
+
+
+ /**
+ * Returns previously entered values of wanted context (i.e. wizard page).
+ * @param section section which contains array
+ * @param array name of the array whose values are needed
+ * @return previously entered paths of given section
+ */
+ protected String[] getPreviousPaths(String section, String array) {
+ String[] retVal = null;
+ IDialogSettings sect = getSection(section);
+ if (sect != null) {
+ retVal = sect.getArray(array);
+ }
+
+ return retVal;
+ }
+
+ /**
+ * Saves given path to correct section in dialog_settings.xml
+ * @param path path to save
+ * @param array name of the array which contains correct values
+ * @param section section which has array
+ */
+ protected void savePath(String path, String array, IDialogSettings section) {
+ if (section != null) {
+ String[] previousValues = section.getArray(array);
+
+ // No previous values exist
+ if (previousValues == null) {
+ previousValues = new String[1];
+ previousValues[0] = path;
+ // Previous values exists
+ } else {
+ int valuesCount = previousValues.length;
+
+ boolean valueExisted = false;
+ // see if passed value already exist.
+ for (int i = 0; i < valuesCount; i++) {
+ if (previousValues[i].compareToIgnoreCase(path) == 0) {
+ valueExisted = true;
+
+ // passed value exists, move it to first position
+ for (int j = i; j > 0; j--) {
+ previousValues[j] = previousValues[j-1];
+ }
+ previousValues[0] = path;
+
+ break;
+ }
+ }
+
+ // passed value did not exist, add it to first position (and move older values "down")
+ if (!valueExisted) {
+ if (valuesCount >= MAX_SAVED_VALUES) {
+ for (int i = valuesCount-1; i > 0; i--) {
+ previousValues[i] = previousValues[i-1];
+ }
+ previousValues[0] = path;
+ } else {
+ String[] values = new String[valuesCount + 1];
+ values[0] = path;
+ for (int i = 0; i < valuesCount; i++) {
+ values[i+1] = previousValues[i];
+ }
+ previousValues = values;
+ }
+ }
+ }
+ section.put(array, previousValues);
+ }
+ }
+
+
+ /**
+ * Get selections for dialog
+ * @return parameter files section
+ */
+ public static IDialogSettings getParameterFilesSection() {
+ IDialogSettings retVal = null;
+ if (MemSpyPlugin.getDefault().getDialogSettings() != null) {
+ retVal = MemSpyPlugin.getDefault().getDialogSettings().getSection(SECTION_PARAMETER_FILES);
+ if (retVal == null) {
+ retVal = MemSpyPlugin.getDefault().getDialogSettings().addNewSection(SECTION_PARAMETER_FILES);
+ }
+ }
+ return retVal;
+ }
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/plugin/MemSpyPlugin.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/plugin/MemSpyPlugin.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,363 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+package com.nokia.s60tools.memspy.plugin;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+import com.nokia.s60tools.memspy.export.ITraceClientNotificationsIf;
+import com.nokia.s60tools.memspy.export.ITraceDataProcessor;
+import com.nokia.s60tools.memspy.export.ITraceProvider;
+import com.nokia.s60tools.memspy.resources.ImageResourceManager;
+import com.nokia.s60tools.memspy.util.MemSpyConsole;
+import com.nokia.s60tools.util.debug.DbgUtility;
+
+
+/**
+ * The activator class controls the plug-in life cycle.
+ */
+public class MemSpyPlugin extends AbstractUIPlugin {
+
+ /**
+ * Plug-in ID for Launcher plug-in.
+ */
+ public static final String MEMSPY_TRACE_PLUGIN_ID = "com.nokia.s60tools.memspy.trace";//$NON-NLS-1$
+ /**
+ * Launcher plug-in binaries directory name.
+ */
+ public static final String LAUNCHER_BINARIES_DIR_NAME = "Launcher.binaries";//$NON-NLS-1$
+
+ /**
+ * Trace provider extension name.
+ */
+ final String EXTENSION_TRACE_PROVIDER = "traceprovider"; //$NON-NLS-1$
+
+ /**
+ * Plug-in ID constant.
+ */
+ public static final String PLUGIN_ID = "com.nokia.s60tools.memspy";
+
+ /**
+ * Member for storing plug-in install path.
+ */
+ private String pluginInstallPath = "";
+
+ /**
+ * Shared plug-in instance
+ */
+ private static MemSpyPlugin plugin;
+
+ /**
+ * Storing reference to possibly installed trace provider plug-in.
+ */
+ private static ITraceProvider traceProvider;
+
+ /**
+ * Preferences store instance reference.
+ */
+ private static IPreferenceStore prefsStore;
+
+ /**
+ * SWMT category setting feature is enabled by default, but may be disabled in case device does not support it.
+ */
+ boolean isSWMTCategorySettingFeatureEnabled = true;
+
+ /**
+ * The constructor
+ */
+ public MemSpyPlugin() {
+ plugin = this;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+
+ String pluginInstallLocation = getPluginInstallPath();
+ String imagesPath = getImagesPath(pluginInstallLocation);
+
+ // Loading images required by this plug-in
+ ImageResourceManager.loadImages(imagesPath);
+
+ // Getting installed trace provider plug-in if available
+ traceProvider = findTraceProviderExtension();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static MemSpyPlugin getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Get plugin installation path
+ * @return the path where this plugin is installed
+ */
+ public static String getPluginInstallPath() {
+ try {
+ if ( plugin.pluginInstallPath.equals("") ) { //$NON-NLS-1$
+ // URL to the plugin's root ("/")
+ URL relativeURL = plugin.getBundle().getEntry("/"); //$NON-NLS-1$
+ // Converting into local path
+ URL localURL = FileLocator.toFileURL(relativeURL);
+ // Getting install location in correct form
+ File f = new File(localURL.getPath());
+ plugin.pluginInstallPath = f.getAbsolutePath();
+ }
+ return plugin.pluginInstallPath;
+ } catch (Exception e) {
+ return ""; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Gets images path relative to given plugin install path.
+ * @param pluginInstallPath Plugin installation path.
+ * @return Path were image resources are located.
+ * @throws IOException
+ */
+ private String getImagesPath(String pluginInstallPath) throws IOException{
+ return pluginInstallPath
+ + File.separatorChar + "icons"; //$NON-NLS-1$
+ }
+
+ /**
+ * This must be called from UI thread. If called
+ * from non-ui thread this returns null
.
+ * @return Currently active workbench page.
+ */
+ public static IWorkbenchPage getCurrentlyActivePage(){
+ return getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ }
+
+ /**
+ * This must be called from UI thread. If called
+ * from non-UI thread this returns null
.
+ * @return The shell of the currently active workbench window..
+ */
+ public static Shell getCurrentlyActiveWbWindowShell(){
+ IWorkbenchPage page = getCurrentlyActivePage();
+ if(page != null){
+ return page.getWorkbenchWindow().getShell();
+ }
+ return null;
+ }
+
+ /**
+ * Checks if SWMT category setting feature is enabled.
+ * @return true
if enabled, otherwise false
.
+ */
+ public boolean isSWMTCategorySettingFeatureEnabled() {
+ return isSWMTCategorySettingFeatureEnabled;
+ }
+
+ /**
+ * Sets if SWMT category setting feature is enabled.
+ * @param isSWMTCategorySettingFeatureEnabled true
if enabled, otherwise false
.
+ */
+ public void setSWMTCategorySettingFeatureEnabled(
+ boolean isSWMTCategorySettingFeatureEnabled) {
+ this.isSWMTCategorySettingFeatureEnabled = isSWMTCategorySettingFeatureEnabled;
+ }
+
+ /**
+ * Gets MemSpy Launcher plugin's binaries directory path
+ * @return path were Launcher binaries are located.
+ */
+ public String getMemspyLauncherBinDir(){
+
+ Bundle bundle = Platform
+ .getBundle(MEMSPY_TRACE_PLUGIN_ID); //$NON-NLS-1$
+
+ String launcherBinDir = null;
+ try {
+ // URL to the Launcher binaries
+ URL relativeURL = bundle.getEntry(LAUNCHER_BINARIES_DIR_NAME); //$NON-NLS-1$
+ // Converting into local path
+ URL localURL = FileLocator.toFileURL(relativeURL);
+ // Getting install location in correct form
+ File file = new File(localURL.getPath());
+ launcherBinDir = file.getAbsolutePath();
+ MemSpyConsole.getInstance().println("MemSpyLauncher binaries dir detected: " +launcherBinDir);
+
+ } catch (IOException e) {
+ MemSpyConsole.getInstance().println("MemSpyLauncher binaries dir detection failed, reason: " +e);
+ e.printStackTrace();
+ }
+ return launcherBinDir;
+
+ }
+
+ /**
+ * Returns PreferenceStore where plugin preferences are stored.
+ * @return PreferenceStore where plugin preferences are stored
+ */
+ public static IPreferenceStore getPrefsStore() {
+ if (prefsStore == null){
+ prefsStore = getDefault().getPreferenceStore();
+ }
+
+ return prefsStore;
+ }
+
+ /**
+ * Gets trace provider interface instance if available.
+ * @return trace provider interface instance or null
if not available
+ */
+ public static ITraceProvider getTraceProvider(){
+ if(isTraceProviderAvailable()){
+ return traceProvider;
+ }
+ // Otherwise returning a dummy provider instance
+ return createDummyTraceProviderInstance();
+ }
+
+ /**
+ * Creates a dummy trace provider instance.
+ * Client can safely reference to this dummy instance without any NullPointerException
+ * problems etc. However the corresponding functionalities from UI should be disables.
+ * @return dummy trace provider instance.
+ */
+ private static ITraceProvider createDummyTraceProviderInstance() {
+ // Creating just a dummy provider instance that does not do anything
+ return new ITraceProvider() {
+
+ public void stopListenTraceData() {
+ // dummy provider does not take any actions
+ }
+
+ public boolean startListenTraceData(ITraceDataProcessor dataProcessor) {
+ // dummy provider does not take any actions
+ return false;
+ }
+
+ public boolean sendStringData(String stringData) {
+ // dummy provider does not take any actions
+ return false;
+ }
+
+ public boolean sendIntData(int integerData) {
+ // dummy provider does not take any actions
+ return false;
+ }
+
+ public String getTraceSourcePreferencePageId() {
+ // dummy provider does not take any actions
+ return null;
+ }
+
+ public String getDisplayNameForCurrentConnection() {
+ return "";
+ }
+
+ public void disconnectTraceSource() {
+ // dummy provider does not take any actions
+ }
+
+ public boolean connectTraceSource(
+ ITraceClientNotificationsIf traceClient) {
+ // dummy provider does not take any actions
+ return false;
+ }
+
+ public boolean activateTrace(String traceGroupID) {
+ // dummy provider does not take any actions
+ return false;
+ }
+
+ };
+ }
+
+ /**
+ * Checks if trace provider plug-in is available.
+ * @return true
if trace provider interface available, otherwise false
+ */
+ public static boolean isTraceProviderAvailable(){
+ return (traceProvider != null);
+ }
+
+ /**
+ * Tries to find trace provider plug-ins. Selecting the first found one.
+ * @return reference to trace provider instance if found, otherwise null
+ */
+ ITraceProvider findTraceProviderExtension() {
+ try {
+ IExtensionRegistry er = Platform.getExtensionRegistry();
+ IExtensionPoint ep = er.getExtensionPoint(PLUGIN_ID, EXTENSION_TRACE_PROVIDER);
+ String uniqueIdentifier = ep.getUniqueIdentifier();
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "Found extension point: " + uniqueIdentifier); //$NON-NLS-1$
+ IExtension[] extensions = ep.getExtensions();
+
+ // if plug-ins were found.
+ if (extensions != null && extensions.length > 0) {
+
+ // read all found trace providers
+ for (int i = 0; i < extensions.length; i++) {
+ IConfigurationElement[] ce = extensions[i].getConfigurationElements();
+ if (ce != null && ce.length > 0) {
+ try {
+ ITraceProvider provider = (ITraceProvider)ce[0].createExecutableExtension("class"); //$NON-NLS-1$
+ // We support only one trace provider
+ if (provider != null) {
+ return provider;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/preferences/MemSpyPreferenceConstants.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/preferences/MemSpyPreferenceConstants.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+package com.nokia.s60tools.memspy.preferences;
+
+
+/**
+ * Class for storing keys to preferences.
+ */
+public class MemSpyPreferenceConstants {
+
+ /**
+ * preference DB key for SWMT Category Setting
+ */
+ public static final String SWMT_CATEGORY_SETTING = "SWMTCategorySetting"; //$NON-NLS-1$
+
+ /**
+ * preference DB key for SWMT Category Setting
+ */
+ public static final String SWMT_CATEGORY_SETTINGS_CUSTOM = "SWMTCategorySettingsCustom"; //$NON-NLS-1$
+
+ /**
+ * preference DB key for SWMT Category Setting
+ */
+ public static final String SWMT_CATEGORY_SETTING_PROFILE_SELECTED = "SWMTCategorySettingProfileSelected"; //$NON-NLS-1$
+
+ /**
+ * preference DB key for SWMT Heap Dump selection
+ */
+ public static final String SWMT_HEAP_DUMP_SELECTED = "SWMTHeapDumpSelected"; //$NON-NLS-1$
+
+ /**
+ * preference DB key for SWMT Heap filter Setting
+ */
+ public static final String SWMT_HEAPFILTER_SETTING = "SWMTHeapFilter"; //$NON-NLS-1$
+
+ /**
+ * preference DB key for closing S60 device between cycles
+ */
+ public static final String CLOSE_BETWEEN_CYCLES = "CloseS60DeviceBetweenCycles";//$NON-NLS-1$
+
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/preferences/MemSpyPreferenceInitializer.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/preferences/MemSpyPreferenceInitializer.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+package com.nokia.s60tools.memspy.preferences;
+
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+
+import com.nokia.s60tools.memspy.model.SWMTCategoryConstants;
+import com.nokia.s60tools.memspy.plugin.MemSpyPlugin;
+
+/**
+ * Class used to initialize default preference values.
+ */
+public class MemSpyPreferenceInitializer extends AbstractPreferenceInitializer {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
+ */
+ public void initializeDefaultPreferences() {
+
+ MemSpyPlugin.getPrefsStore().setDefault(MemSpyPreferenceConstants.SWMT_CATEGORY_SETTINGS_CUSTOM, SWMTCategoryConstants.PROFILE_BASIC);
+ MemSpyPlugin.getPrefsStore().setDefault(MemSpyPreferenceConstants.SWMT_CATEGORY_SETTING, SWMTCategoryConstants.PROFILE_BASIC);
+ MemSpyPlugin.getPrefsStore().setDefault(MemSpyPreferenceConstants.SWMT_CATEGORY_SETTING_PROFILE_SELECTED, true);
+ MemSpyPlugin.getPrefsStore().setDefault(MemSpyPreferenceConstants.SWMT_HEAPFILTER_SETTING, "");
+ MemSpyPlugin.getPrefsStore().setDefault(MemSpyPreferenceConstants.SWMT_HEAP_DUMP_SELECTED, false);
+ MemSpyPlugin.getPrefsStore().setDefault(MemSpyPreferenceConstants.CLOSE_BETWEEN_CYCLES, true);
+
+ }
+}
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/preferences/MemSpyPreferences.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/preferences/MemSpyPreferences.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,149 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+package com.nokia.s60tools.memspy.preferences;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+
+import com.nokia.s60tools.memspy.plugin.MemSpyPlugin;
+
+/**
+ * Helper class to use Dependency Explorer preferences. Use this class for accessing DE preferences
+ * instead of accessing directly through {@link org.eclipse.jface.util.IPropertyChangeListener.IPreferenceStore}.
+ */
+public class MemSpyPreferences {
+
+
+ /**
+ * Gets SWMT category settings for this session.
+ * @return SWMT category settings for this session
+ */
+ public static int getSWMTCategorySetting() {
+
+ IPreferenceStore store = MemSpyPlugin.getPrefsStore();
+
+ boolean isProfileSelected = store.getBoolean(MemSpyPreferenceConstants.SWMT_CATEGORY_SETTING_PROFILE_SELECTED);
+ int value;
+ if(isProfileSelected){
+ value = getSWMTCategorySettingForProfile();
+ }else{
+ value = store.getInt(MemSpyPreferenceConstants.SWMT_CATEGORY_SETTINGS_CUSTOM);
+ }
+ return value ;
+ }
+
+ /**
+ * Gets SWMT category settings for Profile selection.
+ * @return SWMT category settings for profile
+ */
+ public static int getSWMTCategorySettingForProfile() {
+ IPreferenceStore store = MemSpyPlugin.getPrefsStore();
+ return store.getInt(MemSpyPreferenceConstants.SWMT_CATEGORY_SETTING);
+ }
+
+ /**
+ * Sets SWMT category settings for this session.
+ * @param sessionSpecificSWMTCategorySetting SWMT category settings to set for this session
+ */
+ public static void setSWMTCategorySetting(int sessionSpecificSWMTCategorySetting, boolean isProfileSettings) {
+ IPreferenceStore store = MemSpyPlugin.getPrefsStore();
+ setProfileTrackedCategoriesSelected(isProfileSettings);
+ if(isProfileSettings){
+ store.setValue(MemSpyPreferenceConstants.SWMT_CATEGORY_SETTING, sessionSpecificSWMTCategorySetting);
+ }else{
+ store.setValue(MemSpyPreferenceConstants.SWMT_CATEGORY_SETTINGS_CUSTOM, sessionSpecificSWMTCategorySetting);
+ }
+ }
+
+
+ /**
+ * Sets SWMT category settings for this session.
+ * @param sessionSpecificSWMTCategorySetting SWMT category settings to set for this session
+ */
+ public static void setProfileTrackedCategoriesSelected(boolean isAllCategoriesSelected) {
+ IPreferenceStore store = MemSpyPlugin.getPrefsStore();
+ store.setValue(MemSpyPreferenceConstants.SWMT_CATEGORY_SETTING_PROFILE_SELECTED, isAllCategoriesSelected);
+ }
+
+ /**
+ * Get if All Tracke Categories is selected.
+ * @param true
if All is selected false
otherwise.
+ */
+ public static boolean isProfileTrackedCategoriesSelected() {
+
+ IPreferenceStore store = MemSpyPlugin.getPrefsStore();
+ boolean isAllSelected = store.getBoolean(MemSpyPreferenceConstants.SWMT_CATEGORY_SETTING_PROFILE_SELECTED);
+ return isAllSelected;
+
+ }
+
+ /**
+ * Sets the SWMT Heap Dump selection on/off
+ * @param selection
+ */
+ public static void setSWMTHeapDumpSelected(boolean selection) {
+ IPreferenceStore store = MemSpyPlugin.getPrefsStore();
+ store.setValue(MemSpyPreferenceConstants.SWMT_HEAP_DUMP_SELECTED, selection);
+ }
+
+ /**
+ * Gets the SWMT Heap Dump selection
+ * @param true
if Heap Dumps should receive with SWMT logging, false
otherwise.
+ */
+ public static boolean isSWMTHeapDumpSelected( ) {
+ IPreferenceStore store = MemSpyPlugin.getPrefsStore();
+ return store.getBoolean(MemSpyPreferenceConstants.SWMT_HEAP_DUMP_SELECTED);
+ }
+
+ /**
+ * Gets SWMT category settings for this session.
+ * @return SWMT HeapNameFilter setting for this session.
+ */
+ public static String getSWMTHeapNameFilter() {
+ IPreferenceStore store = MemSpyPlugin.getPrefsStore();
+ String filter = store.getString(MemSpyPreferenceConstants.SWMT_HEAPFILTER_SETTING);
+ return filter;
+ }
+
+ /**
+ * Sets SWMT HeapNameFilter setting for this session.
+ * @param heapNameFilter SWMT HeapNameFilter settings to set for this session.
+ */
+ public static void setSWMTHeapNameFilter(String heapNameFilter) {
+ IPreferenceStore store = MemSpyPlugin.getPrefsStore();
+ store.setValue(MemSpyPreferenceConstants.SWMT_HEAPFILTER_SETTING, heapNameFilter);
+ }
+
+ /**
+ * Sets the user selection if S60 device is closed between cycles
+ * @param selection
+ */
+ public static void setCloseSymbianAgentBetweenCycles(boolean selection) {
+ IPreferenceStore store = MemSpyPlugin.getPrefsStore();
+ store.setValue(MemSpyPreferenceConstants.CLOSE_BETWEEN_CYCLES, selection);
+ }
+
+ /**
+ * Gets the user selection if S60 device is closed between cycles
+ * @param true
if S60 Device is about to close between cycles, false
otherwise.
+ */
+ public static boolean isCloseSymbianAgentBetweenCyclesSelected( ) {
+ IPreferenceStore store = MemSpyPlugin.getPrefsStore();
+ return store.getBoolean(MemSpyPreferenceConstants.CLOSE_BETWEEN_CYCLES);
+ }
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/resources/HelpContextIDs.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/resources/HelpContextIDs.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,85 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+package com.nokia.s60tools.memspy.resources;
+
+/**
+ * IDs for context sensitive help.
+ * @see contexts.xml -file IDs links to
+ */
+public class HelpContextIDs {
+
+ /**
+ * The plug-in ID.
+ */
+ private static final String MEMSPY_HELP_PROJECT_PLUGIN_ID = "com.nokia.s60tools.memspy.help";
+
+ //
+ // ID's to MemSpy Help TOC
+ //
+
+ /**
+ * Id to Importing and analyzing heap dump files
+ */
+ public static final String MEMSPY_IMPORT_HEAP =
+ MEMSPY_HELP_PROJECT_PLUGIN_ID +".MEMSPY_HELP_IMPORT_HEAP";
+
+ /**
+ * Id to MemSpy Main View
+ */
+ public static final String MEMSPY_MAIN_VIEW =
+ MEMSPY_HELP_PROJECT_PLUGIN_ID +".MEMSPY_HELP_MAIN_VIEW";
+
+ /**
+ * Id to MemSpy Tasks
+ */
+ public static final String MEMSPY_SELECT_ACTION =
+ MEMSPY_HELP_PROJECT_PLUGIN_ID +".MEMSPY_HELP_IMPORT_SELECT_ACTION";
+
+ /**
+ * Id to Symbol and Map files
+ */
+ public static final String MEMSPY_IMPORT_SYMBOLS =
+ MEMSPY_HELP_PROJECT_PLUGIN_ID +".MEMSPY_HELP_IMPORT_SYMBOLS";
+
+ /**
+ * Id to Importing and comparing two heap dump files
+ */
+ public static final String MEMSPY_IMPORT_COMPARE =
+ MEMSPY_HELP_PROJECT_PLUGIN_ID +".MEMSPY_HELP_IMPORT_COMPARE";
+
+ /**
+ * Id to Importing and analyzing System Wide Memory Tracking log files
+ */
+ public static final String MEMSPY_IMPORT_SWMT =
+ MEMSPY_HELP_PROJECT_PLUGIN_ID +".MEMSPY_HELP_IMPORT_SWMT";
+
+ /**
+ * Id to Setting System Wide Memory Tracking tracked categories
+ */
+ public static final String MEMSPY_IMPORT_SWMT_CATEGORIES_DIALOG =
+ MEMSPY_HELP_PROJECT_PLUGIN_ID +".MEMSPY_HELP_IMPORT_SWMT_CATEGORIES_DIALOG";
+
+ /**
+ * Id to Configuring connection settings
+ */
+ public static final String MEMSPY_IMPORT_CONNECTION_SETTINGS =
+ MEMSPY_HELP_PROJECT_PLUGIN_ID +".MEMSPY_HELP_IMPORT_CONNECTION_SETTINGS";
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/resources/ImageKeys.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/resources/ImageKeys.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,61 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+package com.nokia.s60tools.memspy.resources;
+
+/**
+ * Keys to images with in application
+ */
+public class ImageKeys {
+ /**
+ * ID to MemSpy application icon
+ */
+ public static final String IMG_APP_ICON = "MEMSPY_IMG_APP_ICON";
+ /**
+ * ID to launch Heap Analyser icon
+ */
+ public static final String IMG_ANALYZE_HEAP = "MEMSPY_IMG_ANALYZE_HEAP";
+ /**
+ * ID to compare two heaps icon
+ */
+ public static final String IMG_COMPARE_2_HEAP = "MEMSPY_IMG_COMPARE_2_HEAP";
+ /**
+ * ID to export to HTML icon
+ */
+ public static final String IMG_EXPORT_TO_HTML = "MEMSPY_IMG_EXPORT_TO_HTML";
+ /**
+ * ID to Launch SWMT icon
+ */
+ public static final String IMG_LAUNCH_SWMT = "MEMSPY_IMG_LAUNCH_SWMT";
+ /**
+ * ID to Heap Dump icon
+ */
+ public static final String IMG_HEAP_DUMP = "MEMSPY_IMG_HEAP_DUMP";
+ /**
+ * ID to SWMT icon
+ */
+ public static final String IMG_SWMT_LOG = "MEMSPY_IMG_SWMT_LOG";
+ /**
+ * ID to Wizard icon
+ */
+ public static final String IMG_WIZARD = "MEMSPY_IMG_WIZARD";
+
+
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/resources/ImageResourceManager.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/resources/ImageResourceManager.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,82 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+package com.nokia.s60tools.memspy.resources;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+
+
+/**
+ * Class for handling MemSpy icons.
+ *
+ */
+public class ImageResourceManager {
+
+ /**
+ * Load images
+ * @param imagesPath
+ */
+ public static void loadImages(String imagesPath){
+
+ Display disp = Display.getCurrent();
+
+ ImageRegistry imgReg = JFaceResources.getImageRegistry();
+
+ //
+ // Storing images to image registry
+ //
+ Image img = new Image( disp, imagesPath + "\\memspy_16.png" );
+ imgReg.put( ImageKeys.IMG_APP_ICON, img );
+
+ img = new Image( disp, imagesPath + "\\Launch_SWMT.png" );
+ imgReg.put( ImageKeys.IMG_LAUNCH_SWMT, img );
+
+ img = new Image( disp, imagesPath + "\\Export_To_html.png" );
+ imgReg.put( ImageKeys.IMG_EXPORT_TO_HTML, img );
+
+ img = new Image( disp, imagesPath + "\\Compare_2_Heaps.png" );
+ imgReg.put( ImageKeys.IMG_COMPARE_2_HEAP, img );
+
+ img = new Image( disp, imagesPath + "\\Analyse_Heap.png" );
+ imgReg.put( ImageKeys.IMG_ANALYZE_HEAP, img );
+
+ img = new Image( disp, imagesPath + "\\Launch_SWMT.png" );
+ imgReg.put( ImageKeys.IMG_SWMT_LOG, img );
+
+ img = new Image( disp, imagesPath + "\\Analyse_Heap.png" );
+ imgReg.put( ImageKeys.IMG_HEAP_DUMP, img );
+
+ img = new Image( disp, imagesPath + "\\Memspy_45.png" );
+ imgReg.put( ImageKeys.IMG_WIZARD, img );
+
+ }
+
+ public static ImageDescriptor getImageDescriptor( String key ){
+ ImageRegistry imgReg = JFaceResources.getImageRegistry();
+ return imgReg.getDescriptor( key );
+ }
+
+ public static Image getImage( String key ){
+ ImageRegistry imgReg = JFaceResources.getImageRegistry();
+ return imgReg.get(key);
+ }
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/UiUtils.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/UiUtils.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,255 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+package com.nokia.s60tools.memspy.ui;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.program.Program;
+import org.eclipse.swt.widgets.Display;
+
+import com.nokia.s60tools.memspy.interfaces.IMemSpyTraceListener;
+import com.nokia.s60tools.memspy.interfaces.IMemSpyTraceListener.LauncherErrorType;
+import com.nokia.s60tools.memspy.model.TraceCoreEngine.ProgressStatus;
+import com.nokia.s60tools.memspy.plugin.MemSpyPlugin;
+import com.nokia.s60tools.memspy.util.MemSpyConsole;
+import com.nokia.s60tools.util.debug.DbgUtility;
+
+/**
+ * Static UI utility methods that are needed more than one place
+ * are located here in order to prevent code duplication.
+ */
+public class UiUtils {
+
+
+ /**
+ * Launcher SIS file name
+ */
+ private static final String MEM_SPY_LAUNCHER_S60_50_RN_D_SIGNED_SIS_FILE_NAME = "MemSpyLauncher_S60-50_RnD-signed.sis";
+
+ /**
+ * Shows error dialog that gives error context related information and guidance.
+ * E.g. Advises user to install launcher component to the device if it is needed.
+ * @param error Launcher error encountered
+ * @param errorMessage Error message to be shown to user
+ * @param progressStatus
+ */
+ public static void showErrorDialogToUser(final LauncherErrorType error, final String errorMessage, final ProgressStatus progressStatus) {
+
+ Runnable updateUiRunnable = new Runnable(){
+ public void run(){
+
+ // If no answer from device received, display dialog that allows user to install MemSpy Launcher.
+ if( error == LauncherErrorType.NO_ANSWER_FROM_DEVICE || error == LauncherErrorType.TOO_OLD_MEMSPY_LAUNCHER_DATAVERSION ){
+
+ switch (progressStatus) {
+ // Flow through on purpose 1
+ case EPROGRESS_MEMSPY_LAUNCHED: // MemSpy is launched but not yet actual task
+ case EPROGRESS_FIRST_TASK_LAUNCHED: // MemSpy is launched and also 1st real task is done
+ case EPROGRESS_FIRST_TASK_DONE: // Trace data has been received successfully at least once
+ showStandardErrorMessageDialog(errorMessage);
+ break;
+ // Flow through on purpose 2
+ case EPROGRESS_INITIAL: // MemSpy has not been launched successfully, so no progress at all
+ default:
+ adviceUserToInstallLauncherComponent(errorMessage);
+ break;
+ }
+ }
+ else{
+ showStandardErrorMessageDialog(errorMessage);
+ }
+
+ }
+
+ };
+
+ Display.getDefault().asyncExec(updateUiRunnable);
+ }
+
+ /**
+ * Shows standard eclipse error dialog with given error message
+ * @param errorMessage error message
+ */
+ private static void showStandardErrorMessageDialog(String errorMessage) {
+ Status status = new Status(IStatus.ERROR, MemSpyPlugin.PLUGIN_ID, 0, errorMessage, null);
+ // Display the dialog
+ ErrorDialog.openError(Display.getCurrent().getActiveShell(),IMemSpyTraceListener.ERROR_MEMSPY, null, status);
+ }
+
+ /**
+ * Advises used to install MemSpy launcher component and provides necessary action alternatives.
+ * @param errorMessage error message
+ */
+ private static void adviceUserToInstallLauncherComponent(final String errorMessage) {
+
+ MessageDialog dialog = new MessageDialog( Display.getCurrent().getActiveShell(),
+ IMemSpyTraceListener.ERROR_MEMSPY, null, errorMessage, MessageDialog.ERROR,
+ new String[]{ "Install RnD-signed MemSpy Launcher", "Open sis-file's directory in Explorer", "Don't install" }, 1);
+ dialog.open();
+
+ String launcherFolder = MemSpyPlugin.getDefault().getMemspyLauncherBinDir();
+ String launcherLocation = launcherFolder + File.separatorChar + MEM_SPY_LAUNCHER_S60_50_RN_D_SIGNED_SIS_FILE_NAME;
+
+ // if user wants to install launcher:
+ if( dialog.getReturnCode() == 0 ){
+ // find program for xls-filetype
+ Program p=Program.findProgram(".sis");
+ // if found, launch it.
+ if(p!=null){
+ // Check that found program was Nokia PC Suite.
+ p.execute( launcherLocation );
+ }
+ else{
+ Status status = new Status(IStatus.ERROR, MemSpyPlugin.PLUGIN_ID, 0,
+ "Unable to locate PC suite or other suitable software for installing .sis -file from computer. You can try installing MemSpy launcher manually from:\n"
+ + launcherLocation, null);
+ ErrorDialog.openError(Display.getCurrent().getActiveShell(),"MemSpy Error", null, status);
+ }
+
+ }
+
+ // Open directory in explorer
+ else if( dialog.getReturnCode() == 1 ){
+ try {
+ String directory = Platform.getConfigurationLocation().getURL().getFile();
+ directory = directory.substring(1);
+ Runtime.getRuntime().exec("explorer " + launcherFolder);
+ } catch (IOException e) {
+ Status status = new Status(IStatus.ERROR, MemSpyPlugin.PLUGIN_ID, 0, "Unable to open Explorer", null);
+ ErrorDialog.openError(Display.getCurrent().getActiveShell(),IMemSpyTraceListener.ERROR_MEMSPY, null, status);
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ /**
+ * Maps given launcher error to corresponding error message.
+ * @param error error enumerator
+ * @param clientContextString client context string for giving usage context info. Used only for possible console logging.
+ * @param progressStatus current progress status for giving extra information on the possible error condition.
+ * @return error message string
+ */
+ public static String getErrorMessageForLauncherError(LauncherErrorType error, String clientContextString, ProgressStatus progressStatus) {
+
+ String errorMessage;
+
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "getErrorMessageForLauncherError/progressStatus: " + progressStatus); //$NON-NLS-1$
+
+ switch (error){
+ case NO_ANSWER_FROM_DEVICE:{
+ errorMessage = getErrorDescriptionForNoAnswerFromDeviceError(progressStatus, clientContextString);
+ break;
+ }
+ case MEMSPY_NOT_RUNNING:{
+ errorMessage = IMemSpyTraceListener.ERROR_MEMSPY_NOT_RUNNING;
+ break;
+ }
+ case MEMSPY_NOT_FOUND:{
+ errorMessage = IMemSpyTraceListener.ERROR_MEMSPY_NOT_FOUND;
+ break;
+ }
+ case ACTIVATION:{
+ errorMessage = IMemSpyTraceListener.ERROR_ACTIVATION_NOT_SUCCESFUL;
+ break;
+ }
+ case FILE:{
+ errorMessage = IMemSpyTraceListener.ERROR_FILE_OPERATIONS_NOT_SUCCESSFUL;
+ break;
+ }
+ case TOO_OLD_MEMSPY_LAUNCHER_DATAVERSION:{
+ errorMessage = IMemSpyTraceListener.ERROR_TOO_OLD_MEMSPY_LAUNCHER_VERSION;
+ break;
+ }
+ case DUMPED_TRACES:{
+ errorMessage = IMemSpyTraceListener.ERROR_DUMPED_TRACES;
+ break;
+ }
+ case CATEGORIES_NOT_SUPPORTED:{
+ errorMessage = IMemSpyTraceListener.ERROR_CATEGORIES_NOT_SUPPORTED;
+ break;
+ }
+ case GENERAL_LAUNCHER_ERROR:{
+ errorMessage = IMemSpyTraceListener.ERROR_GENERAL_LAUNCHER_ERROR;
+ break;
+ }
+ // default handling in case new launcher error has been added but not handled appropriately
+ default:{
+ MemSpyConsole.getInstance().println(clientContextString + " error: '" //$NON-NLS-1$
+ + error.name() + "' occurrence." //$NON-NLS-1$
+ , MemSpyConsole.MSG_ERROR); //$NON-NLS-1$
+ errorMessage = IMemSpyTraceListener.ERROR_ACTIVATION_NOT_SUCCESFUL;
+ break;
+ }
+ }
+
+ return errorMessage;
+ }
+
+ /**
+ * Forms error description in no answer from device error situation.
+ * @param progressStatus progress status at the moment when error occurred.
+ * @param clientContextString Possibly more context-specific information
+ * @return
+ */
+ private static String getErrorDescriptionForNoAnswerFromDeviceError(ProgressStatus progressStatus, String clientContextString) {
+
+ // Default message start portion
+ String errorMessage = IMemSpyTraceListener.ERROR_NO_RESPONSE + " " + IMemSpyTraceListener.ERROR_POSSIBLE_REASONS;
+
+ switch (progressStatus) {
+
+ // Flow through on purpose 1
+ case EPROGRESS_MEMSPY_LAUNCHED: // MemSpy is launched but not yet actual task
+ case EPROGRESS_FIRST_TASK_DONE: // Trace data has been received successfully at least once
+ case EPROGRESS_FIRST_TASK_LAUNCHED: // MemSpy is launched and also 1st real task is done
+ // add USB error note.
+ errorMessage = errorMessage + IMemSpyTraceListener.ERROR_USB_TRACE_ENABLED;
+ // add check for connection information message
+ errorMessage = errorMessage + IMemSpyTraceListener.ERROR_CONNECTION_BROKEN;
+ break;
+
+ // Flow through on purpose 2
+ case EPROGRESS_INITIAL: // MemSpy has not been launched successfully, so no progress at all
+ default:
+ errorMessage = IMemSpyTraceListener.ERROR_NO_RESPONSE + " " + IMemSpyTraceListener.ERROR_POSSIBLE_REASONS;
+ // add USB error note.
+ errorMessage = errorMessage + IMemSpyTraceListener.ERROR_USB_TRACE_ENABLED;
+ // add install note for MemSpy Launcher
+ errorMessage = errorMessage + IMemSpyTraceListener.ERROR_INSTALL_MEMSPY_LAUNCHER;
+ break;
+ }
+
+ if(clientContextString.length() > 0){
+ MemSpyConsole.getInstance().println(IMemSpyTraceListener.ERROR_NO_RESPONSE
+ + IMemSpyTraceListener.ERROR_LAUNCHER_ERROR_DETAILS + clientContextString //$NON-NLS-1$
+ , MemSpyConsole.MSG_ERROR);
+ errorMessage = errorMessage + IMemSpyTraceListener.ERROR_SEE_CONSOLE_LOG;
+ }
+
+ return errorMessage;
+ }
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/actions/ToolbarShortcutAction.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/actions/ToolbarShortcutAction.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,84 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+package com.nokia.s60tools.memspy.ui.actions;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+
+import com.nokia.s60tools.memspy.ui.views.MemSpyMainView;
+import com.nokia.s60tools.memspy.ui.wizards.MemSpyWizard.MemSpyWizardType;
+import com.nokia.s60tools.util.debug.DbgUtility;
+
+
+
+
+
+/**
+ * Action for toolbar and import shortcuts that launch MemSpy
+ * @see IWorkbenchWindowActionDelegate
+ */
+public class ToolbarShortcutAction implements IWorkbenchWindowActionDelegate {
+
+ /**
+ * The action has been activated. The argument of the
+ * method represents the 'real' action sitting
+ * in the workbench UI.
+ * @see IWorkbenchWindowActionDelegate#run
+ */
+ public void run(IAction action) {
+ // Open MemSpy's Main View
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "Show main view");
+ MemSpyMainView mainView = MemSpyMainView.showAndReturnYourself();
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "Run wizard");
+ mainView.runWizard( MemSpyWizardType.FULL, null );
+
+ }
+
+ /**
+ * Selection in the workbench has been changed. We
+ * can change the state of the 'real' action here
+ * if we want, but this can only happen after
+ * the delegate has been created.
+ * @see IWorkbenchWindowActionDelegate#selectionChanged
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ // Not needed
+ }
+
+ /**
+ * We can use this method to dispose of any system
+ * resources we previously allocated.
+ * @see IWorkbenchWindowActionDelegate#dispose
+ */
+ public void dispose() {
+ // Not needed
+ }
+
+ /**
+ * We will cache window object in order to
+ * be able to provide parent shell for the message dialog.
+ * @see IWorkbenchWindowActionDelegate#init
+ */
+ public void init(IWorkbenchWindow window) {
+ // Not needed
+ }
+}
\ No newline at end of file
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/dialogs/SWMTCategoriesDialog.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/dialogs/SWMTCategoriesDialog.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,679 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+package com.nokia.s60tools.memspy.ui.dialogs;
+
+import java.util.ArrayList;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+
+import com.nokia.s60tools.memspy.model.SWMTCategoryConstants;
+import com.nokia.s60tools.memspy.model.SWMTCategorys;
+import com.nokia.s60tools.memspy.preferences.MemSpyPreferences;
+import com.nokia.s60tools.memspy.resources.HelpContextIDs;
+import com.nokia.s60tools.memspy.resources.ImageKeys;
+import com.nokia.s60tools.memspy.resources.ImageResourceManager;
+import com.nokia.s60tools.memspy.util.MemSpyConsole;
+import com.nokia.s60tools.ui.S60ToolsTable;
+import com.nokia.s60tools.ui.S60ToolsTableColumnData;
+import com.nokia.s60tools.ui.S60ToolsTableFactory;
+import com.nokia.s60tools.ui.S60ToolsUIConstants;
+
+
+
+/**
+ * Dialog for selecting SWMT categories to be tracked.
+ */
+public class SWMTCategoriesDialog extends TitleAreaDialog{
+
+
+
+ //
+ // Private classes
+ //
+
+ private static final String HEAP_DATA_THREAD_FILTER_TXT = "Heap Data Thread Filter";
+
+ /**
+ * Label provider for table viewer component.
+ */
+ class SWMTCategoryViewerLabelProvider extends LabelProvider implements ITableLabelProvider{
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
+ */
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null; // No images used
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
+ */
+ public String getColumnText(Object element, int columnIndex) {
+ String label = element.toString();
+
+ SWMTCategoryEntry entryData = (SWMTCategoryEntry) element;
+
+ switch (columnIndex) {
+
+ case SWMTCategoryEntry.NAME_COLUMN_INDEX:
+ label = entryData.getCategoryName();
+ break;
+
+ default:
+ MemSpyConsole.getInstance().println("Unexpected column index: " + columnIndex, MemSpyConsole.MSG_ERROR); //$NON-NLS-1$ //$NON-NLS-2$
+ break;
+ }
+
+ return label;
+ }
+
+ }
+
+ //
+ // Private constants
+ //
+
+ /**
+ * Columns in the container area.
+ */
+ private static final int COLUMN_COUNT = 1;
+
+ /**
+ * Dialog width.
+ */
+ private static final int DIALOG_WIDTH = 425;
+
+ /**
+ * Dialog height.
+ */
+ private static final int DIALOG_HEIGHT = 550;
+
+ /**
+ * Percentage as decimal number how much table viewer is taking space horizontally.
+ */
+ private static final double TABLE_VIEWER_WIDTH_PERCENTAGE = 0.8;
+
+ /**
+ * Default guiding message shown to the user in add new mode.
+ */
+ private static final String DEFAULT_MESSAGE = "Set advanced options and tracked SWMT categories.";
+
+ /**
+ * Complete message shown to the user in add new mode.
+ */
+ private static final String COMPLETE_MESSAGE = "Press OK to save advanced options and set categories to be tracked";
+
+ /**
+ * Error message shown to the user in case no categories are selected.
+ */
+ private static final String ERROR_MESSAGE = "At least single category must be selected";
+
+ /**
+ * UI text for closing Symbian agent
+ */
+ private static final String CLOSE_MEM_SPY_BETWEEN_CYCLES_TEXT = "Close MemSpy Symbian Agent Between Cycles";
+
+ /**
+ * Tip text for closing Symbian agent
+ */
+ private static final String CLOSE_MEM_SPY_BETWEEN_CYCLES_TIP_TEXT = "Choose if the MemSpy Symbian agent in S60 target is closed between cycles. That is more realistic use case for memory usage point of view.";
+
+
+ //
+ // Member data
+ //
+
+ /**
+ * Flag used to make sure that create() and open() are called in correct order.
+ */
+ private boolean isCreateCalled = false;
+
+
+ //
+ // UI Controls
+ //
+
+ /**
+ * Container area for individual fields for the user for entering information.
+ */
+ private Composite container;
+
+ /**
+ * Reference to OK button that can be disabled/enabled
+ * due to current category selection-
+ */
+ private Button okActionBtn;
+
+ /**
+ * Viewer showing currently selected category file entries.
+ */
+ private CheckboxTableViewer categoryViewer;
+
+ /**
+ * Selected categories as a result of bitwise OR.
+ */
+ private int categorySelection = SWMTCategoryConstants.CATEGORY_ALL;
+
+ //User Heap filter text field
+ private Text heapText;
+
+ private Button closeBetweenCyclesButton;
+
+ private Button heapDumpBtn;
+
+ /**
+ * Constructor. Used to open dialog in order to add new entry.
+ * @param parentShell Parent shell for the dialog.
+ * @param categorySelection integer containing initially selected categories as a result of bitwise OR.
+ */
+ public SWMTCategoriesDialog(Shell parentShell, int categorySelection) {
+ super(parentShell);
+ this.categorySelection = categorySelection;
+ // Setting banner image
+ String bannerImage = ImageKeys.IMG_WIZARD;
+ setTitleImage(ImageResourceManager.getImage(bannerImage));
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+ */
+ protected void createButtonsForButtonBar(Composite parent) {
+ createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,
+ true);
+ createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL,
+ true);
+ okActionBtn = getButton(IDialogConstants.OK_ID);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ shell.setText("SWMT Categories and Advanced Options");
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createDialogArea(Composite parent) {
+
+ Composite dialogAreaComposite = (Composite) super.createDialogArea(parent);
+
+ //
+ // Creating container and layout for it
+ //
+ container = new Composite(dialogAreaComposite, SWT.NONE);
+ GridLayout gdl = new GridLayout(COLUMN_COUNT, false);
+ // Settings margins according Carbide branding guideline
+ gdl.marginLeft = S60ToolsUIConstants.MARGIN_BTW_FRAME_AND_CONTENTS;
+ gdl.marginRight = S60ToolsUIConstants.MARGIN_BTW_FRAME_AND_CONTENTS;
+ gdl.marginTop = S60ToolsUIConstants.MARGIN_BTW_FRAME_AND_CONTENTS;
+ gdl.marginBottom = S60ToolsUIConstants.MARGIN_BTW_FRAME_AND_CONTENTS;
+ container.setLayout(gdl);
+ container.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ //
+ // Symbian agent options group
+ //
+
+ createSymbianAgentOptionsGroup();
+
+ //
+ // Head dump group
+ //
+ createHeapDumpGroup();
+
+
+ //
+ // Creating table viewer for showing category file entries
+ //
+
+ categoryViewer = createCategoryCheckBoxTableViewer(container);
+ GridData categoryViewerGd = new GridData(GridData.FILL_BOTH);
+ // Spanning as many rows as there are actions buttons on the right
+ categoryViewerGd.verticalSpan = 3;
+ categoryViewerGd.widthHint = (int) (TABLE_VIEWER_WIDTH_PERCENTAGE * DIALOG_WIDTH);
+ categoryViewer.getControl().setLayoutData(categoryViewerGd);
+ categoryViewer.setSorter(new SWMTCategoryEntryTableViewerSorter());
+ // Adding selection change listener
+ categoryViewer.addSelectionChangedListener(new ISelectionChangedListener(){
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
+ */
+ public void selectionChanged(SelectionChangedEvent event) {
+ notifySelectionChanged();
+ }
+
+ });
+
+ //
+ // Setting providers for table viewer
+ //
+
+ // Creating content provider
+ GategoryProvider categoryViewerContentProvider = new GategoryProvider();
+ // Setting content provider
+ categoryViewer.setContentProvider(categoryViewerContentProvider);
+ categoryViewer.setInput(categoryViewerContentProvider);
+
+ // Label provider
+ categoryViewer.setLabelProvider(new SWMTCategoryViewerLabelProvider());
+
+ // Setting initial category selection state
+ InitializeSelectionState();
+
+ // Setting context-sensitive help ID
+ PlatformUI.getWorkbench().getHelpSystem().setHelp( dialogAreaComposite, HelpContextIDs.MEMSPY_IMPORT_SWMT_CATEGORIES_DIALOG);
+
+ // Dialog are composite ready
+ return dialogAreaComposite;
+ }
+
+
+ /**
+ * Private class to provide content for category viewer
+ */
+ class GategoryProvider implements IStructuredContentProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ public Object[] getElements(Object inputElement) {
+ return SWMTCategorys.getInstance().getCategoryEntries().toArray();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ public void dispose() {
+ // Not needed but needs to be implemented
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput,
+ Object newInput) {
+ // Not used but needs to be implemented
+ }
+
+ };
+
+ /**
+ * Creates group for Symbian agent options
+ */
+ private void createSymbianAgentOptionsGroup() {
+ Group closeSymbianGroup = new Group(container, SWT.SHADOW_NONE);
+ closeSymbianGroup.setText("Symbian Agent Options");
+ GridLayout closegl = new GridLayout(2, false);
+ GridData closegd = new GridData(GridData.FILL_BOTH);
+ closeSymbianGroup.setLayout(closegl);
+ closeSymbianGroup.setLayoutData(closegd);
+
+ closeBetweenCyclesButton = new Button(closeSymbianGroup, SWT.CHECK);
+ GridData closeLayoutData = new GridData(GridData.VERTICAL_ALIGN_END);
+ closeBetweenCyclesButton.setLayoutData( closeLayoutData);
+ closeBetweenCyclesButton.setToolTipText(CLOSE_MEM_SPY_BETWEEN_CYCLES_TIP_TEXT);
+ boolean isToBeClosedBetweenCycles = MemSpyPreferences.isCloseSymbianAgentBetweenCyclesSelected();
+ closeBetweenCyclesButton.setSelection(isToBeClosedBetweenCycles);
+
+ //Label for button, separate label is used because setting text to button wont align text to same vertical
+ //position than next label.
+ Label closeBetweenIntervalsLabel = new Label(closeSymbianGroup, SWT.LEFT );
+ GridData closeBetweenLabelData = new GridData(GridData.VERTICAL_ALIGN_CENTER);
+ closeBetweenIntervalsLabel.setText( CLOSE_MEM_SPY_BETWEEN_CYCLES_TEXT );
+ closeBetweenIntervalsLabel.setLayoutData(closeBetweenLabelData);
+
+ }
+
+
+ /**
+ * Creates group for Head Dumps
+ */
+ private void createHeapDumpGroup() {
+ //
+ // Head dump group
+ //
+ Group headDumpGroup = new Group(container, SWT.SHADOW_NONE);
+ headDumpGroup.setText("Heap Dumps During SWMT Logging");
+ GridLayout hdgl = new GridLayout(2, false);
+ GridData hdgd = new GridData(GridData.FILL_BOTH);
+ headDumpGroup.setLayout(hdgl);
+ headDumpGroup.setLayoutData(hdgd);
+
+ heapDumpBtn = new Button(headDumpGroup, SWT.CHECK);
+ heapDumpBtn.setText("Get Heap Dumps for Threads to Analyse with Heap Analyser");
+ heapDumpBtn.setToolTipText("Set if Heap Dumps is to be received for Threads during SWMT logging");
+ heapDumpBtn.addSelectionListener(new HeadDumpSelectionListener());
+ heapDumpBtn.setSelection(MemSpyPreferences.isSWMTHeapDumpSelected());
+ GridData hdBtnGd = new GridData();
+ hdBtnGd.horizontalSpan = 2;
+ heapDumpBtn.setLayoutData(hdBtnGd);
+
+ //Label for Heap gategory limit
+ Label heapTextLabel = new Label(headDumpGroup, SWT.LEFT );
+ heapTextLabel.setText(HEAP_DATA_THREAD_FILTER_TXT + ":");
+ String heapFilterToolTipText = "When filter string is specified, only Threads that contain text specified will be tracked.";
+ heapTextLabel.setToolTipText(heapFilterToolTipText);
+ GridData heapTextLimitLayoutData = new GridData(GridData.VERTICAL_ALIGN_CENTER);
+ heapTextLabel.setLayoutData( heapTextLimitLayoutData );
+
+ //heap limit text
+ heapText = new Text(headDumpGroup, SWT.LEFT | SWT.BORDER | SWT.BORDER);
+ heapText.setTextLimit(120);//Text limit 128 specified in S60 side
+ GridData heapTextLayoutData = new GridData(GridData.VERTICAL_ALIGN_CENTER);
+ heapTextLayoutData.widthHint = 140;
+ heapText.setLayoutData( heapTextLayoutData );
+ heapText.setToolTipText(heapFilterToolTipText);
+ if(heapDumpBtn.getSelection()){
+ heapText.setText(MemSpyPreferences.getSWMTHeapNameFilter());
+ }else{
+ heapText.setEnabled(false);
+ }
+ }
+
+ /**
+ * Listener for Heap Dumps button, updates preferences and text in Heap Dumps group.
+ */
+ private class HeadDumpSelectionListener implements SelectionListener{
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // not needed
+
+ }
+
+ /*
+ * Change heapText and save preferences
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetSelected(SelectionEvent e) {
+ boolean selection = heapDumpBtn.getSelection();
+ if(selection){
+ heapText.setEnabled(true);
+ heapText.setText(MemSpyPreferences.getSWMTHeapNameFilter());
+ }else{
+ heapText.setText("");
+ heapText.setEnabled(false);
+ }
+ }
+
+
+ }
+
+ /**
+ * Save the heap filter text if enabled
+ */
+ private void saveHeapFilterText() {
+ //Check if heaptext is enabled, if it is, saving text to preferences
+ if(heapText.isEnabled()){
+ String heapFilterText = heapText.getText().trim();
+ MemSpyPreferences.setSWMTHeapNameFilter(heapFilterText);
+ }
+ }
+ /**
+ * Save the Close between cycles selection
+ */
+ private void saveCloseS60AgentBetweenCycles() {
+ boolean selection = closeBetweenCyclesButton.getSelection();
+ // User selects to close MemSpy S60 application between cycles
+ MemSpyPreferences.setCloseSymbianAgentBetweenCycles(selection);
+ }
+ /**
+ * Save the heap dump selection
+ */
+ private void saveHeapDumpSelection() {
+ boolean selection = heapDumpBtn.getSelection();
+ MemSpyPreferences.setSWMTHeapDumpSelected(selection);
+ }
+
+
+
+ /**
+ * Sets initial selection state for entries
+ */
+ private void InitializeSelectionState() {
+ int size = SWMTCategorys.getInstance().getCategoryEntries().size();
+ for (int i = 0; i < size; i++) {
+ SWMTCategoryEntry entry = (SWMTCategoryEntry) categoryViewer.getElementAt(i);
+ int isCategoryBitUp = categorySelection & entry.getCategoryId();
+ if(isCategoryBitUp != 0){
+ categoryViewer.setChecked(entry, true);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.TitleAreaDialog#getInitialSize()
+ */
+ protected Point getInitialSize() {
+ return new Point(DIALOG_WIDTH, DIALOG_HEIGHT);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#create()
+ */
+ public void create() {
+ super.create();
+ // Currently just does creation by super call and stores status
+ isCreateCalled = true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ protected void okPressed() {
+
+ if(heapDumpBtn.getSelection()){
+ if(heapText.getText().trim().equals("")){
+ System.out.println("DEBUG: WARNING! Empty heap filter text!");
+ MessageBox box = new MessageBox(getShell(),SWT.ICON_WARNING | SWT.YES | SWT.NO);
+ String warningMsg = "Empty \"" +HEAP_DATA_THREAD_FILTER_TXT
+ + "\" field causes huge amount of data to be traced and tracing may take a very long time. "
+ +"It is highly recommended to use \"" +HEAP_DATA_THREAD_FILTER_TXT
+ + "\"."
+ +"\n\nDo you want to continue anyway?";
+ box.setMessage(warningMsg);
+ box.setText("Using \"" +HEAP_DATA_THREAD_FILTER_TXT
+ + "\" is recommended");
+ int yes_no = box.open();
+ //If user does not want to continue but cancel, returning, otherwise just continue to save all data and exit
+ if(yes_no == SWT.NO){
+ return;
+ }
+
+ }
+ }
+
+ saveHeapFilterText();
+ saveCloseS60AgentBetweenCycles();
+ saveHeapDumpSelection();
+ super.close();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.window.Window#open()
+ */
+ public int open(){
+ try {
+ // Making sure that create is called
+ if(!isCreateCalled){
+ create();
+ }
+ showDefaultMessage();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return super.open();
+ }
+
+ /**
+ * Resets possible error messages and show the default message.
+ */
+ private void showDefaultMessage() {
+ setErrorMessage(null);
+ setMessage(DEFAULT_MESSAGE, IMessageProvider.INFORMATION);
+ }
+
+ /**
+ * Informs user that parameters are valid and dialog can be
+ * dismissed with OK button..
+ */
+ private void setCompleteOkMessage() {
+ setErrorMessage(null);
+ setMessage(COMPLETE_MESSAGE, IMessageProvider.INFORMATION);
+ }
+
+ /**
+ * Shows error message in case no categories are selected.
+ */
+ private void showErrorMessage() {
+ setErrorMessage(ERROR_MESSAGE);
+ setMessage(null);
+ }
+
+ /**
+ * Disables OK button.
+ * This method is guarded against call during construction
+ * when button row has not been created yet and widget is null
.
+ */
+ private void disableOk() {
+ if(okActionBtn != null){
+ okActionBtn.setEnabled(false);
+ }
+ }
+
+ /**
+ * Enables OK button.
+ * This method is guarded against call during construction
+ * when button row has not been created yet and widget is null
.
+ */
+ private void enableOk() {
+ if(okActionBtn != null){
+ okActionBtn.setEnabled(true);
+ }
+ }
+
+ /**
+ * Updates buttons statuses according the current selection
+ * status of table entry viewer contents and refreshes contents.
+ */
+ private void notifySelectionChanged() {
+ Object[] selectedCategoryEntries = getSelectedCategoryEntries();
+ if(selectedCategoryEntries.length > 0){
+ updateSelectedCategories(selectedCategoryEntries);
+ enableOk();
+ setCompleteOkMessage();
+ }
+ else{
+ disableOk();
+ showErrorMessage();
+ }
+ categoryViewer.refresh();
+ }
+
+ /**
+ * Creates checkbox viewer component for showing available SWMT categories.
+ * @param parent Parent composite for the created composite.
+ * @return New CheckboxTableViewer
object instance.
+ */
+ protected CheckboxTableViewer createCategoryCheckBoxTableViewer(Composite parent) {
+
+ ArrayList columnDataArr = new ArrayList();
+
+ //
+ // NOTE: Column indices must start from zero (0) and
+ // the columns must be added in ascending numeric
+ // order.
+ //
+ columnDataArr.add(new S60ToolsTableColumnData("Category", //$NON-NLS-1$
+ 350,
+ SWMTCategoryEntry.NAME_COLUMN_INDEX,
+ SWMTCategoryEntryTableViewerSorter.CRITERIA_NAME));
+
+ S60ToolsTableColumnData[] arr
+ = columnDataArr.toArray(
+ new S60ToolsTableColumnData[0]);
+
+ S60ToolsTable tbl = S60ToolsTableFactory.createCheckboxTable(parent, arr);
+
+ CheckboxTableViewer tblViewer = new CheckboxTableViewer(tbl.getTableInstance());
+ tbl.setHostingViewer(tblViewer);
+
+ return tblViewer;
+ }
+
+ /**
+ * Returns currently selected categories.
+ * @return currently selected categories
+ */
+ private Object[] getSelectedCategoryEntries() {
+ return categoryViewer.getCheckedElements();
+ }
+
+ /**
+ * Stores currently selected categories combined with bitwise as a single integer.
+ * @param selectedCategoryEntries array of selected category entries
+ */
+ private void updateSelectedCategories(Object[] selectedCategoryEntries) {
+ // Re-initializing category selection
+ categorySelection = SWMTCategoryConstants.CATEGORY_NONE;
+ for (int i = 0; i < selectedCategoryEntries.length; i++) {
+ SWMTCategoryEntry categoryEntry = (SWMTCategoryEntry) selectedCategoryEntries[i];
+ categorySelection = categorySelection | categoryEntry.getCategoryId();
+ }
+ }
+
+ /**
+ * Returns currently selected categories combined with bitwise as a single integer.
+ * @return currently selected categories combined with bitwise as a single integer.
+ */
+ public int getSelectedCategories() {
+ return categorySelection;
+ }
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/dialogs/SWMTCategoryEntry.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/dialogs/SWMTCategoryEntry.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,70 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+package com.nokia.s60tools.memspy.ui.dialogs;
+
+import com.nokia.s60tools.memspy.model.SWMTCategoryConstants;
+
+
+/**
+ * Stores information on a single SIS file entry.
+ */
+public class SWMTCategoryEntry {
+
+ //
+ // Column sorting indices for table column sorter
+ //
+ public static final int NAME_COLUMN_INDEX = 0;
+
+ /**
+ * Category id listed in SWMT category constants
+ * @see SWMTCategoryConstants
+ */
+ private final int categoryId;
+
+ /**
+ * Name of the SWMT category.
+ */
+ private final String categoryName;
+
+ /**
+ * Constructor.
+ * @param categoryId path name of the directory SIS file is locating.
+ * @param categoryName name of the SIS file without path.
+ */
+ public SWMTCategoryEntry(int categoryId, String categoryName){
+ this.categoryId = categoryId;
+ this.categoryName = categoryName;
+ }
+
+ /**
+ * Gets path name of the directory SIS file is locating.
+ * @return path name of the directory SIS file is locating.
+ */
+ public int getCategoryId() {
+ return categoryId;
+ }
+
+ /**
+ * Gets name SWMT category.
+ * @return name SWMT category entry
+ */
+ public String getCategoryName() {
+ return categoryName;
+ }
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/dialogs/SWMTCategoryEntryTableViewerSorter.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/dialogs/SWMTCategoryEntryTableViewerSorter.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+package com.nokia.s60tools.memspy.ui.dialogs;
+
+import org.eclipse.jface.viewers.Viewer;
+
+import com.nokia.s60tools.memspy.util.MemSpyConsole;
+import com.nokia.s60tools.ui.S60ToolsViewerSorter;
+
+/**
+ * Sorter implementation for SWMT category entry data.
+ */
+public class SWMTCategoryEntryTableViewerSorter extends S60ToolsViewerSorter {
+
+ //
+ // Sorting criteria constants
+ //
+ public static final int CRITERIA_NAME = 1;
+
+ /**
+ * Constructor
+ */
+ public SWMTCategoryEntryTableViewerSorter() {
+ super();
+ // By default we are not sorting the information
+ setSortCriteria(CRITERIA_NO_SORT);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerSorter#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ public int compare(Viewer viewer, Object e1, Object e2) {
+
+ // By default comparison does not do any ordering
+ int compRes = 0;
+
+ SWMTCategoryEntry entry1 = (SWMTCategoryEntry) e1;
+ SWMTCategoryEntry entry2 = (SWMTCategoryEntry) e2;
+
+ switch (sortCriteria) {
+
+ case CRITERIA_NAME:
+ compRes = alphabeticSort(entry1.getCategoryName(), entry2.getCategoryName());
+ break;
+
+ case CRITERIA_NO_SORT:
+ // No sorting criteria defined.
+ break;
+
+ default:
+ MemSpyConsole.getInstance()
+ .println(
+ "Unexpected sort criteria for a catecory entriey encountered: " + sortCriteria, //$NON-NLS-1$
+ MemSpyConsole.MSG_ERROR);
+ break;
+ }
+
+ return compRes;
+ }
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/views/MemSpyDataSorter.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/views/MemSpyDataSorter.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,101 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+package com.nokia.s60tools.memspy.ui.views;
+
+import org.eclipse.jface.viewers.Viewer;
+
+import com.nokia.s60tools.memspy.model.MemSpyFileBundle;
+import com.nokia.s60tools.ui.S60ToolsViewerSorter;
+
+/**
+ * class MemSpyDataSorter
+ * Data sorter for MemSpy's main view.
+ */
+
+public class MemSpyDataSorter extends S60ToolsViewerSorter {
+
+ /**
+ * Import function data is sorted by file type
+ */
+ public static final int FILE_TYPE = 1;
+ /**
+ * Import function data is sorted by file name
+ */
+ public static final int FILENAME = 2;
+
+ /**
+ * Import function data is sorted by time
+ */
+ public static final int TIME = 3;
+
+ /**
+ * Constructor
+ */
+ public MemSpyDataSorter() {
+ super();
+ // By default set sorting to time
+ setSortCriteria(TIME);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerSorter#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ public int compare(Viewer viewer, Object e1, Object e2) {
+
+
+ // By default comparison does not do any ordering
+ int comparisonResult = 0;
+
+ MemSpyFileBundle f1 = (MemSpyFileBundle) e1;
+ MemSpyFileBundle f2 = (MemSpyFileBundle) e2;
+
+ switch (sortCriteria) {
+
+ case FILE_TYPE:
+ comparisonResult = f1.getFileType().compareToIgnoreCase( f2.getFileType() );
+ // when type is same, sort alphabetically
+ if( comparisonResult == 0 ){
+ comparisonResult = numericSort( f2.getTimeAsLong(), f1.getTimeAsLong() );
+ }
+ break;
+ case FILENAME:
+ comparisonResult = f1.getFileName().compareToIgnoreCase( f2.getFileName() );
+ break;
+ case TIME:
+ comparisonResult = numericSort( f2.getTimeAsLong(), f1.getTimeAsLong() );
+ if( comparisonResult == 0 ){
+ comparisonResult = numericSort( f2.getCycleNumberFromFileName(), f1.getCycleNumberFromFileName() );
+ }
+
+ break;
+ case CRITERIA_NO_SORT:
+ comparisonResult = f2.getFileType().compareToIgnoreCase( f1.getFileType() );
+ // when type is same, sort by file time
+ if( comparisonResult == 0 ){
+ comparisonResult = numericSort( f2.getTimeAsLong(), f1.getTimeAsLong() );
+ }
+ break;
+ default:
+ break;
+ }
+
+ return comparisonResult;
+ }
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/views/MemSpyMainView.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/views/MemSpyMainView.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,1329 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+package com.nokia.s60tools.memspy.ui.views;
+
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.program.Program;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IViewReference;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.part.ViewPart;
+
+import com.nokia.s60tools.heapanalyser.interfaces.HeapAnalyserLauncher;
+import com.nokia.s60tools.memspy.interfaces.IAnalyseHeapJobListener;
+import com.nokia.s60tools.memspy.interfaces.INewMemSpyFilesObserver;
+import com.nokia.s60tools.memspy.model.AnalyseHeapJob;
+import com.nokia.s60tools.memspy.model.AnalyserXMLGenerator;
+import com.nokia.s60tools.memspy.model.AnalyserXMLParser;
+import com.nokia.s60tools.memspy.model.ImportEngine;
+import com.nokia.s60tools.memspy.model.MemSpyFileBundle;
+import com.nokia.s60tools.memspy.model.MemSpyFileOperations;
+import com.nokia.s60tools.memspy.model.UserEnteredData;
+import com.nokia.s60tools.memspy.model.UserEnteredData.ValueTypes;
+import com.nokia.s60tools.memspy.plugin.MemSpyPlugin;
+import com.nokia.s60tools.memspy.resources.HelpContextIDs;
+import com.nokia.s60tools.memspy.resources.ImageKeys;
+import com.nokia.s60tools.memspy.resources.ImageResourceManager;
+import com.nokia.s60tools.memspy.ui.wizards.MemSpyWizard;
+import com.nokia.s60tools.memspy.ui.wizards.MemSpyWizardDialog;
+import com.nokia.s60tools.memspy.ui.wizards.MemSpyWizard.MemSpyWizardType;
+import com.nokia.s60tools.memspy.util.MemSpyConsole;
+import com.nokia.s60tools.swmtanalyser.ui.actions.SwmtAnalyser;
+import com.nokia.s60tools.ui.S60ToolsTable;
+import com.nokia.s60tools.ui.S60ToolsTableColumnData;
+import com.nokia.s60tools.ui.S60ToolsTableFactory;
+import com.nokia.s60tools.ui.S60ToolsViewerSorter;
+import com.nokia.s60tools.util.debug.DbgUtility;
+
+
+
+/**
+ *
+ * MemSpyMainView.
+ * The main view of MemSpy Carbide extension. Shows imported MemSpy data files in a table and allows user to:
+ * - Launch Heap Analyser to analyse one Heap Dump file.
+ * - Launch Heap Analyser to compare two Heap Dump files.
+ * - Launch SWMT-analyser and analyse one System Wide Memory Tracking log.
+ *
+ */
+
+public class MemSpyMainView extends ViewPart implements INewMemSpyFilesObserver, SelectionListener, IAnalyseHeapJobListener, KeyListener {
+
+
+ /**
+ * Enumeration for actions for a MemSpy file
+ */
+ private enum FileActionType{NONE, ANALYSE_SWMT_ONE, ANALYSE_SWMT_MULTIPLE, ANALYSE_HEAP, COMPARE_HEAPS, DELETE};
+
+ /**
+ * TraceViewers ID com.nokia.traceviewer.view.TraceViewerView
+ */
+ private static final String TRACE_VIEWER_VIEW_ID = "com.nokia.traceviewer.view.TraceViewerView";
+
+ /**
+ * Main view's ID com.nokia.s60tools.memspy.ui.views.MemSpyMainView
+ */
+ private static final String ID = "com.nokia.s60tools.memspy.ui.views.MemSpyMainView";
+
+ /* viewer for table */
+ private TableViewer viewer;
+
+ /* contentProvider for table */
+ private MemSpyMainViewContentProvider contentProvider;
+
+ /* Launch Heap Analyser - action */
+ private Action launchHeapAnalyserAction;
+
+ /* Launch Wizard - action */
+ private Action launchWizardAction;
+
+ /* compare two heaps - action */
+ private Action compareTwoHeapsAction;
+
+ /* import and compare two heaps - action */
+ private Action importAndCompareHeapsAction;
+
+ /* import and compare two heaps - toolbar action
+ that changes based on selection*/
+ private Action compareHeapsToolbarAction;
+
+ /* Launch SWMT-analyser - action */
+ private Action launchSWMTAction;
+
+ /* delete selected files - action */
+ private Action deleteAction;
+
+ /* import engine */
+ private ImportEngine importEngine;
+
+ /* doubleClick - action */
+ private Action doubleClickAction;
+
+ /* open file in text editor */
+ private Action openFile;
+
+ /* edit symbol information */
+ private Action editSymbols;
+
+
+ //
+ //Strings for error and info messages
+ //
+
+ /**
+ * Error message for analysis startup
+ */
+ public final static String ERROR_LAUNCH_SWMT_ANALYSER = "MemSpy was unable to start analysing imported files.";
+ /**
+ * Error message for Heap Dump import
+ */
+ public final static String ERROR_HEAP_IMPORT_FAILED = "Some of the Heap Dumps were not imported successfully.( file operations were not successfull )";
+ /**
+ * Error message for SWMT import
+ */
+ public final static String ERROR_SWMT_IMPORT_FAILED = "SWMT-files were not imported successfully. ( file operations were not successfull )";
+ /**
+ * Error message for import
+ */
+ public final static String ERROR_IMPORT_HEADER = "Import error";
+ /**
+ * Warning message for compare
+ */
+ public final static String WARNING_COMPARE = "Compare Warning";
+ /**
+ * Warning message for filea allready exist
+ */
+ public final static String WARNING_FILE_EXISTS = "The file already exists. Do you want to replace the existing file?";
+
+ private final static String ERROR_COMPARE = "Compare error";
+ private final static String ERROR_HEAP_THREADS_NOT_SAME = "Selected Heaps cannot be compared. Only two Heap Dumps that are from same thread can be compared.";
+ private final static String ERROR_TOPIC = "MemSpy Error";
+ private final static String ERROR_CONFIGURATION_FILES_NOT_FOUND = "Configuration files for selected heaps cannot be found.";
+ private final static String ERROR_UNABLE_TO_GENERATE_CONFIGURATIONS = "Error was encountered when generating files that are needed when running Heap Analyser.";
+ private final static String ERROR_HEAP_ANALYSER = "Heap Analyser error.";
+ private final static String WARNING_SYMBOLS_NOT_SAME = "Selected files symbol definitions differ, do you wish to compare heaps anyway?";
+ private final static String FILE_DIALOG_DEFINE_OUTPUT = "Define output file name";
+ private final static String CONFIRMATION = "Confirmation";
+ private final static String CONFIRMATION_OPEN_FILE = "Open generated xls-file with application that is assosiated for that file type?";
+
+ private final static String TOOLTIP_COMPARE_2_IMPORTED_FILE = "Compare selected heaps with Heap Analyser";
+ private final static String TOOLTIP_TEXT_IMPORT_AND_COMPARE = "Import heap dump and compare it to selected heap";
+
+
+ /**
+ * The constructor.
+ */
+ public MemSpyMainView() {
+ importEngine = new ImportEngine( this );
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createPartControl(Composite parent) {
+
+
+ ArrayList columnDataArr = new ArrayList();
+
+ columnDataArr.add(new S60ToolsTableColumnData("File Type", 150, 0, MemSpyDataSorter.FILE_TYPE));
+ columnDataArr.add(new S60ToolsTableColumnData("File Name", 300, 1, MemSpyDataSorter.FILENAME));
+ columnDataArr.add(new S60ToolsTableColumnData("Time", 150, 2, MemSpyDataSorter.TIME));
+
+
+ S60ToolsTableColumnData[] arr = columnDataArr.toArray(new S60ToolsTableColumnData[0]);
+
+ S60ToolsTable tbl = S60ToolsTableFactory.create(parent, arr);
+
+ viewer = new TableViewer( tbl.getTableInstance() );
+ contentProvider = new MemSpyMainViewContentProvider( this );
+ viewer.setContentProvider( contentProvider );
+ viewer.setLabelProvider(new MemSpyMainViewLabelProvider());
+ viewer.setComparator(new MemSpyDataSorter());
+ viewer.setSorter(new MemSpyDataSorter());
+ viewer.setInput(getViewSite());
+
+ tbl.addSelectionListener(this);
+ tbl.addKeyListener(this);
+ tbl.setHostingViewer(viewer);
+
+ try {
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(),HelpContextIDs.MEMSPY_MAIN_VIEW);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ // Make actions
+ makeActions();
+
+ // hook context menus
+ hookContextMenu();
+
+ // hook double click action
+ hookDoubleClickAction();
+
+ // contribute to action bars
+ contributeToActionBars();
+
+ // refresh view
+ this.refreshView();
+
+ // update toolbar items state
+ this.enableAndDisableToolbarItems();
+
+
+
+ }
+
+ /**
+ * hookContextMenu.
+ * Creates context menu.
+ */
+ private void hookContextMenu() {
+ MenuManager menuMgr = new MenuManager("#PopupMenu");
+
+ // Adding all actions to menu.
+ menuMgr.add(launchHeapAnalyserAction);
+ menuMgr.add(compareTwoHeapsAction);
+ menuMgr.add(importAndCompareHeapsAction);
+ menuMgr.add(launchSWMTAction);
+ menuMgr.add(editSymbols);
+ menuMgr.add(openFile);
+ menuMgr.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ menuMgr.add(deleteAction);
+
+ menuMgr.addMenuListener(new IMenuListener() {
+ public void menuAboutToShow(IMenuManager manager) {
+ MemSpyMainView.this.fillContextMenu(manager);
+ }
+ });
+ Menu menu = menuMgr.createContextMenu(viewer.getControl());
+ viewer.getControl().setMenu(menu);
+ getSite().registerContextMenu(menuMgr, viewer);
+ }
+
+ /**
+ * contributeToActionBars.
+ * fills pull down menu and local toolbar
+ */
+ private void contributeToActionBars() {
+ IActionBars bars = getViewSite().getActionBars();
+ fillLocalToolBar(bars.getToolBarManager());
+ }
+
+
+ /**
+ * fillContextMenu.
+ * fills context menu depending what type of file or files are selected.
+ * @param manager menuManager
+ */
+ private void fillContextMenu(IMenuManager manager) {
+
+ FileActionType availableAction = this.getAvailableAction();
+
+ if( availableAction == FileActionType.ANALYSE_HEAP ){
+ launchHeapAnalyserAction.setEnabled(true);
+ compareTwoHeapsAction.setEnabled(false);
+ importAndCompareHeapsAction.setEnabled(true);
+ launchSWMTAction.setEnabled(false);
+ editSymbols.setEnabled(true);
+ openFile.setEnabled(true);
+ deleteAction.setEnabled(true);
+ }
+ else if( availableAction == FileActionType.ANALYSE_SWMT_ONE ){
+ launchHeapAnalyserAction.setEnabled(false);
+ compareTwoHeapsAction.setEnabled(false);
+ importAndCompareHeapsAction.setEnabled(false);
+ launchSWMTAction.setEnabled(true);
+ editSymbols.setEnabled(false);
+ openFile.setEnabled(true);
+ deleteAction.setEnabled(true);
+ }
+ else if( availableAction == FileActionType.ANALYSE_SWMT_MULTIPLE ){
+ launchHeapAnalyserAction.setEnabled(false);
+ compareTwoHeapsAction.setEnabled(false);
+ importAndCompareHeapsAction.setEnabled(false);
+ launchSWMTAction.setEnabled(true);
+ editSymbols.setEnabled(false);
+ openFile.setEnabled(false);
+ deleteAction.setEnabled(true);
+ }
+ else if( availableAction == FileActionType.COMPARE_HEAPS ){
+ launchHeapAnalyserAction.setEnabled(false);
+ compareTwoHeapsAction.setEnabled(true);
+ importAndCompareHeapsAction.setEnabled(false);
+ launchSWMTAction.setEnabled(false);
+ editSymbols.setEnabled(false);
+ openFile.setEnabled(false);
+ deleteAction.setEnabled(true);
+ }
+ else if( availableAction == FileActionType.DELETE ){
+ launchHeapAnalyserAction.setEnabled(false);
+ compareTwoHeapsAction.setEnabled(false);
+ importAndCompareHeapsAction.setEnabled(false);
+ launchSWMTAction.setEnabled(false);
+ editSymbols.setEnabled(false);
+ openFile.setEnabled(false);
+ deleteAction.setEnabled(true);
+ }
+ else if( availableAction == FileActionType.NONE ){
+ launchHeapAnalyserAction.setEnabled(false);
+ compareTwoHeapsAction.setEnabled(false);
+ importAndCompareHeapsAction.setEnabled(false);
+ launchSWMTAction.setEnabled(false);
+ editSymbols.setEnabled(false);
+ openFile.setEnabled(false);
+ deleteAction.setEnabled(false);
+ }
+ }
+
+
+ /**
+ * getAvailableAction.
+ * @return action type that is available for item or items that are currently selected.
+ */
+ private FileActionType getAvailableAction(){
+
+ // get selected items
+ IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
+
+ @SuppressWarnings("unchecked")
+ List selectionList = selection.toList();
+
+ boolean swmtFileFound = false;
+ boolean heapFileFound = false;
+
+ // go thru selected files-list
+ for(Object obj : selectionList){
+ MemSpyFileBundle bundle = (MemSpyFileBundle) obj;
+ if( bundle.getFileType().equals("SWMT-Log") ){
+ swmtFileFound = true;
+ }
+ else{
+ heapFileFound = true;
+ }
+ }
+
+ // if two files and no swmt files are found, compare heaps - action is available
+ if( selectionList.size() == 2 && heapFileFound && !swmtFileFound ){
+ return FileActionType.COMPARE_HEAPS;
+ }
+
+ // if swmt-files are found and no heap dumps are found, analyse swmt-action is available
+ else if( swmtFileFound && selectionList.size() == 1 ){
+ return FileActionType.ANALYSE_SWMT_ONE;
+ }
+ else if( swmtFileFound && !heapFileFound){
+ return FileActionType.ANALYSE_SWMT_MULTIPLE;
+ }
+
+ // if heap one heap file is found, analyse heap - action is available
+ else if( heapFileFound && selectionList.size() == 1 ){
+ return FileActionType.ANALYSE_HEAP;
+ }
+
+ // There are files selected, but only available action is delete.
+ else if( selectionList.size() > 0 ){
+ return FileActionType.DELETE;
+ }
+
+ // No files selected - no actions are available
+ return FileActionType.NONE;
+ }
+
+
+ /**
+ * enableAndDisableToolbarItems.
+ * Enables and disable toolbar items according to type of the selected file.
+ */
+ private void enableAndDisableToolbarItems(){
+ FileActionType availableAction = this.getAvailableAction();
+
+ if( availableAction == FileActionType.ANALYSE_HEAP ){
+ launchSWMTAction.setEnabled(false);
+ launchHeapAnalyserAction.setEnabled(true);
+ compareHeapsToolbarAction.setEnabled(true);
+ compareHeapsToolbarAction.setToolTipText(TOOLTIP_TEXT_IMPORT_AND_COMPARE);
+ deleteAction.setEnabled(true);
+
+
+ }
+ else if( availableAction == FileActionType.ANALYSE_SWMT_MULTIPLE || availableAction == FileActionType.ANALYSE_SWMT_ONE ){
+ launchSWMTAction.setEnabled(true);
+ launchHeapAnalyserAction.setEnabled(false);
+ compareHeapsToolbarAction.setEnabled(false);
+ deleteAction.setEnabled(true);
+ }
+ else if( availableAction == FileActionType.COMPARE_HEAPS ){
+ launchSWMTAction.setEnabled(false);
+ launchHeapAnalyserAction.setEnabled(false);
+ compareHeapsToolbarAction.setEnabled(true);
+ compareHeapsToolbarAction.setToolTipText(TOOLTIP_COMPARE_2_IMPORTED_FILE);
+ deleteAction.setEnabled(true);
+
+ }
+ else if( availableAction == FileActionType.DELETE ){
+ launchSWMTAction.setEnabled(false);
+ launchHeapAnalyserAction.setEnabled(false);
+ compareHeapsToolbarAction.setEnabled(false);
+ deleteAction.setEnabled(true);
+ }
+ else if( availableAction == FileActionType.NONE ){
+ launchSWMTAction.setEnabled(false);
+ launchHeapAnalyserAction.setEnabled(false);
+ compareHeapsToolbarAction.setEnabled(false);
+ deleteAction.setEnabled(false);
+ }
+ }
+
+
+ /**
+ * fillLocalToolBar.
+ * fills toolbar
+ * @param manager Toolbar manager
+ */
+ private void fillLocalToolBar(IToolBarManager manager) {
+ manager.add(launchSWMTAction);
+ manager.add(compareHeapsToolbarAction);
+ manager.add(launchHeapAnalyserAction);
+ manager.add(launchWizardAction);
+ manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ manager.add(deleteAction);
+
+ }
+
+
+ /**
+ * makeActions.
+ * Creates actions
+ */
+ private void makeActions() {
+
+ launchSWMTAction = new Action() {
+ @SuppressWarnings("unchecked")
+ public void run() {
+
+ // get selection list.
+ IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
+
+ // ensure that selected items are swmt-logs
+ if( !selection.isEmpty() ){
+
+ List list = selection.toList();
+ ArrayList swmtLogs = new ArrayList();
+
+ boolean allFilesAreSwmtLogs = true;
+
+ // Go thru bundle list and add all file paths into arraylist
+ for( MemSpyFileBundle item : list ){
+ swmtLogs.add( item.getFilePath() );
+ if( item.getFileType().equals("SWMT-log") ){
+ allFilesAreSwmtLogs = false;
+ }
+ }
+
+ // ensure that all selected files were swmt logs
+ if( allFilesAreSwmtLogs ){
+ // launch swmt analyser for selected logs.
+ SwmtAnalyser analyser = new SwmtAnalyser(MemSpyConsole.getInstance());
+ analyser.analyse( swmtLogs );
+ }
+ }
+ }
+ };
+ launchSWMTAction.setText("Launch SWMT-Analyser");
+ launchSWMTAction.setToolTipText("Launch SWMT-Analyser");
+ launchSWMTAction.setImageDescriptor(ImageResourceManager.getImageDescriptor(ImageKeys.IMG_LAUNCH_SWMT));
+
+
+ compareTwoHeapsAction = new Action() {
+ @SuppressWarnings("unchecked")
+ public void run() {
+
+ // get selected items:
+ ISelection selection = viewer.getSelection();
+ Object obj = ((IStructuredSelection)selection).toList();
+
+ List selectionList = (List)obj;
+
+ //verify that to heap files are selected.
+ if( getAvailableAction() == FileActionType.COMPARE_HEAPS ){
+ compareHeaps(selectionList);
+ }
+ }
+ };
+
+ compareTwoHeapsAction.setText(TOOLTIP_COMPARE_2_IMPORTED_FILE);
+ compareTwoHeapsAction.setToolTipText(TOOLTIP_COMPARE_2_IMPORTED_FILE);
+ compareTwoHeapsAction.setImageDescriptor(ImageResourceManager.getImageDescriptor(ImageKeys.IMG_COMPARE_2_HEAP));
+
+ importAndCompareHeapsAction = new Action() {
+ @SuppressWarnings("unchecked")
+ public void run() {
+
+ // get selected items:
+ ISelection selection = viewer.getSelection();
+ Object obj = ((IStructuredSelection)selection).toList();
+
+ List selectionList = (List)obj;
+
+ //verify that only one file is selected.
+ if( getAvailableAction() == FileActionType.ANALYSE_HEAP ){
+ importAndCompareHeaps(selectionList);
+ }
+ }
+ };
+
+ importAndCompareHeapsAction.setText(TOOLTIP_TEXT_IMPORT_AND_COMPARE);
+ importAndCompareHeapsAction.setToolTipText(TOOLTIP_TEXT_IMPORT_AND_COMPARE);
+ importAndCompareHeapsAction.setImageDescriptor(ImageResourceManager.getImageDescriptor(ImageKeys.IMG_COMPARE_2_HEAP));
+
+ compareHeapsToolbarAction = new Action() {
+ @SuppressWarnings("unchecked")
+ public void run() {
+
+ // get selected items:
+ ISelection selection = viewer.getSelection();
+ Object obj = ((IStructuredSelection)selection).toList();
+
+ List selectionList = (List)obj;
+
+ // check if only one file is selected.
+ if( getAvailableAction() == FileActionType.ANALYSE_HEAP ){
+ importAndCompareHeaps(selectionList);
+ }
+ // or if two heaps are selected, then compare them.
+ else if( getAvailableAction() == FileActionType.COMPARE_HEAPS ){
+ compareHeaps(selectionList);
+ }
+ }
+ };
+
+ compareHeapsToolbarAction.setText(TOOLTIP_COMPARE_2_IMPORTED_FILE);
+ compareHeapsToolbarAction.setToolTipText(TOOLTIP_COMPARE_2_IMPORTED_FILE);
+ compareHeapsToolbarAction.setImageDescriptor(ImageResourceManager.getImageDescriptor(ImageKeys.IMG_COMPARE_2_HEAP));
+
+ launchHeapAnalyserAction = new Action() {
+ @SuppressWarnings("unchecked")
+ public void run() {
+
+ ISelection selection = viewer.getSelection();
+ Object obj = ((IStructuredSelection)selection).toList();
+
+ List selectionList = (List)obj;
+
+ // Get thread name from xml-file
+ String xmlFile = selectionList.get(0).getXMLFilePath();
+ AnalyserXMLGenerator xml = readXMLFile(xmlFile);
+
+ //If Symbol files has not been set to data, before analyze, user have to set a Symbol file
+ if(!xml.hasXMLDebugMetaDataFile()){
+ //verify that only one file is selected.
+ if( selectionList.size() == 1 ){
+ //Make user to edit symbol files, and after that, continue to launch
+ int retCode = runWizard( MemSpyWizardType.SYMBOLS, xml );
+ //Don't giving an error message if user presses Cancel, instead just return
+ if(retCode == Window.CANCEL){
+ return;
+ }
+ }
+ }
+
+
+ String threadName = xml.getXMLThreadName();
+
+ //verify that only one file is selected.
+ if( selectionList.size() == 1 ){
+
+ //verify that heap dump file is selected.
+ if( selectionList.get(0).hasHeapDumpFile() ){
+
+ // get xml files path
+ String xmlPath = xmlFile;
+
+ // launch heap analyser
+ launchHeapAnalyser( xmlPath, null, threadName, true );
+
+ }
+
+
+ }
+ }
+ };
+ launchHeapAnalyserAction.setText("Analyse selected heap with Heap Analyser");
+ launchHeapAnalyserAction.setToolTipText("Analyse selected heap with Heap Analyser");
+ launchHeapAnalyserAction.setImageDescriptor(ImageResourceManager.getImageDescriptor(ImageKeys.IMG_ANALYZE_HEAP));
+
+
+ launchWizardAction = new Action() {
+ public void run() {
+ runWizard( MemSpyWizardType.FULL, null );
+ }
+ };
+
+ launchWizardAction.setText("Launch MemSpy's import Wizard");
+ launchWizardAction.setToolTipText("Launch MemSpy's import Wizard");
+ launchWizardAction.setImageDescriptor(ImageResourceManager.getImageDescriptor(ImageKeys.IMG_APP_ICON));
+
+
+ doubleClickAction = new Action() {
+ public void run() {
+ FileActionType action = getAvailableAction();
+ switch (action){
+ case ANALYSE_HEAP:{
+ launchHeapAnalyserAction.run();
+ break;
+ }
+ case ANALYSE_SWMT_ONE:
+ case ANALYSE_SWMT_MULTIPLE:{
+ launchSWMTAction.run();
+ break;
+ }
+ case COMPARE_HEAPS:{
+ compareTwoHeapsAction.run();
+ break;
+ }
+ default:{
+ // No need to do anything with other action.
+ break;
+ }
+
+ }
+ }
+ };
+
+
+
+ deleteAction = new Action() {
+ @SuppressWarnings("unchecked")
+ public void run() {
+ // get selected items:
+ ISelection selection = viewer.getSelection();
+ Object obj = ((IStructuredSelection)selection).toList();
+
+
+ List selectionList = (List)obj;
+
+ // ensure that some item(s) is selected.
+ if( selectionList.size() >= 1 ){
+
+ // Display a Confirmation dialog
+ MessageBox messageBox = new MessageBox(viewer.getControl().getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
+ messageBox.setText("MemSpy - Delete Files");
+ messageBox.setMessage("Are you sure you want to delete selected files?");
+ int buttonID = messageBox.open();
+ if (buttonID == SWT.YES) {
+ for( MemSpyFileBundle item : selectionList ){
+
+ // delete it
+ item.delete();
+
+ }
+ refreshContentAndView();
+ }
+
+ }
+
+ }
+ };
+
+ deleteAction.setText("Delete");
+ deleteAction.setToolTipText("Delete selected item");
+ deleteAction.setImageDescriptor( PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
+
+
+ openFile = new Action() {
+ @SuppressWarnings("unchecked")
+ public void run() {
+ ISelection selection = viewer.getSelection();
+ Object obj = ((IStructuredSelection)selection).toList();
+
+ List selectionList = (List)obj;
+
+ //verify that only one file is selected.
+ if( selectionList.size() == 1 ){
+
+ // open selected log file in editor.
+ File fileToOpen = new File(selectionList.get(0).getFilePath());
+ if (fileToOpen.exists() && fileToOpen.isFile()) {
+ IFileStore fileStore = EFS.getLocalFileSystem().getStore(fileToOpen.toURI());
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+
+ try {
+ IDE.openEditorOnFileStore( page, fileStore );
+ } catch ( PartInitException e ) {
+ showErrorMessage(ERROR_TOPIC, "MemSpy was unable to open file.");
+ }
+ } else {
+ showErrorMessage(ERROR_TOPIC, "File does not exists.");
+
+ }
+
+ }
+ }
+ };
+ openFile.setText("Open selected file in text editor");
+ openFile.setToolTipText("Open selected file in text editor");
+
+ editSymbols = new Action() {
+ @SuppressWarnings("unchecked")
+ public void run() {
+ ISelection selection = viewer.getSelection();
+ Object obj = ((IStructuredSelection)selection).toList();
+
+ List selectionList = (List)obj;
+
+ //verify that only one file is selected.
+ if( selectionList.size() == 1 ){
+ AnalyserXMLGenerator info = readXMLFile(selectionList.get(0).getXMLFilePath());
+ runWizard( MemSpyWizardType.SYMBOLS, info );
+ }
+ }
+ };
+ editSymbols.setText("Edit symbol definitions of selected Heap Dump");
+ editSymbols.setToolTipText("Edit symbol definitions of selected Heap Dump");
+ }
+
+
+ /**
+ * Starts wizard to compare currently selected heap file.
+ * @param selectionList List from which selected file is found.
+ */
+ private void importAndCompareHeaps(List selectionList) {
+ // get info from xml-file
+ AnalyserXMLGenerator info = readXMLFile(selectionList.get(0).getXMLFilePath());
+
+ // set source files path into info
+ info.setXMLSourceFile(new String[]{ selectionList.get(0).getFilePath() });
+
+ // start wizard
+ runWizard( MemSpyWizardType.COMPARE, info);
+ }
+
+ /**
+ * Starts Heap analyzer to compare two currently selected heaps.
+ * @param selectionList List from which selected heap files are found.
+ */
+ private void compareHeaps(List selectionList) {
+ // get selected file bundles.
+ MemSpyFileBundle bundle1 = selectionList.get(0);
+ MemSpyFileBundle bundle2 = selectionList.get(1);
+
+ // read both Heap Dumps configuration files
+ AnalyserXMLGenerator generator1 = readXMLFile(bundle1.getXMLFilePath());
+ AnalyserXMLGenerator generator2 = readXMLFile(bundle2.getXMLFilePath());
+
+ // ensure that both generators were created successfully.
+ if( generator1 == null || generator2 == null ){
+ MessageDialog.openError( getSite().getShell(), ERROR_COMPARE, ERROR_CONFIGURATION_FILES_NOT_FOUND );
+ return;
+ }
+
+ // if Heaps are not from same thread show error message
+ if( !generator1.getXMLThreadName().equals( generator2.getXMLThreadName() ) ){
+ MessageDialog.openError( getSite().getShell(), ERROR_COMPARE, ERROR_HEAP_THREADS_NOT_SAME );
+ return;
+ }
+
+ boolean compare = true;
+
+ // if symbol definitions are not same, confirm that user really wants continue comparing
+ if( !Arrays.equals(generator1.getXMLDebugMetaDataFile(), generator2.getXMLDebugMetaDataFile() ) ){
+ // Display a Confirmation dialog
+ MessageBox messageBox = new MessageBox(viewer.getControl().getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
+ messageBox.setText( WARNING_COMPARE );
+ messageBox.setMessage( WARNING_SYMBOLS_NOT_SAME );
+ int buttonID = messageBox.open();
+ if (buttonID == SWT.NO) {
+ compare = false;
+ }
+ }
+ if( compare ){
+
+ UserEnteredData data = new UserEnteredData();
+
+ // open file dialog for selecting a MemSpy file
+ FileDialog dialog = new FileDialog( getSite().getShell(), SWT.SAVE );
+ dialog.setText(FILE_DIALOG_DEFINE_OUTPUT);
+ String[] filterExt = { "*.xls" };
+ dialog.setFilterExtensions(filterExt);
+
+ // Restore previous output filename
+ String[] lastUsedFiles = data.getPreviousValues(ValueTypes.OUTPUT_FILE);
+ if( lastUsedFiles != null && lastUsedFiles.length > 0 ){
+ dialog.setFileName(lastUsedFiles[0]);
+ }
+
+ String result = dialog.open();
+
+
+ if( result != null ){
+
+ File file = new File( result );
+ // If file already exists, confirm that user wants to rewrite it.
+ if( file.exists() ){
+
+ // Display a Confirmation dialog
+ MessageBox messageBox = new MessageBox(viewer.getControl().getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
+ messageBox.setText( WARNING_COMPARE );
+ messageBox.setMessage( WARNING_FILE_EXISTS );
+ int buttonID = messageBox.open();
+ if (buttonID == SWT.NO) {
+ compare = false;
+ }
+ }
+
+ if( compare ){
+
+ // Save output filename so that it can be restored later
+ data.saveValue(ValueTypes.OUTPUT_FILE, result);
+
+ generator1.setXMLAnalyseFileOutput(result);
+ String[] sources = new String[]{ bundle1.getFilePath(), bundle2.getFilePath() };
+
+ // generate configuration file for comparison
+ if( importEngine.generateCompareConfigurationFile(sources, generator1.getXMLThreadName(), generator1)){
+ launchHeapAnalyser( MemSpyFileOperations.getCompareConfigurationFilePath(), result, generator1.getXMLThreadName(), false );
+ }
+ else{
+ MessageDialog.openError( getSite().getShell(), ERROR_COMPARE, ERROR_UNABLE_TO_GENERATE_CONFIGURATIONS );
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * hookDoubleClickAction
+ * adds double click listener
+ */
+ private void hookDoubleClickAction() {
+ viewer.addDoubleClickListener(new IDoubleClickListener() {
+ public void doubleClick(DoubleClickEvent event) {
+ doubleClickAction.run();
+ }
+ });
+ }
+
+ /**
+ * setFocus.
+ * Passing the focus request to the viewer's control.
+ */
+ public void setFocus() {
+ viewer.getControl().setFocus();
+ }
+
+
+ /**
+ * Makes main view visible and returns an instance of itself. Can be called from
+ * an UI thread only.
+ * @return instance of main view
+ */
+ public static MemSpyMainView showAndReturnYourself() {
+ return showAndReturnYourself(false);
+ }
+
+ /**
+ * Makes main view visible and returns an instance of itself. Can be called from
+ * an UI thread only.
+ * @return instance of main view
+ */
+ public static MemSpyMainView showAndReturnYourself(boolean openOnly) {
+ try {
+
+ IWorkbenchWindow ww = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (ww == null)
+ return null;
+
+ IWorkbenchPage page = ww.getActivePage();
+ IWorkbenchPart currentPart = page.getActivePart();
+
+ // Checking if view is already open
+ IViewReference[] viewRefs = page.getViewReferences();
+ for (int i = 0; i < viewRefs.length; i++) {
+ IViewReference reference = viewRefs[i];
+ String id = reference.getId();
+ if(id.equalsIgnoreCase(MemSpyMainView.ID)){
+ // Found, restoring the view
+ IViewPart viewPart = reference.getView(true);
+ if (!openOnly)
+ page.activate(viewPart);
+ return (MemSpyMainView)viewPart;
+ }
+ }
+
+ // View was not found, opening it up as a new view.
+ MemSpyMainView mView = (MemSpyMainView)page.showView(MemSpyMainView.ID);
+ if (openOnly)
+ page.bringToTop(currentPart);
+ return mView;
+
+ } catch (Exception e) {
+ e.printStackTrace();
+
+ return null;
+ }
+ }
+
+ /**
+ * runWizard().
+ * Starts MemSpy import wizard.
+ * @return {@link Window#OK} if Finish pressed, {@link Window#CANCEL} if Cancel was pressed.
+ */
+ public int runWizard( MemSpyWizardType wizardType, AnalyserXMLGenerator info ){
+
+
+ MemSpyWizard wizard = null;
+ if( wizardType == MemSpyWizardType.FULL ){
+ wizard = new MemSpyWizard( wizardType, null );
+
+ }
+ else if( wizardType == MemSpyWizardType.COMPARE || wizardType == MemSpyWizardType.SYMBOLS ){
+ wizard = new MemSpyWizard( wizardType, info );
+ }
+
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "Open wizard dialog");
+ // Open wizard dialog
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "Create Dialog");
+ MemSpyWizardDialog wizDialog = new MemSpyWizardDialog(getViewSite().getShell(), wizard);
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "Set dialog data");
+ wizard.setData(wizDialog);
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "Set dialog size");
+ wizDialog.setPageSize(600, 600);
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "Add pagecnhangelistener");
+ wizDialog.addPageChangedListener(wizard);
+ wizard.setWindowTitle("MemSpy Import Wizard");
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "Creating wizaDialog");
+ wizDialog.create();
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "open wizaDialog");
+
+ return wizDialog.open();
+ }
+
+ /**
+ * readXMLFile.
+ * Reads xml file from given path.
+ * @param XMLFilePath path of xml-file
+ * @return analyserXMLFile with read values.
+ */
+ private AnalyserXMLGenerator readXMLFile(String XMLFilePath){
+
+ FileReader reader = null;
+ try {
+ File file = new File( XMLFilePath );
+ reader = new FileReader(file );
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ return null;
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ BufferedReader bReader = new BufferedReader(reader);
+ AnalyserXMLGenerator xml = AnalyserXMLParser.parseXML( bReader );
+ return xml;
+
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.nokia.s60tools.memspy.interfaces.INewMemSpyFilesObserver#memSpyFilesUpdated()
+ */
+ public void memSpyFilesUpdated() {
+ Runnable refreshRunnable = new Runnable(){
+ public void run(){
+ refreshView();
+ // Sort files so that newly imported files are in top
+ ((S60ToolsViewerSorter) viewer.getSorter()).setSortCriteria(MemSpyDataSorter.TIME);
+ }
+ };
+ Display.getDefault().asyncExec(refreshRunnable);
+
+
+ }
+
+ /**
+ * refreshView.
+ * Refreshes view asynchronously.
+ */
+ private void refreshView() {
+ Runnable refreshRunnable = new Runnable(){
+ public void run(){
+ viewer.refresh();
+ enableAndDisableToolbarItems();
+
+ }
+ };
+
+ // Has to be done in its own thread
+ // in order not to cause invalid thread access
+ Display.getDefault().asyncExec(refreshRunnable);
+ }
+
+ /**
+ * refreshContentAndView.
+ * Refreshes content and view synchronously.
+ */
+ private void refreshContentAndView(){
+ contentProvider.refresh();
+ viewer.refresh();
+ this.enableAndDisableToolbarItems();
+ }
+
+ /**
+ * Refreshes content and view asynchronously.
+ */
+ public void refreshContentAndViewAsync() {
+ Runnable refreshRunnable = new Runnable(){
+ public void run(){
+ refreshContentAndView();
+ }
+ };
+
+ Display.getDefault().asyncExec(refreshRunnable);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetDefaultSelected(SelectionEvent arg0) {
+ // can be left empty.
+
+ }
+ public void widgetSelected(SelectionEvent arg0) {
+ this.enableAndDisableToolbarItems();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.nokia.s60tools.memspy.interfaces.IAnalyseHeapJobListener#heapAnalyserReturnValue(int)
+ */
+ public void heapAnalyserFinished(final int returnValue) {
+
+ if( returnValue != 0 ){
+ String errorMessage = HeapAnalyserLauncher.getErrorMessage(returnValue);
+ // Reporting error to console
+ String consoleErrMsg = "Heap Analyser launch failure with process exit value=" + returnValue + "."
+ + " " + errorMessage;
+ reportConsoleMessage(consoleErrMsg, MemSpyConsole.MSG_ERROR);
+ // Reporting error to user
+ showErrorMessage(ERROR_HEAP_ANALYSER, errorMessage );
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.nokia.s60tools.memspy.interfaces.IAnalyseHeapJobListener#heapAnalyserReturnValue(int, java.lang.String)
+ */
+ public void heapAnalyserFinished(int returnValue, final String outputFilePath) {
+
+ // if error occured
+ if( returnValue != 0 ){
+ this.heapAnalyserFinished(returnValue);
+ }
+
+ else{
+ Runnable refreshRunnable = new Runnable(){
+ public void run(){
+ /*// Ask user if generated file should be opened on excel
+ boolean compare = MessageDialog.openConfirm(getSite().getShell(), CONFIRMATION, CONFIRMATION_OPEN_FILE );
+ */
+ boolean compare = true;
+ // Display a Confirmation dialog
+ MessageBox messageBox = new MessageBox(viewer.getControl().getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
+ messageBox.setText( CONFIRMATION );
+ messageBox.setMessage( CONFIRMATION_OPEN_FILE );
+ int buttonID = messageBox.open();
+ if (buttonID == SWT.NO) {
+ compare = false;
+ }
+ if( compare ){
+
+ // find program for xls-filetype
+ Program p=Program.findProgram(".xls");
+
+ // if found, launch it.
+ if(p!=null){
+ p.execute(outputFilePath);
+ }
+ }
+
+ }
+ };
+
+ // Has to be done in its own thread
+ // in order not to cause invalid thread access
+ Display.getDefault().asyncExec(refreshRunnable);
+
+
+ }
+ }
+
+
+ /**
+ * Get import engine.
+ * @return importEngine
+ */
+ public ImportEngine getImportEngine() {
+ return importEngine;
+ }
+
+ /**
+ * Shows error message asynchronously.
+ * @param header header of message
+ * @param text error text
+ */
+ public void showErrorMessage(final String header, final String text){
+ Runnable showErrorMessageRunnable = new Runnable(){
+ public void run(){
+ MessageDialog.openError( getSite().getShell(), header, text);
+ }
+ };
+
+ // Has to be done in its own thread
+ // in order not to cause invalid thread access
+ Display.getDefault().asyncExec(showErrorMessageRunnable);
+ }
+
+ /**
+ * Reports message to console asynchronously.
+ * @param consoleMsg console message.
+ * @param messageType console message type
+ */
+ public void reportConsoleMessage(final String consoleMsg, final int messageType){
+ Runnable reportConsoleMessageRunnable = new Runnable(){
+ public void run(){
+ MemSpyConsole.getInstance().println(consoleMsg, messageType);
+ }
+ };
+
+ // Has to be done in its own thread
+ // in order not to cause invalid thread access
+ Display.getDefault().asyncExec(reportConsoleMessageRunnable);
+ }
+
+ /**
+ * Shows trace viewer plugin
+ */
+ public static void showTraceViewer() {
+ try {
+
+ IWorkbenchWindow ww = MemSpyPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
+ if (ww == null)
+ return;
+ IWorkbenchPage page = ww.getActivePage();
+
+ // Checking if view is already open
+ IViewReference[] viewRefs = page.getViewReferences();
+ for (int i = 0; i < viewRefs.length; i++) {
+ IViewReference reference = viewRefs[i];
+ String id = reference.getId();
+ if(id.equalsIgnoreCase(TRACE_VIEWER_VIEW_ID)){
+ // Found, restoring the view
+ IViewPart viewPart = reference.getView(true);
+ page.activate(viewPart);
+ return;
+ }
+ }
+
+ // View was not found, opening it up as a new view.
+ page.showView(TRACE_VIEWER_VIEW_ID);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * launchHeapAnalyser.
+ * Launches Heap Analyser.
+ * @param configurationFilePath path of the configuration file
+ * @param analyseOutputFilePath path of the output file
+ * @param threadName thread's name
+ * @param viewingHeap true, if action is view heap
+ */
+ public void launchHeapAnalyser( String configurationFilePath, String analyseOutputFilePath, String threadName, boolean viewingHeap ){
+
+ AnalyseHeapJob analyseHeapJob;
+
+ // set heap job's name correct
+ if( viewingHeap ){
+ analyseHeapJob = new AnalyseHeapJob( "Heap Analyser Running, Viewing heap from thread: " + threadName, this );
+ }
+ else{
+ analyseHeapJob = new AnalyseHeapJob( "Heap Analyser Running, Comparing Heaps from thread: " + threadName , this );
+ }
+
+ // set output file path
+ analyseHeapJob.setAnalyseOutputFile( analyseOutputFilePath );
+
+ // launch Heap Analyser
+ analyseHeapJob.setConfigurationFile( configurationFilePath );
+ analyseHeapJob.refresh();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.KeyListener#keyPressed(org.eclipse.swt.events.KeyEvent)
+ */
+ public void keyPressed(KeyEvent keyEvent) {
+
+ // if delete key is pressed run delete -action.
+ if( keyEvent.keyCode == java.awt.event.KeyEvent.VK_DELETE){
+ deleteAction.run();
+ }
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.KeyListener#keyReleased(org.eclipse.swt.events.KeyEvent)
+ */
+ public void keyReleased(KeyEvent arg0) {
+ // can be left empty.
+ }
+ /* (non-Javadoc)
+ * @see com.nokia.s60tools.memspy.interfaces.INewMemSpyFilesObserver#setOutputFilePath(java.lang.String)
+ */
+ public void setOutputFilePath(String outputFilePath) {
+ // can be left empty.
+ }
+
+ /**
+ * Launch the SWMT analyser with given files
+ * @param files
+ */
+ public void launchSWMTAnalyser( final ArrayList files ){
+ Runnable showErrorMessageRunnable = new Runnable(){
+ public void run(){
+ // launch swmt analyser for selected logs.
+ SwmtAnalyser analyser = new SwmtAnalyser(MemSpyConsole.getInstance());
+ analyser.analyse( files );
+ }
+ };
+
+ // Has to be done in its own thread
+ // in order not to cause invalid thread access
+ Display.getDefault().asyncExec(showErrorMessageRunnable);
+
+ }
+
+ /**
+ * Callback called when symbol filea are updated by user
+ * @param symbols
+ */
+ public void symbolsUpdated( final AnalyserXMLGenerator symbols ){
+ Runnable editSymbolDefinitions = new Runnable(){
+ @SuppressWarnings("unchecked")
+ public void run(){
+ // get selected file bundle
+ ISelection selection = viewer.getSelection();
+ Object obj = ((IStructuredSelection)selection).toList();
+ List selectionList = (List)obj;
+ //verify that only one file is selected.
+ if( selectionList.size() == 1 ){
+ if( !importEngine.generateViewConfigurationFile(selectionList.get(0).getFilePath(), symbols.getXMLThreadName(), symbols) ){
+ showErrorMessage(ERROR_TOPIC, "File operations were failed when trying to save new symbol definitions. Definitions may not be saved.");
+ }
+ }
+ }
+ };
+ Display.getDefault().asyncExec(editSymbolDefinitions);
+
+ }
+
+}
\ No newline at end of file
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/views/MemSpyMainViewContentProvider.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/views/MemSpyMainViewContentProvider.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+package com.nokia.s60tools.memspy.ui.views;
+
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+import com.nokia.s60tools.memspy.interfaces.INewMemSpyFilesObserver;
+import com.nokia.s60tools.memspy.model.MemSpyFileManager;
+
+/**
+ * This class provides content for main view
+ */
+class MemSpyMainViewContentProvider implements IStructuredContentProvider {
+
+ private final MemSpyFileManager memSpyFileManager;
+
+ /**
+ * Create new content provider
+ * @param observer
+ */
+ public MemSpyMainViewContentProvider( INewMemSpyFilesObserver observer ){
+ memSpyFileManager = new MemSpyFileManager( observer );
+ }
+ /**
+ * Refresh file manager
+ * @see MemSpyFileManager#refresh()
+ */
+ public void refresh() {
+ memSpyFileManager.refresh();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ public void inputChanged(Viewer v, Object oldInput, Object newInput) {
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ public void dispose() {
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ public Object[] getElements(Object parent) {
+ return memSpyFileManager.getmemSpyFiles();
+ }
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/views/MemSpyMainViewLabelProvider.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/views/MemSpyMainViewLabelProvider.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+package com.nokia.s60tools.memspy.ui.views;
+
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+import com.nokia.s60tools.memspy.model.MemSpyFileBundle;
+import com.nokia.s60tools.memspy.resources.ImageKeys;
+import com.nokia.s60tools.memspy.resources.ImageResourceManager;
+
+class MemSpyMainViewLabelProvider extends LabelProvider implements ITableLabelProvider {
+ /**
+ * Returns text for a column defined by index
+ */
+ public String getColumnText(Object obj, int index) {
+ MemSpyFileBundle cFileBundle = (MemSpyFileBundle)obj;
+ return cFileBundle.getText(index);
+ }
+ public Image getColumnImage(Object obj, int index) {
+ if (index == MemSpyFileBundle.INDEX_FILE_TYPE){
+ return getImage(obj);
+ }
+ else{
+ return null;
+ }
+ }
+ public Image getImage(Object obj) {
+ MemSpyFileBundle bundle = (MemSpyFileBundle)obj;
+ if( bundle.hasHeapDumpFile() ){
+ return ImageResourceManager.getImage(ImageKeys.IMG_HEAP_DUMP);
+ }
+ else{
+ return ImageResourceManager.getImage(ImageKeys.IMG_SWMT_LOG);
+ }
+ }
+}
\ No newline at end of file
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/wizards/DeviceOrFileSelectionPage.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/wizards/DeviceOrFileSelectionPage.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,1436 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+package com.nokia.s60tools.memspy.ui.wizards;
+
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+
+import com.nokia.s60tools.memspy.containers.SWMTLogInfo;
+import com.nokia.s60tools.memspy.containers.ThreadInfo;
+import com.nokia.s60tools.memspy.containers.ThreadInfo.HeapDumpType;
+import com.nokia.s60tools.memspy.interfaces.IMemSpyTraceListener;
+import com.nokia.s60tools.memspy.model.MemSpyFileOperations;
+import com.nokia.s60tools.memspy.model.MemSpyLogParserEngine;
+import com.nokia.s60tools.memspy.model.TraceCoreEngine;
+import com.nokia.s60tools.memspy.model.UserEnteredData;
+import com.nokia.s60tools.memspy.model.UserEnteredData.ValueTypes;
+import com.nokia.s60tools.memspy.plugin.MemSpyPlugin;
+import com.nokia.s60tools.memspy.resources.HelpContextIDs;
+import com.nokia.s60tools.memspy.ui.UiUtils;
+import com.nokia.s60tools.ui.preferences.PreferenceUtils;
+import com.nokia.s60tools.ui.wizards.S60ToolsWizardPage;
+import com.nokia.s60tools.util.debug.DbgUtility;
+
+
+public class DeviceOrFileSelectionPage extends S60ToolsWizardPage implements
+ SelectionListener, ModifyListener, IMemSpyTraceListener {
+
+ /**
+ * Selection index for import from device via TraceViewer radio button
+ */
+ private static final int DEVICE_RADIO_BUTTON_SELECTION_INDEX = 2;
+
+ public enum PageType{ IMPORT_PAGE, COMPARE_FIRST_HEAP, COMPARE_SECOND_HEAP };
+
+ // UI elements
+ private Combo fileCombo;
+ private Button buttonBrowseFile;
+
+ private Button fileRadioButton;
+ private Button deviceRadioButton;
+ private Button loadThreadListButton;
+ private Button connectionSettingsButton;
+ private Button getHeapButton;
+
+ private Label heapsReceivedLabel;
+ private Label connectionTextLabel;
+ private Label connectionNameInUseLabel;
+
+ private GridData threadSelectionGridData;
+ private GridData fileSelectionGridData;
+ private GridData deviceThreadTableGridData;
+ private GridData importedHeapTableGridData;
+ private GridData loadThreadListGridData;
+ private GridData connectionGridData;
+ private GridData connectionButtonGridData;
+ private GridData connectionNameInUseGridData;
+ private GridData threadFilterTypesGridData;
+ private GridData threadFilterGridData;
+
+ private Group compareGroup;
+
+
+ private Group fileSelectionGroup;
+ private Composite fileLocationGroup;
+ private Composite fileThreadListGroup;
+
+ private Group radioButtonGroup;
+ private Group threadSelectionGroup;
+ private Composite threadListGroup;
+ private Composite threadButtonGroup;
+
+ /**
+ * Table that is shown when getting heap From File System.
+ */
+ private Table fileThreadTable;
+ /**
+ * Table which contents can be loaded/refreshed from the device.
+ */
+ private Table deviceThreadTable;
+ /**
+ * Table that contains two heaps that are to be compared when Import and compare is selected.
+ */
+ private Table comparedHeapsTable;
+ /**
+ * Table in second page, where only imported heap can be selected.
+ */
+ private Table importedHeapTable;
+
+ /**
+ * Text field for setting filter text.
+ */
+ private String filterText;
+ /**
+ * Filter text.
+ */
+ private Text threadFilterText;
+ /**
+ * Combo for filtering types.
+ */
+ private Combo threadFilterTypesCombo;
+
+ // Thread list from one file
+ private ArrayList fileThreadList;
+
+ // selected thread from thread list
+ private ThreadInfo comparedThread;
+
+ // Decoder Engine
+ private MemSpyLogParserEngine engine;
+
+ // Thread list received from usb/musti
+ ArrayList deviceThreadList;
+
+ // TraceCore engine
+ TraceCoreEngine traceEngine;
+
+ // List of received heaps:
+ ArrayList receivedHeaps;
+
+ // Heap that is currently received
+ ThreadInfo receivedHeap;
+
+ // this pages UserEnterData section
+ ValueTypes section;
+
+ // viewed error message
+ String errorMessage;
+
+ // Type of this page
+ PageType pageType;
+
+ // boolean variable, which is set to true if some MemSpy operation is running.
+ boolean memSpyOperationRunning;
+
+ // MemSpy operation processes:
+ // receive thread list
+ IRunnableWithProgress receiveThreadListProcess;
+ // receive heap
+ IRunnableWithProgress receiveHeapProcess;
+
+
+ //Strings
+
+ private final static String FILE_SELECTION_DIALOG_TEXT = "Select Heap Dump File";
+ private final static String GET_HEAP_RADIO_BUTTON = "Get Heap:";
+ private final static String GET_HEAP_FROM_FILE_RADIO_BUTTON = "From File System";
+ private final static String GET_HEAP_FROM_DEVICE_RADIO_BUTTON = "From Device via TraceViewer";
+ private final static String HEAP_DUMP_LOCATION_TEXT = "Define Location of Heap Dump File:";
+ private final static String BROWSE_TEXT = "Browse...";
+ private final static String HEAP_CONTAINS_TEXT_IMPORT = "Selected file contains heaps from following threads.";
+ private final static String HEAP_CONTAINS_TEXT_COMPARE = "Selected file contains heaps from following threads, select thread which heap needs to be compared.";
+ private final static String THREAD_NAME_TEXT = "Thread Name";
+ private final static String SELECT_THREAD_TEXT = GET_HEAP_FROM_DEVICE_RADIO_BUTTON;
+ private final static String SELECT_FILE_TEXT = GET_HEAP_FROM_FILE_RADIO_BUTTON;
+ private final static String LOAD_REFRESH_THREAD_LIST_BUTTON = "Load/Refresh Thread List";
+ private final static String CONNECTION_SETTINGS_BUTTON = "Connection Settings...";
+ private final static String CURRENTLY_USING_TEXT = "Currently using:";
+ private final static String GET_HEAP_NOW_BUTTON = "Get Selected Heap Now";
+ private final static String HEAP_DUMP_RECEIVED = "Heap Dump Received";
+ private final static String RECEIVING_THREAD_LIST = "Receiving Thread List: ";
+ private final static String RECEIVING_HEAP_DUMP = "Receiving Heap Dump: ";
+ private final static String HEAP_DUMPS_RECEIVED = " Heap Dumps Received";
+ private final static String COMPARE_HEAPS = "Compared heaps";
+
+
+ // Error/warning messages
+ private final static String ERROR_INVALID_FILE = "Invalid heap dump file. The file doesn't contain any threads with binary data information.";
+ private final static String ERROR_FILE_NOT_FOUND = "File not found";
+ private final static String SELECT_COMPARED_THREAD = "Select thread which heap needs to be compared";
+ private final static String WARNING_HEAPS_NOT_FROM_SAME_THREAD = "Compared heaps are not from same thread";
+
+ private final static String ERROR_DRM_THREAD = "Heaps from threads which name contains word \"drm\" cannot be received due to security policies.";
+ private final static String ERROR_DBGTRS_THREAD = "Heaps from threads which name contains word \"dbgtrcserver::!DbgTrcServer\" cannot be received due to Trace restrictions.";
+
+
+ /**
+ * DeviceOrFileSelectionPage(String pageName)
+ * Constructor
+ * @param pagename name of this wizard page
+ */
+ protected DeviceOrFileSelectionPage( String pageName, String title, String description, ValueTypes section,
+ PageType pageType, TraceCoreEngine traceEngine ) {
+ super(pageName);
+ setTitle( title );
+ setDescription( description );
+ this.engine = new MemSpyLogParserEngine();
+ this.fileThreadList = new ArrayList();
+ this.deviceThreadList = new ArrayList();
+ this.traceEngine = traceEngine;
+ this.receivedHeaps = new ArrayList();
+ this.receivedHeap = new ThreadInfo();
+ this.section = section;
+ this.errorMessage = "";
+ this.pageType = pageType;
+ this.comparedThread = null;
+ memSpyOperationRunning = false;
+ this.createMemSpyProcesses();
+ this.filterText = "";
+ }
+
+ /**
+ * (non-Javadoc)
+ * @see com.nokia.s60tools.ui.wizards.S60ToolsWizardPage#setInitialFocus()
+ */
+
+ public void setInitialFocus() {
+ fileCombo.setFocus();
+ }
+
+ /**
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetDefaultSelected(SelectionEvent e) {
+ this.getHeapButtonPressed();
+ }
+
+ /**
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetSelected(SelectionEvent e) {
+ if (e.widget == buttonBrowseFile) {
+ // open file dialog for selecting a Heap Dump file
+ FileDialog dialog = new FileDialog(this.getShell());
+ dialog.setText(FILE_SELECTION_DIALOG_TEXT);
+ String[] filterExt = { "*.txt", "*.log", "*.*" };
+ dialog.setFilterExtensions(filterExt);
+ dialog.setFilterPath(fileCombo .getText());
+ String result = dialog.open();
+ if (result != null ){
+ fileCombo.setText(result);
+ }
+
+ }
+
+ // Update controls after radio buttons state changes to false
+ else if ( ( e.widget == deviceRadioButton && deviceRadioButton.getSelection() == false ) ||
+ ( e.widget == fileRadioButton && fileRadioButton.getSelection() == false ) ){
+ this.hideAndRevealItems();
+ getWizard().getContainer().updateButtons();
+
+ MemSpyWizard wizard = (MemSpyWizard) getWizard();
+ if( this.pageType != PageType.IMPORT_PAGE ){
+ wizard.setComparedHeaps();
+ }
+
+ }
+
+ // Open connection settings.
+ else if ( e.widget == connectionSettingsButton ){
+ // Open connection Trace viewers connection settings.
+ Shell shell = MemSpyPlugin.getCurrentlyActiveWbWindowShell();
+ PreferenceUtils.openPreferencePage(MemSpyPlugin.getTraceProvider().getTraceSourcePreferencePageId(), shell);
+
+ // Disconnect trace source so that new settings are used when sending next request
+ MemSpyPlugin.getTraceProvider().disconnectTraceSource();
+
+ MemSpyWizard wizard = (MemSpyWizard) this.getWizard();
+ // update new settings to each wizard page.
+ wizard.updateConnectionSettings();
+ }
+
+ // Load thread list from device
+ else if ( e.widget == loadThreadListButton ){
+ this.loadThreadListButtonPressed();
+ }
+ else if ( e.widget == getHeapButton ){
+ this.getHeapButtonPressed();
+ }
+ else if( e.widget == deviceThreadTable ){
+ this.enableAndDisableGetHeapButton();
+ }
+ else if( e.widget == importedHeapTable ){
+ this.enableAndDisableGetHeapButton();
+ }
+ else if( e.widget == fileThreadTable ){
+
+ // get selection index from thread table
+ int selectionIndex = fileThreadTable.getSelectionIndex();
+
+ // set selected heap as compared heap
+ comparedThread = fileThreadList.get( selectionIndex );
+
+ // get wizard and update compared thread names
+ MemSpyWizard wizard = (MemSpyWizard)this.getWizard();
+ wizard.setComparedHeaps();
+
+ wizard.showImportedHeapsInComparePage( false );
+
+ // update buttons
+ getWizard().getContainer().updateButtons();
+
+ // Set selection back to table after updatebuttons has cleared it.
+ fileThreadTable.setSelection( selectionIndex );
+
+ }
+ else if( e.widget == threadFilterTypesCombo) {
+ updateThreadList();
+ }
+
+
+ }
+
+ /**
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ public void modifyText(ModifyEvent event) {
+ if (event.widget.equals(fileCombo)) {
+ try {
+ getWizard().getContainer().updateButtons();
+ } catch (Exception e) {
+ }
+ }
+ else if (event.widget.equals(threadFilterText)) {
+ filterText = threadFilterText.getText();
+ updateThreadList();
+ }
+ }
+
+ /**
+ * (non-Javadoc)
+ * @see com.nokia.s60tools.ui.wizards.S60ToolsWizardPage#recalculateButtonStates()
+ */
+ public void recalculateButtonStates() {
+
+ }
+
+
+ /**
+ * hideAndRevealItems()
+ * Hides and reveals controls according to radiobutton states.
+ */
+ private void hideAndRevealItems() {
+
+ // get radiobutton selection
+ boolean fileSelected = true;
+ if( deviceRadioButton.getSelection() == false ){
+ fileSelected = false;
+ }
+
+ // exlude/include needed controls
+ fileSelectionGridData.exclude = fileSelected;
+ threadSelectionGridData.exclude = !fileSelected;
+
+ if( fileSelected ){
+ // Since excluded groups size and location are not updated, do it now
+ threadSelectionGroup.setSize( fileSelectionGroup.getSize() );
+ threadSelectionGroup.setLocation(fileSelectionGroup.getLocation());
+
+ }
+ else{
+ // Since excluded groups size and location are not updated, do it now
+ fileSelectionGroup.setSize( threadSelectionGroup.getSize() );
+ fileSelectionGroup.setLocation(threadSelectionGroup.getLocation());
+
+ }
+ // Hide/show needed controls
+ fileSelectionGroup.setVisible(!fileSelected);
+ threadSelectionGroup.setVisible(fileSelected);
+
+
+
+ }
+
+
+ /**
+ * canFinish()
+ * Returns false, because symbol files must be defined always.
+ */
+ public boolean canFinish()
+ {
+ return false;
+ }
+
+
+
+ public boolean refreshFileThreadList(){
+
+ File file = new File(fileCombo.getText());
+
+ // If file exists
+ if (file.isFile() && file.exists()) {
+
+ // Empty thread list table
+ fileThreadTable.removeAll();
+
+ fileThreadList.clear();
+
+ // Check that file is Heap Dump file and display thread names in table.
+ if ( engine.isFileHeapDumpFile(file, fileThreadList) ) {
+ this.setErrorMessage(null);
+
+
+ for( int i = 0; i < fileThreadList.size(); i++ ){
+ TableItem newItem = new TableItem(fileThreadTable, SWT.NONE,i);
+ newItem.setText(fileThreadList.get(i).getThreadName());
+ }
+ if( fileThreadList.size() == 1 ){
+ comparedThread = fileThreadList.get(0);
+ ((MemSpyWizard)this.getWizard()).setComparedHeaps();
+ }
+
+ // If comparing heaps and no heap is selected as compared heap
+ if( comparedThread == null && this.pageType != PageType.IMPORT_PAGE){
+ this.setErrorMessage(SELECT_COMPARED_THREAD);
+ return false;
+ }
+ else{
+ // if importing heaps, set first heap as compared heap.
+ if( this.pageType == PageType.IMPORT_PAGE ){
+ comparedThread = fileThreadList.get(0);
+ }
+ return true;
+ }
+ }
+ else {
+ this.setErrorMessage(ERROR_INVALID_FILE);
+ return false;
+ }
+ }
+ else {
+ this.setErrorMessage(ERROR_FILE_NOT_FOUND );
+ return false;
+ }
+
+ }
+
+ /**
+ * (non-Javadoc)
+ * @see org.eclipse.jface.wizard.WizardPage#canFlipToNextPage()
+ */
+
+ public boolean canFlipToNextPage() {
+
+ if( fileRadioButton.getSelection() ){
+ try {
+ if( !this.refreshFileThreadList() ){
+ return false;
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+
+ }
+ else{ // deviceRadioButton.getSelection()
+ if( receivedHeaps.size() > 0 ){
+ this.setErrorMessage(null);
+ }
+ else{
+ this.setErrorMessage(null);
+ return false;
+ }
+ }
+
+ if( this.pageType == PageType.COMPARE_FIRST_HEAP || this.pageType == PageType.COMPARE_SECOND_HEAP ){
+ MemSpyWizard wizard = (MemSpyWizard)this.getWizard();
+ if( !wizard.areComparedHeapsFromSameThread() ){
+ this.setMessage(WARNING_HEAPS_NOT_FROM_SAME_THREAD, ERROR);
+ if( this.pageType == PageType.COMPARE_SECOND_HEAP ){
+ return false;
+ }
+ }
+ else{
+ this.setMessage(null);
+ }
+ }
+ return true;
+
+
+
+
+ }
+
+
+ /**
+ * loadUserEnteredData
+ * Loads previously used values and selections into UI components
+ */
+
+ private void loadUserEnteredData(){
+
+ // restore previous state of radio buttons.
+ // if last value is not found, set selection file.
+
+ UserEnteredData data = new UserEnteredData();
+ int lastUsedSource = data.getPreviousRadioButtonSelection(section);
+
+ // Restoring previous state of radio buttons only if device import is also possible and was previously selected
+ if(MemSpyPlugin.isTraceProviderAvailable() && lastUsedSource == DEVICE_RADIO_BUTTON_SELECTION_INDEX){
+ deviceRadioButton.setSelection( true );
+ fileRadioButton.setSelection( false );
+ }
+ else{
+ deviceRadioButton.setSelection( false );
+ fileRadioButton.setSelection( true );
+ }
+
+ // Restore previous values to file combobox
+ String[] lastUsedFiles = data.getPreviousValues( section );
+ if ( lastUsedFiles != null ) {
+ fileCombo.setItems( lastUsedFiles );
+ fileCombo.select(0);
+ }
+
+ }
+
+ /**
+ * saveUserEnteredData.
+ * Saves user entered values and selections.
+ */
+ public void saveUserEnteredData(){
+ UserEnteredData data = new UserEnteredData();
+
+ // Save Action radio-buttons state
+ if( deviceRadioButton.getSelection() ){
+ data.saveRadioButtonSelection(section, 2);
+ }
+ else {
+ data.saveRadioButtonSelection(section, 1);
+ }
+
+ // Save file combo box
+ String item = fileCombo.getText();
+ data.saveValue(section, item);
+
+
+
+ }
+
+ /**
+ * enableAndDisableGetHeapButton.
+ * Enables/Disables "Get Heap Now" -button regarding wizard's state
+ */
+ private void enableAndDisableGetHeapButton(){
+ final PageType type = this.pageType;
+ Runnable updateUiRunnable = new Runnable(){
+ public void run(){
+ if( type == PageType.COMPARE_SECOND_HEAP && !importedHeapTableGridData.exclude ) {
+ getHeapButton.setEnabled( true );
+ }
+ else if( deviceThreadTable.getSelectionCount() == 1 ){
+ getHeapButton.setEnabled( true );
+ }
+ else{
+ getHeapButton.setEnabled( false );
+ }
+ }
+ };
+ Display.getDefault().asyncExec(updateUiRunnable);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.nokia.s60tools.memspy.ui.wizards.MemSpyTraceListener#operationFinished(com.nokia.s60tools.memspy.ui.wizards.MemSpyTraceListener.LauncherAction)
+ */
+ public void operationFinished( LauncherAction action ){
+
+
+ this.memSpyOperationRunning = false;
+
+ if( action == LauncherAction.GET_HEAP_DUMP ){
+ this.updateReceivedHeap();
+ }
+ else if( action == LauncherAction.GET_THREAD_LIST ){
+
+ // command wizard to update all thread tables from all wizard pages
+ ((MemSpyWizard)this.getWizard()).updateThreadLists( this.deviceThreadList );
+ }
+
+
+ }
+
+ /**
+ * updateReceivedHeap.
+ * Does all actions that are done when Heap Dump file has been received.
+ */
+ private void updateReceivedHeap(){
+ receivedHeaps.add( receivedHeap );
+
+
+ if( this.pageType == PageType.COMPARE_FIRST_HEAP || this.pageType == PageType.COMPARE_SECOND_HEAP ){
+ comparedThread = receivedHeap;
+ }
+
+ final MemSpyWizard wizard = (MemSpyWizard)this.getWizard();
+
+ Runnable updateUiRunnable = new Runnable(){
+ public void run(){
+
+ // if this is import page, update UI's receivedHeaps-text
+ if( pageType == PageType.IMPORT_PAGE ){
+ heapsReceivedLabel.setText( Integer.toString( receivedHeaps.size() ) + HEAP_DUMPS_RECEIVED );
+ threadButtonGroup.layout();
+ }
+
+ // If this is compare heaps page, command wizard to update all compare-tables.
+ else{
+ wizard.setComparedHeaps();
+ }
+
+ // hide thread list selection in second compare page.
+ if( pageType == PageType.COMPARE_FIRST_HEAP ){
+ wizard.showImportedHeapsInComparePage( true );
+ }
+
+ // Getting selected item from currently active table
+ TableItem item;
+ if( pageType == PageType.COMPARE_SECOND_HEAP && importedHeapTable.isVisible() ) {
+ item = importedHeapTable.getItem( importedHeapTable.getSelectionIndex() );
+ } else {
+ item = deviceThreadTable.getItem( deviceThreadTable.getSelectionIndex() );
+ }
+ ThreadInfo thread = (ThreadInfo)item.getData();
+
+ // Imported threads needs to be updated from first compare page.
+ if( pageType == PageType.COMPARE_FIRST_HEAP ) {
+ // sets thread list selection in 2. comparePage
+ wizard.setThreadListSelectionToComparePages( thread );
+ }
+
+ // get date formatter
+ SimpleDateFormat formatter = new SimpleDateFormat ( MemSpyFileOperations.DATEFORMAT );
+ String date = formatter.format( receivedHeap.getDate() );
+ item.setText( 1, date );
+ // Date is saved to thread information so that it will be available if table is sorted.
+ thread.setStatus(date);
+ }
+
+ };
+
+ // needs to be called from UI thread.
+ Display.getDefault().asyncExec(updateUiRunnable);
+ }
+
+ /**
+ * Updates list and uses current filtering.
+ */
+ public void updateThreadList(){
+ Runnable updateUiRunnable = new Runnable(){
+ public void run(){
+ String filter = filterText;
+ deviceThreadTable.removeAll();
+ for( ThreadInfo thread : deviceThreadList ) {
+ if(threadFilterTypesCombo.getSelectionIndex() == 0) {
+ // Starts with filter.
+ if(thread.getThreadName().toLowerCase().startsWith(filter.toLowerCase())) {
+ TableItem newItem = new TableItem(deviceThreadTable, SWT.NONE);
+ newItem.setText( new String[]{ thread.getThreadName(), thread.getStatus() } );
+ newItem.setData(thread);
+ }
+ } else {
+ // Contains filter.
+ if(thread.getThreadName().toLowerCase().contains(filter.toLowerCase())) {
+ TableItem newItem = new TableItem(deviceThreadTable, SWT.NONE);
+ newItem.setText( new String[]{ thread.getThreadName(), thread.getStatus() } );
+ newItem.setData(thread);
+ }
+ }
+ }
+
+ // update wizard buttons
+ getWizard().getContainer().updateButtons();
+ // Update get heap button.
+ enableAndDisableGetHeapButton();
+ }
+ };
+ Display.getDefault().asyncExec(updateUiRunnable);
+
+ }
+
+ /**
+ * updateConnectionText
+ * updates connection text to match used settings
+ */
+
+ public void updateConnectionText(){
+ // Updating connection name.
+ String displayName = MemSpyPlugin.getTraceProvider().getDisplayNameForCurrentConnection();
+ connectionNameInUseLabel.setText(displayName);
+ // Update layout.
+ threadSelectionGroup.layout();
+ threadButtonGroup.layout();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.nokia.s60tools.memspy.ui.wizards.MemSpyTraceListener#deviceError(com.nokia.s60tools.memspy.ui.wizards.MemSpyTraceListener.LauncherErrorType)
+ */
+ public void deviceError( final LauncherErrorType error ){
+
+ Date date = new Date (System.currentTimeMillis());
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "DeviceOrFileSelectionPage.deviceError: '" + error.name() +"' time:'" +date.toString() + "'."); //$NON-NLS-1$ $NON-NLS-2$ $NON-NLS-3$
+ memSpyOperationRunning = false;
+
+ // Getting user visible error message
+ errorMessage = UiUtils.getErrorMessageForLauncherError(error, traceEngine.getAdditionalErrorInformation(), traceEngine.getProgressStatus()); //$NON-NLS-1$
+
+ // Handling HeapDump query-specific logic related to the error
+ switch (error){
+ case HEAP_NOT_FOUND:{
+ errorMessage = ERROR_HEAP_NOT_FOUND;
+ this.receivedHeap = null;
+ break;
+ }
+ }
+
+ // Advising user to install launcher component to the device
+ UiUtils.showErrorDialogToUser(error, errorMessage, traceEngine.getProgressStatus());
+
+ }
+
+ /**
+ * Gets trace engine object instance.
+ * @return used TraceEngine-object
+ */
+ public TraceCoreEngine getTraceEngine() {
+ return traceEngine;
+ }
+
+
+ /**
+ * Sets thread info into comparedHeaps-table.
+ * @param firstHeap first compared heap
+ * @param secondHeap second compared heap
+ */
+ public void setComparedHeap( final ThreadInfo firstHeap, final ThreadInfo secondHeap ){
+ Runnable updateUiRunnable = new Runnable(){
+ public void run(){
+ comparedHeapsTable.removeAll();
+ TableItem firstItem = new TableItem(comparedHeapsTable, SWT.NONE, 0 );
+ TableItem secondItem = new TableItem(comparedHeapsTable, SWT.NONE, 1 );
+
+ // get date formatter
+ SimpleDateFormat formatter = new SimpleDateFormat ( MemSpyFileOperations.DATEFORMAT );
+ if( firstHeap != null){
+ firstItem.setText( new String[]{ firstHeap.getThreadName(), formatter.format( firstHeap.getDate() ) } );
+ }
+ if( secondHeap != null ){
+ secondItem.setText( new String[]{ secondHeap.getThreadName(), formatter.format( secondHeap.getDate() ) } );
+ }
+
+ }
+
+ };
+ Display.getDefault().asyncExec(updateUiRunnable);
+ }
+
+ /**
+ * setThreadListSelection.
+ * Sets thread list selection into given index and updates thread list selection into importedHeapTable if needed
+ * @param thread Thread information.
+ */
+ public void setThreadListSelection( final ThreadInfo thread ){
+ Runnable updateUiRunnable = new Runnable(){
+ public void run(){
+ if( pageType == PageType.COMPARE_SECOND_HEAP ){
+ ThreadInfo importedThread = thread.clone();
+
+ importedHeapTable.removeAll();
+ // Get selected item from deviceThread
+ TableItem importedItem = new TableItem( importedHeapTable, SWT.NONE, 0 );
+
+ // copy selected item data into importedThread
+ importedItem.setText(new String[]{ importedThread.getThreadName(), importedThread.getStatus() });
+ importedItem.setData(importedThread);
+
+ // select thread in importedHeapTable
+ importedHeapTable.setSelection( 0 );
+
+ enableAndDisableGetHeapButton();
+ }
+ }
+
+ };
+ Display.getDefault().asyncExec(updateUiRunnable);
+ }
+
+ /**
+ * setDeviceThreadList.
+ * @param deviceThreadList new deviceThreadList
+ */
+ public void setDeviceThreadList(ArrayList deviceThreadList) {
+ this.deviceThreadList = deviceThreadList;
+ }
+
+ /**
+ * getRecentHeap
+ * @return last received Heap's thread info.
+ */
+ public ThreadInfo getRecentHeap(){
+ if( this.deviceRadioButton.getSelection() ){
+ if( receivedHeaps.size() > 0 ){
+ ThreadInfo returnValue = receivedHeaps.get( receivedHeaps.size()-1 );
+ return returnValue;
+ }
+ else{
+ return null;
+ }
+ }
+ else{
+ if(comparedThread != null ){
+ return comparedThread;
+ }
+ else{
+ return null;
+ }
+ }
+ }
+
+ /**
+ * getImportedHeaps.
+ * @return imported heaps
+ */
+ public ArrayList getImportedHeaps() {
+ if( this.deviceRadioButton.getSelection() ){
+ return receivedHeaps;
+ }
+ else{
+ return fileThreadList;
+ }
+ }
+
+ /**
+ * updateConnectionSettings.
+ * Updates new connection settings to UI
+ */
+ public void updateConnectionSettings() {
+ this.updateConnectionText();
+ }
+
+ /**
+ * setImportedThreadTableVisible.
+ * Shows/Hides importedHeapTable
+ * @param value true if importedHeapsTable should be shown.
+ */
+ public void setImportedThreadTableVisible( boolean value ){
+ if( this.pageType == PageType.COMPARE_SECOND_HEAP ){
+
+ deviceThreadTableGridData.exclude = value;
+ deviceThreadTable.setVisible( !value );
+
+ importedHeapTableGridData.exclude = !value;
+ importedHeapTable.setVisible( value );
+
+ loadThreadListGridData.exclude = value;
+ loadThreadListButton.setVisible( !value );
+
+ connectionButtonGridData.exclude = value;
+ connectionSettingsButton.setVisible( !value );
+
+ connectionGridData.exclude = value;
+ connectionTextLabel.setVisible( !value );
+
+ connectionNameInUseGridData.exclude = value;
+ connectionNameInUseLabel.setVisible( !value );
+
+ threadFilterGridData.exclude = value;
+ threadFilterText.setVisible( !value );
+
+ threadFilterTypesGridData.exclude = value;
+ threadFilterTypesCombo.setVisible( !value );
+
+ if( value == true ){
+
+ threadButtonGroup.setLayoutData( new GridData( GridData.FILL_BOTH));
+ }
+ else{
+ threadButtonGroup.setLayoutData( new GridData( GridData.VERTICAL_ALIGN_CENTER));
+
+ }
+ threadButtonGroup.layout();
+
+
+ }
+
+ threadSelectionGroup.layout();
+ threadListGroup.layout();
+
+ enableAndDisableGetHeapButton();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+
+ Composite composite = new Composite(parent, SWT.NULL);
+
+ // create the desired layout for this wizard page
+ GridLayout gl = new GridLayout();
+ gl.numColumns = 1;
+ composite.setLayout(gl);
+
+ if( this.pageType == PageType.COMPARE_FIRST_HEAP || this.pageType == PageType.COMPARE_SECOND_HEAP ){
+ GridLayout compareGroupGridLayout = new GridLayout();
+ compareGroupGridLayout.numColumns = 2;
+ compareGroup = new Group(composite, SWT.NONE);
+ compareGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ compareGroup.setText(COMPARE_HEAPS);
+ compareGroup.setLayout(compareGroupGridLayout);
+
+
+ // Table that contains all thread names and id's
+ comparedHeapsTable = new Table(compareGroup, SWT.BORDER);
+ TableColumn heapNameColumn = new TableColumn(comparedHeapsTable, SWT.LEFT);
+ heapNameColumn.setText(THREAD_NAME_TEXT);
+ heapNameColumn.setWidth(200);
+ TableColumn receivedColumn = new TableColumn(comparedHeapsTable, SWT.LEFT);
+ receivedColumn.setText(HEAP_DUMP_RECEIVED);
+ receivedColumn.setWidth(150);
+ comparedHeapsTable.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ comparedHeapsTable.setHeaderVisible(true);
+
+
+ TableItem newItem = new TableItem(comparedHeapsTable, SWT.NONE,0);
+ newItem.setText( new String[]{ "", "" } );
+ TableItem newItem1 = new TableItem(comparedHeapsTable, SWT.NONE,1);
+ newItem1.setText( new String[]{ "", "" } );
+
+
+ }
+
+
+ // Radio button group
+ GridLayout radioButtonGroupGridLayout = new GridLayout();
+ radioButtonGroup = new Group(composite, SWT.NONE);
+ radioButtonGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ radioButtonGroup.setText(GET_HEAP_RADIO_BUTTON);
+ radioButtonGroup.setLayout(radioButtonGroupGridLayout);
+ GridData radioButtonGridData = new GridData(GridData.FILL_HORIZONTAL);
+ radioButtonGridData.horizontalSpan = 2;
+
+ // Heap Dump File radio button
+ fileRadioButton = new Button(radioButtonGroup, SWT.RADIO);
+ fileRadioButton.setText(GET_HEAP_FROM_FILE_RADIO_BUTTON);
+ fileRadioButton.setLayoutData(radioButtonGridData);
+ fileRadioButton.addSelectionListener(this);
+ fileRadioButton.setSelection(true);
+
+ // From Device via TraceViewer radio button
+ deviceRadioButton = new Button(radioButtonGroup, SWT.RADIO);
+ deviceRadioButton.setText(GET_HEAP_FROM_DEVICE_RADIO_BUTTON);
+ deviceRadioButton.setLayoutData(radioButtonGridData);
+ deviceRadioButton.addSelectionListener(this);
+ deviceRadioButton.setSelection(false);
+
+ // In case trace plugin is not available, disabling import from device selection
+ if(!MemSpyPlugin.isTraceProviderAvailable()){
+ deviceRadioButton.setEnabled(false);
+ }
+
+ // File selection group
+
+ fileSelectionGroup = new Group(composite, SWT.NONE);
+ GridLayout fileSelectionGridLayout = new GridLayout();
+ fileSelectionGridLayout.numColumns = 1;
+
+ fileSelectionGridData = new GridData(GridData.FILL_BOTH);
+ fileSelectionGroup.setLayoutData(fileSelectionGridData);
+ fileSelectionGroup.setLayout(fileSelectionGridLayout);
+ fileSelectionGroup.setText(SELECT_FILE_TEXT);
+
+ // File location composite
+ fileLocationGroup = new Composite(fileSelectionGroup, SWT.NONE);
+ GridLayout fileLocationGridLayout = new GridLayout();
+ fileLocationGridLayout.numColumns = 2;
+ GridData fileLocationGridData = new GridData(GridData.FILL_HORIZONTAL);
+ fileLocationGroup.setLayoutData(fileLocationGridData);
+ fileLocationGroup.setLayout(fileLocationGridLayout);
+
+ // Define location label
+ Label defineFileLocation = new Label(fileLocationGroup, SWT.NONE);
+ defineFileLocation.setText( HEAP_DUMP_LOCATION_TEXT );
+ GridData defineFileLocationGridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ defineFileLocationGridData.horizontalSpan = 2;
+ defineFileLocation.setLayoutData(defineFileLocationGridData);
+
+ // File location combo
+ fileCombo = new Combo(fileLocationGroup, SWT.BORDER);
+ GridData fileDataGrid = new GridData(GridData.FILL_HORIZONTAL);
+
+ fileCombo.setLayoutData(fileDataGrid);
+ fileCombo.addModifyListener(this);
+
+ // Browse-button
+ buttonBrowseFile = new Button(fileLocationGroup, SWT.PUSH);
+ buttonBrowseFile.setText(BROWSE_TEXT);
+ buttonBrowseFile.addSelectionListener(this);
+
+ // File location group
+ fileThreadListGroup = new Composite(fileSelectionGroup, SWT.NONE);
+ GridLayout fileThreadListGridLayout = new GridLayout();
+ fileThreadListGridLayout.numColumns = 1;
+
+ GridData fileThreadListGridData = new GridData(GridData.FILL_BOTH);
+ fileThreadListGroup.setLayoutData(fileThreadListGridData);
+ fileThreadListGroup.setLayout(fileThreadListGridLayout);
+
+
+ // Define location label
+ Label threadsFromFileLabel = new Label(fileThreadListGroup, SWT.NONE);
+ if( this.pageType == PageType.IMPORT_PAGE ){
+ threadsFromFileLabel.setText( HEAP_CONTAINS_TEXT_IMPORT );
+ }
+ else{
+ threadsFromFileLabel.setText( HEAP_CONTAINS_TEXT_COMPARE );
+ }
+ threadsFromFileLabel.setLayoutData( new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING) );
+
+ // Threads from file table
+ fileThreadTable = new Table(fileThreadListGroup, SWT.BORDER);
+ TableColumn nameColumn = new TableColumn(fileThreadTable, SWT.LEFT);
+ nameColumn.setText(THREAD_NAME_TEXT);
+ nameColumn.setWidth(250);
+ fileThreadTable.setLayoutData(new GridData(GridData.FILL_BOTH));
+ fileThreadTable.setHeaderVisible(true);
+ fileThreadTable.setItemCount(5);
+
+ if( this.pageType == PageType.COMPARE_FIRST_HEAP || this.pageType == PageType.COMPARE_SECOND_HEAP ){
+ fileThreadTable.addSelectionListener(this);
+ }
+
+
+ // Thread Selection group
+
+ threadSelectionGroup = new Group(composite, SWT.NONE);
+ GridLayout threadSelectionGridLayout = new GridLayout();
+ threadSelectionGridLayout.numColumns = 2;
+
+
+ threadSelectionGridData = new GridData(GridData.FILL_BOTH);
+ threadSelectionGroup.setLayoutData(threadSelectionGridData);
+ threadSelectionGroup.setLayout(threadSelectionGridLayout);
+ threadSelectionGroup.setText(SELECT_THREAD_TEXT);
+
+ // Thread list Group
+ threadListGroup = new Composite(threadSelectionGroup, SWT.NONE);
+ GridLayout threadListLayout = new GridLayout();
+ threadListLayout.numColumns = 2;
+ threadListGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
+ threadListGroup.setLayout(threadListLayout);
+
+ // Filter text field.
+ threadFilterText = new Text(threadListGroup, SWT.BORDER);
+ threadFilterText.setText("type filter text");
+ threadFilterGridData = new GridData(GridData.FILL_HORIZONTAL);
+ threadFilterGridData.grabExcessHorizontalSpace = true;
+ threadFilterGridData.grabExcessVerticalSpace = false;
+ threadFilterGridData.verticalAlignment = SWT.TOP;
+ threadFilterText.setLayoutData(threadFilterGridData);
+
+ threadFilterText.addModifyListener(this);
+
+ // Filter selection combo.
+ threadFilterTypesCombo = new Combo(threadListGroup, SWT.BORDER|SWT.READ_ONLY);
+ threadFilterTypesCombo.setItems(new String[]{"Starts with", "Contains"});
+ threadFilterTypesGridData = new GridData();
+ threadFilterTypesGridData.widthHint = 100;
+ threadFilterTypesCombo.select(0);
+ threadFilterTypesCombo.setLayoutData(threadFilterTypesGridData);
+
+ threadFilterTypesCombo.addSelectionListener(this);
+
+ // Table that contains all thread names and id's
+ deviceThreadTable = new Table(threadListGroup, SWT.BORDER);
+
+ TableColumn deviceThreadColumn = new TableColumn(deviceThreadTable, SWT.LEFT);
+ deviceThreadColumn.setText(THREAD_NAME_TEXT);
+ deviceThreadColumn.setWidth(200);
+ TableColumn receivedColumn = new TableColumn(deviceThreadTable, SWT.LEFT);
+ receivedColumn.setText(HEAP_DUMP_RECEIVED);
+ receivedColumn.setWidth(150);
+ deviceThreadTableGridData = new GridData(GridData.FILL_BOTH);
+ deviceThreadTableGridData.horizontalSpan = 2;
+ deviceThreadTable.setLayoutData( deviceThreadTableGridData );
+ deviceThreadTable.setHeaderVisible(true);
+ deviceThreadTable.addSelectionListener( this );
+
+ if( this.pageType == PageType.COMPARE_SECOND_HEAP ){
+ // Table where first imported heaps name is presented
+ importedHeapTable = new Table( threadListGroup, SWT.BORDER );
+ TableColumn importedThreadNameColumn = new TableColumn( importedHeapTable, SWT.LEFT );
+ importedThreadNameColumn.setText( THREAD_NAME_TEXT );
+ importedThreadNameColumn.setWidth( 200 );
+ TableColumn importedWhenColumn = new TableColumn( importedHeapTable, SWT.LEFT );
+ importedWhenColumn.setText( HEAP_DUMP_RECEIVED );
+ importedWhenColumn.setWidth( 150 );
+ //importedHeapTableGridData = new GridData(GridData.GRAB_VERTICAL);
+ importedHeapTableGridData = new GridData(GridData.FILL_HORIZONTAL);
+ importedHeapTable.setLayoutData( importedHeapTableGridData );
+ importedHeapTable.setHeaderVisible( true );
+ importedHeapTable.addSelectionListener( this );
+ }
+
+ // Thread button group
+ threadButtonGroup = new Composite(threadSelectionGroup, SWT.NONE);
+ GridLayout threadButtonLayout = new GridLayout();
+ threadButtonLayout.numColumns = 1;
+
+ GridData threadButtonGridData = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
+ threadButtonGroup.setLayoutData(threadButtonGridData);
+ threadButtonGroup.setLayout(threadButtonLayout);
+
+ loadThreadListButton = new Button(threadButtonGroup, SWT.PUSH);
+ loadThreadListGridData = new GridData(GridData.FILL_HORIZONTAL);
+ loadThreadListButton.setLayoutData( loadThreadListGridData );
+ loadThreadListButton.setText(LOAD_REFRESH_THREAD_LIST_BUTTON);
+ loadThreadListButton.addSelectionListener( this );
+
+ // Connection settings button
+
+ connectionSettingsButton = new Button(threadButtonGroup, SWT.PUSH);
+ connectionButtonGridData = new GridData(GridData.FILL_HORIZONTAL);
+ connectionSettingsButton.setLayoutData( connectionButtonGridData );
+ connectionSettingsButton.setText(CONNECTION_SETTINGS_BUTTON);
+ connectionSettingsButton.addSelectionListener(this);
+
+ // Connection settings labels
+ connectionTextLabel = new Label(threadButtonGroup, SWT.LEFT);
+ connectionTextLabel.setText(CURRENTLY_USING_TEXT);
+ connectionGridData = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
+ connectionTextLabel.setLayoutData( connectionGridData );
+
+ connectionNameInUseLabel = new Label(threadButtonGroup, SWT.LEFT);
+ connectionNameInUseGridData = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
+ connectionNameInUseLabel.setLayoutData( connectionNameInUseGridData );
+
+ // Get Heap button
+
+ getHeapButton = new Button(threadButtonGroup, SWT.PUSH);
+ getHeapButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ getHeapButton.setText(GET_HEAP_NOW_BUTTON);
+ getHeapButton.addSelectionListener( this );
+ this.enableAndDisableGetHeapButton();
+
+ if( this.pageType == PageType.IMPORT_PAGE ){
+ heapsReceivedLabel = new Label(threadButtonGroup, SWT.LEFT);
+ heapsReceivedLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
+ heapsReceivedLabel.setText( "0" + HEAP_DUMPS_RECEIVED );
+ }
+ // load saved user entered data.
+ this.loadUserEnteredData();
+
+ // update buttons and texts on screen.
+ this.updateConnectionText();
+ this.hideAndRevealItems();
+ this.setImportedThreadTableVisible( false );
+
+ setHelps();
+ setInitialFocus();
+ setControl(composite);
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see com.nokia.s60tools.memspy.ui.wizards.MemSpyTraceListener#operationFinished(com.nokia.s60tools.memspy.ui.wizards.MemSpyTraceListener.LauncherAction, com.nokia.s60tools.memspy.containers.SWMTLogInfo)
+ */
+ public void operationFinished(LauncherAction action, SWMTLogInfo swmtLogInfo, boolean timerRunning) {
+ // Can be left empty.
+
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.nokia.s60tools.memspy.ui.wizards.MemSpyTraceListener#startedReceivingSWMTLog()
+ */
+ public void startedReceivingSWMTLog() {
+ // Can be left empty.
+
+ }
+
+ private void loadThreadListButtonPressed(){
+ deviceThreadList.clear();
+ if( traceEngine.requestThreadList( deviceThreadList, (DeviceOrFileSelectionPage)getWizard().getContainer().getCurrentPage() ) ){
+ try {
+ getContainer().run(true, false, receiveThreadListProcess);
+ } catch (InvocationTargetException e1) {
+ e1.printStackTrace();
+ } catch (InterruptedException e1) {
+ e1.printStackTrace();
+ }
+ }
+ else{
+ MessageDialog.openError( this.getShell(), ERROR_MEMSPY, ERROR_CONNECTION);
+ }
+ }
+
+ /**
+ * getHeapButtonPressed.
+ * Method that is called when "Get Heap Now"-button is pressed.
+ */
+ private void getHeapButtonPressed(){
+ // Imported thread is loaded, if it is importedHeapTable is visible.
+ ThreadInfo thread;
+ if(this.pageType == PageType.COMPARE_SECOND_HEAP && importedHeapTable.isVisible()) {
+ if(importedHeapTable.getSelectionIndex() == -1) {
+ // No selection, nothing to do.
+ return;
+ }
+ thread = (ThreadInfo)importedHeapTable.getSelection()[0].getData();
+ } else {
+ if(deviceThreadTable.getSelectionIndex() == -1) {
+ // No selection, nothing to do.
+ return;
+ }
+ thread = (ThreadInfo)deviceThreadTable.getSelection()[0].getData();
+ }
+
+ // if thread name contains text "drm" it cannot be requested because of security reasons
+ if( thread.getThreadName().toLowerCase().contains("drm") ){
+ MessageDialog.openError( this.getShell(), ERROR_MEMSPY, ERROR_DRM_THREAD);
+ return;
+ }
+ // if thread name contains text "dbgtrcserver::!DbgTrcServer" it cannot be requested because of TraceCore
+ else if(thread.getThreadName().toLowerCase().contains("dbgtrcserver::!dbgtrcserver") ){
+ MessageDialog.openError( this.getShell(), ERROR_MEMSPY, ERROR_DBGTRS_THREAD);
+ return;
+ }
+
+ String threadID = thread.getThreadID();
+ Date date = new Date();
+ String threadName = thread.getThreadName();
+
+ // Get file name for heap dump from engine
+ String filePath = MemSpyFileOperations.getFileNameForTempHeapDump( threadName, date);
+
+ // Add new file into receivedHeaps-ArrayList
+ receivedHeap = new ThreadInfo();
+ receivedHeap.setThreadFilePath(filePath);
+ receivedHeap.setThreadID(threadID);
+ receivedHeap.setThreadName(threadName);
+ receivedHeap.setDate(date);
+ receivedHeap.setType(HeapDumpType.DEVICE);
+
+
+ if( traceEngine.requestHeapDump( threadID, this, filePath ) ){
+
+ try {
+ getContainer().run(true, false, receiveHeapProcess);
+ } catch (InvocationTargetException e1) {
+ // do nothing
+ e1.printStackTrace();
+ } catch (InterruptedException e1) {
+ // do nothing
+ e1.printStackTrace();
+ }
+ }
+ else{
+ MessageDialog.openError( this.getShell(), ERROR_MEMSPY, ERROR_CONNECTION);
+ receivedHeap = null;
+ }
+
+ getWizard().getContainer().updateButtons();
+
+ }
+
+ /**
+ * createMemSpyProcesses.
+ * Creates MemSpy operation processes.
+ */
+ private void createMemSpyProcesses(){
+
+ // receive thread list process
+ receiveThreadListProcess = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) {
+ memSpyOperationRunning = true;
+ monitor.beginTask(RECEIVING_THREAD_LIST, IProgressMonitor.UNKNOWN);
+ while(true){
+ // some delay, so that launcher has time to set it's state correct.
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ // do nothing
+ }
+ if( !memSpyOperationRunning ){
+ break;
+ }
+ }
+ monitor.done();
+ }
+ };
+
+ // receive heap process.
+ receiveHeapProcess = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) {
+ memSpyOperationRunning = true;
+ monitor.beginTask(RECEIVING_HEAP_DUMP, IProgressMonitor.UNKNOWN);
+ while(true){
+ // some delay
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ // do nothing
+ }
+ if( !memSpyOperationRunning ){
+ break;
+ }
+
+ }
+ monitor.done();
+
+ }
+ };
+ }
+
+ /**
+ * setHeapDumpFile.
+ * Sets parameter test to file combo box, selects file radio button and disables UI-components
+ * @param newFilePath new file path.
+ */
+ public void setHeapDumpFile( final String newFilePath ){
+ Runnable updateUiRunnable = new Runnable(){
+ public void run(){
+
+ if( deviceRadioButton.getSelection() ){
+ // select file system-radio button
+ fileRadioButton.setSelection(true);
+ deviceRadioButton.setSelection(false);
+ hideAndRevealItems();
+ }
+ // set text to file location combo box
+ fileCombo.setText( newFilePath );
+
+ // set selection buttons disabled.
+ fileCombo.setEnabled( false );
+ buttonBrowseFile.setEnabled( false );
+ deviceRadioButton.setEnabled(false);
+
+
+ }
+ };
+ Display.getDefault().asyncExec(updateUiRunnable);
+
+ }
+
+ /**
+ * getSelectedFilePath.
+ * @return text value from file combo box.
+ */
+ public String getSelectedFilePath(){
+ return fileCombo.getText();
+ }
+
+ /**
+ * resetFileCombo.
+ * sets text field in file combo box empty.
+ */
+ public void resetFileCombo(){
+ Runnable updateUiRunnable = new Runnable(){
+ public void run(){
+ fileCombo.setText( "" );
+ }
+ };
+ Display.getDefault().asyncExec(updateUiRunnable);
+ }
+
+
+ /**
+ * Sets this page's context sensitive helps
+ *
+ */
+ protected void setHelps() {
+
+ String helpContextId = null;
+ if( this.pageType == PageType.IMPORT_PAGE ){
+ helpContextId = HelpContextIDs.MEMSPY_IMPORT_HEAP;
+ }
+ else{
+ helpContextId = HelpContextIDs.MEMSPY_IMPORT_COMPARE;
+ }
+ PlatformUI.getWorkbench().getHelpSystem().setHelp( deviceRadioButton, helpContextId );
+ PlatformUI.getWorkbench().getHelpSystem().setHelp( fileRadioButton, helpContextId);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp( fileCombo, helpContextId);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp( fileThreadTable, helpContextId);
+
+ PlatformUI.getWorkbench().getHelpSystem().setHelp( loadThreadListButton, helpContextId );
+ PlatformUI.getWorkbench().getHelpSystem().setHelp( connectionSettingsButton, helpContextId);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp( getHeapButton, helpContextId);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp( deviceThreadTable, helpContextId);
+
+ }
+
+
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/wizards/ExportFileNamePage.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/wizards/ExportFileNamePage.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,233 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+package com.nokia.s60tools.memspy.ui.wizards;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.ui.PlatformUI;
+
+import com.nokia.s60tools.memspy.model.UserEnteredData;
+import com.nokia.s60tools.memspy.model.UserEnteredData.ValueTypes;
+import com.nokia.s60tools.memspy.resources.HelpContextIDs;
+import com.nokia.s60tools.ui.wizards.S60ToolsWizardPage;
+
+public class ExportFileNamePage extends S60ToolsWizardPage implements ModifyListener, SelectionListener{
+
+ // UI-components
+ private Combo fileCombo;
+ private Button buttonBrowseFile;
+
+ // Strings
+ private final static String REPORT_LOCATION_TEXT = "File Location";
+ private final static String BROWSE_TEXT = "Browse...";
+ private final static String FILE_SELECTION_DIALOG_TEXT = "Define location for exported file.";
+ private final static String OUTPUT_FILE_TEXT = "Output file";
+ private final static String DESCRIPTION_TEXT = "Define file name for exported comparison report file(xls-file).";
+
+ /*
+ * (non-Javadoc)
+ * @see com.nokia.s60tools.ui.wizards.S60ToolsWizardPage#setInitialFocus()
+ */
+ public void setInitialFocus() {
+ fileCombo.setFocus();
+ }
+
+
+
+ /*
+ * (non-Javadoc)
+ * @see com.nokia.s60tools.ui.wizards.S60ToolsWizardPage#recalculateButtonStates()
+ */
+ public void recalculateButtonStates() {
+ }
+
+ /**
+ * ExportFileNamePage
+ * constructor
+ * @param pageName name of the page
+ */
+ protected ExportFileNamePage(String pageName) {
+ super(pageName);
+ setTitle(OUTPUT_FILE_TEXT);
+ setDescription(DESCRIPTION_TEXT);
+ }
+
+ public void createControl(Composite parent) {
+ // Radio button group
+ Composite composite = new Composite(parent, SWT.NULL);
+
+ // create the desired layout for this wizard page
+ GridLayout gl = new GridLayout();
+ gl.numColumns = 1;
+ composite.setLayout(gl);
+
+ // file location group
+ Group fileLocationGroup = new Group(composite, SWT.NONE);
+ fileLocationGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
+ GridLayout fileLocationLayout = new GridLayout();
+ fileLocationLayout.numColumns = 2;
+ fileLocationGroup.setLayout( fileLocationLayout );
+ fileLocationGroup.setText( REPORT_LOCATION_TEXT );
+
+ // file combo
+ fileCombo = new Combo(fileLocationGroup, SWT.BORDER);
+ GridData fileDataGrid = new GridData(GridData.FILL_HORIZONTAL);
+ fileCombo.setLayoutData(fileDataGrid);
+ fileCombo.addModifyListener(this);
+
+ // browse button
+ buttonBrowseFile = new Button(fileLocationGroup, SWT.PUSH);
+ buttonBrowseFile.setText(BROWSE_TEXT);
+ buttonBrowseFile.addSelectionListener(this);
+
+ // load previous value
+ this.loadUserEnteredData();
+
+ setHelps();
+ setInitialFocus();
+ setControl(composite);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ public void modifyText(ModifyEvent event) {
+
+ if (event.widget.equals(fileCombo)) {
+ try {
+ getWizard().getContainer().updateButtons();
+ } catch (Exception e) {
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetDefaultSelected(SelectionEvent arg0) {
+
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetSelected(SelectionEvent e) {
+ if (e.widget == buttonBrowseFile) {
+ // open file dialog for selecting a crash file
+ FileDialog dialog = new FileDialog(this.getShell(), SWT.SAVE );
+ dialog.setText(FILE_SELECTION_DIALOG_TEXT);
+ String[] filterExt = { "*.xls" };
+ dialog.setFilterExtensions(filterExt);
+
+ dialog.setFilterPath(fileCombo.getText());
+ String result = dialog.open();
+
+ // add xls-end if needed
+ if( !result.endsWith( ".xls" ) ){
+ result += ".xls";
+ }
+
+
+
+ fileCombo.setText(result);
+
+ }
+
+ }
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.wizard.WizardPage#canFlipToNextPage()
+ */
+ public boolean canFlipToNextPage() {
+ if( fileCombo.getText() != "" ){
+ return true;
+ }
+ else {
+ return false;
+
+ }
+
+ }
+
+ /**
+ * loadUserEnteredData
+ * loads previous values into UI components
+ */
+ private void loadUserEnteredData(){
+ UserEnteredData data = new UserEnteredData();
+
+ // Restore previous values to file combobox
+ String[] lastUsedFiles = data.getPreviousValues(ValueTypes.OUTPUT_FILE);
+ if (lastUsedFiles != null) {
+ fileCombo.setItems(lastUsedFiles);
+ fileCombo.select(0);
+ }
+
+
+
+ }
+
+ /**
+ * saveUserEnteredData
+ * Saves current user entered data from UI components
+ */
+ public void saveUserEnteredData(){
+ UserEnteredData data = new UserEnteredData();
+
+ // Save file combo box
+ String item = fileCombo.getText();
+ data.saveValue(ValueTypes.OUTPUT_FILE, item);
+ }
+
+ /**
+ * getOutputFileName
+ * @return output file name
+ */
+ public String getOutputFileName(){
+ return fileCombo.getText();
+ }
+
+ /**
+ * Sets this page's context sensitive helps
+ *
+ */
+ protected void setHelps() {
+ PlatformUI.getWorkbench().getHelpSystem().setHelp( fileCombo, HelpContextIDs.MEMSPY_IMPORT_COMPARE);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp( buttonBrowseFile, HelpContextIDs.MEMSPY_IMPORT_COMPARE);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp( buttonBrowseFile, HelpContextIDs.MEMSPY_IMPORT_COMPARE);
+
+ }
+
+
+}
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/wizards/MemSpyWizard.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/wizards/MemSpyWizard.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,641 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+package com.nokia.s60tools.memspy.ui.wizards;
+
+
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.ui.IWorkbench;
+
+import com.nokia.s60tools.memspy.containers.SWMTLogInfo;
+import com.nokia.s60tools.memspy.containers.ThreadInfo;
+import com.nokia.s60tools.memspy.model.AnalyserXMLGenerator;
+import com.nokia.s60tools.memspy.model.ImportEngine;
+import com.nokia.s60tools.memspy.model.MemSpyFileOperations;
+import com.nokia.s60tools.memspy.model.TraceCoreEngine;
+import com.nokia.s60tools.memspy.model.UserEnteredData.ValueTypes;
+import com.nokia.s60tools.memspy.resources.ImageKeys;
+import com.nokia.s60tools.memspy.resources.ImageResourceManager;
+import com.nokia.s60tools.memspy.ui.views.MemSpyMainView;
+import com.nokia.s60tools.memspy.ui.wizards.DeviceOrFileSelectionPage.PageType;
+import com.nokia.s60tools.memspy.ui.wizards.SelectActionPage.MemSpyAction;
+import com.nokia.s60tools.ui.wizards.S60ToolsWizard;
+import com.nokia.s60tools.util.debug.DbgUtility;
+
+public class MemSpyWizard extends S60ToolsWizard {
+
+ public enum MemSpyWizardType{ FULL, COMPARE, SYMBOLS };
+
+ static private final ImageDescriptor bannerImgDescriptor = ImageResourceManager.getImageDescriptor(ImageKeys.IMG_WIZARD);
+
+
+ SelectActionPage selectActionPage;
+ DeviceOrFileSelectionPage importHeapPage;
+ DeviceOrFileSelectionPage compareHeapsFirstPage;
+ DeviceOrFileSelectionPage compareHeapsSecondPage;
+ ParameterFilesPage parameterFilesPage;
+ ExportFileNamePage exportFileNamePage;
+ SWMTLogPage swmtLogPage;
+ MemSpyMainView mainView;
+ ImportEngine importEngine;
+ MemSpyWizardDialog wizDialog;
+
+ MemSpyWizardType wizardType;
+ TraceCoreEngine traceEngine;
+ AnalyserXMLGenerator fillValues;
+
+ private final static String IMPORTING_FILES = "Importing Files";
+
+ public MemSpyWizard(){
+ super(bannerImgDescriptor);
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "MemSpyWizard constructor - start");
+
+ this.mainView = MemSpyMainView.showAndReturnYourself();
+ this.importEngine = mainView.getImportEngine();
+ this.setNeedsProgressMonitor(true);
+ this.traceEngine = new TraceCoreEngine();
+ this.wizardType = MemSpyWizardType.FULL;
+ this.fillValues = null;
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "MemSpyWizard constructor - end");
+
+ }
+
+ public MemSpyWizard( MemSpyWizardType wizardType, AnalyserXMLGenerator fillValues ) {
+ this();
+ this.wizardType = wizardType;
+ this.fillValues = fillValues;
+ if( wizardType != MemSpyWizardType.SYMBOLS ){
+ MemSpyMainView.showTraceViewer();
+ }
+ }
+
+
+ /**
+ * (non-Javadoc)
+ *
+ * @see com.nokia.s60tools.ui.wizards.S60ToolsWizard#addPages()
+ */
+ public void addPages() {
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "MemSpyWizard addpages - start");
+
+ // if wizard's type is full, add all pages.
+ if( wizardType == MemSpyWizardType.FULL ){
+
+ selectActionPage = new SelectActionPage("Select Action");
+ addPage(selectActionPage);
+
+ importHeapPage = new DeviceOrFileSelectionPage( "Get Heap From",
+ "Import Heap Wizard, step 1", "Define source for Heap Dump files. Logs can be imported from already existing files or from device via TraceViewer.", ValueTypes.IMPORT_HEAP,
+ PageType.IMPORT_PAGE, traceEngine );
+ addPage(importHeapPage);
+
+ compareHeapsFirstPage = new DeviceOrFileSelectionPage("Select First Heap",
+ "Compare Two Heaps Wizard, step 1", "Define source for first compared Heap Dump. Heap Dumps can be imported from already existing files\nor from device via TraceViewer.", ValueTypes.COMPARE_HEAP_FIRST_HEAP,
+ PageType.COMPARE_FIRST_HEAP, traceEngine);
+ addPage(compareHeapsFirstPage);
+
+ compareHeapsSecondPage = new DeviceOrFileSelectionPage("Select Second Heap",
+ "Compare Two Heaps Wizard, step 2", "Define source for second compared Heap Dump. Compared heap dumps must be from same thread.", ValueTypes.COMPARE_HEAP_SECOND_HEAP,
+ PageType.COMPARE_SECOND_HEAP, traceEngine);
+ addPage(compareHeapsSecondPage);
+
+ exportFileNamePage = new ExportFileNamePage("Define export file name");
+ addPage(exportFileNamePage);
+
+ parameterFilesPage = new ParameterFilesPage(null, null, "Import Heap Wizard, step 2");
+ addPage(parameterFilesPage);
+
+ swmtLogPage = new SWMTLogPage("Get SWMT-logs", traceEngine);
+ addPage(swmtLogPage);
+ }
+ // if wizard type is compare add only compare output and symbol pages.
+ else if( wizardType == MemSpyWizardType.COMPARE){
+
+ compareHeapsFirstPage = new DeviceOrFileSelectionPage("Select First Heap",
+ "Compare Two Heaps Wizard, step 1", "Define source for first compared Heap Dump. Heap Dumps can be imported from already existing files\nor from device via TraceViewer.", ValueTypes.COMPARE_HEAP_FIRST_HEAP,
+ PageType.COMPARE_FIRST_HEAP, traceEngine);
+ addPage(compareHeapsFirstPage);
+
+ // prefill path of compared Heap Dump to wizard page.
+ compareHeapsFirstPage.setHeapDumpFile( fillValues.getXMLSourceFile()[0] );
+
+ compareHeapsSecondPage = new DeviceOrFileSelectionPage("Select Second Heap",
+ "Compare Two Heaps Wizard, step 2", "Define source for second compared Heap Dump. Compared heap dumps must be from same thread.", ValueTypes.COMPARE_HEAP_SECOND_HEAP,
+ PageType.COMPARE_SECOND_HEAP, traceEngine);
+ addPage(compareHeapsSecondPage);
+
+ // reset file combo box text from second page.
+ compareHeapsSecondPage.resetFileCombo();
+
+ exportFileNamePage = new ExportFileNamePage("Define export file name");
+ addPage(exportFileNamePage);
+
+ parameterFilesPage = new ParameterFilesPage(fillValues.getXMLDebugMetaDataFile(), null, "Import Heap Wizard, step 2");
+ addPage(parameterFilesPage);
+
+
+
+
+ }
+ else if( wizardType == MemSpyWizardType.SYMBOLS ){
+ parameterFilesPage = new ParameterFilesPage( fillValues.getXMLDebugMetaDataFile(), fillValues.getXMLDebugMetaDataDirectory(), "Edit Symbol Definitions" );
+ addPage(parameterFilesPage);
+ }
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "MemSpyWizard addpages - end");
+
+ }
+
+ /**
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.wizard.Wizard#getNextPage(org.eclipse.jface.wizard.IWizardPage)
+ */
+ public IWizardPage getNextPage(IWizardPage page) {
+
+
+ if (page.equals( selectActionPage )) {
+
+ SelectActionPage SelectWizardPage = (SelectActionPage) page;
+ if ( SelectWizardPage.importHeapRadioButton.getSelection() ) {
+ return importHeapPage;
+ }
+ else if ( SelectWizardPage.compareTwoHeapsRadioButton.getSelection() ) {
+ return compareHeapsFirstPage;
+ }
+ else if ( SelectWizardPage.swmtRadioButton.getSelection() ) {
+ return swmtLogPage;
+ }
+ } else if ( page.equals(importHeapPage) ) {
+ return parameterFilesPage;
+ }
+
+ else if ( page.equals(compareHeapsFirstPage) ) {
+ return compareHeapsSecondPage;
+ }
+ else if ( page.equals(compareHeapsSecondPage ) ) {
+ return exportFileNamePage;
+ }
+ else if ( page.equals( exportFileNamePage ) ){
+ boolean setText = true;
+ File file = new File( exportFileNamePage.getOutputFileName());
+ if( file.exists() ){
+ // if file already exists confirm that user wants to overwrite it.
+ MessageBox messageBox = new MessageBox(this.getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
+ messageBox.setText( MemSpyMainView.WARNING_COMPARE );
+ messageBox.setMessage( MemSpyMainView.WARNING_FILE_EXISTS );
+ int buttonID = messageBox.open();
+ if (buttonID == SWT.NO) {
+ setText = false;
+ }
+ }
+ if( setText == false ){
+ return exportFileNamePage;
+ }
+ return parameterFilesPage;
+ }
+
+
+ return page;
+ }
+
+ /**
+ * (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#canFinish()
+ */
+ public boolean canFinish() {
+ if (this.getContainer().getCurrentPage() == parameterFilesPage) {
+ return parameterFilesPage.canFinish();
+ }
+ else if (this.getContainer().getCurrentPage() == swmtLogPage ){
+ return swmtLogPage.canFinish();
+ }
+ else {
+ return false;
+ }
+
+ }
+
+
+
+
+ /**
+ * (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+
+
+ public boolean performFinish() {
+
+ if( this.wizardType == MemSpyWizardType.FULL ){
+ // save form values
+ saveUserEnteredData();
+
+ IRunnableWithProgress importFiles = null;
+
+ // get selected action from first page.
+ final MemSpyAction action = selectActionPage.getAction();
+
+ importHeapPage.getTraceEngine().shutDownMemSpy();
+ // Initialize XML generator
+ AnalyserXMLGenerator generator = new AnalyserXMLGenerator();
+
+
+ if( action != MemSpyAction.SWMT ){
+
+ // read symbol definitions
+ this.getSymbolInformation(generator);
+
+ final AnalyserXMLGenerator finalGenerator = generator;
+
+ // if importing Heap Dump(s)
+ if( selectActionPage.getAction() == MemSpyAction.IMPORT_HEAP ){
+ final ArrayList importedHeaps = importHeapPage.getImportedHeaps();
+ importFiles = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) {
+ monitor.beginTask(IMPORTING_FILES, IProgressMonitor.UNKNOWN);
+
+ // import heaps
+ importEngine.importAndAnalyseHeap( importedHeaps, finalGenerator, true );
+ }
+ };
+ }//if Comparing heaps
+ else if( selectActionPage.getAction() == MemSpyAction.COMPARE_HEAPS ){
+
+ final ArrayList heaps = new ArrayList();
+
+ heaps.add( compareHeapsFirstPage.getRecentHeap() );
+ heaps.add( compareHeapsSecondPage.getRecentHeap() );
+ final String output = exportFileNamePage.getOutputFileName();
+
+ importFiles = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) {
+ monitor.beginTask(IMPORTING_FILES, IProgressMonitor.UNKNOWN);
+ // import heaps
+ importEngine.importAndAnalyseHeap( heaps, finalGenerator, false );
+ // compare heaps
+ importEngine.compareHeaps( heaps.get(0), heaps.get(1), finalGenerator, output );
+ }
+ };
+
+ }
+ }
+ else{ // if importing SWMT-logs
+ final ArrayList logList = swmtLogPage.getLogList();
+ final AnalyserXMLGenerator finalGenerator = generator;
+ importFiles = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) {
+ monitor.beginTask(IMPORTING_FILES, IProgressMonitor.UNKNOWN);
+
+ // import heaps if SWMT logging was also dumping heap data for thread(s)
+ final ArrayList importedHeaps = traceEngine.getImportedSWMTHeaps();
+ if(importedHeaps != null){
+ //Don't delete temp folder and files yet, SWMT import will do that
+ importEngine.importAndAnalyseHeap( importedHeaps, finalGenerator, false, false );
+ }
+
+ // import swmt-logs and delete temp files & folder
+ importEngine.importSWMTLogs( logList, true );
+
+ }
+ };
+ }
+ try {
+ getContainer().run(true, false, importFiles);
+ }
+ catch (InvocationTargetException e1) {
+ // do nothing
+ e1.printStackTrace();
+ }
+ catch (InterruptedException e1) {
+ // do nothing
+ e1.printStackTrace();
+ }
+ MemSpyMainView.showAndReturnYourself();
+ }
+ else if( this.wizardType == MemSpyWizardType.COMPARE ){
+
+ IRunnableWithProgress importFiles = null;
+
+ compareHeapsFirstPage.getTraceEngine().shutDownMemSpy();
+
+ // Initialize XML generator
+ AnalyserXMLGenerator generator = new AnalyserXMLGenerator();
+
+ // read symbol definitions
+ this.getSymbolInformation(generator);
+
+ final AnalyserXMLGenerator finalGenerator = generator;
+ final ThreadInfo secondHeap = compareHeapsSecondPage.getRecentHeap();
+
+ // create new ThreadInfo object and format combobox value from first compare page to it's
+ // threadFilePath variable.(We don't want to import that heap again as it has already
+ // been updated.)
+ ThreadInfo firstModifiedHeap = new ThreadInfo();
+ firstModifiedHeap.setThreadFilePath( compareHeapsFirstPage.getSelectedFilePath() );
+ firstModifiedHeap.setThreadName( secondHeap.getThreadName() );
+ final ThreadInfo firstHeap = firstModifiedHeap;
+
+ final String output = exportFileNamePage.getOutputFileName();
+
+ importFiles = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) {
+ monitor.beginTask(IMPORTING_FILES, IProgressMonitor.UNKNOWN);
+ ArrayList heaps = new ArrayList();
+ heaps.add( secondHeap );
+ importEngine.importAndAnalyseHeap(heaps, finalGenerator, false);
+ importEngine.compareHeaps( firstHeap, secondHeap, finalGenerator, output );
+ }
+ };
+
+
+ try {
+ getContainer().run(true, false, importFiles);
+ }
+ catch (InvocationTargetException e1) {
+ // do nothing
+ e1.printStackTrace();
+ }
+ catch (InterruptedException e1) {
+ // do nothing
+ e1.printStackTrace();
+ }
+ MemSpyMainView.showAndReturnYourself();
+
+ }
+ else if(this.wizardType == MemSpyWizardType.SYMBOLS ){
+
+ // read symbol definitions
+ this.getSymbolInformation(fillValues);
+
+ // send new symbols to Main View
+ IRunnableWithProgress importFiles = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) {
+ monitor.beginTask("Saving new symbol definitions", IProgressMonitor.UNKNOWN);
+ mainView.symbolsUpdated(fillValues);
+ monitor.done();
+ }
+ };
+
+
+ try {
+ getContainer().run(true, false, importFiles);
+ }
+ catch (InvocationTargetException e1) {
+ // do nothing
+ e1.printStackTrace();
+ }
+ catch (InterruptedException e1) {
+ // do nothing
+ e1.printStackTrace();
+ }
+ }
+ return true;
+ }
+
+ /**
+ * (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#performCancel()
+ */
+ public boolean performCancel() {
+ try {
+ if( this.wizardType == MemSpyWizardType.FULL){
+ this.saveUserEnteredData();
+ }
+
+ MemSpyMainView.showAndReturnYourself();
+
+ // delete temp files
+ MemSpyFileOperations.deleteTempMemSpyFiles();
+ traceEngine.shutDownMemSpy();
+ } catch (Exception e) {
+ // Some failure in above should not prevent user Canceling dialog
+ e.printStackTrace();
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "performCancel/exception: " + e);
+ }
+
+ return true;
+ }
+
+ /**
+ * (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#getPreviousPage(org.eclipse.jface.wizard.IWizardPage)
+ */
+ public IWizardPage getPreviousPage(IWizardPage page) {
+ if (page.equals(importHeapPage)) {
+ return selectActionPage;
+ } else if (page.equals(compareHeapsFirstPage)) {
+ return selectActionPage;
+ } else if (page.equals(compareHeapsSecondPage)) {
+ return compareHeapsFirstPage;
+ }
+ return page;
+ }
+
+ /**
+ * setComparedHeaps
+ * sets compared thread names into each compare page
+ */
+ public void setComparedHeaps(){
+
+ // get recent thread infos from compare heap pages
+ ThreadInfo firstHeap = null;
+ ThreadInfo secondHeap = null;
+
+ firstHeap = compareHeapsFirstPage.getRecentHeap();
+ secondHeap = compareHeapsSecondPage.getRecentHeap();
+
+ // save thread infos into compare pages
+ compareHeapsSecondPage.setComparedHeap(firstHeap, secondHeap);
+ compareHeapsFirstPage.setComparedHeap(firstHeap, secondHeap);
+ }
+
+ /**
+ * updateThreadLists
+ * updates tread lists into each file or device selection page
+ * @param threadList
+ */
+ public void updateThreadLists(ArrayList threadList){
+ // Each page gets new thread list so that status of threads won't change when another page is modified.
+ if(importHeapPage != null){
+ this.importHeapPage.setDeviceThreadList( copyThreadList( threadList ) );
+ this.importHeapPage.updateThreadList();
+ }
+ if(compareHeapsFirstPage != null){
+ this.compareHeapsFirstPage.setDeviceThreadList( copyThreadList( threadList ) );
+ this.compareHeapsFirstPage.updateThreadList();
+ }
+ if(compareHeapsFirstPage != null){
+ this.compareHeapsSecondPage.setDeviceThreadList( copyThreadList( threadList ) );
+ this.compareHeapsSecondPage.updateThreadList();
+ }
+ }
+
+ /**
+ * Copies threads to new list.
+ * @param threadList List to be copied.
+ * @return New list containing thread information in new list.
+ */
+ private ArrayList copyThreadList(ArrayList threadList) {
+ ArrayList returnList = new ArrayList();
+ for(ThreadInfo thread : threadList) {
+ returnList.add(thread.clone());
+ }
+ return returnList;
+ }
+
+ /**
+ * sets thread list selection and hides threadListTable from 2. comparePage
+ * @param thread Thread information.
+ */
+ public void setThreadListSelectionToComparePages( ThreadInfo thread ){
+ this.compareHeapsSecondPage.setThreadListSelection( thread );
+ }
+
+ /**
+ * shows or hides threadListTable in 2. comparePage
+ */
+ public void showImportedHeapsInComparePage( boolean value ){
+ this.compareHeapsSecondPage.setImportedThreadTableVisible( value );
+
+ }
+
+
+
+ /**
+ * Check if compared heaps are from same thread
+ * @return true if heaps are from same thread or other or both heaps are still undefined
+ */
+ public boolean areComparedHeapsFromSameThread(){
+ if( compareHeapsFirstPage.getRecentHeap() != null &&
+ compareHeapsSecondPage.getRecentHeap() != null ){
+ if( compareHeapsFirstPage.getRecentHeap().getThreadName().equals(compareHeapsSecondPage.getRecentHeap().getThreadName() ) ){
+ return true;
+ }
+ else{
+ return false;
+ }
+ }
+ else{
+ return true;
+ }
+
+ }
+
+
+ /**
+ * saveUserEnteredData
+ * calls saveUserEnteredData method of all wizard pages.
+ */
+ private void saveUserEnteredData(){
+
+ // Save form values so that they can be restored later
+ if( selectActionPage != null){
+ selectActionPage.saveUserEnteredData();
+ }
+ if( importHeapPage != null){
+ importHeapPage.saveUserEnteredData();
+ }
+ if( parameterFilesPage != null){
+ parameterFilesPage.saveUserEnteredData();
+ }
+ if( compareHeapsFirstPage != null){
+ compareHeapsFirstPage.saveUserEnteredData();
+ }
+ if( compareHeapsSecondPage != null){
+ compareHeapsSecondPage.saveUserEnteredData();
+ }
+ if( exportFileNamePage != null){
+ exportFileNamePage.saveUserEnteredData();
+ }
+ if( swmtLogPage != null){
+ swmtLogPage.saveUserEnteredData();
+ }
+ }
+
+ public void updateConnectionSettings(){
+ if( importHeapPage != null ){
+ this.importHeapPage.updateConnectionSettings();
+ }
+ if( compareHeapsFirstPage != null ){
+ this.compareHeapsFirstPage.updateConnectionSettings();
+ }
+ if( compareHeapsSecondPage != null ){
+ this.compareHeapsSecondPage.updateConnectionSettings();
+ }
+ if( swmtLogPage != null ){
+ this.swmtLogPage.updateConnectionSettings();
+ }
+
+ if(traceEngine != null){
+ // Resetting progress status in case connection settings have been changed
+ traceEngine.resetProgressStatus();
+ }
+
+ }
+
+ public void init(IWorkbench arg0, IStructuredSelection arg1) {
+
+ }
+
+ public void setData(MemSpyWizardDialog wizDialog){
+ this.wizDialog = wizDialog;
+ }
+
+ public void setCancelText( String newText ){
+ wizDialog.setCancelText( newText );
+ }
+
+ private void getSymbolInformation( AnalyserXMLGenerator symbolInfo ){
+
+ // combine map and symbol files into one String[] and set them into xmlGenerator
+ ArrayList debugMetaData;
+ String[] symbolFiles = parameterFilesPage.getSymbolFiles();
+ if( symbolFiles == null ){
+ debugMetaData = new ArrayList();
+ }
+ else{
+ debugMetaData = new ArrayList(Arrays.asList( symbolFiles ));
+ }
+ if( parameterFilesPage.getMapFilesZip().equals("") == false ){
+ debugMetaData.add( parameterFilesPage.getMapFilesZip() );
+ }
+
+ // Set meta data folder
+ symbolInfo.setXMLDebugMetaDataFile(debugMetaData.toArray(new String [debugMetaData.size()]));
+ if( parameterFilesPage.getMapFilesFolder().equals("") == false ){
+ symbolInfo.setXMLDebugMetaDataDirectory( parameterFilesPage.getMapFilesFolder() );
+ }
+ else{
+ symbolInfo.setXMLDebugMetaDataDirectory(null);
+ }
+
+ }
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/wizards/MemSpyWizardDialog.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/wizards/MemSpyWizardDialog.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+package com.nokia.s60tools.memspy.ui.wizards;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+
+public class MemSpyWizardDialog extends WizardDialog {
+ @Override
+ public void create() {
+ super.create();
+ }
+
+ public MemSpyWizardDialog(Shell parentShell, IWizard newWizard) {
+ super(parentShell, newWizard);
+ }
+
+ public void enableBackCancelButtons(boolean enable) {
+ getButton(IDialogConstants.BACK_ID).setEnabled(enable);
+ getButton(IDialogConstants.CANCEL_ID).setEnabled(enable);
+
+
+ }
+
+ public void setCancelText(String newText){
+ getButton(IDialogConstants.CANCEL_ID).setText(newText);
+
+ }
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/wizards/ParameterFilesPage.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/wizards/ParameterFilesPage.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,165 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+package com.nokia.s60tools.memspy.ui.wizards;
+
+import java.util.HashMap;
+
+import org.eclipse.swt.widgets.Composite;
+
+import com.nokia.s60tools.memspy.model.UserEnteredData;
+import com.nokia.s60tools.memspy.resources.HelpContextIDs;
+import com.nokia.s60tools.sdk.SdkUtils;
+import com.nokia.s60tools.ui.wizards.DebugMetadataWizardPage;
+
+
+/**
+ * class ParameterFilesPage
+ * This wizard page will query the user for locations symbol and map files.
+ */
+public class ParameterFilesPage extends DebugMetadataWizardPage {
+
+ private String[] symbolOrMapFiles;
+ private String mapFileDirectory;
+
+ private enum FileType{ SYMBOL, MAPFILE };
+
+
+ public ParameterFilesPage( String[] symbolOrMapFiles, String mapFileDirectory, String descriptionText ){
+ super("MemSpy", descriptionText, false, UserEnteredData.getParameterFilesSection(),
+ UserEnteredData.MAX_SAVED_VALUES);
+ this.symbolOrMapFiles = symbolOrMapFiles;
+ this.mapFileDirectory = mapFileDirectory;
+
+ }
+
+ public void createControl(Composite parent) {
+ super.createControl(parent);
+
+ // read symbolOrMapFiles-variables values and set them to UI items.
+
+ if( this.symbolOrMapFiles != null ){
+
+ //Reset Symbol file list-component
+ this.listSymbols.removeAll();
+
+
+ // Reset ui-components values
+
+ // set "No Map Files"-radio button selected.(and unselect other buttons)
+ this.buttonMapFilesFolderRadio.setSelection(false);
+ this.buttonMapFilesZipRadio.setSelection(false);
+ this.buttonSdkFolderRadio.setSelection(false);
+ this.buttonNoMapFilesRadio.setSelection(true);
+
+ // disable combo boxes and browse buttons buttons
+ this.comboMapFilesFolder.setEnabled(false);
+ this.buttonMapFolderBrowse.setEnabled(false);
+ this.comboMapFilesZip.setEnabled(false);
+ this.buttonZipBrowse.setEnabled(false);
+ this.comboSdkFolder.setEnabled(false);
+
+
+ for( String item : symbolOrMapFiles ){
+ if( getFileType(item) == FileType.SYMBOL ){
+ listSymbols.add(item);
+
+ }
+ else if(getFileType(item) == FileType.MAPFILE ){
+ comboMapFilesZip.setText(item);
+
+ // set zip-radio button selected.(and unselect other buttons)
+ this.buttonMapFilesFolderRadio.setSelection(false);
+ this.buttonMapFilesZipRadio.setSelection(true);
+ this.buttonSdkFolderRadio.setSelection(false);
+ this.buttonNoMapFilesRadio.setSelection(false);
+
+ // enable zip buttons
+ this.comboMapFilesFolder.setEnabled(false);
+ this.buttonMapFolderBrowse.setEnabled(false);
+ this.comboMapFilesZip.setEnabled(true);
+ this.buttonZipBrowse.setEnabled(true);
+ this.comboSdkFolder.setEnabled(false);
+ }
+ }
+
+ }
+ if( this.mapFileDirectory != null ){
+ comboMapFilesFolder.setText( mapFileDirectory );
+
+ // set folder-radio button selected.(and unselect other buttons)
+ this.buttonMapFilesFolderRadio.setSelection(true);
+ this.buttonMapFilesZipRadio.setSelection(false);
+ this.buttonSdkFolderRadio.setSelection(false);
+ this.buttonNoMapFilesRadio.setSelection(false);
+
+ // enable folder buttons
+ this.comboMapFilesFolder.setEnabled(true);
+ this.buttonMapFolderBrowse.setEnabled(true);
+ this.comboMapFilesZip.setEnabled(false);
+ this.buttonZipBrowse.setEnabled(false);
+ this.comboSdkFolder.setEnabled(false);
+
+ }
+ }
+
+ public boolean zipContainsMapFiles(String path) {
+ return SdkUtils.zipContainsMapFiles(path);
+ }
+
+ public String getHelpContext() {
+ return HelpContextIDs.MEMSPY_IMPORT_SYMBOLS;
+ }
+
+ public boolean canFlipToNextPage(){
+ return false;
+ }
+
+ public boolean canFinish() {
+ return canProceed();
+ }
+
+ public HashMap getSdkMapFolders() {
+ return SdkUtils.getSdkMapFileFolders(true);
+ }
+
+ private static FileType getFileType( String fileName ){
+ int index = fileName.lastIndexOf('.');
+ if ( index <= 0 ){
+ return FileType.SYMBOL;
+ }
+ else{
+ String end = fileName.substring(index);
+ if(end.equals(".zip")){
+ return FileType.MAPFILE;
+ }
+ else{
+ return FileType.SYMBOL;
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see com.nokia.s60tools.ui.wizards.DebugMetadataWizardPage#folderContainsMapFiles(java.lang.String)
+ */
+ public boolean folderContainsMapFiles(String folder) {
+ return SdkUtils.folderContainsMapFiles(folder);
+ }
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/wizards/SWMTCategoryGroupComposite.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/wizards/SWMTCategoryGroupComposite.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,388 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+package com.nokia.s60tools.memspy.ui.wizards;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Layout;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Widget;
+
+import com.nokia.s60tools.memspy.model.CategoryProfile;
+import com.nokia.s60tools.memspy.model.SWMTCategorys;
+import com.nokia.s60tools.memspy.plugin.MemSpyPlugin;
+import com.nokia.s60tools.memspy.preferences.MemSpyPreferences;
+import com.nokia.s60tools.memspy.ui.dialogs.SWMTCategoriesDialog;
+import com.nokia.s60tools.ui.AbstractUIComposite;
+import com.nokia.s60tools.util.debug.DbgUtility;
+
+
+/**
+ * This interface is used to notify category selection changes
+ */
+interface SWMTCategorySelectionMediator{
+
+ /**
+ * Gets category selection as bitwise OR:ed integer.
+ * @return category selection
+ */
+ public int getCategorySelection();
+
+ /**
+ * Sets new category selection
+ * @param newCategorySelection new category selection as bitwise OR:ed integer
+ * @param isProfileSettings true
if these settings are profile settings
+ * false
if these are custom settings
+ */
+ public void setCategorySelection(int newCategorySelection, boolean isProfileSettings);
+
+ /**
+ * Set Categories button selection to "All" or "Custom".
+ * @param isProfileCategoriesSelected true
if one profile is selected
+ * false
otherwise.
+ */
+ public void setProfileTrackedCategoriesSelected(boolean isProfileTrackedCategoriesSelected);
+
+ /**
+ * Get if user has been selected to use one of the profiles Categories
+ * @return true
if one profile is selected
+ * false
if custom categories is selected.
+ */
+ public boolean isProfileTrackedCategoriesSelected();
+};
+
+
+/**
+ * Composite for SWMT category selection group in SWMTLogPage wizard page.
+ */
+public class SWMTCategoryGroupComposite extends AbstractUIComposite implements SelectionListener {
+
+ //
+ // Private constants
+ //
+ private static final int COMPOSITE_COLUMN_COUNT = 1;
+ private static final int TRACKED_CATEGORIES_GROUP_COLUMN_COUNT = 2;
+ //
+ // Private member data
+ //
+ private Button profileCategoriesRadioBtn;
+ private Button customCategoriesRadioBtn;
+ private Button editCategoriesPushButton;
+ private boolean isCustomCategorySelected = false;
+ private final SWMTCategorySelectionMediator mediator;
+ private boolean isCustomCategorySelectionEnabled = true;
+ private Combo profileCombo;
+
+ /**
+ * Constructor.
+ * @param parentComposite parent composite
+ * @param isCustomCategorySelected true
if custom category is initially selected, otherwise false
+ * @param mediator mediator for handling category selection changes
+ * @param isCustomCategorySelectionEnabled true
if custom category selection is enabled, otherwise false
.
+ */
+ public SWMTCategoryGroupComposite(Composite parentComposite, boolean isCustomCategorySelected, SWMTCategorySelectionMediator mediator, boolean isCustomCategorySelectionEnabled) {
+ super(parentComposite);
+ this.isCustomCategorySelected = isCustomCategorySelected;
+ this.mediator = mediator;
+ this.isCustomCategorySelectionEnabled = isCustomCategorySelectionEnabled;
+ setCustomCategorySelection();
+ // Updating widget UI state based on the provided constructor parameters
+ setWidgetStates();
+ }
+
+ /**
+ * Sets custom category selection based on the feature availability
+ * and the current selection data.
+ */
+ private void setCustomCategorySelection() {
+ boolean isAllTrackedCategoriesSelected = mediator.isProfileTrackedCategoriesSelected();
+ if(isCustomCategorySelectionEnabled && !isAllTrackedCategoriesSelected){
+ // If feature is enabled and there is pre-selected values => custom category is selected
+ isCustomCategorySelected = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see com.nokia.s60tools.ui.AbstractUIComposite#createControls()
+ */
+ @Override
+ protected void createControls() {
+
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, this.getClass().getSimpleName() + ": createControls()"); //$NON-NLS-1$
+
+ // Tracked Categories -group
+ Group categoryGroup = new Group(this, SWT.SHADOW_NONE);
+ categoryGroup.setText("Tracked Categories and Advanced Options");
+ GridLayout gdl = new GridLayout(TRACKED_CATEGORIES_GROUP_COLUMN_COUNT, false);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ categoryGroup.setLayout(gdl);
+ categoryGroup.setLayoutData(gd);
+
+ Composite profileCom = new Composite(categoryGroup,SWT.NONE);
+ GridLayout pgl = new GridLayout(2, false);
+ pgl.marginHeight = 0;
+ pgl.marginWidth = 0;
+ GridData pgd = new GridData(GridData.FILL_BOTH);
+ pgd.horizontalSpan = 2;
+ pgd.grabExcessHorizontalSpace = true;
+ pgd.grabExcessVerticalSpace = true;
+ profileCom.setLayout(pgl);
+ profileCom.setLayoutData(pgd);
+
+ //
+ // Tracked Categories -group contents
+ //
+
+ boolean isProfileSelected = MemSpyPreferences.isProfileTrackedCategoriesSelected();
+
+ //Profiles button
+ profileCategoriesRadioBtn = new Button(profileCom, SWT.RADIO);
+ profileCategoriesRadioBtn.addSelectionListener(this);
+ profileCategoriesRadioBtn.setSelection(isProfileSelected);
+
+ profileCombo = new Combo( profileCom, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
+ profileCombo.addSelectionListener(this);
+
+ List categoryProfiles = SWMTCategorys.getInstance().getCategoryProfiles();
+ for (Iterator iterator = categoryProfiles.iterator(); iterator
+ .hasNext();) {
+ CategoryProfile profile = (CategoryProfile) iterator.next();
+ profileCombo.add(profile.getName());
+ }
+
+
+ // Custom -radio button
+ customCategoriesRadioBtn = new Button(categoryGroup, SWT.RADIO);
+ customCategoriesRadioBtn.setText("Custom Categories and Advanced Options");
+ customCategoriesRadioBtn.addSelectionListener(this);
+ customCategoriesRadioBtn.setSelection(!isProfileSelected);
+
+ // Edit -push button
+ editCategoriesPushButton = new Button(categoryGroup, SWT.PUSH);
+ editCategoriesPushButton.setText("Edit...");
+ editCategoriesPushButton.addSelectionListener(this);
+ }
+
+ /**
+ * Sets selection and enabled disable states for the widgets
+ */
+ private void setWidgetStates() {
+
+ customCategoriesRadioBtn.setEnabled(true);
+ profileCategoriesRadioBtn.setEnabled(true);
+ profileCombo.setEnabled(true);
+
+ if(isCustomCategorySelected){
+ profileCombo.setEnabled(false);
+ profileCategoriesRadioBtn.setSelection(false);
+ customCategoriesRadioBtn.setSelection(true);
+ editCategoriesPushButton.setEnabled(true);
+ }
+ else{
+ profileCombo.setEnabled(true);
+ profileCategoriesRadioBtn.setSelection(true);
+ customCategoriesRadioBtn.setSelection(false);
+ editCategoriesPushButton.setEnabled(false);
+ }
+ setProfileComboSelectionAndTooltipText();
+
+ if(!isCustomCategorySelectionEnabled){
+ disableControls();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see com.nokia.s60tools.ui.AbstractUIComposite#createLayout()
+ */
+ @Override
+ protected Layout createLayout() {
+ return new GridLayout(COMPOSITE_COLUMN_COUNT, false);
+ }
+
+ /* (non-Javadoc)
+ * @see com.nokia.s60tools.ui.AbstractUIComposite#createLayoutData()
+ */
+ @Override
+ protected Object createLayoutData() {
+ GridData gridData = new GridData(GridData.FILL_BOTH);
+ gridData.verticalSpan = 2;
+ return gridData;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // Must be implemented but not needed in this case
+ }
+
+ /**
+ * Sets selection for profile Combo and sets tooltip text
+ */
+ private void setProfileComboSelectionAndTooltipText() {
+ int selectedProfile = MemSpyPreferences.getSWMTCategorySettingForProfile();
+
+ List categoryProfiles = SWMTCategorys.getInstance()
+ .getCategoryProfiles();
+ int j = 0;
+ for (Iterator iterator = categoryProfiles.iterator(); iterator
+ .hasNext();) {
+ CategoryProfile profile = (CategoryProfile) iterator.next();
+ if (selectedProfile == profile.getCategories()) {
+ //Selection of combo
+ profileCombo.select(j);
+ //Tootip text for combo selection
+ String categoryNames = "";
+ String[] profileCategoryNames = profile.getCategoryEntryNames();
+ //Collection names of all categories belongs to profile as comma separated list (but last with "and")
+ for (int i = 0; i < profileCategoryNames.length; i++) {
+ categoryNames += profileCategoryNames[i];
+ if (i == profileCategoryNames.length - 2) {
+ categoryNames += " and ";
+ } else if (i != profileCategoryNames.length - 1) {
+ categoryNames += ", ";
+ }
+ // else its last item and we dont need to add anything
+ }
+ String name = profile.getName();
+ //To show "&" char in tooltip, it must be replaced with "&&"
+ name = name.replace("&", "&&");
+ String toolTipText = "Profile: (" + name
+ + ") contains following categories: " + categoryNames;
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, toolTipText);
+ profileCombo.setToolTipText(toolTipText);
+ break;
+ }
+
+ j++;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetSelected(SelectionEvent e) {
+ Widget widget = e.widget;
+
+ if(widget.equals(profileCategoriesRadioBtn)){
+ isCustomCategorySelected = false;
+ mediator.setProfileTrackedCategoriesSelected(true);
+ setWidgetStates();
+ }
+ else if(widget.equals(customCategoriesRadioBtn)){
+ isCustomCategorySelected = true;
+ mediator.setProfileTrackedCategoriesSelected(false);
+ setWidgetStates();
+ }
+ else if(widget.equals(editCategoriesPushButton)){
+ categoriesEditButtonPressed();
+ }
+ else if(widget.equals(profileCombo)){
+ String selectedProfile = profileCombo.getText();
+ CategoryProfile profile = SWMTCategorys.getInstance().getProfile(selectedProfile);
+ mediator.setCategorySelection(profile.getCategories(), true);
+ setProfileComboSelectionAndTooltipText();
+ }
+ }
+
+
+
+ /**
+ * Checks if custom category set has been selected by a user.
+ * @return true
if custom category has been selected, otherwise false
.
+ */
+ public boolean isCustomCategorySelected() {
+ return isCustomCategorySelected;
+ }
+
+ /**
+ * Handles Edit...-button press event.
+ */
+ private void categoriesEditButtonPressed() {
+ Shell sh = MemSpyPlugin.getCurrentlyActiveWbWindowShell();
+ SWMTCategoriesDialog entryDialog = new SWMTCategoriesDialog(sh, mediator.getCategorySelection());
+ entryDialog.create();
+ int userSelection = entryDialog.open();
+ if(userSelection == Window.OK){
+ int newCategorySelection = entryDialog.getSelectedCategories();
+ mediator.setCategorySelection(newCategorySelection, false);
+ }
+ }
+
+ /**
+ * Disables custom category selection programmatically and updates UI accordingly
+ */
+ public void disableCustomCategorySelection(){
+ isCustomCategorySelectionEnabled = false;
+ isCustomCategorySelected = false;
+ setWidgetStates();
+ }
+
+ /**
+ * Sets enable state false to the controls.
+ */
+ private void disableControls() {
+ // Disabling custom category selection
+ setEnabled(false);
+ profileCategoriesRadioBtn.setEnabled(false);
+ customCategoriesRadioBtn.setEnabled(false);
+ editCategoriesPushButton.setEnabled(false);
+ profileCombo.setEnabled(false);
+ }
+
+ /**
+ * Refreshes widget state
+ */
+ public void refresh(){
+ setWidgetStates();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.widgets.Widget#dispose()
+ */
+ public void dispose(){
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, this.getClass().getSimpleName() + ": dispose()"); //$NON-NLS-1$
+ super.dispose();
+ }
+
+ /**
+ * Sets buttons enabled/disabled
+ * @param isButtonsEnabled set true
if buttons are enabled, and false
+ * if buttons are disabled
+ */
+ public void setButtonsEnabled(boolean isButtonsEnabled){
+ if(isButtonsEnabled){
+ setWidgetStates();
+ }else{
+ disableControls();
+ }
+ }
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/wizards/SWMTLogPage.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/wizards/SWMTLogPage.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,1362 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+package com.nokia.s60tools.memspy.ui.wizards;
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.PlatformUI;
+
+import com.nokia.s60tools.memspy.containers.SWMTLogInfo;
+import com.nokia.s60tools.memspy.containers.SWMTLogInfo.SWMTLogType;
+import com.nokia.s60tools.memspy.interfaces.IMemSpyTraceListener;
+import com.nokia.s60tools.memspy.model.MemSpyFileOperations;
+import com.nokia.s60tools.memspy.model.MemSpyLogParserEngine;
+import com.nokia.s60tools.memspy.model.TraceCoreEngine;
+import com.nokia.s60tools.memspy.model.UserEnteredData;
+import com.nokia.s60tools.memspy.model.UserEnteredData.ValueTypes;
+import com.nokia.s60tools.memspy.plugin.MemSpyPlugin;
+import com.nokia.s60tools.memspy.preferences.MemSpyPreferences;
+import com.nokia.s60tools.memspy.resources.HelpContextIDs;
+import com.nokia.s60tools.memspy.ui.UiUtils;
+import com.nokia.s60tools.ui.preferences.PreferenceUtils;
+import com.nokia.s60tools.ui.wizards.S60ToolsWizardPage;
+import com.nokia.s60tools.util.debug.DbgUtility;
+
+/**
+ * SWMT-log import page is used for importing SWMT-logs from file system or from device.
+ */
+
+public class SWMTLogPage extends S60ToolsWizardPage implements SelectionListener, IMemSpyTraceListener, SWMTCategorySelectionMediator{
+
+ /**
+ * Selection index for import from device via TraceViewer radio button
+ */
+ private static final int DEVICE_RADIO_BUTTON_SELECTION_INDEX = 2;
+
+ // Array list of logs that are imported
+ // from files:
+ private ArrayList fileLogList;
+ // from device:
+ private ArrayList deviceLogList;
+
+ // SWMT-log that is currently received
+ SWMTLogInfo receivedLog;
+
+ // TraceCore engine
+ private TraceCoreEngine traceEngine;
+
+ // Cycle Number for SMWT-log file name
+ private int cycleNumber;
+
+ // Error message
+ String errorMessage;
+
+ // boolean value stating that error has been occurred and logs cannot be requested before removing
+ // all items and restarting from cycle 1.
+ boolean missedLogs;
+
+ //UI-components:
+ private Group radioButtonGroup;
+ private Button fileRadioButton;
+ private Button deviceRadioButton;
+
+ // Components for importing file from device
+ private Table fileLogsTable;
+ private Composite fileSelectionButtonComposite;
+ private Button addFileButton;
+ private Button addDirectoryButton;
+ private Button removeOneButton;
+ private Button removeAllButton;
+
+ private Group fileSelectionGroup;
+ private Group deviceGroup;
+
+ private GridData fileSelectionGridData;
+ private GridData deviceGridData;
+
+
+ // components for importing log from device
+ private Table deviceLogsTable;
+ private Composite loggingComposite;
+ private Button connectionSettingsButton;
+ private Button getLogNowButton;
+ private Button removeReceivedLogsButton;
+ private Label connectionNameInUseLabel;
+
+ // Timer related components
+ private Label intervalLabel;
+ private Label secondLabel;
+ private Button startTimerButton;
+ private Combo timerCombo;
+
+ /**
+ * UI composite for SWMT Category group
+ */
+ private SWMTCategoryGroupComposite categoryGroupComposite;
+
+ // boolean variable, which is set to true if some MemSpy operation is running.
+ boolean memSpyOperationRunning;
+ boolean memSpyStopping;
+ boolean memSpyTimerRunning;
+
+ // MemSpy operation processes:
+ // receive SWMT-log manually
+ IRunnableWithProgress receiveSWMTLogProcess;
+
+ private final static String GET_LOG_FROM_RADIO_BUTTON = "Get SWMT Log";
+ private final static String GET_FROM_FROM_FILE_RADIO_BUTTON = "From File System";
+ private final static String GET_LOG_FROM_DEVICE_RADIO_BUTTON = "From Device via TraceViewer";
+ private final static String LOG_FILES = "Log files:";
+ private final static String LOG_TYPE = "Type";
+ private final static String ADD_FILE = "Add File";
+ private final static String ADD_DIRECTORY = "Add Directory";
+ private final static String REMOVE_ONE = "Remove";
+ private final static String REMOVE_ALL = "Remove All";
+ private final static String ADD_FILE_TEXT = "Define Location of SWMT Log file:";
+ private final static String ADD_DIRECTORY_TEXT = "Define Location of directory that contains SWMT Logs:";
+ private final static String LOG_TYPE_FILE = "File";
+ private final static String LOG_TYPE_DIRECTORY = "Directory";
+
+ private final static String CONNECTION_SETTINGS_BUTTON = "Connection Settings...";
+ private final static String CURRENTLY_USING_TEXT = "Currently using:";
+ private final static String GET_LOG_NOW_BUTTON = "Get SWMT Log Now";
+ private final static String LOGS = "Logs";
+ private final static String RECEIVED = "Received";
+
+ private final static String RECEIVING_SWMT_LOG = "Receiving SWMT Log: ";
+ private final static String WAITING_FOR_TIMER = "Waiting for timer to expire: ";
+ private final static String STOPPING_TIMER = "Stopping timer: ";
+
+ private final static String TEXT_GET_LOG_WITH_TIMER = "Get Log with Timer";
+ private final static String TEXT_INTERVAL = "Interval:";
+ private final static String START_TIMER = "Start Timer";
+ private final static String TEXT_SECOND = "Seconds";
+
+ private final static String ERROR_INTERVAL = "Time interval needs to be integer and more than zero.";
+
+ /**
+ * Constructor.
+ * @param pageName name of the page
+ * @param traceEngine TraceCore engine that is used when requesting data from TC
+ */
+ protected SWMTLogPage(String pageName, TraceCoreEngine traceEngine) {
+ super(pageName);
+ setTitle("System Wide Memory Tracking Wizard");
+ setDescription("Define Source For SWMT logs that are imported. Logs can be imported from already existing files or from device via TraceViewer.");
+ this.fileLogList = new ArrayList();
+ this.deviceLogList = new ArrayList();
+ this.traceEngine = traceEngine;
+ this.createMemSpyProcesses();
+
+ this.memSpyTimerRunning = false;
+ this.memSpyOperationRunning = false;
+ this.memSpyStopping = false;
+ this.cycleNumber = 0;
+
+ this.missedLogs = false;
+ }
+
+ @Override
+ public void recalculateButtonStates() {
+ // no implementation needed
+ }
+
+ @Override
+ public void setInitialFocus() {
+ timerCombo.setFocus();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // Not needed in this case
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetSelected(SelectionEvent e) {
+ // Update controls after radio buttons state changes to false
+ if ( ( e.widget == deviceRadioButton && deviceRadioButton.getSelection() == false ) ||
+ ( e.widget == fileRadioButton && fileRadioButton.getSelection() == false ) ){
+ //When selection is changed, we clear the previous results.
+ removeReceivedLogs();
+ this.hideAndRevealItems();
+ }
+
+ // open file dialog
+ else if (e.widget == addFileButton) {
+ // open file dialog for selecting a crash file
+ FileDialog dialog = new FileDialog(this.getShell(), SWT.MULTI);
+ dialog.setText(ADD_FILE_TEXT);
+ String[] filterExt = { "*.txt", "*.log", "*.*" };
+ dialog.setFilterExtensions(filterExt);
+
+ if (dialog.open() != null ){
+ String[] files = dialog.getFileNames();
+ String directory = dialog.getFilterPath();
+ directory = MemSpyFileOperations.addSlashToEnd( directory );
+
+ boolean noLogFound = false;
+
+ for( String item : files ){
+
+ // confirm that file is smwt log
+ if( MemSpyLogParserEngine.isFileSWMTLog( new File(directory + item)) ){
+ this.addFileLog( directory + item );
+ }
+
+ else{
+ noLogFound = true;
+ }
+ }
+
+ // if some of the selected files is not swmt-file show error message.
+ if( noLogFound ){
+ Status status = new Status(IStatus.ERROR, MemSpyPlugin.PLUGIN_ID, 0, "Some of the selected files is not SWMT-log file.", null);
+ // Display the dialog
+ ErrorDialog.openError(Display.getCurrent().getActiveShell(),ERROR_MEMSPY, null, status);
+ }
+ }
+
+
+ }
+
+ // open directory dialog
+ else if (e.widget == addDirectoryButton) {
+ // open file dialog for selecting a crash file
+ DirectoryDialog dialog = new DirectoryDialog(this.getShell());
+ dialog.setText(ADD_DIRECTORY_TEXT);
+ String result = dialog.open();
+ if (result != null ){
+
+ File[] allFiles = MemSpyFileOperations.getFilesFromDirectory( new File( result ) );
+
+ int swmtFileCount = 0;
+
+ for ( File item : allFiles ){
+ if( MemSpyLogParserEngine.isFileSWMTLog( item ) ){
+ swmtFileCount++;
+ this.addFileLog( item.toString() );
+ }
+ }
+ // if no SWMT-log files were found from selected directory, show error message.
+ if(swmtFileCount == 0){
+ Status status = new Status(IStatus.ERROR, MemSpyPlugin.PLUGIN_ID, 0, "No SWMT-logs were found from selected directory.", null);
+ // Display the dialog
+ ErrorDialog.openError(Display.getCurrent().getActiveShell(),ERROR_MEMSPY, null, status);
+
+
+ }
+ }
+ }
+
+ // remove selected log file
+ else if (e.widget == removeOneButton ){
+ if( fileLogsTable.getSelectionCount() == 1 ){
+ fileLogList.remove( fileLogsTable.getSelectionIndex() );
+ this.refreshFileLogTable();
+ }
+ }
+
+ // remove all log files
+ else if (e.widget == removeAllButton ){
+ fileLogList.clear();
+ this.refreshFileLogTable();
+ }
+
+ // open connection settings
+ else if ( e.widget == connectionSettingsButton ){
+ // Open connection Trace viewers connection settings.
+ Shell shell = MemSpyPlugin.getCurrentlyActiveWbWindowShell();
+ PreferenceUtils.openPreferencePage(MemSpyPlugin.getTraceProvider().getTraceSourcePreferencePageId(), shell);
+
+ // Disconnect trace source so that new settings are used when sending next request
+ MemSpyPlugin.getTraceProvider().disconnectTraceSource();
+
+ // get wizard pointer and cast it to MemSpyWizard
+ MemSpyWizard wizard = (MemSpyWizard) this.getWizard();
+ // update new settings to each wizard page.
+ wizard.updateConnectionSettings();
+ }
+
+ // get log now from TC
+ else if (e.widget == getLogNowButton ){
+ this.getLogNowPressed();
+ }
+
+ // Remove all log received from device-button
+ else if( e.widget == removeReceivedLogsButton ){
+ this.removeReceivedLogs();
+ }
+
+ // SWMT timer started
+ else if( e.widget == startTimerButton ){
+ this.getLogWithTimerPressed();
+ }
+
+
+ // if file logs table selection changes or button is pressed, enable and disable buttons
+ if( e.widget == this.fileLogsTable ||
+ e.widget == this.removeAllButton ||
+ e.widget == this.removeOneButton ||
+ e.widget == this.addFileButton ||
+ e.widget == this.addDirectoryButton ){
+ this.enableAndDisableFileButtons();
+ }
+ getWizard().getContainer().updateButtons();
+
+ }
+
+ /**
+ * Checks if wizard can be finished or not.
+ * @return boolean value if wizard can finish
+ */
+ public boolean canFinish(){
+
+ // if traceEngines taskList is not empty, return false
+ if( traceEngine.getFirstTask() != null ){
+ return false;
+ }
+
+ // if file or device log lists are not empty(depending on radiobutton selection) return true
+ if( fileRadioButton.getSelection() ){
+ if( fileLogList.size() > 0 ){
+ return true;
+ }
+ }
+ else{
+ if( deviceLogList.size() > 0 ){
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * Hides and reveals controls according to radio button states.
+ */
+ private void hideAndRevealItems() {
+
+ boolean fileSelected = true;
+
+ if( fileRadioButton.getSelection() == false ){
+ fileSelected = false;
+ }
+
+ // exclude/include needed controls
+ fileSelectionGridData.exclude = !fileSelected;
+ deviceGridData.exclude = fileSelected;
+
+ if( !fileSelected ){
+ // Since excluded groups size and location are not updated, do it now
+ deviceGroup.setSize( fileSelectionGroup.getSize() );
+ deviceGroup.setLocation(fileSelectionGroup.getLocation());
+ }
+ else{
+ // Since excluded groups size and location are not updated, do it now
+ fileSelectionGroup.setSize( deviceGroup.getSize() );
+ fileSelectionGroup.setLocation(deviceGroup.getLocation());
+
+ }
+ // Hide/show needed controls
+ fileSelectionGroup.setVisible(fileSelected);
+ deviceGroup.setVisible(!fileSelected);
+
+ }
+
+ /**
+ * Adds a log file.
+ * @param location of log file
+ */
+ private void addFileLog( String location ){
+
+ // create SWMTLogInfo object for log file.
+ SWMTLogInfo info = new SWMTLogInfo();
+ info.setType( SWMTLogType.FILE );
+ info.setPath( location );
+ fileLogList.add(info);
+
+ // get files name
+ String fileName = location.substring( location.lastIndexOf("\\") + 1 );
+
+ // add name into table
+ TableItem item = new TableItem( fileLogsTable, SWT.NONE, fileLogsTable.getItemCount() );
+ item.setText( new String[]{ fileName, LOG_TYPE_FILE });
+
+ }
+
+ /**
+ * Updates file log table so that it contains same data that file log list.
+ */
+ private void refreshFileLogTable(){
+ //Remove all items
+ fileLogsTable.removeAll();
+
+ for( int i = 0; i < fileLogList.size(); i++ ){
+ TableItem newItem = new TableItem(fileLogsTable, SWT.NONE,i);
+
+ // get item
+ SWMTLogInfo log = fileLogList.get(i);
+ String fileName = log.getPath();
+ String fileType = LOG_TYPE_DIRECTORY;
+
+ // Remove path if type is file
+ if( log.getType() == SWMTLogType.FILE ){
+ fileName = fileName.substring( fileName.lastIndexOf("\\") + 1 );
+ fileType = LOG_TYPE_FILE;
+ }
+
+ newItem.setText( new String[]{ fileName, fileType } );
+ }
+
+ }
+
+ /**
+ * Removed received logs.
+ */
+ private void removeReceivedLogs(){
+ // Delete all items in deviceLogList and deviceLogsTable
+ deviceLogList.clear();
+ deviceLogsTable.removeAll();
+
+ // Delete all temp files
+ MemSpyFileOperations.deleteTempMemSpyFiles();
+
+ // set cycle number to zero
+ cycleNumber = 0;
+
+ // reset missed logs value
+ missedLogs = false;
+
+ // enable and disable buttons
+ this.enableAndDisableDeviceButtonsAndSWMTCategoryGroup();
+ }
+
+ /**
+ * Gets list of log files that are in currently selected table.
+ * @return list of log files that are in currently selected table
+ */
+ public ArrayList getLogList(){
+ if( fileRadioButton.getSelection() ){
+ return fileLogList;
+ }
+ else{
+ return deviceLogList;
+ }
+ }
+
+ /**
+ * Updates connection text to match used settings.
+ */
+ public void updateConnectionText(){
+ // Updating connection name.
+ String displayName = MemSpyPlugin.getTraceProvider().getDisplayNameForCurrentConnection();
+ connectionNameInUseLabel.setText(displayName);
+ loggingComposite.layout();
+ }
+
+ /**
+ * Loads previous values into UI components.
+ */
+ private void loadUserEnteredData(){
+
+ // if last value is not found, set selection file.
+ UserEnteredData data = new UserEnteredData();
+ int lastUsedSource = data.getPreviousRadioButtonSelection( ValueTypes.SWMT );
+
+ // Restoring previous state of radio buttons only if device import is also possible and was previously selected
+ if(MemSpyPlugin.isTraceProviderAvailable() && lastUsedSource == DEVICE_RADIO_BUTTON_SELECTION_INDEX){
+ deviceRadioButton.setSelection( true );
+ fileRadioButton.setSelection( false );
+ }
+ else{
+ deviceRadioButton.setSelection( false );
+ fileRadioButton.setSelection( true );
+ }
+
+ // Restore previous values to file combobox
+ String[] lastUsedFiles = data.getPreviousValues( ValueTypes.SWMT );
+ if (lastUsedFiles != null) {
+ timerCombo.setItems(lastUsedFiles);
+ timerCombo.select(0);
+ }
+
+ }
+
+ /**
+ * Saves user entered values and selections from UI components so that they can be restored later if needed.
+ */
+ public void saveUserEnteredData(){
+ UserEnteredData data = new UserEnteredData();
+
+ // Save Action radio-buttons state
+ if( deviceRadioButton.getSelection() ){
+ data.saveRadioButtonSelection(ValueTypes.SWMT, 2);
+ }
+ else {
+ data.saveRadioButtonSelection(ValueTypes.SWMT, 1);
+ }
+ data.saveValue(ValueTypes.SWMT, timerCombo.getText());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.nokia.s60tools.memspy.ui.wizards.MemSpyTraceListener#deviceError(com.nokia.s60tools.memspy.ui.wizards.MemSpyTraceListener.LauncherErrorType)
+ */
+ public void deviceError( final LauncherErrorType error ){
+
+ Date date = new Date (System.currentTimeMillis());
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "SWMTLogPage.deviceError: '" + error.name() +"' time:'" +date.toString() + "'."); //$NON-NLS-1$ $NON-NLS-2$ $NON-NLS-3$
+
+ // Set MemSpy's state correct
+ memSpyOperationRunning = false;
+ memSpyTimerRunning = false;
+
+ // change Cancel text from wizard back to "Cancel"
+ this.setCancelText( "Cancel" );
+
+ // Getting user visible error message
+ errorMessage = UiUtils.getErrorMessageForLauncherError(error, traceEngine.getAdditionalErrorInformation(), traceEngine.getProgressStatus()); //$NON-NLS-1$
+
+ // Handling SWMT-specific logic related to the error
+ switch (error){
+ case DUMPED_TRACES:{
+ this.receivedLog = null;
+ break;
+ }
+ case CATEGORIES_NOT_SUPPORTED:{
+ disableSWMTCategoryFeature();
+ break;
+ }
+ }
+
+ // Add reset info into error message.
+ if(error != LauncherErrorType.CATEGORIES_NOT_SUPPORTED){
+ errorMessage = errorMessage + ERROR_SWMT_NEEDS_RESET;
+ }
+
+ // Set missedLogs value to true so that logs cannot be requested anymore because of missed logs.
+ missedLogs = true;
+
+ // Advising user to install launcher component to the device
+ UiUtils.showErrorDialogToUser(error, errorMessage, traceEngine.getProgressStatus());
+ }
+
+ /**
+ * Disables SWMT category feature for the rest of the session in case is was not supported by the device.
+ */
+ private void disableSWMTCategoryFeature() {
+ Runnable disableRunnable = new Runnable(){
+
+ public void run() {
+ try {
+ MemSpyPlugin.getDefault().setSWMTCategorySettingFeatureEnabled(false);
+ MemSpyPreferences.setProfileTrackedCategoriesSelected(true);
+ categoryGroupComposite.disableCustomCategorySelection();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ };
+
+ Display.getDefault().asyncExec(disableRunnable);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.nokia.s60tools.memspy.ui.wizards.MemSpyTraceListener#operationFinished(com.nokia.s60tools.memspy.ui.wizards.MemSpyTraceListener.LauncherAction)
+ */
+ public void operationFinished(LauncherAction action) {
+
+ // reset missed logs.
+ missedLogs = false;
+
+ if( action == LauncherAction.SWMT_UPDATE ){
+ cycleNumber++;
+ this.updateReceivedSWMTLog( false );
+ }
+
+ }
+
+ /**
+ * Does actions that are made when SWMT log is received.
+ */
+ private void updateReceivedSWMTLog( final boolean timerRunning ){
+
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "SWMTLogPage.updateReceivedSWMTLog/timerRunning=" + timerRunning ); //$NON-NLS-1$
+
+ Runnable updateUiRunnable = new Runnable(){
+ public void run(){
+
+ // get date formatter
+ SimpleDateFormat formatter = new SimpleDateFormat ( MemSpyFileOperations.DATEFORMAT );
+ String date = formatter.format(receivedLog.getDate() );
+ // get files name
+ String path = receivedLog.getPath().substring( receivedLog.getPath().lastIndexOf("\\") + 1 );
+
+ // add log into table
+ TableItem item = new TableItem( deviceLogsTable, SWT.NONE, deviceLogsTable.getItemCount() );
+ item.setText( new String[]{ path, date });
+
+ // add receivedlog-object into deviceLogsList-Arraylist
+ deviceLogList.add( receivedLog );
+
+ if( timerRunning ){
+ // show progress bar
+ memSpyTimerRunning = true;
+ memSpyOperationRunning = false;
+
+ }
+ else{
+
+ // change Cancel text from wizard back to "Cancel"
+ setCancelText("Cancel");
+
+ // Set state correct
+ memSpyOperationRunning = false;
+
+ }
+ }
+
+ };
+ Display.getDefault().asyncExec(updateUiRunnable);
+ }
+
+ /**
+ * Enables and disables device buttons and SWMT category group UI according to current situation
+ */
+ private void enableAndDisableDeviceButtonsAndSWMTCategoryGroup(){
+
+ // Refreshes enable/disable status for SWMT category group UI
+ categoryGroupComposite.refresh();
+
+ // if log table is not empty, enable remove all button.
+ if( this.deviceLogsTable.getItemCount() > 0 ){
+ this.connectionSettingsButton.setEnabled(false);
+ this.removeReceivedLogsButton.setEnabled(true);
+ this.categoryGroupComposite.setButtonsEnabled(false);
+ this.categoryGroupComposite.setEnabled(false);
+ if( this.missedLogs ){
+ this.getLogNowButton.setEnabled(false);
+ this.startTimerButton.setEnabled(false);
+ }
+ }
+ else{
+ this.connectionSettingsButton.setEnabled(true);
+ this.removeReceivedLogsButton.setEnabled(false);
+ this.categoryGroupComposite.setButtonsEnabled(true);
+ this.categoryGroupComposite.setEnabled(true);
+ if( !this.missedLogs ){
+ this.getLogNowButton.setEnabled(true);
+ this.startTimerButton.setEnabled(true);
+ }
+ }
+ }
+
+ /**
+ * Enables and disables file buttons according to current situation.
+ */
+ private void enableAndDisableFileButtons(){
+
+ // If one log is selected, enable Remove button, otherwise disable it
+ if( this.fileLogsTable.getSelectionCount() == 1 ){
+ this.removeOneButton.setEnabled(true);
+ }
+ else{
+ this.removeOneButton.setEnabled(false);
+ }
+
+ // if log table is not empty, enable remove all button.
+ if( this.fileLogsTable.getItemCount() > 0 ){
+ this.removeAllButton.setEnabled(true);
+ }
+ else{
+ this.removeAllButton.setEnabled(false);
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.wizard.WizardPage#canFlipToNextPage()
+ */
+ public boolean canFlipToNextPage() {
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, this.getClass().getSimpleName() + ": createControl()"); //$NON-NLS-1$
+
+ // Radio button group
+ Composite composite = new Composite(parent, SWT.NULL);
+
+ // create the desired layout for this wizard page
+ GridLayout gl = new GridLayout();
+ gl.numColumns = 1;
+ composite.setLayout(gl);
+
+ //Create group where to select if import from File System / From Device
+ createRadioButtonGroup(composite);
+
+ //Create group where import logs from File
+ createImportFromFileGroup(composite);
+
+ //Create group where import logs from Device
+ createImportFromDeviceGroup(composite);
+
+
+ // load saved user entered data.
+ this.loadUserEnteredData();
+
+ // update buttons and texts on screen.
+ this.updateConnectionText();
+
+ // Enable/disable buttons
+ this.enableAndDisableDeviceButtonsAndSWMTCategoryGroup(); //will call also #enableOrDisableHeapFilterText();
+ this.enableAndDisableFileButtons();
+
+ this.hideAndRevealItems();
+
+ // Setting context-sensitive help ID
+ PlatformUI.getWorkbench().getHelpSystem().setHelp( composite, HelpContextIDs.MEMSPY_IMPORT_SWMT);
+
+ setInitialFocus();
+ setControl(composite);
+ }
+
+ private void createImportFromDeviceGroup(Composite parent) {
+ // Device group
+
+ deviceGroup = new Group(parent, SWT.NONE);
+ GridLayout deviceGridLayout = new GridLayout();
+ deviceGridLayout.numColumns = 2;
+
+ deviceGridData = new GridData(GridData.FILL_BOTH);
+ deviceGroup.setLayoutData(deviceGridData);
+ deviceGroup.setLayout(deviceGridLayout);
+ deviceGroup.setText(GET_LOG_FROM_DEVICE_RADIO_BUTTON);
+
+
+
+ // Logs from device table
+
+ deviceLogsTable = new Table(deviceGroup, SWT.BORDER);
+ GridData tableGridData = new GridData(GridData.FILL_BOTH);
+ deviceLogsTable.setLayoutData(tableGridData);
+
+ TableColumn logsColumn = new TableColumn(deviceLogsTable, SWT.LEFT);
+ logsColumn.setText(LOGS);
+ logsColumn.setWidth(300);
+
+ TableColumn receivedColumn = new TableColumn(deviceLogsTable, SWT.LEFT);
+ receivedColumn.setText(RECEIVED);
+ receivedColumn.setWidth(110);
+
+ GridData deviceLogsTableGridData = new GridData(GridData.FILL_BOTH);
+ deviceLogsTable.setLayoutData(deviceLogsTableGridData);
+ deviceLogsTable.setHeaderVisible(true);
+ deviceLogsTable.addSelectionListener(this);
+
+
+ //
+ //Create logging composite, contains Get log now, Get log with timer and remove logs functions
+ //
+ createLoggingComposite(deviceGroup);
+
+ //
+ //Bottom composite where settings and categories are located
+ //
+ Composite bottomComposite = new Composite(deviceGroup,SWT.NONE);
+ GridLayout pgl = new GridLayout(2, false);
+ pgl.marginHeight = 0;
+ pgl.marginWidth = 0;
+ GridData pgd = new GridData(GridData.VERTICAL_ALIGN_END | GridData.FILL_HORIZONTAL);
+ bottomComposite.setLayout(pgl);
+ bottomComposite.setLayoutData(pgd);
+
+ //
+ //Create Connection settings group
+ //
+ createConnectionSettingsGroup(bottomComposite);
+
+ //
+ // Create and add SWMT category setting group
+ //
+ categoryGroupComposite = new SWMTCategoryGroupComposite(bottomComposite, false, this, MemSpyPlugin.getDefault().isSWMTCategorySettingFeatureEnabled());
+
+ }
+
+ private void createLoggingComposite(Composite parent) {
+
+ loggingComposite = new Composite(parent, SWT.NONE);
+ GridLayout deviceButtonLayout = new GridLayout();
+ GridData deviceButtonGridData = new GridData(SWT.FILL, SWT.FILL, true, true);//GridData.FILL_BOTH | GridData.VERTICAL_ALIGN_CENTER
+ deviceButtonLayout.numColumns = 1;
+ loggingComposite.setLayoutData(deviceButtonGridData);
+ loggingComposite.setLayout(deviceButtonLayout);
+
+ //
+ // Get Log now button
+ //
+ Composite getLogComposite = new Composite(loggingComposite, SWT.NONE);
+ GridLayout getLogLayout = new GridLayout();
+ GridData getLogGD = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
+ getLogComposite.setLayoutData(getLogGD);
+ getLogComposite.setLayout(getLogLayout);
+
+ //Null label is added with no text to align get log now
+ @SuppressWarnings("unused")
+ Label nullLabel = new Label(getLogComposite,SWT.NULL);
+
+ getLogNowButton = new Button(getLogComposite, SWT.PUSH);
+ getLogNowButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL ));//| GridData.VERTICAL_ALIGN_BEGINNING
+ getLogNowButton.setText(GET_LOG_NOW_BUTTON);
+ getLogNowButton.addSelectionListener(this);
+
+ //
+ // Timer composite
+ //
+ Composite timerComposite = new Composite(loggingComposite, SWT.NONE);
+ GridLayout timerLayout = new GridLayout();
+ timerLayout.marginWidth = 0;
+ GridData timerGD = new GridData(SWT.FILL, SWT.CENTER, true, true);
+ timerComposite.setLayoutData(timerGD);
+ timerComposite.setLayout(timerLayout);
+
+ createTimerComposite(timerComposite);
+
+ //
+ // Remove all files button
+ //
+ Composite removeComposite = new Composite(loggingComposite, SWT.NONE);
+ GridLayout removeLayout = new GridLayout();
+ GridData removeGD = new GridData(SWT.FILL, SWT.BOTTOM, true, false);
+ removeComposite.setLayoutData(removeGD);
+ removeComposite.setLayout(removeLayout);
+
+ removeReceivedLogsButton = new Button(removeComposite, SWT.PUSH);
+ removeReceivedLogsButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));//| GridData.VERTICAL_ALIGN_END
+ removeReceivedLogsButton.setText(REMOVE_ALL);
+ removeReceivedLogsButton.addSelectionListener(this);
+ }
+
+ private void createConnectionSettingsGroup(Composite parent) {
+ Group connectionSettingsGroup = new Group(parent, SWT.NONE);
+ connectionSettingsGroup.setText("Connection");
+ GridLayout connectionGroupLayout = new GridLayout();
+ connectionGroupLayout.numColumns = 1;
+ connectionSettingsGroup.setLayout(connectionGroupLayout);
+ GridData connectionGridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ connectionSettingsGroup.setLayoutData(connectionGridData);
+
+
+ connectionSettingsButton = new Button(connectionSettingsGroup, SWT.PUSH);
+ connectionSettingsButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ connectionSettingsButton.setText(CONNECTION_SETTINGS_BUTTON);
+ connectionSettingsButton.addSelectionListener(this);
+
+ // Connection settings labels
+ Label connectionTextLabel = new Label(connectionSettingsGroup, SWT.LEFT);
+ connectionTextLabel.setText(CURRENTLY_USING_TEXT);
+ connectionTextLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
+
+ connectionNameInUseLabel = new Label(connectionSettingsGroup, SWT.LEFT);
+ connectionNameInUseLabel.setLayoutData( new GridData(GridData.HORIZONTAL_ALIGN_CENTER) );
+ }
+
+ private void createImportFromFileGroup(Composite parent) {
+ // File selection group
+
+ fileSelectionGroup = new Group(parent, SWT.NONE);
+ GridLayout fileSelectionGridLayout = new GridLayout();
+ fileSelectionGridLayout.numColumns = 2;
+
+ fileSelectionGridData = new GridData(GridData.FILL_BOTH);
+ fileSelectionGroup.setLayoutData(fileSelectionGridData);
+ fileSelectionGroup.setLayout(fileSelectionGridLayout);
+ fileSelectionGroup.setText(GET_FROM_FROM_FILE_RADIO_BUTTON);
+
+ // Logs from file table
+
+ fileLogsTable = new Table(fileSelectionGroup, SWT.BORDER);
+ TableColumn fileColumn = new TableColumn(fileLogsTable, SWT.LEFT);
+ fileColumn.setText(LOG_FILES);
+ fileColumn.setWidth(300);
+
+ TableColumn nameColumn = new TableColumn(fileLogsTable, SWT.LEFT);
+ nameColumn.setText(LOG_TYPE);
+ nameColumn.setWidth(100);
+
+ GridData fileLogsTableGridData = new GridData(GridData.FILL_BOTH);
+ fileLogsTable.setLayoutData(fileLogsTableGridData);
+ fileLogsTable.setHeaderVisible(true);
+ fileLogsTable.addSelectionListener(this);
+
+ // File Selection button composite. Contains file operation buttons
+
+ fileSelectionButtonComposite = new Composite(fileSelectionGroup, SWT.NONE);
+ GridLayout threadButtonLayout = new GridLayout();
+ GridData fileSelectionButtonGridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ fileSelectionButtonComposite.setLayoutData(fileSelectionButtonGridData);
+ fileSelectionButtonComposite.setLayout(threadButtonLayout);
+ threadButtonLayout.numColumns = 1;
+
+ // Add file button
+ addFileButton = new Button(fileSelectionButtonComposite, SWT.PUSH);
+ addFileButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ addFileButton.setText(ADD_FILE);
+ addFileButton.addSelectionListener(this);
+
+ // Add folder button
+ addDirectoryButton = new Button(fileSelectionButtonComposite, SWT.PUSH);
+ addDirectoryButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ addDirectoryButton.setText(ADD_DIRECTORY);
+ addDirectoryButton.addSelectionListener(this);
+
+ // Remove one file button
+ removeOneButton = new Button(fileSelectionButtonComposite, SWT.PUSH);
+ removeOneButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ removeOneButton.setText(REMOVE_ONE);
+ removeOneButton.addSelectionListener(this);
+
+ // Remove all files and folders button
+ removeAllButton = new Button(fileSelectionButtonComposite, SWT.PUSH);
+ removeAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ removeAllButton.setText(REMOVE_ALL);
+ removeAllButton.addSelectionListener(this);
+ }
+
+ private void createRadioButtonGroup(Composite parent) {
+ // Radio button group
+ GridLayout radioButtonGroupGridLayout = new GridLayout();
+ radioButtonGroup = new Group(parent, SWT.NONE);
+ radioButtonGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ radioButtonGroup.setText(GET_LOG_FROM_RADIO_BUTTON);
+ radioButtonGroup.setLayout(radioButtonGroupGridLayout);
+ GridData radioButtonGridData = new GridData(GridData.FILL_HORIZONTAL);
+ radioButtonGridData.horizontalSpan = 2;
+
+ // File radio button
+ fileRadioButton = new Button(radioButtonGroup, SWT.RADIO);
+ fileRadioButton.setText(GET_FROM_FROM_FILE_RADIO_BUTTON);
+ fileRadioButton.setLayoutData(radioButtonGridData);
+ fileRadioButton.addSelectionListener(this);
+ fileRadioButton.setSelection(true);
+
+ // From Device via TraceViewer radio button
+ deviceRadioButton = new Button(radioButtonGroup, SWT.RADIO);
+ deviceRadioButton.setText(GET_LOG_FROM_DEVICE_RADIO_BUTTON);
+ deviceRadioButton.setLayoutData(radioButtonGridData);
+ deviceRadioButton.addSelectionListener(this);
+ deviceRadioButton.setSelection(false);
+
+ // In case trace plugin is not available, disabling import from device selection
+ if(!MemSpyPlugin.isTraceProviderAvailable()){
+ deviceRadioButton.setEnabled(false);
+ }
+ }
+
+ private void createTimerComposite(Composite parent) {
+ // Timer UI-components
+
+ Group timerComposite = new Group(parent, SWT.NONE);
+ timerComposite.setText(TEXT_GET_LOG_WITH_TIMER);
+
+ GridLayout timerLayout = new GridLayout();
+ timerLayout.numColumns = 2;
+ GridData timerGd = new GridData(SWT.FILL, SWT.CENTER, true, true);;
+ timerComposite.setLayoutData( timerGd );
+ timerComposite.setLayout( timerLayout );
+
+
+ // Interval- label
+ intervalLabel = new Label( timerComposite, SWT.LEFT );
+ intervalLabel.setText( TEXT_INTERVAL );
+ GridData intervalGd = new GridData();
+ intervalGd.horizontalSpan = 2;
+ intervalLabel.setLayoutData( intervalGd );
+
+ // Timer combo box
+ timerCombo = new Combo( timerComposite, SWT.BORDER);
+ GridData timerComboGridData = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
+ timerComboGridData.widthHint = 25;
+ timerCombo.setLayoutData( timerComboGridData );
+ timerCombo.setTextLimit(3);
+
+ // Interval- label
+ secondLabel = new Label( timerComposite, SWT.LEFT );
+ secondLabel.setText( TEXT_SECOND );
+ GridData secondLabelLayoutData = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
+ secondLabel.setLayoutData( secondLabelLayoutData );
+
+ // Start timer - button
+ startTimerButton = new Button(timerComposite, SWT.PUSH);
+ GridData startTimerGridData = new GridData( GridData.FILL_HORIZONTAL );
+ startTimerGridData.horizontalSpan = 2;
+ startTimerButton.setLayoutData( startTimerGridData );
+ startTimerButton.setText( START_TIMER );
+ startTimerButton.addSelectionListener(this);
+
+
+ }
+
+
+ /**
+ * Checks if device radio buttons is selected.
+ * @return true
if device radio button is selected, otherwise false
.
+ */
+ public boolean isDeviceRadioButtonSelected(){
+ return deviceRadioButton.getSelection();
+ }
+
+ /**
+ * Updates connection settings.
+ */
+ public void updateConnectionSettings() {
+ this.updateConnectionText();
+ }
+
+
+ /**
+ * Gets timer interval from interval UI-component.
+ * If interval set to text box is not valid, method prints error message and returns value 0.
+ * @return current timer interval
+ */
+ private int getTimerInteval() {
+ boolean showError = false;
+
+ int integer = 0;
+ try{
+ integer = Integer.parseInt( timerCombo.getText() );
+ }
+ catch( NumberFormatException e ){
+ // show error message of interval is not integer.
+ showError = true;
+ }
+
+ if( integer <= 0 && showError == false ){
+ // show error message if integer is negative or zero.
+ showError = true;
+ }
+
+ if( showError ){
+ // open error dialog and print error message
+ Status status = new Status(IStatus.ERROR, MemSpyPlugin.PLUGIN_ID, 0, ERROR_INTERVAL, null);
+ ErrorDialog.openError(Display.getCurrent().getActiveShell(),"MemSpy Error", null, status);
+ return 0;
+ }
+
+ return integer;
+
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.nokia.s60tools.memspy.ui.wizards.MemSpyTraceListener#operationFinished(com.nokia.s60tools.memspy.ui.wizards.MemSpyTraceListener.LauncherAction, com.nokia.s60tools.memspy.containers.SWMTLogInfo)
+ */
+ public void operationFinished(LauncherAction action, SWMTLogInfo swmtLogInfo, boolean timerRunning) {
+ if( action == LauncherAction.TIMED_SWMT_UPDATE ){
+
+ // update received log to table
+ this.receivedLog = swmtLogInfo;
+ this.updateReceivedSWMTLog( timerRunning );
+
+ // increase cycle number
+ cycleNumber++;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.nokia.s60tools.memspy.ui.wizards.MemSpyTraceListener#startedReceivingSWMTLog()
+ */
+ public void startedReceivingSWMTLog() {
+
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "SWMTLogPage.startedReceivingSWMTLog"); //$NON-NLS-1$
+
+ // Set MemSpy's state correct
+ this.memSpyOperationRunning = true;
+ this.memSpyTimerRunning = false;
+ }
+
+ /**
+ * Method that is called when "Get Log Now" - button is pressed.
+ */
+ private void getLogNowPressed(){
+
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "SWMTLogPage.getLogNowPressed"); //$NON-NLS-1$
+
+ // if cycle number is zero(this is first log file in list), MemSpy's SWMT-logging needs to be reseted.
+ boolean reset = false;
+ if( deviceLogsTable.getItemCount() == 0 ){
+ reset = true;
+ cycleNumber = 1;
+ }
+
+ //Check if S60 application is ment to reset between cycles
+ boolean isToBeClosedBetweenCycles = MemSpyPreferences.isCloseSymbianAgentBetweenCyclesSelected() && !MemSpyPreferences.isProfileTrackedCategoriesSelected();
+ if(isToBeClosedBetweenCycles){
+ reset = true;
+ }
+
+ // Create new SWMTLogInfo object
+ receivedLog = new SWMTLogInfo();
+
+ // get temp file name for swmt-log
+ Date date = new Date();
+ receivedLog.setPath( MemSpyFileOperations.getTempFileNameForSWMTLog( cycleNumber, date ) );
+ receivedLog.setType( SWMTLogType.FILE );
+ receivedLog.setDate(date);
+ receivedLog.setType(SWMTLogType.DEVICE);
+
+ if( traceEngine.requestSWMTLog( this, receivedLog.getPath(), reset) ){
+
+ try {
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "SWMTLogPage.getLogNowPressed/getContainer().run/receiveSWMTLogProcess"); //$NON-NLS-1$
+ getContainer().run(true, false, receiveSWMTLogProcess);
+ } catch (InvocationTargetException e1) {
+ // do nothing
+ e1.printStackTrace();
+ } catch (InterruptedException e1) {
+ // do nothing
+ e1.printStackTrace();
+ }
+ enableAndDisableDeviceButtonsAndSWMTCategoryGroup();
+ }
+ else{
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "SWMTLogPage.getLogNowPressed/openError"); //$NON-NLS-1$
+ MessageDialog.openError( this.getShell(), ERROR_MEMSPY, ERROR_CONNECTION);
+ receivedLog = null;
+ }
+ }
+
+
+ /**
+ * Method that is called when "Start Timer" - button is pressed.
+ */
+ private void getLogWithTimerPressed(){
+
+ int interval = this.getTimerInteval();
+
+ // if interval is not zero continue
+ if( interval != 0 ){
+
+ // if cycle number is zero(this is first log file in list), MemSpy's SWMT-logging needs to be reseted.
+ boolean reset = false;
+ if( deviceLogsTable.getItemCount() == 0 ){
+ reset = true;
+ cycleNumber = 1;
+ }
+
+ boolean isToBeClosedBetweenCycles = MemSpyPreferences.isCloseSymbianAgentBetweenCyclesSelected() && !MemSpyPreferences.isProfileTrackedCategoriesSelected();
+
+ // if connect to trace source was established
+ if( traceEngine.startSWMTTimer(this, cycleNumber, reset, isToBeClosedBetweenCycles, interval) ){
+
+ // change Cancel text from wizard to "Stop Timer"
+ setCancelText("Stop Timer");
+
+ // launch receiveSWMTLog process.
+ try {
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "SWMTLogPage.getLogWithTimerPressed/getContainer().run/receiveSWMTLogProcess"); //$NON-NLS-1$
+ getContainer().run(true, true, receiveSWMTLogProcess);
+ } catch (InvocationTargetException e1) {
+ // do nothing
+ e1.printStackTrace();
+ } catch (InterruptedException e1) {
+ // do nothing
+ e1.printStackTrace();
+ }
+
+ // Enable/Disable device buttons.
+ enableAndDisableDeviceButtonsAndSWMTCategoryGroup();
+
+ }
+ else{
+ // increase cycle number
+ cycleNumber++;
+
+ // show error message
+ MessageDialog.openError( this.getShell(), ERROR_MEMSPY, ERROR_CONNECTION);
+
+ }
+ }
+ }
+
+ /**
+ * Method that is called when stop timer-button is pressed.
+ */
+ private void stopTimerPressed(){
+
+ this.memSpyTimerRunning = false;
+ if( traceEngine.stopSWMTTimer() ){
+ // if timer is stopped immediately, hide progress bar
+ memSpyStopping = false;
+
+ this.setCancelText("Cancel");
+ }
+ }
+
+ /**
+ * Created needed MemSpy processes.
+ */
+ private void createMemSpyProcesses(){
+
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "SWMTLogPage.createMemSpyProcesses/receiveSWMTLogProcess"); //$NON-NLS-1$
+
+ // receive SWMT-Log process
+ receiveSWMTLogProcess = new IRunnableWithProgress() {
+ /**
+ * In receive SWMT-Log process process views progress bar and checks every 0,5 seconds
+ * if current MemSpy process has been finished. After MemSpy process has finished. Progress
+ * bar is hidden.
+ */
+ public void run(IProgressMonitor monitor) {
+ memSpyOperationRunning = true;
+
+ monitor.beginTask(RECEIVING_SWMT_LOG, IProgressMonitor.UNKNOWN);
+ while(true){
+ // some delay, so that launcher has time to set it's state correct.
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ // do nothing
+ }
+
+ // If no operations are on-going, break
+ if( !memSpyOperationRunning && !memSpyTimerRunning && !memSpyStopping ){
+ break;
+ }
+
+ // If Cancel-message received, send stop request.
+ if( monitor.isCanceled() ){
+ monitor.beginTask(STOPPING_TIMER, IProgressMonitor.UNKNOWN);
+ stopTimerPressed();
+ }
+
+ // If timer and operation are running, show "Waiting for timer to expire"-text
+ else if ( memSpyTimerRunning ){
+ monitor.beginTask(WAITING_FOR_TIMER, IProgressMonitor.UNKNOWN);
+ }
+
+ // If MemSpy operation is running, show "Requesting Heap Dump" -text
+ else if( memSpyOperationRunning ){
+ monitor.beginTask(RECEIVING_SWMT_LOG, IProgressMonitor.UNKNOWN);
+ }
+ }
+ monitor.done();
+ }
+ };
+ }
+
+ /**
+ * Changes wizard's cancel button's text.
+ * @param newText new text for button
+ */
+ private void setCancelText( final String newText ){
+ Runnable updateUiRunnable = new Runnable(){
+ public void run(){
+ // change Cancel text from wizard back to "Cancel"
+ ( (MemSpyWizard)getWizard() ).setCancelText( newText );
+ }
+ };
+ // needs to be done on UI thread.
+ Display.getDefault().asyncExec(updateUiRunnable);
+ }
+
+ /* (non-Javadoc)
+ * @see com.nokia.s60tools.memspy.ui.wizards.SWMTCategoryGroupComposite.SWMTCategorySelectionChangeListener#categorySelectionChanged(int)
+ */
+ public void setCategorySelection(int newCategorySelection, boolean isProfileSettings) {
+ traceEngine.setCategoriesForSWMT(newCategorySelection, isProfileSettings);
+ }
+
+ /* (non-Javadoc)
+ * @see com.nokia.s60tools.memspy.ui.wizards.SWMTCategorySelectionMediator#getCategorySelection()
+ */
+ public int getCategorySelection() {
+ return traceEngine.getCategoriesForSWMT();
+ }
+
+ /* (non-Javadoc)
+ * @see com.nokia.s60tools.memspy.ui.wizards.SWMTCategorySelectionMediator#setAllTrackedCategoriesSelected(boolean)
+ */
+ public void setProfileTrackedCategoriesSelected(
+ boolean isAllCategoriesSelected) {
+ traceEngine.setProfileTrackedCategoriesSelected(isAllCategoriesSelected);
+ }
+
+ /* (non-Javadoc)
+ * @see com.nokia.s60tools.memspy.ui.wizards.SWMTCategorySelectionMediator#getAllTrackedCategoriesSelected()
+ */
+ public boolean isProfileTrackedCategoriesSelected() {
+ return traceEngine.isProfileTrackedCategoriesSelected();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.DialogPage#dispose()
+ */
+ public void dispose(){
+ DbgUtility.println(DbgUtility.PRIORITY_OPERATION, this.getClass().getSimpleName() + ": dispose()"); //$NON-NLS-1$
+ categoryGroupComposite.dispose();
+ super.dispose();
+ }
+
+
+}
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/wizards/SelectActionPage.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/ui/wizards/SelectActionPage.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,172 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+package com.nokia.s60tools.memspy.ui.wizards;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.ui.PlatformUI;
+
+import com.nokia.s60tools.memspy.model.UserEnteredData;
+import com.nokia.s60tools.memspy.model.UserEnteredData.ValueTypes;
+import com.nokia.s60tools.memspy.resources.HelpContextIDs;
+import com.nokia.s60tools.ui.wizards.S60ToolsWizardPage;
+
+public class SelectActionPage extends S60ToolsWizardPage{
+
+ // Available actions
+ public enum MemSpyAction{IMPORT_HEAP, COMPARE_HEAPS, SWMT}
+
+ // UI components
+ public Button importHeapRadioButton;
+ public Button compareTwoHeapsRadioButton;
+ public Button swmtRadioButton;
+
+ /*
+ * (non-Javadoc)
+ * @see com.nokia.s60tools.ui.wizards.S60ToolsWizardPage#setInitialFocus()
+ */
+ public void setInitialFocus() {
+ }
+
+ public void recalculateButtonStates() {
+ }
+
+
+ protected SelectActionPage(String pageName) {
+ super(pageName);
+ setTitle("MemSpy Import Wizard, First step");
+ setDescription("Select action you wish to perform with MemSpy.");
+ }
+ public void createControl(Composite parent) {
+ // Radio button group
+
+ Composite composite = new Composite(parent, SWT.NULL);
+
+ // create the desired layout for this wizard page
+ GridLayout gl = new GridLayout();
+ gl.numColumns = 1;
+ composite.setLayout(gl);
+
+ // Radio Button Group
+ GridLayout radioButtonGroupGridLayout = new GridLayout();
+ Group radioButtonGroup = new Group (composite, SWT.NONE);
+ radioButtonGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ radioButtonGroup.setText("Select Action:");
+ radioButtonGroup.setLayout(radioButtonGroupGridLayout);
+ GridData radioButtonGridData = new GridData(GridData.FILL_HORIZONTAL);
+ radioButtonGridData.horizontalSpan = 2;
+
+ // Import Heap wizard radio button
+ importHeapRadioButton = new Button(radioButtonGroup, SWT.RADIO);
+ importHeapRadioButton.setText("Import heap and analyse log with Heap Analyser");
+ importHeapRadioButton.setLayoutData(radioButtonGridData);
+
+ // Compare Two Heaps radio button
+ compareTwoHeapsRadioButton = new Button(radioButtonGroup, SWT.RADIO);
+ compareTwoHeapsRadioButton.setText("Import heaps and compare logs with Heap Analyser");
+ compareTwoHeapsRadioButton.setLayoutData(radioButtonGridData);
+
+ // SWMT wizard radio button
+ swmtRadioButton = new Button(radioButtonGroup, SWT.RADIO);
+ swmtRadioButton.setText("Import System Wide Memory Tracking logs and analyse them with SWMT Analyser");
+ swmtRadioButton.setLayoutData(radioButtonGridData);
+
+ // restore previous value of radio button.
+ // if last value is not found, set selection to import heap
+
+ UserEnteredData data = new UserEnteredData();
+ int lastUsed = data.getPreviousRadioButtonSelection(ValueTypes.SELECT_ACTION);
+
+ if( lastUsed == 2 ){
+ compareTwoHeapsRadioButton.setSelection(true);
+ }
+ else if( lastUsed == 3 ){
+ swmtRadioButton.setSelection(true);
+ }
+ else {
+ importHeapRadioButton.setSelection(true);
+ }
+
+ setHelps();
+ setInitialFocus();
+ setControl(composite);
+ }
+
+ /**
+ * getAction
+ * @return currently selected action
+ */
+ public MemSpyAction getAction(){
+ if( importHeapRadioButton.getSelection() ){
+ return MemSpyAction.IMPORT_HEAP;
+ }
+ else if( compareTwoHeapsRadioButton.getSelection() ){
+ return MemSpyAction.COMPARE_HEAPS;
+ }
+ else{
+ return MemSpyAction.SWMT;
+ }
+
+ }
+
+
+ /**
+ * saves user entered data from UI components so that it can be restored later.
+ */
+ public void saveUserEnteredData(){
+ UserEnteredData data = new UserEnteredData();
+
+ // Save Action radio-buttons state
+ if( compareTwoHeapsRadioButton.getSelection() ){
+ data.saveRadioButtonSelection(ValueTypes.SELECT_ACTION, 2);
+ }
+ else if( swmtRadioButton.getSelection() ){
+ data.saveRadioButtonSelection(ValueTypes.SELECT_ACTION, 3);
+ }
+ else {
+ data.saveRadioButtonSelection(ValueTypes.SELECT_ACTION, 1);
+ }
+ }
+
+ /**
+ * canFlipPreviousPage
+ * returns always false because this is first page of wizard.
+ */
+ public boolean canFlipPreviousPage(){
+ return false;
+ }
+
+ /**
+ * Sets this page's context sensitive helps
+ *
+ */
+ protected void setHelps() {
+ PlatformUI.getWorkbench().getHelpSystem().setHelp( importHeapRadioButton, HelpContextIDs.MEMSPY_SELECT_ACTION);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp( compareTwoHeapsRadioButton, HelpContextIDs.MEMSPY_SELECT_ACTION);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp( swmtRadioButton, HelpContextIDs.MEMSPY_SELECT_ACTION);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp( this.getShell(), HelpContextIDs.MEMSPY_SELECT_ACTION);
+
+ }
+
+}
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/util/MemSpyConsole.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.memspy/src/com/nokia/s60tools/memspy/util/MemSpyConsole.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+package com.nokia.s60tools.memspy.util;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+
+import com.nokia.s60tools.memspy.resources.ImageKeys;
+import com.nokia.s60tools.memspy.resources.ImageResourceManager;
+import com.nokia.s60tools.util.console.AbstractProductSpecificConsole;
+
+/**
+ * Singleton class that offers console printing
+ * services for the MemSpy plug-in.
+ */
+public class MemSpyConsole extends AbstractProductSpecificConsole {
+
+ /**
+ * Singleton instance of the class.
+ */
+ static private MemSpyConsole instance = null;
+
+ /**
+ * Public accessor method.
+ * @return Singleton instance of the class.
+ */
+ static public MemSpyConsole getInstance(){
+ if(instance == null ){
+ instance = new MemSpyConsole();
+ }
+ return instance;
+ }
+
+ /**
+ * Private constructor forcing Singleton usage of the class.
+ */
+ private MemSpyConsole(){
+ }
+
+ /* (non-Javadoc)
+ * @see com.nokia.s60tools.util.console.AbstractProductSpecificConsole#getProductConsoleName()
+ */
+ protected String getProductConsoleName() {
+ return "MemSpy Console";
+ }
+
+ /* (non-Javadoc)
+ * @see com.nokia.s60tools.util.console.AbstractProductSpecificConsole#getProductConsoleImageDescriptor()
+ */
+ protected ImageDescriptor getProductConsoleImageDescriptor() {
+ return ImageResourceManager.getImageDescriptor(ImageKeys.IMG_APP_ICON);
+ }
+
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser.thirdpartysources/.classpath
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.swmtanalyser.thirdpartysources/.classpath Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser.thirdpartysources/.settings/org.eclipse.jdt.core.prefs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.swmtanalyser.thirdpartysources/.settings/org.eclipse.jdt.core.prefs Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,8 @@
+#Tue Sep 22 14:04:29 EEST 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser.thirdpartysources/META-INF/MANIFEST.MF
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.swmtanalyser.thirdpartysources/META-INF/MANIFEST.MF Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Carbide.c++ Extensions - SWMT Analyser Thirdpartysources
+Bundle-SymbolicName: com.nokia.s60tools.swmtanalyser.thirdpartysources
+Bundle-Version: 1.6.0
+Bundle-Activator: com.nokia.s60tools.swmtanalyser.thirdpartysources.Activator
+Bundle-Vendor: Nokia
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser.thirdpartysources/about.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.swmtanalyser.thirdpartysources/about.html Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,22 @@
+
+
+
+About
+
+
+
+About This Content
+
+Dec 11, 2009
+
+Copyright
+
+
+
+
Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
+License: http://www.eclipse.org/legal/epl-v10.html .
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser.thirdpartysources/build.properties
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.swmtanalyser.thirdpartysources/build.properties Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,22 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+#
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ iText-src-2.1.7.zip,\
+ about.html
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser.thirdpartysources/iText-src-2.1.7.zip
Binary file sysperfana/memspyext/com.nokia.s60tools.swmtanalyser.thirdpartysources/iText-src-2.1.7.zip has changed
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser.thirdpartysources/src/com/nokia/s60tools/swmtanalyser/thirdpartysources/Activator.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.swmtanalyser.thirdpartysources/src/com/nokia/s60tools/swmtanalyser/thirdpartysources/Activator.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+package com.nokia.s60tools.swmtanalyser.thirdpartysources;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ /**
+ * The plug-in ID for third party sources plugin
+ */
+ public static final String PLUGIN_ID = "com.nokia.s60tools.swmtanalyser.thirdpartysources";
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/.classpath
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/.classpath Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/.settings/org.eclipse.jdt.core.prefs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/.settings/org.eclipse.jdt.core.prefs Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,8 @@
+#Tue Sep 22 14:04:40 EEST 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/META-INF/MANIFEST.MF
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/META-INF/MANIFEST.MF Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,28 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Carbide.c++ Extensions - Swmt Analyser
+Bundle-SymbolicName: com.nokia.s60tools.swmtanalyser;singleton:=true
+Bundle-Version: 1.6.0
+Bundle-Activator: com.nokia.s60tools.swmtanalyser.SwmtAnalyserPlugin
+Bundle-Vendor: Nokia
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.ui.forms,
+ com.nokia.s60tools.ui;bundle-version="1.5.0",
+ org.eclipse.core.filesystem,
+ org.eclipse.core.resources,
+ org.eclipse.ui.ide,
+ org.eclipse.ui.editors,
+ org.eclipse.draw2d,
+ com.nokia.s60tools.util;bundle-version="1.5.0"
+Bundle-ActivationPolicy: lazy
+Bundle-ClassPath: poi-3.2-FINAL-20081019.jar,
+ poi-contrib-3.2-FINAL-20081019.jar,
+ poi-scratchpad-3.2-FINAL-20081019.jar,
+ iText-2.1.7.jar,
+ .
+Export-Package: com.nokia.s60tools.swmtanalyser.data;x-friends:="com.nokia.s60tools.swmtanalyser.tests",
+ com.nokia.s60tools.swmtanalyser.exception;x-friends:="com.nokia.s60tools.swmtanalyser.tests",
+ com.nokia.s60tools.swmtanalyser.model;x-friends:="com.nokia.s60tools.swmtanalyser.tests",
+ com.nokia.s60tools.swmtanalyser.ui.actions
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/about.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/about.html Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,22 @@
+
+
+
+About
+
+
+
+About This Content
+
+Dec 11, 2009
+
+Copyright
+
+
+
+
Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
+License: http://www.eclipse.org/legal/epl-v10.html .
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/build.properties
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/build.properties Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,13 @@
+javacSource=1.5
+javacTarget=1.5
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ poi-3.2-FINAL-20081019.jar,\
+ poi-contrib-3.2-FINAL-20081019.jar,\
+ poi-scratchpad-3.2-FINAL-20081019.jar,\
+ icons/,\
+ iText-2.1.7.jar,\
+ about.html
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/iText-2.1.7.jar
Binary file sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/iText-2.1.7.jar has changed
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/icons/Launch_SWMT.png
Binary file sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/icons/Launch_SWMT.png has changed
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/icons/green.png
Binary file sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/icons/green.png has changed
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/icons/red.png
Binary file sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/icons/red.png has changed
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/icons/yellow.png
Binary file sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/icons/yellow.png has changed
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/plugin.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/plugin.xml Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/poi-3.2-FINAL-20081019.jar
Binary file sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/poi-3.2-FINAL-20081019.jar has changed
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/poi-contrib-3.2-FINAL-20081019.jar
Binary file sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/poi-contrib-3.2-FINAL-20081019.jar has changed
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/poi-scratchpad-3.2-FINAL-20081019.jar
Binary file sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/poi-scratchpad-3.2-FINAL-20081019.jar has changed
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/SwmtAnalyserPlugin.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/SwmtAnalyserPlugin.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,155 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+package com.nokia.s60tools.swmtanalyser;
+
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+import com.nokia.s60tools.swmtanalyser.analysers.IAnalyser;
+import com.nokia.s60tools.swmtanalyser.analysers.LinearAnalyser;
+import com.nokia.s60tools.swmtanalyser.analysers.ThreadDataAnalyser;
+import com.nokia.s60tools.util.console.IConsolePrintUtility;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class SwmtAnalyserPlugin extends AbstractUIPlugin {
+
+ ArrayList Analysers = new ArrayList();
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "com.nokia.s60tools.swmtanalyser";
+
+ // The shared instance
+ private static SwmtAnalyserPlugin plugin;
+
+ private String pluginInstallPath = "";
+
+ /**
+ * Console for plug-in
+ */
+ private IConsolePrintUtility console;
+
+ /**
+ * The constructor
+ */
+ public SwmtAnalyserPlugin() {
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ registerAnalyser(new LinearAnalyser());
+ registerAnalyser(new ThreadDataAnalyser());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static SwmtAnalyserPlugin getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+
+ /**
+ * @param analyser will be registered for analysis. The tool invokes analysis
+ * on all registered analysers.
+ */
+ public void registerAnalyser(IAnalyser analyser)
+ {
+ if(!Analysers.contains(analyser))
+ Analysers.add(analyser);
+ }
+
+ public IAnalyser [] getRegisteredAnalysers()
+ {
+ return Analysers.toArray(new IAnalyser[0]);
+ }
+
+ public static String getPluginInstallPath() {
+ try {
+ if ("".equals(plugin.pluginInstallPath)) {
+ // URL to the plugin's root ("/")
+ URL relativeURL = plugin.getBundle().getEntry("/");
+ // Converting into local path
+ URL localURL = FileLocator.toFileURL(relativeURL);
+ // Getting install location in correct form
+ File f = new File(localURL.getPath());
+ plugin.pluginInstallPath = f.getAbsolutePath();
+ }
+ return plugin.pluginInstallPath;
+ } catch (Exception e) {
+ return "";
+ }
+ }
+
+ /**
+ * Set the IConsolePrintUtility for plug-in
+ * @param console
+ */
+ public void setConsole(IConsolePrintUtility console) {
+ this.console = console;
+ }
+
+ /**
+ * Get the console print utility
+ * @return console
+ */
+ public static IConsolePrintUtility getConsole(){
+ return getDefault().getConsolePrintUtility();
+ }
+
+ /**
+ * Get the console print utility
+ * @return console
+ */
+ private IConsolePrintUtility getConsolePrintUtility(){
+ return console;
+ }
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/analysers/AnalyserConstants.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/analysers/AnalyserConstants.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+package com.nokia.s60tools.swmtanalyser.analysers;
+
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Constants for general Analyser purposes
+ */
+public class AnalyserConstants {
+
+ /**
+ * Priority types
+ */
+ public static enum Priority {NEGLIGIBLE,NORMAL,HIGH,CRITICAL}
+ /**
+ * Delta types
+ */
+ public static enum DeltaType {SIZE, COUNT}
+ /**
+ * Color for Severity Normal
+ */
+ public static final Color COLOR_SEVERITY_NORMAL = new Color(Display.getCurrent(),121,255,121);//Green
+ /**
+ * Color for Severity High
+ */
+ public static final Color COLOR_SEVERITY_HIGH = new Color(Display.getCurrent(),255,255,138);//Yellow
+ /**
+ * Color for Severity Critical
+ */
+ public static final Color COLOR_SEVERITY_CRITICAL = new Color(Display.getCurrent(),254,106,99);//Red
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/analysers/IAnalyser.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/analysers/IAnalyser.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+package com.nokia.s60tools.swmtanalyser.analysers;
+
+import com.nokia.s60tools.swmtanalyser.data.ParsedData;
+
+/**
+ *
+ * This Interface must be implemented by all swmt analysers
+ */
+public interface IAnalyser {
+
+
+ /**
+ * Analysis is started from this method. And all analysis results
+ * are added to a list.
+ *
+ * @param logData data objects of log file
+ */
+ public void analyse(ParsedData logData);
+
+
+ /**
+ * The method returns the array of issues.
+ * @return results
+ */
+ public Object [] getResults();
+
+ /**
+ * The method returns the array of children for a given issue.
+ * @param parent must be {@link ResultsParentNodes}
+ * @return childrens
+ */
+ public Object [] getChildren (Object parent);
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/analysers/LinearAnalyser.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/analysers/LinearAnalyser.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,537 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+package com.nokia.s60tools.swmtanalyser.analysers;
+
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+
+import com.nokia.s60tools.swmtanalyser.data.DiskOverview;
+import com.nokia.s60tools.swmtanalyser.data.KernelElements;
+import com.nokia.s60tools.swmtanalyser.data.ParsedData;
+import com.nokia.s60tools.swmtanalyser.data.SystemData;
+import com.nokia.s60tools.swmtanalyser.model.SWMTLogReaderUtils;
+
+/**
+ *
+ * Defines Enum constants for all Kernel events to be analysed.
+ */
+enum KERNEL_EVENTS{
+ NO_OF_THREADS("Number of Threads"), NO_OF_PROCESSES("Number of Processes"),
+ NO_OF_TIMERS("Number of Timers"), NO_OF_SEMAPHORES("Number of Semaphores"),
+ NO_OF_SERVERS("Number of Servers"), NO_OF_MSGQUEUES("Number of Msg. Queues"),
+ NO_OF_SESSIONS("Number of Sessions"), NO_OF_CHUNKS("Number of Chunks");
+
+ private String event_name;
+ private String event_cateogory = "System Data";
+
+ private KERNEL_EVENTS(String eventName) {
+ this.event_name = eventName;
+ }
+
+ /**
+ * Returns event string
+ * @return name of the event
+ */
+ public String getEventName()
+ {
+ return event_name;
+ }
+
+ /**
+ * Returns event category
+ * @return category of the event
+ */
+ public String getEventCategory()
+ {
+ return event_cateogory;
+ }
+}
+
+/**
+ * Analyses RAM and DISK events and Kernal events. It implements interface IAnalyser.
+ *
+ */
+public class LinearAnalyser implements IAnalyser {
+
+ /**
+ * {@link #RAM_AND_DISK_TITLE} and {@link #KERNEL_ELEMS_TITLE} issues
+ */
+ ArrayList allIssues = new ArrayList();
+
+ protected static DecimalFormat Bytes_Format = new DecimalFormat("#####.##");
+ protected int [] time_intervals = null;
+
+ private static final String RAM_AND_DISK_TITLE = "RAM and Disk Memory";
+ private static final String KERNEL_ELEMS_TITLE = "Kernel Elements";
+
+ private ParsedData logData = null;
+
+
+ /* (non-Javadoc)
+ * @see com.nokia.s60tools.swmtanalyser.analysers.IAnalyser#analyse(com.nokia.s60tools.swmtanalyser.data.ParsedData)
+ */
+ public void analyse(ParsedData logData) {
+
+ this.logData = logData;
+ allIssues.clear();
+
+ //List to store RAM DISK issues
+ ArrayList ram_disk_issues = new ArrayList();
+
+ //Analyse RAM events using the logData and store the results in given list
+ analyseUsedRam(logData, ram_disk_issues);
+ //Analyse DISK events using the logData and store the results in given list
+ analyseDiskSizes(logData, ram_disk_issues);
+
+ //Create parent for all RAM and Disks issues.
+ ResultsParentNodes ram_and_disk_node = new ResultsParentNodes(RAM_AND_DISK_TITLE);
+ ram_and_disk_node.setChildren(ram_disk_issues);
+ allIssues.add(ram_and_disk_node);
+
+ //List to store Kernel issues
+ ArrayList kernel_issues = new ArrayList();
+ //Analyse Kernel events using the logData and store the results in given list
+ analyseKernelHandles(logData, kernel_issues);
+
+ //Create parent for all kernel issues found
+ ResultsParentNodes kernel_analysis_node = new ResultsParentNodes(KERNEL_ELEMS_TITLE);
+ kernel_analysis_node.setChildren(kernel_issues);
+ allIssues.add(kernel_analysis_node);
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.nokia.s60tools.swmtanalyser.analysers.IAnalyser#getResults()
+ */
+ public Object[] getResults() {
+ return allIssues.toArray();
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.nokia.s60tools.swmtanalyser.analysers.IAnalyser#getChildren(java.lang.Object)
+ */
+ public Object[] getChildren(Object parent)
+ {
+ if(parent instanceof ResultsParentNodes && allIssues.contains(parent))
+ {
+ return ((ResultsParentNodes)(parent)).getChildren();
+ }
+ else
+ return null;
+ }
+
+ /**
+ * This method linearly analyses the variation of used Ram size.
+ * @param logData signifies data of all seleced cycles.
+ * @param results signifies the list to which all issues will be added to.
+ */
+ private void analyseUsedRam(ParsedData logData, ArrayList results)
+ {
+ SWMTLogReaderUtils utils = new SWMTLogReaderUtils();
+
+ ArrayList systemData = utils.getSystemDataFromAllCycles(logData);
+
+ //Store used memory values
+ long [] usedRamValues = new long[logData.getNumberOfCycles()];
+
+ //Calculate used memory using the total and free memroy
+ for(int i=0; i results)
+ {
+ SWMTLogReaderUtils utils = new SWMTLogReaderUtils();
+ ArrayList diskNames = utils.getAllDiskNames(logData);
+ for(String disk:diskNames) {
+ ArrayList diskData = utils.getUsedMemoryAndSizesForDisk(disk, logData);
+
+ //Store used memory values
+ long [] diskUsedValues = new long[logData.getNumberOfCycles()];
+ for(int i=0; i results)
+ {
+ SWMTLogReaderUtils utils = new SWMTLogReaderUtils();
+ ArrayList kernelElems = utils.getKerenelElemsFromAllCycles(logData);
+
+ for(KERNEL_EVENTS event: KERNEL_EVENTS.values()){
+ long [] event_values = new long[kernelElems.size()];
+ for(int i=0; i 0)
+ overallNormalizedRoc[i] = overallNormalizedRoc[i-1] + normalizedRocWithTime[i];
+ else if(normalizedRocWithTime[i] < 0)
+ overallNormalizedRoc[i] = -Math.log(-normalizedRocWithTime[i])+ overallNormalizedRoc[i-1];
+ else
+ overallNormalizedRoc[i] = overallNormalizedRoc[i-1];
+ }
+
+ totalNormalizedRoc = overallNormalizedRoc[overallNormalizedRoc.length - 1];
+ int growth_index = calculateStableGrowth(values);
+ double growiness_factor = Math.exp(growth_index);
+
+ double log_of_first = 0;
+ double log_of_last = 0;
+
+ if(values[values.length -1] != 0)
+ log_of_last = Math.log(values[values.length -1]);
+
+ if(values[0] != 0)
+ log_of_first = Math.log(values[0]);
+
+ double log_diff = log_of_last - log_of_first;
+
+ double tmp = Math.round(Math.exp(totalNormalizedRoc));
+ double final_growth_factor = tmp * log_diff + growiness_factor;
+
+ return final_growth_factor;
+ }
+
+ protected long [] calculateNormalizedRoC(long [] values)
+ {
+ long [] deltas = new long[values.length];
+ long [] valueVsBaseline = new long[values.length];
+
+ deltas[0] = 0;
+ valueVsBaseline[0] = 0;
+
+ for(int i=1; i 0)
+ {
+ if(valueVsBaseline[i] > 0)
+ normalizedRoC[i] = (long)Math.log(deltas[i]);
+
+ else if(valueVsBaseline[i] < 0)
+ normalizedRoC[i] = (long)(Math.log(deltas[i] + valueVsBaseline[i]));
+ else
+ normalizedRoC[i] = 0;
+ }
+ else if(deltas[i] < 0)
+ normalizedRoC[i] = -(long)Math.log(-deltas[i]);
+ else
+ normalizedRoC[i] = 0;
+ }
+
+ return normalizedRoC;
+ }
+
+ private int calculateStableGrowth(long [] values)
+ {
+ int [] stableGrowiness = new int[values.length];
+
+ for(int i=0; i0)
+ {
+ long diff = values[i] - values[i-1];
+
+ if(diff > 0)
+ {
+ stableGrowiness[i] = stableGrowiness[i-1] + 1;
+ }
+ else if(diff == 0)
+ stableGrowiness[i] = stableGrowiness[i-1];
+ else
+ {
+ if(values[i] > values[0])
+ stableGrowiness[i] = stableGrowiness[i-1] - 1;
+ else
+ stableGrowiness[i] = 0;
+ }
+ }
+ }
+
+ return stableGrowiness[stableGrowiness.length-1];
+ }
+
+ /**
+ * The method calculates priority of an issue, based on the values of
+ * growiness factor, delta factor and number of Cycles.
+ * @param growing_factor
+ * @param delta_factor
+ * @param noOfCycles
+ * @return priority of the issue.
+ */
+ protected AnalyserConstants.Priority calculatePriorityFactor(double growing_factor, double delta_factor, int noOfCycles)
+ {
+ double high_threshold = Math.exp(noOfCycles - 1);
+ int temp = noOfCycles/2;
+ double normal_threshold = Math.exp(temp);
+
+ int temp1 = noOfCycles/4;
+ double low_threshold = Math.exp(temp1);
+
+ if(growing_factor > high_threshold)
+ {
+ if(delta_factor > 0)
+ return AnalyserConstants.Priority.CRITICAL;
+ }
+ if(growing_factor > normal_threshold)
+ {
+ if(delta_factor > 0.5)
+ return AnalyserConstants.Priority.CRITICAL;
+ else if(delta_factor > 0)
+ return AnalyserConstants.Priority.HIGH;
+ }
+ if(growing_factor > low_threshold)
+ {
+ if(delta_factor > 3)
+ return AnalyserConstants.Priority.CRITICAL;
+ else if(delta_factor > 0.5)
+ return AnalyserConstants.Priority.HIGH;
+ }
+ if(growing_factor > Math.exp(1))
+ {
+ if(delta_factor > 5)
+ return AnalyserConstants.Priority.CRITICAL;
+ else if(delta_factor > 3)
+ return AnalyserConstants.Priority.HIGH;
+ }
+ if(growing_factor >0 && delta_factor > 0)
+ return AnalyserConstants.Priority.NORMAL;
+
+ return AnalyserConstants.Priority.NEGLIGIBLE;
+ }
+
+ /**
+ * The method formats the given value to Bytes, Kilo Bytes and Mega Bytes.
+ * @param bytes -- value to be formatted.
+ * @return formatted string in KB or MB
+ */
+ protected String getFormattedBytes(long bytes)
+ {
+ String formatted_value = "";
+
+ if (bytes < 1024)
+ {
+ formatted_value += Bytes_Format.format(bytes) + " B"; //$NON-NLS-1$
+ }
+ else if (bytes <= 500 * 1024)
+ {
+ formatted_value += Bytes_Format.format(bytes / 1024) + " KB"; //$NON-NLS-1$
+ }
+ else
+ {
+ formatted_value += Bytes_Format.format(((float) bytes / (1024 * 1024))) + " MB"; //$NON-NLS-1$
+ }
+
+ return formatted_value;
+ }
+
+ /**
+ * The method calculates Growiness and priority based on given set of values.
+ * As no time intervals are provided, the method treats that the event is alive in all cycles (from first to last).
+ * @param event_values -- values of the event being analysed.
+ * @param result_elem -- structure to which calculated growiness and priority would be set to.
+ */
+ protected void calculateGrowinessAndPriority(long [] event_values, ResultElements result_elem)
+ {
+ SWMTLogReaderUtils utils = new SWMTLogReaderUtils();
+
+ if(time_intervals == null)
+ time_intervals = utils.getTimeIntervalsFromLogData(logData);
+
+ calculateGrowinessAndPriority(event_values, time_intervals, result_elem);
+
+ }
+
+ /**
+ * The method calculates Growiness and priority based on given set of values and given time intervals
+ * @param event_values
+ * @param log_intervals
+ * @param result_elem
+ */
+ protected void calculateGrowinessAndPriority(long [] event_values, int [] log_intervals, ResultElements result_elem)
+ {
+ double growiness = calculateGrowiness(event_values, log_intervals);
+
+ long firstValue = event_values[0];
+ long lastValue = event_values[event_values.length -1];
+
+ double log_of_first = 0;
+ double log_of_last = 0;
+
+ if(firstValue != 0)
+ log_of_first = Math.log(firstValue);
+ if(lastValue != 0)
+ log_of_last = Math.log(lastValue);
+
+ double prioritization_factor = log_of_last - log_of_first;
+
+ AnalyserConstants.Priority priority = calculatePriorityFactor(growiness, prioritization_factor, log_intervals.length);
+
+ result_elem.setGrowingFactor(growiness);
+ result_elem.setPriority(priority);
+
+ }
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/analysers/ResultElements.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/analysers/ResultElements.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,301 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+package com.nokia.s60tools.swmtanalyser.analysers;
+
+import org.eclipse.swt.graphics.Color;
+/**
+ * Input object for tree viewer in analysis tab.
+ *
+ */
+public class ResultElements implements Comparable{
+
+ /**
+ * Item name
+ */
+ public static final String ITEM_NAME_COLUMN = "Item name";
+ /**
+ * Event
+ */
+ public static final String EVENT_COLUMN = "Event";
+ /**
+ * Delta
+ */
+ public static final String DELTA_COLUMN = "Delta";
+ /**
+ * Severity
+ */
+ public static final String SEVERITY_COLUMN = "Severity";
+
+ private static final String TAB = "\t";
+
+ private String itemName;
+ private String event;
+ private String delta;
+ private long delta_value;
+ private double growing_factor;
+ private Color color;
+ private long [] event_values;
+
+ private AnalyserConstants.Priority priority = AnalyserConstants.Priority.NEGLIGIBLE;
+ private AnalyserConstants.DeltaType deltaType = AnalyserConstants.DeltaType.COUNT;
+
+ /**
+ * Construction
+ * @param itemName
+ * @param event
+ * @param delta
+ * @param deltaValue
+ * @param type
+ */
+ ResultElements(String itemName, String event, String delta, long deltaValue, AnalyserConstants.DeltaType type)
+ {
+ this.itemName = itemName;
+ this.event = event;
+ this.delta = delta;
+ this.delta_value = deltaValue;
+ this.deltaType = type;
+ }
+
+ /**
+ * @return item name
+ */
+ public String toString()
+ {
+ return this.itemName;
+ }
+
+
+ /**
+ * Get tab separated headers for this result.
+ * @return headers with tab as separator
+ */
+ public String getTabSeparatedHeaders()
+ {
+ //NOTE: If reorganized, also #getTabSeparatedValues() must reorganize
+ StringBuffer b = new StringBuffer();
+ b.append(ITEM_NAME_COLUMN);
+ b.append(TAB);
+ b.append(EVENT_COLUMN);
+ b.append(TAB);
+ b.append(DELTA_COLUMN);
+ b.append(TAB);
+ b.append(SEVERITY_COLUMN);
+
+ return b.toString();
+
+ }
+
+ /**
+ * Get tab separated values for this result.
+ * @return values
+ */
+ public String getTabSeparatedValues()
+ {
+ //NOTE: If reorganized, also #getTabSeparatedHeaders() must reorganize
+ StringBuffer b = new StringBuffer();
+ b.append(itemName);
+ b.append(TAB);
+ b.append(event);
+ b.append(TAB);
+ b.append(delta);
+ b.append(TAB);
+ b.append(getPriority());
+
+ return b.toString();
+
+ }
+
+
+
+ /**
+ * Get delta
+ * @return delta
+ */
+ public String getDelta() {
+ return delta;
+ }
+
+ /**
+ * Set delta
+ * @param delta
+ */
+ public void setDelta(String delta) {
+ this.delta = delta;
+ }
+
+ /**
+ * Get item name
+ * @return item name
+ */
+ public String getItemName() {
+ return itemName;
+ }
+
+ /**
+ * Get event
+ * @return event
+ */
+ public String getEvent() {
+ return event;
+ }
+
+ /**
+ * Set event
+ * @param event
+ */
+ public void setEvent(String event) {
+ this.event = event;
+ }
+
+ /**
+ * Get growing factor
+ * @return growing factor
+ */
+ public double getGrowingFactor() {
+ return growing_factor;
+ }
+
+ /**
+ * Set growing factor
+ * @param growing_factor
+ */
+ public void setGrowingFactor(double growing_factor) {
+ this.growing_factor = growing_factor;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(ResultElements input) {
+
+ int priority_comparision = this.getPriority().compareTo(input.getPriority());
+
+ if(priority_comparision == 0)
+ {
+ if(this.growing_factor > input.growing_factor)
+ return 1;
+ else if(this.growing_factor < input.growing_factor)
+ return -1;
+ else
+ return 0;
+ }
+ else
+ return priority_comparision;
+ }
+
+ /**
+ * Compare this objects {@link #getDelta()} to given object {@link #getDelta()}
+ * Returns a negative integer, zero, or a positive integer
+ * as this object is less than, equal to, or greater than the specified object.
+ * @param input
+ * @return 0 if this object is equal to given object,
+ * 1 if this object is greater to given object,
+ * -1 if this object is less to given object
+ */
+ public int compareByDelta(ResultElements input)
+ {
+ long input_delta = input.getDeltaValue();
+
+ if(delta_value > input_delta)
+ return 1;
+ else if(delta_value < input_delta)
+ return -1;
+ else
+ return 0;
+
+ }
+ /**
+ * Get priority
+ * @return priority
+ */
+ public AnalyserConstants.Priority getPriority() {
+ return priority;
+ }
+
+ /**
+ * Set priority
+ * @param priority
+ */
+ public void setPriority(AnalyserConstants.Priority priority) {
+ this.priority = priority;
+ }
+
+ /**
+ * Get delta
+ * @return delta
+ */
+ public long getDeltaValue() {
+ return delta_value;
+ }
+
+ /**
+ * Set delta
+ * @param delta_value
+ */
+ public void setDeltaValue(long delta_value) {
+ this.delta_value = delta_value;
+ }
+
+ /**
+ * Get Delta type
+ * @return delta type
+ */
+ public AnalyserConstants.DeltaType getType() {
+ return deltaType;
+ }
+
+ /**
+ * Set delta type
+ * @param type
+ */
+ public void setType(AnalyserConstants.DeltaType type) {
+ this.deltaType = type;
+ }
+
+ /**
+ * Get color
+ * @return color
+ */
+ public Color getColor() {
+ return color;
+ }
+
+ /**
+ * Set Color
+ * @param color
+ */
+ public void setColor(Color color) {
+ this.color = color;
+ }
+
+ /**
+ * Get event values
+ * @return values
+ */
+ public long[] getEventValues() {
+ return event_values;
+ }
+
+ /**
+ * Set event values
+ * @param event_values
+ */
+ public void setEventValues(long[] event_values) {
+ this.event_values = event_values;
+ }
+}
+
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/analysers/ResultsParentNodes.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/analysers/ResultsParentNodes.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,93 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+package com.nokia.s60tools.swmtanalyser.analysers;
+
+import java.util.ArrayList;
+/**
+ * Input object(parent) for tree viewer in analysis tab.
+ *
+ */
+public class ResultsParentNodes{
+
+ private String description;
+ private ArrayList children;
+ private ArrayList filteredChildren = new ArrayList();
+
+ /**
+ * Construction
+ * @param description
+ */
+ ResultsParentNodes(String description)
+ {
+ this.description = description;
+ }
+
+ /**
+ * Set the childrens of this element
+ * @param childArrayList
+ */
+ public void setChildren(ArrayList childArrayList)
+ {
+ this.children = childArrayList;
+ }
+
+ /**
+ * Get childrens
+ * @return childrens as {@link ResultElements}
+ */
+ public Object[] getChildren()
+ {
+ if(children != null)
+ return children.toArray(new ResultElements[0]);
+ else
+ return null;
+ }
+
+ /**
+ * Get description
+ */
+ public String toString()
+ {
+ return this.description;
+ }
+
+ /**
+ * Add a filtered children
+ * @param child
+ */
+ public void addFilteredChild(ResultElements child)
+ {
+ filteredChildren.add(child);
+ }
+
+ /**
+ * Get all filtered childrens
+ * @return
+ */
+ public ArrayList getFilteredChildrenList()
+ {
+ return filteredChildren;
+ }
+ /**
+ * Get count for filtered childrens
+ * @return count
+ */
+ public int getFilteredCount()
+ {
+ return filteredChildren.size();
+ }
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/analysers/ThreadDataAnalyser.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/analysers/ThreadDataAnalyser.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,264 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+package com.nokia.s60tools.swmtanalyser.analysers;
+
+import java.util.ArrayList;
+
+import com.nokia.s60tools.swmtanalyser.data.CycleData;
+import com.nokia.s60tools.swmtanalyser.data.ParsedData;
+import com.nokia.s60tools.swmtanalyser.data.ThreadData;
+import com.nokia.s60tools.swmtanalyser.data.ThreadSegments;
+import com.nokia.s60tools.swmtanalyser.model.SWMTLogReaderUtils;
+
+/**
+ *
+ * Defines Enum constants for all Thread events to be analysed.
+ */
+enum THREAD_EVENTS {
+
+ HEAP_SIZE("Heap size"), NO_OF_FILES("No of Files"), HEAP_ALLOC_SPACE("Heap allocated space"), HEAP_ALLOC_CELLS("Heap allocated cell count"), NO_OF_PSHANDLES("No of PS Handles");
+
+ private String description;
+
+ THREAD_EVENTS(String desc)
+ {
+ description = desc;
+ }
+ public String getDescription()
+ {
+ return description;
+ }
+}
+/**
+ * Analyser class implementation for Thread data
+ */
+public class ThreadDataAnalyser extends LinearAnalyser{
+
+ private static final String THREADS_TITLE = "Threads";
+
+ ArrayList treeElements = new ArrayList();
+
+
+ /* (non-Javadoc)
+ * @see com.nokia.s60tools.swmtanalyser.analysers.LinearAnalyser#analyse(com.nokia.s60tools.swmtanalyser.data.ParsedData)
+ */
+ public void analyse(ParsedData logData) {
+
+ treeElements.clear();
+ ResultsParentNodes thread_issues = new ResultsParentNodes(THREADS_TITLE);
+
+ SWMTLogReaderUtils utils = new SWMTLogReaderUtils();
+
+ ArrayList heapThreads = utils.getAllThreadNames(logData);
+
+ int in = 0;
+
+ ArrayList sub_issues = new ArrayList ();
+
+ for(String thName: heapThreads)
+ {
+ ArrayList thData = utils.getHeapDataFromAllCycles(thName, logData);
+ ThreadSegments [] segments = utils.getHeapSegments(thData);
+
+ if(segments != null){
+
+ THREAD_EVENTS [] events = THREAD_EVENTS.values();
+
+ for(THREAD_EVENTS event:events)
+ analyseThreadEvent(event, thName, thData, logData, segments, sub_issues);
+
+ }
+
+ in++;
+ }
+
+ thread_issues.setChildren(sub_issues);
+
+ treeElements.add(thread_issues);
+
+ }
+
+ /* (non-Javadoc)
+ * @see com.nokia.s60tools.swmtanalyser.analysers.LinearAnalyser#getResults()
+ */
+ public Object[] getResults() {
+
+ return treeElements.toArray();
+ }
+
+ /* (non-Javadoc)
+ * @see com.nokia.s60tools.swmtanalyser.analysers.LinearAnalyser#getChildren(java.lang.Object)
+ */
+ public Object[] getChildren(Object parent)
+ {
+ if(parent instanceof ResultsParentNodes && treeElements.contains(parent))
+ {
+ return ((ResultsParentNodes)(parent)).getChildren();
+ }
+ else
+ return null;
+ }
+
+ /**
+ * This method analyses data of given thread event
+ * @param event thread event to be analysed
+ * @param thName name of the thread
+ * @param heapData represents data of given thread from all log files
+ * @param logData represents data of all log files
+ * @param thSegments array of segments in which the thread is alive
+ * @param results structure to which all thread issues will be added to.
+ */
+ private void analyseThreadEvent(THREAD_EVENTS event, String thName, ArrayList heapData, ParsedData logData, ThreadSegments [] thSegments, ArrayList results)
+ {
+ SWMTLogReaderUtils utils = new SWMTLogReaderUtils();
+ CycleData[] cyclesData = logData.getLogData();
+
+ for(int i=0; i 1){
+ int id = i+1;
+ thread_instance += "(0" + id + ")";
+
+ int index;
+
+ for(index=0; index < startIndex; index++){
+ event_values[index] = 0;
+ }
+
+ for(int tmp =0; tmp < heap_size_values.length; tmp++)
+ {
+ event_values[index] = heap_size_values[tmp];
+ index++;
+ }
+
+ for(;index < cyclesData.length ;index++)
+ event_values[index] = 0;
+ }
+ else
+ {
+ for(int index=0; index < heapData.size(); index++)
+ event_values[index] = getEventValue(heapData.get(index), event);
+ }
+ String formatted_delta = Long.toString(delta);
+ AnalyserConstants.DeltaType delta_type = AnalyserConstants.DeltaType.COUNT;
+ switch(event)
+ {
+ case HEAP_SIZE:
+ case HEAP_ALLOC_SPACE:
+ formatted_delta = getFormattedBytes(delta);
+ delta_type = AnalyserConstants.DeltaType.SIZE;
+ }
+
+ ResultElements res_elem = new ResultElements(thread_instance, event.getDescription(), formatted_delta, delta, delta_type);
+ res_elem.setEventValues(event_values);
+
+ calculateGrowinessAndPriority(heap_size_values, time_intervals, res_elem);
+ if(res_elem.getPriority() != AnalyserConstants.Priority.NEGLIGIBLE)
+ {
+ results.add(res_elem);
+ }
+ }
+
+ }
+
+ /**
+ *
+ * @param thData structure represents entire data of a thread in one log(cycle).
+ * @param event a specific thread event
+ * @return value of the given event.
+ */
+ private long getEventValue(ThreadData thData, THREAD_EVENTS event)
+ {
+ long event_value = 0;
+
+ if(thData.getStatus() == CycleData.Deleted)
+ return 0;
+
+ switch(event)
+ {
+ case HEAP_SIZE:
+ event_value = thData.getHeapChunkSize();
+ break;
+ case NO_OF_FILES:
+ event_value = thData.getOpenFiles();
+ break;
+ case HEAP_ALLOC_SPACE:
+ event_value = thData.getHeapAllocatedSpace();
+ break;
+ case HEAP_ALLOC_CELLS:
+ event_value = thData.getAllocatedCells();
+ break;
+ case NO_OF_PSHANDLES:
+ event_value = thData.getPsHandles();
+ break;
+ }
+
+ return event_value;
+
+ }
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/data/ChunksData.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/data/ChunksData.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,87 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+package com.nokia.s60tools.swmtanalyser.data;
+
+/**
+ * Stores chunk related data.
+ *
+ */
+public class ChunksData {
+ private String processName;
+ private String chunkName;
+ private String handle;
+ private String baseAddr;
+ private long size = -1;
+ private int attrib;
+ private boolean isKernelHandleDeleted;
+
+ public ChunksData() {}
+
+ public ChunksData(ChunksData target)
+ {
+ this.chunkName = target.chunkName;
+ this.processName = target.processName;
+ this.baseAddr = target.baseAddr;
+ this.size = target.size;
+ this.attrib = target.attrib;
+ }
+
+ public int getAttrib() {
+ return attrib;
+ }
+ public void setAttrib(int attrib) {
+ this.attrib = attrib;
+ }
+ public String getBaseAddr() {
+ return baseAddr;
+ }
+ public void setBaseAddr(String baseAddr) {
+ this.baseAddr = baseAddr;
+ }
+ public String getChunkName() {
+ return chunkName;
+ }
+ public void setChunkName(String chunkName) {
+ this.chunkName = chunkName;
+ }
+ public String getHandle() {
+ return handle;
+ }
+ public void setHandle(String handle) {
+ this.handle = handle;
+ }
+ public String getProcessName() {
+ return processName;
+ }
+ public void setProcessName(String processName) {
+ this.processName = processName;
+ }
+ public long getSize() {
+ return size;
+ }
+ public void setSize(long size) {
+ this.size = size;
+ }
+
+ public boolean isKernelHandleDeleted() {
+ return isKernelHandleDeleted;
+ }
+
+ public void setKernelHandleDeleted(boolean isKernelHandleDeleted) {
+ this.isKernelHandleDeleted = isKernelHandleDeleted;
+ }
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/data/CycleData.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/data/CycleData.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,953 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+package com.nokia.s60tools.swmtanalyser.data;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+
+public class CycleData implements Comparable{
+
+ private String fileName;
+ private int cycleNumber;
+ private String time;
+ private String romCheckSum;
+ private String romVersion;
+ private long changeCount;
+ private long freeMemory = -1;
+ private long totalMemory = -1;
+ private long prevFreeMem;
+ private long memspyRam;
+
+ public static final int Deleted = 0;
+ public static final int New = 1;
+ public static final int Alive =2;
+
+ private ArrayList psHandlesList;
+ private ArrayList kernelHandlesList;
+ private ArrayList disksList;
+ private ArrayList filesList;
+ private ArrayList globalDataChunksList;
+ private ArrayList stacksList;
+ private ArrayList nonRHeapList;
+ private ArrayList heapsList;
+ private ArrayList chunksList;
+ private ArrayList wndgList;
+
+ private ArrayList newlyCreatedDisks;
+ private ArrayList updatedDisks;
+ private ArrayList deletedDisks;
+
+ private ArrayList newlyCreatedThreads;
+ private ArrayList updatedThreads;
+ private ArrayList deletedThreads;
+
+ private ArrayList newlyCreatedHeaps;
+ private ArrayList updatedHeaps;
+ private ArrayList deletedHeaps;
+
+
+ /**
+ * @param diskData will be added to the list of disks, maintained internally
+ */
+ public void addDiskData(DiskData diskData)
+ {
+ if(disksList == null)
+ disksList = new ArrayList();
+
+ disksList.add(diskData);
+ }
+
+ /**
+ * @param kernelData will be added to the list of kernelhandles, maintained internally
+ */
+ public void addKernelData(KernelHandles kernelData)
+ {
+ if(kernelHandlesList == null)
+ kernelHandlesList = new ArrayList();
+
+ kernelHandlesList.add(kernelData);
+ }
+
+ /**
+ * @param fileData will be added to the list of files, maintained internally
+ */
+ public void addFileData(FilesData fileData)
+ {
+ if(filesList == null)
+ filesList = new ArrayList();
+
+ filesList.add(fileData);
+ }
+
+ /**
+ * @param HPAS Handles Data will be added to the list of ps handles data, maintained internally
+ */
+ public void addHPASHandlesData(PSHandlesData psHandlesData)
+ {
+ if(psHandlesList == null)
+ psHandlesList = new ArrayList();
+
+ psHandlesList.add(psHandlesData);
+ }
+
+ /**
+ * @param heapData will be added to the list of heaps, maintained internally
+ */
+ public void addHeapData(HeapData heapData)
+ {
+ if(heapsList == null)
+ heapsList = new ArrayList();
+
+ heapsList.add(heapData);
+ }
+
+ /**
+ * @param stackData will be added to the list of stacks, maintained internally
+ */
+ public void addStackData(StackData stackData)
+ {
+ if(stacksList == null)
+ stacksList = new ArrayList();
+
+ stacksList.add(stackData);
+ }
+
+ /**
+ * @param Chunks Data will be added to the list of chunks data, maintained internally
+ */
+ public void addChunksData(ChunksData chunksData)
+ {
+ if( chunksList == null)
+ chunksList = new ArrayList();
+
+ chunksList.add(chunksData);
+ }
+
+ /**
+ * @param Chunks Data will be added to the list of chunks data, maintained internally.
+ */
+ public void addGlobalChunksData(GlobalDataChunks globalChunksData)
+ {
+ if( globalDataChunksList == null)
+ globalDataChunksList = new ArrayList();
+
+ globalDataChunksList.add(globalChunksData);
+ }
+
+ /**
+ *
+ * @param Window Groups Data will be added to the list of window groups, maintained internally.
+ */
+ public void addWindowGroupsData(WindowGroups wndgData)
+ {
+ if(wndgList == null)
+ wndgList = new ArrayList();
+
+ wndgList.add(wndgData);
+ }
+
+ /**
+ * @returns an arraylist of disknames present in this cycle.
+ */
+ public ArrayList getDiskNames()
+ {
+ ArrayList diskNames = new ArrayList();
+
+ if(disksList != null)
+ for(DiskData d:disksList)
+ diskNames.add(d.getName());
+
+ return diskNames;
+ }
+
+ /**
+ * This method parses the cycle data and stores the disk names to
+ * corresponding lists based on their status.
+ *
+ */
+ public void parseDisksList()
+ {
+ newlyCreatedDisks = new ArrayList();
+ updatedDisks = new ArrayList();
+ deletedDisks = new ArrayList();
+
+ if(disksList != null){
+ for(DiskData d:disksList){
+ if(d.getStatus() == CycleData.New)
+ newlyCreatedDisks.add(d.getName());
+ else if(d.getStatus() == CycleData.Alive)
+ updatedDisks.add(d.getName());
+ else if(d.getStatus() == CycleData.Deleted)
+ deletedDisks.add(d.getName());
+ }
+ }
+
+ }
+
+ /**
+ * This method parses the handles list of a cycle data and if the handle type
+ * if thread, it stores thread names of those handles to corresponding lists
+ * based on their status
+ *
+ */
+ public void parseAllThreads()
+ {
+ newlyCreatedThreads = new ArrayList();
+ updatedThreads = new ArrayList();
+ deletedThreads = new ArrayList();
+
+ if(kernelHandlesList != null){
+ for(KernelHandles handle:kernelHandlesList){
+ if(handle.getHandleType().equals("Thread"))
+ {
+ if(handle.getStatus() == CycleData.New)
+ newlyCreatedThreads.add(handle.getHandleName());
+ else if(handle.getStatus() == CycleData.Alive)
+ updatedThreads.add(handle.getHandleName());
+ else if(handle.getStatus() == CycleData.Deleted)
+ deletedThreads.add(handle.getHandleName());
+ }
+ }
+ }
+
+ }
+
+ /**
+ *
+ * @param threadName name of the thread whose stack data is needed
+ * @return class which stores stack information
+ */
+ public StackData getStackData(String threadName)
+ {
+ if(stacksList != null)
+ {
+ for(StackData st:stacksList)
+ {
+ if(st.getThreadName().equalsIgnoreCase(threadName))
+ return st;
+ }
+ }
+
+ return null;
+ }
+
+ public int getNewOpenFiles(String threadName)
+ {
+ int openFilesCnt = 0;
+
+ if(filesList != null)
+ {
+ for(FilesData file:filesList)
+ {
+ if(file.getThreadName().equalsIgnoreCase(threadName)
+ && file.getStatus() == CycleData.New)
+ openFilesCnt++;
+ }
+
+ }
+
+ return openFilesCnt;
+ }
+
+ public int getDeletedFiles(String threadName)
+ {
+ int closedFilesCnt = 0;
+
+ if(filesList != null)
+ {
+ for(FilesData file:filesList)
+ {
+ if(file.getThreadName().equalsIgnoreCase(threadName)
+ && file.getStatus() == CycleData.Deleted)
+ closedFilesCnt++;
+ }
+ }
+
+ return closedFilesCnt;
+ }
+
+ public int getUpdatedFiles(String threadName)
+ {
+ int openFilesCnt = 0;
+
+ if(filesList != null)
+ {
+ for(FilesData file:filesList)
+ {
+ if(file.getThreadName().equalsIgnoreCase(threadName)
+ && file.getStatus() == CycleData.Alive)
+ openFilesCnt++;
+ }
+ //DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "Openfiles for " + threadName + " are " + openFilesCnt);
+ }
+
+ return openFilesCnt;
+ }
+
+ public int getNewPSHandles(String threadName)
+ {
+ int psHandlesCnt = 0;
+
+ if(psHandlesList != null)
+ {
+ for(PSHandlesData psHandle:psHandlesList)
+ {
+ if(psHandle.getThreadName().equalsIgnoreCase(threadName)
+ && (psHandle.getStatus() == CycleData.New))
+ psHandlesCnt++;
+ }
+ }
+
+ return psHandlesCnt;
+ }
+
+ public int getDeletedPSHandles(String threadName)
+ {
+ int deletedHandlesCnt = 0;
+
+ if(psHandlesList != null)
+ {
+ for(PSHandlesData psHandle:psHandlesList)
+ {
+ if(psHandle.getThreadName().equalsIgnoreCase(threadName)
+ && psHandle.getStatus() == CycleData.Deleted)
+ deletedHandlesCnt++;
+ }
+ }
+
+ return deletedHandlesCnt;
+ }
+
+ public int getUpdatedPSHandles(String threadName)
+ {
+ int alivePSHandles = 0;
+
+ if(psHandlesList != null)
+ {
+ for(PSHandlesData psHandle:psHandlesList)
+ {
+ if(psHandle.getThreadName().equalsIgnoreCase(threadName)
+ && psHandle.getStatus() == CycleData.Alive)
+ alivePSHandles++;
+ }
+ //DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "Openfiles for " + threadName + " are " + openFilesCnt);
+
+ }
+
+ return alivePSHandles;
+ }
+
+ public ArrayList getNewlyCreatedDisks()
+ {
+ return newlyCreatedDisks;
+ }
+
+ public ArrayList getUpdatedDisks()
+ {
+ return updatedDisks;
+ }
+
+ public ArrayList getDeletedDisks()
+ {
+ return deletedDisks;
+ }
+
+ public ArrayList getNewlyCreatedThreads()
+ {
+ return newlyCreatedThreads;
+ }
+
+ public ArrayList getUpdatedThreads()
+ {
+ return updatedThreads;
+ }
+
+ public ArrayList getDeletedThreads()
+ {
+ return deletedThreads;
+ }
+
+ /**
+ * Reads the values for given disk in this cycledata.
+ * @param diskName name of the disk whose info must be fetched.
+ * @return a structure which can store used memory and size values.
+ */
+ public DiskOverview getDiskUsedAndFreeSize(String diskName)
+ {
+ if(disksList != null)
+ {
+ DiskOverview overview = new DiskOverview();
+
+ int index = -1;
+ for(DiskData disk:disksList)
+ {
+ index++;
+ if(disk.getName().equalsIgnoreCase(diskName))
+ {
+ DiskData diskData = disksList.get(index);
+ overview.setSize(diskData.getSize());
+ overview.setFreeSize(diskData.getFreeSize());
+ overview.setStatus(diskData.getStatus());
+
+ return overview;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param threadName name of the thread whose heap data is needed.
+ * @return class which stores heap information of given thread in this cycle.
+ */
+ public ThreadData getHeapData(String threadName)
+ {
+
+ if(heapsList != null)
+ {
+ ThreadData data = new ThreadData(threadName);
+ for(HeapData heap:heapsList)
+ {
+ if(heap.getThreadName().equalsIgnoreCase(threadName))
+ {
+ data.setHeapChunkSize(heap.getSize());
+ data.setMaxHeapSize(heap.getMaxSize());
+ data.setAllocatedCells(heap.getAllocatedCells());
+ data.setFreeCells(heap.getFreeCells());
+ data.setHeapAllocatedSpace(heap.getAllocSpace());
+ data.setHeapFreeSpace(heap.getFreeSpace());
+ data.setLargestAllocCellSize(heap.getLargestAllocCell());
+ data.setLargestFreeCellSize(heap.getLargestFreeCell());
+ data.setFreeSlackSize(heap.getFreeSlack());
+ data.setStatus(heap.getStatus());
+
+ return data;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public int getKernelHandles()
+ {
+ if(kernelHandlesList != null)
+ return kernelHandlesList.size();
+ else
+ return 0;
+ }
+
+ /**
+ * This method parses all heap structures for this cycle and
+ * stores the thread names of those heaps to corresponding lists
+ * based on their status
+ *
+ */
+ public void parseAllHeaps()
+ {
+ newlyCreatedHeaps = new ArrayList();
+ updatedHeaps = new ArrayList();
+ deletedHeaps = new ArrayList();
+
+ if(heapsList != null){
+ for(HeapData heap:heapsList){
+ if(heap.getStatus() == CycleData.New)
+ newlyCreatedHeaps.add(heap.getThreadName());
+ else if(heap.getStatus() == CycleData.Alive)
+ updatedHeaps.add(heap.getThreadName());
+ else if(heap.getStatus() == CycleData.Deleted)
+ deletedHeaps.add(heap.getThreadName());
+ }
+ }
+
+ }
+
+ /**
+ * @return list of thread names whose heap is created in this cycle.
+ */
+ public ArrayList getNewHeapThreads()
+ {
+ return newlyCreatedHeaps;
+ }
+
+ /**
+ * @return list of thread names whose heap information is
+ * updated in this cycle.
+ */
+ public ArrayList getAliveHeapThreads()
+ {
+ return updatedHeaps;
+ }
+
+ /**
+ * @return list of thread names whose heap is deleted in this cycle.
+ *
+ */
+ public ArrayList getDeletedHeapThreads()
+ {
+ return deletedHeaps;
+ }
+
+ /**
+ * This method parses all stack structures for this cycle and
+ * returns the list of thread names for all newly created stacks.
+ *
+ */
+ public ArrayList getNewStackThreads()
+ {
+ ArrayList threadNames = new ArrayList();
+
+ if(stacksList != null)
+ for(StackData stack:stacksList)
+ {
+ if(stack.getStatus() == CycleData.New)
+ threadNames.add(stack.getThreadName());
+ }
+ return threadNames;
+ }
+
+ /**
+ * This method parses all stack structures for this cycle and
+ * returns the list of thread names for updated stacks.
+ *
+ */
+ public ArrayList getAliveStackThreads()
+ {
+ ArrayList threadNames = new ArrayList();
+
+ if(stacksList != null)
+ for(StackData stack:stacksList)
+ {
+ if(stack.getStatus() == CycleData.Alive)
+ threadNames.add(stack.getThreadName());
+ }
+ return threadNames;
+ }
+
+ /**
+ * This method parses all stack structures for this cycle and
+ * returns the list of thread names for all deleted stacks.
+ *
+ */
+ public ArrayList getDeletedStackThreads()
+ {
+ ArrayList threadNames = new ArrayList();
+
+ if(stacksList != null)
+ for(StackData stack:stacksList)
+ {
+ if(stack.getStatus() == CycleData.Deleted){
+ threadNames.add(stack.getThreadName());
+ }
+ }
+ return threadNames;
+ }
+
+ /**
+ *
+ * @return list of thread names which contain PSHandles
+ */
+ public ArrayList getHPASThreads()
+ {
+ ArrayList threadNames = new ArrayList();
+
+ if(psHandlesList != null)
+ for(PSHandlesData hpas:psHandlesList)
+ threadNames.add(hpas.getThreadName());
+
+ return threadNames;
+ }
+
+ /**
+ *
+ * @return list of thread names which contain file handles.
+ */
+ public ArrayList getFileThreads()
+ {
+ ArrayList threadNames = new ArrayList();
+
+ if(filesList != null)
+ for(FilesData file:filesList)
+ threadNames.add(file.getThreadName());
+
+ return threadNames;
+ }
+
+ public ArrayList getDeletedChunkNames ()
+ {
+ ArrayList deletedChunks = new ArrayList();
+
+ if(kernelHandlesList != null){
+ for(KernelHandles handle:kernelHandlesList){
+
+ if(handle.getHandleType().equals("Chunk") &&
+ (handle.getStatus() == CycleData.Deleted))
+ {
+ deletedChunks.add(handle.getHandleName());
+ }
+ }
+ }
+
+ return deletedChunks;
+ }
+
+
+
+ public long getChangeCount() {
+ return changeCount;
+ }
+ public void setChangeCount(long changeCount) {
+ this.changeCount = changeCount;
+ }
+ public int getCycleNumber() {
+ return cycleNumber;
+ }
+ public void setCycleNumber(int cycleNumber) {
+ this.cycleNumber = cycleNumber;
+ }
+ public String getFileName() {
+ return fileName;
+ }
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+
+ public long getMemspyRam() {
+ return memspyRam;
+ }
+ public void setMemspyRam(long memspyRam) {
+ this.memspyRam = memspyRam;
+ }
+ public long getPrevFreeMem() {
+ return prevFreeMem;
+ }
+ public void setPrevFreeMem(long prevFreeMem) {
+ this.prevFreeMem = prevFreeMem;
+ }
+ public String getTime() {
+ return time;
+ }
+ public void setTime(String time) {
+ this.time = time;
+ }
+
+ /**
+ * Clears all the previous data
+ *
+ */
+ public void clear()
+ {
+ if(disksList != null)
+ disksList.clear();
+ if(heapsList != null)
+ heapsList.clear();
+ if(stacksList != null)
+ stacksList.clear();
+ if(globalDataChunksList != null)
+ globalDataChunksList.clear();
+ if(nonRHeapList != null)
+ nonRHeapList.clear();
+ if(chunksList != null)
+ chunksList.clear();
+ if(kernelHandlesList != null)
+ kernelHandlesList.clear();
+ if(filesList != null)
+ filesList.clear();
+ if(psHandlesList != null)
+ psHandlesList.clear();
+ }
+
+ public ArrayList getGlobalDataChunksList() {
+ ArrayList s = new ArrayList();
+ if(globalDataChunksList!=null)
+ for (GlobalDataChunks data: globalDataChunksList)
+ s.add(data);
+ return s;
+ }
+
+ public GlobalDataChunks getGlobalChunkDataFor(String chunkName)
+ {
+ if(globalDataChunksList != null)
+ {
+ for(GlobalDataChunks data : globalDataChunksList)
+ {
+ if(data.getChunkName().equalsIgnoreCase(chunkName))
+ {
+ return data;
+ }
+ }
+ }
+ return null;
+ }
+
+ public ChunksData getChunkDataFor(String chunkName)
+ {
+ if(chunksList != null)
+ {
+ for(ChunksData data : chunksList)
+ {
+ if(data.getChunkName().equalsIgnoreCase(chunkName))
+ {
+ return data;
+ }
+ }
+ }
+ return null;
+ }
+
+ public ArrayList getGlobalChunkNames()
+ {
+ ArrayList chunkNames = new ArrayList();
+
+ if(globalDataChunksList != null)
+ for(GlobalDataChunks glod:globalDataChunksList)
+ chunkNames.add(glod.getChunkName());
+
+ return chunkNames;
+ }
+
+
+
+ public ArrayList getNonHeapChunkNames()
+ {
+ ArrayList chunkNames = new ArrayList();
+
+ if(chunksList != null)
+ for(ChunksData chnk:chunksList)
+ chunkNames.add(chnk.getChunkName());
+
+ return chunkNames;
+ }
+
+ public ArrayList getPsHandlesList() {
+ ArrayList s = new ArrayList();
+ for (PSHandlesData data: psHandlesList)
+ s.add(data);
+
+ return s;
+ }
+
+ public ArrayList getGenHandlesList() {
+ ArrayList s = new ArrayList();
+ for (KernelHandles data: kernelHandlesList)
+ s.add(data);
+
+ return s;
+
+ }
+
+ public ArrayList getDisksList() {
+ ArrayList s = new ArrayList();
+ for (DiskData data: disksList)
+ s.add(data);
+ return s;
+ }
+
+ public ArrayList getHeapsList() {
+ ArrayList s = new ArrayList();
+ for (HeapData data: heapsList)
+ s.add(data);
+ return s;
+ }
+
+ public ArrayList getChunksList() {
+ ArrayList s = new ArrayList();
+ if(chunksList!=null)
+ for (ChunksData data: chunksList)
+ s.add(data);
+ return s;
+ }
+
+ /**
+ *
+ * @returns list of window groups from this cycle.
+ */
+ public ArrayList getWindowGroupsData()
+ {
+ ArrayList list = new ArrayList();
+
+ if(wndgList != null)
+ {
+ for(WindowGroups wndg:wndgList)
+ {
+ list.add(wndg);
+ }
+ }
+
+ return list;
+ }
+ public long getFreeMemory() {
+ return freeMemory;
+ }
+
+ public void setFreeMemory(long freeMemory) {
+ this.freeMemory = freeMemory;
+ }
+
+ public long getTotalMemory() {
+ return totalMemory;
+ }
+
+ public void setTotalMemory(long totalMemory) {
+ this.totalMemory = totalMemory;
+ }
+
+ public String getRomCheckSum() {
+ return romCheckSum;
+ }
+
+ public void setRomCheckSum(String romCheckSum) {
+ this.romCheckSum = romCheckSum;
+ }
+
+ public String getRomVersion() {
+ return romVersion;
+ }
+
+ public void setRomVersion(String romVersion) {
+ this.romVersion = romVersion;
+ }
+
+ /**
+ *
+ * This method returns the data related to various kernel elements.
+ */
+ public KernelElements getAllOpenKernelElements()
+ {
+ KernelElements elements = new KernelElements();
+
+ if(kernelHandlesList != null){
+ for(KernelHandles handle:kernelHandlesList)
+ {
+ if(handle.getHandleType().equals("Timer"))
+ {
+ int count = elements.getNumberOfTimers();
+
+ if(handle.getStatus() == CycleData.New)
+ count++;
+ else if(handle.getStatus() == CycleData.Deleted)
+ count--;
+
+ elements.setNumberOfTimers(count);
+ }
+ else if(handle.getHandleType().equals("Semaphore"))
+ {
+ int count = elements.getNumberOfSemaphores();
+
+ if(handle.getStatus() == CycleData.New)
+ count++;
+ else if(handle.getStatus() == CycleData.Deleted)
+ count--;
+
+ elements.setNumberOfSemaphores(count);
+ }
+ else if(handle.getHandleType().equals("Process"))
+ {
+ int count = elements.getNumberOfProcesses();
+
+ if(handle.getStatus() == CycleData.New)
+ count++;
+ else if(handle.getStatus() == CycleData.Deleted)
+ count--;
+
+ elements.setNumberOfProcesses(count);
+ }
+ else if(handle.getHandleType().equals("Thread"))
+ {
+ int count = elements.getNumberOfThreads();
+
+ if(handle.getStatus() == CycleData.New)
+ count++;
+ else if(handle.getStatus() == CycleData.Deleted)
+ count--;
+
+ elements.setNumberOfThreads(count);
+ }
+ else if(handle.getHandleType().equals("Chunk"))
+ {
+ int count = elements.getNumberOfChunks();
+
+ if(handle.getStatus() == CycleData.New)
+ count++;
+ else if(handle.getStatus() == CycleData.Deleted)
+ count--;
+
+ elements.setNumberOfChunks(count);
+ }
+ else if(handle.getHandleType().equals("Session"))
+ {
+ int count = elements.getNumberOfSessions();
+
+ if(handle.getStatus() == CycleData.New)
+ count++;
+ else if(handle.getStatus() == CycleData.Deleted)
+ count--;
+
+ elements.setNumberOfSessions(count);
+ }
+ else if(handle.getHandleType().equals("Server"))
+ {
+ int count = elements.getNumberOfServers();
+
+ if(handle.getStatus() == CycleData.New)
+ count++;
+ else if(handle.getStatus() == CycleData.Deleted)
+ count--;
+
+ elements.setNumberOfServers(count);
+ }
+ else if(handle.getHandleType().equals("Msg. Queue"))
+ {
+ int count = elements.getNumberOfMsgQueues();
+
+ if(handle.getStatus() == CycleData.New)
+ count++;
+ else if(handle.getStatus() == CycleData.Deleted)
+ count--;
+
+ elements.setNumberOfMsgQueues(count);
+ }
+ }
+ }
+ return elements;
+ }
+
+ public int compareTo(CycleData tmp) {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd HH:mm:ss");
+ Date aDate=null;
+ Date bDate=null;
+ try {
+ aDate = sdf.parse(this.getTime());
+ bDate = sdf.parse(tmp.getTime());
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+
+ if(aDate.before(bDate))
+ {
+ return -1;
+ }
+ else if(aDate.after(bDate))
+ {
+ return 1;
+ }
+ return 0;
+ }
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/data/DiskData.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/data/DiskData.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,72 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+package com.nokia.s60tools.swmtanalyser.data;
+
+public class DiskData {
+ private String driveName;
+ private long size;
+ private long freeSize;
+ private int status;
+
+ public void setName(String name)
+ {
+ this.driveName = name;
+ }
+ public void setSize(String size)
+ {
+ this.size = Long.parseLong(size);
+ }
+
+ public void setFreeSize(String freeSize)
+ {
+ this.freeSize = Long.parseLong(freeSize);
+ }
+
+ public String getName()
+ {
+ return driveName;
+ }
+
+ /**
+ * @param status
+ * This method sets the status of this handle to New, Alive or Deleted
+ */
+ public void setStatus(String status)
+ {
+ if(status.equals("[N]+[A]"))
+ this.status = CycleData.New;
+ else if (status.equals("[A]"))
+ this.status = CycleData.Alive;
+ else
+ this.status = CycleData.Deleted;
+ }
+ public int getStatus()
+ {
+ return status;
+ }
+
+ public long getFreeSize()
+ {
+ return this.freeSize;
+ }
+
+ public long getSize()
+ {
+ return this.size;
+
+ }
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/data/DiskOverview.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/data/DiskOverview.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+package com.nokia.s60tools.swmtanalyser.data;
+
+public class DiskOverview {
+
+ private long freeSize;
+ private long size;
+ private int status;
+
+ public DiskOverview(DiskOverview target)
+ {
+ this.freeSize = target.freeSize;
+ this.size = target.size;
+ this.status = target.status;
+ }
+
+ public DiskOverview()
+ {
+ this.freeSize = -1;
+ this.size = -1;
+ }
+
+ public long getFreeSize()
+ {
+ return freeSize;
+ }
+
+ public long getSize()
+ {
+ return size;
+ }
+
+ public long getUsedSize()
+ {
+ if(freeSize == -1 || size == -1)
+ return -1;
+ else
+ return size - freeSize;
+ }
+
+ public void setFreeSize(long freeSize)
+ {
+ this.freeSize = freeSize;
+ }
+
+ public void setSize(long size)
+ {
+ this.size = size;
+ }
+
+ public int getStatus() {
+ return status;
+ }
+
+ public void setStatus(int status) {
+ this.status = status;
+ }
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/data/FilesData.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/data/FilesData.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+package com.nokia.s60tools.swmtanalyser.data;
+
+public class FilesData {
+ private String fileName;
+ private String threadName;
+ private long fileSize;
+ private int status;
+
+ public void setFileName(String fileName){
+ this.fileName = fileName;
+ }
+
+ public void setFileSize(String fileSize){
+ this.fileSize = Long.parseLong(fileSize);
+ }
+
+ public void setThreadName(String threadName){
+ this.threadName = threadName;
+ }
+
+ /**
+ * @param status
+ * This method sets the status of this file to New, Alive or Deleted
+ */
+ public void setStatus(String status)
+ {
+ if(status.equals("[N]+[A]"))
+ this.status = CycleData.New;
+ else if (status.equals("[A]"))
+ this.status = CycleData.Alive;
+ else
+ this.status = CycleData.Deleted;
+ }
+
+ public int getStatus()
+ {
+ return status;
+ }
+
+ public String getThreadName(){
+ return threadName;
+ }
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public long getFileSize() {
+ return fileSize;
+ }
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/data/GlobalDataChunks.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/data/GlobalDataChunks.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,77 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+package com.nokia.s60tools.swmtanalyser.data;
+/**
+ * Stores GLOD data from the log files.
+ */
+public class GlobalDataChunks {
+ private String processName;
+ private String chunkName;
+ private String baseAddr;
+ private long size = -1;
+ private int attrib;
+ private boolean isKernelHandleDeleted;
+
+ public GlobalDataChunks(){}
+
+ public GlobalDataChunks(GlobalDataChunks target)
+ {
+ this.chunkName = target.chunkName;
+ this.processName = target.processName;
+ this.baseAddr = target.baseAddr;
+ this.size = target.size;
+ this.attrib = target.attrib;
+ }
+ public int getAttrib() {
+ return attrib;
+ }
+ public void setAttrib(int attrib) {
+ this.attrib = attrib;
+ }
+ public String getBaseAddr() {
+ return baseAddr;
+ }
+ public void setBaseAddr(String baseAddr) {
+ this.baseAddr = baseAddr;
+ }
+ public String getChunkName() {
+ return chunkName;
+ }
+ public void setChunkName(String chunkName) {
+ this.chunkName = chunkName;
+ }
+ public String getProcessName() {
+ return processName;
+ }
+ public void setProcessName(String processName) {
+ this.processName = processName;
+ }
+ public long getSize() {
+ return size;
+ }
+ public void setSize(long size) {
+ this.size = size;
+ }
+
+ public boolean isKernelHandleDeleted() {
+ return isKernelHandleDeleted;
+ }
+
+ public void setKernelHandleDeleted(boolean isKernelHandleDeleted) {
+ this.isKernelHandleDeleted = isKernelHandleDeleted;
+ }
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/data/HeapData.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/data/HeapData.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,187 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+package com.nokia.s60tools.swmtanalyser.data;
+/**
+ * Stores the HEAP data from the log files.
+ *
+ */
+public class HeapData {
+ private String threadName;
+ private String processName;
+ private String baseAddr;
+ private long size;
+ private long maxSize;
+ private long allocatedCells;
+ private long freeCells;
+ private long allocSpace;
+ private long freeSpace;
+ private long freeSlack;
+ private long largestFreeCell;
+ private long largestAllocCell;
+ private int attrib;
+
+ public void setThreadAndProcessName(String threadName)
+ {
+ int index = threadName.indexOf("::");
+ this.processName = threadName.substring(0, index-1);
+ this.threadName = threadName;
+ }
+
+ public long getAllocatedCells() {
+ return allocatedCells;
+ }
+
+ public void setAllocatedCells(String allocatedCells) {
+ this.allocatedCells = Long.parseLong(allocatedCells);
+ }
+
+ public long getAllocSpace() {
+ return allocSpace;
+ }
+
+ public void setAllocSpace(String allocSpace) {
+ this.allocSpace = Long.parseLong(allocSpace);
+ }
+
+ public String getBaseAddr() {
+ return baseAddr;
+ }
+
+ public void setBaseAddr(String baseAddr) {
+ this.baseAddr = baseAddr;
+ }
+
+ public long getFreeCells() {
+ return freeCells;
+ }
+
+ public void setFreeCells(String freeCells) {
+ this.freeCells = Long.parseLong(freeCells);
+ }
+
+ public long getFreeSlack() {
+ return freeSlack;
+ }
+
+ public void setFreeSlack(String freeSlack) {
+ this.freeSlack = Long.parseLong(freeSlack);
+ }
+
+ public long getFreeSpace() {
+ return freeSpace;
+ }
+
+ public void setFreeSpace(String freeSpace) {
+ this.freeSpace = Long.parseLong(freeSpace);
+ }
+
+ public long getLargestAllocCell() {
+ return largestAllocCell;
+ }
+
+ public void setLargestAllocCell(String largestAllocCell) {
+ this.largestAllocCell = Long.parseLong(largestAllocCell);
+ }
+
+ public long getLargestFreeCell() {
+ return largestFreeCell;
+ }
+
+ public void setLargestFreeCell(String largestFreeCell) {
+ this.largestFreeCell = Long.parseLong(largestFreeCell);
+ }
+
+ public String getProcessName() {
+ return processName;
+ }
+
+ /*public void setProcessName(String processName) {
+ this.processName = processName;
+ }*/
+
+ public long getSize() {
+ return size;
+ }
+
+ public void setSize(String size) {
+ this.size = Long.parseLong(size);
+ }
+
+ public long getMaxSize() {
+ return maxSize;
+ }
+
+ public void setMaxSize(String maxSize) {
+ this.maxSize = Long.parseLong(maxSize);
+ }
+ public String getThreadName() {
+ return threadName;
+ }
+ /**
+ * @param status
+ * This method sets the status of this heap to New, Alive or Deleted
+ */
+ public void setStatus(String status)
+ {
+ if(status.equals("[N]+[A]"))
+ attrib = CycleData.New;
+ else if (status.equals("[A]"))
+ attrib = CycleData.Alive;
+ else
+ attrib = CycleData.Deleted;
+ }
+ public int getStatus()
+ {
+ return attrib;
+ }
+
+ public void setAllocatedCells(long allocatedCells) {
+ this.allocatedCells = allocatedCells;
+ }
+
+ public void setAllocSpace(long allocSpace) {
+ this.allocSpace = allocSpace;
+ }
+ public int getAttrib() {
+ return attrib;
+ }
+ public void setAttrib(int attrib) {
+ this.attrib = attrib;
+ }
+
+ public void setFreeCells(long freeCells) {
+ this.freeCells = freeCells;
+ }
+
+ public void setFreeSlack(long freeSlack) {
+ this.freeSlack = freeSlack;
+ }
+ public void setFreeSpace(long freeSpace) {
+ this.freeSpace = freeSpace;
+ }
+ public void setLargestAllocCell(long largestAllocCell) {
+ this.largestAllocCell = largestAllocCell;
+ }
+ public void setLargestFreeCell(long largestFreeCell) {
+ this.largestFreeCell = largestFreeCell;
+ }
+
+ public void setSize(long size) {
+ this.size = size;
+ }
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/data/KernelElements.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/data/KernelElements.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,85 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+/**
+ * This class contains the information about various kernel elements.
+ */
+package com.nokia.s60tools.swmtanalyser.data;
+/**
+ * Stores kernel handles information
+ *
+ */
+public class KernelElements {
+
+ private int numberOfThreads = 0;
+ private int numberOfProcesses = 0;
+ private int numberOfTimers = 0;
+ private int numberOfSessions = 0;
+ private int numberOfSemaphores = 0;
+ private int numberOfServers = 0;
+ private int numberOfChunks = 0;
+ private int numberOfMsgQueues = 0;
+
+ public int getNumberOfProcesses() {
+ return numberOfProcesses;
+ }
+ public void setNumberOfProcesses(int numberOfProcesses) {
+ this.numberOfProcesses = numberOfProcesses;
+ }
+ public int getNumberOfSemaphores() {
+ return numberOfSemaphores;
+ }
+ public void setNumberOfSemaphores(int numberOfSemaphores) {
+ this.numberOfSemaphores = numberOfSemaphores;
+ }
+ public int getNumberOfServers() {
+ return numberOfServers;
+ }
+ public void setNumberOfServers(int numberOfServers) {
+ this.numberOfServers = numberOfServers;
+ }
+ public int getNumberOfSessions() {
+ return numberOfSessions;
+ }
+ public void setNumberOfSessions(int numberOfSessions) {
+ this.numberOfSessions = numberOfSessions;
+ }
+ public int getNumberOfThreads() {
+ return numberOfThreads;
+ }
+ public void setNumberOfThreads(int numberOfThreads) {
+ this.numberOfThreads = numberOfThreads;
+ }
+ public int getNumberOfTimers() {
+ return numberOfTimers;
+ }
+ public void setNumberOfTimers(int numberOfTimers) {
+ this.numberOfTimers = numberOfTimers;
+ }
+ public int getNumberOfChunks() {
+ return numberOfChunks;
+ }
+ public void setNumberOfChunks(int numberOfChunks) {
+ this.numberOfChunks = numberOfChunks;
+ }
+ public int getNumberOfMsgQueues() {
+ return numberOfMsgQueues;
+ }
+ public void setNumberOfMsgQueues(int numberOfMsgQueues) {
+ this.numberOfMsgQueues = numberOfMsgQueues;
+ }
+
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/data/KernelHandles.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/data/KernelHandles.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+package com.nokia.s60tools.swmtanalyser.data;
+
+/**
+ * Stores HGEN information
+ *
+ */
+public class KernelHandles {
+
+ private String handleName;
+ private String handle;
+ private String handleType;
+ private int attrib;
+
+ public void setHandleName(String name) {
+ this.handleName = name;
+ }
+ public void setHandle(String handle){
+ this.handle = handle;
+ }
+ public void setHandleType(String handleType){
+ this.handleType = handleType;
+ }
+
+ /**
+ * @param status
+ * This method sets the status of this handle to New, Alive or Deleted
+ */
+ public void setStatus(String status)
+ {
+ if(status.equals("[N]+[A]"))
+ attrib = CycleData.New;
+ else if (status.equals("[A]"))
+ attrib = CycleData.Alive;
+ else
+ attrib = CycleData.Deleted;
+ }
+
+ public int getStatus(){
+ return attrib;
+ }
+
+ public String getHandleType(){
+ return handleType;
+ }
+
+ public String getHandleName(){
+ return handleName;
+ }
+ public String getHandle() {
+ return handle;
+ }
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/data/OverviewData.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/data/OverviewData.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+package com.nokia.s60tools.swmtanalyser.data;
+
+/**
+ * Stores overview information from all the log files.
+ *
+ */
+public class OverviewData {
+
+ public int noOfcycles;
+ public String fromTime;
+ public String toTime;
+ public long duration;
+ public String durationString;
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/data/PSHandlesData.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/data/PSHandlesData.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,89 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+package com.nokia.s60tools.swmtanalyser.data;
+
+/**
+ * Stores HPAS data from the log file.
+ *
+ */
+public class PSHandlesData {
+
+ public static String [] keyTypes = new String [] {"EInt", "EByteArray", "EText", "ELargeByteArray","ELargeText", "ETypeLimit", "ETypeMask"};
+
+ private String handleName;
+ private String handle;
+ private long key;
+ private int keyType;
+ private long threadId;
+ private String threadName;
+ private int attrib;
+
+ public int getStatus()
+ {
+ return attrib;
+ }
+ public String getHandle() {
+ return handle;
+ }
+ public void setHandle(String handle) {
+ this.handle = handle;
+ }
+ public String getHandleName() {
+ return handleName;
+ }
+ public void setHandleName(String handleName) {
+ this.handleName = handleName;
+ }
+ public long getKey() {
+ return key;
+ }
+ public void setKey(long key) {
+ this.key = key;
+ }
+ public int getKeyType() {
+ return keyType;
+ }
+ public void setKeyType(int keyType) {
+ this.keyType = keyType;
+ }
+ public long getThreadId() {
+ return threadId;
+ }
+ public void setThreadId(long threadId) {
+ this.threadId = threadId;
+ }
+ public String getThreadName() {
+ return threadName;
+ }
+ public void setThreadName(String threadName) {
+ this.threadName = threadName;
+ }
+
+ /**
+ * @param status
+ * This method sets the status of this handle to New, Alive or Deleted
+ */
+ public void setStatus(String status)
+ {
+ if(status.equals("[N]+[A]"))
+ attrib = CycleData.New;
+ else if (status.equals("[A]"))
+ attrib = CycleData.Alive;
+ else
+ attrib = CycleData.Deleted;
+ }
+}
diff -r f65f740e69f9 -r 8e12a575a9b5 sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/data/ParsedData.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysperfana/memspyext/com.nokia.s60tools.swmtanalyser/src/com/nokia/s60tools/swmtanalyser/data/ParsedData.java Wed Apr 21 20:01:08 2010 +0300
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+package com.nokia.s60tools.swmtanalyser.data;
+
+import java.util.ArrayList;
+/**
+ * Stores the cycle data objects of all log files.
+ *
+ */
+public class ParsedData {
+
+ private ArrayList logData;
+
+ public void setParsedData(ArrayList