- Fix a regression of hidden in tracing time Call Trace table (regression in DA 2.5.0)
- Show filter icon after filtering above sorting (SRADA-1364)
- Fix a regression of inserting an "unknown" API item into callstack (SRADA-1362)
- Disable sorting in Memory Details table (SRADA-1366)
- Fix popup menu behavior broken with previous redesign of callstack (regression in DA 2.5.0)
- Improve memory usage and performance for HeapAllocation profiling (SRADA-1231)
- Add primary keys and indexes for database tables
- Update HSQLDB to 2.3.4 version
- Heavy queries to database are executed in separate threads
- All data calculation for Statistics and Persistent Allocations tables is
moved to database
- Increase max memory available to DA from 512MB to 1GB
- Fix incorrect memory map building (SRADA-1327)
- Add device serial number to pop-up notifications (SRADA-1255)
- Removed redundant double updates in left table views (SRADA-1374)
- Remove deprecated logic related to Interactive, Kernel, Range Analysis
and User Interface pages
- Replace 'Analyze range' pop-up menu item for charts with 'Select range'
- Fix synchronization issues in DeviceManager and NotificationManager (regression in DA 2.5.0)
- Fix NullPointerException in TableTooltipListener (SRADA-1390)
- Fix JIRA defects:
SPTSDKUX-3428: Tracing data is not being saved in given path but no failure message shown
Change-Id: I5195b44905e38ae6179739814675e732ac5134cc
// * seting
public static final Font SETTING_BUTTON_FONT = getFont(
- "setting_button_font", resizeDefaultFont(8, 3));//$NON-NLS-1$
+ "setting_button_font", resizeDefaultFont(6, 3));//$NON-NLS-1$
public static final Font SETTING_TITLE_FONT = getFont(
"setting_title_font", resizeDefaultFont(10, -1));//$NON-NLS-1$
public static final Font ABOUT_DIALOG_TITLE_SMALL_FONT = getFont(
"about_dialog_title_small_font", new FontData[] { new FontData("Arial", 10, SWT.BOLD) });//$NON-NLS-1$
+ public static final Font NOTIFICATION_TITLE_FONT = getFont("notification_title_font",
+ resizeSystemFont(13, SWT.BOLD));
+
+ public static final Font NOTIFICATION_MESSAGE_FONT = getFont("notification_message_font",
+ resizeSystemFont(10));
+
private static Font getFont(String fontName, FontData[] fontData) {
if (!fontRegistry.hasValueFor(fontName)) {
fontRegistry.put(fontName, fontData);
return fontData;
}
+ public static FontData[] resizeSystemFont(int size, int style) {
+ FontData[] fontData = systemFont.getFontData();
+ for (int i = 0; i < fontData.length; i++) {
+ fontData[i].setHeight(size);
+ fontData[i].setStyle(style);
+ }
+ return fontData;
+ }
+
public static Font getDADefaultFont() {
String fontName = null;
if (CommonUtil.isLinux()) {
*/
package org.tizen.dynamicanalyzer.resources;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.graphics.Image;
public static final Image TARGET_NAME_FLAT_TV_NORMAL = getPngImage("device_tv_nor"); //$NON-NLS-1$
public static final Image TARGET_NAME_FLAT_TV_OVER = getPngImage("device_tv_over"); //$NON-NLS-1$
public static final Image TARGET_NAME_FLAT_TV_SEL = getPngImage("device_tv_sel"); //$NON-NLS-1$
+ public static final Image TARGET_CONNECTED = getPngImage("target_connected"); //$NON-NLS-1$
+ public static final Image TARGET_DISCONNECTED = getPngImage("target_disconnected"); //$NON-NLS-1$
public static final Image TEMPLATE_BOTTLENECK_ANALYSIS = getPngImage("feature_template_bottleneck"); //$NON-NLS-1$
public static final Image TEMPLATE_MEMORY_LEAK = getPngImage("feature_template_memoryleaks"); //$NON-NLS-1$
public static final Image TOOLTIP_INFO_FEATURELIST_NORMAL = getPngImage("tooltip_icon-nor");
public static final Image TOOLTIP_INFO_FEATURELIST_HOVER = getPngImage("tooltip_icon-hov");
+ /** configurable features **/
+ public static final Image CONFIG_FEATURE_NORMAL = getPngImage("configurable_feature_area_nor");
+ public static final Image CONFIG_FEATURE_HOVER = getPngImage("configurable_feature_area_over");
+ public static final Image CONFIG_FEATURE_PUSH = getPngImage("configurable_feature_area_sel");
+
/** etc **/
public static final Image DELETE = getPngImage("delete");
public static final Image CONNECT_BTN_OVER = getPngImage("btn_connect_over");
public static final Image CONNECT_BTN_SEL = getPngImage("btn_connect_sel");
+ /** Filtered table */
+ public static final Image DA_IC_FILTER = getPngImage("da_column_filtered");
+ public static final Image DA_IC_FILTER_OVER = getPngImage("da_column_filtered_Mover");
+ public static final Image DA_IC_FILTER_PRESSED = getPngImage("da_column_filtered_Mpressed");
+ public static final Set<Image> FILTER_IMAGES = Collections.unmodifiableSet(new HashSet<Image>(
+ Arrays.asList(DA_IC_FILTER, DA_IC_FILTER_OVER, DA_IC_FILTER_PRESSED)));
+
+ /** Sorted table */
+ public static final Image SORTED_INC = getPngImage("sorted_inc");
+ public static final Image SORTED_INC_OVER = getPngImage("sorted_inc_over");
+ public static final Image SORTED_INC_SELECTED = getPngImage("sorted_inc_sel");
+ public static final Image SORTED_DESC = getPngImage("sorted_desc");
+ public static final Image SORTED_DESC_OVER = getPngImage("sorted_desc_over");
+ public static final Image SORTED_DESC_SELECTED = getPngImage("sorted_desc_sel");
/**
* Next resources migrated from org.tizen.dynamicanalyzer.widgets plugin.
public static final Image CHILD_CHART_UNFOLD = getPngImage("child_chart_unfold");
public static final Image CHILD_CHART_UNFOLD_HOVER = getPngImage("child_chart_unfold_hover");
+ // notification pop-up
+ public static final Image NOTIFICATION_BG = getPngImage("noti_pop_bg");
+ public static final Image NOTIFICATION_ICON = getPngImage("noti_icon_info");
+
private static Image getImage(String pluginId, String folderName,
String imageName, String extension) {
if (null == imageRegistry.get(imageName)
// Create all needed data managers before
UIActionHolder.getUIAction().setUIElementsBySetting();
CommonAction.configure(); // TODO move this to common place for CLI and GUI
- CommandAction.startTrace(false);
+ CommandAction.startTrace();
Logger.debug("Tracing started");
return ErrorCode.SUCCESS;
<parent>
<artifactId>dynamic-analyzer</artifactId>
<groupId>org.tizen.dynamicanalyzer</groupId>
- <version>2.4.5-SNAPSHOT</version>
+ <version>2.5.1-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<groupId>org.tizen.dynamicanalyzer</groupId>
<parent>
<artifactId>dynamic-analyzer</artifactId>
<groupId>org.tizen.dynamicanalyzer</groupId>
- <version>2.4.5-SNAPSHOT</version>
+ <version>2.5.1-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<groupId>org.tizen.dynamicanalyzer</groupId>
+++ /dev/null
-package org.tizen.dynamicanakyzer.project.callstack;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.mock;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Matchers;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.modules.junit4.PowerMockRunner;
-import org.powermock.reflect.Whitebox;
-import org.tizen.dynamicanalyzer.common.Global;
-import org.tizen.dynamicanalyzer.common.UIMode;
-import org.tizen.dynamicanalyzer.project.AppInfo;
-import org.tizen.dynamicanalyzer.project.BinaryInfo;
-import org.tizen.dynamicanalyzer.project.DeviceStatusInfo;
-import org.tizen.dynamicanalyzer.project.ProcessInformation;
-import org.tizen.dynamicanalyzer.project.Project;
-import org.tizen.dynamicanalyzer.project.callstack.RuntimeCallstackManager;
-import org.tizen.dynamicanalyzer.protocol.ProtocolConstants;
-import org.tizen.dynamicanalyzer.setting.PrimitiveFeature;
-import org.tizen.dynamicanalyzer.setting.SettingConstants;
-import org.tizen.dynamicanalyzer.setting.SettingDataManager;
-import org.tizen.dynamicanalyzer.swap.model.data.ProbeCommonData;
-import org.tizen.dynamicanalyzer.swap.model.data.ProfileData;
-import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackData;
-import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackInserter;
-import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackUnit;
-import org.tizen.dynamicanalyzer.ui.summary.profiling.ProfileDataMaker;
-import org.tizen.dynamicanalyzer.ui.summary.profiling.RuntimeProfileDataMaker;
-import org.tizen.dynamicanalyzer.util.InternalLogger;
-import org.tizen.dynamicanalyzer.util.Logger;
-
-/**
- * Class introduced to test that Map callstackDataBySeqMap corresponds to really
- * occurred callstacks.
- */
-@RunWith(PowerMockRunner.class)
-public class BaseCallstackManagerTest {
- static RuntimeCallstackManager callstackManager;
-
- static CallStackData csd;
- int pid = 3045;
-
- @BeforeClass
- public static void setUp() throws Exception {
- SettingConstants.SettingFilePath = System.getProperty("user.dir")
- + "/resources/";
- callstackManager = new RuntimeCallstackManager();
- List<Long> addrs = new ArrayList<Long>();
- addrs.add(100000L);
- csd = new CallStackData(3L, addrs);
- callstackManager.getCallStackDataBySeqMap().put(3L, csd);
-
- AppInfo aInfo = mock(AppInfo.class);
- BinaryInfo bInfo = mock(BinaryInfo.class);
- DeviceStatusInfo dsi = mock(DeviceStatusInfo.class);
- ProcessInformation process = mock(ProcessInformation.class);
- PowerMockito.when(dsi, "getBinaryInfo", Matchers.any(String.class))
- .thenReturn(bInfo);
- PowerMockito.when(dsi, "getBinaryInfo", Matchers.anyInt()).thenReturn(bInfo);
- Project project = mock(Project.class);
- PowerMockito.when(project, "getRuntimeCallstackManager").thenReturn(callstackManager);
- PowerMockito.when(project, "getDeviceStatusInfo").thenReturn(dsi);
- PowerMockito.when(project, "getProcessInformation", Matchers.anyInt())
- .thenReturn(process);
- PowerMockito.when(project, "getApplicationInfo").thenReturn(aInfo);
- Global.setProject(project);
- }
-
- // ==================RuntimeCallstackDataManager==================
- /**
- * Test that RuntimeCallstackDataManager.getCallstackAddrListFromSeq() does
- * not change callstackDataBySeqMap.
- */
- @Test
- public void testGetCallstackAddrListFromSeq() {
- Map<Long, CallStackData> initialMapState = Whitebox.getInternalState(
- callstackManager, "callstackDataBySeqMap");
-
- assertEquals(csd.getAddrs(),
- callstackManager.getCallstackAddrListFromSeq(3L));
-
- Map<Long, CallStackData> newMapState = Whitebox.getInternalState(
- callstackManager, "callstackDataBySeqMap");
- assertEquals(initialMapState.size(), newMapState.size());
- for (Map.Entry<Long, CallStackData> entry : initialMapState.entrySet()) {
- assertEquals(entry.getValue(), newMapState.get(entry.getKey()));
- }
- }
-
- /**
- * Test that RuntimeCallstackDataManager.makeCallstackWithoutBacktrace()
- * simply adds one entry to callstackDataBySeqMap and does nothing more with
- * this map.
- */
- @Test
- public void testMakeCallstackWithoutBacktrace() {
- Map<Long, CallStackData> initialMapState = new HashMap<Long, CallStackData>();
- initialMapState.putAll(((Map<Long, CallStackData>) Whitebox
- .getInternalState(callstackManager, "callstackDataBySeqMap")));
-
- // add log data with caller address
- ProbeCommonData inputData = new ProbeCommonData(6L, 12134L, 3, pid,
- pid, "", "", 0);
-
- callstackManager.makeCallstackWithoutBacktrace(inputData);
-
- Map<Long, CallStackData> newMapState = Whitebox.getInternalState(
- callstackManager, "callstackDataBySeqMap");
- assertEquals(initialMapState.size() + 1, newMapState.size());
- for (Map.Entry<Long, CallStackData> entry : initialMapState.entrySet()) {
- assertEquals(entry.getValue(), newMapState.get(entry.getKey()));
- }
- assertNotNull(newMapState.get(6L));
- initialMapState.clear();
- initialMapState.putAll(newMapState);
-
- // add log data without caller address
- inputData = new ProbeCommonData(9L, 12134L, 3, pid, pid, "", "", 0);
- inputData.setCallerAddress(-1L);
- callstackManager.makeCallstackWithoutBacktrace(inputData);
-
- newMapState = Whitebox.getInternalState(
- callstackManager, "callstackDataBySeqMap");
- assertEquals(initialMapState.size() + 1, newMapState.size());
- for (Map.Entry<Long, CallStackData> entry : newMapState.entrySet()) {
- assertEquals(entry.getValue(), newMapState.get(entry.getKey()));
- }
- assertNotNull(newMapState.get(9L));
- }
-
- /**
- * Test that RuntimeCallstackDataManager.proceedEntry() simply adds one
- * entry to callstackDataBySeqMap and does nothing more with this map.
- */
- @Test
- public void testProceedEntry() throws Exception {
- Map<Long, CallStackData> initialMapState = new HashMap<Long, CallStackData>();
- initialMapState.putAll(((Map<Long, CallStackData>) Whitebox
- .getInternalState(callstackManager, "callstackDataBySeqMap")));
-
- RuntimeProfileDataMaker profileDataMaker = mock(RuntimeProfileDataMaker.class);
- profileDataMaker.setPid(pid);
- ProfileData inputData = new ProfileData(
- ProtocolConstants.MSG_FUNCTION_ENTRY, 8L, pid, pid, 0, 0,
- 12167L, 100000L, 300100L);
- Method proceedEntry = Whitebox.getMethod(RuntimeCallstackManager.class,
- "proceedEntry", ProfileData.class, CallStackUnit.class,
- Map.class);
- proceedEntry.invoke(callstackManager, inputData,
- mock(CallStackUnit.class), new HashMap<Long, CallStackData>());
-
- Map<Long, CallStackData> newMapState = Whitebox.getInternalState(
- callstackManager, "callstackDataBySeqMap");
- assertEquals(initialMapState.size() + 1, newMapState.size());
- for (Map.Entry<Long, CallStackData> entry : initialMapState.entrySet()) {
- assertEquals(entry.getValue(), newMapState.get(entry.getKey()));
- }
- assertNotNull(newMapState.get(8L));
- }
-
- /**
- * Test that RuntimeCallstackDataManager.proceedExit() simply adds one entry
- * to callstackDataBySeqMap and does nothing more with this map.
- */
- @Test
- public void testProceedExit() throws Exception {
- Map<Long, CallStackData> initialMapState = new HashMap<Long, CallStackData>();
- initialMapState.putAll(((Map<Long, CallStackData>) Whitebox
- .getInternalState(callstackManager, "callstackDataBySeqMap")));
-
- RuntimeProfileDataMaker profileDataMaker = mock(RuntimeProfileDataMaker.class);
- profileDataMaker.setPid(pid);
- ProfileData inputData = new ProfileData(
- ProtocolConstants.MSG_FUNCTION_EXIT, 12L, pid, pid, 0, 0,
- 12169L, 300100L, 500100L);
- Method proceedExit = Whitebox.getMethod(RuntimeCallstackManager.class,
- "proceedExit", ProfileData.class, CallStackUnit.class,
- Map.class);
- proceedExit.invoke(callstackManager, inputData,
- mock(CallStackUnit.class), new HashMap<Long, CallStackData>());
-
- Map<Long, CallStackData> newMapState = Whitebox.getInternalState(
- callstackManager, "callstackDataBySeqMap");
- assertEquals(initialMapState.size() + 1, newMapState.size());
- for (Map.Entry<Long, CallStackData> entry : initialMapState.entrySet()) {
- assertEquals(entry.getValue(), newMapState.get(entry.getKey()));
- }
- assertNotNull(newMapState.get(12L));
- }
-
- // ==================RuntimeProfileDataMaker======================
- /**
- * Test that RuntimeProfileDataMaker.makeFunctionUsageProfileData() does not
- * change callstackDataBySeqMap.
- */
- @Test
- public void testMakeFunctionUsageProfileData() {
- // Test that it does not change map
- Map<Long, CallStackData> initialMapState = new HashMap<Long, CallStackData>();
- initialMapState.putAll(((Map<Long, CallStackData>) Whitebox
- .getInternalState(callstackManager, "callstackDataBySeqMap")));
-
- Logger.init(InternalLogger.ERROR);
- ProfileDataMaker maker = new RuntimeProfileDataMaker();
- maker.makeFunctionUsageProfileData(new ProfileData(
- ProtocolConstants.MSG_FUNCTION_EXIT, 12L, pid, pid, 0, 0,
- 12169L, 300100L, 500100L));
-
- Map<Long, CallStackData> newMapState = Whitebox.getInternalState(
- callstackManager, "callstackDataBySeqMap");
- assertEquals(initialMapState.size(), newMapState.size());
- for (Map.Entry<Long, CallStackData> entry : initialMapState.entrySet()) {
- assertEquals(entry.getValue(), newMapState.get(entry.getKey()));
- }
- }
-
- // ==================CallStackInserter============================
- /**
- * Test that CallStackInserter.saveCallStackData() does not change
- * callstackDataBySeqMap if Persistent Allocations feature selected.
- *
- * @throws Exception
- */
- @Test
- public void testSaveCallStackData() throws Exception {
- Map<Long, CallStackData> initialMapState = new HashMap<Long, CallStackData>();
- initialMapState.putAll(((Map<Long, CallStackData>) Whitebox
- .getInternalState(callstackManager, "callstackDataBySeqMap")));
-
- Global.setCurrentUIMode(UIMode.CLI);
- SettingDataManager.INSTANCE.getConnectedTargetOrSelected()
- .addSelectedFlatFeature(PrimitiveFeature.MEMORY_ALLOC.getName());
- CallStackInserter csi = CallStackInserter.getInstance();
- Method save = Whitebox.getMethod(CallStackInserter.class,
- "saveCallStackData", List.class);
- List<CallStackData> csdList = new ArrayList<CallStackData>();
- csdList.add(new CallStackData(3L));
- save.invoke(csi, csdList);
-
- Map<Long, CallStackData> newMapState = Whitebox.getInternalState(
- callstackManager, "callstackDataBySeqMap");
- assertEquals(initialMapState.size(), newMapState.size());
- for (Map.Entry<Long, CallStackData> entry : initialMapState.entrySet()) {
- assertEquals(entry.getValue(), newMapState.get(entry.getKey()));
- }
- }
-}
--- /dev/null
+package org.tizen.dynamicanalyzer.project;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.when;
+
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.tizen.dynamicanalyzer.common.Global;
+import org.tizen.dynamicanalyzer.util.InternalLogger;
+import org.tizen.dynamicanalyzer.util.Logger;
+
+/**
+ * Suite for testing building of process memory map.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class ProcessMemoryMapTest {
+ @Mock
+ Project project;
+
+ @Mock
+ DeviceStatusInfo deviceStatusInfo;
+
+ @Mock
+ BinaryInfo binaryInfo;
+
+ ProcessMemoryMap pMap; // CUT instance
+
+ static long A = 1000, B = 2000, C = 3000, D = 4000, E = 5000, F = 6000;
+ static int ID1 = 1, ID2 = 2, ID3 = 3, ID4 = 4, ID5 = 5;
+
+ @BeforeClass
+ static public void setUpSuite() {
+ Logger.init(InternalLogger.DEBUG);
+ }
+
+ @Before
+ public void setUpTest() {
+ when(project.getDeviceStatusInfo()).thenReturn(deviceStatusInfo);
+ when(deviceStatusInfo.getBinaryInfo(anyInt())).thenReturn(binaryInfo);
+ Global.setProject(project);
+
+ pMap = new ProcessMemoryMap(0, 0);
+ }
+
+ /**
+ * Test handling of one library object.
+ */
+ @Test
+ public void test_add_one() {
+ LibraryObject lo = new LibraryObject(ID1, A, B);
+ assertTrue(pMap.addLibraryMap(lo));
+
+ assertEquals(1, pMap.getAllMappings().size());
+ assertEquals(1, pMap.getLibraryMappingByBinaryID(ID1).size());
+ assertEquals(lo, pMap.getLibraryByAddress((A + B) / 2));
+ }
+
+ /**
+ * Test overlapped library objects not added.
+ */
+ @Test
+ public void test_add_overlap() {
+ LibraryObject lo1 = new LibraryObject(ID1, A, C), lo2 = new LibraryObject(ID2, B, D);
+ assertTrue(pMap.addLibraryMap(lo1));
+ assertFalse(pMap.addLibraryMap(lo2));
+
+ assertEquals(1, pMap.getAllMappings().size());
+ assertEquals(lo1, pMap.getLibraryByAddress(B));
+ }
+
+ /**
+ * Test overlapped library objects not added. One inside another.
+ */
+ @Test
+ public void test_add_overlap2() {
+ LibraryObject lo1 = new LibraryObject(ID1, A, D), lo2 = new LibraryObject(ID2, B, C);
+ assertTrue(pMap.addLibraryMap(lo1));
+ assertFalse(pMap.addLibraryMap(lo2));
+
+ assertEquals(1, pMap.getAllMappings().size());
+ assertEquals(lo1, pMap.getLibraryByAddress(B));
+ }
+
+ /**
+ * Test multiple mappings for the same library id.
+ */
+ @Test
+ public void test_add_single_id() {
+ LibraryObject lo1 = new LibraryObject(ID1, A, B), lo2 = new LibraryObject(ID1, C, D);
+ assertTrue(pMap.addLibraryMap(lo1));
+ assertTrue(pMap.addLibraryMap(lo2));
+
+ assertEquals(2, pMap.getAllMappings().size());
+ assertEquals(2, pMap.getLibraryMappingByBinaryID(ID1).size());
+ assertEquals(lo1, pMap.getLibraryByAddress(A));
+ assertEquals(lo2, pMap.getLibraryByAddress(C));
+ }
+
+ /**
+ * Test main binary processed in the same way as others library objects.
+ */
+ @Test
+ public void test_add_main_binary() {
+ LibraryObject main = new LibraryObject(ID1, A, C);
+ LibraryObject lo = new LibraryObject(ID2, B, D);
+ pMap.setMainBinary(main);
+
+ assertFalse(pMap.addLibraryMap(lo));
+ assertEquals(1, pMap.getAllMappings().size());
+ assertEquals(main, pMap.getLibraryByAddress(A));
+ }
+
+ /**
+ * Test existing mapping will be shrinked.
+ */
+ @Test
+ public void test_remove_shrink() {
+ LibraryObject lo = new LibraryObject(ID1, A, C);
+ pMap.addLibraryMap(lo);
+ assertNotNull(pMap.getLibraryByAddress(B));
+ pMap.removeMapping(B, C);
+
+ assertEquals(1, pMap.getAllMappings().size());
+ assertNull(pMap.getLibraryByAddress(B));
+ assertNotSame(lo, pMap.getLibraryByAddress(A));
+ assertEquals(B, pMap.getLibraryByAddress(A).getHighestAddress());
+ }
+
+ /**
+ * Test existing mapping will be completely removed.
+ */
+ @Test
+ public void test_remove_complete() {
+ LibraryObject lo = new LibraryObject(ID1, A, B);
+ pMap.addLibraryMap(lo);
+
+ pMap.removeMapping(A, B);
+
+ assertEquals(0, pMap.getAllMappings().size());
+ assertNull(pMap.getLibraryByAddress(A));
+ }
+
+ /**
+ * Test existing mapping will be splitted.
+ */
+ @Test
+ public void test_remove_split() {
+ LibraryObject lo = new LibraryObject(ID1, A, D);
+ pMap.addLibraryMap(lo);
+
+ pMap.removeMapping(B, C);
+
+ assertEquals(2, pMap.getAllMappings().size());
+ assertEquals(2, pMap.getLibraryMappingByBinaryID(ID1).size());
+ assertEquals(B, pMap.getLibraryByAddress(A).getHighestAddress());
+ assertEquals(C, pMap.getLibraryByAddress(C).getLowestAddress());
+ }
+
+ /**
+ * Test complex removal with one call.
+ */
+ @Test
+ public void test_remove_complex() {
+ pMap.addLibraryMap(new LibraryObject(ID1, A, B));
+ pMap.addLibraryMap(new LibraryObject(ID2, B, C));
+ pMap.addLibraryMap(new LibraryObject(ID3, C, D));
+ pMap.addLibraryMap(new LibraryObject(ID4, D, E));
+ pMap.addLibraryMap(new LibraryObject(ID5, E, F));
+
+ assertEquals(5, pMap.getAllMappings().size());
+
+ long low = (B + C) / 2, high = (E + F) / 2;
+ pMap.removeMapping(low, high);
+ assertEquals(3, pMap.getAllMappings().size());
+ assertEquals(low, pMap.getLibraryByAddress(B).getHighestAddress());
+ assertEquals(high, pMap.getLibraryByAddress(F - 1).getLowestAddress());
+ assertNull(pMap.getLibraryByAddress(C));
+ assertNull(pMap.getLibraryByAddress(D));
+ }
+}
}
@Before
- public void setUp() {
+ public void setUp() throws Exception {
Global.setLSanInitialized(false);
parser = new MessageParser();
parser.start();
}
@After
- public void tearDown() {
+ public void tearDown() throws Exception {
parser.stopForced();
}
}
package org.tizen.dynamicanalyzer.ui.memory.data;
import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyZeroInteractions;
-import java.io.File;
-import java.io.PrintWriter;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.After;
-import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Mock;
import org.mockito.Spy;
-import org.mockito.internal.util.reflection.Whitebox;
import org.mockito.runners.MockitoJUnitRunner;
import org.powermock.reflect.internal.WhiteboxImpl;
import org.tizen.dynamicanalyzer.common.Global;
-import org.tizen.dynamicanalyzer.database.DBInserter;
import org.tizen.dynamicanalyzer.project.Project;
import org.tizen.dynamicanalyzer.swap.model.data.MemoryData;
import org.tizen.dynamicanalyzer.util.InternalLogger;
@RunWith(MockitoJUnitRunner.class)
public class HeapDataManagerTest {
- private final static String lsanReport = "lsan.test.log";
- private final static String lsanReportFormat = "%d %d %d\n";
-
- @Mock
- private DBInserter lsanDBInserter;
-
@Spy
private HeapDataManager manager = HeapDataManager.getInstance();
Logger.init(InternalLogger.DEBUG);
}
- @Before
- public void setUp() {
- Whitebox.setInternalState(manager, "lsanDBInserter", lsanDBInserter);
- }
-
- /**
- * Helper method for writing LSan report file and parsing it by
- * {@link HeapDataManager#parseLSanReportFile(String)}.
- *
- * @param content content of report file
- * @throws Exception
- */
- private void parseLSanReport(String content) throws Exception {
- PrintWriter lsanReportWriter = new PrintWriter(lsanReport,
- StandardCharsets.US_ASCII.name());
- lsanReportWriter.write(content);
- lsanReportWriter.flush();
- lsanReportWriter.close();
-
- manager.parseLSanReportFile(lsanReport);
- }
-
- @Test
- public void parseLSanReportFile_correctFormat() throws Exception {
- List<List<Object>> expected = new ArrayList<List<Object>>();
- StringBuffer report = new StringBuffer();
-
- List<Object> row = new ArrayList<Object>();
- expected.add(row);
- row.add(0L);
- row.add(1L);
- row.add(2L);
- report.append(String.format(lsanReportFormat, (Long) row.get(0), (Long) row.get(1), (Long) row.get(2)));
-
- row = new ArrayList<Object>();
- expected.add(row);
- row.add(3L);
- row.add(4L);
- row.add(5L);
- report.append(String.format(lsanReportFormat, (Long) row.get(0), (Long) row.get(1), (Long) row.get(2)));
-
- parseLSanReport(report.toString());
- verify(lsanDBInserter).pushData(eq(expected));
- }
-
- @Test
- public void parseLSanReportFile_partlyCorrectFormat() throws Exception {
- List<List<Object>> expected = new ArrayList<List<Object>>();
- StringBuffer report = new StringBuffer();
-
- // correct line
- List<Object> row = new ArrayList<Object>();
- expected.add(row);
- row.add(0L);
- row.add(1L);
- row.add(2L);
- report.append(String.format(lsanReportFormat, (Long) row.get(0), (Long) row.get(1), (Long) row.get(2)));
-
- // incorrect line
- report.append("test");
-
- parseLSanReport(report.toString());
- verifyZeroInteractions(lsanDBInserter);
- }
-
- @Test
- public void parseLSanReportFile_nonExistentReport() {
- manager.parseLSanReportFile("non-existent/report.file");
- verifyZeroInteractions(lsanDBInserter);
- }
-
- @Test
- public void parseLSanReportFile_nonDigits() throws Exception {
- parseLSanReport("a b c");
- verifyZeroInteractions(lsanDBInserter);
- }
-
- @Test
- public void parseLSanReportFile_tooFewFields() throws Exception {
- parseLSanReport("0 1");
- verifyZeroInteractions(lsanDBInserter);
- }
-
- @Test
- public void parseLSanReportFile_tooManyFields() throws Exception {
- parseLSanReport("0 1 2 3");
- verifyZeroInteractions(lsanDBInserter);
- }
-
- @Test
- public void parseLSanReportFile_empty() throws Exception {
- parseLSanReport("");
- verifyZeroInteractions(lsanDBInserter);
- }
-
@Test
public void testGetAllocatorAddress32() throws Exception {
setProtocolVersion("4.2");
p.setProtocolVersion(version);
Global.setProject(p);
}
-
- @After
- public void tearDown() {
- File lsanReportFile = new File(lsanReport);
- if (lsanReportFile.exists())
- lsanReportFile.delete();
- }
-
}
--- /dev/null
+package org.tizen.dynamicanalyzer.ui.memory.data;
+
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Spy;
+import org.mockito.internal.util.reflection.Whitebox;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.tizen.dynamicanalyzer.database.DBInserter;
+import org.tizen.dynamicanalyzer.util.InternalLogger;
+import org.tizen.dynamicanalyzer.util.Logger;
+
+/**
+ * Tests for {@link LeakDataManager}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class LeakDataManagerTest {
+
+ private final static String lsanReport = "lsan.test.log";
+ private final static String lsanReportFormat = "%d %d %d\n";
+
+ @Mock
+ private DBInserter lsanDBInserter;
+
+ @Spy
+ private LsanDataManager manager = LsanDataManager.getInstance();
+
+ @BeforeClass
+ public static void init() {
+ Logger.init(InternalLogger.DEBUG);
+ }
+
+ @Before
+ public void setUp() {
+ Whitebox.setInternalState(manager, "lsanDBInserter", lsanDBInserter);
+ }
+
+ /**
+ * Helper method for writing LSan report file and parsing it by
+ * {@link HeapDataManager#parseLSanReportFile(String)}.
+ *
+ * @param content content of report file
+ * @throws Exception
+ */
+ private void parseLSanReport(String content) throws Exception {
+ PrintWriter lsanReportWriter = new PrintWriter(lsanReport,
+ StandardCharsets.US_ASCII.name());
+ lsanReportWriter.write(content);
+ lsanReportWriter.flush();
+ lsanReportWriter.close();
+
+ manager.parseLSanReportFile(lsanReport);
+ }
+
+ @Test
+ public void parseLSanReportFile_correctFormat() throws Exception {
+ List<List<Object>> expected = new ArrayList<List<Object>>();
+ StringBuffer report = new StringBuffer();
+
+ List<Object> row = new ArrayList<Object>();
+ expected.add(row);
+ row.add(0L);
+ row.add(1L);
+ row.add(2L);
+ report.append(String.format(lsanReportFormat, (Long) row.get(0), (Long) row.get(1), (Long) row.get(2)));
+
+ row = new ArrayList<Object>();
+ expected.add(row);
+ row.add(3L);
+ row.add(4L);
+ row.add(5L);
+ report.append(String.format(lsanReportFormat, (Long) row.get(0), (Long) row.get(1), (Long) row.get(2)));
+
+ parseLSanReport(report.toString());
+ verify(lsanDBInserter).pushData(eq(expected));
+ }
+
+ @Test
+ public void parseLSanReportFile_partlyCorrectFormat() throws Exception {
+ List<List<Object>> expected = new ArrayList<List<Object>>();
+ StringBuffer report = new StringBuffer();
+
+ // correct line
+ List<Object> row = new ArrayList<Object>();
+ expected.add(row);
+ row.add(0L);
+ row.add(1L);
+ row.add(2L);
+ report.append(String.format(lsanReportFormat, (Long) row.get(0), (Long) row.get(1), (Long) row.get(2)));
+
+ // incorrect line
+ report.append("test");
+
+ parseLSanReport(report.toString());
+ verifyZeroInteractions(lsanDBInserter);
+ }
+
+ @Test
+ public void parseLSanReportFile_nonExistentReport() {
+ manager.parseLSanReportFile("non-existent/report.file");
+ verifyZeroInteractions(lsanDBInserter);
+ }
+
+ @Test
+ public void parseLSanReportFile_nonDigits() throws Exception {
+ parseLSanReport("a b c");
+ verifyZeroInteractions(lsanDBInserter);
+ }
+
+ @Test
+ public void parseLSanReportFile_tooFewFields() throws Exception {
+ parseLSanReport("0 1");
+ verifyZeroInteractions(lsanDBInserter);
+ }
+
+ @Test
+ public void parseLSanReportFile_tooManyFields() throws Exception {
+ parseLSanReport("0 1 2 3");
+ verifyZeroInteractions(lsanDBInserter);
+ }
+
+ @Test
+ public void parseLSanReportFile_empty() throws Exception {
+ parseLSanReport("");
+ verifyZeroInteractions(lsanDBInserter);
+ }
+
+ @After
+ public void tearDown() {
+ File lsanReportFile = new File(lsanReport);
+ if (lsanReportFile.exists())
+ lsanReportFile.delete();
+ }
+
+}
--- /dev/null
+package org.tizen.dynamicanalyzer.ui.memory.data.util;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.tizen.dynamicanalyzer.ui.memory.data.MemAllocDBTable;
+import org.tizen.dynamicanalyzer.ui.memory.data.MemFreeDBTable;
+
+public class StatisticsQuerySerializerTest {
+
+ private static final String allocTimeRangeFormat = String.format("%s BETWEEN %%s AND %%s",
+ MemAllocDBTable.COLUMN.ALLOCATED_TIME);
+ private static final String freeTimeRangeFormat = String.format("%s <= %%s",
+ MemFreeDBTable.COLUMN.FREE_TIME);
+ private static final String pidRangeFormat = String.format("WHERE %s in %%s",
+ MemAllocDBTable.COLUMN.PID.name);
+
+ private StatisticsQuerySerializer serializer = new StatisticsQuerySerializer();
+
+ @Test
+ public void toSqlString_pidString() {
+ Query q = new Query();
+ q.pidString = "(1,2,3)";
+
+ String pidRange = String.format(pidRangeFormat, q.pidString);
+
+ assertTrue(serializer.toSqlString(q).contains(pidRange));
+ }
+
+ @Test
+ public void toSqlString_allRange() {
+ Query q = new Query();
+
+ String allocTimeRange = String.format(allocTimeRangeFormat, q.startTime, q.endTime);
+ String freeTimeRange = String.format(freeTimeRangeFormat, q.endTime);
+ String serializedStr = serializer.toSqlString(q);
+
+ assertFalse(serializedStr.contains(allocTimeRange));
+ assertFalse(serializedStr.contains(freeTimeRange));
+ }
+
+ @Test
+ public void toSqlString_selectedRange() {
+ Query q = new Query();
+ q.startTime = 10;
+ q.endTime = 20;
+
+ String allocTimeRange = String.format(allocTimeRangeFormat, q.startTime, q.endTime);
+ String freeTimeRange = String.format(freeTimeRangeFormat, q.endTime);
+ String serializedStr = serializer.toSqlString(q);
+
+ assertTrue(serializedStr.contains(allocTimeRange));
+ assertTrue(serializedStr.contains(freeTimeRange));
+ }
+}
import org.tizen.dynamicanalyzer.model.TableInput;
import org.tizen.dynamicanalyzer.setting.SettingConstants;
import org.tizen.dynamicanalyzer.ui.memory.MemoryPage;
-import org.tizen.dynamicanalyzer.ui.memory.data.HeapDataManager;
+import org.tizen.dynamicanalyzer.ui.memory.data.HeapDataProcessor;
import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat;
@RunWith(PowerMockRunner.class)
memAllocationData.add(3); // CALLER LIBRARY ID
memAllocationData.add(128L); // ALLOCATED SIZE
- TableInput input = HeapDataManager.getInstance()
+ TableInput input = HeapDataProcessor.getInstance()
.makePersistentAllocsTableInput(memAllocationData, 10, false);
assertNotNull(input);
((DATableDataFormat)input.getData()).setType(AnalyzerConstants.TYPE_TABLE_MEM_ALLOCATEDTRACE);
import org.tizen.dynamicanalyzer.setting.SettingConstants;
import org.tizen.dynamicanalyzer.ui.file.FilePage;
import org.tizen.dynamicanalyzer.ui.hierarchy.HierarchyPage;
-import org.tizen.dynamicanalyzer.ui.interactive.InteractivePage;
-import org.tizen.dynamicanalyzer.ui.kernel.KernelPage;
import org.tizen.dynamicanalyzer.ui.memory.MemoryPage;
import org.tizen.dynamicanalyzer.ui.network.NetworkPage;
import org.tizen.dynamicanalyzer.ui.opengl.GLPage;
import org.tizen.dynamicanalyzer.ui.summary.SummaryPage;
import org.tizen.dynamicanalyzer.ui.thread.ThreadPage;
import org.tizen.dynamicanalyzer.ui.timeline.TimelinePage;
-import org.tizen.dynamicanalyzer.ui.userinterface.UIPage;
import org.tizen.dynamicanalyzer.util.InternalLogger;
import org.tizen.dynamicanalyzer.util.Logger;
expectedPageNames.add(SettingConstants.PAGE_NAME_FILE);
pageIDs.add(GLPage.pageID);
expectedPageNames.add(SettingConstants.PAGE_NAME_OPENGL);
- pageIDs.add(UIPage.pageID);
- expectedPageNames.add(SettingConstants.PAGE_NAME_UI);
- pageIDs.add(KernelPage.pageID);
- expectedPageNames.add(SettingConstants.PAGE_NAME_KERNEL);
- pageIDs.add(InteractivePage.pageID);
- expectedPageNames.add(SettingConstants.PAGE_NAME_INTERACTIVE);
pageIDs.add(SummaryPage.pageID);
expectedPageNames.add(SettingConstants.PAGE_NAME_SUMMARY);
pageIDs.add(HierarchyPage.pageID);
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry exported="true" kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
-org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.7
+org.eclipse.jdt.core.compiler.source=1.8
org.tizen.dynamicanalyzer.widgets.graph.circular,
org.tizen.dynamicanalyzer.widgets.helper,
org.tizen.dynamicanalyzer.widgets.lifecycle,
+ org.tizen.dynamicanalyzer.widgets.notification,
org.tizen.dynamicanalyzer.widgets.popupMenu,
org.tizen.dynamicanalyzer.widgets.progress,
org.tizen.dynamicanalyzer.widgets.scale,
--- /dev/null
+package org.tizen.dynamicanalyzer.widgets.chart;
+
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+
+/**
+ * Renderer is used to show notifications on chart.
+ */
+public class DANotificationOnChartRenderer extends DAChartRenderer {
+
+ /** offsets */
+ private static final int LEFT_OFFSET = 5;
+ private static final int TOP_OFFSET = 4;
+ private static final int LINE_OFFSET = 2;
+ /** notification strings */
+ private final String[] notification;
+
+ /**
+ * Public constructor.
+ *
+ * @param notification Notification to be shown.
+ */
+ public DANotificationOnChartRenderer(String notification) {
+ this.notification = notification.split("\n");
+ }
+
+ @Override
+ public void draw(GC gc, DAChart chart, Image buffer) {
+ super.draw(gc, chart, buffer);
+ Rectangle rectangle = chart.getClientArea();
+ Point[] line = new Point[notification.length];
+ line[0] = new Point(rectangle.x + LEFT_OFFSET, rectangle.y + TOP_OFFSET);
+ for (int i = 1; i < line.length; i++) {
+ line[i] = new Point(line[i - 1].x,
+ line[i - 1].y + LINE_OFFSET + gc.getFontMetrics().getHeight());
+ }
+ for (int i = 0; i < line.length; i++) {
+ gc.drawString(notification[i], line[i].x, line[i].y, true);
+ }
+
+ }
+}
import org.tizen.dynamicanalyzer.widgets.helper.ColorResources;
import org.tizen.dynamicanalyzer.widgets.helper.FontResources;
import org.tizen.dynamicanalyzer.widgets.lifecycle.LifecycleBar;
-import org.tizen.dynamicanalyzer.widgets.lifecycle.LifecycleData;
import org.tizen.dynamicanalyzer.widgets.scale.DAScale;
import org.tizen.dynamicanalyzer.widgets.scale.DAScaleSelectionListener;
import org.tizen.dynamicanalyzer.widgets.timeline.DATimeline;
import org.tizen.dynamicanalyzer.widgets.timeline.DATimelineFrameRenderer;
-import org.tizen.dynamicanalyzer.widgets.timeline.DATimelineMarker;
import org.tizen.dynamicanalyzer.widgets.timeline.DATimelineTimeRenderer;
import org.tizen.dynamicanalyzer.widgets.timeline.DATimelineTinyTimeRenderer;
private Composite titleComp;
private DACustomToggleButton itemMinimizeButton;
private DATimeline timeline;
- private LifecycleBar lifecycleBar;
- /**
- * Default lifecycle data used to draw very first phase.
- */
- private LifecycleData defaultLifecycleData = null;
+ protected LifecycleBar lifecycleBar;
private DefaultToolTip lifecycleBarTooltip;
private DefaultToolTip timelineTooltip;
private IDAChartSeriesMaker chartSeriesMaker;
- public DAChartBoard(Composite parent, String title, LifecycleData defaultLifecycleData) {
- this(parent, title, BOARD_STYLE_TIME, defaultLifecycleData);
+ public DAChartBoard(Composite parent, String title) {
+ this(parent, title, BOARD_STYLE_TIME);
}
- public DAChartBoard(Composite parent, String title, int[] scaleValues,
- LifecycleData defaultLifecycleData) {
- this(parent, title, BOARD_STYLE_KERNEL, defaultLifecycleData);
+ public DAChartBoard(Composite parent, String title, int[] scaleValues) {
+ this(parent, title, BOARD_STYLE_KERNEL);
scale.setMaximum(scaleValues.length - 1);
boardManager.setScaleValues(scaleValues);
}
- public DAChartBoard(Composite parent, String title, int boardStyle,
- LifecycleData defaultLifecycleData) {
+ public DAChartBoard(Composite parent, String title, int boardStyle) {
super(parent, SWT.NONE);
this.setLayout(new FormLayout());
this.setBackground(ColorResources.WHITE);
- this.defaultLifecycleData = defaultLifecycleData;
titleComp = new Composite(this, SWT.NONE);
titleComp.setLayout(new FillLayout());
boardManager = new DAChartBoardManager(this);
}
- /**
- * Get default {@link LifecycleData}.
- */
- public LifecycleData getDefaultLifecycleData() {
- return defaultLifecycleData;
- }
-
public DAScale getScale(){
return scale;
}
}
/**
- * Clear list of lifecycle phases and add first default phase.
+ * Clear list of lifecycle phases
*/
- private void reinitLifecycleData() {
- if (lifecycleBar != null) {
+ protected void reinitLifecycleData() {
+ if (lifecycleBar != null)
lifecycleBar.clear();
- if (defaultLifecycleData != null) {
- lifecycleBar.addLifecycleData(defaultLifecycleData);
- }
- }
}
public void contentsClear() {
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
private SelectionListener okButtonListener = null;
private SelectionListener cancelButtonListener = null;
+ private SelectionListener defaultCancelButtonListener = new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ close();
+ }
+ };
// loading animation
private DAAnimationIcon progressIcon = null;
progressStyle == PROGRESS_STYLE_INDETERMINATE) {
cancelButton = createButton(progressComp, "Cancel", cancelData);
cancelButton.setLayoutData(cancelData);
- cancelButton.addSelectionListener(new SelectionListener () {
-
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
- // TODO Auto-generated method stub
-
- }
- @Override
- public void widgetSelected(SelectionEvent arg0) {
- close();
- }
-
- });
-
-
- if (cancelButtonListener != null) {
+ if (cancelButtonListener != null)
cancelButton.addSelectionListener(cancelButtonListener);
- }
+ else
+ cancelButton.addSelectionListener(defaultCancelButtonListener);
}
}
public void setOkListener(SelectionListener listener) {
okButtonListener = listener;
}
-
+
+ /**
+ * Replace default 'Cancel' button listener with the specified listener.
+ *
+ * @param listener listener to set as {@link SelectionListener} for 'Cancel'
+ * button
+ */
public void setCancelListener(SelectionListener listener) {
cancelButtonListener = listener;
}
--- /dev/null
+package org.tizen.dynamicanalyzer.widgets.notification;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.dynamicanalyzer.util.Logger;
+
+/**
+ * Notification pop-up implementation.
+ *
+ * @author d.nikiforov
+ */
+public class DAPopupNotification {
+
+ /**
+ * Sleep timeouts
+ */
+ private static final long NOTIFICATION_TIMEOUT_MILLIS = 3000;
+ private static final long FADE_OUT_STEP_MILLIS = 10;
+
+ /**
+ * Size constants
+ */
+ private static final int VERTICAL_BOTTOM_OFFSET = 225;
+ private static final int HEIGHT = 110;
+ private static final int WIDTH = 320;
+
+ /**
+ * Transparency constants
+ */
+ private static final int DEFAULT_ALPHA = 230;
+ private static final int FADE_OUT_STEPS = 100;
+
+ /**
+ * Contents
+ */
+ private String title;
+ private String message;
+ private String details;
+
+ /**
+ * Notification pop-up window
+ */
+ private Shell shell = null;
+
+ /**
+ * Contents renderer
+ */
+ private IPopupNotificationRenderer renderer = new DAPopupNotificationRenderer();
+
+ /**
+ * Closes notification on mouse click.
+ */
+ private MouseListener mouseListener = new MouseListener() {
+
+ @Override
+ public void mouseUp(MouseEvent e) {
+ // Auto-generated method stub
+ }
+
+ @Override
+ public void mouseDown(MouseEvent e) {
+ close();
+ }
+
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {
+ // Auto-generated method stub
+ }
+ };
+
+ /**
+ * Draws all contents.
+ */
+ private PaintListener paintListener = (PaintEvent e) -> {
+ // title should not be empty
+ if (title == null || title.isEmpty()) {
+ Logger.warning("There is no title for notification!");
+ close();
+ return;
+ }
+
+ // renderer should be specified to draw anything
+ if (renderer == null) {
+ Logger.warning("There is no render for notification!");
+ shell.dispose();
+ return;
+ }
+
+ renderer.draw(e.gc, this);
+ };
+
+ /**
+ * Creates a new instance of notification message with one line:
+ * <ul>
+ * <li>{@code title} - Notification Title</li>
+ * </ul>
+ *
+ * @param parent parent {@link Shell}
+ * @param title message title
+ */
+ public DAPopupNotification(Shell parent, String title) {
+ this(parent, title, null, null);
+ }
+
+ /**
+ * Creates a new instance of notification message with two lines:
+ * <ul>
+ * <li>{@code title} - Notification Title</li>
+ * <li>{@code message} - Location / Detail</li>
+ * </ul>
+ *
+ * @param parent parent {@link Shell}
+ * @param title message title
+ * @param message detailed message
+ */
+ public DAPopupNotification(Shell parent, String title, String message) {
+ this(parent, title, message, null);
+ }
+
+ /**
+ * Creates a new instance of notification message with three lines:
+ * <ul>
+ * <li>{@code title} - Notification Title</li>
+ * <li>{@code message} - Location / Detail</li>
+ * <li>{@code details} - Option (Guide for next action)</li>
+ * </ul>
+ *
+ * @param parent parent {@link Shell}
+ * @param title message title
+ * @param message detailed message
+ * @param details additional information
+ */
+ public DAPopupNotification(Shell parent, String title, String message, String details) {
+ // contents
+ this.title = title;
+ this.message = message;
+ this.details = details;
+
+ // shell
+ shell = new Shell(parent, SWT.TOOL | SWT.NO_FOCUS | SWT.NO_TRIM);
+
+ shell.setSize(WIDTH, HEIGHT);
+
+ Point parentSize = parent.getSize();
+ Point parentLoc = parent.getLocation();
+ shell.setLocation((parentLoc.x + parentSize.x - WIDTH) / 2,
+ parentLoc.y + parentSize.y - VERTICAL_BOTTOM_OFFSET);
+
+ shell.addPaintListener(paintListener);
+ shell.addMouseListener(mouseListener);
+
+ shell.setAlpha(DEFAULT_ALPHA);
+ shell.setVisible(false);
+
+ // save reference to this object as shell's data, so that it can be
+ // retrieved in events listeners
+ shell.setData(this);
+ }
+
+ /**
+ * Opens this notification and closes it after a few seconds.
+ */
+ public void open() {
+ if (shell == null || shell.isDisposed() || renderer == null)
+ return;
+
+ shell.setRegion(renderer.getVisibleRegion());
+ shell.open();
+
+ Thread closingThread = new Thread(() -> {
+ try {
+ Thread.sleep(NOTIFICATION_TIMEOUT_MILLIS);
+ } catch (InterruptedException e) {
+ Logger.warning("Interrupted while sleeping");
+ Thread.currentThread().interrupt();
+ } finally {
+ Display.getDefault().syncExec(DAPopupNotification.this::close);
+ }
+ }, "DAPopupNotification closing thread");
+
+ closingThread.start();
+ }
+
+ /**
+ * Closes and disposes this notification with 'fade out' effect. Blocking
+ * method.
+ */
+ public void close() {
+ if (shell == null || shell.isDisposed())
+ return;
+
+ int curAlpha = shell.getAlpha();
+ int alphaStep = curAlpha / FADE_OUT_STEPS;
+
+ // fade out loop
+ for (int i = 0; i < FADE_OUT_STEPS && curAlpha > 0; ++i, curAlpha -= alphaStep) {
+ shell.setAlpha(curAlpha);
+ shell.redraw();
+ shell.update();
+
+ try {
+ Thread.sleep(FADE_OUT_STEP_MILLIS);
+ } catch (InterruptedException e) {
+ Logger.warning("Interrupted while fading");
+ Thread.currentThread().interrupt();
+ break;
+ }
+ }
+
+ shell.close();
+ shell.dispose();
+ }
+
+ /**
+ * Gets the notification title.
+ *
+ * @return the title
+ */
+ public String getTitle() {
+ return title;
+ }
+
+ /**
+ * Sets the notification title. Cannot be {@code null}.
+ *
+ * @param title the title to set
+ */
+ public void setTitle(String title) {
+ if (title != null)
+ this.title = title;
+ }
+
+ /**
+ * Gets the notification message.
+ *
+ * @return the message
+ */
+ public String getMessage() {
+ return message;
+ }
+
+ /**
+ * Sets the notification message.
+ *
+ * @param message the message to set
+ */
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ /**
+ * Gets the notification details.
+ *
+ * @return the details
+ */
+ public String getDetails() {
+ return details;
+ }
+
+ /**
+ * Sets the notification details.
+ *
+ * @param details the details to set
+ */
+ public void setDetails(String details) {
+ this.details = details;
+ }
+
+ /**
+ * Sets custom renderer for notification. Cannot be {@code null}.
+ *
+ * @param renderer the renderer to set
+ */
+ public void setRenderer(IPopupNotificationRenderer renderer) {
+ if (renderer != null)
+ this.renderer = renderer;
+ }
+
+ /**
+ * Adds specified {@code listener} to underlying shell.
+ *
+ * @param listener {@link DisposeListener} implementation
+ */
+ public void addDisposeListener(DisposeListener listener) {
+ shell.addDisposeListener(listener);
+ }
+
+ /**
+ * Removes specified {@code listener} from underlying shell.
+ *
+ * @param listener {@link DisposeListener} implementation
+ */
+ public void removeDisposeListener(DisposeListener listener) {
+ shell.removeDisposeListener(listener);
+ }
+
+ /**
+ * Gets the location of the notification.
+ *
+ * @return absolute coordinates of the top left corner
+ */
+ public Point getLocation() {
+ return shell.getLocation();
+ }
+
+ /**
+ * Sets the location of the notification.
+ *
+ * @param location absolute coordinates of the top left corner
+ */
+ public void setLocation(Point location) {
+ shell.setLocation(location);
+ }
+
+ /**
+ * Gets the size of the notification.
+ *
+ * @return relative coordinates of the bottom right corner (width, height)
+ */
+ public Point getSize() {
+ return shell.getSize();
+ }
+}
--- /dev/null
+package org.tizen.dynamicanalyzer.widgets.notification;
+
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGBA;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.graphics.Region;
+import org.tizen.dynamicanalyzer.resources.ColorResources;
+import org.tizen.dynamicanalyzer.resources.FontResources;
+import org.tizen.dynamicanalyzer.resources.ImageResources;
+
+/**
+ * Default implementation of {@link IPopupNotificationRenderer}.
+ *
+ * @author d.nikiforov
+ */
+public class DAPopupNotificationRenderer implements IPopupNotificationRenderer {
+
+ /**
+ * Offsets
+ */
+ private static final int TEXT_LEFT_MARGIN = 95;
+ private static final int TEXT_TOP_MARGIN_1L = 48;
+ private static final int TEXT_TOP_MARGIN_2L = 35;
+ private static final int TEXT_TOP_MARGIN_3L = 27;
+ private static final int TEXT_SPACING1 = 10;
+ private static final int TEXT_SPACING2 = 5;
+ private static final int TEXT_HEIGHT1 = 15;
+ private static final int TEXT_HEIGHT2 = 13;
+ private static final int ICON_LEFT_MARGIN = 25;
+ private static final int ICON_TOP_MARGIN = 30;
+ private static final int TEXT_MAX_WIDTH = 200;
+ private static final int UNDERLINE_OFFSET = -2;
+
+ /**
+ * Transparency of 'details' text
+ */
+ private static final double DETAILS_TEXT_ALPHA = 0.65;
+
+ /**
+ * Images
+ */
+ private static final Image BACKGROUND = ImageResources.NOTIFICATION_BG;
+ private static final Image ICON = ImageResources.NOTIFICATION_ICON;
+
+ /**
+ * Fonts
+ */
+ private static final Font TITLE_FONT = FontResources.NOTIFICATION_TITLE_FONT;
+ private static final Font MESSAGE_FONT = FontResources.NOTIFICATION_MESSAGE_FONT;
+
+ /**
+ * Visible region that should be drawn upon
+ */
+ private static final Region visibleRegion = calculateVisibleRegion();
+
+ @Override
+ public void draw(GC gc, DAPopupNotification notification) {
+ // draw images
+ gc.drawImage(BACKGROUND, 0, 0);
+ gc.drawImage(ICON, ICON_LEFT_MARGIN, ICON_TOP_MARGIN);
+
+ // draw text
+ drawAllText(gc,
+ notification.getTitle(),
+ notification.getMessage(),
+ notification.getDetails());
+ }
+
+ @Override
+ public Region getVisibleRegion() {
+ return visibleRegion;
+ }
+
+ /**
+ * Calculates visible region based on alpha channel of the background image.
+ *
+ * @return visible region (for any pixel: alpha > 0)
+ */
+ private static Region calculateVisibleRegion() {
+ Region result = new Region();
+ ImageData imageData = BACKGROUND.getImageData();
+
+ if (imageData.alphaData == null) {
+ // if image has no alpha channel, then the whole region is visible
+ result.add(BACKGROUND.getBounds());
+ } else {
+ // if image has alpha, then cut transparent pixels from the
+ // resulting region, e.g. it can cut white corners from
+ // image with rounded corners
+ for (int y = 0; y < imageData.height; y++) {
+ for (int x = 0; x < imageData.width; x++) {
+ if (imageData.getAlpha(x, y) > 0) {
+ result.add(imageData.x + x, imageData.y + y, 1, 1);
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Draws all specified texts.
+ *
+ * @param gc {@link GC} instance
+ * @param title notification title
+ * @param message notification message
+ * @param details notification details
+ */
+ private void drawAllText(GC gc, String title, String message, String details) {
+ // title cannot be empty
+ if (title == null || title.isEmpty())
+ return;
+
+ // set white color for text
+ gc.setForeground(ColorResources.WHITE);
+
+ // text coordinates
+ int x = TEXT_LEFT_MARGIN, y;
+
+ if (message != null && !message.isEmpty()) {
+ if (details != null && !details.isEmpty()) {
+ // 3 lines
+ y = TEXT_TOP_MARGIN_3L;
+ drawText(gc, title, TITLE_FONT, x, y);
+
+ y += TEXT_HEIGHT1 + TEXT_SPACING1;
+ drawText(gc, message, MESSAGE_FONT, x, y);
+
+ y += TEXT_HEIGHT2 + TEXT_SPACING2;
+ drawText(gc, details, MESSAGE_FONT, x, y, DETAILS_TEXT_ALPHA, true);
+ } else {
+ // 2 lines
+ y = TEXT_TOP_MARGIN_2L;
+ drawText(gc, title, TITLE_FONT, x, y);
+
+ y += TEXT_HEIGHT1 + TEXT_SPACING1;
+ drawText(gc, message, MESSAGE_FONT, x, y);
+ }
+ } else {
+ // 1 line
+ y = TEXT_TOP_MARGIN_1L;
+ drawText(gc, title, TITLE_FONT, x, y);
+ }
+
+ // revert clipping area to its original state
+ gc.setClipping((Rectangle) null);
+ }
+
+ /**
+ * Draws {@code text} onto specified {@link GC}.
+ *
+ * @param gc {@link GC} instance
+ * @param text text to be drawn
+ * @param font font to use for drawing
+ * @param x x-axis text coordinate
+ * @param y y-axis text coordinate
+ */
+ private void drawText(GC gc, String text, Font font, int x, int y) {
+ gc.setFont(font);
+ // set clipping width so that too long text would be cut out and
+ // set clipping height a little bigger to enable underlined text
+ gc.setClipping(new Rectangle(x, y, TEXT_MAX_WIDTH, gc.textExtent(text).y + 3));
+ gc.drawText(text, x, y, true);
+ }
+
+ /**
+ * Draws {@code text} onto specified {@link GC}.
+ *
+ * @param gc {@link GC} instance
+ * @param text text to be drawn
+ * @param font font to use for drawing
+ * @param x x-axis text coordinate
+ * @param y y-axis text coordinate
+ * @param alpha decimal opaqueness value (1.0 - opaque, 0.0 - transparent)
+ * @param underline whether text should be underlined
+ */
+ private void drawText(GC gc, String text, Font font, int x, int y, double alpha,
+ boolean underline) {
+ // set alpha
+ Color fg = gc.getForeground();
+ RGBA rgba = fg.getRGBA();
+ rgba.alpha = (int) (255 * alpha);
+ gc.setForeground(new Color(fg.getDevice(), rgba));
+
+ // draw text
+ drawText(gc, text, font, x, y);
+
+ // draw underline 1px below text
+ if (underline) {
+ Point textSize = gc.textExtent(text);
+ y = y + textSize.y + UNDERLINE_OFFSET;
+ gc.drawLine(x, y, x + textSize.x, y);
+ }
+ }
+}
--- /dev/null
+package org.tizen.dynamicanalyzer.widgets.notification;
+
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Region;
+
+/**
+ * Interface for {@link DAPopupNotification} renderers.
+ *
+ * @author d.nikiforov
+ */
+public interface IPopupNotificationRenderer {
+
+ /**
+ * Draws given {@code notification} in specified {@link GC}.
+ *
+ * @param gc {@link GC} instance
+ * @param notification {@link DAPopupNotification} instance that needs to be
+ * drawn
+ */
+ public void draw(GC gc, DAPopupNotification notification);
+
+ /**
+ * Returns visible region calculated based on alpha channel of background
+ * image.
+ *
+ * @return visible {@link Region}
+ */
+ public Region getVisibleRegion();
+}
private static Shell topShell;
private Shell shell;
private DAPopupMenu childMenu;
- private List<DAPopupMenuItem> children;
+ private List<DAPopupMenuItem> children = new ArrayList<>();
private Font itemFont; // FIXME
private static final int MOUSE_LEFT = 1;
case 3:
Point pt = Display.getCurrent().getCursorLocation();
- if (true == isInParent(pt)) {
+ if (isInParent(pt) && children.size() > 0) {
open(topShell, pt.x - 5, pt.y - 5);
}
break;
}
public boolean makeItem(Shell shell, int x, int y) {
- if (null == children) {
- return false;
- }
-
shell.setLayout(new FormLayout());
int childSize = children.size();
int itemHeight = 0;
}
protected void addChild(DAPopupMenuItem item) {
- if (null == children) {
- children = new ArrayList<DAPopupMenuItem>();
- }
children.add(item);
}
protected void removeChild(DAPopupMenuItem item) {
- if (null == children) {
- return;
- }
int childSize = children.size();
for (int i = 0; i < childSize; i++) {
if (item.equals(children.get(i))) {
}
protected void removechild(int index) {
- if (null == children || children.size() <= index) {
+ if (children.size() <= index) {
return;
}
children.remove(index);
}
public DAPopupMenuItem getItem(int index) {
- if (children == null || children.size() <= index) {
+ if (children.size() <= index) {
return null;
}
return children.get(index);
<?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.5"?>
-<product name="%DynamicAnalyzer" uid="org.tizen.dynamicanalyzer.workbench.product" id="org.tizen.dynamicanalyzer.workbench.product" application="org.tizen.dynamicanalyzer.workbench.application" version="2.4.5.qualifier" useFeatures="true" includeLaunchers="true">
+<product name="%DynamicAnalyzer" uid="org.tizen.dynamicanalyzer.workbench.product" id="org.tizen.dynamicanalyzer.workbench.product" application="org.tizen.dynamicanalyzer.workbench.application" version="2.5.1.qualifier" useFeatures="true" includeLaunchers="true">
<aboutInfo>
<image path="icons/about_tizen_sdk.png"/>
<launcherArgs>
<programArgs>-data @noDefault
</programArgs>
- <vmArgs>-XX:MaxPermSize=64m
--Xms256m
--Xmx512m
+ <vmArgs>-Xms256m
+-Xmx1024m
-XX:+UseParNewGC
-XX:+UseConcMarkSweepGC
</vmArgs>
<parent>
<artifactId>dynamic-analyzer</artifactId>
<groupId>org.tizen.dynamicanalyzer</groupId>
- <version>2.4.5-SNAPSHOT</version>
+ <version>2.5.1-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<groupId>org.tizen.dynamicanalyzer</groupId>
<artifactId>org.tizen.dynamicanalyzer.workbench.product</artifactId>
- <version>2.4.5-SNAPSHOT</version>
+ <version>2.5.1-SNAPSHOT</version>
<packaging>eclipse-repository</packaging>
<properties>
Version|0.2
Log Level|4
-Debug Print|Y
+Debug Print|N
Available Target List|mobile|wearable
Selected Target|mobile
Total Overhead Range|1000000|3000000|7000000|15000000
<classpathentry exported="true" kind="lib" path="lib/org.eclipse.cdt.core_5.3.1.201109151620.jar"/>
<classpathentry exported="true" kind="lib" path="lib/org.eclipse.cdt.dsf_2.2.0.201109151620.jar"/>
<classpathentry kind="lib" path="lib/hsqldb.jar"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="lib/json-simple-1.1.1.jar"/>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.7
+org.eclipse.jdt.core.compiler.source=1.8
public final static String CALLSTACK_KEY_LIBNAME = "libName";//$NON-NLS-1$
public final static String MEM_CALLSTACK_KEY_CALLER_ADDRESS = "caller address";
- public final static String MEM_CALLSTACK_KEY_FUNCTION_START_ADDRESS = "start address";
+
// application list management
public final static String UNKNOWN = "unknown";//$NON-NLS-1$
import org.tizen.dynamicanalyzer.annotation.UIMethod;
import org.tizen.dynamicanalyzer.ui.opengl.data.type.GLSelectionData;
import org.tizen.dynamicanalyzer.ui.page.BaseView;
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
import org.tizen.dynamicanalyzer.ui.summary.warning.WarningChecker;
import org.tizen.dynamicanalyzer.util.WorkbenchUtil;
import org.tizen.dynamicanalyzer.widgets.da.view.DABaseComposite;
stopAckArrived = false;
warningChecker.clear();
-
- if (Global.isGUIMode()) {
- RangeDataManager.getInstance().initRange();
- }
}
@FutureUse
public static final String CMD_PROCESS_NAME = "ps -p %d -o comm=rcu_sched";
public static final String CMD_BINARY_DETAIL_INFO = "rpm -qf";
public static final String CMD_GET_FILE_SIZE = "stat -c %s";
+ // get 'root_path' property of specified package and find all shared libraries (*.so) in it
+ public static final String CMD_GET_APPLICATION_LIBS = "find `/usr/bin/pkginfo --pkg %s"
+ + " | sed -rn \'s/^root_path : (.*)/\\1/p\'` -name *.so 2>/dev/null";
// via da_command
public static final String DACOMMAND_KILL_MANAGER = "/usr/bin/profile_command killmanager";
public void run() {
if (Toolbar.INSTANCE.setDevice(deviceName)) {
if (Toolbar.INSTANCE.setApplicationByID(appid)) {
- CommandAction.startTrace(false);
+ CommandAction.startTrace();
} else {
Logger.warning("Failed to set application to toolbar");
}
ERR_DATA_SOCKET_CLOSED(-2012, UserErrorWarningLabels.ERROR_CONNECTION_CLOSED),
ERR_DOWNLOAD_FILE_FAILED(-2013, UserErrorWarningLabels.ERROR_DOWNLOAD_FILE_FAILED),
ERR_DOWNLOAD_FILE_FAILED_DUETO_SECURITY(-2014, UserErrorWarningLabels.ERROR_DOWNLOAD_FILE_FAILED_DUETO_SECURITY),
+ ERR_CANCEL_FAILED(-2015, UserErrorWarningLabels.ERROR_CANCEL_FAILED),
ERR_MSG_START_FAIL(-2101, UserErrorWarningLabels.ERROR_START_TRACE_FAILED),
ERR_MSG_SEND_FAIL(-2102, UserErrorWarningLabels.ERR_MSG_SEND_FAIL),
public static boolean isStartable() {
return (currentState == INIT || currentState == DONE);
}
+
+ public static boolean isDone() {
+ return (currentState == DONE);
+ }
}
import org.tizen.dynamicanalyzer.project.AppInfo;
import org.tizen.dynamicanalyzer.project.ImageInfo;
import org.tizen.dynamicanalyzer.project.Project;
-import org.tizen.dynamicanalyzer.project.callstack.RuntimeCallstackManager;
import org.tizen.dynamicanalyzer.protocol.Protocol;
-import org.tizen.dynamicanalyzer.util.Logger;
// This class is for global information that can be accessed from anywhere in dynamic analyzer code.
// So this class contains only static methods and variables.
private static DeviceInfo currentDevice = null;
private static AppInfo currentApplication = null;
private static Project currentProject = null;
- private static RuntimeCallstackManager temporaryCallstackManager = new RuntimeCallstackManager();
private static boolean lsanInitSucceeded = false;
public static boolean isLSanInitialized() {
return AnalyzerConstants.UNKNOWN_LIB;
}
}
-
- public static RuntimeCallstackManager getRuntimeCallstackManager() {
- if (currentProject != null) {
- return currentProject.getRuntimeCallstackManager();
- } else {
- Logger.error("should not be happened");
- return temporaryCallstackManager;
- }
- }
}
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.ref.WeakReference;
-import java.util.ArrayList;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import org.eclipse.cdt.debug.edc.internal.symbols.dwarf.DwarfDebugInfoProviderFactory;
import org.tizen.dynamicanalyzer.project.ProcessMemoryMap;
import org.tizen.dynamicanalyzer.project.Project;
import org.tizen.dynamicanalyzer.swap.model.data.ProfileData;
-import org.tizen.dynamicanalyzer.swap.platform.BinarySettingData;
-import org.tizen.dynamicanalyzer.swap.platform.BinarySettingManager;
import org.tizen.dynamicanalyzer.util.Logger;
public class SymbolManager {
}
/**
- * getFuncName : returns function id from pc address, pid, time and set build type and binary
- * path for ProfileData
- *
- * @param input
- * : can be null. If not null, set build type and binary path for ProfileData
- * @param address
- * : pc address
- * @param pid
- * : process id
- * @param time
- * : time stamp of the function call
- * @return : function id
+ * Returns function id from pc address, pid, time and sets build type and binary
+ * path for ProfileData.
+ *
+ * @param input set build type and binary path for input ProfileData, can be null
+ * @param address pc address
+ * @param pid process id
+ * @param time time stamp of the function call
+ * @return function identifier
*/
// TODO: remove unnecessary code
public static int getFuncId(ProfileData input, long address, int pid, long time) {
ProcessMemoryMap pmap = process.getProcessMemoryMap(time);
if (pmap != null) {
- if (address >= pmap.getMainbinary().getLowestAddress()
- && address <= pmap.getMainbinary().getHighestAddress()) {
- // if address is in main executable binary of process
- String baseAddr = Long.toString(pmap.getMainbinary().getLowestAddress());
- String pcStr = Long.toString(address);
-
- BinaryInfo binInfo = project.getDeviceStatusInfo().getBinaryInfo(
- pmap.getMainbinary().getBinaryID());
+ LibraryObject libraryObject = pmap.getLibraryByAddress(address);
+
+ String baseAddr = Long.toString(libraryObject.getLowestAddress());
+ String pcStr = Long.toString(address);
+
+ BinaryInfo binInfo = project.getDeviceStatusInfo().getBinaryInfo(libraryObject.getBinaryID());
+ if (binInfo != null) {
String localPath = binInfo.getTempBinaryPath();
if (null != input) {
input.setBuildType(binInfo.getType());
}
+
boolean isPieBuild = true;
if (binInfo.getType() != 1) {
isPieBuild = false;
}
functionName = addr2func(localPath, pcStr, isPieBuild, baseAddr);
- } else {
- // if address is not in main executable binary of process
- // search address in binary of "binary setting configuration"
- List<BinarySettingData> binDataList = BinarySettingManager.getInstance()
- .getBinarySettingList();
- List<String> binPaths = new ArrayList<String>();
- for (BinarySettingData binData : binDataList) {
- binPaths.add(binData.getBinaryPath());
- }
-
- LibraryObject libraryObject = null;
- int size = binPaths.size();
- for (int i = 0; i < size; i++) {
- String binPath = binPaths.get(i);
- BinaryInfo bininfo = project.getDeviceStatusInfo().getBinaryInfo(binPath);
- LibraryObject libObj = pmap.getLibraryByBinaryID(bininfo.getID());
- if (null == libObj) {
- continue;
- }
- long lowAddr = libObj.getLowestAddress();
- long highAddr = libObj.getHighestAddress();
-
- if (address >= lowAddr && address <= highAddr) {
- libraryObject = libObj;
- break;
- }
- }
-
- // if found binary of address in "binary setting configuration"
- if (null != libraryObject) {
- int binaryID = libraryObject.getBinaryID();
- BinaryInfo binInfo = project.getDeviceStatusInfo().getBinaryInfo(binaryID);
- if (binInfo != null) {
- String localPath = binInfo.getTempBinaryPath();
- String baseAddr = Long.toString(libraryObject.getLowestAddress());
- String pcStr = Long.toString(address);
- boolean isPieBuild = true;
- if (binInfo.getType() != 1) {
- isPieBuild = false;
- }
- functionName = addr2func(localPath, pcStr, isPieBuild, baseAddr);
- }
- }
}
}
} else {
Logger.warning("unable to get real path of %s", path);
}
- } catch (InterruptedException e) {
- Logger.exception(e);
} catch (UnsupportedProtocolException e) {
Logger.exception(e);
}
return curDev.getPackageInfoMap();
}
- public static DAResult startTrace(IProgress progress) throws InterruptedException {
+ public static DAResult startTrace(IProgress progress) {
DeviceInfo curDev = Global.getCurrentDeviceInfo();
- if (curDev != null) {
- try {
- return curDev.getCommunicator().getSubCommunicator()
- .sendTraceStartMessage(progress);
- } catch (UnsupportedProtocolException e) {
- // never happened currently
- Logger.error("It is not supported to send start trace message by communicator");
- return new DAResult(ErrorCode.ERR_PROTOCOL_NOT_SUPPORTED);
- }
- } else {
+ if (curDev == null)
return new DAResult(ErrorCode.ERR_NO_DEVICE);
+
+ SubCommunicator subComm = curDev.getCommunicator().getSubCommunicator();
+
+ try {
+ // inform SWAP that all library binaries should be instrumented
+ AppInfo curApp = Global.getCurrentApplication();
+ List<String> binPaths = curApp.getProcessInformation();
+ binPaths.remove(curApp.getExecBinaryPath());
+ DAResult ret = addInstrumentation(binPaths);
+
+ return ret.isSuccess() ? subComm.sendTraceStartMessage(progress) : ret;
+ } catch (UnsupportedProtocolException e) {
+ // never happened currently
+ Logger.error("It is not supported to send start trace message by communicator");
+ return new DAResult(ErrorCode.ERR_PROTOCOL_NOT_SUPPORTED);
}
}
- public static DAResult stopTrace() throws InterruptedException {
+ public static DAResult stopTrace() {
DeviceInfo curDev = Global.getCurrentDeviceInfo();
- if (curDev != null) {
- try {
- return curDev.getCommunicator().getSubCommunicator().sendTraceStopMessage(null);
- } catch (UnsupportedProtocolException e) {
- // never happened currently
- Logger.error("It is not supported to send stop trace message by communicator");
- return new DAResult(ErrorCode.ERR_PROTOCOL_NOT_SUPPORTED);
- }
- } else {
+ if (curDev == null)
return new DAResult(ErrorCode.ERR_NO_DEVICE);
+
+ SubCommunicator subComm = curDev.getCommunicator().getSubCommunicator();
+
+ try {
+ // inform SWAP that all library binaries should not be instrumented
+ // anymore
+ AppInfo curApp = Global.getCurrentApplication();
+ List<String> binPaths = curApp.getProcessInformation();
+ binPaths.remove(curApp.getExecBinaryPath());
+ DAResult ret = removeInstrumentation(binPaths);
+
+ return ret.isSuccess() ? subComm.sendTraceStopMessage(null) : ret;
+ } catch (UnsupportedProtocolException e) {
+ Logger.error("It is not supported to send stop trace message by communicator");
+ return new DAResult(ErrorCode.ERR_PROTOCOL_NOT_SUPPORTED);
}
}
}
}
- public static DAResult addInstrumentation(List<String> paths) throws InterruptedException,
- UnsupportedProtocolException {
+ public static DAResult addInstrumentation(List<String> paths)
+ throws UnsupportedProtocolException {
DeviceInfo curDev = Global.getCurrentDeviceInfo();
if (curDev != null) {
return curDev.getCommunicator().getSubCommunicator()
}
}
- public static DAResult removeInstrumentation(List<String> paths) throws InterruptedException,
- UnsupportedProtocolException {
+ public static DAResult removeInstrumentation(List<String> paths)
+ throws UnsupportedProtocolException {
DeviceInfo curDev = Global.getCurrentDeviceInfo();
if (curDev != null) {
return curDev.getCommunicator().getSubCommunicator()
Logger.debug("daemon log file is too large or does not exist");
}
}
+
+ /**
+ * Retrieves list of shared libraries from specified package.
+ *
+ * @param packageId package ID
+ * @return list of absolute paths to application libraries
+ */
+ public static List<String> getApplicationLibs(String packageId) {
+ final List<String> libPaths = new ArrayList<>();
+ CommunicatorUtils.execShellCommand(Global.getCurrentDeviceInfo().getIDevice(),
+ String.format(AnalyzerShellCommands.CMD_GET_APPLICATION_LIBS, packageId),
+ new MultiLineReceiver() {
+ @Override
+ public void processNewLines(String[] lines) {
+ for (String line : lines)
+ libPaths.add(line);
+ }
+ });
+ return libPaths;
+ }
}
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import org.eclipse.swt.widgets.Display;
import org.tizen.dynamicanalyzer.common.DAResult;
import org.tizen.dynamicanalyzer.common.Global;
import org.tizen.dynamicanalyzer.common.path.PathManager;
import org.tizen.dynamicanalyzer.handlers.UIActionHolder;
+import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
import org.tizen.dynamicanalyzer.protocol.Protocol;
import org.tizen.dynamicanalyzer.setting.SettingDataManager;
+import org.tizen.dynamicanalyzer.ui.notification.NotificationManager;
import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
import org.tizen.dynamicanalyzer.util.Logger;
import org.tizen.sdblib.IDevice;
public class DeviceManager {
private static SmartDevelopmentBridge sdbBridge = null;
- private static List<DeviceInfo> devices = new ArrayList<DeviceInfo>();
+ private static List<DeviceInfo> devices = Collections
+ .synchronizedList(new ArrayList<DeviceInfo>());
+ private static Set<IDeviceStatusListener> listeners = new HashSet<>();
public static void init() {
if (null != PathManager.SDB_PATH) {
sdbBridge.startBridge();
sdbBridge.waitforStart();
}
+
+ /**
+ * Updates UI on any connected or disconnected device.
+ */
+ if (Global.isGUIMode())
+ listeners.add(DeviceManager::updateUIByDevice);
}
private static IDeviceChangeListener deviceChanged = new IDeviceChangeListener() {
@Override
public void onDisconnected(IDevice device) {
Logger.debug("device disconnected : " + device.getSerialNumber());
- synchronized (devices) {
- // called : each device disconnected time
- if (onDisconnectedInternal(device)) {
- updateToolbarByDevice();
- }
- }
+ if (onDisconnectedInternal(device))
+ notifyListeners(false, device);
}
@Override
public void onConnected(IDevice device) {
Logger.debug("device connected : " + device.getSerialNumber());
- synchronized (devices) {
- // It is called when dynamic-analyzer start, only once
- if (onConnectedInternal(device)) {
- updateToolbarByDevice();
- }
- }
+ if (onConnectedInternal(device))
+ notifyListeners(true, device);
}
@Override
public void onChanged(IDevice device, int changeMask) {
Logger.debug("device changed : " + device.getSerialNumber() + " : " + changeMask);
- synchronized (devices) {
- // called : device added - already dynamic-analyzer running (not tracing)
- if (changeMask == IDevice.CHANGE_STATE
- || changeMask == IDevice.CHANGE_STATE_TO_ONLINE) {
- // state changed (offline -> online or suspended -> online)
- boolean bRemoved = onDisconnectedInternal(device);
- boolean bAdded = onConnectedInternal(device);
- if (bRemoved || bAdded) {
- updateToolbarByDevice();
- }
- } else {
- // do nothing
- }
+ if (changeMask == IDevice.CHANGE_STATE
+ || changeMask == IDevice.CHANGE_STATE_TO_ONLINE) {
+ // state changed (offline -> online or suspended -> online)
+ boolean bRemoved = onDisconnectedInternal(device);
+ boolean bAdded = onConnectedInternal(device);
+ if (bRemoved)
+ notifyListeners(false, device);
+ else if (bAdded)
+ notifyListeners(true, device);
}
}
};
- // this method should be called inside synchronized(devices) block
private static boolean onDisconnectedInternal(IDevice device) {
boolean bRemoved = false;
DeviceInfo deviceInfo = getDeviceByName(device.getSerialNumber());
return bRemoved;
}
- // this method should be called inside synchronized(devices) block
private static boolean onConnectedInternal(IDevice device) {
- boolean bAdded = false;
DeviceInfo devInfo = new DeviceInfo(device);
for(DeviceInfo dinfo : devices) {
- if(dinfo.isSameDevice(devInfo))
+ if (dinfo.isSameDevice(devInfo))
return true;
}
// set availability of root
- if(SettingDataManager.INSTANCE.isPlatformDA() == true)
+ if (SettingDataManager.INSTANCE.isPlatformDA())
devInfo.setAvailabilityOfRoot(CommunicatorUtils.enableRoot(device));
-
+
// connect with swap of device
DAResult result = devInfo.getCommunicator().connect();
if (result.isSuccess()) {
String devProtocol = devInfo.getCommunicator().getProtocolVersion();
if (devProtocol != null) {
- try {
- double versionNum = Double.parseDouble(devProtocol);
-
- if (versionNum >= Protocol.VERSION_42.getVersionNum()) {
- Logger.debug("set Memps Available");
- devInfo.setMempAvailable(true);
- }
- } catch (Exception ex) {
- Logger.debug("protocol version - " + devProtocol);
+ double versionNum = Protocol.getVersion(devProtocol).getVersionNum();
+
+ if (versionNum >= Protocol.VERSION_42.getVersionNum()) {
+ Logger.debug("set Memps Available");
+ devInfo.setMempAvailable(true);
}
}
devices.add(devInfo);
- bAdded = true;
- }
- else if (result.equals(new DAResult(ErrorCode.ERR_NOT_SUPPORTED))){
- Logger.warning("Cannot found some components: " + result.getMessage());
- result.setDetailMessage(devInfo.getIDevice().getDeviceName() + ", " +
- devInfo.getIDevice().getSerialNumber());
- UIActionHolder.getUIAction().showWarning(result);
- }
- else {
- Logger.warning("Cannot connect with swap manager : " + result.getMessage());
- result.setDetailMessage(devInfo.getIDevice().getDeviceName() + ", " +
- devInfo.getIDevice().getSerialNumber());
- UIActionHolder.getUIAction().showWarning(result);
+ return true;
}
- return bAdded;
+ String errMsg = result.equals(new DAResult(ErrorCode.ERR_NOT_SUPPORTED))
+ ? "Cannot found some components: "
+ : "Cannot connect with swap manager: ";
+ Logger.warning(errMsg + result.getMessage());
+
+ result.setDetailMessage(devInfo.getIDevice().getDeviceName() + ", "
+ + devInfo.getIDevice().getSerialNumber());
+ UIActionHolder.getUIAction().showWarning(result);
+
+ return false;
}
- private static void updateToolbarByDevice() {
- // this should be asyncExec
- // think about this happened while device combo is middle of selection
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- if (!Toolbar.INSTANCE.updateDeviceCombo(null)) {
- Toolbar.INSTANCE.updateAppCombo(true);
- }
- }
+ /**
+ * Updates toolbar devices combobox and creates pop-up notifications to
+ * alert user if some device was connected or disconnected.
+ *
+ * @param connected device status, {@code true} if device was connected and
+ * {@code false} if disconnected
+ * @param device corresponding device
+ */
+ private static void updateUIByDevice(final boolean connected, final IDevice device) {
+ Display.getDefault().asyncExec(() -> {
+ if (!Toolbar.INSTANCE.updateDeviceCombo(null))
+ Toolbar.INSTANCE.updateAppCombo(true);
});
+
+ String title = connected
+ ? AnalyzerLabels.NOTIFICATION_DEVICE_CONNECTED
+ : AnalyzerLabels.NOTIFICATION_DEVICE_DISCONNECTED;
+ String message = device.getDeviceName();
+ String details = device.getSerialNumber();
+ NotificationManager.showNotification(title, message, details);
}
public static void addDeviceListener() {
}
public static void loadDevices() {
- if (null != sdbBridge) {
- synchronized (devices) {
- IDevice[] devices = sdbBridge.getDevices();
- int size = devices.length;
- for (int i = 0; i < size; i++) {
- if (isOnline(devices[i])) {
- onConnectedInternal(devices[i]);
- }
- }
- }
- } else {
- Logger.debug("sdbbridge is null!");
+ if (null == sdbBridge) {
+ Logger.warning("sdbbridge is null!");
+ return;
+ }
+
+ for (IDevice device : sdbBridge.getDevices()) {
+ if (isOnline(device))
+ onConnectedInternal(device);
}
}
*/
public static List<DeviceInfo> getDevicesOnSdb() {
List<DeviceInfo> sdbDevices = new ArrayList<DeviceInfo>();
- if (null != sdbBridge) {
- IDevice[] devices = sdbBridge.getDevices();
- int size = devices.length;
- for (int i = 0; i < size; i++) {
- if (isOnline(devices[i])) {
- sdbDevices.add(new DeviceInfo(devices[i]));
- }
- }
- } else {
- Logger.debug("sdbbridge is null!");
+ if (null == sdbBridge) {
+ Logger.warning("sdbbridge is null!");
+ return sdbDevices;
+ }
+
+ for (IDevice device : sdbBridge.getDevices()) {
+ if (isOnline(device))
+ sdbDevices.add(new DeviceInfo(device));
}
+
return sdbDevices;
}
}
public static DeviceInfo getDeviceByName(String name) {
- synchronized (devices) {
- for (DeviceInfo device : devices) {
- if (device.getIDevice().getSerialNumber().equals(name)) {
- return device;
- }
+ for (DeviceInfo device : devices) {
+ if (device.getIDevice().getSerialNumber().equals(name)) {
+ return device;
}
}
}
public static boolean onDeviceSelected(String serial) {
- boolean bret = true;
if (null == serial || serial.isEmpty()) {
Global.setCurrentDeviceInfo(null);
- } else {
- boolean bFound = false;
- synchronized (devices) {
- for (DeviceInfo device : devices) {
- if (serial.equals(device.getIDevice().getSerialNumber())) {
- Global.setCurrentDeviceInfo(device);
- bFound = true;
- break;
- }
- }
- }
+ return true;
+ }
- if (!bFound) {
- // there is no matching device
- // so, do not change current device
- bret = false;
+ for (DeviceInfo device : devices) {
+ if (serial.equals(device.getIDevice().getSerialNumber())) {
+ Global.setCurrentDeviceInfo(device);
+ return true;
}
}
- return bret;
+ return false;
}
public static void closeAll() {
- synchronized (devices) {
- for (DeviceInfo device : devices) {
- device.getCommunicator().disconnect();
- }
- }
+ for (DeviceInfo device : devices)
+ device.getCommunicator().disconnect();
+ }
+
+ /**
+ * Adds specified device status listener.
+ *
+ * @param listener {@link IDeviceStatusListener} implementation
+ */
+ public static void addDeviceStatusListener(IDeviceStatusListener listener) {
+ listeners.add(listener);
+ }
+
+ /**
+ * Removes specified device status listener.
+ *
+ * @param listener {@link IDeviceStatusListener} implementation
+ */
+ public static void removeDeviceStatusListener(IDeviceStatusListener listener) {
+ listeners.remove(listener);
+ }
+
+ /**
+ * Notifies all listeners about new {@code device} status.
+ *
+ * @param connected {@code true} if device was connected and {@code false}
+ * if device was disconnected
+ * @param device device which status was changed
+ */
+ private static void notifyListeners(boolean connected, IDevice device) {
+ for (IDeviceStatusListener listener : listeners)
+ listener.onStatusChanged(connected, device);
}
}
import org.tizen.dynamicanalyzer.project.AppInfo;
import org.tizen.dynamicanalyzer.swap.platform.BinarySettingData;
import org.tizen.dynamicanalyzer.swap.platform.BinarySettingManager;
-import org.tizen.dynamicanalyzer.ui.interactive.data.InteractiveDataManager;
-import org.tizen.dynamicanalyzer.ui.interactive.model.InteractiveInfo;
-import org.tizen.dynamicanalyzer.ui.interactive.model.InteractiveParser;
import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
import org.tizen.dynamicanalyzer.util.CommonUtil;
import org.tizen.dynamicanalyzer.util.Logger;
}
localPackagePathList.add(new String(strMsg[msgIndex].trim()));
}
- /*
- * make interactiveInfo, FunctionBodyInstrument
- */
- parseCheckpoints(strMsg, msgIndex);
-
- // remove waiting dialog close
- /*
- if (isOpenWelcomeDlg()) {
- Logger.debug("Start -AutoRun Waiting...");
- synchronized (getWaitingWelcomeDlg()) {
- try {
- getWaitingWelcomeDlg().wait();
- } catch (InterruptedException e) {
- Logger.exception(e);
- }
- }
- Logger.debug("End - AutoRun Waiting");
- }
- */
// change the pages by whether interactive data exist or not
UIActionHolder.getUIAction().setPageBySetting();
Toolbar.INSTANCE.setAllControlState(true);
}
- private void parseCheckpoints(String[] strMsg, int msg_index_interactive) {
- InteractiveDataManager.getInstance().getVariableInfoList().clear();
- List<String> interactiveInfoList = new ArrayList<String>();
- for (int i = msg_index_interactive; i < strMsg.length; i++) {
- interactiveInfoList.add(new String(strMsg[i].trim()));
- }
- if (interactiveInfoList.isEmpty() == false) {
- int msg_index = 0;
- int variableCount = Integer.parseInt(interactiveInfoList.get(msg_index++));
- String debugBinaryPath = interactiveInfoList.get(msg_index++);
- for (int i = 0; i < variableCount; i++) {
- String sourcePath = interactiveInfoList.get(msg_index++);
- String variableName = interactiveInfoList.get(msg_index++);
- int lineNum = Integer.parseInt(interactiveInfoList.get(msg_index++));
- int arrayCount = Integer.parseInt(interactiveInfoList.get(msg_index++));
- int checkLocation = Integer.parseInt(interactiveInfoList.get(msg_index++));
- InteractiveInfo interactiveInfo = InteractiveParser.getInteractiveInfo(
- debugBinaryPath, sourcePath, lineNum, variableName, arrayCount,
- checkLocation);
- if (interactiveInfo == null) {
- Logger.warning("Invalid Interactive Info : " + sourcePath + ", " + lineNum
- + ", " + variableName + ", " + arrayCount);
- continue;
- }
- InteractiveDataManager.getInstance().addVariableInfo(interactiveInfo);
- }
- }
- }
-
private void popupMessageWithAppname(final String appName, final String postfix) {
String name = appName;
if (name.length() > APPNAME_LENGTH) {
--- /dev/null
+package org.tizen.dynamicanalyzer.communicator;
+
+import org.tizen.sdblib.IDevice;
+
+/**
+ * Listener used by {@link DeviceManager}.
+ *
+ * @author d.nikiforov
+ */
+@FunctionalInterface
+public interface IDeviceStatusListener {
+ /**
+ * Called when {@code device} is connected or disconnected.
+ *
+ * @param connected whether device was connected ({@code true} if connected)
+ * @param device {@link IDevice} instance
+ */
+ public void onStatusChanged(boolean connected, IDevice device);
+}
* send messages
*******************************************************/
- public abstract DAResult sendTraceStartMessage(IProgress progress) throws InterruptedException,
- UnsupportedProtocolException;
+ public abstract DAResult sendTraceStartMessage(IProgress progress)
+ throws UnsupportedProtocolException;
- public abstract DAResult sendTraceStopMessage(IProgress progress) throws InterruptedException,
- UnsupportedProtocolException;
+ public abstract DAResult sendTraceStopMessage(IProgress progress)
+ throws UnsupportedProtocolException;
public abstract DAResult sendConfigurationMessage(IProgress progress)
- throws InterruptedException, UnsupportedProtocolException;
+ throws UnsupportedProtocolException;
public abstract DAResult sendBinaryInfoMessage(IProgress progress, List<String> paths)
- throws InterruptedException, UnsupportedProtocolException;
+ throws UnsupportedProtocolException;
- public abstract DAResult sendTargetInfoMessage(IProgress progress) throws InterruptedException,
- UnsupportedProtocolException;
+ public abstract DAResult sendTargetInfoMessage(IProgress progress)
+ throws UnsupportedProtocolException;
public abstract DAResult sendInstrumentAddMessage(IProgress progress, List<String> paths)
- throws InterruptedException, UnsupportedProtocolException;
+ throws UnsupportedProtocolException;
public abstract DAResult sendInstrumentRemoveMessage(IProgress progress, List<String> paths)
- throws InterruptedException, UnsupportedProtocolException;
+ throws UnsupportedProtocolException;
- public abstract DAResult sendProbeMapMessage(IProgress progress) throws InterruptedException,
- UnsupportedProtocolException;
+ public abstract DAResult sendProbeMapMessage(IProgress progress)
+ throws UnsupportedProtocolException;
- public abstract DAResult sendKeepAliveMessage(IProgress progress) throws InterruptedException,
- UnsupportedProtocolException;
+ public abstract DAResult sendKeepAliveMessage(IProgress progress)
+ throws UnsupportedProtocolException;
- public abstract DAResult sendScreenshotMessage(IProgress progress) throws InterruptedException,
- UnsupportedProtocolException;
+ public abstract DAResult sendScreenshotMessage(IProgress progress)
+ throws UnsupportedProtocolException;
public abstract DAResult sendProcessAddInfoMessage(IProgress progress, List<Integer> pids,
- Map<Integer, ProcessAdditionalInfo> infoMap) throws InterruptedException,
- UnsupportedProtocolException;
+ Map<Integer, ProcessAdditionalInfo> infoMap) throws UnsupportedProtocolException;
public abstract DAResult sendUIHierarchyMessage(IProgress progress, int requestOption)
- throws InterruptedException, UnsupportedProtocolException;
+ throws UnsupportedProtocolException;
public abstract DAResult sendUIScreenshotMessage(IProgress progress, long uiObjectAddress)
- throws InterruptedException, UnsupportedProtocolException;
+ throws UnsupportedProtocolException;
public abstract DAResult sendUIHierarchyCancelMessage(IProgress progress)
- throws InterruptedException, UnsupportedProtocolException;
+ throws UnsupportedProtocolException;
public abstract DAResult sendRealPathMessage(IProgress progress, String path)
- throws InterruptedException, UnsupportedProtocolException;
+ throws UnsupportedProtocolException;
}
thread.join();
thread = null;
} catch (InterruptedException e) {
- Logger.exception(e);
+ Logger.debug("Interrupted while joining previously started thread: "
+ + e.getLocalizedMessage());
+ Thread.currentThread().interrupt();
return false;
}
}
thread = null;
Logger.debug(getThreadName() + " thread joined!"); //$NON-NLS-1$
} catch (InterruptedException e) {
- Logger.exception(e);
+ Logger.debug("Interrupted while stopping working thread: "
+ + e.getLocalizedMessage());
+ Thread.currentThread().interrupt();
return false;
}
}
thread = null;
Logger.debug(getThreadName() + " thread joined!"); //$NON-NLS-1$
} catch (InterruptedException e) {
- Logger.exception(e);
+ Logger.debug("Interrupted while force-stopping working thread: "
+ + e.getLocalizedMessage());
+ Thread.currentThread().interrupt();
return false;
}
}
data = dataQueue.take(); // wait if empty
} catch (InterruptedException e) {
Logger.debug(getThreadName() + " is interrupted while taking from queue");
+ Thread.currentThread().interrupt();
}
return data;
public void setStageComplete(STAGE stage);
public boolean isCanceled();
-
- public void testCancel() throws InterruptedException;
+
+ /**
+ * Checks whether operation was canceled.
+ *
+ * @return {@code true} if operation was canceled
+ */
+ public boolean testCancel();
public void run();
}
import java.util.EnumMap;
import java.util.Map;
+import org.tizen.dynamicanalyzer.common.DAResult.ErrorCode;
+
public class ProgressTable {
public enum STAGE {
+ // @formatter:off
NONE(0),
- CHECK_DEV(3),
- CHECK_APP(3),
- CHECK_CONFIG(5),
+ CHECK_DEV(3, ErrorCode.ERR_DISCONNECTED),
+ CHECK_APP(3, ErrorCode.ERR_INVALID_APP),
+ CHECK_CONFIG(5, ErrorCode.ERR_CONFIG_FAILED),
CREATE_PROJECT(2),
ESTABLISH_DB(5),
CREATE_DBTABLE(20),
RESET_UI(3),
- CREATE_DATATHREAD(3),
- CREATE_MESSAGEPARSER(3),
- CREATE_LOGPARSER(3),
+ CREATE_DATATHREAD(3, ErrorCode.ERR_START_DATA_CHANNEL),
+ CREATE_MESSAGEPARSER(3, ErrorCode.ERR_START_MESSAGE_PARSER),
+ CREATE_LOGPARSER(3, ErrorCode.ERR_START_LOG_PARSER),
CREATE_PAGEMANAGER(10),
CREATE_CALLSTACK_INSERTER(3),
START_RESOURCE_MONITOR(2),
SEND_STARTMSG(15),
- WAIT_PROCINFO(20),
+ WAIT_PROCINFO(20, ErrorCode.ERR_NO_PROCINFO),
START_CLOCK(2),
CREATE_SCREENSHOT_TIMER(2),
CREATE_UPDATE_TIMER(2),
STOP_SCREENSHOT_TIMER(2),
STOP_UPDATE_TIMER(2),
SEND_STOPMSG(15),
- /*
- STOP_DATATHREAD(10),
- STOP_MESSAGEPARSER(8),
- STOP_LOGPARSER(8),
- STOP_PAGEMANAGER(17),
- STOP_CALLSTACK_INSERTER(5),
- */
STOP_DATATHREADS(48),
SUMMARIZE_UI(5),
FINAL(0);
+ // @formatter:on
protected int weight;
+ protected ErrorCode errCode;
private STAGE(int weight) {
this.weight = weight;
+ this.errCode = ErrorCode.ERR_UNKNOWN;
+ }
+
+ private STAGE(int weight, ErrorCode errCode) {
+ this.weight = weight;
+ this.errCode = errCode;
}
}
package org.tizen.dynamicanalyzer.control;
+import java.util.Arrays;
+import java.util.List;
+
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Display;
import org.tizen.dynamicanalyzer.swap.logparser.DataManagerRegistry;
import org.tizen.dynamicanalyzer.swap.logparser.LogParser;
import org.tizen.dynamicanalyzer.swap.logparser.MessageParser;
-import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackInserter;
import org.tizen.dynamicanalyzer.ui.info.screenshot.ScreenshotTimer;
import org.tizen.dynamicanalyzer.ui.page.MenuBar;
import org.tizen.dynamicanalyzer.ui.page.UpdateViewTimer;
}
@Override
- public void testCancel() throws InterruptedException {
- StartTraceManager.this.testCancel();
+ public boolean testCancel() {
+ return StartTraceManager.this.testCancel();
}
@Override
}
@Override
- public void testCancel() throws InterruptedException {
- StartTraceManager.this.testCancel();
+ public boolean testCancel() {
+ return StartTraceManager.this.testCancel();
}
@Override
@Override
public void run() {
- DAResult result = new DAResult(ErrorCode.SUCCESS);
-
- try {
- startThread = Thread.currentThread();
-
- if (!CommonAction.checkDeviceValidness()) {
- result = new DAResult(ErrorCode.ERR_DISCONNECTED);
- return;
- }
-
- setStageComplete(STAGE.CHECK_DEV);
-
- if (!CommonAction.checkApplicationValidness()) {
- result = new DAResult(ErrorCode.ERR_INVALID_APP);
- return;
- }
- setStageComplete(STAGE.CHECK_APP);
-
- if (!CommonAction.checkConfiguration()) {
- result = new DAResult(ErrorCode.ERR_CONFIG_FAILED);
- return;
- }
- setStageComplete(STAGE.CHECK_CONFIG);
-
- CommonAction.clear();
+ startThread = Thread.currentThread();
+ DAResult result = setup();
+
+ if (lastStage == STAGE.FINAL && result.isSuccess())
+ DAState.changeCurrentState(DAState.RUNNING);
+ else {
+ DAState.changeCurrentState(DAState.PREPARE_CANCEL);
+ if (!cleanup())
+ /**
+ * You really don't want to be here. Some threads might still be
+ * working and some not. Application state becomes inconsistent.
+ */
+ result = new DAResult(ErrorCode.ERR_CANCEL_FAILED);
+ }
- // make and initialize new project
- Project project = new Project();
- Global.setProject(project);
- project.init(initProgress);
- project.setMempsAvailable(Global.getCurrentDeviceInfo().getMempAvailable());
+ // close progress dialog
+ if (progressDlg != null) {
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ progressDlg.close();
+ }
+ });
+ }
- // reset UI
- if (UILayoutDataManager.INSTANCE.isDirty()) {
- UIActionHolder.getUIAction().setUIElementsBySetting();
- }
- UIActionHolder.getUIAction().applyStartTraceUI();
- UIActionHolder.getUIAction().applyWebProfilingUI(project.isWebApplication());
- setStageComplete(STAGE.RESET_UI);
-
- // start data receive thread
- if (!DataChannelThread.getInstance().start()) {
- // failed to start data channel thread
- result = new DAResult(ErrorCode.ERR_START_DATA_CHANNEL);
- return;
- }
- setStageComplete(STAGE.CREATE_DATATHREAD);
+ // if error occurred and it was not caused by cancel, show the error dialog
+ if (!result.isSuccess() && result.getErrorCode() != ErrorCode.ERR_BY_USER_CANCEL) {
+ UIActionHolder.getUIAction().showWarning(result);
+ }
- // start message parser thread
- if (!MessageParser.getInstance().start()) {
- // failed to start message parser
- result = new DAResult(ErrorCode.ERR_START_MESSAGE_PARSER);
- return;
- }
- setStageComplete(STAGE.CREATE_MESSAGEPARSER);
+ if (Global.isGUIMode()) {
+ // set shortcut and toolbar UI as DA state
+ ShortCutManager.getInstance().setEnabled(true);
+ Toolbar.INSTANCE.changeUIState(DAState.getCurrentState());
+ }
+ }
- // start log parser thread
- if (!LogParser.getInstance().start()) {
- // failed to start log parser
- result = new DAResult(ErrorCode.ERR_START_LOG_PARSER);
- return;
- }
- setStageComplete(STAGE.CREATE_LOGPARSER);
+ /**
+ * Executes all necessary setup routines for stages from
+ * {@link PHASE#TRACE_START}.
+ *
+ * @return {@link DAResult} object
+ */
+ private DAResult setup() {
+ for (STAGE stage : PHASE.TRACE_START.stageArray) {
+ DAResult result = setupStage(stage);
+ if (!result.isSuccess())
+ return result;
+ if (!setStageComplete(stage))
+ return new DAResult(ErrorCode.ERR_BY_USER_CANCEL);
+ }
- // start registered data manager thread and db inserters
- DataManagerRegistry.startThreads();
- setStageComplete(STAGE.CREATE_PAGEMANAGER);
+ return DAResult.SUCCESS;
+ }
- // start callstack inserter
- CallStackInserter.getInstance().start();
- setStageComplete(STAGE.CREATE_CALLSTACK_INSERTER);
+ /**
+ * Sets up specified {@link STAGE}.
+ *
+ * @param stage stage to setup
+ * @return {@link DAResult} object
+ */
+ private DAResult setupStage(STAGE stage) {
+ boolean result = true;
+ switch (stage) {
+ case CHECK_DEV:
+ result = CommonAction.checkDeviceValidness();
+ break;
+ case CHECK_APP:
+ result = CommonAction.checkApplicationValidness();
+ break;
+ case CHECK_CONFIG:
+ result = CommonAction.checkConfiguration();
+ break;
+ case RESET_UI:
+ CommonAction.clear();
+ Project project = createProject();
+ Global.setProject(project);
+ resetUI(project);
+ break;
+ case CREATE_DATATHREAD:
+ result = DataChannelThread.getInstance().start();
+ break;
+ case CREATE_MESSAGEPARSER:
+ result = MessageParser.getInstance().start();
+ break;
+ case CREATE_LOGPARSER:
+ result = LogParser.getInstance().start();
+ break;
+ case CREATE_PAGEMANAGER:
+ DataManagerRegistry.startThreads();
+ break;
+ case START_RESOURCE_MONITOR:
+ ResourceMonitor.start();
+ break;
+ case SEND_STARTMSG:
+ DAResult ret = DACommunicator.startTrace(startProgress);
+ if (!ret.isSuccess() && testCancel())
+ ret = new DAResult(ErrorCode.ERR_BY_USER_CANCEL);
+ return ret;
+ case WAIT_PROCINFO:
+ try {
+ result = waitProcInfo(PROCINFO_WAIT_TIME);
+ } catch (InterruptedException e) {
+ return new DAResult(ErrorCode.ERR_BY_USER_CANCEL);
+ }
+ break;
+ case CREATE_SCREENSHOT_TIMER:
+ FlatPreferences pref = FlatPreferences.SCREENSHOT_PERIODICALLY;
+ int value = SettingDataManager.INSTANCE.getPreferenceValue(pref);
+ if (value > 0 && SettingDataManager.INSTANCE.isFlatFeatureSelected(FlatFeature.SCREENSHOT))
+ ScreenshotTimer.start(value);
+ break;
+ default:
+ return DAResult.SUCCESS;
+ }
- // start resource monitor timer
- ResourceMonitor.start();
- setStageComplete(STAGE.START_RESOURCE_MONITOR);
+ return result ? DAResult.SUCCESS : new DAResult(stage.errCode);
+ }
- // send start message to target
- result = DACommunicator.startTrace(startProgress);
- if (!result.isSuccess()) {
- // failed to start trace (error from target)
- return;
- }
- setStageComplete(STAGE.SEND_STARTMSG);
-
- if (Global.isGUIMode()) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- MenuBar.getInstance().setMenuItemEnable(MenuBarLabels.FILE_NEW, false);
- MenuBar.getInstance().setMenuItemEnable(MenuBarLabels.FILE_LOAD, false);
- }
- });
- }
+ /**
+ * Creates new {@link Project} and initializes it.
+ */
+ private Project createProject() {
+ Project project = new Project();
+ project.init(initProgress);
+ project.setMempsAvailable(Global.getCurrentDeviceInfo().getMempAvailable());
+ return project;
+ }
- // wait until process info message is arrived (for a few seconds)
- int waittime = 0;
- while (waittime <= PROCINFO_WAIT_TIME) {
- if (AnalyzerManager.isProcessInfoArrived()) {
- break;
- }
+ /**
+ * Resets UI before tracing.
+ *
+ * @param project created {@link Project}
+ */
+ private void resetUI(Project project) {
+ if (UILayoutDataManager.INSTANCE.isDirty()) {
+ UIActionHolder.getUIAction().setUIElementsBySetting();
+ }
+ UIActionHolder.getUIAction().applyStartTraceUI();
+ UIActionHolder.getUIAction().applyWebProfilingUI(project.isWebApplication());
+ }
- Thread.sleep(AnalyzerConstants.THREAD_SLEEP_INTERVAL);
- waittime += AnalyzerConstants.THREAD_SLEEP_INTERVAL;
- testCancel();
- }
- if (waittime > PROCINFO_WAIT_TIME) {
- result = new DAResult(ErrorCode.ERR_NO_PROCINFO);
- return;
+ /**
+ * Disables 'New' and 'Load' menu items.
+ */
+ private void disableMenuItems() {
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ MenuBar.getInstance().setMenuItemEnable(MenuBarLabels.FILE_NEW, false);
+ MenuBar.getInstance().setMenuItemEnable(MenuBarLabels.FILE_LOAD, false);
}
-
- // Call Start Dlog
- //startDlog();
+ });
+ }
- setStageComplete(STAGE.WAIT_PROCINFO);
+ /**
+ * Waits for message with information about traced process and disables
+ * 'New' and 'Load' menu items if DA is in GUI mode.
+ *
+ * @param millis timeout in milliseconds
+ * @return {@code true} if information was received, {@code false} if
+ * timeout was reached
+ * @throws InterruptedException if operation was interrupted
+ */
+ private boolean waitProcInfo(int millis) throws InterruptedException {
+ if (Global.isGUIMode())
+ disableMenuItems();
+
+ int waittime = 0;
+ while (waittime <= millis && !AnalyzerManager.isProcessInfoArrived()) {
+ Thread.sleep(AnalyzerConstants.THREAD_SLEEP_INTERVAL);
+ waittime += AnalyzerConstants.THREAD_SLEEP_INTERVAL;
+ }
+ return waittime <= millis;
+ }
- // start toolbar clock
- setStageComplete(STAGE.START_CLOCK);
+ /**
+ * Clean-up routines necessary in case of failed or canceled start.
+ *
+ * @return {@code true} on success
+ */
+ private boolean cleanup() {
+ DAState.changeCurrentState(DAState.PREPARE_CANCEL);
- // start screenshot timer
- FlatPreferences feature = FlatPreferences.SCREENSHOT_PERIODICALLY;
- int value = SettingDataManager.INSTANCE.getPreferenceValue(feature);
- if (SettingDataManager.INSTANCE.getSelectedFlatFeatureSet().contains(FlatFeature.SCREENSHOT)
- && value > 0) {
- ScreenshotTimer.start(value);
- }
- setStageComplete(STAGE.CREATE_SCREENSHOT_TIMER);
-
- // start update view timer
- setStageComplete(STAGE.CREATE_UPDATE_TIMER);
-
- setStageComplete(STAGE.FINAL);
- } catch (InterruptedException e) {
- // operation is canceled
-
- // swallow exception and proceed to 'finally'
- // raised interruption flag may cause failed joins
- // and other cleanup operations
-
- // set DA state to canceling
- result = new DAResult(ErrorCode.ERR_BY_USER_CANCEL);
- } finally {
- // set DA state as result of start progress
- if (lastStage != STAGE.FINAL) {
- /*********************************************************************
- * canceled or failed to start tracing
- *********************************************************************/
-
- DAState.changeCurrentState(DAState.PREPARE_CANCEL);
-
- // unwind operations
- switch (lastStage) {
- case FINAL:
- case CREATE_UPDATE_TIMER:
- setCancelProgress(STAGE.CREATE_UPDATE_TIMER);
- case CREATE_SCREENSHOT_TIMER:
- ScreenshotTimer.stop();
- setCancelProgress(STAGE.CREATE_SCREENSHOT_TIMER);
- case START_CLOCK:
- setCancelProgress(STAGE.START_CLOCK);
- case WAIT_PROCINFO:
- case SEND_STARTMSG:
- try {
- DACommunicator.stopTrace();
- } catch (Exception e) {
- // never happened currently
- Logger.error("Interrupted during stop trace");
- }
- setCancelProgress(STAGE.SEND_STARTMSG);
- case START_RESOURCE_MONITOR:
- if (Global.isGUIMode()) {
- Toolbar.INSTANCE.stopTimer();
- }
- UpdateViewTimer.stop();
- ResourceMonitor.stop();
- setCancelProgress(STAGE.START_RESOURCE_MONITOR);
- case CREATE_CALLSTACK_INSERTER:
- CallStackInserter.getInstance().stopForced();
- setCancelProgress(STAGE.CREATE_CALLSTACK_INSERTER);
- case CREATE_PAGEMANAGER:
- DataManagerRegistry.stopThreadsForced();
- setCancelProgress(STAGE.CREATE_PAGEMANAGER);
- case CREATE_LOGPARSER:
- LogParser.getInstance().stopForced();
- setCancelProgress(STAGE.CREATE_LOGPARSER);
- case CREATE_MESSAGEPARSER:
- MessageParser.getInstance().stopForced();
- setCancelProgress(STAGE.CREATE_MESSAGEPARSER);
- case CREATE_DATATHREAD:
- DataChannelThread.getInstance().stopForced();
- setCancelProgress(STAGE.CREATE_DATATHREAD);
- case RESET_UI:
- case CREATE_DBTABLE:
- case ESTABLISH_DB:
- case CREATE_PROJECT:
- // clear including project
- CommonAction.clear();
- setCancelProgress(STAGE.CREATE_PROJECT);
- case CHECK_CONFIG:
- case CHECK_APP:
- case CHECK_DEV:
- break;
- default:
- break;
- }
+ // unwind operations
+ List<STAGE> stages = Arrays.asList(PHASE.TRACE_START.stageArray);
+ for (int i = stages.indexOf(lastStage); i >= 0; --i)
+ unwind(stages.get(i));
- DAState.changeCurrentState(DAState.INIT);
- } else {
- DAState.changeCurrentState(DAState.RUNNING);
- }
+ CommonAction.clear();
- // close progress dialog
- if (progressDlg != null) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- progressDlg.close();
- }
- });
- }
+ DAState.changeCurrentState(DAState.INIT);
- // if error occurred, show the error dialog
- if (!result.isSuccess()) {
- UIActionHolder.getUIAction().showWarning(result);
- }
+ return !Thread.interrupted();
+ }
- if (Global.isGUIMode()) {
- // set shortcut and toolbar UI as DA state
- ShortCutManager.getInstance().setEnabled(true);
- Toolbar.INSTANCE.changeUIState(DAState.getCurrentState());
- }
+ /**
+ * Unwinds specified stage of trace start process.
+ *
+ * @param stage stage to unwind
+ */
+ private void unwind(STAGE stage) {
+ switch (stage) {
+ case CREATE_SCREENSHOT_TIMER:
+ ScreenshotTimer.stop();
+ break;
+ case SEND_STARTMSG:
+ DACommunicator.stopTrace();
+ break;
+ case START_RESOURCE_MONITOR:
+ if (Global.isGUIMode())
+ Toolbar.INSTANCE.stopTimer();
+ UpdateViewTimer.stop();
+ ResourceMonitor.stop();
+ break;
+ case CREATE_PAGEMANAGER:
+ DataManagerRegistry.stopThreadsForced();
+ break;
+ case CREATE_LOGPARSER:
+ LogParser.getInstance().stopForced();
+ break;
+ case CREATE_MESSAGEPARSER:
+ MessageParser.getInstance().stopForced();
+ break;
+ case CREATE_DATATHREAD:
+ DataChannelThread.getInstance().stopForced();
+ break;
+ default:
+ break;
}
+
+ setCancelProgress(stage);
}
private void setProgressPercent(int percent) {
}
}
- private void setStageComplete(STAGE st) throws InterruptedException {
+ /**
+ * Checks on cancellation and sets specified {@link STAGE} as completed.
+ *
+ * @param st {@link STAGE} instance
+ * @return {@code true} if stage was completed or {@code false} if it was
+ * cancelled
+ */
+ private boolean setStageComplete(STAGE st) {
Logger.debug("done stage: " + st);
lastStage = st;
int percent = ProgressTable.getPercent(PHASE.TRACE_START, lastStage);
- if (percent != 100) {
- testCancel();
- }
+ if (percent != 100 && testCancel())
+ return false;
setProgressPercent(percent);
+ return true;
}
private void setCancelProgress(STAGE st) {
- int percent = ProgressTable.getPercent(PHASE.CANCEL_TRACE_START, st);
+ if (st == lastStage)
+ return;
+
+ int percent = ProgressTable.getPercent(PHASE.TRACE_START, st);
setProgressPercent(percent);
}
- private void testCancel() throws InterruptedException {
- if (startThread.isInterrupted() || AnalyzerManager.isExit()) {
- // reset interruption flag
- Thread.interrupted();
-
- throw new InterruptedException();
- }
+ /**
+ * Checks whether operation was cancelled.
+ *
+ * @return {@code true} if operation was cancelled
+ */
+ private boolean testCancel() {
+ return Thread.interrupted() || AnalyzerManager.isExit();
}
private void startDlog(){
import org.tizen.dynamicanalyzer.handlers.UIActionHolder;
import org.tizen.dynamicanalyzer.nl.MenuBarLabels;
import org.tizen.dynamicanalyzer.project.Project;
-import org.tizen.dynamicanalyzer.setting.FlatFeature;
-import org.tizen.dynamicanalyzer.setting.FlatPreferences;
-import org.tizen.dynamicanalyzer.setting.SettingDataManager;
import org.tizen.dynamicanalyzer.shortcut.ShortCutManager;
import org.tizen.dynamicanalyzer.swap.communicator.DataChannelThread;
import org.tizen.dynamicanalyzer.swap.logparser.DataManagerRegistry;
import org.tizen.dynamicanalyzer.swap.logparser.LogParser;
import org.tizen.dynamicanalyzer.swap.logparser.MessageParser;
-import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackInserter;
import org.tizen.dynamicanalyzer.ui.info.screenshot.ScreenshotTimer;
-import org.tizen.dynamicanalyzer.ui.memory.data.HeapDataManager;
import org.tizen.dynamicanalyzer.ui.page.BaseView;
import org.tizen.dynamicanalyzer.ui.page.MenuBar;
import org.tizen.dynamicanalyzer.ui.page.UpdateViewTimer;
+import org.tizen.dynamicanalyzer.ui.timeline.calltrace.CallTraceDataManager;
import org.tizen.dynamicanalyzer.ui.timeline.dlog.DLogDataManager;
import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
import org.tizen.dynamicanalyzer.util.Logger;
LogParser.getInstance().stopForced();
// stop page data manager
DataManagerRegistry.stopThreadsForced();
- // stop other db inserters
- CallStackInserter.getInstance().stopForced();
+ // add indexes to function entries
+ CallTraceDataManager.getInstance().addCallStackIndexes();
}
}
LogParser.getInstance().stopNormal();
// stop page data manager
DataManagerRegistry.stopThreadsNormal();
- // stop other db inserters
- CallStackInserter.getInstance().stopNormal();
+ // add indexes to function entries
+ CallTraceDataManager.getInstance().addCallStackIndexes();
}
}
}
} finally {
-
updateDAState();
- // we must wait for all data threads to join before updating heap tables.
- if (Global.isGUIMode()) {
- startUpdateHeapDataManager();
- }
- }
- }
-
- /**
- * Calculate allocation data in HeapDataManager.
- */
- private void startUpdateHeapDataManager() {
- if(SettingDataManager.INSTANCE.getSelectedFlatFeatureSet().contains(FlatFeature.MEMORY_ALLOC)) {
- Display.getDefault().asyncExec(new Runnable() {
-
- @Override
- public void run() {
- Logger.info("Calculating allocation data in HeapDataManager");
- if (SettingDataManager.INSTANCE
- .isPreferenceSelected(FlatPreferences.LEAK_SANITIZER))
- HeapDataManager.getInstance().makeWholePersistentAllocsData(true);
-
- if (MenuBar.getInstance().getPersistentAllocationsSelection())
- HeapDataManager.getInstance().makeWholePersistentAllocsData(false);
-
- HeapDataManager.getInstance().makeStatisticsData(0, 0);
-
- BaseView baseView = (BaseView) WorkbenchUtil.getViewPart(BaseView.ID);
- baseView.getTopComposite().updateView();
- }
- });
}
}
private String option;
private String type;
private int string_size;
- private boolean isIndex;
public DBColumn(String name, String option, String type) {
this.name = name;
this.option = option;
this.type = type;
this.string_size = 0;
- this.isIndex = false;
}
public DBColumn(String name, String option, String type, int size) {
this.option = option;
this.type = type;
this.string_size = size;
- this.isIndex = false;
}
public String getName() {
return string_size;
}
- public boolean isIndex() {
- return isIndex;
- }
-
- public void setIndex(boolean isIndex) {
- this.isIndex = isIndex;
- }
-
public String getColumnString() {
if (DBConstants.DBTYPE_VARCHAR.equals(type) || DBConstants.DBTYPE_VARBINARY.equals(type)) {
return name + CommonConstants.SPACE + type + "(" + string_size + ")" + CommonConstants.SPACE + option;
public static final String DBTYPE_VARBINARY = "VARBINARY";//$NON-NLS-1$
// shared column name
+ public static final String DBCOLUMN_IS_ENTRY = "IS_ENTRY";//$NON-NLS-1$
public static final String DBCOLUMN_RID = "RID";//$NON-NLS-1$
public static final String DBCOLUMN_SEQUENCE_NUMBER = "SEQUENCE_NUMBER";//$NON-NLS-1$
public static final String DBCOLUMN_START_TIME = "START_TIME";//$NON-NLS-1$
public static final String DBCOLUMN_RETURN_VALUE = "RETURN_VALUE";//$NON-NLS-1$
public static final String DBCOLUMN_ERROR_NUMBER = "ERROR_NUMBER";//$NON-NLS-1$
public static final String DBCOLUMN_CALLER_PC_ADDRESS = "CALLER_PC_ADDRESS";//$NON-NLS-1$
+ public static final String DBCOLUMN_START_PC_ADDRESS = "START_PC_ADDRESS";//$NON-NLS-1$
public static final String DBCOLUMN_CALLER_LIBRARY_NAME = "CALLER_LIBRARY_NAME";//$NON-NLS-1$
public static final String DBCOLUMN_FD = "FD";//$NON-NLS-1$
public static final String DBCOLUMN_API_ID = "API_ID";//$NON-NLS-1$
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
+import java.util.StringJoiner;
+import java.util.stream.Collectors;
import org.tizen.dynamicanalyzer.constant.CommonConstants;
import org.tizen.dynamicanalyzer.util.Logger;
*/
protected static final String SELECT_ALL_QUERY = "select * from %s";
- private List<DBColumn> columns = new ArrayList<DBColumn>();
+ protected static final String SELECT = " select ";
+ protected static final String FROM = " from ";
+ public static final String UPDATE = " update ";
+ public static final String WHERE = " where ";
+ public static final String AND = " and ";
+ public static final String OR = " or ";
+ public static final String ORDER_BY = " order by ";
+ public static final String DESC = " DESC ";
+
+ private List<DBColumn> columns = new ArrayList<>();
+ private List<Integer> primaryKey = null;
+ private List<List<Integer>> indexes = new ArrayList<>();
+
protected DBInserter dbInserter = null;
// instance initializing block
dbInserter = inserter;
}
- protected final void addColumn(DBColumn col) {
- columns.add(col);
+ /**
+ * Set specified columns set as compound primary key.
+ *
+ * @param primaryKey set of columns indexes
+ */
+ public final void setPrimaryKey(Integer... primaryKey) {
+ this.primaryKey = Arrays.asList(primaryKey);
+ }
+
+ /**
+ * Add set of columns as index columns.
+ *
+ * @param index set of columns indexes
+ */
+ public final void addIndex(Integer... indexes) {
+ this.indexes.add(Arrays.asList(indexes));
}
- protected final void setIndexColumn(int index) {
- columns.get(index).setIndex(true);
+ protected final void addColumn(DBColumn col) {
+ columns.add(col);
}
protected final String clipString(String colstr, int str_len, String key) {
}
public final boolean createTable() {
- StringBuffer query = new StringBuffer();
- query.append("create table ");
- query.append(getTableName());
- query.append(CommonConstants.SPACE + CommonConstants.OPEN_BRACKET);
-
- int size = columns.size();
- for (int i = 0; i < size; i++) {
- query.append(columns.get(i).getColumnString());
- if (i == size - 1) {
- query.append(CommonConstants.CLOSE_BRACKET);
- } else {
- query.append(CommonConstants.COMMA);
- }
- }
- query.append(CommonConstants.SEMICOLON);
+ StringJoiner tableDesc = new StringJoiner(", ");
+
+ columns.forEach((column) -> {
+ tableDesc.add(column.getColumnString());
+ });
+
+ if (primaryKey != null && !primaryKey.isEmpty())
+ tableDesc.add(String.format("primary key (%s)", getColumnListString(primaryKey)));
- String queryString = query.toString();
- return SqlConnectionManager.executeUpdate(queryString);
+ String query = String.format("create table %s (%s);", getTableName(), tableDesc.toString());
+ return SqlConnectionManager.executeUpdate(query);
}
public final void insertData(List<List<Object>> data) {
// do nothing by default
}
- public final boolean createIndexTable() {
- int size = columns.size();
- StringBuffer indexColumns = new StringBuffer();
+ /**
+ * Get string representation of columns names separated by comma.
+ *
+ * @param index set of columns indexes
+ */
+ private String getColumnListString(List<Integer> index) {
+ return index.stream().map((colIdx) -> columns.get(colIdx).getName())
+ .collect(Collectors.joining(", "));
+ }
- for (int i = 0; i < size; i++) {
- if (columns.get(i).isIndex()) {
- if (indexColumns.length() > 0) {
- indexColumns.append(", ");
- }
- indexColumns.append(columns.get(i).getName());
+ /**
+ * Create indexes for table.
+ *
+ * @return <code>true</code> if all indexes created successfully, <code>false</code> otherwise.
+ */
+ public final boolean createIndexes() {
+ String createQueryFormat = "create index %s_index_%s on %s (%s)";
+ boolean ret = true;
+
+ for (List<Integer> index : indexes) {
+ String columnsString = getColumnListString(index);
+ String indexId = index.stream().map(Object::toString).collect(Collectors.joining());
+ String query = String.format(createQueryFormat,
+ getTableName(), indexId, getTableName(), columnsString);
+
+ if (!SqlConnectionManager.executeUpdate(query)) {
+ Logger.warning("Failed to create index [%s]", query);
+ ret = false;
}
}
- if (indexColumns.length() > 0) {
- String queryString = "create index " + getTableName() + "_index on "//$NON-NLS-1$//$NON-NLS-2$
- + getTableName() + CommonConstants.OPEN_BRACKET + indexColumns.toString()
- + CommonConstants.CLOSE_BRACKET;
-
- return SqlConnectionManager.executeUpdate(queryString);
- } else {
- return true;
- }
+ return ret;
}
/**
for (Map.Entry<String, DBTable> entry : tables.entrySet()) {
DBTable table = entry.getValue();
table.createTable();
- table.createIndexTable();
+ table.createIndexes();
}
} else {
for (Map.Entry<String, DBTable> entry : tables.entrySet()) {
if (tableNames.contains(tableName)) {
DBTable table = entry.getValue();
table.createTable();
- table.createIndexTable();
+ table.createIndexes();
}
}
}
try {
updateConnectionLock.wait();
} catch (InterruptedException e) {
- Logger.exception(e);
+ Logger.debug("Interrupted while closing update connection: "
+ + e.getLocalizedMessage());
+ Thread.currentThread().interrupt();
}
}
}
try {
queryConnectionLock.wait();
} catch (InterruptedException e) {
- Logger.exception(e);
+ Logger.debug("Interrupted while closing query connection: "
+ + e.getLocalizedMessage());
+ Thread.currentThread().interrupt();
}
}
}
}
}
- private static Connection getUpdateConnection() {
+ public static Connection getUpdateConnection() {
Connection retConn = null;
if (state == State.CONNECTED) {
try {
retConn = updateConnections.take();
} catch (InterruptedException e) {
- Logger.exception(e);
+ Logger.debug(
+ "Interrupted while getting update connection: " + e.getLocalizedMessage());
+ Thread.currentThread().interrupt();
}
}
return retConn;
}
- private static void putUpdateConnection(Connection conn) {
+ public static void putUpdateConnection(Connection conn) {
if (conn != null) {
synchronized (updateConnectionLock) {
updateConnections.offer(conn);
try {
retConn = queryConnections.take();
} catch (InterruptedException e) {
- Logger.exception(e);
+ Logger.debug(
+ "Interrupted while getting query connection: " + e.getLocalizedMessage());
+ Thread.currentThread().interrupt();
}
}
DBTableRegistry.registerEnabled(false);
DBTable lifecycleTable = (DBTable) new LifeCycleDBTable();
DBTableRegistry.registerEnabled(true);
- if (!lifecycleTable.createTable() || !lifecycleTable.createIndexTable()) {
+ if (!lifecycleTable.createTable() || !lifecycleTable.createIndexes()) {
return false;
}
} else {
import org.tizen.dynamicanalyzer.database.DBTableRegistry;
import org.tizen.dynamicanalyzer.ui.info.appStartup.AppStartupDBTable;
import org.tizen.dynamicanalyzer.ui.info.appStartup.WebAppStartupDBTable;
-import org.tizen.dynamicanalyzer.ui.interactive.data.InteractiveValueDBTable;
-import org.tizen.dynamicanalyzer.ui.interactive.data.InteractiveVariableDBTable;
import org.tizen.dynamicanalyzer.ui.opengl.data.DB.GLBufferSizeDBTableManager;
import org.tizen.dynamicanalyzer.ui.summary.profiling.WebProfilingDataDBTable;
import org.tizen.dynamicanalyzer.ui.timeline.calltrace.WebFunctionEntryDBTable;
DBTableRegistry.registerEnabled(false);
DBTable appStartup = (DBTable) new AppStartupDBTable();
DBTable glBufferSize = (DBTable) new GLBufferSizeDBTableManager();
- DBTable interValue = (DBTable) new InteractiveValueDBTable();
- DBTable interVariable = (DBTable) new InteractiveVariableDBTable();
DBTable webStartup = (DBTable) new WebAppStartupDBTable();
DBTable webFuncEntry = (DBTable) new WebFunctionEntryDBTable();
DBTable webFuncExit = (DBTable) new WebFunctionExitDBTable();
DBTableRegistry.registerEnabled(true);
if (!tables.contains(appStartup.getTableName())) {
- if (!appStartup.createTable() || !appStartup.createIndexTable()) {
+ if (!appStartup.createTable() || !appStartup.createIndexes()) {
return false;
}
}
if (!tables.contains(glBufferSize.getTableName())) {
- if (!glBufferSize.createTable() || !glBufferSize.createIndexTable()) {
- return false;
- }
- }
-
- if (!tables.contains(interValue.getTableName())) {
- if (!interValue.createTable() || !interValue.createIndexTable()) {
- return false;
- }
- }
-
- if (!tables.contains(interVariable.getTableName())) {
- if (!interVariable.createTable() || !interVariable.createIndexTable()) {
+ if (!glBufferSize.createTable() || !glBufferSize.createIndexes()) {
return false;
}
}
if (!tables.contains(webStartup.getTableName())) {
- if (!webStartup.createTable() || !webStartup.createIndexTable()) {
+ if (!webStartup.createTable() || !webStartup.createIndexes()) {
return false;
}
}
if (!tables.contains(webFuncEntry.getTableName())) {
- if (!webFuncEntry.createTable() || !webFuncEntry.createIndexTable()) {
+ if (!webFuncEntry.createTable() || !webFuncEntry.createIndexes()) {
return false;
}
}
if (!tables.contains(webFuncExit.getTableName())) {
- if (!webFuncExit.createTable() || !webFuncExit.createIndexTable()) {
+ if (!webFuncExit.createTable() || !webFuncExit.createIndexes()) {
return false;
}
}
if (!tables.contains(webProfiling.getTableName())) {
- if (!webProfiling.createTable() || !webProfiling.createIndexTable()) {
+ if (!webProfiling.createTable() || !webProfiling.createIndexes()) {
return false;
}
}
import org.tizen.dynamicanalyzer.setting.TargetData;
import org.tizen.dynamicanalyzer.swap.logparser.DataManagerRegistry;
import org.tizen.dynamicanalyzer.ui.info.appStartup.AppStartupDataManager;
-import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackInserter;
import org.tizen.dynamicanalyzer.ui.page.PageInfoRegistry;
-import org.tizen.dynamicanalyzer.util.Logger;
public class CLIAction implements UIAction {
// Register a manager to collect startup data
DataManagerRegistry.registerPageDataManager(AppStartupDataManager.getInstance());
-
- // In case of GUI CallStackInserter is created in CallstackView class.
- // TODO Generalize this step for GUI and CLI
- CallStackInserter inserter = CallStackInserter.getInstance();
- if (inserter == null) {
- Logger.warning("Could not create CallStackInserter");
- }
}
@Override
package org.tizen.dynamicanalyzer.handlers;
import java.io.File;
+import java.io.IOException;
import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
import org.tizen.dynamicanalyzer.common.DAResult;
import org.tizen.dynamicanalyzer.project.Project;
import org.tizen.dynamicanalyzer.shortcut.ShortCutManager;
import org.tizen.dynamicanalyzer.swap.logparser.DataManagerRegistry;
-import org.tizen.dynamicanalyzer.ui.interactive.data.InteractiveDataManager;
import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
import org.tizen.dynamicanalyzer.util.Logger;
import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
return success;
}
+ /**
+ * Save collected trace of the current {@link Project} to the specified zip
+ * archive.
+ *
+ * @param saveFileName path to zip archive, where trace should be saved.
+ * @return {@code true} if trace saved correctly and {@code false}
+ * otherwise.
+ */
public static boolean saveToZip(String saveFileName) {
Project project = Global.getProject();
String sourcePath = project.getSavePath();
return false;
}
+ boolean res = true;
try {
- ZipUtils.zip(sourcePath, saveFileName);
+ res = ZipUtils.zip(sourcePath, saveFileName);
}
- catch(Exception ex) {
+ catch (IOException ex) {
return false;
}
SqlConnectionManager.establishConnection(sourcePath + File.separator
+ AnalyzerConstants.DATABASE_NAME);
- return true;
+ return res;
}
public static String loadFromZip(String zipfile) {
return output;
}
- public static void startTrace(boolean bFromIDE) {
+ public static void startTrace() {
// only when trace is not running, trace can be started
boolean stateChange = DAState.changeCurrentState(DAState.PREPARE_START);
if (!stateChange) {
// change UI state
if (Global.isGUIMode()) {
- updateUiOnStartTrace(bFromIDE);
+ updateUiOnStartTrace();
}
// make thread to prepare start
thread.start();
}
- private static void updateUiOnStartTrace(boolean bFromIDE) {
+ private static void updateUiOnStartTrace() {
Toolbar.INSTANCE.resetProcessCombo();
Toolbar.INSTANCE.changeUIState(DAState.PREPARE_START);
ShortCutManager.getInstance().setEnabled(false);
- if (bFromIDE == false) {
- InteractiveDataManager.getInstance().clear();
- } else {
- // When DA is profiled from IDE, Do nothing.
- }
}
// stop trace with result
import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener;
import org.tizen.dynamicanalyzer.widgets.da.base.DADialog;
-import org.tizen.dynamicanalyzer.widgets.da.view.DATabComposite;
public class GUIAction implements UIAction {
public static final int DEFAULT_WARNING_WIDTH = 446;
@Override
public void run() {
// change startup table in timeline page
- DATabComposite timelineTabComp = (DATabComposite) AnalyzerUtil.getView(
- TimelinePage.pageID, TimelineTableView.tabID);
- AppStartupView appStartup = (AppStartupView) timelineTabComp
- .getView(TimelineTableView.appStartupViewID);
+ AppStartupView appStartup = (AppStartupView) AnalyzerUtil
+ .getView(TimelinePage.pageID, TimelineTableView.appStartupViewID);
appStartup.changeTable(isWeb);
// change call trace table in timeline page
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.swt.widgets.Display;
import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
-import org.tizen.dynamicanalyzer.common.AnalyzerManager;
import org.tizen.dynamicanalyzer.common.Global;
-import org.tizen.dynamicanalyzer.communicator.DeviceManager;
import org.tizen.dynamicanalyzer.database.SqlConnectionManager;
import org.tizen.dynamicanalyzer.database.compatible.DBConverter;
import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
import org.tizen.dynamicanalyzer.project.Project;
import org.tizen.dynamicanalyzer.setting.UILayoutDataManager;
import org.tizen.dynamicanalyzer.swap.logparser.DataManagerRegistry;
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
-import org.tizen.dynamicanalyzer.ui.range.RangePage;
import org.tizen.dynamicanalyzer.ui.summary.profiling.FunctionUsageProfiler;
import org.tizen.dynamicanalyzer.ui.summary.profiling.ProfileDataMaker;
import org.tizen.dynamicanalyzer.ui.summary.profiling.ProfilingChildData;
import org.tizen.dynamicanalyzer.ui.summary.profiling.WebProfileDataMaker;
import org.tizen.dynamicanalyzer.ui.summary.profiling.WebProfilingData;
import org.tizen.dynamicanalyzer.ui.summary.profiling.WebProfilingDataDBTable;
-import org.tizen.dynamicanalyzer.ui.timeline.TimelinePage;
-import org.tizen.dynamicanalyzer.ui.toolbar.DAToolBarCustomCombo;
import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
import org.tizen.dynamicanalyzer.ui.toolbar.opentrace.OpenTraceProgressManager;
-import org.tizen.dynamicanalyzer.ui.userinterface.UIDataManager;
import org.tizen.dynamicanalyzer.util.Logger;
-import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
-import org.tizen.dynamicanalyzer.widgets.combo.DACustomCombo;
-import org.tizen.dynamicanalyzer.widgets.da.view.DAContainerComposite;
public class OpenTraceHandler extends AbstractHandler {
public static final String ID = OpenTraceHandler.class.getName();
// change tab list and page to be shown and chart list in timeline page
UIActionHolder.getUIAction().setUIElements(project);
- // change page
- if (RangeDataManager.getInstance().isBeingAnalyzed()) {
- DAContainerComposite page = AnalyzerManager.getCurrentPage();
- if (page instanceof RangePage) {
- AnalyzerUtil.changePage(TimelinePage.pageID);
- }
- }
-
// set dirty of UI layout
UILayoutDataManager.INSTANCE.setDirty(true);
}
profiler.getProfilingDataMap().put(profilingDataID, fupData);
- UIDataManager.getInstance().getfunctionProfilingDataChecker()
- .addProfilingData(fupData);
// restore total sample count
profiler.setTotalSampleCount(profiler.getTotalSampleCount()
+ fupData.getExCount());
private static final int TOOLTIP_OFFSET = 5;
private static final Cursor sourceCursor = new Cursor(null,
ImageResources.VIEW_SOURCE_CURSOR.getImageData(), 0, 0);
+ private static final SourceLine errorNoSourceLineData = new SourceLine();
+ static {
+ errorNoSourceLineData.setError(AnalyzerConstants.SOURCELINE_NO_SOURCELINE_DATA);
+ }
private static Cursor defaultCursor = null;
public TableTooltipListener(Grid table) {
break;
case AnalyzerConstants.TYPE_TABLE_MEM_CALLSTACK:
addr = (Long) item
- .getData(AnalyzerConstants.MEM_CALLSTACK_KEY_FUNCTION_START_ADDRESS);
+ .getData(AnalyzerConstants.CALLSTACK_KEY_ADDR);
pid = (Integer) item.getData(AnalyzerConstants.CALLSTACK_KEY_PID);
time = (Long) item.getData(AnalyzerConstants.CALLSTACK_KEY_TIME);
break;
private SourceLine getSourceLine(long addr, int pid, long time) {
Project project = Global.getProject();
ProcessInformation process = project.getProcessInformation(pid);
+ if (process == null) {
+ return errorNoSourceLineData;
+ }
ProcessMemoryMap pmap = process.getProcessMemoryMap(time);
LibraryObject libobj = null;
if (pmap == null || (libobj = pmap.getLibraryByAddress(addr)) == null) {
- SourceLine sl = new SourceLine();
- sl.setError(AnalyzerConstants.SOURCELINE_NO_SOURCELINE_DATA);
- return sl;
+ return errorNoSourceLineData;
}
BinaryInfo binInfo = project.getDeviceStatusInfo().getBinaryInfo(libobj.getBinaryID());
public static String HOWTO_LINK;
public static String BUGREPORT_LINK;
+ // popup notifications
+ public static String NOTIFICATION_DEVICE_CONNECTED;
+ public static String NOTIFICATION_DEVICE_DISCONNECTED;
+
+ // table view ID's
+ public static String LEFT_TABLE_VIEW_ID;
+ public static String RIGHT_TABLE_VIEW_ID;
+
+ public static String TABLE_PROCESSING_DATA;
+
+ // charts popup menu items
+ public static String SELECT_RANGE;
+
static {
NLS.initializeMessages(BUNDLE_NAME, AnalyzerLabels.class);
}
TIZEN_DEVELOP_SITE_LINK=http://developer.tizen.org
RELEASE_NOTE_LINK=https://developer.tizen.org/development/tizen-studio/download/release-notes
HOWTO_LINK=https://developer.tizen.org/development/tizen-studio/native-tools/debugging-your-app/dynamic-analyzer
-BUGREPORT_LINK=https://developer.tizen.org/forums/sdk-ide/active
\ No newline at end of file
+BUGREPORT_LINK=https://developer.tizen.org/forums/sdk-ide/active
+
+NOTIFICATION_DEVICE_CONNECTED=Connected
+NOTIFICATION_DEVICE_DISCONNECTED=Disconnected
+
+LEFT_TABLE_VIEW_ID=Left table view
+RIGHT_TABLE_VIEW_ID=Right table view
+
+TABLE_PROCESSING_DATA=Processing...
+
+SELECT_RANGE=Select range
public static String TARGET_NAME_TV;
public static String TARGET_NAME_WEARABLE;
+ public static String TARGET_CONNECTED;
+ public static String TARGET_DISCONNECTED;
+
public static String TARGET_NAME_FLAT_MOBILE_FOCUS;
public static String TARGET_NAME_FLAT_TV_FOCUS;
public static String TARGET_NAME_FLAT_WEARABLE_FOCUS;
TARGET_NAME_TV=TV
TARGET_NAME_WEARABLE=Wearable
+TARGET_CONNECTED=Connected
+TARGET_DISCONNECTED=Not Connected
+
TARGET_NAME_FLAT_MOBILE_FOCUS=mobile
TARGET_NAME_FLAT_TV_FOCUS=tv
TARGET_NAME_FLAT_WEARABLE_FOCUS=wearable
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jungwook Ryu <jungwook.ryu@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.nl;
-
-import org.eclipse.osgi.util.NLS;
-
-public class InteractivePageLabels extends NLS {
- private static final String BUNDLE_NAME = "org.tizen.dynamicanalyzer.nl.InteractivePageLabels"; //$NON-NLS-1$
-
- public static String INTERACTIVE_CHART;
- public static String INTERACTIVE_CHART_VALUE;
- public static String INTERACTIVE_CHART_INVALID_CHECK_LOCATION;
- public static String CHART_TITLE;
-
- public static String INTERACTIVE_TABLE_VIEW_TITLE;
- public static String INTERACTIVE_TABLE_TIME;
- public static String INTERACTIVE_TABLE_TYPE;
- public static String INTERACTIVE_TABLE_VALUE;
-
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, InteractivePageLabels.class);
- }
-
- private InteractivePageLabels() {
- }
-}
+++ /dev/null
-INTERACTIVE_CHART=Interactive
-INTERACTIVE_CHART_VALUE=Value
-INTERACTIVE_CHART_INVALID_CHECK_LOCATION=Cannot get the variable value. See Tizen documentation for help.
-CHART_TITLE=Variable
-
-INTERACTIVE_TABLE_VIEW_TITLE=Interactive Profiling
-INTERACTIVE_TABLE_TIME=Time / name
-INTERACTIVE_TABLE_TYPE=Type
-INTERACTIVE_TABLE_VALUE=Value
\ No newline at end of file
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jaewon Lim <jaewon81.lim@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.nl;
-
-import org.eclipse.osgi.util.NLS;
-
-public class KernelPageLabels extends NLS {
- private static final String BUNDLE_NAME = "org.tizen.dynamicanalyzer.nl.KernelPageLabels";
-
- public static String CONTEXT_SWITCH_CHART_TITLE;
- public static String CONTEXT_SWITCH_BOARD_NAME_PID;
- public static String CONTEXT_SWITCH_BOARD_NAME_TID;
- public static String CONTEXT_SWITCH_BOARD_NAME_FUNC_CHILD;
- public static String CONTEXT_SWITCH_SERIES_NAME;
- public static String CONTEXT_SWITCH_SERIES_NAME_CHILD;
- public static String CONTEXT_SWITCH_SERIES_ITEM_NAME;
-
- public static String CALL_FLOW_CHART_TITLE;
- public static String CALL_FLOW_BOARD_NAME_TID;
-
- public static String UNKNOWN_FUNCTION_NAME;
- public static String CORE_NAME_PREFIX;
- public static String CORE_NAME_POSTFIX;
- public static String THREAD_NAME_PREFIX;
- public static String THREAD_NAME_POSTFIX;
- public static String FUNCTION_NAME_POSTFIX;
-
- public static String KERNEL_CHART_ITEM_START;
- public static String KERNEL_CHART_ITEM_END;
- public static String KERNEL_CHART_ITEM_SWITCHED;
-
- public static String KERNEL_LIST_VIEW_NAME;
- public static String KERNEL_LIST_VIEW_TITLE_CORE;
- public static String KERNEL_LIST_VIEW_TITLE_FUNCTION;
- public static String KERNEL_LIST_VIEW_INDEX;
- public static String KERNEL_LIST_VIEW_PID;
- public static String KERNEL_LIST_VIEW_TID;
- public static String KERNEL_LIST_VIEW_START_TIME;
- public static String KERNEL_LIST_VIEW_END_TIME;
- public static String KERNEL_LIST_VIEW_EXECUTION_TIME;
- public static String KERNEL_LIST_VIEW_START_PC;
- public static String KERNEL_LIST_VIEW_END_PC;
- public static String KERNEL_LIST_VIEW_ENTRY;
- public static String KERNEL_LIST_VIEW_EXIT;
- public static String KERNEL_LIST_VIEW_CORE;
- public static String KERNEL_LIST_VIEW_FUNCTION;
-
- public static String KERNEL_STATISTIC_TITLE;
- public static String KERNEL_STATISTIC_CS_COUNT;
- public static String KERNEL_STATISTIC_CS_AVGTIME;
- public static String KERNEL_STATISTIC_CS_OVERHEAD;
- public static String KERNEL_STATISTIC_KERNEL_MODE_TIME;
- public static String KERNEL_STATISTIC_CORE_AVGLOAD;
- public static String KERNEL_STATISTIC_THREAD_STARVING_AVGTIME;
- public static String KERNEL_STATISTIC_THREAD_STARVING_MAXTIME;
- public static String KERNEL_STATISTIC_THREAD_CORE_COUNT;
- public static String KERNEL_STATISTIC_THREAD_PARALLELISM_LEVEL;
- public static String KERNEL_STATISTIC_LONGEST_FUNCTION_TIME;
- public static String KERNEL_STATISTIC_LONGEST_FUNCTION_NAME;
-
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, KernelPageLabels.class);
- }
-
- private KernelPageLabels() {
- }
-}
+++ /dev/null
-CONTEXT_SWITCH_CHART_TITLE=Context Switch
-CONTEXT_SWITCH_BOARD_NAME_PID=PID :
-CONTEXT_SWITCH_BOARD_NAME_TID=TID :
-CONTEXT_SWITCH_BOARD_NAME_FUNC_CHILD=Functions
-CONTEXT_SWITCH_SERIES_NAME=core number
-CONTEXT_SWITCH_SERIES_NAME_CHILD=function name
-CONTEXT_SWITCH_SERIES_ITEM_NAME=Core
-
-CALL_FLOW_CHART_TITLE=Call Flow
-CALL_FLOW_BOARD_NAME_TID=TID :
-
-UNKNOWN_FUNCTION_NAME=unknown
-CORE_NAME_PREFIX=core<
-CORE_NAME_POSTFIX=>
-THREAD_NAME_PREFIX=thread<
-THREAD_NAME_POSTFIX=>
-FUNCTION_NAME_POSTFIX=()
-
-KERNEL_CHART_ITEM_START=Start
-KERNEL_CHART_ITEM_END=End
-KERNEL_CHART_ITEM_SWITCHED=Switched
-
-KERNEL_LIST_VIEW_NAME=Contexts
-KERNEL_LIST_VIEW_TITLE_CORE=Context List for Thread
-KERNEL_LIST_VIEW_TITLE_FUNCTION=Function Fragment List for Thread
-KERNEL_LIST_VIEW_INDEX=#
-KERNEL_LIST_VIEW_PID=PID
-KERNEL_LIST_VIEW_TID=TID
-KERNEL_LIST_VIEW_START_TIME=Start time
-KERNEL_LIST_VIEW_END_TIME=End time
-KERNEL_LIST_VIEW_EXECUTION_TIME=Execution time
-KERNEL_LIST_VIEW_START_PC=Start PC address
-KERNEL_LIST_VIEW_END_PC=End PC address
-KERNEL_LIST_VIEW_ENTRY=Function entry
-KERNEL_LIST_VIEW_EXIT=Function exit
-KERNEL_LIST_VIEW_CORE=CPU Core
-KERNEL_LIST_VIEW_FUNCTION=Function name
-
-KERNEL_STATISTIC_TITLE=Kernel Statistics
-KERNEL_STATISTIC_CS_COUNT=Number of context switch :
-KERNEL_STATISTIC_CS_AVGTIME=Average execution time of contexts :
-KERNEL_STATISTIC_CS_OVERHEAD=Overhead time of context switch :
-KERNEL_STATISTIC_KERNEL_MODE_TIME=Average kernel mode time :
-KERNEL_STATISTIC_CORE_AVGLOAD=Average core load
-KERNEL_STATISTIC_THREAD_STARVING_AVGTIME=Average thread starving time :
-KERNEL_STATISTIC_THREAD_STARVING_MAXTIME=Max thread starving time :
-KERNEL_STATISTIC_THREAD_CORE_COUNT=Core count for thread per second :
-KERNEL_STATISTIC_THREAD_PARALLELISM_LEVEL=Average count of busy thread :
-KERNEL_STATISTIC_LONGEST_FUNCTION_TIME=Longest function execution time :
-KERNEL_STATISTIC_LONGEST_FUNCTION_NAME=Longest function name :
public static String TIMELINE_TICK_ADD;
public static String EDIT_CHART_DLG_TITLE;
-
- public static String RANGE_CONTEXT_TITLE;
- public static String RANGE_CONTEXT_SET_START;
- public static String RANGE_CONTEXT_SET_END;
- public static String RANGE_CONTEXT_SET_FROM_SELECTION;
- public static String RANGE_CONTEXT_ANALYSIS;
- public static String RANGE_CONTEXT_CLEAR;
+
public static String RANGE_CONTEXT_EVENT_LIST;
-
+
public static String UIEVENT_ORIENTATION;
public static String UIEVENT_ORIENTATION_NONE;
public static String UIEVENT_ORIENTATION_PORTRAIT;
EDIT_CHART_DLG_TITLE=Chart configuration
-RANGE_CONTEXT_TITLE=Range setting
-RANGE_CONTEXT_SET_START=Set the range start
-RANGE_CONTEXT_SET_END=Set the range end
-RANGE_CONTEXT_SET_FROM_SELECTION=Set the selection as a range
-RANGE_CONTEXT_ANALYSIS=Analyze the range
-RANGE_CONTEXT_CLEAR=Clear the range
RANGE_CONTEXT_EVENT_LIST=Event list
UIEVENT_ORIENTATION=Orientation
public static String ERROR_CONNECTION_CLOSED;
public static String ERROR_DOWNLOAD_FILE_FAILED;
public static String ERROR_DOWNLOAD_FILE_FAILED_DUETO_SECURITY;
+ public static String ERROR_CANCEL_FAILED;
public static String ERROR_FAILED_OPERATION;
public static String ERROR_INTERNAL_REASON;
public static String ERR_NO_PROCINFO;
public static String ERR_WRONG_MESSAGE_FORMAT;
public static String ERR_MSG_SEND_FAIL;
+
+ public static String ERR_FAILED_TO_WRITE_TO_FILE;
+ public static String ERR_FAILED_TO_DELETE_FILE;
+
+ public static String ERR_GUIDE_SELECT_ANOTHER_DEVICE;
+
static {
NLS.initializeMessages(BUNDLE_NAME, UserErrorWarningLabels.class);
}
ERROR_CONNECTION_CLOSED=Socket seems to be closed. \nReconnect the device.
ERROR_DOWNLOAD_FILE_FAILED=Download failed.
ERROR_DOWNLOAD_FILE_FAILED_DUETO_SECURITY=Download failed due to security reason. \nEnable root mode on device to proceed.
+ERROR_CANCEL_FAILED=Failed to cancel operation.\nPlease, restart Dynamic Analyzer.
ERROR_FAILED_OPERATION=Binary information cannot be retrieved from the device. \nReconnect the device.
ERROR_INTERNAL_REASON=Failed for an internal reason.\nTry again or restart the dynamic analyzer.
ERROR_BY_UNKNOWN_REASON=Failed for some reason.
ERR_NO_PROCINFO=Process cannot be traced. \nSelect another process.
ERR_WRONG_MESSAGE_FORMAT=AckMessage payload is null or exceeds the maximum size. \nRe-connect the device.
ERR_MSG_SEND_FAIL=No acknowledgement from the device. \nRe-connect the device.
+ERR_FAILED_TO_WRITE_TO_FILE=Failed to write to file.
+ERR_FAILED_TO_DELETE_FILE=Failed to delete existing file
+ERR_GUIDE_SELECT_ANOTHER_DEVICE=Selected features are not supported for the current device or emulator.\nPlease check the target connection status.\nOr select other target and features with File>New dialog.
\ No newline at end of file
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Hyunjong Park <phjwithyou.park@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.nl;
-
-import org.eclipse.osgi.util.NLS;
-
-public class UserInterfacePageLabels extends NLS {
-
- private static final String BUNDLE_NAME = "org.tizen.dynamicanalyzer.nl.UserInterfacePageLabels"; //$NON-NLS-1$
- public static String USERINTERFACE_SNAPSHOT_VIEW_NAME;
-
- public static String USERINTERFACE_CONTROL_LIST_VIEW_NAME;
- public static String USERINTERFACE_CONTROL_LIST_VIEW_COLUMN_0;
- public static String USERINTERFACE_CONTROL_LIST_VIEW_COLUMN_1;
- public static String USERINTERFACE_CONTROL_LIST_VIEW_COLUMN_2;
- public static String USERINTERFACE_CONTROL_LIST_VIEW_COLUMN_3;
- public static String USERINTERFACE_CONTROL_LIST_VIEW_COLUMN_4;
-
- public static String USERINTERFACE_SCENETRANSFORM_LIST_VIEW_NAME;
- public static String USERINTERFACE_SCENETRANSFORM_LIST_VIEW_COLUMN_0;
- public static String USERINTERFACE_SCENETRANSFORM_LIST_VIEW_COLUMN_1;
- public static String USERINTERFACE_SCENETRANSFORM_LIST_VIEW_COLUMN_2;
- public static String USERINTERFACE_SCENETRANSFORM_LIST_VIEW_COLUMN_3;
- public static String USERINTERFACE_SCENETRANSFORM_LIST_VIEW_COLUMN_4;
- public static String USERINTERFACE_SCENETRANSFORM_LIST_VIEW_COLUMN_5;
-
- public static String USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_NAME;
- public static String USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_COLUMN_0;
- public static String USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_COLUMN_1;
- public static String USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_COLUMN_2;
- public static String USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_COLUMN_3;
- public static String USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_COLUMN_4;
- public static String USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_COLUMN_5;
- public static String USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_COLUMN_6;
- public static String USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_COLUMN_7;
- public static String USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_COLUMN_8;
-
- public static String USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_INCLUSIVE_ELAPSED_TIME;
- public static String USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_EXCLUSIVE_ELAPSED_TIME;
- public static String USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_INCLUSIVE_CPU_TIME;
- public static String USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_EXCLUSIVE_CPU_TIME;
-
- public static String PID;
-
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, UserInterfacePageLabels.class);
- }
-
- private UserInterfacePageLabels() {
- }
-}
\ No newline at end of file
+++ /dev/null
-
-USERINTERFACE_CONTROL_LIST_VIEW_NAME = Controls
-USERINTERFACE_CONTROL_LIST_VIEW_COLUMN_0 = Class name
-USERINTERFACE_CONTROL_LIST_VIEW_COLUMN_1 = Initializing time
-USERINTERFACE_CONTROL_LIST_VIEW_COLUMN_2 = Terminating time
-USERINTERFACE_CONTROL_LIST_VIEW_COLUMN_3 = Control type
-USERINTERFACE_CONTROL_LIST_VIEW_COLUMN_4 = PID
-
-
-USERINTERFACE_SCENETRANSFORM_LIST_VIEW_NAME = Scene Transition
-USERINTERFACE_SCENETRANSFORM_LIST_VIEW_COLUMN_0 = Time
-USERINTERFACE_SCENETRANSFORM_LIST_VIEW_COLUMN_1 = PID
-USERINTERFACE_SCENETRANSFORM_LIST_VIEW_COLUMN_2 = Scene name
-USERINTERFACE_SCENETRANSFORM_LIST_VIEW_COLUMN_3 = Form name
-USERINTERFACE_SCENETRANSFORM_LIST_VIEW_COLUMN_4 = Panel name
-USERINTERFACE_SCENETRANSFORM_LIST_VIEW_COLUMN_5 = Transition time
-
-USERINTERFACE_SNAPSHOT_VIEW_NAME = Snapshot
-
-USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_NAME = Function Profiling of Tizen UI
-USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_COLUMN_0 = Library/function name
-USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_COLUMN_1 = Sum
-USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_COLUMN_2 = Average
-USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_COLUMN_3 = Sum
-USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_COLUMN_4 = Average
-USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_COLUMN_5 = Sum
-USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_COLUMN_6 = Average
-USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_COLUMN_7 = Sum
-USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_COLUMN_8 = Average
-USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_INCLUSIVE_ELAPSED_TIME = Inclusive elapsed time
-USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_EXCLUSIVE_ELAPSED_TIME = Exclusive elapsed time
-USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_INCLUSIVE_CPU_TIME = Inclusive CPU time
-USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_EXCLUSIVE_CPU_TIME = Exclusive CPU time
-
-PID=PID :
-
private String execPath = null;
private String execFileName = null;
+ private List<String> binPaths = new ArrayList<String>();
private List<String> localPackagePath = null;
private Map<Integer, String> runningProcesses = null;
* @return list of paths to binaries for running processes
*/
public List<String> getProcessInformation() {
- List<String> binPaths = new ArrayList<>();
+ if (!binPaths.isEmpty())
+ return binPaths;
+
String appID = getAppID();
if (AnalyzerConstants.RUNNING_PROCESS.equals(appID)) {
Map<Integer, String> selProcess = getRunningProcesses();
if (execpath != null)
binPaths.add(execpath);
+
+ if (!getAppType().equals(APPTYPE_WEB))
+ // Get paths to application libraries
+ binPaths.addAll(0, DACommunicator.getApplicationLibs(getPackageID()));
}
return binPaths;
}
*
* Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact:
+ * Contact:
* Jaewon Lim <jaewon81.lim@samsung.com>
* Jooyoul Lee <jy.exe.lee@samsung.com>
* Juyoung Kim <j0.kim@samsung.com>
+ * Vladislav Eliseev <v.eliseev@samsung.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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.
- *
+ *
* Contributors:
* - S-Core Co., Ltd
- *
+ *
*/
package org.tizen.dynamicanalyzer.project;
this.lowestAddress = low;
this.highestAddress = high;
}
-
+
public long getLowestAddress() {
return lowestAddress;
}
public int getBinaryID() {
return binaryID;
}
+
+ /**
+ * Tell whether specified address belongs to the specified range.
+ *
+ * @param addr address to check
+ * @param low range low address
+ * @param high range high address
+ */
+ private static boolean isAddrInRange(long addr, long low, long high) {
+ return low <= addr && addr < high;
+ }
+
+ /**
+ * Return whether specified address belongs to this library object.
+ *
+ * @param addr address to check
+ */
+ public boolean isAddrInRange(long addr) {
+ return isAddrInRange(addr, lowestAddress, highestAddress);
+ }
+
+ /**
+ * Return whether specified address range overlaps with this library object.
+ * Range low address should be lesser than range high address,
+ * otherwise range will be considered as empty.
+ *
+ * @param low range low address
+ * @param high range high address
+ */
+ public boolean isOverlapped(long low, long high) {
+ if (low >= high)
+ return false;
+ else
+ return isAddrInRange(lowestAddress, low, high)
+ || isAddrInRange(highestAddress, low + 1, high + 1)
+ || (lowestAddress <= low && high <= highestAddress);
+ }
+
+ /**
+ * Return whether specified library object overlaps with this library object.
+ *
+ * @param other other library object
+ */
+ public boolean isOverlapped(LibraryObject other) {
+ return isOverlapped(other.lowestAddress, other.highestAddress);
+ }
}
private boolean dropLog = false;
private NavigableMap<Long, ProcessMemoryMap> processMemSnapshots = new TreeMap<Long, ProcessMemoryMap>();
- private boolean isMapping = true;
// not saved data
// temporary function address-id map
}
}
- public void updateProcessMemoryMap(ProcessMemoryMap pmap, long newtime) {
- long prevtime = pmap.getCapturedTime();
- synchronized (processMemSnapshots) {
- processMemSnapshots.remove(Long.valueOf(prevtime));
- pmap.setCapturedTime(newtime);
- processMemSnapshots.put(Long.valueOf(newtime), pmap);
- }
- }
-
public void setDropLog(boolean droplog) {
this.dropLog = droplog;
}
return dropLog;
}
- public void setMappingState(boolean mapping) {
- isMapping = mapping;
- }
-
- public boolean isMapping() {
- return isMapping;
- }
-
public int getFunctionID(long address) {
Integer ret = funcIDMap.get(Long.valueOf(address));
if (ret == null) {
*
* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact:
+ * Contact:
* Jaewon Lim <jaewon81.lim@samsung.com>
* Juyoung Kim <j0.kim@samsung.com>
+ * Vladislav Eliseev <v.eliseev@samsung.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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.
- *
+ *
* Contributors:
* - S-Core Co., Ltd
- *
+ *
*/
package org.tizen.dynamicanalyzer.project;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.NavigableMap;
import java.util.TreeMap;
+import org.tizen.dynamicanalyzer.common.Global;
import org.tizen.dynamicanalyzer.database.DBTable;
import org.tizen.dynamicanalyzer.project.data.MemoryMapDBTable;
+import org.tizen.dynamicanalyzer.util.Logger;
public class ProcessMemoryMap {
private static final String WHERE_PID_TIME = "where " + MemoryMapDBTable.COLUMN.PID.name
private long capturedTime = -1;
protected LibraryObject mainBinary = null;
- protected NavigableMap<Long, LibraryObject> binaryByAddress = new TreeMap<Long, LibraryObject>();
- protected Map<Integer, LibraryObject> binaryByBinaryID = new HashMap<Integer, LibraryObject>();
+ protected NavigableMap<Long, LibraryObject> binaryByAddress = new TreeMap<>();
+ protected Map<Integer, NavigableMap<Long, LibraryObject>> binaryByBinaryID = new HashMap<>();
public ProcessMemoryMap(int pid, long time) {
this.pid = pid;
return mainBinary;
}
- // return false if given library already exist in memory map
- // return true otherwise
+ /**
+ * Return <code>false</code> if given library can't be added to memory map because of overlap
+ * return <code>true</code> otherwise.
+ */
public boolean addLibraryMap(LibraryObject libobj) {
long lowaddr = libobj.getLowestAddress();
int binid = libobj.getBinaryID();
- LibraryObject objByID = null;
+ // update address -> library map
+ synchronized (binaryByAddress) {
+ Entry<Long, LibraryObject> leftEntry;
+ Entry<Long, LibraryObject> rightEntry;
- synchronized (binaryByBinaryID) {
- objByID = binaryByBinaryID.put(Integer.valueOf(binid), libobj);
- }
+ leftEntry = binaryByAddress.floorEntry(lowaddr);
+ rightEntry = binaryByAddress.ceilingEntry(lowaddr);
- synchronized (binaryByAddress) {
- if (objByID != null) {
- binaryByAddress.remove(Long.valueOf(objByID.getLowestAddress()));
+ // check left entry overlap
+ if (leftEntry != null && leftEntry.getValue().isOverlapped(libobj)) {
+ return false;
}
- binaryByAddress.put(Long.valueOf(lowaddr), libobj);
- }
+ // check right entry overlap
+ if (rightEntry != null && rightEntry.getValue().isOverlapped(libobj)) {
+ return false;
+ }
- if (objByID != null) {
- return false;
- } else {
- return true;
+ // if ok then add new library object
+ binaryByAddress.put(lowaddr, libobj);
+
+ // update binid -> (address -> library) map
+ NavigableMap<Long, LibraryObject> libMap = binaryByBinaryID.get(binid);
+ if (libMap == null) {
+ libMap = new TreeMap<>();
+ binaryByBinaryID.put(binid, libMap);
+ }
+
+ libMap.put(lowaddr, libobj);
}
+
+ return true;
}
+ /**
+ * Returns library object to which specified address belongs.
+ *
+ * @param address address to check
+ * @return library object or <code>null</code> if no library owns this address
+ */
public LibraryObject getLibraryByAddress(long address) {
Map.Entry<Long, LibraryObject> entry = binaryByAddress.floorEntry(Long.valueOf(address));
- if (entry == null) {
- return null;
- } else {
+ if (entry != null) {
LibraryObject libobj = entry.getValue();
- if (libobj != null && address <= libobj.getHighestAddress()) {
- return libobj;
- } else {
- return null;
- }
+ return libobj.isAddrInRange(address) ? libobj : null;
+ } else {
+ return null;
}
}
- public LibraryObject getLibraryByBinaryID(int binaryID) {
- return binaryByBinaryID.get(Integer.valueOf(binaryID));
+ /**
+ * Get all mapping which belongs to the specified binary.
+ *
+ * @param binaryID binary to get mappings for
+ * @return map where key is low address and value is libobject mapping that start in
+ * corresponding low address (lowaddress -> libobject), all libobjects correspond to
+ * the specified binary
+ */
+ public NavigableMap<Long, LibraryObject> getLibraryMappingByBinaryID(int binaryID) {
+ return binaryByBinaryID.get(binaryID);
}
- public boolean removeLibrary(long lowaddr, long highaddr) {
- LibraryObject libobj = binaryByAddress.floorEntry(Long.valueOf(lowaddr)).getValue();
- if (libobj != null && highaddr <= libobj.getHighestAddress()) {
- synchronized (binaryByAddress) {
- binaryByAddress.remove(Long.valueOf(libobj.getLowestAddress()));
- }
- synchronized (binaryByBinaryID) {
- binaryByBinaryID.remove(Integer.valueOf(libobj.getBinaryID()));
+ /**
+ * Tell whether specified address belongs to the specified range.
+ *
+ * @param addr address to check
+ * @param low range low address
+ * @param high range high address
+ */
+ private static boolean isAddrInRange(long addr, long low, long high) {
+ return low <= addr && addr < high;
+ }
+
+ /**
+ * Get target path of binary with specified binary id.
+ */
+ private static String getLibraryPath(int binID) {
+ return Global.getProject().getDeviceStatusInfo().getBinaryInfo(binID).getTargetBinaryPath();
+ }
+
+ /**
+ * Remove memory mapping on specified address range, this may affect multiple library mappings:
+ * they may be shrinked, splitted or completely removed.
+ *
+ * @param lowaddr range low address
+ * @param highaddr range high address
+ * @return <code>true</code> if memory map changed, <code>false</code> otherwise
+ */
+ public boolean removeMapping(long lowaddr, long highaddr) {
+ boolean changed = false;
+ synchronized (binaryByAddress) {
+ Entry<Long, LibraryObject> curEntry = binaryByAddress.floorEntry(lowaddr);
+
+ // check if there is no lib object before range
+ // or nearest lib object (from left) is not overlapped with range
+ if (curEntry == null || !curEntry.getValue().isOverlapped(lowaddr, highaddr)) {
+ // take nearest lib object from right
+ curEntry = binaryByAddress.ceilingEntry(lowaddr);
}
- return true;
- } else {
- return false;
+ // while we have overlapped lib object
+ while (curEntry != null && curEntry.getValue().isOverlapped(lowaddr, highaddr)) {
+ LibraryObject curLib = curEntry.getValue();
+ int binid = curLib.getBinaryID();
+ long curLow = curLib.getLowestAddress();
+ long curHigh = curLib.getHighestAddress();
+ boolean leftTouched = isAddrInRange(curLow, lowaddr, highaddr);
+ boolean rightTouched = isAddrInRange(curHigh, lowaddr, highaddr + 1);
+
+ binaryByAddress.remove(curLow);
+ binaryByBinaryID.get(binid).remove(curLow);
+ changed = true;
+
+ if (leftTouched && rightTouched) {
+ // completely remove mapping
+ if (binaryByBinaryID.get(binid).size() == 0) {
+ binaryByBinaryID.remove(binid);
+ }
+ Logger.info("Removed mapping for %s", getLibraryPath(binid));
+ } else if (!leftTouched && !rightTouched) {
+ // split mapping
+ LibraryObject leftLib = new LibraryObject(binid, curLow, lowaddr);
+ LibraryObject rightLib = new LibraryObject(binid, highaddr, curHigh);
+
+ binaryByAddress.put(curLow, leftLib);
+ binaryByAddress.put(highaddr, rightLib);
+
+ binaryByBinaryID.get(binid).put(curLow, leftLib);
+ binaryByBinaryID.get(binid).put(highaddr, rightLib);
+ Logger.info("Splitted mapping for %s", getLibraryPath(binid));
+ } else {
+ // shrink mapping : (leftTouched ^ rightTouched)
+ // either right or left border is touched (but not both)
+ if (rightTouched) {
+ curHigh = lowaddr;
+ } else {
+ curLow = highaddr;
+ }
+
+ LibraryObject newLib = new LibraryObject(binid, curLow, curHigh);
+ binaryByAddress.put(curLow, newLib);
+ binaryByBinaryID.get(binid).put(curLow, newLib);
+ Logger.info("Shrinked mapping for %s", getLibraryPath(binid));
+ }
+
+ curEntry = binaryByAddress.ceilingEntry(curHigh);
+ }
}
+ return changed;
}
+ /**
+ * Copy all library objects from specified map to this map.
+ *
+ * @param srcMap source map to copy from
+ */
public void copy(ProcessMemoryMap srcMap) {
this.mainBinary = srcMap.mainBinary;
synchronized (binaryByAddress) {
this.binaryByAddress.putAll(srcMap.binaryByAddress);
- }
- synchronized (binaryByBinaryID) {
this.binaryByBinaryID.putAll(srcMap.binaryByBinaryID);
}
}
public void saveMemoryMap(DBTable table) {
- List<List<Object>> datas = new ArrayList<List<Object>>();
+ List<List<Object>> datas = new ArrayList<>();
for (Map.Entry<Long, LibraryObject> entry : binaryByAddress.entrySet()) {
- List<Object> data = new ArrayList<Object>();
+ List<Object> data = new ArrayList<>();
LibraryObject lib = entry.getValue();
data.add(Integer.valueOf(pid));
data.add(Long.valueOf(capturedTime));
}
}
}
-
- public Map<Integer, LibraryObject> getAllLibraryID() {
- return binaryByBinaryID;
+
+ /**
+ * Get all known memory mappings.
+ *
+ * @return map where key is some low address and value is libobject mapping that start in
+ * corresponding low address (lowaddress -> libobject)
+ */
+ public Map<Long, LibraryObject> getAllMappings() {
+ return binaryByAddress;
}
}
import org.tizen.dynamicanalyzer.handlers.UIActionHolder;
import org.tizen.dynamicanalyzer.model.DATime;
import org.tizen.dynamicanalyzer.nl.TimelineChartLabels;
-import org.tizen.dynamicanalyzer.project.callstack.RuntimeCallstackManager;
import org.tizen.dynamicanalyzer.project.data.BinaryInfoDBTable;
import org.tizen.dynamicanalyzer.project.data.FunctionNameDBTable;
import org.tizen.dynamicanalyzer.project.data.MemoryMapDBTable;
import org.tizen.dynamicanalyzer.setting.UILayoutDataManager;
import org.tizen.dynamicanalyzer.ui.file.data.FileApiDB;
import org.tizen.dynamicanalyzer.ui.info.screenshot.ScreenShotDBTable;
-import org.tizen.dynamicanalyzer.ui.kernel.data.ContextDataDBTable;
import org.tizen.dynamicanalyzer.ui.network.data.NetworkAPIDBManager;
import org.tizen.dynamicanalyzer.ui.opengl.data.DB.GLAPIDBTableManager;
import org.tizen.dynamicanalyzer.ui.page.PageInfoRegistry;
private static final String QUERY_TABLE_ROW_COUNT = "select table_name, cardinality from information_schema.system_tablestats where table_schema='PUBLIC' order by table_name";
private static final String TABLE_FOR_FILE_PAGE = FileApiDB.TABLENAME;
private static final String TABLE_FOR_THREAD_PAGE = ThreadDataDBTable.TABLENAME;
- private static final String TABLE_FOR_KERNEL_PAGE = ContextDataDBTable.TABLENAME;
private static final String TABLE_FOR_NETWORK_PAGE = NetworkAPIDBManager.TABLENAME;
private static final String TABLE_FOR_OPENGL_PAGE = GLAPIDBTableManager.TABLENAME;
private static final String TABLE_FOR_SCREENSHOT_CHART = ScreenShotDBTable.TABLENAME;
private DeviceStatusInfo targetDeviceStatusInfo = null;
private AppInfo targetApplicationInfo = null;
- private RuntimeCallstackManager runtimeCallstackManager = new RuntimeCallstackManager();
-
// following data will not be saved
// lock object
public String getFunctionName(int id) {
FunctionInfo finfo = functionInfos.getByIndex(id);
if (finfo == null) {
- Logger.error("Invalid index for function name\n");
return AnalyzerConstants.UNKNOWN_API;
} else {
return finfo.getFunctionName();
return finfo.getID();
}
- public RuntimeCallstackManager getRuntimeCallstackManager() {
- return runtimeCallstackManager;
- }
-
public void addImageInfo(ImageInfo info) {
if (info != null) {
long time = info.getTime();
return timelineChartList;
}
- // this init() function called only when trace is started.
- // current device and application should be validated before calling this method.
- public void init(IProgress progress) throws InterruptedException {
+ /**
+ * Initializes created project. Should be called only when trace is started.
+ * Current device and application should be validated before calling this
+ * method.
+ *
+ * @param progress {@link IProgress} implementation
+ * @return {@code true} on success
+ */
+ public boolean init(IProgress progress) {
AppInfo curApp = Global.getCurrentApplication();
DeviceInfo curDev = Global.getCurrentDeviceInfo();
}
}
}
- progress.testCancel();
+
+ if (progress.testCancel())
+ return false;
+
progress.setStageComplete(STAGE.CREATE_PROJECT);
// make sure previous database connection is closed
SqlConnectionManager.establishConnection(getSavePath() + File.separator
+ AnalyzerConstants.DATABASE_NAME);
- progress.testCancel();
+ if (progress.testCancel())
+ return false;
+
progress.setStageComplete(STAGE.ESTABLISH_DB);
// create table
DBTableRegistry.createDBTables(null);
- progress.testCancel();
+ if (progress.testCancel())
+ return false;
+
progress.setStageComplete(STAGE.CREATE_DBTABLE);
+
+ return true;
}
/**
profilingStartTime = null;
}
savePath = null;
-
- runtimeCallstackManager.clear();
}
public boolean isValid() {
saveFunctionInfo();
saveBinaryInfo();
saveProcessInfo();
- runtimeCallstackManager.save();
} catch (IOException e) {
Logger.exception(e);
bret = false;
openFunctionInfo();
openBinaryInfo();
openProcessInfo();
- runtimeCallstackManager.open();
} catch (IOException e) {
Logger.exception(e);
bret = false;
pageList.add(SettingConstants.PAGE_NAME_OPENGL);
}
- val = tableRowCount.get(TABLE_FOR_KERNEL_PAGE);
- if (val != null && val.longValue() > 0) {
- pageList.add(SettingConstants.PAGE_NAME_KERNEL);
- }
-
pageList.add(SettingConstants.PAGE_NAME_SUMMARY);
pageTabList = pageList.toArray(new String[0]);
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * WooJin Jung <woojin2.jung@samsung.com>
- * Jooyoul Lee <jy.exe.lee@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-package org.tizen.dynamicanalyzer.project.callstack;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.NavigableMap;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentSkipListMap;
-
-import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
-import org.tizen.dynamicanalyzer.common.Global;
-import org.tizen.dynamicanalyzer.common.SymbolManager;
-import org.tizen.dynamicanalyzer.constant.CommonConstants;
-import org.tizen.dynamicanalyzer.nl.InformationViewLabels;
-import org.tizen.dynamicanalyzer.project.BinaryInfo;
-import org.tizen.dynamicanalyzer.project.LibraryObject;
-import org.tizen.dynamicanalyzer.project.ProcessInformation;
-import org.tizen.dynamicanalyzer.project.ProcessMemoryMap;
-import org.tizen.dynamicanalyzer.project.Project;
-import org.tizen.dynamicanalyzer.swap.model.data.LogData;
-import org.tizen.dynamicanalyzer.swap.platform.BinarySettingData;
-import org.tizen.dynamicanalyzer.swap.platform.BinarySettingManager;
-import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackData;
-import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackItem;
-import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackUnit;
-import org.tizen.dynamicanalyzer.ui.summary.profiling.ProfileDataMaker;
-import org.tizen.dynamicanalyzer.util.Logger;
-import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
-
-public abstract class BaseCallstackManager {
- protected Map<Integer, Map<Long, CallStackUnit>> callstackApiAddrByPidMap = new ConcurrentHashMap<Integer, Map<Long, CallStackUnit>>();
- protected NavigableMap<Long, CallStackData> callstackDataBySeqMap = new ConcurrentSkipListMap<Long, CallStackData>();
- protected Map<Integer, List<CallStackItem>> userCallstackByTidMap = new HashMap<Integer, List<CallStackItem>>();
-
- /**
- * Method to create callstack for current state of program executing.
- *
- * @param log data that includes information about last function entry or
- * exit
- * @param profiler profiler that encapsulates data preparations
- */
- abstract public void makeUserCallstack(LogData log, ProfileDataMaker profiler);
-
- abstract public long getSeqOfUserCallstackForTime(int tid, long time);
-
- public Map<Long, CallStackUnit> getCallStackApiAddrByPidMap(int pid) {
- Map<Long, CallStackUnit> callstackApiByAddrMap = callstackApiAddrByPidMap.get(pid);
- if (null == callstackApiByAddrMap) {
- callstackApiByAddrMap = new ConcurrentHashMap<Long, CallStackUnit>();
- callstackApiAddrByPidMap.put(pid, callstackApiByAddrMap);
- }
- return callstackApiByAddrMap;
- }
-
- public NavigableMap<Long, CallStackData> getCallStackDataBySeqMap() {
- return callstackDataBySeqMap;
- }
-
- public List<CallStackItem> getUserCallstack(int tid) {
- List<CallStackItem> userCallstack = userCallstackByTidMap.get(tid);
- if (null == userCallstack) {
- userCallstack = new ArrayList<CallStackItem>();
- userCallstackByTidMap.put(tid, userCallstack);
- }
- return userCallstack;
- }
-
- public void clear() {
- callstackApiAddrByPidMap.clear();
- callstackDataBySeqMap.clear();
- userCallstackByTidMap.clear();
- }
-
- private String getUserFunctionPosition(int pid, long time) {
- Project project = Global.getProject();
- ProcessInformation process = project.getProcessInformation(pid);
- ProcessMemoryMap pmap = process.getProcessMemoryMap(time);
-
- if (pmap != null) {
- int binaryID = pmap.getMainbinary().getBinaryID();
- return project.getDeviceStatusInfo().getBinaryInfo(binaryID).getTargetBinaryPath();
- } else {
- return CommonConstants.EMPTY;
- }
- }
-
- // callstack symbol format : path(functionName
- // ex. /usr/lib/libpthread.so(pthread_create
- public String getCallStackSymbol(long addr, int pid, long time) {
- String functionName = null;
- String symbol = null;
-
- Project project = Global.getProject();
- ProcessInformation process = project.getProcessInformation(pid);
- ProcessMemoryMap pmap = process.getProcessMemoryMap(time);
-
- if (pmap != null) {
- if (addr >= pmap.getMainbinary().getLowestAddress()
- && addr <= pmap.getMainbinary().getHighestAddress()) { // application
- // binary
- String baseAddr = Long.toString(pmap.getMainbinary().getLowestAddress());
- String pcStr = Long.toString(addr);
-
- LibraryObject libobj = pmap.getLibraryByAddress(addr);
- if (libobj != null) {
- BinaryInfo binInfo = project.getDeviceStatusInfo().getBinaryInfo(
- libobj.getBinaryID());
- String localPath = binInfo.getTempBinaryPath();
- boolean isPieBuild = true;
- if (binInfo.getType() != 1) {
- isPieBuild = false;
- }
- functionName = SymbolManager.addr2func(localPath, pcStr, isPieBuild, baseAddr);
- }
-
- if (null == functionName || functionName.isEmpty() || functionName.equals("_end")) { //$NON-NLS-1$
- functionName = InformationViewLabels.CALLSTACK_TABLE_UNKNOWN_FUNCTION;
- } else {
- String prevFunctionName = functionName;
- functionName = SymbolManager.demanglingFunctionName(prevFunctionName);
- }
- // need to be checked again - in case pid is not main
- // application
- symbol = getUserFunctionPosition(pid, time)
- + AnalyzerConstants.CALLSTACK_API_TOKEN_STRING + functionName;
- } else {
- List<BinarySettingData> binDataList = BinarySettingManager.getInstance()
- .getBinarySettingList();
-
- LibraryObject libraryObject = pmap.getLibraryByAddress(addr);
- if (null != libraryObject) {
- int binaryID = libraryObject.getBinaryID();
- BinaryInfo binfo = Global.getProject().getDeviceStatusInfo()
- .getBinaryInfo(binaryID);
- String path = binfo.getTargetBinaryPath();
-
- boolean isInBinarySetting = false;
- for (BinarySettingData binData : binDataList) {
- if (path.equals(binData.getBinaryPath())) {
- isInBinarySetting = true;
- break;
- }
- }
-
- if (isInBinarySetting) {
- String localPath = binfo.getTempBinaryPath();
- String baseAddr = Long.toString(libraryObject.getLowestAddress());
- String pcStr = Long.toString(addr);
- boolean isPieBuild = true;
- if (binfo.getType() != 1) {
- isPieBuild = false;
- }
- functionName = SymbolManager.addr2func(localPath, pcStr, isPieBuild,
- baseAddr);
- if (null == functionName || functionName.isEmpty()
- || functionName.equals("_end")) { //$NON-NLS-1$
- functionName = InformationViewLabels.CALLSTACK_TABLE_UNKNOWN_FUNCTION;
- } else {
- String prevFunctionName = functionName;
- functionName = SymbolManager.demanglingFunctionName(prevFunctionName);
- }
- // need to be checked again - in case pid is not main
- // application
- } else {
- functionName = InformationViewLabels.CALLSTACK_TABLE_UNKNOWN_FUNCTION;
- }
- symbol = path + AnalyzerConstants.CALLSTACK_API_TOKEN_STRING + functionName;
- }
- }
- }
-
- if (symbol == null) {
- Logger.debug("binary for the sample pc is not found :" + AnalyzerUtil.toHexdecimal(addr)); //$NON-NLS-1$
- symbol = InformationViewLabels.CALLSTACK_TABLE_UNKNOWN_LIBRARY
- + AnalyzerConstants.CALLSTACK_API_TOKEN_STRING
- + AnalyzerUtil.toHexdecimal(addr);
- // + InformationViewLabels.CALLSTACK_TABLE_UNKNOWN_FUNCTION;
- }
-
- return symbol;
- }
-
- protected boolean isAddrInBinaryRange(int pid, long time, long addr) {
- ProcessMemoryMap pmap = Global.getProject().getProcessInformation(pid)
- .getProcessMemoryMap(time);
- if (null == pmap) {
- return false;
- }
- // return true when addr is within memory range of main executable
- // or library which is set in the binary setting
- if (addr >= pmap.getMainbinary().getLowestAddress()
- && addr <= pmap.getMainbinary().getHighestAddress()) {
- return true;
- }
-
- List<BinarySettingData> binDataList = BinarySettingManager.getInstance()
- .getBinarySettingList();
- List<String> binPaths = new ArrayList<String>();
- for (BinarySettingData binData : binDataList) {
- binPaths.add(binData.getBinaryPath());
- }
- // TODO: performance improvement
- int size = binPaths.size();
- for (int i = 0; i < size; i++) {
- String binPath = binPaths.get(i);
- BinaryInfo bininfo = Global.getProject().getDeviceStatusInfo().getBinaryInfo(binPath);
- LibraryObject libObj = pmap.getLibraryByBinaryID(bininfo.getID());
- if (null == libObj) {
- continue;
- }
- if (addr >= libObj.getLowestAddress() && addr <= libObj.getHighestAddress()) {
- return true;
- }
- }
- return false;
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * WooJin Jung <woojin2.jung@samsung.com>
- * Jooyoul Lee <jy.exe.lee@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.project.callstack;
-
-import java.util.List;
-import java.util.Map;
-
-import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
-import org.tizen.dynamicanalyzer.common.Global;
-import org.tizen.dynamicanalyzer.project.BinaryInfo;
-import org.tizen.dynamicanalyzer.protocol.ProtocolConstants;
-import org.tizen.dynamicanalyzer.swap.model.data.LogData;
-import org.tizen.dynamicanalyzer.swap.model.data.ProfileData;
-import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackItem;
-import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackUnit;
-import org.tizen.dynamicanalyzer.ui.summary.profiling.ProfileDataMaker;
-import org.tizen.dynamicanalyzer.util.Logger;
-
-public class RangeCallstackManager extends BaseCallstackManager {
-
- @Override
- public void makeUserCallstack(LogData log, ProfileDataMaker profiler) {
- if (!(log instanceof ProfileData)) {
- Logger.warning("failed to make user callstack : log is not profile log");
- return;
- }
-
- ProfileData pData = (ProfileData) log;
- int pid = pData.getPid();
- long time = pData.getTime();
-
- Map<Long, CallStackUnit> addrMap = getCallStackApiAddrByPidMap(pid);
-
- int tid = pData.getTid();
- long selfAddr = pData.getPcAddr();
- long callerAddr = pData.getCallerPcAddr();
-
- CallStackUnit selfCallstackUnit = addrMap.get(selfAddr);
- // TODO: use callstackunit made during trace time
- if (null == selfCallstackUnit) {
- String strSelfFuncName = Global.getFunctionName(pData.getApiId());
- BinaryInfo binInfo = Global.getProject().getDeviceStatusInfo()
- .getBinaryInfo(pData.getBinaryId());
- String strSelfSymbol = binInfo.getTargetBinaryPath()
- + AnalyzerConstants.CALLSTACK_API_TOKEN_STRING + strSelfFuncName;
- selfCallstackUnit = new CallStackUnit(selfAddr, strSelfSymbol, pData.getApiId(), pData);
- addrMap.put(selfAddr, selfCallstackUnit);
- }
-
- // make ProfilingData
- profiler.makeFupDataForCallTrace(selfCallstackUnit, pData);
-
- List<CallStackItem> userCallstack = getUserCallstack(tid);
- int size = userCallstack.size();
-
- CallStackUnit callerCallstackUnit = addrMap.get(callerAddr);
- if (null == callerCallstackUnit) {
- String strCallerSymbol = getCallStackSymbol(callerAddr, pid, time);
- callerCallstackUnit = new CallStackUnit(callerAddr, strCallerSymbol, pData);
- addrMap.put(callerAddr, callerCallstackUnit);
- }
-
- int eventType = pData.getMsgID();
- if (eventType == ProtocolConstants.MSG_FUNCTION_ENTRY) {
- if (size == 0) {
- userCallstack.add(new CallStackItem(selfCallstackUnit, time));
- } else {
- if (isAddrInBinaryRange(pid, time, callerAddr)) {
- // change previous top callstackunit's address to caller address of this
- // callstackunit
- CallStackUnit callerCsa = addrMap.get(callerAddr);
- if (null == callerCsa) {
- callerCsa = userCallstack.get(size - 1).getCallStackUnit();
- callerCsa.setFunctionStartAddr(callerCsa.getAddr());
- callerCsa.setAddr(callerAddr);
- } else {
- CallStackItem topCallstackItem = userCallstack.get(size - 1);
- callerCsa.setFunctionStartAddr(topCallstackItem.getCallStackUnit()
- .getAddr());
- userCallstack.set(size - 1,
- new CallStackItem(callerCsa, topCallstackItem.getStartTime()));
- }
- } // do nothing when call is from library
- // in range analysis, user callstack is only used to make callstack of sample
- // and callstack of sample does not include "~~ internal library~~"
- userCallstack.add(new CallStackItem(selfCallstackUnit, time));
- }
- } else if (eventType == ProtocolConstants.MSG_FUNCTION_EXIT) {
- if (size == 0) {
- return;
- }
- CallStackUnit removeCallStackUnit = userCallstack.get(size - 1).getCallStackUnit();
- if (selfCallstackUnit.getFunctionId() == removeCallStackUnit.getFunctionId()) {
- userCallstack.remove(size - 1);
- size = userCallstack.size();
- if (size > 0) {
- // restore start address of previous top callstackunit
- CallStackItem prevCallstackItem = userCallstack.get(size - 1);
- long prevSelfAddr = prevCallstackItem.getCallStackUnit().getFunctionStartAddr();
- CallStackUnit callerCsa = addrMap.get(prevSelfAddr);
- if (null == callerCsa) {
- prevCallstackItem.getCallStackUnit().setAddr(prevSelfAddr);
- } else {
- userCallstack.set(size - 1,
- new CallStackItem(callerCsa, prevCallstackItem.getStartTime()));
- }
- }
- } else {
- Logger.debug("exit self function : %s, user callstack function : %s",
- Global.getFunctionName(selfCallstackUnit.getFunctionId()),
- Global.getFunctionName(removeCallStackUnit.getFunctionId()));
- }
- }
- }
-
- @Override
- public long getSeqOfUserCallstackForTime(int tid, long time) {
- // do nothing, never been called
- Logger.error("Should not be called in range callstack manager");
- return 0;
- }
-
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * WooJin Jung <woojin2.jung@samsung.com>
- * Jooyoul Lee <jy.exe.lee@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.project.callstack;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.NavigableMap;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentSkipListMap;
-
-import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
-import org.tizen.dynamicanalyzer.common.Global;
-import org.tizen.dynamicanalyzer.logparser.LogCenterConstants;
-import org.tizen.dynamicanalyzer.project.BinaryInfo;
-import org.tizen.dynamicanalyzer.project.LibraryObject;
-import org.tizen.dynamicanalyzer.project.ProcessInformation;
-import org.tizen.dynamicanalyzer.project.ProcessMemoryMap;
-import org.tizen.dynamicanalyzer.protocol.ProtocolConstants;
-import org.tizen.dynamicanalyzer.swap.model.data.LogData;
-import org.tizen.dynamicanalyzer.swap.model.data.ProbeCommonData;
-import org.tizen.dynamicanalyzer.swap.model.data.ProfileData;
-import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackData;
-import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackDataDBTable;
-import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackInserter;
-import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackItem;
-import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackUnit;
-import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackUnitDBTable;
-import org.tizen.dynamicanalyzer.ui.summary.profiling.ProfileDataMaker;
-import org.tizen.dynamicanalyzer.util.Logger;
-
-public class RuntimeCallstackManager extends BaseCallstackManager {
-
- protected Map<Integer, NavigableMap<Long, Long>> seqTimeByTidMap = new ConcurrentHashMap<Integer, NavigableMap<Long, Long>>();
-
- // callstackdata made in range analysis should not be saved to DB
- public RuntimeCallstackManager() {
- }
-
- public void offerCallStackData(CallStackData csd) {
- CallStackInserter.getInstance().pushData(csd);
- }
-
- /**
- * Get sequence time map (for each tid)
- *
- * @param tid thread id
- * @param isCreate whether sequence time map create or not
- * (true : if the map does not exist for thread, create and return)
- */
- public NavigableMap<Long, Long> getSeqTimeByTidMap(int tid, boolean isCreate) {
- NavigableMap<Long, Long> seqByTimeMap = seqTimeByTidMap.get(tid);
- if (isCreate && null == seqByTimeMap) {
- seqByTimeMap = new ConcurrentSkipListMap<Long, Long>();
- seqTimeByTidMap.put(tid, seqByTimeMap);
- }
- return seqByTimeMap;
- }
-
- public List<Integer> getTidsOfSeqTimeMap() {
- ArrayList<Integer> tids = new ArrayList<Integer>();
- tids.addAll(seqTimeByTidMap.keySet());
-
- return tids;
- }
-
- @Override
- public void clear() {
- super.clear();
- seqTimeByTidMap.clear();
- }
-
- @Override
- public void makeUserCallstack(LogData input, ProfileDataMaker profiler) {
- if (!(input instanceof ProfileData)) {
- Logger.warning("failed to make user callstack : log is not profile log");
- return;
- }
-
- ProfileData log = (ProfileData) input;
- int pid = log.getPid();
- long time = log.getTime();
-
- Map<Long, CallStackUnit> addrMap = getCallStackApiAddrByPidMap(pid);
-
- long selfAddr = log.getPcAddr();
- long callerAddr = log.getCallerPcAddr();
-
- CallStackUnit selfCallstackUnit = addrMap.get(selfAddr);
-
- if (null == selfCallstackUnit) {
- String strSelfFuncName = Global.getFunctionName(log.getApiId());
- BinaryInfo binInfo = Global.getProject().getDeviceStatusInfo()
- .getBinaryInfo(log.getBinaryId());
- String strSelfSymbol = binInfo.getTargetBinaryPath()
- + AnalyzerConstants.CALLSTACK_API_TOKEN_STRING + strSelfFuncName;
- selfCallstackUnit = new CallStackUnit(selfAddr, strSelfSymbol, log.getApiId(), log);
- addrMap.put(selfAddr, selfCallstackUnit);
- }
-
- // insert call count
- profiler.makeFupDataForCallTrace(selfCallstackUnit, log);
-
-
-
- CallStackUnit callerCallstackUnit = addrMap.get(callerAddr);
- if (null == callerCallstackUnit) {
- String strCallerSymbol = getCallStackSymbol(callerAddr, pid, time);
- callerCallstackUnit = new CallStackUnit(callerAddr, strCallerSymbol, log);
- addrMap.put(callerAddr, callerCallstackUnit);
- }
-
- int eventType = log.getMsgID();
- if (eventType == ProtocolConstants.MSG_FUNCTION_ENTRY) {
- proceedEntry(log, selfCallstackUnit, addrMap);
- } else if (eventType == ProtocolConstants.MSG_FUNCTION_EXIT) {
- proceedExit(log, selfCallstackUnit, addrMap);
-
- }
- }
-
- /**
- * Method calculates new callstack value on function entry.
- *
- * @param log data that includes information about current state of
- * execution
- * @param selfCallstackUnit description of function execution enter to
- * @param addrMap map with functions assigned to caller addresses
- */
- private void proceedEntry(ProfileData log, CallStackUnit selfCallstackUnit,
- Map<Long, CallStackUnit> addrMap) {
- int pid = log.getPid();
- int tid = log.getTid();
-
- long time = log.getTime();
- long callerAddr = log.getCallerPcAddr();
- long seq = log.getSeq();
-
- List<CallStackItem> userCallstack = getUserCallstack(tid);
- int size = userCallstack.size();
- CallStackData callstackData = new CallStackData(seq);
-
- NavigableMap<Long, Long> seqByTimeMap = getSeqTimeByTidMap(tid, true);
- if (size == 0) {
- userCallstack.add(new CallStackItem(selfCallstackUnit, time));
- } else {
- if (!isAddrInBinaryRange(pid, time, callerAddr)) {
- CallStackUnit callbackApi = addrMap
- .get(LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC_ADDR);
- if (null == callbackApi) {
- callbackApi = new CallStackUnit(
- LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC_ADDR,
- LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC_SYMBOL,
- log);
- addrMap.put(
- LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC_ADDR,
- callbackApi);
- }
- userCallstack.add(new CallStackItem(callbackApi));
- } else {
- CallStackUnit callerCsa = addrMap.get(callerAddr);
- if (null == callerCsa) {
- callerCsa = userCallstack.get(size - 1).getCallStackUnit();
- callerCsa.setFunctionStartAddr(callerCsa.getAddr());
- callerCsa.setAddr(callerAddr);
- } else {
- CallStackItem topCallstackItem = userCallstack
- .get(size - 1);
- callerCsa.setFunctionStartAddr(topCallstackItem
- .getCallStackUnit().getAddr());
- userCallstack.set(size - 1, new CallStackItem(callerCsa,
- topCallstackItem.getStartTime()));
- }
- }
- userCallstack.add(new CallStackItem(selfCallstackUnit, time));
- }
- size = userCallstack.size();
- for (int i = size - 1; i >= 0; i--) {
- callstackData.addAddr(userCallstack.get(i).getCallStackUnit()
- .getAddr());
- }
- offerCallStackData(callstackData);
- getCallStackDataBySeqMap().put(seq, callstackData);
- seqByTimeMap.put(time, seq);
- }
-
- /**
- * Method calculates new callstack value on function exit.
- *
- * @param log data that includes information about current state of
- * execution
- * @param selfCallstackUnit description of function execution exit from
- * @param addrMap map with functions assigned to caller addresses
- */
- private void proceedExit(ProfileData log, CallStackUnit selfCallstackUnit,
- Map<Long, CallStackUnit> addrMap) {
- int tid = log.getTid();
- long time = log.getTime();
- long seq = log.getSeq();
- List<CallStackItem> userCallstack = getUserCallstack(tid);
- int size = userCallstack.size();
- CallStackData callstackData = new CallStackData(seq);
-
- NavigableMap<Long, Long> seqByTimeMap = getSeqTimeByTidMap(tid, true);
- if (size == 0) {
- // if not in range profiling, this should not be reached
- return;
- }
- CallStackUnit removeCallStackUnit = userCallstack.get(size - 1)
- .getCallStackUnit();
- if (selfCallstackUnit.getFunctionId() == removeCallStackUnit
- .getFunctionId()) {
- userCallstack.remove(size - 1);
- size = userCallstack.size();
- if (size - 1 > 0) {
- CallStackUnit checkCallStackUnit = userCallstack.get(size - 1)
- .getCallStackUnit();
- if (checkCallStackUnit.getFunctionName().equals(
- LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC)) {
- userCallstack.remove(size - 1);
- }
- }
- size = userCallstack.size();
- if (size > 0) {
- CallStackItem prevCallstackItem = userCallstack.get(size - 1);
- long prevSelfAddr = prevCallstackItem.getCallStackUnit()
- .getFunctionStartAddr();
- CallStackUnit callerCsa = addrMap.get(prevSelfAddr);
- if (null == callerCsa) {
- prevCallstackItem.getCallStackUnit().setAddr(prevSelfAddr);
- } else {
- userCallstack.set(size - 1, new CallStackItem(callerCsa,
- prevCallstackItem.getStartTime()));
- }
- }
- for (int i = size - 1; i >= 0; i--) {
- callstackData.addAddr(userCallstack.get(i).getCallStackUnit()
- .getAddr());
- }
- offerCallStackData(callstackData);
- getCallStackDataBySeqMap().put(seq, callstackData);
- seqByTimeMap.put(time, seq);
- } else {
- Logger.debug("makeUserCallstack : EXIT self is not the same as top of user callstack");
- }
-
- String apiName = Global.getFunctionName(log.getApiId());
- if ((null != apiName) && (apiName.equals("main"))) { //$NON-NLS-1$
- ProcessInformation process = Global.getProject()
- .getProcessInformation(log.getPid());
- process.setDropLog(true);
- }
- }
-
- /**
- * Method to update callstack for current state of execution, if it is not
- * function entry or exit.
- *
- * @param inputData data that includes information about current state of
- * execution
- */
- public void makeCallstackWithoutBacktrace(LogData inputData) {
- if (!(inputData instanceof ProbeCommonData)) {
- Logger.warning("failed to make callstack : log is not probe log");
- return;
- }
-
- ProbeCommonData log = (ProbeCommonData) inputData;
-
- int pid = log.getPid();
- long time = log.getTime();
-
- Map<Long, CallStackUnit> addrMap = getCallStackApiAddrByPidMap(pid);
-
- long seq = log.getSeq();
- int tid = log.getTid();
- long callerAddr = log.getCallerPcAddr();
-
- if (callerAddr < 0) { // TODO: verify which case this is
- CallStackData callstackData = new CallStackData(seq);
- offerCallStackData(callstackData);
- getCallStackDataBySeqMap().put(seq, callstackData);
- return;
- }
-
- long userCallstackSeq = getSeqOfUserCallstackForTime(tid, time);
- List<Long> addrs = new ArrayList<Long>();
- int size = 0;
-
- if (-1 != userCallstackSeq) { // seq for usercallstack is found
- List<Long> addrsFromUserCallStack = getCallstackAddrListFromSeq(userCallstackSeq);
- if (null != addrsFromUserCallStack) { // callstack data for seq is found
- addrs.addAll(addrsFromUserCallStack);
- size = addrs.size();
- }
- }
-
- CallStackData callstackData = new CallStackData(seq);
-
- if ((size == 0) || (!isAddrInBinaryRange(pid, time, callerAddr))) {
- CallStackUnit callbackApi = addrMap
- .get(LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC_ADDR);
- if (null == callbackApi) {
- callbackApi = new CallStackUnit(
- LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC_ADDR,
- LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC_SYMBOL, log);
- addrMap.put(LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC_ADDR, callbackApi);
- }
- addrs.add(0, LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC_ADDR);
- } else {
- CallStackUnit callerCallstackUnit = addrMap.get(callerAddr);
- if (null == callerCallstackUnit) {
- String strCallerSymbol = getCallStackSymbol(callerAddr, pid, time);
- if(strCallerSymbol != null) {
- callerCallstackUnit = new CallStackUnit(callerAddr, strCallerSymbol, inputData);
-
- CallStackUnit topUserCallstack = addrMap.get(addrs.get(0));
- if (callerCallstackUnit.getFunctionId() == topUserCallstack.getFunctionId())
- callerCallstackUnit.setFunctionStartAddr(topUserCallstack.getFunctionStartAddr());
-
- addrMap.put(callerAddr, callerCallstackUnit);
- }
- }
-
- CallStackUnit topUserCallstack = addrMap.get(addrs.get(0));
- if (callerCallstackUnit.getFunctionId() == topUserCallstack.getFunctionId()) {
- addrs.set(0, callerAddr);
- } else {
- Logger.debug("probe caller is not the same as top of user callstack"); //$NON-NLS-1$
- }
- }
-
- size = addrs.size();
- for (int i = 0; i < size; i++) {
- callstackData.addAddr(addrs.get(i));
- }
- offerCallStackData(callstackData);
- getCallStackDataBySeqMap().put(seq, callstackData);
- }
-
- // to make callstack for sample, probe
- @Override
- public long getSeqOfUserCallstackForTime(int tid, long time) {
- NavigableMap<Long, Long> seqByTimeMap = getSeqTimeByTidMap(tid, false);
- if (null != seqByTimeMap) {
- Long callstackTime = seqByTimeMap.floorKey(time);
- if (null != callstackTime) { // found from memory
- return seqByTimeMap.get(callstackTime);
- }
- }
-
- return -1;
- }
-
- public List<Long> getCallstackAddrListFromSeq(long seq) {
- List<Long> addrs = new ArrayList<Long>();
- CallStackData csd = getCallStackDataBySeqMap().get(seq);
-
- if (null == csd) { // callstackdata is not in memory, find from DB
- List<List<Object>> callStackAddrs = CallStackInserter.getInstance()
- .getCallStackDataTable().getCallStackAddrsFromDB(seq);
-
- if (null == callStackAddrs || 0 == callStackAddrs.size()
- || null == callStackAddrs.get(0)) { // not found
- Logger.debug("CallStackData is not found for seq : " + seq);
- return null;
- }
-
- @SuppressWarnings("unchecked")
- List<Long> addressList = (List<Long>) callStackAddrs.get(0).get(0);
-
- addrs.addAll(addressList);
- } else { // callstackdata is in memory
- addrs.addAll(csd.getAddrs());
- }
- return addrs;
- }
-
- // TODO: 1. execute select query once 2. change return type - <seq, List<Long>>
- // TODO: 3. additional discussion with leak analysis implementer if needed
- public List<List<Long>> getArrayOfAddrListFromSeq(List<Long> seqs) {
- List<List<Long>> addrsList = null;
- if (null == seqs) {
- return null;
- }
-
- addrsList = new ArrayList<List<Long>>();
- int size = seqs.size();
- for (int i = 0; i < size; i++) {
- List<Long> addrs = getCallstackAddrListFromSeq(seqs.get(i));
- if (null != addrs) {
- addrsList.add(addrs);
- }
- }
-
- return addrsList;
- }
-
- public boolean isPieBuild(int pid, long time) {
- ProcessMemoryMap pmap = Global.getProject().getProcessInformation(pid)
- .getProcessMemoryMap(time);
- if (null == pmap) {
- return false;
- }
-
- LibraryObject obj = pmap.getMainbinary();
- BinaryInfo binInfo = Global.getProject().getDeviceStatusInfo()
- .getBinaryInfo(obj.getBinaryID());
-
- if (null == binInfo || binInfo.getType() != 1) {
- return false;
- } else {
- return true;
- }
- }
-
- /**
- * Prepare callstack data to be saved into {@link CallStackUnitDBTable}.
- */
- public void save() {
- // save callstack unit
- List<List<Object>> insertData = new ArrayList<List<Object>>();
- Collection<Map<Long, CallStackUnit>> mapset = callstackApiAddrByPidMap.values();
- for (Map<Long, CallStackUnit> map : mapset) {
- Collection<CallStackUnit> units = map.values();
- for (CallStackUnit unit : units) {
- List<Object> data = new ArrayList<Object>();
- data.add(Integer.valueOf(unit.getPid()));
- data.add(Integer.valueOf(unit.getFunctionId()));
- data.add(Integer.valueOf(unit.getBinaryID()));
- data.add(Long.valueOf(unit.getAddr()));
-
- insertData.add(data);
- }
- }
-
- if (insertData.size() > 0) {
- CallStackInserter.getInstance().getCallStackUnitTable().insertData(insertData);
- }
- }
-
- /**
- * Restore callstack data maps from {@link CallStackDataDBTable} and
- * {@link CallStackUnitDBTable}.
- */
- public void open() {
- // open callstack unit
- List<List<Object>> callStackUnits = CallStackInserter.getInstance().getCallStackUnitTable()
- .selectAllColumnData(null);
- int size = callStackUnits.size();
- for (int i = 0; i < size; i++) {
- List<Object> callStackUnit = callStackUnits.get(i);
- int pid = (Integer) callStackUnit.get(CallStackUnitDBTable.COLUMN.PID.index);
- int functionId = (Integer) callStackUnit
- .get(CallStackUnitDBTable.COLUMN.FUNCTION_ID.index);
- int binaryId = (Integer) callStackUnit.get(CallStackUnitDBTable.COLUMN.BINARY_ID.index);
- long addr = (Long) callStackUnit.get(CallStackUnitDBTable.COLUMN.PC_ADDRESS.index);
- CallStackUnit csa = new CallStackUnit(addr, pid, functionId, binaryId);
- getCallStackApiAddrByPidMap(pid).put(addr, csa);
- }
-
- // open callstack data
- List<List<Object>> callStackData = CallStackInserter.getInstance()
- .getCallStackDataTable().selectAllColumnData(null);
- for (int i = 0; i < callStackData.size(); i++) {
- List<Object> csdata = callStackData.get(i);
- long seq = (Long) csdata
- .get(CallStackDataDBTable.COLUMN.SEQUENCE_NUMBER.index);
- List<Long> addrs = (List<Long>) csdata
- .get(CallStackDataDBTable.COLUMN.ADDRESS_ARRAY.index);
- CallStackData csd = new CallStackData(seq, addrs);
- getCallStackDataBySeqMap().put(seq, csd);
- }
- }
-}
DBConstants.DBTYPE_INT4));
addColumn(new DBColumn(COLUMN.MAINTAG.name, DBConstants.EMPTY,
DBConstants.DBTYPE_BOOLEAN));
+
+ setPrimaryKey(COLUMN.CAPTIME.index, COLUMN.PID.index, COLUMN.BINARYID.index,
+ COLUMN.LOWADDR.index);
}
@Override
}
@Override
- public DAResult sendTraceStartMessage(IProgress progress) throws InterruptedException {
+ public DAResult sendTraceStartMessage(IProgress progress) {
ProtocolSerializer ps = new ProtocolSerializer();
ps.setMessageID(ProtocolConstant30.MSG_START_SWAP);
}
protected DAResult sendIntrumentMessage(boolean isAdd, List<String> paths) {
+ if (paths.isEmpty())
+ return DAResult.SUCCESS;
+
ProtocolSerializer ps = new ProtocolSerializer();
if (isAdd) {
@Override
public DAResult sendUIHierarchyMessage(IProgress progress, int requestOption)
- throws InterruptedException, UnsupportedProtocolException {
+ throws UnsupportedProtocolException {
throw new UnsupportedProtocolException();
}
@Override
public DAResult sendUIScreenshotMessage(IProgress progress, long uiObjectAddress)
- throws InterruptedException, UnsupportedProtocolException {
+ throws UnsupportedProtocolException {
throw new UnsupportedProtocolException();
}
@Override
- public DAResult sendUIHierarchyCancelMessage(IProgress progress) throws InterruptedException,
- UnsupportedProtocolException {
+ public DAResult sendUIHierarchyCancelMessage(IProgress progress)
+ throws UnsupportedProtocolException {
throw new UnsupportedProtocolException();
}
public DAResult sendRealPathMessage(IProgress progress, String path)
- throws InterruptedException, UnsupportedProtocolException {
+ throws UnsupportedProtocolException {
String command = AnalyzerShellCommands.DACOMMAND_READLINK + path;
final List<String> readlinkResult = new ArrayList<String>();
Map<FlatFeature, IProtocolConfig[]> tempMap = new EnumMap<FlatFeature, IProtocolConfig[]>(
FlatFeature.class);
tempMap.put(FlatFeature.CPU_USAGE, new ProtocolConfig30[] { SYSTEM_CPU });
+ tempMap.put(FlatFeature.CPU_USAGE_PER_CORE, new ProtocolConfig30[] { SYSTEM_CPU });
tempMap.put(FlatFeature.SYSTEM_MEMORY, new ProtocolConfig30[] { SYSTEM_MEMORY });
tempMap.put(FlatFeature.PROCESS_MEMORY, new ProtocolConfig30[] { SYSTEM_PROCESS });
tempMap.put(FlatFeature.MEMORY_ALLOC, new ProtocolConfig30[] { INTERNAL_MEMORY_ALLOC });
@Override
public DAResult sendUIHierarchyMessage(IProgress progress, int requestOption)
- throws InterruptedException, UnsupportedProtocolException {
+ throws UnsupportedProtocolException {
ProtocolSerializer ps = new ProtocolSerializer();
ps.setMessageID(ProtocolConstant30_UIHV.MSG_GET_UI_HIERARCHY);
ps.putByte((byte)requestOption);
@Override
public DAResult sendUIScreenshotMessage(IProgress progress, long uiObjectAddress)
- throws InterruptedException, UnsupportedProtocolException {
+ throws UnsupportedProtocolException {
ProtocolSerializer ps = new ProtocolSerializer();
ps.setMessageID(ProtocolConstant30_UIHV.MSG_GET_UI_SCREENSHOT);
ps.putLong(uiObjectAddress);
}
@Override
- public DAResult sendUIHierarchyCancelMessage(IProgress progress) throws InterruptedException,
- UnsupportedProtocolException {
+ public DAResult sendUIHierarchyCancelMessage(IProgress progress)
+ throws UnsupportedProtocolException {
ProtocolSerializer ps = new ProtocolSerializer();
ps.setMessageID(ProtocolConstant30_UIHV.MSG_GET_UI_HIERARCHY_CANCEL);
byte[] msg = ps.toByteArray();
Map<FlatFeature, IProtocolConfig[]> tempMap = new EnumMap<FlatFeature, IProtocolConfig[]>(
FlatFeature.class);
tempMap.put(FlatFeature.CPU_USAGE, new ProtocolConfig30_UIHV[] { SYSTEM_CPU });
+ tempMap.put(FlatFeature.CPU_USAGE_PER_CORE, new ProtocolConfig30_UIHV[] { SYSTEM_CPU });
tempMap.put(FlatFeature.SYSTEM_MEMORY, new ProtocolConfig30_UIHV[] { SYSTEM_MEMORY });
tempMap.put(FlatFeature.PROCESS_MEMORY, new ProtocolConfig30_UIHV[] { SYSTEM_PROCESS });
tempMap.put(FlatFeature.MEMORY_ALLOC, new ProtocolConfig30_UIHV[] { INTERNAL_MEMORY_ALLOC });
import java.util.ArrayList;
import java.util.Collections;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.tizen.dynamicanalyzer.setting.FlatPreferences;
import org.tizen.dynamicanalyzer.setting.SettingDataManager;
import org.tizen.dynamicanalyzer.swap.communicator.SwapErrorCode;
-import org.tizen.dynamicanalyzer.ui.interactive.data.InteractiveDataManager;
-import org.tizen.dynamicanalyzer.ui.interactive.model.InteractiveInfo;
-import org.tizen.dynamicanalyzer.ui.interactive.model.VAR_TYPE;
import org.tizen.dynamicanalyzer.util.Logger;
public class Communicator40 extends Communicator30 {
continue;
}
- if (Global.isGUIMode()) {
- // checkpoints are not supported in CLI mode yet
- addCheckpointsToInstList(functionInstList);
- }
-
// TODO : make sure that first app of package is main app
if (app.equals(curApp)) {
String appType = app.getInfo(AppInfo.PROPERTY.APPTYPE.index);
}
}
- /**
- * Add checkpoints data to function instrumentation list
- *
- * @param functionInstList list of ISerializable objects to add new
- * functions to
- */
- private void addCheckpointsToInstList(
- List<ISerializable> functionInstList) {
- List<FunctionBodyInstrument40> fbiList = getFBIList(InteractiveDataManager
- .getInstance().getVariableInfoList());
- Logger.debug("fbiList.size() : " + fbiList.size());
- for (int i = 0; i < fbiList.size(); i++) {
- FunctionInst40 functionInst = new FunctionInst40();
- functionInst.setAddr(fbiList.get(i).getAddress());
- functionInst.setType(ProtocolConstant40.PROBE_FBI);
- functionInst.setFBI(fbiList.get(i));
- functionInstList.add(functionInst);
- }
- }
-
@Override
protected List<ISerializable> getFunctionInstList(List<AddrSymbolPair> symbols) {
List<ISerializable> functionInstList = new ArrayList<ISerializable>();
return functionInstList;
}
- // get function body instrument list
- protected List<FunctionBodyInstrument40> getFBIList(List<InteractiveInfo> iInfos) {
- // LinkedHashMap maintain the insertion order
- Map<Long, FunctionBodyInstrument40> fbiMap = new LinkedHashMap<Long, FunctionBodyInstrument40>();
-
- for (InteractiveInfo info : iInfos) {
- switch (info.getCheckLocation()) {
- case InteractiveInfo.CHECK_BEFORE_LINE:
- case InteractiveInfo.CHECK_AFTER_LINE:
- FunctionBodyInstrument40 fbi = getFunctionBodyInstrument(fbiMap,
- info.getSourceLineAddress(info.getCheckLocation()));
- makeFBIVariables(info, info.getCheckLocation(), fbi);
- break;
- case InteractiveInfo.CHECK_BEFORE_AFTER_LINE:
- FunctionBodyInstrument40 beforeFBI = getFunctionBodyInstrument(fbiMap,
- info.getSourceLineAddress(InteractiveInfo.CHECK_BEFORE_LINE));
- FunctionBodyInstrument40 afterFBI = getFunctionBodyInstrument(fbiMap,
- info.getSourceLineAddress(InteractiveInfo.CHECK_AFTER_LINE));
- makeFBIVariables(info, InteractiveInfo.CHECK_BEFORE_LINE, beforeFBI);
- makeFBIVariables(info, InteractiveInfo.CHECK_AFTER_LINE, afterFBI);
- break;
- default:
- Logger.error("Impossible case!!");
- break;
- }
- }
-
- List<FunctionBodyInstrument40> fbiList = new ArrayList<FunctionBodyInstrument40>();
- fbiList.addAll(fbiMap.values());
-
- return fbiList;
- }
-
protected FunctionBodyInstrument40 getFunctionBodyInstrument(
Map<Long, FunctionBodyInstrument40> map, long address) {
FunctionBodyInstrument40 fbi = map.get(Long.valueOf(address));
return fbi;
}
- protected void makeFBIVariables(InteractiveInfo info, int checkLocation,
- FunctionBodyInstrument40 fbi) {
- long registerOffset = info.getRegisterOffset();
- byte registerNum = (byte) info.getRegisterID();
- int dataSize = info.getByteSize();
- if (info.isPointerArray()) {
- dataSize = info.getPointerSize() * info.getArrayCount();
- } else if (info.isArray()) {
- dataSize *= info.getArrayCount();
- } else if (info.isString()) {
- dataSize = 0;
- }
-
- // make target variable
- FunctionBodyInstrumentVariable40 targetVariable = new FunctionBodyInstrumentVariable40(
- info.getVariableID(checkLocation), registerOffset, registerNum, dataSize);
- makeFBISteps(info, targetVariable);
- fbi.addVariable(targetVariable);
-
- // make child variable (char * member of struct)
- if (info.getType() == VAR_TYPE.STRUCT) {
- List<InteractiveInfo> children = info.getChildren();
- for (int i = 0; i < children.size(); i++) {
- InteractiveInfo child = children.get(i);
- if (child.isString()) {
- FunctionBodyInstrumentVariable40 childVariable = new FunctionBodyInstrumentVariable40(
- child.getVariableID(checkLocation), registerOffset, registerNum, 0);
- makeFBISteps(child, childVariable);
- fbi.addVariable(childVariable);
- }
- }
- }
- }
-
- protected void makeFBISteps(InteractiveInfo info, FunctionBodyInstrumentVariable40 variable) {
- InteractiveInfo cursorInfo = info;
- while (cursorInfo != null) {
- int pointerOrder = cursorInfo.getPointerOrder();
- if (info.isPointerArray()) {
- pointerOrder = 0; // just request list of pointer address, not value.
- }
- // Add sequence is important. Do not change sequence without consideration.
- if (cursorInfo == info) {
- FunctionBodyInstrumentStep40 step = new FunctionBodyInstrumentStep40(
- (byte) pointerOrder, 0);
- variable.addStep(step);
- }
- InteractiveInfo parentInfo = cursorInfo.getParent();
- if (parentInfo != null) {
- FunctionBodyInstrumentStep40 step = new FunctionBodyInstrumentStep40(
- (byte) parentInfo.getPointerOrder(), cursorInfo.getOffset());
- variable.addStep(step);
- }
- cursorInfo = parentInfo;
- }
- }
-
@Override
public DAResult sendBinaryInfoMessage(IProgress progress, List<String> binPaths) {
ProtocolSerializer ps = new ProtocolSerializer();
@Override
public DAResult sendRealPathMessage(IProgress progress, String path)
- throws InterruptedException, UnsupportedProtocolException {
+ throws UnsupportedProtocolException {
ProtocolSerializer ps = new ProtocolSerializer();
ps.setMessageID(ProtocolConstant40.MSG_GET_REALPATH);
ps.putString(path);
Map<FlatFeature, ProtocolConfig40[]> tempMap = new EnumMap<FlatFeature, ProtocolConfig40[]>(
FlatFeature.class);
tempMap.put(FlatFeature.CPU_USAGE, new ProtocolConfig40[] { SYSTEM_CPU });
+ tempMap.put(FlatFeature.CPU_USAGE_PER_CORE, new ProtocolConfig40[] { SYSTEM_CPU });
tempMap.put(FlatFeature.SYSTEM_MEMORY, new ProtocolConfig40[] { SYSTEM_MEMORY });
tempMap.put(FlatFeature.PROCESS_MEMORY, new ProtocolConfig40[] { SYSTEM_PROCESS });
tempMap.put(FlatFeature.MEMORY_ALLOC, new ProtocolConfig40[] { INTERNAL_MEMORY_ALLOC });
@Override
public DAResult sendUIHierarchyMessage(IProgress progress, int requestOption)
- throws InterruptedException, UnsupportedProtocolException {
+ throws UnsupportedProtocolException {
ProtocolSerializer ps = new ProtocolSerializer();
ps.setMessageID(ProtocolConstant41.MSG_GET_UI_HIERARCHY);
ps.putByte((byte)requestOption);
@Override
public DAResult sendUIScreenshotMessage(IProgress progress, long uiObjectAddress)
- throws InterruptedException, UnsupportedProtocolException {
+ throws UnsupportedProtocolException {
ProtocolSerializer ps = new ProtocolSerializer();
ps.setMessageID(ProtocolConstant41.MSG_GET_UI_SCREENSHOT);
ps.putLong(uiObjectAddress);
}
@Override
- public DAResult sendUIHierarchyCancelMessage(IProgress progress) throws InterruptedException,
- UnsupportedProtocolException {
+ public DAResult sendUIHierarchyCancelMessage(IProgress progress)
+ throws UnsupportedProtocolException {
ProtocolSerializer ps = new ProtocolSerializer();
ps.setMessageID(ProtocolConstant41.MSG_GET_UI_HIERARCHY_CANCEL);
byte[] msg = ps.toByteArray();
Map<FlatFeature, ProtocolConfig41[]> tempMap = new EnumMap<FlatFeature, ProtocolConfig41[]>(
FlatFeature.class);
tempMap.put(FlatFeature.CPU_USAGE, new ProtocolConfig41[] { SYSTEM_CPU });
+ tempMap.put(FlatFeature.CPU_USAGE_PER_CORE, new ProtocolConfig41[] { SYSTEM_CPU });
tempMap.put(FlatFeature.SYSTEM_MEMORY, new ProtocolConfig41[] { SYSTEM_MEMORY });
tempMap.put(FlatFeature.PROCESS_MEMORY, new ProtocolConfig41[] { SYSTEM_PROCESS });
tempMap.put(FlatFeature.MEMORY_ALLOC, new ProtocolConfig41[] { INTERNAL_MEMORY_ALLOC });
PROCESS_MEMORY(PrimitiveFeature.PROCESS_MEMORY),
- MEMORY_ALLOC(PrimitiveFeature.MEMORY_ALLOC),
+ MEMORY_ALLOC(PrimitiveFeature.MEMORY_ALLOC, true),
// Group300 File system
DISK_IO(PrimitiveFeature.DISK_IO),
// Group600 UI
UI_EVENT(PrimitiveFeature.UI_EVENT),
- SCREENSHOT(PrimitiveFeature.SCREENSHOT),
+ SCREENSHOT(PrimitiveFeature.SCREENSHOT, true),
UI_HIERARCHY_ANALYSIS(PrimitiveFeature.UI_HIERARCHY_ANALYSIS), // TODO: Replace constant
private Image overImg = null;
private Image smallImg = null;
private int overheadRanking = 0;
-
+ private boolean isConfigurable = false;
+
+ /**
+ * Constructs new instance of this class with given {@code primitive}
+ * feature.
+ *
+ * @param primitive {@link PrimitiveFeature} instance that will be used for
+ * initialization
+ */
private FlatFeature(PrimitiveFeature primitive) {
this.primitive = primitive;
}
+ /**
+ * Constructs new instance of this class with given {@code primitive}
+ * feature and sets it as configurable depending on {@code configurable}
+ * argument.
+ *
+ * @param primitive {@link PrimitiveFeature} instance that will be used for
+ * initialization
+ * @param configurable whether this feature should be configurable
+ */
+ private FlatFeature(PrimitiveFeature primitive, boolean configurable) {
+ this.primitive = primitive;
+ this.isConfigurable = configurable;
+ }
+
static {
setResources();
this.smallImg = smallImg;
}
+ /**
+ * Checks if feature is configurable.
+ *
+ * @return {@code true} if feature is configurable
+ */
+ public boolean isConfigurable() {
+ return isConfigurable;
+ }
+
public int getIndex() {
return primitive.getIndex();
}
}
/**
+ * Gets value of specified {@code preference}.
+ *
+ * @param preference {@link FlatPreferences} enum value
+ * @param defaultValue whether default value should be returned
+ * @return value of {@code preference} if it is selected or its default
+ * value if it is not selected of {@code defaultValue} is set to
+ * {@code true}, if {@code preference} is {@code null} then
+ * {@code -1} is returned
+ */
+ public int getPreferenceValue(FlatPreferences preference, boolean defaultValue) {
+ if (preference == null)
+ return -1;
+
+ return !defaultValue && isPreferenceSelected(preference)
+ ? preference.getValue()
+ : preference.getDefaultValue();
+ }
+
+ /**
* Adds given {@code preference} to a list of selected preferences.
*
* @param preference {@link FlatPreferences} enum value
}
/**
+ * Checks whether given {@code preference} is selected.
+ *
+ * @param preference {@link FlatPreferences} enum value
+ * @param defaultValue whether default value should be returned
+ * @return {@code true} if {@code preference} is selected
+ */
+ public boolean isPreferenceSelected(FlatPreferences preference, boolean defaultValue) {
+ return defaultValue
+ ? (getPreferenceValue(preference, true) != 0)
+ : optionsSelectedPreferenceList.contains(preference);
+ }
+
+ /**
* Sets specified {@code preference} as selected.
*
* @param preference {@link FlatPreferences} object
import org.tizen.dynamicanalyzer.common.Global;
import org.tizen.dynamicanalyzer.common.SymbolManager;
import org.tizen.dynamicanalyzer.communicator.DeviceInfo;
-import org.tizen.dynamicanalyzer.communicator.UnsupportedProtocolException;
import org.tizen.dynamicanalyzer.control.DataThread;
import org.tizen.dynamicanalyzer.nl.InformationViewLabels;
import org.tizen.dynamicanalyzer.protocol.ProtocolConstants;
import org.tizen.dynamicanalyzer.swap.model.data.ProfileData;
import org.tizen.dynamicanalyzer.swap.model.data.ScreenShotData;
import org.tizen.dynamicanalyzer.swap.model.data.WebProfileData;
-import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackInserter;
import org.tizen.dynamicanalyzer.ui.info.screenshot.SocketClient;
import org.tizen.dynamicanalyzer.ui.summary.profiling.FunctionUsageProfiler;
import org.tizen.dynamicanalyzer.ui.summary.profiling.WebProfileDataMaker;
}
} finally {
DataManagerRegistry.updateLog(LogPackage.END_OF_QUEUE);
- CallStackInserter.getInstance().pushData(CallStackInserter.END_OF_QUEUE);
}
Logger.debug("log parsing thread end!!"); //$NON-NLS-1$
switch (id) {
case ProtocolConstants.MSG_FUNCTION_ENTRY:
case ProtocolConstants.MSG_FUNCTION_EXIT:
- ret = processFunctionData((ProfileData) log);
- if (ret) {
- packLog(log, logPack);
- }
+ processFunctionData((ProfileData) log);
+ packLog(log, logPack);
break;
case ProtocolConstants.MSG_SYSCALL_ENTRY: // protocol 4.0
case ProtocolConstants.MSG_SYSCALL_EXIT: // protocol 4.0
// Currently, an only message that got to default section is
// MSG_PROBE_LIFECYCLE = 0x0105
packLog(log, logPack);
- Global.getRuntimeCallstackManager().makeCallstackWithoutBacktrace(log);
break;
}
}
updateLog(logPack);
}
- private boolean processFunctionData(ProfileData pData) {
- int msgID = pData.getMsgID();
- Deque<Long> functionStack = getFunctionEntryStack(pData.getTid());
-
- // entry / exit pair matching
- if (msgID == ProtocolConstants.MSG_FUNCTION_ENTRY) {
- functionStack.addLast(pData.getSeq());
- } else { // msg_function_exit
- if (!functionStack.isEmpty()) {
- pData.setEntrySeq(functionStack.removeLast());
- } else { // size <= 0 : bug (exit without entry)
- Logger.error("function exit log without entry log");
- }
- }
-
+ /**
+ * Identify function name and id and save it inside {@code pData}. It is
+ * identified by PC address, pid and time. Identification performed
+ * correctly only for functions from profiled binaries.
+ *
+ * @param pData ProfileData
+ */
+ private void processFunctionData(ProfileData pData) {
boolean bMakeCallstack = true;
- try {
- if (pData.getProbeType() == ProtocolConstants.FUNCTION_TYPE_FILE) {
- bMakeCallstack = false;
- } else if (pData.getProbeType() == ProtocolConstants.FUNCTION_TYPE_SYSCALL) {
- // do not make callstack with system call log
- bMakeCallstack = false;
- } else {
- bMakeCallstack = true;
- }
- } catch (UnsupportedProtocolException e) {
- bMakeCallstack = true;
+ if (pData.getProbeType() == ProtocolConstants.FUNCTION_TYPE_FILE
+ || pData.getProbeType() == ProtocolConstants.FUNCTION_TYPE_SYSCALL) {
+ bMakeCallstack = false;
}
if (bMakeCallstack) {
int apiID = SymbolManager.getFuncId(pData, pData.getPcAddr(), pData.getPid(),
pData.getTime());
if (apiID < 0) {
- return false;
+ return;
} else {
String apiName = Global.getFunctionName(apiID);
- if (apiName.equals(InformationViewLabels.CALLSTACK_TABLE_UNKNOWN_FUNCTION)) {
- return false;
- } else {
+ if (!apiName.equals(InformationViewLabels.CALLSTACK_TABLE_UNKNOWN_FUNCTION)) {
pData.setApiId(apiID);
}
}
-
- Global.getRuntimeCallstackManager().makeUserCallstack(pData,
- FunctionUsageProfiler.getInstance().getProfileDataMakerByPid(pData.getPid()));
}
-
- return true;
+ FunctionUsageProfiler.getInstance().getProfileDataMakerByPid(pData.getPid())
+ .prepareFUPDataForCallTrace(pData);
}
private boolean processWebFunctionData(WebProfileData pData) {
case ProtocolConstants.MSG_FUNCTION_ENTRY:
case ProtocolConstants.MSG_FUNCTION_EXIT:
ProfileData fData = (ProfileData) logData;
- try {
- if (fData.getProbeType() == ProtocolConstants.FUNCTION_TYPE_FILE) {
- logPack.setLogs(ProtocolConstants.MSG_FUNCTION_ENTRY_EXIT, logData);
- } else {
- logPack.setLogs(logData.getMsgID(), logData);
- }
- } catch (UnsupportedProtocolException e) {
+ if (fData.getProbeType() == ProtocolConstants.FUNCTION_TYPE_FILE) {
+ logPack.setLogs(ProtocolConstants.MSG_FUNCTION_ENTRY_EXIT, logData);
+ } else {
logPack.setLogs(logData.getMsgID(), logData);
}
break;
import org.tizen.dynamicanalyzer.swap.model.data.MemoryMapData;
import org.tizen.dynamicanalyzer.swap.model.data.ProcessAddInfoData;
import org.tizen.dynamicanalyzer.swap.model.data.ProcessInfoData;
-import org.tizen.dynamicanalyzer.ui.memory.data.HeapDataManager;
+import org.tizen.dynamicanalyzer.ui.memory.data.LsanDataManager;
import org.tizen.dynamicanalyzer.ui.thread.data.ThreadDataManager;
import org.tizen.dynamicanalyzer.util.Logger;
import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
AnalyzerManager.waitStartAck.wait();
}
} catch (InterruptedException e) {
- Logger.exception(e);
+ Logger.debug("Interrupted while waiting for trace start aknowledge message: "
+ + e.getLocalizedMessage());
+ Thread.currentThread().interrupt();
return;
}
}
case ProtocolConstants.MSG_PROCESS_MAP:
case ProtocolConstants.MSG_PROCESS_UNMAP:
try {
- memoryMapChanged(log);
+ memoryMapChanged(log);
}
catch (Exception ex) {}
break;
Logger.debug("Pulled LeakSanitizer report file: " + source);
// Pass pulled file to HeapDataManager
- HeapDataManager.getInstance().parseLSanReportFile(destination);
+ LsanDataManager.getInstance().parseLSanReportFile(destination);
break;
case ERROR:
}
}
+ /**
+ * Process process memory map message.
+ */
private void processProcessInfo(LogData plog) {
Project project = Global.getProject();
ProcessInfoData log = (ProcessInfoData) plog;
ProcessInformation pinfo = project.getProcessInformation(pid);
if (null == pinfo) {
pinfo = new ProcessInformation();
-
+
int ppid = log.getPpid();
-
+
pinfo.setPid(pid);
pinfo.setPpid(ppid);
pinfo.setStartTime(starttime);
pinfo.setProcessName(log.getCmdname());
-
+
project.putProcessInformation(pinfo);
pinfo.setDropLog(true);
}
- pinfo.setMappingState(true);
// make process memory map of the moment
ProcessMemoryMap pMap = new ProcessMemoryMap(pinfo.getPid(), starttime);
ThreadDataManager.getInstance().getThreadDataMaker().createMainThreadItem(pid);
}
+ /**
+ * Process memory map/unmap messages.
+ */
private void memoryMapChanged(LogData plog) {
Project project = Global.getProject();
MemoryMapData log = (MemoryMapData) plog;
int pid = log.getPid();
ProcessInformation pinfo = project.getProcessInformation(pid);
if (null == pinfo) {
- // bug!!!
- Logger.error("bug occurred!!");
+ // it shouldn't happen
+ Logger.error("Memory map changed before process memory info arrived.");
return;
}
ProcessMemoryMap lastMap = pinfo.getLastProcessMemoryMap();
- if (lastMap != null) {
- int msgID = log.getMsgID();
- long lowAddr = log.getLowAddr();
- long highAddr = log.getHighAddr();
-
- if (msgID == ProtocolConstants.MSG_PROCESS_MAP) {
- // update to last memory map
- String libPath = log.getLibPath();
-
- BinaryInfo bininfo = project.getDeviceStatusInfo().getBinaryInfo(libPath);
- LibraryObject libObj = new LibraryObject(bininfo.getID(), lowAddr, highAddr);
- if (!lastMap.addLibraryMap(libObj)) {
- Logger.error("exist library(%d, %d, %s)", lowAddr, highAddr, libPath);
- } else {
- Logger.debug("map library(%d, %d, %s)", lowAddr, highAddr, libPath);
- }
+ int msgID = log.getMsgID();
+ long lowAddr = log.getLowAddr();
+ long highAddr = log.getHighAddr();
- pinfo.setMappingState(true);
- } else {
- if (pinfo.isMapping()) {
- // make new memory map
- ProcessMemoryMap newMap = new ProcessMemoryMap(pinfo.getPid(), log.getTime());
- pinfo.addProcessMemoryMap(newMap);
- newMap.copy(lastMap);
-
- // remove from new map
- newMap.removeLibrary(lowAddr, highAddr);
- } else {
- // update captured time of last memory map
- pinfo.updateProcessMemoryMap(lastMap, log.getTime());
-
- // remove from map
- lastMap.removeLibrary(lowAddr, highAddr);
- }
+ // make new memory map
+ ProcessMemoryMap newMap = new ProcessMemoryMap(pinfo.getPid(), log.getTime());
+
+ newMap.copy(lastMap);
- Logger.debug("unmap library(%d, %d)", lowAddr, highAddr);
+ if (msgID == ProtocolConstants.MSG_PROCESS_MAP) {
+ // update to last memory map
+ String libPath = log.getLibPath();
- pinfo.setMappingState(false);
+ BinaryInfo bininfo = project.getDeviceStatusInfo().getBinaryInfo(libPath);
+ LibraryObject libObj = new LibraryObject(bininfo.getID(), lowAddr, highAddr);
+ if (!newMap.addLibraryMap(libObj)) {
+ Logger.error("library mapping overlap (%d, %d, %s)", lowAddr, highAddr, libPath);
+ } else {
+ pinfo.addProcessMemoryMap(newMap);
+ Logger.debug("map library (%d, %d, %s)", lowAddr, highAddr, libPath);
+ }
+ } else {
+ // remove from new map
+ if (!newMap.removeMapping(lowAddr, highAddr)) {
+ Logger.info("nothing to unmap in range (%d, %d)", lowAddr, highAddr);
+ } else {
+ pinfo.addProcessMemoryMap(newMap);
+ Logger.debug("unmapped memory map (%d, %d)", lowAddr, highAddr);
}
}
}
this.callerPcAddr = callerPcAddr;
}
- public int getProbeType() throws UnsupportedProtocolException {
- if (protocolVersion == Protocol.VERSION_30 || protocolVersion == Protocol.VERSION_30A
- || protocolVersion == Protocol.VERSION_30_UIHV) {
- return probeType;
- } else {
- throw new UnsupportedProtocolException();
- }
- }
-
- public void setProbeType(int probeType) {
- this.probeType = probeType;
+ public int getProbeType() {
+ return probeType;
}
public int getProbeSubType() throws UnsupportedProtocolException {
--- /dev/null
+package org.tizen.dynamicanalyzer.ui.common;
+
+import java.util.List;
+
+import org.tizen.dynamicanalyzer.common.AnalyzerManager;
+import org.tizen.dynamicanalyzer.common.DASelectionData;
+import org.tizen.dynamicanalyzer.constant.CommonConstants;
+import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
+import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
+import org.tizen.dynamicanalyzer.widgets.chart.DAChart;
+import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotIntervalMarker;
+import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenu;
+import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuItem;
+import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuListener;
+import org.tizen.dynamicanalyzer.widgets.timeline.MarkerManager;
+
+/**
+ * Default pop-up menu for charts. Consists of one default menu item - 'Select range'.
+ *
+ * @author d.nikiforov
+ */
+public class ChartPopupMenu extends DAPopupMenu {
+
+ /**
+ * Creates a new instance of pop-up menu given its parent chart.
+ *
+ * @param parent {@link DAChart} instance
+ */
+ public ChartPopupMenu(DAChart parent) {
+ super(parent);
+
+ DAPopupMenuItem selectRangeItem = new DAPopupMenuItem(this);
+ selectRangeItem.setText(AnalyzerLabels.SELECT_RANGE);
+ selectRangeItem.addListener(new DAPopupMenuListener() {
+ @Override
+ public void widgetSelected(DAPopupMenuItem menuItem) {
+ setRangeFromMarkerList(menuItem.getDoubleData());
+ }
+ });
+ }
+
+ /**
+ * Selects range between range markers with specified {@code time}. If {@code time} equals to
+ * the time of one of the markers or if there are no markers then current selection will not be
+ * changed.
+ *
+ * @param time time within selected range
+ */
+ private void setRangeFromMarkerList(double time) {
+ List<Double> markers = MarkerManager.INSTANCE.getMarkerTimeList();
+
+ if (markers.isEmpty() || markers.contains(time))
+ return;
+
+ int findIndex = -1;
+
+ for (int i = 0; i < markers.size(); i++) {
+ if (markers.get(i) > time) {
+ findIndex = i;
+ break;
+ }
+ }
+
+ double startTime;
+ double endTime;
+ DAChart parentChart = (DAChart) getParent();
+
+ if (findIndex == 0) {
+ startTime = 0;
+ endTime = markers.get(findIndex);
+ } else if (findIndex == -1) {
+ startTime = markers.get(markers.size() - 1);
+ endTime = parentChart.getPlot().getValidEndX();
+ } else {
+ startTime = markers.get(findIndex - 1);
+ endTime = markers.get(findIndex);
+ }
+
+ DAChartPlotIntervalMarker intervalMarker = (DAChartPlotIntervalMarker) parentChart.getPlot()
+ .getMarkers().get(0);
+ intervalMarker.setInterval(startTime, endTime);
+
+ AnalyzerManager.getCurrentPage().updateView(
+ new DASelectionData(CommonConstants.EMPTY,
+ (long) (startTime * TimelineConstants.MEGA_DOUBLE),
+ (long) (endTime * TimelineConstants.MEGA_DOUBLE), null, null));
+ }
+}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jungwook Ryu <jungwook.ryu@samsung.com>
- * yeongtaik byeon <yeongtaik.byeon@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.common;
-
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuItem;
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuListener;
-
-public class PopupAnalysisMenuItemClickListener extends DAPopupMenuListener {
-
- @Override
- public void widgetSelected(DAPopupMenuItem menuItem) {
- // TODO Auto-generated method stub
- RangeDataManager.getInstance().startRangeAnalysis();
- }
-
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jungwook Ryu <jungwook.ryu@samsung.com>
- * yeongtaik byeon <yeongtaik.byeon@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.common;
-
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuItem;
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuListener;
-
-public class PopupClearMenuItemClickListener extends DAPopupMenuListener {
-
- @Override
- public void widgetSelected(DAPopupMenuItem menuItem) {
- // TODO Auto-generated method stub
- RangeDataManager.getInstance().initRange();
- }
-
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jungwook Ryu <jungwook.ryu@samsung.com>
- * yeongtaik byeon <yeongtaik.byeon@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.common;
-
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
-import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotIntervalMarker;
-import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoard;
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuItem;
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuListener;
-
-public class PopupEndMenuItemClickListener extends DAPopupMenuListener {
- private DAPopupMenuItem endItem;
- private DAChartBoard chartBoard;
- private RangeDataManager rangeDataManager = RangeDataManager.getInstance();
-
- public PopupEndMenuItemClickListener(DAPopupMenuItem item, DAChartBoard board){
- endItem = item;
- chartBoard = board;
- }
-
- @Override
- public void widgetSelected(DAPopupMenuItem menuItem) {
- double endTime = endItem.getDoubleData();
- rangeDataManager
- .setMarkerEndTime((long) (endTime * TimelineConstants.MEGA_DOUBLE));
-
- double startTime = rangeDataManager.getMarkerStartTime()
- / TimelineConstants.MEGA_DOUBLE;
-
-
- ((DAChartPlotIntervalMarker) chartBoard.getMarkers().get(
- UICommonConstants.RANGE_MARKER_INDEX)).setInterval(startTime,
- endTime);
- }
-
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jungwook Ryu <jungwook.ryu@samsung.com>
- * yeongtaik byeon <yeongtaik.byeon@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.common;
-
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
-import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotIntervalMarker;
-import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoard;
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuItem;
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuListener;
-
-public class PopupFromSelectionMenuItemClickListener extends
- DAPopupMenuListener {
- private DAChartBoard chartBoard;
- private RangeDataManager rangeDataManager = RangeDataManager.getInstance();
-
- public PopupFromSelectionMenuItemClickListener(DAPopupMenuItem item,
- DAChartBoard board) {
- chartBoard = board;
- }
-
- @Override
- public void widgetSelected(DAPopupMenuItem menuItem) {
- // TODO Auto-generated method stub
- double startTime = ((DAChartPlotIntervalMarker) chartBoard.getMarkers()
- .get(UICommonConstants.SELECTION_MARKER_INDEX)).getStartVal();
- double endTime = ((DAChartPlotIntervalMarker) chartBoard.getMarkers()
- .get(UICommonConstants.SELECTION_MARKER_INDEX)).getEndVal();
- double temp;
-
- if (startTime > endTime) {
- temp = startTime;
- startTime = endTime;
- endTime = temp;
- }
- rangeDataManager
- .setMarkerStartTime((long) (startTime * TimelineConstants.MEGA_DOUBLE));
- rangeDataManager
- .setMarkerEndTime((long) (endTime * TimelineConstants.MEGA_DOUBLE));
- ((DAChartPlotIntervalMarker) chartBoard.getMarkers().get(
- UICommonConstants.RANGE_MARKER_INDEX)).setInterval(startTime,
- endTime);
- }
-
-}
+++ /dev/null
-package org.tizen.dynamicanalyzer.ui.common;\r
-\r
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;\r
-import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;\r
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuItem;\r
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuListener;\r
-\r
-public class PopupRangeAnalysisMenuItemListener extends DAPopupMenuListener {\r
-\r
- @Override\r
- public void widgetSelected(DAPopupMenuItem menuItem) {\r
- double time = menuItem.getDoubleData();\r
- RangeDataManager.getInstance().setRangeFromMarkerList((long) (time * TimelineConstants.MEGA_DOUBLE));\r
- }\r
-\r
-}\r
+++ /dev/null
-/**
- *
- */
-package org.tizen.dynamicanalyzer.ui.common;
-
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
-import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
-import org.tizen.dynamicanalyzer.util.Logger;
-import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChart;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotIntervalMarker;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotMarker;
-import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoard;
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuItem;
-
-public class PopupRangeAnalysisMenuItemOnChartListener extends PopupRangeAnalysisMenuItemListener {
-
- DAChartBoard chartBoard;
- DAChart chart;
-
- public PopupRangeAnalysisMenuItemOnChartListener(DAPopupMenuItem item, DAChartBoard chartBoard, DAChart chart) {
- this.chartBoard = chartBoard;
- this.chart = chart;
- }
-
- @Override
- public void widgetSelected(DAPopupMenuItem menuItem) {
- double time = menuItem.getDoubleData();
- RangeDataManager.getInstance().setRangeFromMarkerList((long) (time * TimelineConstants.MEGA_DOUBLE));
-
- DAChartPlotMarker marker = chart.getPlot().getMarkers().get(0);
- // Check type of marker before cast to prevent ClassCastException in runtime
- if (marker instanceof DAChartPlotIntervalMarker) {
- DAChartPlotIntervalMarker intervalMarker = (DAChartPlotIntervalMarker) marker;
- double startVal = RangeDataManager.getInstance().getMarkerStartTime();
- double endVal = RangeDataManager.getInstance().getMarkerEndTime();
- intervalMarker.setInterval(startVal / TimelineConstants.MEGA_DOUBLE,
- endVal / TimelineConstants.MEGA_DOUBLE);
-
- AnalyzerUtil.getMainTab().getTopComposite().callUpdatePage(chartBoard.getSelectItem());
- }
- else {
- Logger.error(
- "Chart plot marker is not of type DAChartPlotIntervalMarker but " + marker.getClass().getName());
- }
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jungwook Ryu <jungwook.ryu@samsung.com>
- * yeongtaik byeon <yeongtaik.byeon@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.common;
-
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
-import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotIntervalMarker;
-import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoard;
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuItem;
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuListener;
-
-public class PopupStartMenuItemClickListener extends DAPopupMenuListener {
- private DAPopupMenuItem startItem;
- private DAChartBoard chartBoard;
- private RangeDataManager rangeDataManager = RangeDataManager.getInstance();
-
- public PopupStartMenuItemClickListener(DAPopupMenuItem item, DAChartBoard board){
- startItem = item;
- chartBoard = board;
- }
-
- @Override
- public void widgetSelected(DAPopupMenuItem menuItem) {
- // TODO Auto-generated method stub
- double startTime = startItem.getDoubleData();
- rangeDataManager
- .setMarkerStartTime((long) (startTime * TimelineConstants.MEGA_DOUBLE));
-
- double endTime = rangeDataManager.getMarkerEndTime()
- / TimelineConstants.MEGA_DOUBLE;
-
- ((DAChartPlotIntervalMarker) chartBoard.getMarkers().get(
- UICommonConstants.RANGE_MARKER_INDEX)).setInterval(startTime,
- endTime);
- }
-
-}
import org.tizen.dynamicanalyzer.common.AnalyzerManager;
import org.tizen.dynamicanalyzer.common.DASelectionData;
import org.tizen.dynamicanalyzer.ui.info.screenshot.ScreenshotDialog;
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
import org.tizen.dynamicanalyzer.ui.timeline.TimelinePage;
import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
import org.tizen.dynamicanalyzer.widgets.chart.DAUIEventChartPlot;
import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoard;
import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenu;
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuItem;
import org.tizen.dynamicanalyzer.widgets.timeline.DATimeline;
import org.tizen.dynamicanalyzer.widgets.timeline.MarkerManager;
public class TimelineChartMouseEventListener extends MouseAdapter implements MouseMoveListener {
- protected RangeDataManager rangeDataManager = RangeDataManager.getInstance();
protected DAPopupMenu menu;
protected DATimeline timeline;
protected double baseTime = TimelineConstants.NOT_INITED;
double eventTime = plot.getXFromXPixel(e.x);
if (e.button == 3) {
- List<DAPopupMenuItem> itemList = menu.getItems();
- for(DAPopupMenuItem item : itemList) {
- item.setDoubleData(eventTime);
- }
+ if (menu != null)
+ menu.getItems().forEach((item) -> item.setDoubleData(eventTime));
return;
}
public static Color RANGE_MARKING_COLOR = ColorResources.YELLOW;
public final static int SELECTION_MARKER_INDEX = 0;
- public final static int RANGE_ANALYSIS_MARKER_INDEX = 1;
- public final static int RANGE_MARKER_INDEX = 2;
}
import org.tizen.dynamicanalyzer.logparser.LogCenterConstants;
import org.tizen.dynamicanalyzer.model.FilterProperty;
import org.tizen.dynamicanalyzer.model.TableInput;
-import org.tizen.dynamicanalyzer.swap.model.data.FileData;
import org.tizen.dynamicanalyzer.ui.file.data.FileAccessorDB;
import org.tizen.dynamicanalyzer.ui.file.data.FileApiDB;
import org.tizen.dynamicanalyzer.ui.file.manager.FileDataManager;
import org.tizen.dynamicanalyzer.ui.file.model.FileAccessor;
import org.tizen.dynamicanalyzer.ui.file.model.FileEvent;
import org.tizen.dynamicanalyzer.ui.file.model.FileSelectedData;
-import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
import org.tizen.dynamicanalyzer.ui.widgets.table.DAApiListTableComposite;
import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat;
import org.tizen.dynamicanalyzer.util.Logger;
return errMsg;
}
- protected void actionSetStartEnd(int type) {
- GridItem item = table.getItem(mousePoint);
- if (null != item) {
- FileData data = (FileData) ((DATableDataFormat) item.getData()).getLogData();
- long time = data.getTime();
- double startTime = -1;
- double endTime = -1;
-
- if (type == START_TIME) {
- rangeDataManager.setMarkerStartTime(time);
- startTime = time / TimelineConstants.MEGA_DOUBLE;
- endTime = rangeDataManager.getMarkerEndTime() / TimelineConstants.MEGA_DOUBLE;
-
- } else if (type == END_TIME) {
- rangeDataManager.setMarkerEndTime(time);
- endTime = time / TimelineConstants.MEGA_DOUBLE;
- startTime = rangeDataManager.getMarkerStartTime() / TimelineConstants.MEGA_DOUBLE;
- }
-
- FileChartView chartview = (FileChartView) (AnalyzerManager.getCurrentPage().getView(FilePage.chartViewID));
- if (chartview != null) {
- chartview.setRangeMarker(startTime, endTime);
- }
- }
- }
-
public boolean[] getColumnVisibility() {
if (null == table)
return null;
import org.tizen.dynamicanalyzer.resources.ColorResources;
import org.tizen.dynamicanalyzer.ui.file.manager.FileDataManager;
import org.tizen.dynamicanalyzer.ui.file.model.FileSelectedData;
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
import org.tizen.dynamicanalyzer.ui.widgets.DAAdvancedViewComposite;
import org.tizen.dynamicanalyzer.widgets.da.view.DAViewData;
private long analysisStartTime = 0;
private long analysisEndTime = 0;
private int preSelectionPId = 1;
- private long preAnalysisStartTime = 0;
- private long preAnalysisEndTime = 0;
private FileSelectedData selectedData = null;
private String[] columnNames = { FilePageLabels.FILE_API_LIST_VIEW_INDEX,
isUpdate = true;
}
preSelectionPId = selectedPid;
-
- // if analyzer is changed, set the start and end time with changed
- // analyzer and update table
- long newAnalysisStartTime = 0;
- long newAnalysisEndTime = 0;
- if (RangeDataManager.getInstance().isBeingAnalyzed()) {
- newAnalysisStartTime = RangeDataManager.getInstance()
- .getAnalysisStartTime();
- newAnalysisEndTime = RangeDataManager.getInstance()
- .getAnalysisEndTime();
- } else {
- newAnalysisStartTime = 0;
- newAnalysisEndTime = 0;
- }
- if (newAnalysisStartTime != preAnalysisStartTime
- || newAnalysisEndTime != preAnalysisEndTime) {
- preAnalysisStartTime = newAnalysisStartTime;
- preAnalysisEndTime = newAnalysisEndTime;
- isUpdate = true;
- }
-
- // if new event is put from swap, update table
- /*int newTotal = manager.getApiDB().getTotal();
- if(tableComp.getTable().getItemCount() > 0 && newTotal > currentTotal) {
- manager.setSelectedData(selectedData);
- isUpdate = true;
- }*/
return isUpdate;
}
import org.tizen.dynamicanalyzer.communicator.DACommunicator;
import org.tizen.dynamicanalyzer.constant.CommonConstants;
import org.tizen.dynamicanalyzer.nl.FilePageLabels;
-import org.tizen.dynamicanalyzer.nl.TimelineChartLabels;
import org.tizen.dynamicanalyzer.resources.ColorResources;
import org.tizen.dynamicanalyzer.resources.FontResources;
import org.tizen.dynamicanalyzer.resources.ImageResources;
-import org.tizen.dynamicanalyzer.ui.common.PopupRangeAnalysisMenuItemOnChartListener;
+import org.tizen.dynamicanalyzer.ui.common.ChartPopupMenu;
import org.tizen.dynamicanalyzer.ui.common.TimeLineChartKeyListener;
import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseEventListener;
import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseTrackAdapter;
import org.tizen.dynamicanalyzer.widgets.chart.DAChartSeries;
import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoardItem;
import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenu;
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuItem;
public class FileChartBoard extends DADefaultChartBoard {
private List<FileChart> chartList = new ArrayList<FileChart>();
tooltip.setFont(FontResources.CHART_TOOLTIP_FONT);
plot.setTooltip(tooltip);
- DAPopupMenu popupMenu = new DAPopupMenu(chart);
+ DAPopupMenu popupMenu = new ChartPopupMenu(chart);
popupMenu.setFont(FontResources.CONTEXT_MENU_ITEM_FONT);
-
- DAPopupMenuItem analysisItem = new DAPopupMenuItem(popupMenu);
- analysisItem.setText(TimelineChartLabels.RANGE_CONTEXT_ANALYSIS);
- analysisItem.addListener(new PopupRangeAnalysisMenuItemOnChartListener(analysisItem, this, chart));
TimelineChartMouseEventListener timelineChartMouseEventListener =
new TimelineChartMouseEventListener(
import org.tizen.dynamicanalyzer.ui.common.UICommonConstants;
import org.tizen.dynamicanalyzer.ui.file.manager.FileDataManager;
import org.tizen.dynamicanalyzer.ui.page.BaseView;
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
import org.tizen.dynamicanalyzer.ui.timeline.logparser.LifecycleLogParser;
import org.tizen.dynamicanalyzer.ui.toolbar.DAToolBarCustomCombo;
private DAToolBarCustomCombo processCombo;
- private final RangeDataManager rangeDataManager = RangeDataManager.getInstance();
private FileDataManager chartManager = FileDataManager.getInstance();
public FileChartView(Composite parent, int style) {
} else {
fileChartBoard.setTotalEndTime(Toolbar.INSTANCE.getTime(), false);
}
-
- if (RangeDataManager.getInstance().isBeingAnalyzed()) {
- ((DAChartPlotIntervalMarker) fileChartBoard.getMarkers().get(UICommonConstants.RANGE_ANALYSIS_MARKER_INDEX))
- .setInterval(rangeDataManager.getAnalysisStartTime() / TimelineConstants.MEGA_DOUBLE,
- rangeDataManager.getAnalysisEndTime() / TimelineConstants.MEGA_DOUBLE);
- } else {
- ((DAChartPlotIntervalMarker) fileChartBoard.getMarkers().get(UICommonConstants.RANGE_ANALYSIS_MARKER_INDEX))
- .setInterval(-1, -1);
- }
-
- ((DAChartPlotIntervalMarker) fileChartBoard.getMarkers().get(UICommonConstants.RANGE_MARKER_INDEX)).setInterval(
- rangeDataManager.getMarkerStartTime() / TimelineConstants.MEGA_DOUBLE,
- rangeDataManager.getMarkerEndTime() / TimelineConstants.MEGA_DOUBLE);
-
}
@Override
selectionMarker.setBackgroundColor(ColorResources.SELECTION_RANGE);
selectionMarker.setAlpha((int) (255 * 0.25));
board.addIntervalMarker(selectionMarker);
-
- // range analysis marker
- DAChartPlotIntervalMarker rangeAnalyzeMarker = new DAChartPlotIntervalMarker(-1, -1,
- DAChartPlotIntervalMarker.INTERVAL_MARKER_STYLE_AREA);
- rangeAnalyzeMarker.setBackgroundColor(ColorResources.YELLOW);
- rangeAnalyzeMarker.setAlpha((int) (255 * 0.25));
- board.addIntervalMarker(rangeAnalyzeMarker);
-
- // range marker
- DAChartPlotIntervalMarker rangeMarker = new DAChartPlotIntervalMarker(-1, -1,
- DAChartPlotIntervalMarker.INTERVAL_MARKER_STYLE_LINE);
- rangeMarker.setForegroundColor(ColorResources.RED);
- rangeMarker.setAlpha((int) (255 * 0.25));
- board.addIntervalMarker(rangeMarker);
- }
-
- public void setRangeMarker(double starttime, double endtime) {
- ((DAChartPlotIntervalMarker) fileChartBoard.getMarkers().get(UICommonConstants.RANGE_MARKER_INDEX))
- .setInterval(starttime, endtime);
}
public DAChartBoard getChartBoard() {
this.setData(KEY_TOOLTIP, ShortCutManager.COOLBAR_AREA_FILE_TOOLTIP);
this.setBackground(ColorResources.WHITE);
this.setLayout(new FillLayout());
-
-// ((FillLayout) getLayout()).marginHeight = 0;
-// ((FillLayout) getLayout()).marginWidth = 0;
FileChartView fileChartView = new FileChartView(topForm, SWT.NONE);
addView(fileChartView);
fileAPITableView = new DATabComposite(bottomLeftForm, SWT.NONE, false, true);
{
+ fileAPITableView.setID(AnalyzerLabels.LEFT_TABLE_VIEW_ID);
FileApiListView fileApiListView = new FileApiListView(fileAPITableView.getContentComposite(), SWT.NONE);
fileAPITableView.addView(fileApiListView);
- addView(fileApiListView);
}
addView(fileAPITableView);
-
+
fileDetailTableView = new DATabComposite(bottomRightForm, SWT.NONE, false, true);
- {
+ {
+ fileDetailTableView.setID(AnalyzerLabels.RIGHT_TABLE_VIEW_ID);
FileDetailInfoView fileDetailInfoView = new FileDetailInfoView(fileDetailTableView.getContentComposite(), SWT.NONE);
fileDetailTableView.addView(fileDetailInfoView);
- addView(fileDetailInfoView);
}
addView(fileDetailTableView);
}
import org.tizen.dynamicanalyzer.model.TableInput;
import org.tizen.dynamicanalyzer.nl.InformationViewLabels;
import org.tizen.dynamicanalyzer.swap.model.data.AppStartupData;
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineTableView;
import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
import org.tizen.dynamicanalyzer.ui.widgets.table.DATableComposite;
@Override
public void widgetSelected(SelectionEvent e) {
AnalyzerManager.getCurrentPage().updateView(
- new DAViewData(TimelineTableView.tabID, null));
+ new DAViewData(TimelineTableView.appStartupViewID, null));
GridItem[] sels = table.getSelection();
if (sels.length > 0) {
table.setFocusItem(sels[0]);
tableInput.setText(contentText);
tableInput.setData(tableData);
input.add(tableInput);
-
- if (RangeDataManager.getInstance().isBeingAnalyzed()) {
- long analysisStartTime = RangeDataManager.getInstance()
- .getAnalysisStartTime();
- long analysisEndTime = RangeDataManager.getInstance()
- .getAnalysisEndTime();
- if (startTime >= analysisStartTime && startTime <= analysisEndTime) {
- tableInput.setInRange(true);
- }
- }
}
return input;
addColumn(new DBColumn(COLUMN.RESOURCE_PATH.name, DBConstants.EMPTY,
DBConstants.DBTYPE_VARCHAR, DALimit.FILEPATH_LENGTH));
addColumn(new DBColumn(COLUMN.TIME.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
- setIndexColumn(COLUMN.TIME.index);
+ addIndex(COLUMN.TIME.index);
}
@Override
import org.tizen.dynamicanalyzer.model.TableInput;
import org.tizen.dynamicanalyzer.nl.InformationViewLabels;
import org.tizen.dynamicanalyzer.swap.model.data.WebAppStartupData;
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineTableView;
import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
import org.tizen.dynamicanalyzer.ui.widgets.table.DATableComposite;
@Override
public void widgetSelected(SelectionEvent e) {
AnalyzerManager.getCurrentPage().updateView(
- new DAViewData(TimelineTableView.tabID, null));
+ new DAViewData(TimelineTableView.appStartupViewID, null));
GridItem[] sels = table.getSelection();
if (sels.length > 0) {
table.setFocusItem(sels[0]);
contentData.add(Long.toString(time));
// create table input
- TableInput tableInput = createTableData(rowData, contentText, contentData, time);
+ TableInput tableInput = createTableData(rowData, contentText, contentData);
input.add(tableInput);
// set start table data
contentData.add(Long.toString(endTime - startData.startTime));
}
- private TableInput createTableData(List<Object> rowData, List<String> contentText, List<String> contentData, long time) {
+ private TableInput createTableData(List<Object> rowData, List<String> contentText,
+ List<String> contentData) {
DATableDataFormat tableData = new DATableDataFormat(
(Long) rowData.get(WebAppStartupDBTable.COLUMN.SEQUENCE_NUMBER.getIndex()));
tableData.setLogData(makeWebAppStartupData(rowData));
tableInput.setText(contentText);
tableInput.setData(tableData);
- if (RangeDataManager.getInstance().isBeingAnalyzed()) {
- long analysisStartTime = RangeDataManager.getInstance()
- .getAnalysisStartTime();
- long analysisEndTime = RangeDataManager.getInstance()
- .getAnalysisEndTime();
- if (time >= analysisStartTime && time <= analysisEndTime) {
- tableInput.setInRange(true);
- }
- }
return tableInput;
}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * WooJin Jung <woojin2.jung@samsung.com>
- * Jooyoul Lee <jy.exe.lee@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.info.callstack;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * Class containing data about callstack state at the moment of receiving
- * message with specified sequence number.
- */
-public class CallStackData {
- protected long seq;
- protected List<Long> addrs;
-
- /**
- * Public constructor for empty callstack data.
- *
- * @param seqNum sequence number of entry or exit message
- */
- public CallStackData(long seqNum) {
- seq = seqNum;
- addrs = new ArrayList<Long>();
- }
-
- /**
- * Public constructor for non empty callstack data.
- *
- * @param seqNum sequence number of entry or exit message
- * @param addrs List with addresses of called functions
- */
- public CallStackData(long seqNum, List<Long> addrs) {
- seq = seqNum;
- this.addrs = addrs;
- }
-
- /**
- * Return sequence number.
- */
- public long getSeq() {
- return seq;
- }
-
- /**
- * Return unmodifiable copy of list with addresses of called functions.
- */
- public List<Long> getAddrs() {
- return Collections.unmodifiableList(addrs);
- }
-
- /**
- * Add specified address to call stack data.
- *
- * @param addr specified address
- */
- public void addAddr(long addr) {
- this.addrs.add(addr);
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * WooJin Jung <woojin2.jung@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.info.callstack;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.tizen.dynamicanalyzer.database.DBColumn;
-import org.tizen.dynamicanalyzer.database.DBConstants;
-import org.tizen.dynamicanalyzer.database.DBTable;
-import org.tizen.dynamicanalyzer.database.IResultSet;
-import org.tizen.dynamicanalyzer.util.Logger;
-
-public class CallStackDataDBTable extends DBTable {
- private static final String TABLENAME="CALL_STACK_DATA";
- private static final String queryto_withSeq = "where %s = %s";
-
- public enum COLUMN {
- SEQUENCE_NUMBER(0, DBConstants.DBCOLUMN_SEQUENCE_NUMBER),
- ADDRESS_ARRAY(1, "ADDRESS_ARRAY");
-
- public final int index;
- public final String name;
-
- COLUMN(int index, String name) {
- this.index = index;
- this.name = name;
- }
- }
-
- @Override
- public String getTableName() {
- return TABLENAME;
- }
-
- public CallStackDataDBTable() {
- addColumn(new DBColumn(COLUMN.SEQUENCE_NUMBER.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
- addColumn(new DBColumn(COLUMN.ADDRESS_ARRAY.name, DBConstants.NOT_NULL, DBConstants.BIGINT_ARRAY));
- }
-
- public List<List<Object>> getCallStackAddrsFromDB(long seq) {
- String where = String.format(queryto_withSeq,
- COLUMN.SEQUENCE_NUMBER.name, seq);
-
- List<String> selectColumn = new ArrayList<String>();
- selectColumn.add(COLUMN.ADDRESS_ARRAY.name);
-
- return selectData(selectColumn, where, new IResultSet() {
- @Override
- public List<Object> extractDataFromResultSet(ResultSet rs) {
- List<Object> row = new ArrayList<Object>();
- row.add(getArrayFromResultSet(rs, 1, Long.valueOf(0)));
- return row;
- }
- });
- }
-
- @Override
- public boolean prepare(PreparedStatement prep, List<Object> rowData) {
- boolean isPrepared = true;
-
- int columnsize = getColumnSize();
- if (columnsize != rowData.size()) {
- isPrepared = false;
- } else {
- try {
- prep.setLong(COLUMN.SEQUENCE_NUMBER.index + 1, (Long) (rowData.get(COLUMN.SEQUENCE_NUMBER.index)));
- setArrayToPreparedStatement(COLUMN.ADDRESS_ARRAY.index, DBConstants.DBTYPE_LONG,
- prep, rowData);
- } catch (SQLException e) {
- Logger.exception(e);
- isPrepared = false;
- }
- }
-
- return isPrepared;
- }
-
- @Override
- public List<Object> extractDataFromResultSet(ResultSet rs) {
- List<Object> row = new ArrayList<Object>();
- try {
- row.add(Long.valueOf(rs.getLong(COLUMN.SEQUENCE_NUMBER.index + 1))); //because counting starts from 1 in db.
- //add array
- List<Long> addrs = new ArrayList<Long>();
- Object[] buf = (Object[]) rs.getArray(
- COLUMN.ADDRESS_ARRAY.index + 1).getArray();
- for (Object b : buf) {
- addrs.add((Long) b);
- }
- row.add(addrs);
- } catch (SQLException e) {
- Logger.exception(e);
- return null;
- }
-
- return row;
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * WooJin Jung <woojin2.jung@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.info.callstack;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.NavigableMap;
-import java.util.SortedMap;
-
-import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
-import org.tizen.dynamicanalyzer.common.DALimit;
-import org.tizen.dynamicanalyzer.common.Global;
-import org.tizen.dynamicanalyzer.control.DataThread;
-import org.tizen.dynamicanalyzer.setting.FlatFeature;
-import org.tizen.dynamicanalyzer.setting.FlatPreferences;
-import org.tizen.dynamicanalyzer.setting.SettingDataManager;
-import org.tizen.dynamicanalyzer.ui.summary.profiling.FunctionUsageProfiler;
-import org.tizen.dynamicanalyzer.util.Logger;
-
-// inserter thread for callstackdata, callstackunit
-public class CallStackInserter extends DataThread<CallStackData> {
- public static final CallStackData END_OF_QUEUE = new CallStackData(-1);
-
- private static final int FULL_COUNT = 5000;
- private static CallStackInserter instance = new CallStackInserter();
-
- private CallStackDataDBTable callStackDataTable = null;
- private CallStackUnitDBTable callStackUnitTable = null;
-
- private CallStackInserter() {
- callStackDataTable = new CallStackDataDBTable();
- callStackUnitTable = new CallStackUnitDBTable();
- }
-
- public static CallStackInserter getInstance() {
- return instance;
- }
-
- public CallStackDataDBTable getCallStackDataTable() {
- return callStackDataTable;
- }
-
- public CallStackUnitDBTable getCallStackUnitTable() {
- return callStackUnitTable;
- }
-
- @Override
- protected String getThreadName() {
- return AnalyzerConstants.CALLSTACK_INSERTER_THREAD;
- }
-
- @Override
- protected boolean workAfterStart() {
- return true;
- }
-
- @Override
- protected boolean workAfterStopNormal() {
- return true;
- }
-
- @Override
- protected boolean workAfterStopForced() {
- return true;
- }
-
- @Override
- protected void resetBeforeStart() {
- }
-
- @Override
- protected void clearAfterStop() {
- }
-
- @Override
- public void run() {
- Thread curThread = Thread.currentThread();
-
- List<CallStackData> bufferList = new ArrayList<CallStackData>();
- while (testThread(curThread)) {
- CallStackData data = pollData();
- if (data == null || data == END_OF_QUEUE) {
- break;
- }
-
- bufferList.add(data);
- if (bufferList.size() >= FULL_COUNT) {
- saveCallStackData(bufferList);
- bufferList.clear();
- }
- }
-
- if (!bufferList.isEmpty() && testThread(curThread)) {
- saveCallStackData(bufferList);
- bufferList.clear();
- }
- }
-
- private void saveCallStackData(List<CallStackData> dataList) {
- ArrayList<List<Object>> insertData = new ArrayList<List<Object>>();
- long lastInsertSeq = -1;
-
- int dataSize = dataList.size();
- for (int i = 0; i < dataSize; i++) {
- CallStackData csd = dataList.get(i);
- List<Long> addrs = csd.getAddrs();
-
- List<Object> insertRowData = new ArrayList<Object>();
- try {
- insertRowData.add(Long.valueOf(csd.getSeq()));
- insertRowData.add(addrs);
- } catch (ArrayIndexOutOfBoundsException e) {
- Logger.exception(e);
- }
- insertData.add(insertRowData);
-
- lastInsertSeq = csd.getSeq();
- }
-
- if (!insertData.isEmpty()) {
- callStackDataTable.insertData(insertData);
-
- // The next step is working only if we don't have to construct call trace for memory allocations.
- // FIXME:
- // Another option might be to fix MemoryCallStackTable to read data from database.
- // On one hand it takes additional time. On other hand keeping all calltraces in memory
- // may also result in memory/performance degradation (however it is anyway done when opening a trace).
- // We should consider some reasonable optimization here.
- if (!SettingDataManager.INSTANCE.getSelectedFlatFeatureSet().contains(FlatFeature.MEMORY_ALLOC))
- {
- // remove unnecessary callstackdata from memory
- if (SettingDataManager.INSTANCE.getPreferenceValue(FlatPreferences.FUNCTION_SAMPLING_RATE) > 0) {
- // sample feature is on
- long lastSampleSeq = FunctionUsageProfiler.getInstance().getLastSampleSeq();
- if (lastSampleSeq != -1) {
- if (lastSampleSeq <= lastInsertSeq) {
- removeCallstackData(lastSampleSeq);
- } else { // lastSampleSeq > lastInsertSeq
- removeCallstackData(lastInsertSeq);
- }
- }
- } else { // sample feature is off
- // callstackdata is not needed in memory after insertion to DB
- removeCallstackData(lastInsertSeq);
- }
- }
- }
-
- // stop trace if number of entries over > 1M
- List<Integer> tids = Global.getRuntimeCallstackManager().getTidsOfSeqTimeMap();
- int size = tids.size();
- for (int i = 0; i < size; i++) {
- Map<Long, Long> seqByTimeMap = Global.getRuntimeCallstackManager().getSeqTimeByTidMap(
- tids.get(i), false);
- if (null != seqByTimeMap && seqByTimeMap.size() > DALimit.MAX_CALLSTACK_SEQTIMEMAP_SIZE) {
- DALimit.stopTraceAndOpenWarningDialog();
- }
- }
- }
-
- private void removeCallstackData(long seq) {
- NavigableMap<Long, CallStackData> callstackDataMap = Global.getRuntimeCallstackManager()
- .getCallStackDataBySeqMap();
- SortedMap<Long, CallStackData> headMap = callstackDataMap.headMap(seq);
- Iterator<Map.Entry<Long, CallStackData>> itr = headMap.entrySet().iterator();
- while (itr.hasNext()) {
- itr.next();
- itr.remove();
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * WooJin Jung <woojin2.jung@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.info.callstack;
-
-public class CallStackItem {
- protected long startTime;
- protected CallStackUnit callstackUnit;
-
- public CallStackItem(CallStackUnit CallstackUnit) {
- callstackUnit = CallstackUnit;
- startTime = -1;
- }
-
- public CallStackItem(CallStackUnit CallstackUnit, long time) {
- callstackUnit = CallstackUnit;
- startTime = time;
- }
-
- public long getStartTime() {
- return startTime;
- }
-
- public CallStackUnit getCallStackUnit() {
- return callstackUnit;
- }
-
-}
\ No newline at end of file
* WooJin Jung <woojin2.jung@samsung.com>
* Jooyoul Lee <jy.exe.lee@samsung.com>
* Juyoung Kim <j0.kim@samsung.com>
+ * Petr Privalov <p.privalov@partner.samsung.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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.
- *
+ *
* Contributors:
* - S-Core Co., Ltd
- *
+ *
*/
package org.tizen.dynamicanalyzer.ui.info.callstack;
-import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
import org.tizen.dynamicanalyzer.common.Global;
import org.tizen.dynamicanalyzer.constant.CommonConstants;
-import org.tizen.dynamicanalyzer.nl.InformationViewLabels;
-import org.tizen.dynamicanalyzer.project.BinaryInfo;
-import org.tizen.dynamicanalyzer.swap.model.data.LogData;
-import org.tizen.dynamicanalyzer.ui.summary.profiling.FunctionUsageProfiler;
-import org.tizen.dynamicanalyzer.util.Logger;
+import org.tizen.dynamicanalyzer.logparser.LogCenterConstants;
public class CallStackUnit {
private long address;
- private long functionStartAddress;
- private String path;
- private String functionName;
- private String offset = CommonConstants.EMPTY;
- private String etc = CommonConstants.EMPTY;
+ private long callerAddress;
private int pid;
+ private int tid;
private long time;
private int functionID;
- private int binaryID;
- // TODO: get path and function name as parameter, not symbol
- public CallStackUnit(long addr, String symbol, LogData log) {
- this.address = addr;
- this.functionStartAddress = addr;
- this.time = log.getTime();
- this.pid = log.getPid();
- this.functionID = AnalyzerConstants.INVALID_ID;
- this.functionName = CommonConstants.EMPTY;
- makeCallstackData(symbol);
- }
+ private int binaryID;
+ private String path;
+ private String functionName;
- public CallStackUnit(long addr, String symbol, int functionId, LogData log) {
+ /**
+ * Public constructor, got {@code binaryID}, {@code path},
+ * {@code functionName} from {@link Global}.
+ *
+ * @param addr PC address of function start
+ * @param callerAddr PC address of caller instruction
+ * @param pid pid
+ * @param tid tid
+ * @param time time in microseconds
+ * @param functionID function id
+ */
+ public CallStackUnit(long addr, long callerAddr, int pid, int tid, long time, int functionID) {
this.address = addr;
- this.functionStartAddress = addr;
- this.time = log.getTime();
- this.pid = log.getPid();
- this.functionID = functionId;
- this.functionName = CommonConstants.EMPTY;
- makeCallstackData(symbol);
- }
-
- /** using open trace **/
- public CallStackUnit(long addr, int pid, int functionId, int binaryID) {
+ this.callerAddress = callerAddr;
+ this.pid = pid;
+ this.tid = tid;
+ this.time = time;
+ this.functionID = functionID;
+
+ this.binaryID = Global.getBinaryID(pid, time, addr);
+ if (functionID > 0)
+ this.functionName = Global.getFunctionName(functionID);
+ else
+ this.functionName = LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC;
+ this.path = Global.getLibraryName(binaryID);
+ }
+
+ /**
+ * Public constructor.
+ *
+ * @param addr PC address of function start
+ * @param callerAddr PC address of caller instruction
+ * @param pid pid
+ * @param tid tid
+ * @param time time in microseconds
+ * @param functionID function id
+ * @param binaryID binary id
+ * @param functionName function name
+ * @param path absolute path to binary on target device
+ */
+ public CallStackUnit(long addr, long callerAddr, int pid, int tid, long time, int functionID,
+ int binaryID, String functionName, String path) {
this.address = addr;
- this.functionStartAddress = addr;
- this.time = -1;
+ this.callerAddress = callerAddr;
this.pid = pid;
- this.functionID = functionId;
- this.functionName = Global.getFunctionName(functionId);
+ this.tid = tid;
+ this.time = time;
+ this.functionID = functionID;
this.binaryID = binaryID;
+ this.functionName = functionName;
+ this.path = path;
+ }
+
+ /**
+ * Public constructor for entries and exits in not profiled binaries.
+ */
+ public CallStackUnit() {
+ this.functionName = LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC;
+ this.path = LogCenterConstants.USER_FUNCTION_CALLBACK_FUNC;
+ }
- BinaryInfo bInfo = Global.getProject().getDeviceStatusInfo().getBinaryInfo(binaryID);
- this.path = bInfo.getTargetBinaryPath();
- }
-
- private void makeCallstackData(String symbol) {
- // callstack symbol format : path(functionName
- // ex. /usr/lib/libpthread.so(pthread_create
- String[] splitPath = symbol.split("\\(", 2); //$NON-NLS-1$
- path = splitPath[0];
- if (!path.startsWith("/") && !path.contains(FunctionUsageProfiler.APPLICATION)
- && !path.contains(FunctionUsageProfiler.DEPENDENT_LIB)) {
- path = InformationViewLabels.CALLSTACK_TABLE_UNKNOWN_LIBRARY;
- }
-
- BinaryInfo bInfo = Global.getProject().getDeviceStatusInfo().getBinaryInfo(path);
- binaryID = bInfo.getID();
-
- if (splitPath.length < 2) {
- if (!splitPath[0].equals(FunctionUsageProfiler.APPLICATION)
- && !splitPath[0].equals(FunctionUsageProfiler.DEPENDENT_LIB)) {
- Logger.error("Invalid function name for calltrace unit\n");
- }
- functionName = InformationViewLabels.CALLSTACK_TABLE_UNKNOWN_FUNCTION;
- } else {
- String[] splitFunc = splitPath[1].split("\\+"); //$NON-NLS-1$
- if (splitFunc.length != 0) {
- if (splitFunc[0].isEmpty()) {
- functionName = InformationViewLabels.CALLSTACK_TABLE_UNKNOWN_FUNCTION;
- } else {
- functionName = splitFunc[0];
- }
- if (functionID == AnalyzerConstants.INVALID_ID) {
- functionID = Global.getFunctionID(functionName);
- }
- }
- }
+ /**
+ * Public constructor for units "Application" and "Dependent Libraries"
+ *
+ * @param symbol text to represent
+ */
+ public CallStackUnit(String symbol) {
+ this.functionName = "";
+ this.path = symbol;
}
public long getAddr() {
return address;
}
- public long getFunctionStartAddr() {
- return functionStartAddress;
+ public long getCallerAddress() {
+ return callerAddress;
}
public String getSymbol() {
- return path + CommonConstants.OPEN_BRACKET + functionName;
+ return functionName.isEmpty() ? path : path + CommonConstants.OPEN_BRACKET + functionName;
}
public void setAddr(long addr) {
address = addr;
}
- public void setFunctionStartAddr(long addr) {
- functionStartAddress = addr;
+ public void setCallerAddress(long addr) {
+ callerAddress = addr;
}
+
public String getFunctionName() {
return functionName;
}
return functionID;
}
- public String getOffset() {
- return offset;
- }
-
- public String getEtc() {
- return etc;
- }
-
public String getPath() {
return path;
}
public int getBinaryID() {
return binaryID;
}
+
+ public int getTid() {
+ return tid;
+ }
+
+ public void setTid(int tid) {
+ this.tid = tid;
+ }
}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * WooJin Jung <woojin2.jung@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.info.callstack;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.tizen.dynamicanalyzer.database.DBColumn;
-import org.tizen.dynamicanalyzer.database.DBConstants;
-import org.tizen.dynamicanalyzer.database.DBTable;
-import org.tizen.dynamicanalyzer.database.IResultSet;
-import org.tizen.dynamicanalyzer.util.Logger;
-
-public class CallStackUnitDBTable extends DBTable implements IResultSet {
- private static final String TABLENAME="CALL_STACK_UNIT";
-
- public enum COLUMN {
- PID(0, DBConstants.DBCOLUMN_PID),
- FUNCTION_ID(1, DBConstants.DBCOLUMN_FUNCTION_ID),
- BINARY_ID(2, "BINARY_ID"),
- PC_ADDRESS(3, "PC_ADDRESS");
-
- public final int index;
- public final String name;
-
- COLUMN(int index, String name) {
- this.index = index;
- this.name = name;
- }
- }
-
- @Override
- public String getTableName() {
- return TABLENAME;
- }
-
- public CallStackUnitDBTable() {
- addColumn(new DBColumn(COLUMN.PID.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
- addColumn(new DBColumn(COLUMN.FUNCTION_ID.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
- addColumn(new DBColumn(COLUMN.BINARY_ID.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
- addColumn(new DBColumn(COLUMN.PC_ADDRESS.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
- }
-
- @Override
- public boolean prepare(PreparedStatement prep, List<Object> rowData) {
- boolean isPrepared = true;
-
- int columnsize = getColumnSize();
- if (columnsize != rowData.size()) {
- isPrepared = false;
- } else {
- try {
- prep.setInt(COLUMN.PID.index + 1, (Integer) (rowData.get(COLUMN.PID.index)));
- prep.setInt(COLUMN.FUNCTION_ID.index + 1, (Integer) (rowData.get(COLUMN.FUNCTION_ID.index)));
- prep.setInt(COLUMN.BINARY_ID.index + 1, (Integer) (rowData.get(COLUMN.BINARY_ID.index)));
- prep.setLong(COLUMN.PC_ADDRESS.index + 1, (Long) (rowData.get(COLUMN.PC_ADDRESS.index)));
- } catch (SQLException e) {
- Logger.exception(e);
- isPrepared = false;
- }
- }
-
- return isPrepared;
- }
-
- @Override
- public List<Object> extractDataFromResultSet(ResultSet rs) {
- List<Object> row = new ArrayList<Object>();
- try {
- row.add(Integer.valueOf(rs.getInt(1)));
- row.add(Integer.valueOf(rs.getInt(2)));
- row.add(Integer.valueOf(rs.getInt(3)));
- row.add(Long.valueOf(rs.getLong(4)));
- } catch (SQLException e) {
- Logger.exception(e);
- return null;
- }
-
- return row;
- }
-}
package org.tizen.dynamicanalyzer.ui.info.callstack;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
-import java.util.Map;
import org.eclipse.nebula.widgets.grid.GridItem;
import org.eclipse.swt.SWT;
import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
import org.tizen.dynamicanalyzer.common.AnalyzerManager;
import org.tizen.dynamicanalyzer.common.DASelectionData;
-import org.tizen.dynamicanalyzer.common.Global;
+import org.tizen.dynamicanalyzer.common.DAState;
import org.tizen.dynamicanalyzer.model.TableInput;
-import org.tizen.dynamicanalyzer.project.callstack.RuntimeCallstackManager;
import org.tizen.dynamicanalyzer.swap.model.data.LogData;
import org.tizen.dynamicanalyzer.ui.file.FilePage;
import org.tizen.dynamicanalyzer.ui.opengl.GLPage;
-import org.tizen.dynamicanalyzer.ui.range.RangePage;
import org.tizen.dynamicanalyzer.ui.summary.SummaryPage;
+import org.tizen.dynamicanalyzer.ui.timeline.calltrace.CallTraceDataManager;
import org.tizen.dynamicanalyzer.ui.timeline.calltrace.FunctionEntryDBTable;
import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineTableView;
-import org.tizen.dynamicanalyzer.ui.userinterface.UIPage;
import org.tizen.dynamicanalyzer.ui.widgets.table.DATableComposite;
import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat;
import org.tizen.dynamicanalyzer.util.Logger;
import org.tizen.dynamicanalyzer.widgets.da.view.DAViewData;
public class CallstackTable extends DATableComposite {
+
+ /**
+ * List of view Id which selection data should not trigger table update.
+ */
+ static final List<String> forbiddenViewId = new ArrayList<>(
+ Arrays.asList(FilePage.chartViewID, GLPage.chartViewID,
+ GLPage.contextViewID, GLPage.contextHistoryID, GLPage.programViewID,
+ GLPage.statisticsViewID, GLPage.redundantViewID, GLPage.textureViewID,
+ SummaryPage.profilingViewID));
+
public CallstackTable(Composite parent, int compStyle, int tableStyle) {
super(parent, compStyle, tableStyle);
@Override
public void widgetSelected(SelectionEvent e) {
AnalyzerManager.getCurrentPage().updateView(
- new DAViewData(TimelineTableView.tabID, null));
+ new DAViewData(TimelineTableView.callstackViewID, null));
GridItem[] sels = table.getSelection();
if (sels.length <= 0) {
return;
return;
}
String viewId = selData.getViewID();
- if (null == viewId || viewId.isEmpty() || viewId.equals(FilePage.chartViewID)
- || viewId.equals(UIPage.profilingViewID) || viewId.equals(GLPage.chartViewID)
- || viewId.equals(GLPage.contextViewID) || viewId.equals(GLPage.contextHistoryID)
- || viewId.equals(GLPage.programViewID) || viewId.equals(GLPage.statisticsViewID)
- || viewId.equals(GLPage.redundantViewID) || viewId.equals(GLPage.textureViewID)
- || viewId.equals(UIPage.profilingViewID)
- || viewId.equals(RangePage.profilingViewID)
- || viewId.equals(SummaryPage.profilingViewID)) {
+ if (null == viewId || viewId.isEmpty() || forbiddenViewId.contains(viewId)) {
return;
}
Object obj = selData.getData();
}
DATableDataFormat tableData = (DATableDataFormat) items[0].getData();
- long seqNum = -1;
- int pid = -1;
- long time = -1;
- if (tableData.getType() == AnalyzerConstants.TYPE_TABLE_FAILED) {
- List<Object> failedData = tableData.getData();
- seqNum = (Long) failedData.get(0);
- pid = (Integer) failedData.get(7);
- time = (Long) failedData.get(1);
- } else if (tableData.getType() == AnalyzerConstants.TYPE_TABLE_LEAK) {
- List<Object> leakData = tableData.getData();
- seqNum = (Long) leakData.get(0);
- pid = (Integer) leakData.get(2);
- time = (Long) leakData.get(4);
- } else if (tableData.getType() == AnalyzerConstants.TYPE_TABLE_CALLTRACE) {
- List<Object> calltraceData = tableData.getData();
- seqNum = (Long) calltraceData.get(FunctionEntryDBTable.COLUMN.SEQUENCE_NUMBER.index);
- pid = (Integer) calltraceData.get(FunctionEntryDBTable.COLUMN.PID.index);
- time = (Long) calltraceData.get(FunctionEntryDBTable.COLUMN.START_TIME.index);
- } else if (tableData.getType() == AnalyzerConstants.TYPE_TABLE_INTERACTIVE) {
- return; // TODO
- } else { // in case table has LogData
- LogData logData = tableData.getLogData();
- seqNum = logData.getSeq();
- pid = logData.getPid();
- time = logData.getTime();
- }
-
- RuntimeCallstackManager callstackManager = Global.getRuntimeCallstackManager();
- Map<Long, CallStackUnit> addrMap = callstackManager.getCallStackApiAddrByPidMap(pid);
- if (null == addrMap) {
+ List<CallStackUnit> callStack = getCallStack(tableData);
+ if (callStack.isEmpty()) {
return;
}
- List<Long> addrs = null;
- addrs = callstackManager.getCallstackAddrListFromSeq(seqNum);
- if (null == addrs) {
- return;
- }
-
- int size = addrs.size();
- for (int i = 0; i < size; i++) {
- String hexAddr = Formatter.toHexString(addrs.get(i).toString());
- CallStackUnit api = addrMap.get(addrs.get(i));
+ for (int i = 0; i < callStack.size(); i++) {
+ String hexAddr = Formatter.toHexString(Long.toString(callStack.get(i).getAddr()));
+ CallStackUnit api = callStack.get(i);
- if (null == api) {
+ if (null == api || api.getPath() == null) {
Logger.debug("callstackunit for addr : " + hexAddr + " not found");
return;
}
-
String path = api.getPath();
- if (null == path) {
- Logger.debug("callstackunit for addr : " + hexAddr + " not found");
- return;
- }
// TODO : make GridItem using filter property data
GridItem gridItem = new GridItem(table, SWT.NONE);
// setData block
- {
- long address = addrs.get(i);
- DATableDataFormat callstackTableData = new DATableDataFormat(address);
- // 99 means "table type callstack"
- callstackTableData.setType(AnalyzerConstants.TYPE_TABLE_CALLSTACK);
- callstackTableData.setObject(address);
- gridItem.setData(callstackTableData);
- gridItem.setData(AnalyzerConstants.CALLSTACK_KEY_ADDR, address);
- gridItem.setData(AnalyzerConstants.CALLSTACK_KEY_PID, pid);
- gridItem.setData(AnalyzerConstants.CALLSTACK_KEY_TIME, time);
- gridItem.setData(AnalyzerConstants.CALLSTACK_KEY_LIBNAME, path);
- }
-
- String addrInput = (addrs.get(i) == 0) ? "" : hexAddr; //$NON-NLS-1$
+ long address = api.getAddr();
+ DATableDataFormat callstackTableData = new DATableDataFormat(address);
+
+ callstackTableData.setType(AnalyzerConstants.TYPE_TABLE_CALLSTACK);
+ callstackTableData.setObject(address);
+ gridItem.setData(callstackTableData);
+ gridItem.setData(AnalyzerConstants.CALLSTACK_KEY_ADDR, address);
+ gridItem.setData(AnalyzerConstants.CALLSTACK_KEY_PID, api.getPid());
+ gridItem.setData(AnalyzerConstants.CALLSTACK_KEY_TIME, api.getTime());
+ gridItem.setData(AnalyzerConstants.CALLSTACK_KEY_LIBNAME, path);
+
+ String addrInput = (api.getAddr() == 0) ? "" : hexAddr; //$NON-NLS-1$
gridItem.setText(1, addrInput.toLowerCase());
String fName = api.getFunctionName();
}
+ private List<CallStackUnit> getCallStack(DATableDataFormat tableData) {
+ if (!DAState.isStartable())
+ return Collections.emptyList();
+
+ int pid;
+ int tid = -1;
+ long time;
+ if (tableData.getType() == AnalyzerConstants.TYPE_TABLE_FAILED) {
+ List<Object> failedData = tableData.getData();
+ pid = (Integer) failedData.get(7);
+ time = (Long) failedData.get(1);
+ } else if (tableData.getType() == AnalyzerConstants.TYPE_TABLE_LEAK) {
+ List<Object> leakData = tableData.getData();
+ pid = (Integer) leakData.get(2);
+ time = (Long) leakData.get(4);
+ } else if (tableData.getType() == AnalyzerConstants.TYPE_TABLE_CALLTRACE) {
+ List<Object> calltraceData = tableData.getData();
+ pid = (Integer) calltraceData.get(FunctionEntryDBTable.COLUMN.PID.index);
+ time = (Long) calltraceData.get(FunctionEntryDBTable.COLUMN.START_TIME.index);
+ tid = (Integer) calltraceData.get(FunctionEntryDBTable.COLUMN.TID.index);
+ } else if (tableData.getType() == AnalyzerConstants.TYPE_TABLE_INTERACTIVE) {
+ return Collections.emptyList();
+ } else { // in case table has LogData
+ LogData logData = tableData.getLogData();
+ pid = logData.getPid();
+ time = logData.getTime();
+ }
+ if (tid == -1) {
+ tid = pid;
+ }
+
+ return CallTraceDataManager.getInstance().getCallstackForTable(pid, tid, time);
+ }
+
@Override
protected List<TableInput> makeTableInput() {
return null;
private boolean[] columnVisibility = { true, true, true };
Composite contents = null;
- // this definition should be here for creation of instance (register db table)
- @SuppressWarnings("unused")
- private static CallStackInserter inserter = CallStackInserter.getInstance();
-
public CallstackView(Composite parent, int style) {
super(parent, style, false);
this.setLayout(new FillLayout());
addColumn(new DBColumn(CAPTURE_TIME, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
addColumn(new DBColumn(IMAGE_FILE_PATH, DBConstants.EMPTY, DBConstants.DBTYPE_VARCHAR, MAX_IMAGEPATH_LEN));
addColumn(new DBColumn(IMAGE_ORIENTATION, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
- setIndexColumn(COLUMN.CAPTURE_TIME.ordinal());
+ addIndex(COLUMN.CAPTURE_TIME.ordinal());
}
@Override
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jungwook Ryu <jungwook.ryu@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.interactive;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
-import org.tizen.dynamicanalyzer.resources.ColorResources;
-import org.tizen.dynamicanalyzer.swap.logparser.DataManagerRegistry;
-import org.tizen.dynamicanalyzer.ui.interactive.chart.InteractiveChartView;
-import org.tizen.dynamicanalyzer.ui.interactive.data.InteractiveDataManager;
-import org.tizen.dynamicanalyzer.ui.interactive.table.InteractiveTableView;
-import org.tizen.dynamicanalyzer.ui.timeline.calltrace.CallTraceView;
-import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineTableView;
-import org.tizen.dynamicanalyzer.widgets.da.view.DAContainerComposite;
-
-public class InteractivePage extends DAContainerComposite {
- public static final String pageID = InteractivePage.class.getName();
- public static final String chartViewID = InteractiveChartView.class.getName();
- public static final String listViewID = InteractiveTableView.class.getName();
-
- SashForm baseForm;
- SashForm leftForm;
- SashForm rightForm;
-
- public InteractivePage(Composite parent, int style) {
- super(parent, style);
- setTitle(AnalyzerLabels.COOLBAR_AREA_INTERACTIVE);
- this.setBackground(ColorResources.CONFIGURATION_TABLE_COVER_BACKGROUND_COLOR);
- this.setLayout(new FillLayout());
-
- baseForm = new SashForm(this, SWT.HORIZONTAL);
- baseForm.setLayout(new FillLayout());
- baseForm.setForeground(ColorResources.TAB_SELECTED_COLOR_START);
- ((FillLayout) getLayout()).marginHeight = 15;
- ((FillLayout) getLayout()).marginWidth = 5;
-
- leftForm = new SashForm(baseForm, SWT.VERTICAL);
- InteractiveChartView chartView = new InteractiveChartView(leftForm, SWT.NONE);
- addView(chartView);
- InteractiveTableView tableView = new InteractiveTableView(leftForm, SWT.NONE);
- addView(tableView);
-
- leftForm.setWeights(new int[] { 60, 40 });
-
- rightForm = new SashForm(baseForm, SWT.VERTICAL);
-
- CallTraceView apiListView = new CallTraceView(rightForm, SWT.NONE);
- addView(apiListView);
-
- TimelineTableView tabView = new TimelineTableView(rightForm,
- SWT.NONE);
-// tabView.setObservingViews(TimelineTableView.screenshotViewID,
-// new String[] { InteractivePage.chartViewID });
-// tabView.setObservingViews(TimelineTableView.screenshotViewID,
-// new String[] { InteractivePage.listViewID });
- addView(tabView);
-
- rightForm.setWeights(new int[] { 50, 50 });
- baseForm.setWeights(new int[] { 75, 25 });
-
- baseForm.setSashWidth(SASH_WIDTH);
- leftForm.setSashWidth(SASH_WIDTH);
- rightForm.setSashWidth(SASH_WIDTH);
-
- DataManagerRegistry.registerPageDataManager(InteractiveDataManager.getInstance());
- }
-
- @Override
- protected void onResized(int width, int height) {
- int wrate = (int) (TimelineTableView.DEFAULT_WIDTH * 100 / width);
- int hrate = (int) (TimelineTableView.DEFAULT_TABLE_VIEW_HEIGHT * 100 / height);
- wrate = (wrate > 100) ? 100 : wrate;
- hrate = (hrate > 100) ? 100 : hrate;
-
- if ((wrate > (100 - 37)) || hrate > 100) {
- return;
- }
-
- baseForm.setWeights(new int[] { 100 - wrate, wrate });
- rightForm.setWeights(new int[] { 100 - hrate, hrate });
- }
-
- @Override
- public void clear() {
- super.clear();
- InteractiveDataManager.getInstance().clear();
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jungwook Ryu <jungwook.ryu@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.interactive.chart;
-
-import java.util.List;
-
-import org.tizen.dynamicanalyzer.nl.InteractivePageLabels;
-import org.tizen.dynamicanalyzer.nl.TimelineChartLabels;
-import org.tizen.dynamicanalyzer.resources.ColorResources;
-import org.tizen.dynamicanalyzer.resources.FontResources;
-import org.tizen.dynamicanalyzer.resources.ImageResources;
-import org.tizen.dynamicanalyzer.ui.common.PopupAnalysisMenuItemClickListener;
-import org.tizen.dynamicanalyzer.ui.common.PopupClearMenuItemClickListener;
-import org.tizen.dynamicanalyzer.ui.common.PopupEndMenuItemClickListener;
-import org.tizen.dynamicanalyzer.ui.common.PopupFromSelectionMenuItemClickListener;
-import org.tizen.dynamicanalyzer.ui.common.PopupStartMenuItemClickListener;
-import org.tizen.dynamicanalyzer.ui.interactive.data.InteractiveUIData;
-import org.tizen.dynamicanalyzer.ui.interactive.model.InteractiveInfo;
-import org.tizen.dynamicanalyzer.utils.Formatter;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChart;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlot;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlot.AutoRangeType;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotTooltip;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartSeries;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartSeriesItem;
-import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoard;
-import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoardItem;
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenu;
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuItem;
-
-public class InteractiveChart {
- private InteractiveInfo interactiveInfo;
- private DAChart chartWidget;
- private DAPopupMenu popupMenu;
- DAChartSeries beforeCheckPointSeries;
- DAChartSeries afterCheckPointSeries;
-
- public InteractiveChart(InteractiveInfo interactiveInfo) {
- this.interactiveInfo = interactiveInfo;
- if (interactiveInfo.hasCheckLocation(InteractiveInfo.CHECK_BEFORE_LINE)) {
- beforeCheckPointSeries = new DAChartSeries(interactiveInfo.getDescription() + " Before",
- DAChartSeries.SERIES_STYLE_BAR, ColorResources.SERIES_COLOR_INTERACTIVE_BEFORE);
- }
- if (interactiveInfo.hasCheckLocation(InteractiveInfo.CHECK_AFTER_LINE)) {
- afterCheckPointSeries = new DAChartSeries(interactiveInfo.getDescription() + " After",
- DAChartSeries.SERIES_STYLE_BAR, ColorResources.SERIES_COLOR_INTERACTIVE_AFTER);
- }
- }
-
- public DAChartBoardItem createBoardItem(final DAChartBoard chartBoard) {
- DAChartBoardItem item = new DAChartBoardItem(chartBoard, InteractivePageLabels.CHART_TITLE);
- item.setData(interactiveInfo);
- chartWidget = item.getChart();
-
- setChartStyle();
- popupMenu = new DAPopupMenu(chartWidget);
- initPopupMenu(chartBoard, popupMenu);
-
- if (beforeCheckPointSeries != null) {
- chartWidget.addSeries(beforeCheckPointSeries);
- }
- if (afterCheckPointSeries != null) {
- chartWidget.addSeries(afterCheckPointSeries);
- }
- return item;
- }
-
- public InteractiveInfo getInteractiveInfo() {
- return interactiveInfo;
- }
-
- public DAChart getChartWidget() {
- return chartWidget;
- }
-
- private void initPopupMenu(DAChartBoard chartBoard, DAPopupMenu popupMenu) {
- popupMenu.setFont(FontResources.CONTEXT_MENU_ITEM_FONT);
- DAPopupMenuItem startItem = new DAPopupMenuItem(popupMenu);
- startItem.setText(TimelineChartLabels.RANGE_CONTEXT_SET_START);
- startItem.addListener(new PopupStartMenuItemClickListener(startItem, chartBoard));
-
- DAPopupMenuItem endItem = new DAPopupMenuItem(popupMenu);
- endItem.setText(TimelineChartLabels.RANGE_CONTEXT_SET_END);
- endItem.addListener(new PopupEndMenuItemClickListener(endItem, chartBoard));
-
- DAPopupMenuItem fromSelectionItem = new DAPopupMenuItem(popupMenu);
- fromSelectionItem.setText(TimelineChartLabels.RANGE_CONTEXT_SET_FROM_SELECTION);
- fromSelectionItem.addListener(new PopupFromSelectionMenuItemClickListener(fromSelectionItem, chartBoard));
-
- DAPopupMenuItem analysisItem = new DAPopupMenuItem(popupMenu);
- analysisItem.setText(TimelineChartLabels.RANGE_CONTEXT_ANALYSIS);
- analysisItem.addListener(new PopupAnalysisMenuItemClickListener());
-
- DAPopupMenuItem clearItem = new DAPopupMenuItem(popupMenu);
- clearItem.setText(TimelineChartLabels.RANGE_CONTEXT_CLEAR);
- clearItem.addListener(new PopupClearMenuItemClickListener());
- }
-
- private void setChartStyle() {
- DAChartPlot plot = chartWidget.getPlot();
- if (null == plot) {
- return;
- }
- plot.setBackgroundImage(ImageResources.BG_GRADIENT);
- plot.setAutoHeightRange(AutoRangeType.SEMI_AUTO);
- DAChartPlotTooltip tooltip = new DAChartPlotTooltip(-1);
- tooltip.setFont(FontResources.CHART_TOOLTIP_FONT);
- plot.setTooltip(tooltip);
- plot.setAxisFont(FontResources.CHART_AXIS_FONT);
- }
-
- public DAPopupMenu getPopupMenu() {
- return popupMenu;
- }
-
- public void clear() {
- List<DAChartSeries> seriesList = chartWidget.getSeriesList();
- for (DAChartSeries series : seriesList) {
- series.clear();
- }
- }
-
- public void inputChartSeries(List<InteractiveUIData> parsedBeforeDataList,
- List<InteractiveUIData> parsedAfterDataList) {
- if (beforeCheckPointSeries != null) {
- beforeCheckPointSeries.clear();
- for (int i = 0; i < parsedBeforeDataList.size(); i++) {
- InteractiveUIData valueData = parsedBeforeDataList.get(i);
- double chartTime = Formatter.longTimeToDoubleTime(valueData.getTime());
- String tooltipText = valueData.getChartTooltipString();
- beforeCheckPointSeries.addSeriesItem(new DAChartSeriesItem(chartTime, 0, tooltipText));
- }
- }
- if (afterCheckPointSeries != null) {
- afterCheckPointSeries.clear();
- for (int i = 0; i < parsedAfterDataList.size(); i++) {
- InteractiveUIData valueData = parsedAfterDataList.get(i);
- double chartTime = Formatter.longTimeToDoubleTime(valueData.getTime());
- String tooltipText = valueData.getChartTooltipString();
- afterCheckPointSeries.addSeriesItem(new DAChartSeriesItem(chartTime, 0, tooltipText));
- }
- }
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jungwook Ryu <jungwook.ryu@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.interactive.chart;
-
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.widgets.Canvas;
-import org.tizen.dynamicanalyzer.common.AnalyzerManager;
-import org.tizen.dynamicanalyzer.common.DASelectionData;
-import org.tizen.dynamicanalyzer.ui.interactive.InteractivePage;
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
-import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
-import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
-import org.tizen.dynamicanalyzer.util.Logger;
-import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChart;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlot;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotIntervalMarker;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotMarker;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotTooltip;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartSeries;
-import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoard;
-import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoardItem;
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenu;
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuItem;
-import org.tizen.dynamicanalyzer.widgets.timeline.DATimeline;
-
-public class InteractiveChartMouseEventListener extends MouseAdapter implements MouseMoveListener {
- private RangeDataManager rangeDataManager = RangeDataManager.getInstance();
- private DAPopupMenu menu;
- private DATimeline timeline;
- private DAChartBoard chartBoard;
- private double baseTime = TimelineConstants.NOT_INITED;
-
- private static final int SELECTION_MARKER_INDEX = 0;
-
- public InteractiveChartMouseEventListener(DAPopupMenu menu, DATimeline timeline, DAChartBoard chartBoard) {
- this.menu = menu;
- this.timeline = timeline;
- this.chartBoard = chartBoard;
- }
-
- @Override
- public void mouseDown(MouseEvent e) {
- DAChart chart = (DAChart) e.widget;
- DAChartPlot plot = chart.getPlot();
- DAChartPlotMarker marker = plot.getMarkers().get(SELECTION_MARKER_INDEX);
- if (!(marker instanceof DAChartPlotIntervalMarker)) {
- return;
- }
- DAChartPlotIntervalMarker intervalMarker = (DAChartPlotIntervalMarker) marker;
-
- double eventTime = plot.getXFromXPixel(e.x);
-
- if (e.button == 3) { // mouse right click
- List<DAPopupMenuItem> itemList = menu.getItems();
- DAPopupMenuItem startItem = itemList.get(0);
- DAPopupMenuItem endItem = itemList.get(1);
- DAPopupMenuItem fromSelectionItem = itemList.get(2);
- DAPopupMenuItem analysisItem = itemList.get(3);
- DAPopupMenuItem clearItem = itemList.get(4);
-
- if (eventTime * TimelineConstants.MEGA_DOUBLE <= Toolbar.INSTANCE.getTime()) {
- startItem.setEnabled(true);
- endItem.setEnabled(true);
- analysisItem.setEnabled(rangeDataManager.isAnalyzable());
- clearItem.setEnabled(rangeDataManager.isBeingAnalyzed());
-
- startItem.setDoubleData(eventTime);
- endItem.setDoubleData(eventTime);
- } else {
- startItem.setEnabled(false);
- endItem.setEnabled(false);
- analysisItem.setEnabled(rangeDataManager.isAnalyzable());
- clearItem.setEnabled(rangeDataManager.isBeingAnalyzed());
- }
-
- if (intervalMarker.getStartVal() != intervalMarker.getEndVal()) {
- fromSelectionItem.setEnabled(true);
- } else {
- fromSelectionItem.setEnabled(false);
- }
- return;
- }
-
- AnalyzerUtil.setLatestTraceMode(InteractivePage.pageID, false);
-
- boolean bShift = false;
- if ((e.stateMask & SWT.SHIFT) != 0) {
- bShift = true;
- }
-
- if (bShift == true && intervalMarker.getStartVal() != -1) {
- if (baseTime > eventTime) {
- intervalMarker.setInterval(eventTime, baseTime);
- } else {
- intervalMarker.setInterval(baseTime, eventTime);
- }
- } else {
- intervalMarker.setInterval(eventTime, eventTime);
- baseTime = eventTime;
- }
-
- chart.redraw();
- }
-
- @Override
- public void mouseUp(MouseEvent e) {
- if (e.button == 3) { // mouse right click
- return;
- }
-
- DAChart chart = (DAChart) e.widget;
- DAChartPlot plot = chart.getPlot();
- DAChartPlotMarker marker = plot.getMarkers().get(SELECTION_MARKER_INDEX);
- if (!(marker instanceof DAChartPlotIntervalMarker)) {
- return;
- }
- DAChartPlotIntervalMarker intervalMarker = (DAChartPlotIntervalMarker) marker;
-
- double eventTime = plot.getXFromXPixel(e.x);
- double markerStartTime;
- double markerEndTime;
-
- if (intervalMarker.getStartVal() >= eventTime) {
- markerStartTime = eventTime;
- markerEndTime = intervalMarker.getEndVal();
- } else {
- markerStartTime = intervalMarker.getStartVal();
- markerEndTime = eventTime;
- }
-
- double toolbarTime = Toolbar.INSTANCE.getTime() / TimelineConstants.MEGA_DOUBLE;
-
- if (markerStartTime < 0) {
- markerStartTime = 0;
- } else if (markerStartTime > toolbarTime) {
- markerStartTime = toolbarTime;
- }
-
- if (markerEndTime > toolbarTime) {
- markerEndTime = toolbarTime;
- } else if (markerEndTime < 0) {
- markerEndTime = 0;
- }
-
- if (markerEndTime <= plot.getVisibleEndX()) {
- intervalMarker.setInterval(markerStartTime, markerEndTime);
- } else {
- intervalMarker.setInterval(markerStartTime, plot.getVisibleEndX());
- }
-
- sendSelectionTimes(intervalMarker.getStartVal(), intervalMarker.getEndVal());
- }
-
- @Override
- public void mouseMove(MouseEvent e) {
- DAChart chart = (DAChart) e.widget;
- DAChartPlot plot = chart.getPlot();
- DAChartPlotMarker marker = plot.getMarkers().get(SELECTION_MARKER_INDEX);
- if (!(marker instanceof DAChartPlotIntervalMarker)) {
- Logger.debug("mouseMove !IntervalMarker");
- return;
- }
- DAChartPlotIntervalMarker intervalMarker = (DAChartPlotIntervalMarker) marker;
- DAChartPlotTooltip tooltip;
-
- if ((e.stateMask & SWT.BUTTON1) != 0) {
- double eventTime = plot.getXFromXPixel(e.x);
-
- if (baseTime > eventTime) {
- intervalMarker.setInterval(eventTime, baseTime);
- } else {
- intervalMarker.setInterval(baseTime, eventTime);
- }
- }
- tooltip = plot.getTooltip();
- if (null == tooltip) {
- return;
- }
-
- double oldYPosRatio = tooltip.getYPosRatio();
- double newYPosRatio = (double) e.y / ((Canvas) e.widget).getSize().y;
-
- if (Double.compare(oldYPosRatio, newYPosRatio) != 0) {
- if (newYPosRatio < 0) {
- newYPosRatio = 0.01;
- } else if (newYPosRatio >= 1) {
- newYPosRatio = 0.99;
- }
-
- tooltip.setYPosRatio(newYPosRatio);
- }
-
- double oldStartVal = tooltip.getStartVal();
- double newStartVal = getTooltipStartX(plot, chart.getSeriesList(), e.x, newYPosRatio);
-
- if (oldStartVal != newStartVal) {
- tooltip.setStartVal(newStartVal);
- }
-
- timeline.setDetailTime(plot.getXFromXPixel(e.x));
- timeline.setDetailTimePosition(e.x);
- timeline.setDrawDetailTime(true);
- timeline.redraw();
- }
-
- private void sendSelectionTimes(double start, double end) {
- long startTime = (long) (start * TimelineConstants.MEGA_DOUBLE);
- long endTime = (long) (end * TimelineConstants.MEGA_DOUBLE);
- if (endTime < startTime) { // user mouse drag right->left on chart
- long temp = startTime;
- startTime = endTime;
- endTime = temp;
- }
- if (startTime < 0) {
- startTime = 0;
- }
- DAChartBoardItem selectedItem = chartBoard.getSelectItem();
- Object data = selectedItem.getData();
- AnalyzerManager.getCurrentPage().updateView(
- new DASelectionData(InteractivePage.chartViewID, startTime, endTime, data, null));
- }
-
- private double getTooltipStartX(DAChartPlot plot, List<DAChartSeries> seriesList, int x, double yPosRatio) {
- double ret = -1;
- for (int i = 0; i < seriesList.size(); i++) {
- DAChartSeries series = seriesList.get(i);
- int index = series.getPrevIndexByXvalue(plot.getXFromXPixel(x));
- if (-1 == index) {
- continue;
- }
- double startVal = series.getSeriesItemList().get(index).getX();
- if (ret < startVal) {
- ret = startVal;
- }
- }
- return ret;
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jungwook Ryu <jungwook.ryu@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.interactive.chart;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Rectangle;
-import org.tizen.dynamicanalyzer.nl.InteractivePageLabels;
-import org.tizen.dynamicanalyzer.resources.ImageResources;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChart;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotTooltip;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartRenderer;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartSeries;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartSeriesItem;
-import org.tizen.dynamicanalyzer.widgets.helper.ColorResources;
-import org.tizen.dynamicanalyzer.widgets.helper.FontResources;
-
-public class InteractiveChartRenderer extends DAChartRenderer {
- private final int SERIES_DISTANCE_MARGIN = 20;
-
- @Override
- protected void drawToGc(GC gc, DAChart chart) {
- if (!preDraw(gc, chart)) {
- return;
- }
- for (int i = 0; i < seriesList.size(); i++) {
- drawSeries(gc, seriesList.get(i), i);
- }
- }
-
- private void drawSeries(GC gc, DAChartSeries series, int seriesIndex) {
- int seriesSize = seriesList.size();
- Rectangle rect = new Rectangle(r.x, r.y + r.height * seriesIndex / seriesSize, r.width, r.height / seriesSize);
-
- if (seriesIndex != 0) {
- gc.setForeground(ColorResources.CHART_SEPERATE_LINE);
- gc.drawLine(rect.x, r.height * seriesIndex / seriesSize, rect.width, r.height * seriesIndex / seriesSize);
- }
-
- Font oriFont = gc.getFont();
- gc.setForeground(ColorResources.CHART_INFO);
- gc.setFont(FontResources.CHART_INFO_FONT);
- gc.drawImage(ImageResources.CHART_INFO, rect.x + 3, rect.y + rect.height / 2 - gc.stringExtent(series.getName()).y / 2);
- gc.drawText(series.getName(), rect.x + 18,
- rect.y + rect.height / 2 - gc.stringExtent(series.getName()).y / 2, true);
-
- gc.setFont(oriFont);
-
- List<DAChartSeriesItem> seriesItems = series.getSeriesItemList();
- if (seriesItems == null) {
- return;
- }
- int seriesItemSize = seriesItems.size();
- if (seriesItemSize < 1) {
- return;
- }
-
- int index = series.getPrevIndexByXvalue(plot.getVisibleStartX());
- if (index < 0) {
- index = 0;
- }
-
- gc.setLineStyle(SWT.LINE_SOLID);
- gc.setAntialias(SWT.ON);
- for (int i = index; i < seriesItemSize; i++) {
- double currentX = seriesItems.get(i).getX();
- int pixcelStartX = plot.getXPixelFromX(currentX, r);
- int pixcelStartY = rect.y + 4;
-
- gc.setBackground(series.getColor());
- gc.fillRectangle(pixcelStartX, pixcelStartY, 2, rect.height - 4);
- if (currentX > plot.getVisibleEndX()) {
- return;
- }
- }
- }
-
- @Override
- protected void drawTooltip(GC gc) {
- DAChartPlotTooltip tooltip = plot.getTooltip();
- if (tooltip == null || tooltip.shouldBeDrawn() == false || tooltip.getStartVal() == -1) {
- return;
- }
-
- gc.setFont(tooltip.getFont());
-
- List<String> tooltipTexts = new ArrayList<String>();
- List<String> tooltipTimes = new ArrayList<String>();
- List<Color> tooltipColor = new ArrayList<Color>();
-
- // make text,time & draw auxiliary line
- int textWidthMax = 0;
- int textHeightMax = 0;
- double realXVal = tooltip.getStartVal();
- int tooltipSize = 0;
- for (int i = 0; i < seriesList.size(); i++) {
- DAChartSeries series = seriesList.get(i);
- tooltipSize++;
-
- int index = series.getPrevIndexByXvalue(realXVal);
- String text = "";
- String time = "";
- Color color;
- if (index >= 0) {
- double xVal = series.getSeriesItemList().get(index).getX();
-
- time += toTimeFormat(xVal);
-
- if (series.isSummarizeTooltip() && checkOverlapFromPrevItem(series, index)) {
- text += series.getSummarizeString();
- } else {
- text += series.getSeriesItemList().get(index).getTooltipText();
- }
-
- gc.setForeground(tooltip.getLineColor());
- gc.setLineStyle(SWT.LINE_DOT);
- gc.setLineWidth(1);
-
- gc.drawLine(plot.getXPixelFromX(xVal), 0, plot.getXPixelFromX(xVal), r.height);
- gc.setLineStyle(SWT.LINE_CUSTOM);
-
- // event color
- color = series.getSeriesItemList().get(index).getColor();
- } else { // Case : There is no series item to draw.
- text = InteractivePageLabels.INTERACTIVE_CHART_INVALID_CHECK_LOCATION;
- color = null;
- }
-
- tooltipTexts.add(text);
- tooltipTimes.add(time);
- tooltipColor.add(color);
-
- int textWidth = gc.textExtent(text).x + DAChartPlotTooltip.TOOLTIP_TIME_MARGIN + gc.textExtent(time).x;
- int textHeight = gc.textExtent(text).y;
- if (textWidthMax < textWidth) {
- textWidthMax = textWidth;
- }
- if (textHeightMax < textHeight) {
- textHeightMax = textHeight;
- }
- }
-
- int preTextWidthMargin = DAChartPlotTooltip.TOOLTIP_MARGIN + DAChartPlotTooltip.TOOLTIP_SERIES_RECT_LENGTH
- + DAChartPlotTooltip.TOOLTIP_MARGIN;
- int startX = getTooltipStartX(realXVal, textWidthMax + preTextWidthMargin, DAChartPlotTooltip.TOOLTIP_MARGIN);
-
- int totalHeight = tooltipSize * textHeightMax + DAChartPlotTooltip.TOOLTIP_MARGIN
- + DAChartPlotTooltip.TOOLTIP_MARGIN + (tooltipSize - 1) * SERIES_DISTANCE_MARGIN;
-
- int startY = (r.y + r.height / 2) - (totalHeight / 2);
-
- gc.setAlpha(180);
- gc.setBackground(tooltip.getBackgroundColor());
- gc.setForeground(tooltip.getForegroundColor());
- gc.fillGradientRectangle(startX, startY, preTextWidthMargin + textWidthMax + DAChartPlotTooltip.TOOLTIP_MARGIN,
- totalHeight, true);
- gc.setAlpha(255);
- gc.setForeground(tooltip.getLineColor());
- gc.drawRoundRectangle(startX, startY, preTextWidthMargin + textWidthMax + DAChartPlotTooltip.TOOLTIP_MARGIN,
- totalHeight, 5, 5);
- gc.setFont(tooltip.getFont());
-
- String timeStr;
- tooltipSize = -1;
- for (int i = 0; i < seriesList.size(); i++) {
- DAChartSeries series = seriesList.get(i);
- if (series.isDisableTooltip()) {
- continue;
- } else {
- tooltipSize++;
- }
-
- int yPosition = r.y + r.height * i / seriesList.size() + r.height / seriesList.size() / 2 - textHeightMax
- / 2;
-
- Color col = tooltipColor.get(i);
- if (col == null) {
- gc.setBackground(series.getColor());
- } else {
- gc.setBackground(col);
- }
- gc.fillRectangle(startX + DAChartPlotTooltip.TOOLTIP_MARGIN, yPosition + textHeightMax / 2
- - DAChartPlotTooltip.TOOLTIP_SERIES_RECT_LENGTH / 2, DAChartPlotTooltip.TOOLTIP_SERIES_RECT_LENGTH,
- DAChartPlotTooltip.TOOLTIP_SERIES_RECT_LENGTH);
- gc.setBackground(tooltip.getBackgroundColor());
-
- gc.setForeground(tooltip.getTextColor());
- gc.drawText(tooltipTexts.get(i), startX + DAChartPlotTooltip.TOOLTIP_MARGIN
- + DAChartPlotTooltip.TOOLTIP_SERIES_RECT_LENGTH + DAChartPlotTooltip.TOOLTIP_MARGIN, yPosition,
- SWT.DRAW_DELIMITER | SWT.DRAW_TRANSPARENT);
-
- gc.setForeground(tooltip.getTimeColor());
- timeStr = tooltipTimes.get(i);
- gc.drawText(tooltipTimes.get(i), startX + DAChartPlotTooltip.TOOLTIP_MARGIN
- + DAChartPlotTooltip.TOOLTIP_SERIES_RECT_LENGTH + DAChartPlotTooltip.TOOLTIP_MARGIN + textWidthMax
- - DAChartPlotTooltip.TOOLTIP_MARGIN - gc.textExtent(timeStr).x, yPosition, SWT.DRAW_DELIMITER
- | SWT.DRAW_TRANSPARENT);
- }
- }
-
- @Override
- protected int getTooltipStartX(double startVal, int width, int margin) {
- int ret = plot.getXPixelFromX(startVal);
- if (ret + width > r.x + r.width) {
- ret = ret - width - margin;
- if (ret < 0) {
- ret = 50;
- }
- } else if (ret < r.x) {
- ret = r.x + margin;
- } else {
- ret += margin;
- }
-
- return ret;
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jungwook Ryu <jungwook.ryu@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.interactive.chart;
-
-import java.sql.ResultSet;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.ScrollBar;
-import org.eclipse.swt.widgets.Shell;
-import org.tizen.dynamicanalyzer.common.DASelectionData;
-import org.tizen.dynamicanalyzer.nl.InteractivePageLabels;
-import org.tizen.dynamicanalyzer.resources.ColorResources;
-import org.tizen.dynamicanalyzer.resources.FontResources;
-import org.tizen.dynamicanalyzer.ui.common.TimeLineChartKeyListener;
-import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseTrackAdapter;
-import org.tizen.dynamicanalyzer.ui.common.UICommonConstants;
-import org.tizen.dynamicanalyzer.ui.interactive.InteractivePage;
-import org.tizen.dynamicanalyzer.ui.interactive.data.InteractiveDataManager;
-import org.tizen.dynamicanalyzer.ui.interactive.data.InteractiveUIData;
-import org.tizen.dynamicanalyzer.ui.interactive.data.InteractiveValue;
-import org.tizen.dynamicanalyzer.ui.interactive.model.InteractiveInfo;
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
-import org.tizen.dynamicanalyzer.ui.timeline.chart.TimelineChart;
-import org.tizen.dynamicanalyzer.ui.timeline.common.AddChartMenuComposite;
-import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
-import org.tizen.dynamicanalyzer.ui.timeline.logparser.LifecycleLogParser;
-import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
-import org.tizen.dynamicanalyzer.ui.widgets.DADefaultChartBoard;
-import org.tizen.dynamicanalyzer.util.WorkbenchUtil;
-import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
-import org.tizen.dynamicanalyzer.utils.Formatter;
-import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
-import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChart;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotIntervalMarker;
-import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoard;
-import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoardItem;
-import org.tizen.dynamicanalyzer.widgets.da.view.DAViewComposite;
-import org.tizen.dynamicanalyzer.widgets.da.view.DAViewData;
-import org.tizen.dynamicanalyzer.widgets.timeline.DATimeline;
-
-public class InteractiveChartView extends DAViewComposite {
- private DAChartBoard chartBoard;
-
- private final RangeDataManager rangeDataManager = RangeDataManager.getInstance();
- private final LifecycleLogParser lifecycleLogParser = LifecycleLogParser.getInstance();
- private List<InteractiveChart> chartList = new ArrayList<InteractiveChart>();
-
- public InteractiveChartView(Composite parent, int style) {
- super(parent, style, false);
- this.setLayout(new FillLayout());
-
- Composite contents = getContentArea();
- contents.setBackground(ColorResources.WINDOW_BG_COLOR);
-
- chartBoard = new DADefaultChartBoard(contents, InteractivePageLabels.INTERACTIVE_CHART);
- chartBoard.setItemHeight(65);
- chartBoard.setNameFont(FontResources.CHART_NAME_FONT);
-
- ScrollBar hScrollBar = chartBoard.getHScrollBar();
- hScrollBar.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (chartBoard.isMaximumScrolled()) {
- AnalyzerUtil.setLatestTraceMode(InteractivePage.pageID, true);
- } else {
- AnalyzerUtil.setLatestTraceMode(InteractivePage.pageID, false);
- }
- }
- });
-
- StackLayout stackLayout = new StackLayout();
- stackLayout.topControl = chartBoard;
- contents.setLayout(stackLayout);
-
- initializeCharts();
-
- AddChartMenuComposite addChartComposite = new AddChartMenuComposite(chartBoard.getTitleComp());
- addChartComposite.setAddItemListButtonListener(new DACustomButtonClickEventListener() {
- @Override
- public void handleClickEvent(DACustomButton button) {
- Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell();
- InteractiveEditItemsDialog dialog = new InteractiveEditItemsDialog(shell, InteractiveChartView.this);
- if (dialog.isRunningDialog() == false) {
- dialog.open();
- }
- }
- });
- addChartComposite.createAddMenuComp();
-
- setBackground(ColorResources.VIEW_BG_COLOR);
-
- final DATimeline timeline = chartBoard.getTimeline();
-
- timeline.setTimeTickFont(FontResources.TIMELINE_TICK_FONT);
- timeline.setTimeBalloonFont(FontResources.TIMELINE_BALLOON_FONT);
-
- lifecycleLogParser.registerLifecycleBar(chartBoard.getLifecycleBar());
- lifecycleLogParser.registerTimeline(timeline);
-
- timeline.setTimeTickFont(FontResources.TIMELINE_TICK_FONT);
- timeline.setTimeBalloonFont(FontResources.TIMELINE_BALLOON_FONT);
-
- InteractiveDataManager.getInstance().setChartView(this);
- }
-
- private void initializeCharts() {
- initIntervalMarkers(chartBoard);
-
- List<TimelineChart> timelineChartList = InteractiveDataManager.getInstance().getTimelineChartList();
- for (int i = 0; i < timelineChartList.size(); i++) {
- TimelineChart timelineChart = timelineChartList.get(i);
-
- DAChartBoardItem item = timelineChart.createBoardItem(chartBoard);
- item.setHeight(DAChartBoard.DEFAULT_ITEM_HEIGHT);
- DAChart chartWidget = item.getChart();
-
- chartWidget.getPlot().setAxisRangeX(chartBoard.getVisibleStartTime(), chartBoard.getVisibleEndTime());
-
- chartWidget.getPlot().setMarkers(chartBoard.getMarkers());
- InteractiveChartMouseEventListener chartMouseEventListener = new InteractiveChartMouseEventListener(
- timelineChart.getPopupMenu(), chartBoard.getTimeline(), chartBoard);
- chartWidget.addMouseListener(chartMouseEventListener);
- chartWidget.addMouseMoveListener(chartMouseEventListener);
- chartWidget.addMouseTrackListener(new TimelineChartMouseTrackAdapter(chartBoard.getTimeline()));
-
- ///Add KeyListener 0215
- TimeLineChartKeyListener timelineKeyListener = new TimeLineChartKeyListener(chartBoard);
- chartWidget.addKeyListener(timelineKeyListener);
-
- List<TimelineChart> showChartList = InteractiveDataManager.getInstance().getShowTimelineChartList();
- chartBoard.hideItem(i);
- for (int ii = 0; ii < showChartList.size(); ii++) {
- if (showChartList.get(ii).getChartType() == timelineChart.getChartType()) {
- chartBoard.showItem(i);
- }
- }
- }
-
- /*
- * Interactive Chart
- */
- List<InteractiveInfo> interactiveList = InteractiveDataManager.getInstance().getVariableInfoList();
- for (int i = 0; i < interactiveList.size(); i++) {
- InteractiveChart chart = new InteractiveChart(interactiveList.get(i));
- chartList.add(chart);
- DAChartBoardItem boardItem = chart.createBoardItem(chartBoard);
- DAChart chartWidget = boardItem.getChart();
- chartWidget.setChartRenderer(new InteractiveChartRenderer());
-
- String chartInfo = interactiveList.get(i).getDescription();
- chartWidget.setInformation(chartInfo);
-
- chartWidget.getPlot().setMarkers(chartBoard.getMarkers());
- InteractiveChartMouseEventListener chartMouseEventListener = new InteractiveChartMouseEventListener(
- chart.getPopupMenu(), chartBoard.getTimeline(), chartBoard);
- chartWidget.addMouseListener(chartMouseEventListener);
- chartWidget.addMouseMoveListener(chartMouseEventListener);
- chartWidget.addMouseTrackListener(new TimelineChartMouseTrackAdapter(chartBoard.getTimeline()));
- }
- }
-
- private void initIntervalMarkers(DAChartBoard board) {
- // selection marker
- DAChartPlotIntervalMarker selectionMarker = new DAChartPlotIntervalMarker(-1, -1,
- DAChartPlotIntervalMarker.INTERVAL_MARKER_STYLE_AREA);
- selectionMarker.setBackgroundColor(ColorResources.SELECTION_RANGE);
- selectionMarker.setAlpha((int) (255 * 0.25));
- board.addIntervalMarker(selectionMarker);
-
- // range analysis marker
- DAChartPlotIntervalMarker rangeAnalyzeMarker = new DAChartPlotIntervalMarker(-1, -1,
- DAChartPlotIntervalMarker.INTERVAL_MARKER_STYLE_AREA);
- rangeAnalyzeMarker.setBackgroundColor(ColorResources.YELLOW);
- rangeAnalyzeMarker.setAlpha((int) (255 * 0.25));
- board.addIntervalMarker(rangeAnalyzeMarker);
-
- // range marker
- DAChartPlotIntervalMarker rangeMarker = new DAChartPlotIntervalMarker(-1, -1,
- DAChartPlotIntervalMarker.INTERVAL_MARKER_STYLE_LINE);
- rangeMarker.setForegroundColor(ColorResources.SELECTION_LINE);
- rangeMarker.setAlpha((int) (255 * 0.25));
- board.addIntervalMarker(rangeMarker);
- }
-
- @Override
- public void updateView() {
- InteractiveDataManager.getInstance().makeChartSeries(
- AnalyzerUtil.translateSecToMicroSec(chartBoard.getVisibleStartTime()),
- AnalyzerUtil.translateSecToMicroSec(chartBoard.getVisibleEndTime()));
-
- long time = Toolbar.INSTANCE.getTime();
- if (AnalyzerUtil.isLatestTraceMode(InteractivePage.pageID)) {
- DAChartPlotIntervalMarker intervalMarker = (DAChartPlotIntervalMarker) chartBoard.getMarkers().get(
- UICommonConstants.SELECTION_MARKER_INDEX);
- intervalMarker.setInterval(time / TimelineConstants.MEGA_DOUBLE, time / TimelineConstants.MEGA_DOUBLE);
- chartBoard.updateVisibleStartTime();
- chartBoard.setTotalEndTime(time, true);
- } else {
- chartBoard.setTotalEndTime(time, false);
- }
-
- if (RangeDataManager.getInstance().isBeingAnalyzed()) {
- ((DAChartPlotIntervalMarker) chartBoard.getMarkers().get(UICommonConstants.RANGE_ANALYSIS_MARKER_INDEX))
- .setInterval(rangeDataManager.getAnalysisStartTime() / TimelineConstants.MEGA_DOUBLE,
- rangeDataManager.getAnalysisEndTime() / TimelineConstants.MEGA_DOUBLE);
- } else {
- ((DAChartPlotIntervalMarker) chartBoard.getMarkers().get(UICommonConstants.RANGE_ANALYSIS_MARKER_INDEX))
- .setInterval(-1, -1);
- }
-
- ((DAChartPlotIntervalMarker) chartBoard.getMarkers().get(UICommonConstants.RANGE_MARKER_INDEX)).setInterval(
- rangeDataManager.getMarkerStartTime() / TimelineConstants.MEGA_DOUBLE,
- rangeDataManager.getMarkerEndTime() / TimelineConstants.MEGA_DOUBLE);
- }
-
- @Override
- public void updateView(DAViewData data) {
- if (data instanceof DASelectionData) {
- DASelectionData selData = (DASelectionData) data;
-
- long start = selData.getStartTime();
- long end = selData.getEndTime();
- Double startTime = Formatter.longTimeToDoubleTime(start);
- Double endTime = Formatter.longTimeToDoubleTime(end);
- double middleTime = (startTime + endTime) / 2.0;
- if (startTime.equals(endTime)) {
- middleTime = startTime;
- }
-
- chartBoard.setVisibleMiddleTime(middleTime);
- DAChartPlotIntervalMarker intervalMarker = (DAChartPlotIntervalMarker) chartBoard.getMarkers().get(
- UICommonConstants.SELECTION_MARKER_INDEX);
- intervalMarker.setInterval(startTime, endTime);
-
- InteractiveDataManager.getInstance().makeChartSeries(
- AnalyzerUtil.translateSecToMicroSec(chartBoard.getVisibleStartTime()),
- AnalyzerUtil.translateSecToMicroSec(chartBoard.getVisibleEndTime()));
- }
- }
-
- @Override
- public void clear() {
- chartBoard.contentsClear();
- chartBoard.clear();
- chartList.clear();
- for (TimelineChart timelineChart : InteractiveDataManager.getInstance().getTimelineChartList()) {
- timelineChart.clear();
- }
- initializeCharts();
- }
-
- @Override
- public Control getControl() {
- return chartBoard;
- }
-
- public void setRangeMarker(double starttime, double endtime) {
- ((DAChartPlotIntervalMarker) chartBoard.getMarkers().get(UICommonConstants.RANGE_MARKER_INDEX)).setInterval(
- starttime, endtime);
- }
-
- public void inputChartSeries(ResultSet rs) {
- // Key : variableID
- Map<Long, List<InteractiveValue>> valueInfoMap = InteractiveDataManager.getInstance().makeInteractiveValueMap(
- rs);
- if (valueInfoMap == null) {
- return;
- }
- /*
- * Make Chart series
- */
- for (int i = 0; i < chartList.size(); i++) {
- InteractiveInfo rootInteractiveInfo = chartList.get(i).getInteractiveInfo();
-
- List<InteractiveUIData> beforeUIDataList = new ArrayList<InteractiveUIData>();
- List<InteractiveUIData> afterUIDataList = new ArrayList<InteractiveUIData>();
- boolean result = InteractiveDataManager.getInstance().makeInteractiveUIData(rootInteractiveInfo,
- valueInfoMap, beforeUIDataList, afterUIDataList);
- if (result) {
- chartList.get(i).inputChartSeries(beforeUIDataList, afterUIDataList);
- } else {
- /*
- * Nothing to draw Chart. There is no series in visible range of Chart.
- */
- }
- }
- }
-
- /*
- * User can add Timeline chart on Chart Edit dialog and rearrange added
- * charts. but only Timeline charts can be rearranged. Value charts is not
- * rearranged.
- */
- public void reArrangeChart(List<Integer> order, List<Boolean> showInfo) {
- if (order != null) {
- int lastIndex = order.size();
- for (int i = 0; i < chartList.size(); i++) {
- order.add(lastIndex++);
- }
- chartBoard.reArrangeItem(order.toArray(new Integer[order.size()]));
- }
- for (int i = 0; i < showInfo.size(); i++) {
- if (showInfo.get(i)) {
- chartBoard.showItem(i);
- } else {
- chartBoard.hideItem(i);
- }
- }
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jungwook Ryu <jungwook.ryu@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.interactive.chart;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.TableItem;
-import org.tizen.dynamicanalyzer.ui.interactive.data.InteractiveDataManager;
-import org.tizen.dynamicanalyzer.ui.timeline.chart.TimelineChart;
-import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineEditItemsDialog;
-import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
-import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener;
-
-public class InteractiveEditItemsDialog extends TimelineEditItemsDialog {
- private InteractiveChartView chartView;
-
- public InteractiveEditItemsDialog(Shell parent, InteractiveChartView chartView_) {
- super(parent);
- this.chartView = chartView_;
- this.chartList = InteractiveDataManager.getInstance().getTimelineChartList();
- setOkButtonListener(okButtonListener);
- }
-
- @Override
- protected Set<String> getSelectedChartSet() {
- Set<String> chartNameList = new HashSet<String>();
- List<TimelineChart> selectedChartList = InteractiveDataManager.getInstance().getShowTimelineChartList();
- for (int i = 0; i < selectedChartList.size(); i++) {
- chartNameList.add(selectedChartList.get(i).getChartName());
- }
- return chartNameList;
- }
-
- private DACustomButtonClickEventListener okButtonListener = new DACustomButtonClickEventListener() {
- @Override
- public void handleClickEvent(DACustomButton button) {
- TableItem[] tableitems = chartTableViewer.getTable().getItems();
- ArrayList<Integer> order = new ArrayList<Integer>();
- ArrayList<Boolean> showInfo = new ArrayList<Boolean>();
- List<TimelineChart> selectedChartList = new ArrayList<TimelineChart>();
-
- List<TimelineChart> tempChartList = new ArrayList<TimelineChart>(chartList);
- chartList.clear();
- for (TableItem item : tableitems) { // Rearrange chart order
- TableItemData itemData = (TableItemData) item.getData();
- TimelineChart chart = findChart(tempChartList, itemData.chartType);
- chartList.add(chart);
-
- if (itemData.isEnabled) {
- selectedChartList.add(chart);
- showInfo.add(true);
- } else {
- showInfo.add(false);
- }
-
- order.add(itemData.index);
- }
-
- InteractiveDataManager.getInstance().setShowTimelineChartList(selectedChartList);
- chartView.reArrangeChart(order, showInfo);
- shell.dispose();
- RunningDialog = false;
- }
- };
-
- private TimelineChart findChart(List<TimelineChart> chartList, int chartType) {
- if (chartList != null) {
- for (int i = 0; i < chartList.size(); i++) {
- if (chartType == chartList.get(i).getChartType()) {
- return chartList.get(i);
- }
- }
- }
- return null;
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jungwook Ryu <jungwook.ryu@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.interactive.data;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.swt.widgets.Display;
-import org.tizen.dynamicanalyzer.communicator.UnsupportedProtocolException;
-import org.tizen.dynamicanalyzer.database.DBInserter;
-import org.tizen.dynamicanalyzer.database.SqlConnectionManager;
-import org.tizen.dynamicanalyzer.protocol.ProtocolConstants;
-import org.tizen.dynamicanalyzer.swap.logparser.LogPackage;
-import org.tizen.dynamicanalyzer.swap.logparser.Logs;
-import org.tizen.dynamicanalyzer.swap.logparser.PageDataManager;
-import org.tizen.dynamicanalyzer.swap.model.data.FunctionBodyInstrumentData;
-import org.tizen.dynamicanalyzer.swap.model.data.LogData;
-import org.tizen.dynamicanalyzer.ui.interactive.InteractivePage;
-import org.tizen.dynamicanalyzer.ui.interactive.chart.InteractiveChartView;
-import org.tizen.dynamicanalyzer.ui.interactive.model.InteractiveInfo;
-import org.tizen.dynamicanalyzer.ui.interactive.model.InteractiveParser;
-import org.tizen.dynamicanalyzer.ui.interactive.model.VAR_TYPE;
-import org.tizen.dynamicanalyzer.ui.page.BaseView;
-import org.tizen.dynamicanalyzer.ui.timeline.chart.CPUChart;
-import org.tizen.dynamicanalyzer.ui.timeline.chart.CPUCoreChart;
-import org.tizen.dynamicanalyzer.ui.timeline.chart.CPUFrequencyChart;
-import org.tizen.dynamicanalyzer.ui.timeline.chart.DeviceChart;
-import org.tizen.dynamicanalyzer.ui.timeline.chart.DiskIOChart;
-import org.tizen.dynamicanalyzer.ui.timeline.chart.EnergyChart;
-import org.tizen.dynamicanalyzer.ui.timeline.chart.HeapChart;
-import org.tizen.dynamicanalyzer.ui.timeline.chart.NetworkIOChart;
-import org.tizen.dynamicanalyzer.ui.timeline.chart.ProcessMemoryChart;
-import org.tizen.dynamicanalyzer.ui.timeline.chart.ScreenshotChart;
-import org.tizen.dynamicanalyzer.ui.timeline.chart.SystemMemoryChart;
-import org.tizen.dynamicanalyzer.ui.timeline.chart.TimelineChart;
-import org.tizen.dynamicanalyzer.ui.timeline.chart.UIEventChart;
-import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineDataManager;
-import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
-import org.tizen.dynamicanalyzer.util.Logger;
-import org.tizen.dynamicanalyzer.util.WorkbenchUtil;
-import org.tizen.dynamicanalyzer.widgets.chartBoard.IDAChartSeriesMaker;
-
-public class InteractiveDataManager extends PageDataManager implements IDAChartSeriesMaker {
- private static InteractiveDataManager instance = null;
-
- private InteractiveVariableDBTable variableDBTable = null;
- private InteractiveValueDBTable valueDBTable = null;
- private DBInserter valueDBInserter = null;
- // Only contain target variables
- private List<InteractiveInfo> variableInfoList = new ArrayList<InteractiveInfo>();
- private InteractiveChartView chartView;
- private List<TimelineChart> timelineChartList = new ArrayList<TimelineChart>();
- private List<TimelineChart> showTimelineChartList = new ArrayList<TimelineChart>();
-
- private InteractiveDataManager() {
- variableDBTable = new InteractiveVariableDBTable();
- valueDBTable = new InteractiveValueDBTable();
- valueDBInserter = makeInserter(valueDBTable);
-
- timelineChartList.add(new CPUChart(InteractivePage.pageID));
- timelineChartList.add(new CPUCoreChart(InteractivePage.pageID));
- timelineChartList.add(new CPUFrequencyChart(InteractivePage.pageID));
- timelineChartList.add(new HeapChart(InteractivePage.pageID));
- timelineChartList.add(new ProcessMemoryChart(InteractivePage.pageID));
- timelineChartList.add(new SystemMemoryChart(InteractivePage.pageID));
- timelineChartList.add(new ScreenshotChart(InteractivePage.pageID));
- timelineChartList.add(new UIEventChart(InteractivePage.pageID));
- timelineChartList.add(new DiskIOChart(InteractivePage.pageID));
- timelineChartList.add(new NetworkIOChart(InteractivePage.pageID));
- timelineChartList.add(new DeviceChart(InteractivePage.pageID));
- timelineChartList.add(new EnergyChart(InteractivePage.pageID));
- }
-
- public synchronized static InteractiveDataManager getInstance() {
- if (null == instance) {
- instance = new InteractiveDataManager();
- }
- return instance;
- }
-
- public List<InteractiveInfo> getVariableInfoList() {
- return variableInfoList;
- }
-
- public void setChartView(InteractiveChartView chartView) {
- this.chartView = chartView;
- }
-
- public List<TimelineChart> getTimelineChartList() {
- return timelineChartList;
- }
-
- public List<TimelineChart> getShowTimelineChartList() {
- return showTimelineChartList;
- }
-
- public void setShowTimelineChartList(List<TimelineChart> chartList) {
- showTimelineChartList.clear();
- showTimelineChartList.addAll(chartList);
- }
-
- public void addVariableInfo(InteractiveInfo info) {
- variableInfoList.add(info);
- }
-
- public static ResultSet getValueDataFromDB(long start, long end) {
- String query = "SELECT SEQUENCE_NUMBER, SAMPLING_TIME, VARIABLE_ID, VALUE_SIZE, VALUE FROM CHECKPOINT_VALUE "
- + "WHERE SAMPLING_TIME BETWEEN " + start + " AND " + end + " ORDER BY SAMPLING_TIME";
- ResultSet rs = SqlConnectionManager.executeQueryRS(query);
-
- return rs;
- }
-
- public ResultSet getValueDataFromDB(InteractiveInfo interactiveInfo) {
- String query = "SELECT SEQUENCE_NUMBER, SAMPLING_TIME, VARIABLE_ID, VALUE_SIZE, VALUE FROM CHECKPOINT_VALUE "
- + "WHERE VARIABLE_ID IN (";
- List<Long> variableIDList = new ArrayList<Long>();
- interactiveInfo.getAllRelatedVariableIDs(variableIDList, interactiveInfo.getCheckLocation());
- for (int i = 0; i < variableIDList.size(); i++) {
- query += variableIDList.get(i);
- if (i + 1 < variableIDList.size()) {
- query += ",";
- }
- }
- query += ")";
- ResultSet rs = SqlConnectionManager.executeQueryRS(query);
- return rs;
- }
-
- @Override
- public void saveData(Map<String, String> dataMap) {
- List<List<Object>> list = new ArrayList<List<Object>>();
- insertVariableInfo(variableInfoList, list);
- variableDBTable.insertData(list);
- }
-
- private void insertVariableInfo(List<InteractiveInfo> infoList, List<List<Object>> list) {
- for (int i = 0; i < infoList.size(); i++) {
- ArrayList<Object> dbVariableData = new ArrayList<Object>();
- InteractiveInfo info = infoList.get(i);
- dbVariableData.add(info.getVariableID(InteractiveInfo.CHECK_BEFORE_LINE));
- dbVariableData.add(info.getVariableID(InteractiveInfo.CHECK_AFTER_LINE));
- dbVariableData.add(info.getCheckLocation());
- dbVariableData.add(info.getType().ordinal());
- dbVariableData.add(info.getTypeName());
- dbVariableData.add(info.getVariableName());
- dbVariableData.add(info.getFunctionID());
- dbVariableData.add(info.getSourceLineNum());
- dbVariableData.add(info.getSourceFileName());
- dbVariableData.add(info.getPointerOrder());
- dbVariableData.add(info.getPointerSize());
- dbVariableData.add(info.getArrayCount());
- dbVariableData.add(info.getByteSize());
- dbVariableData.add(info.getOffset());
- dbVariableData.add(info.isTarget());
- dbVariableData.add(info.getChildrenIDs());
- list.add(dbVariableData);
- if (info.getChildren() != null) {
- insertVariableInfo(info.getChildren(), list);
- }
- }
- }
-
- @Override
- public void openData(Map<String, String> dataMap) {
- variableInfoList.clear();
- List<List<Object>> datas = variableDBTable.selectAllColumnData(null);
- if (datas == null) {
- return;
- }
-
- Map<InteractiveInfo, List<Long>> relationMap = new HashMap<InteractiveInfo, List<Long>>();
- for (int i = 0; i < datas.size(); i++) {
- List<Object> row = datas.get(i);
- long beforeVariableID = ((Long) row.get(InteractiveVariableDBTable.COLUMN.BEFORE_VARIABLE_ID.ordinal()))
- .longValue();
- long afterVariableID = ((Long) row.get(InteractiveVariableDBTable.COLUMN.AFTER_VARIABLE_ID.ordinal()))
- .longValue();
- int checkLocation = ((Integer) row.get(InteractiveVariableDBTable.COLUMN.CHECK_LOCATION.ordinal()))
- .intValue();
- VAR_TYPE variableType = VAR_TYPE.values()[((Integer) row
- .get(InteractiveVariableDBTable.COLUMN.VARIABLE_TYPE.ordinal())).intValue()];
- String typeName = (String) row.get(InteractiveVariableDBTable.COLUMN.VARIABLE_TYPE_NAME.ordinal());
- String variableName = (String) row.get(InteractiveVariableDBTable.COLUMN.VARIABLE_NAME.ordinal());
- int functionID = ((Integer) row.get(InteractiveVariableDBTable.COLUMN.FUNCTION_ID.ordinal()))
- .intValue();
- int sourceLineNum = ((Integer) row.get(InteractiveVariableDBTable.COLUMN.SOURCE_LINE_NUMBER.ordinal()))
- .intValue();
- String sourceFileName = (String) row.get(InteractiveVariableDBTable.COLUMN.SOURCE_FILE_NAME.ordinal());
- int pointerOrder = ((Integer) row.get(InteractiveVariableDBTable.COLUMN.POINTER_ORDER.ordinal()))
- .intValue();
- int pointerSize = ((Integer) row.get(InteractiveVariableDBTable.COLUMN.POINTER_SIZE.ordinal())).intValue();
- int arrayCount = ((Integer) row.get(InteractiveVariableDBTable.COLUMN.ARRAY_COUNT.ordinal())).intValue();
- int byteSize = ((Integer) row.get(InteractiveVariableDBTable.COLUMN.BYTE_SIZE.ordinal())).intValue();
- boolean isTarget = ((Boolean) row.get(InteractiveVariableDBTable.COLUMN.IS_TARGET.ordinal()))
- .booleanValue();
- int offset = ((Integer) row.get(InteractiveVariableDBTable.COLUMN.OFFSET.ordinal())).intValue();
- @SuppressWarnings("unchecked")
- List<Long> childrenID = (List<Long>) row.get(InteractiveVariableDBTable.COLUMN.CHILDREN_VARIABLE_ID
- .ordinal());
-
- InteractiveInfo valueInfo = new InteractiveInfo();
- valueInfo.setVariableID(InteractiveInfo.CHECK_BEFORE_LINE, beforeVariableID);
- valueInfo.setVariableID(InteractiveInfo.CHECK_AFTER_LINE, afterVariableID);
- valueInfo.setCheckLocation(checkLocation);
- valueInfo.setType(variableType);
- valueInfo.setTypeName(typeName);
- valueInfo.setVariableName(variableName);
- valueInfo.setFunctionID(functionID);
- valueInfo.setSourceLineNum(sourceLineNum);
- valueInfo.setSourceFileName(sourceFileName);
- valueInfo.setPointerOrder(pointerOrder);
- valueInfo.setPointerSize(pointerSize);
- valueInfo.setArrayCount(arrayCount);
- valueInfo.setByteSize(byteSize);
- valueInfo.setOffset(offset);
- valueInfo.setTarget(isTarget);
- if (isTarget) { // target variable, only this info show in chart.
- variableInfoList.add(valueInfo);
- }
- relationMap.put(valueInfo, childrenID);
- }
- makeRelation(relationMap);
-
- /*
- * Refresh InteractiveChartView
- * because this method is called after InteractiveChartView creation.
- */
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- if (chartView != null) {
- chartView.clear();
- }
- }
- });
- }
-
- private void makeRelation(Map<InteractiveInfo, List<Long>> relationMap) {
- Iterator<InteractiveInfo> iter = relationMap.keySet().iterator();
- while (iter.hasNext()) {
- InteractiveInfo parent = iter.next();
- List<Long> childrenIDs = relationMap.get(parent);
- if (childrenIDs != null) {
- List<InteractiveInfo> children = new ArrayList<InteractiveInfo>();
- for (int i = 0; i < childrenIDs.size(); i++) {
- InteractiveInfo child = findInfo(relationMap.keySet(), childrenIDs.get(i));
- if (child == null) {
- Logger.error("Child does not exist.");
- continue;
- }
- if (children.contains(child) == false) {
- child.setParent(parent);
- children.add(child);
- }
- parent.setChildren(children);
- }
- }
- }
- }
-
- private InteractiveInfo findInfo(Set<InteractiveInfo> infoSet, long variableID) {
- Iterator<InteractiveInfo> iter = infoSet.iterator();
- while (iter.hasNext()) {
- InteractiveInfo target = iter.next();
- if (target.hasVariableID(variableID)) {
- return target;
- }
- }
- return null;
- }
-
- @Override
- protected void makeData(LogPackage pack) {
- Logs fbiLogs = pack.getLogs(ProtocolConstants.MSG_FUNCTION_BODY);
- List<LogData> fbiLogList = fbiLogs == null ? null : fbiLogs.getRawLogs();
-
- if (fbiLogList != null) {
- List<List<Object>> valueDataList = new ArrayList<List<Object>>();
- for (int i = 0; i < fbiLogList.size(); i++) {
- FunctionBodyInstrumentData log = (FunctionBodyInstrumentData) fbiLogList.get(i);
- try {
- long variableID = log.getVariableID().getValue();
- long size = log.getSize().getValue();
- byte[] data = log.getData();
-
- ArrayList<Object> dbValueData = new ArrayList<Object>();
- dbValueData.add(new Long(log.getSeq()));
- dbValueData.add(new Long(log.getTime()));
- dbValueData.add(new Long(variableID));
- dbValueData.add(new Long(size));
- dbValueData.add(data);
-
- valueDataList.add(dbValueData);
- } catch (UnsupportedProtocolException ex) {
- // TODO need to policy of exception handling
- Logger.exception(ex);
- }
- }
- valueDBInserter.pushData(valueDataList);
- }
- }
-
- @Override
- public void makeChartSeries(long startTime, long endTime) {
- chartView.inputChartSeries(getValueDataFromDB(startTime, endTime));
-
- List<List<Object>> systemDBData = TimelineDataManager.getInstance().getSystemDataFromDB(startTime, endTime);
- List<List<Object>> uiEventDBData = TimelineDataManager.getInstance().getUIEventDataFromDB(startTime, endTime);
- List<List<Object>> screenShotDBData = TimelineDataManager.getInstance().getScreenShotDataFromDB(startTime,
- endTime);
-
- int selectedPID = 0;
- if (Toolbar.INSTANCE != null) {
- selectedPID = Toolbar.INSTANCE.getSelectedPid();
- }
- Map<Integer, List<List<Object>>> targetProcessDBData = TimelineDataManager.getInstance()
- .getTargetProcessDataFromDB(startTime, endTime, selectedPID);
-
- /*
- * 2. Make series of chart
- */
- for (TimelineChart chart : timelineChartList) {
- if (chart.getProbeType() == ProtocolConstants.MSG_DATA_SYSTEM) {
- List<Object> dataList = new ArrayList<Object>();
- dataList.add(systemDBData);
- dataList.add(targetProcessDBData);
- chart.inputChartSeries(dataList);
- } else if (chart.getProbeType() == ProtocolConstants.MSG_PROBE_UIEVENT) {
- List<Object> dataList = new ArrayList<Object>();
- dataList.add(uiEventDBData);
- chart.inputChartSeries(dataList);
- } else if (chart.getProbeType() == ProtocolConstants.MSG_PROBE_SCREENSHOT) {
- List<Object> dataList = new ArrayList<Object>();
- dataList.add(screenShotDBData);
- chart.inputChartSeries(dataList);
- }
- }
- }
-
- public Map<Long, List<InteractiveValue>> makeInteractiveValueMap(ResultSet rs) {
- if (rs == null) {
- return null;
- }
- // Key : variableID
- Map<Long, List<InteractiveValue>> valueInfoMap = new HashMap<Long, List<InteractiveValue>>();
- try {
- while (rs.next()) {
- long seq = rs.getLong(1);
- long time = rs.getLong(2);
- long id = rs.getLong(3);
- byte[] value = rs.getBytes(5);
- List<InteractiveValue> valueInfoList = valueInfoMap.get(id);
- if (valueInfoList == null) {
- valueInfoList = new ArrayList<InteractiveValue>();
- valueInfoMap.put(id, valueInfoList);
- }
- valueInfoList.add(new InteractiveValue(seq, time, id, value));
- }
- } catch (SQLException e) {
- Logger.error(e);
- return null;
- } finally {
- SqlConnectionManager.releaseResultSet(rs);
- }
- if (valueInfoMap.isEmpty()) {
- return null;
- }
- return valueInfoMap;
- }
-
- /*
- * Object of this method is to make data for UI (chart, table)
- * If you want to understand this logic, refer to the document (Interactive profiling_Analysis_Design.pptx)
- */
- public boolean makeInteractiveUIData(InteractiveInfo interactiveInfo, Map<Long, List<InteractiveValue>> valueInfoMap,
- List<InteractiveUIData> beforeUIDataList, List<InteractiveUIData> afterUIDataList) {
- List<InteractiveValue> rootBeforeValueInfoList = valueInfoMap.get(interactiveInfo
- .getVariableID(InteractiveInfo.CHECK_BEFORE_LINE));
- List<InteractiveValue> rootAfterValueInfoList = valueInfoMap.get(interactiveInfo
- .getVariableID(InteractiveInfo.CHECK_AFTER_LINE));
- if (rootBeforeValueInfoList == null && rootAfterValueInfoList == null) {
- return false;
- }
-
- List<List<InteractiveValue>> childrenBeforeValueInfoList = new ArrayList<List<InteractiveValue>>();
- List<List<InteractiveValue>> childrenAfterValueInfoList = new ArrayList<List<InteractiveValue>>();
- Iterator<Long> variableIDIter = valueInfoMap.keySet().iterator();
- while (variableIDIter.hasNext()) {
- long variableID = variableIDIter.next();
- if (interactiveInfo.hasChild(variableID, InteractiveInfo.CHECK_BEFORE_LINE)) {
- childrenBeforeValueInfoList.add(valueInfoMap.get(variableID));
- } else if (interactiveInfo.hasChild(variableID, InteractiveInfo.CHECK_AFTER_LINE)) {
- childrenAfterValueInfoList.add(valueInfoMap.get(variableID));
- } else {
- // Do nothing
- }
- }
- parseValue(interactiveInfo, InteractiveInfo.CHECK_BEFORE_LINE,
- rootBeforeValueInfoList, childrenBeforeValueInfoList, beforeUIDataList);
- parseValue(interactiveInfo, InteractiveInfo.CHECK_AFTER_LINE,
- rootAfterValueInfoList, childrenAfterValueInfoList, afterUIDataList);
- return true;
- }
-
- private void parseValue(InteractiveInfo interactiveInfo, int checkLocation,
- List<InteractiveValue> rootValueInfoList, List<List<InteractiveValue>> childrenValueInfoList,
- List<InteractiveUIData> parsedUIDataList) {
- if (rootValueInfoList == null) {
- return;
- }
- for (int i = 0; i < rootValueInfoList.size(); i++) {
- Map<Long, byte[]> valueMap = new HashMap<Long, byte[]>(); // Map<variableID, value>
- valueMap.put(interactiveInfo.getVariableID(checkLocation), rootValueInfoList.get(i).value);
- for (int k = 0; k < childrenValueInfoList.size(); k++) {
- if (childrenValueInfoList.get(k).size() > i) { // Child is in root's range
- InteractiveValue valueInfo = childrenValueInfoList.get(k).get(i);
- valueMap.put(valueInfo.variableID, valueInfo.value);
- } else {
- // FBI probe of root is sent more than FBI probe of children.
- Logger.error("rootValueInfo size is larger than childrenValueInfo size.");
- }
- }
- InteractiveUIData uiData = InteractiveParser.parseValue(interactiveInfo, checkLocation, valueMap);
- if (uiData != null) {
- uiData.setSeq(rootValueInfoList.get(i).seq);
- uiData.setTime(rootValueInfoList.get(i).time);
- parsedUIDataList.add(uiData);
- }
- }
- }
-
- public void clear() {
- // Remove a CheckPoint tab
- BaseView baseView = (BaseView) WorkbenchUtil.getViewPart(BaseView.ID);
- if (baseView != null) {
- baseView.removeTabViewPage(InteractivePage.pageID, true);
- } else {
- Logger.error("BaseView is null!!");
- }
- variableInfoList.clear();
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jungwook Ryu <jungwook.ryu@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.interactive.data;
-
-import java.util.List;
-
-import org.tizen.dynamicanalyzer.nl.InteractivePageLabels;
-import org.tizen.dynamicanalyzer.ui.interactive.model.InteractiveInfo;
-
-public class InteractiveUIData implements Comparable {
- private final static long UNSET_SEQ = -1;
-
- private long tableRowID; /* need for table row identity */
- private long seq = UNSET_SEQ; // sequence number from SWAP
- private long time;
- private String type;
- private String name;
- private Object value;
- private boolean array = false;
- private int checkLocation;
- private InteractiveInfo interactiveInfo;
- private List<InteractiveUIData> children;
-
- public InteractiveUIData(InteractiveInfo interactiveInfo, int checkLocation) {
- this.interactiveInfo = interactiveInfo;
- this.type = interactiveInfo.getTypeNameWithPointer();
- this.name = interactiveInfo.getVariableName();
- this.checkLocation = checkLocation;
- }
-
- public long getTableRowID() {
- return tableRowID;
- }
-
- public void setTableRowID(long tableRowID) {
- this.tableRowID = tableRowID;
- }
-
- public long getSeq() {
- return seq;
- }
-
- public void setSeq(long seq) {
- this.seq = seq;
- }
-
- public long getTime() {
- return time;
- }
-
- public void setTime(long time) {
- this.time = time;
- }
-
- public boolean isArray() {
- return array;
- }
-
- public void setArray(boolean array) {
- this.array = array;
- }
-
- public String getType() {
- if (array) {
- type += " [" + children.size() + "]";
- }
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public Object getValue() {
- if (array || children != null) {
- return getComplexValue();
- }
- if (value == null) {
- return "This variable type is not supported.";
- }
- return value;
- }
-
- public void setValue(Object value) {
- this.value = value;
- }
-
- public List<InteractiveUIData> getChildren() {
- return children;
- }
-
- public void setChildren(List<InteractiveUIData> children) {
- this.children = children;
- }
-
- public InteractiveInfo getVariableInfo() {
- return interactiveInfo;
- }
-
- public int getCheckLocation() {
- return checkLocation;
- }
-
- private String getComplexValue() {
- String complexValue = "[";
- for (int i = 0; i < children.size(); i++) {
- InteractiveUIData child = children.get(i);
- if (child == null) {
- complexValue += InteractivePageLabels.INTERACTIVE_CHART_INVALID_CHECK_LOCATION;
- } else if (child.isArray() || child.getChildren() != null) {
- complexValue += child.getComplexValue();
- } else {
- complexValue += child.getValue();
- }
- if (i != children.size() - 1) { // is not last index
- complexValue += ", ";
- }
- }
- return complexValue + "]";
- }
-
- public String getChartTooltipString() {
- if (array || children != null) {
- return getComplexValue();
- }
- return getType() + " " + name + " : " + getValue();
- }
-
- @Override
- public int compareTo(Object arg0) {
- if (arg0 instanceof InteractiveUIData) {
- return (int) (time - ((InteractiveUIData) arg0).time);
- }
- return 0;
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jungwook Ryu <jungwook.ryu@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.interactive.data;
-
-public class InteractiveValue {
- long seq;
- long time;
- long variableID;
- byte[] value;
-
- public InteractiveValue(long seq, long time, long variableID, byte[] value) {
- this.seq = seq;
- this.time = time;
- this.variableID = variableID;
- this.value = value;
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jungwook Ryu <jungwook.ryu@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.interactive.data;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.tizen.dynamicanalyzer.database.DBColumn;
-import org.tizen.dynamicanalyzer.database.DBConstants;
-import org.tizen.dynamicanalyzer.database.DBTable;
-import org.tizen.dynamicanalyzer.util.Logger;
-
-public class InteractiveValueDBTable extends DBTable {
- private static final String TABLENAME = "CHECKPOINT_VALUE";
-
- private final static int MAX_BYTES_LEN = 1024;
-
- public static enum COLUMN {
- SEQUENCE_NUMBER,
- SAMPLING_TIME,
- VARIABLE_ID,
- VALUE_SIZE,
- VALUE
- }
-
- public static final String SEQUENCE_NUMBER = "SEQUENCE_NUMBER";
- public static final String SAMPLING_TIME = "SAMPLING_TIME";
- public static final String VARIABLE_ID = "VARIABLE_ID";
- public static final String VALUE_SIZE = "VALUE_SIZE";
- public static final String VALUE = "VALUE";
-
- @Override
- public String getTableName() {
- return TABLENAME;
- }
-
- public InteractiveValueDBTable() {
- addColumn(new DBColumn(SEQUENCE_NUMBER, DBConstants.PRIMARY_KEY, DBConstants.DBTYPE_LONG));
- addColumn(new DBColumn(SAMPLING_TIME, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
- addColumn(new DBColumn(VARIABLE_ID, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
- addColumn(new DBColumn(VALUE_SIZE, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
- addColumn(new DBColumn(VALUE, DBConstants.NOT_NULL, DBConstants.DBTYPE_VARBINARY, MAX_BYTES_LEN));
- }
-
- @Override
- public boolean prepare(PreparedStatement prep, List<Object> rowData) {
- boolean isPrepared = true;
-
- int columnsize = getColumnSize();
- if (columnsize != rowData.size()) {
- isPrepared = false;
- } else {
- try {
- int index = 1;
- prep.setLong(index++, (Long) (rowData.get(COLUMN.SEQUENCE_NUMBER.ordinal())));
- prep.setLong(index++, (Long) (rowData.get(COLUMN.SAMPLING_TIME.ordinal())));
- prep.setLong(index++, (Long) (rowData.get(COLUMN.VARIABLE_ID.ordinal())));
- prep.setLong(index++, (Long) (rowData.get(COLUMN.VALUE_SIZE.ordinal())));
- prep.setBytes(index++, (byte[]) (rowData.get(COLUMN.VALUE.ordinal())));
- } catch (SQLException e) {
- Logger.error(e);
- isPrepared = false;
- }
- }
-
- return isPrepared;
- }
-
- @Override
- public List<Object> extractDataFromResultSet(ResultSet rs) {
- List<Object> row = new ArrayList<Object>();
- try {
- row.add(Long.valueOf(rs.getLong(1)));
- row.add(Long.valueOf(rs.getLong(2)));
- row.add(Long.valueOf(rs.getLong(3)));
- row.add(Long.valueOf(rs.getLong(4)));
- row.add(rs.getBytes(5));
-// row.add(getArrayFromResultSet(rs, 3, String.valueOf(0)));
- } catch (SQLException e) {
- Logger.error(e);
- return null;
- }
- return row;
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jungwook Ryu <jungwook.ryu@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.interactive.data;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.tizen.dynamicanalyzer.database.DBColumn;
-import org.tizen.dynamicanalyzer.database.DBConstants;
-import org.tizen.dynamicanalyzer.database.DBTable;
-import org.tizen.dynamicanalyzer.util.Logger;
-
-public class InteractiveVariableDBTable extends DBTable {
- private static final String TABLENAME = "CHECKPOINT_VARIABLE";
-
- private final static int MAX_NAME_LEN = 128;
- private final static int MAX_TYPE_LEN = 64;
-
- public static enum COLUMN {
- BEFORE_VARIABLE_ID,
- AFTER_VARIABLE_ID,
- CHECK_LOCATION,
- VARIABLE_TYPE,
- VARIABLE_TYPE_NAME,
- VARIABLE_NAME,
- FUNCTION_ID,
- SOURCE_LINE_NUMBER,
- SOURCE_FILE_NAME,
- POINTER_ORDER,
- POINTER_SIZE,
- ARRAY_COUNT,
- BYTE_SIZE,
- OFFSET,
- IS_TARGET,
- CHILDREN_VARIABLE_ID
- }
-
- public static final String BEFORE_VARIABLE_ID = "BEFORE_VARIABLE_ID";
- public static final String AFTER_VARIABLE_ID = "AFTER_VARIABLE_ID";
- public static final String CHECK_LOCATION = "CHECK_LOCATION";
- public static final String VARIABLE_TYPE = "VARIABLE_TYPE";
- public static final String VARIABLE_TYPE_NAME = "VARIABLE_TYPE_NAME";
- public static final String VARIABLE_NAME = "VARIABLE_NAME";
- public static final String FUNCTION_ID = "FUNCTION_ID";
- public static final String SOURCE_LINE_NUMBER = "SOURCE_LINE_NUMBER";
- public static final String SOURCE_FILE_NAME = "SOURCE_FILE_NAME";
- public static final String POINTER_ORDER = "POINTER_ORDER";
- public static final String POINTER_SIZE = "POINTER_SIZE";
- public static final String ARRAY_COUNT = "ARRAY_COUNT";
- public static final String BYTE_SIZE = "BYTE_SIZE";
- public static final String OFFSET = "OFFSET";
- public static final String IS_TARGET = "IS_TARGET";
- public static final String CHILDREN_VARIABLE_ID = "CHILDREN_VARIABLE_ID";
-
- @Override
- public String getTableName() {
- return TABLENAME;
- }
-
- public InteractiveVariableDBTable() {
- addColumn(new DBColumn(BEFORE_VARIABLE_ID, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
- addColumn(new DBColumn(AFTER_VARIABLE_ID, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
- addColumn(new DBColumn(CHECK_LOCATION, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
- addColumn(new DBColumn(VARIABLE_TYPE, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
- addColumn(new DBColumn(VARIABLE_TYPE_NAME, DBConstants.EMPTY, DBConstants.DBTYPE_VARCHAR, MAX_TYPE_LEN));
- addColumn(new DBColumn(VARIABLE_NAME, DBConstants.NOT_NULL, DBConstants.DBTYPE_VARCHAR, MAX_NAME_LEN));
- addColumn(new DBColumn(FUNCTION_ID, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
- addColumn(new DBColumn(SOURCE_LINE_NUMBER, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
- addColumn(new DBColumn(SOURCE_FILE_NAME, DBConstants.NOT_NULL, DBConstants.DBTYPE_VARCHAR, MAX_NAME_LEN));
- addColumn(new DBColumn(POINTER_ORDER, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
- addColumn(new DBColumn(POINTER_SIZE, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
- addColumn(new DBColumn(ARRAY_COUNT, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
- addColumn(new DBColumn(BYTE_SIZE, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
- addColumn(new DBColumn(OFFSET, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
- addColumn(new DBColumn(IS_TARGET, DBConstants.NOT_NULL, DBConstants.DBTYPE_BOOLEAN));
- addColumn(new DBColumn(CHILDREN_VARIABLE_ID, DBConstants.EMPTY, DBConstants.BIGINT_ARRAY));
- }
-
- @Override
- public boolean prepare(PreparedStatement prep, List<Object> rowData) {
- boolean isPrepared = true;
-
- int columnsize = getColumnSize();
- if (columnsize != rowData.size()) {
- isPrepared = false;
- } else {
- try {
- int index = 1;
- prep.setLong(index++, (Long) (rowData.get(COLUMN.BEFORE_VARIABLE_ID.ordinal())));
- prep.setLong(index++, (Long) (rowData.get(COLUMN.AFTER_VARIABLE_ID.ordinal())));
- prep.setInt(index++, (Integer) (rowData.get(COLUMN.CHECK_LOCATION.ordinal())));
- prep.setInt(index++, (Integer) (rowData.get(COLUMN.VARIABLE_TYPE.ordinal())));
- // Check string overflow
- String name = (String) (rowData.get(COLUMN.VARIABLE_TYPE_NAME.ordinal()));
- if (name != null && name.length() > MAX_TYPE_LEN) {
- Logger.warning("Overflow occurs VARIABLE_TYPE_NAME in InteractiveVariableDBTable : " + name);
- name = name.substring(0, MAX_NAME_LEN);
- }
- prep.setString(index++, name);
- // Check string overflow
- name = (String) (rowData.get(COLUMN.VARIABLE_NAME.ordinal()));
- if (name != null && name.length() > MAX_NAME_LEN) {
- Logger.warning("Overflow occurs VARIABLE_NAME in InteractiveVariableDBTable : " + name);
- name = name.substring(0, MAX_NAME_LEN);
- }
- prep.setString(index++, name);
- prep.setInt(index++, (Integer) (rowData.get(COLUMN.FUNCTION_ID.ordinal())));
- prep.setInt(index++, (Integer) (rowData.get(COLUMN.SOURCE_LINE_NUMBER.ordinal())));
- // Check string overflow
- name = (String) (rowData.get(COLUMN.SOURCE_FILE_NAME.ordinal()));
- if (name != null && name.length() > MAX_NAME_LEN) {
- Logger.warning("Overflow occurs SOURCE_FILE_NAME in InteractiveVariableDBTable : " + name);
- name = name.substring(0, MAX_NAME_LEN);
- }
- prep.setString(index++, name);
- prep.setInt(index++, (Integer) (rowData.get(COLUMN.POINTER_ORDER.ordinal())));
- prep.setInt(index++, (Integer) (rowData.get(COLUMN.POINTER_SIZE.ordinal())));
- prep.setInt(index++, (Integer) (rowData.get(COLUMN.ARRAY_COUNT.ordinal())));
- prep.setInt(index++, (Integer) (rowData.get(COLUMN.BYTE_SIZE.ordinal())));
- prep.setInt(index++, (Integer) (rowData.get(COLUMN.OFFSET.ordinal())));
- prep.setBoolean(index++, (Boolean) (rowData.get(COLUMN.IS_TARGET.ordinal())));
- setArrayToPreparedStatement(COLUMN.CHILDREN_VARIABLE_ID.ordinal(), DBConstants.DBTYPE_LONG, prep, rowData);
- } catch (SQLException e) {
- Logger.error(e);
- isPrepared = false;
- }
- }
-
- return isPrepared;
- }
-
- @Override
- public List<Object> extractDataFromResultSet(ResultSet rs) {
- List<Object> row = new ArrayList<Object>();
- try {
- int index = 1;
- row.add(Long.valueOf(rs.getLong(index++)));
- row.add(Long.valueOf(rs.getLong(index++)));
- row.add(Integer.valueOf(rs.getInt(index++)));
- row.add(Integer.valueOf(rs.getInt(index++)));
- row.add(rs.getString(index++));
- row.add(rs.getString(index++));
- row.add(Integer.valueOf(rs.getInt(index++)));
- row.add(Integer.valueOf(rs.getInt(index++)));
- row.add(rs.getString(index++));
- row.add(Integer.valueOf(rs.getInt(index++)));
- row.add(Integer.valueOf(rs.getInt(index++)));
- row.add(Integer.valueOf(rs.getInt(index++)));
- row.add(Integer.valueOf(rs.getInt(index++)));
- row.add(Integer.valueOf(rs.getInt(index++)));
- row.add(Boolean.valueOf(rs.getBoolean(index++)));
- row.add(getArrayFromResultSet(rs, index++, Long.valueOf(0)));
- } catch (SQLException e) {
- Logger.error(e);
- return null;
- }
- return row;
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jungwook Ryu <jungwook.ryu@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.interactive.model;
-
-public class InteractiveIDGenerator {
- private static int id = 0;
-
- public static synchronized int generateID() {
- return ++id;
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jungwook Ryu <jungwook.ryu@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.interactive.model;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.tizen.dynamicanalyzer.common.Global;
-import org.tizen.dynamicanalyzer.util.Logger;
-import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
-
-public class InteractiveInfo {
- public final static int NO_SET_VARIABLE_ID = -1;
- public final static int CHECK_BEFORE_LINE = 1;
- public final static int CHECK_AFTER_LINE = 2;
- public final static int CHECK_BEFORE_AFTER_LINE = 3;
- public final static int UNSET_FUNC_ID = -1;
-
- private long beforeVariableID = NO_SET_VARIABLE_ID;
- private long afterVariableID = NO_SET_VARIABLE_ID;
- private VAR_TYPE type;
- private String typeName;
- private String variableName = "";
- private int sourceLineNum = 0;
- private int checkLocation = CHECK_BEFORE_LINE;
- private long sourceLineLowAddress = 0;
- private long sourceLineHighAddress = 0;
- private String sourceFileName = "";
- private int pointerOrder = 0;
- private int pointerSize = 4;
- private int arrayCount = 0;
- private int byteSize = 0;
- private int offset = 0;
- private int registerID;
- private long registerOffset;
- private String functionName;
- private int functionID = UNSET_FUNC_ID;
- private InteractiveInfo parent;
- private List<InteractiveInfo> children;
- private boolean isTarget = false;
-
- public int getCheckLocation() {
- return checkLocation;
- }
-
- public void setCheckLocation(int checkLocation) {
- this.checkLocation = checkLocation;
- }
-
- public boolean hasCheckLocation(int checkLocation) {
- int result = this.checkLocation & checkLocation;
- return result != 0;
- }
-
- public boolean isTarget() {
- return isTarget;
- }
-
- public void setTarget(boolean isTarget) {
- this.isTarget = isTarget;
- }
-
- public void setTypeName(String typeName) {
- this.typeName = typeName;
- }
-
- public void increasePointerOrder() {
- pointerOrder++;
- }
-
- public List<InteractiveInfo> getChildren() {
- return children;
- }
-
- public void setChildren(List<InteractiveInfo> children) {
- this.children = children;
- }
-
- public boolean isString() {
- return type == VAR_TYPE.CHAR && pointerOrder > 0;
- }
-
- public int getRegisterID() {
- return registerID;
- }
-
- public void setRegisterID(int registerID) {
- this.registerID = registerID;
- }
-
- public long getRegisterOffset() {
- return registerOffset;
- }
-
- public void setRegisterOffset(long registerOffset) {
- this.registerOffset = registerOffset;
- }
-
- public int getFunctionID() {
- if (functionID == UNSET_FUNC_ID) {
- functionID = Global.getFunctionID(this.functionName);
- }
- return functionID;
- }
-
- public void setFunctionID(int functionID) {
- this.functionID = functionID;
- }
-
- public void setFunctionName(String functionName) {
- this.functionName = functionName;
- }
-
- public long getVariableID(int checkLocation) {
- switch (checkLocation) {
- case CHECK_BEFORE_LINE:
- return beforeVariableID;
- case CHECK_AFTER_LINE:
- return afterVariableID;
- default:
- Logger.error("Impossible case!!");
- return -1;
- }
- }
-
- public void setVariableID(int checkLocation, long variableID) {
- switch (checkLocation) {
- case CHECK_BEFORE_LINE:
- this.beforeVariableID = variableID;
- break;
- case CHECK_AFTER_LINE:
- this.afterVariableID = variableID;
- break;
- default:
- Logger.error("Impossible case!!");
- break;
- }
- }
-
- public VAR_TYPE getType() {
- return type;
- }
-
- public void setType(VAR_TYPE type) {
- this.type = type;
- }
-
- public String getVariableName() {
- return variableName;
- }
-
- public void setVariableName(String variableName) {
- this.variableName = variableName;
- }
-
- public int getSourceLineNum() {
- return sourceLineNum;
- }
-
- public void setSourceLineNum(int sourceLineNum) {
- this.sourceLineNum = sourceLineNum;
- }
-
- public long getSourceLineAddress(int checkLocation) {
- switch (checkLocation) {
- case CHECK_BEFORE_LINE:
- return sourceLineLowAddress;
- case CHECK_AFTER_LINE:
- return sourceLineHighAddress;
- default:
- Logger.error("Impossible case!!");
- return -1;
- }
- }
-
- public void setSourceLineAddress(int checkLocation, long sourceLineAddress) {
- switch (checkLocation) {
- case CHECK_BEFORE_LINE:
- this.sourceLineLowAddress = sourceLineAddress;
- break;
- case CHECK_AFTER_LINE:
- this.sourceLineHighAddress = sourceLineAddress;
- break;
- default:
- Logger.error("Impossible case!!");
- break;
- }
- }
-
- public String getSourceFileName() {
- return sourceFileName;
- }
-
- public void setSourceFileName(String sourceFileName) {
- this.sourceFileName = sourceFileName;
- }
-
- public int getPointerOrder() {
- return pointerOrder;
- }
-
- public void setPointerOrder(int pointerOrder) {
- this.pointerOrder = pointerOrder;
- }
-
- public int getPointerSize() {
- return pointerSize;
- }
-
- public void setPointerSize(int pointerSize) {
- this.pointerSize = pointerSize;
- }
-
- public int getArrayCount() {
- return arrayCount;
- }
-
- public void setArrayCount(int arrayCount) {
- this.arrayCount = arrayCount;
- }
-
- public InteractiveInfo getParent() {
- return parent;
- }
-
- public void setParent(InteractiveInfo parent) {
- this.parent = parent;
- }
-
- public int getByteSize() {
- return byteSize;
- }
-
- public void setByteSize(int byteSize) {
- this.byteSize = byteSize;
- }
-
- public int getOffset() {
- return offset;
- }
-
- public void setOffset(int offset) {
- this.offset = offset;
- }
-
- public String getTypeName() {
- return typeName;
- }
-
- public String getTypeNameWithPointer() {
- String string = typeName;
- if (string == null) {
- string = type.getName();
- }
- for (int i = 0; i < pointerOrder; i++) {
- string += "*";
- }
- return string;
- }
-
- /*
- * type + variable name ( source file name : source line number)
- * ex) char* name (test.c : 123)
- */
- public String getDescription() {
- String[] splitedSourcePath = AnalyzerUtil.splitFilePath(sourceFileName, File.separator);
- String fileName = splitedSourcePath[splitedSourcePath.length - 1];
- if (arrayCount > 0) {
- return getTypeNameWithPointer() + " " + getVariableName() + " [" + arrayCount + "] (" + fileName + " : "
- + sourceLineNum + ")";
- } else {
- return getTypeNameWithPointer() + " " + getVariableName() + " (" + fileName + " : " + sourceLineNum + ")";
- }
- }
-
- public boolean isStructType() {
- return (type == VAR_TYPE.STRUCT);
- }
-
- public boolean isArray() {
- return (arrayCount > 0);
- }
-
- public boolean isPointerType() {
- return (pointerOrder > 0);
- }
-
- public boolean isPointerArray() {
- return (isArray() && isPointerType());
- }
-
- public void getAllRelatedVariableIDs(List<Long> variableIDList, int checkLocation) {
- switch (checkLocation) {
- case CHECK_BEFORE_LINE:
- variableIDList.add(beforeVariableID);
- break;
- case CHECK_AFTER_LINE:
- variableIDList.add(afterVariableID);
- break;
- case CHECK_BEFORE_AFTER_LINE:
- variableIDList.add(beforeVariableID);
- variableIDList.add(afterVariableID);
- break;
- default:
- Logger.error("Impossible case!!");
- break;
- }
- if (children != null) {
- for (int i = 0; i < children.size(); i++) {
- children.get(i).getAllRelatedVariableIDs(variableIDList, checkLocation);
- }
- }
- }
-
- public boolean hasVariableID(long variableID) {
- if (variableID == NO_SET_VARIABLE_ID) {
- return false;
- }
- return (beforeVariableID == variableID) || (afterVariableID == variableID);
- }
-
- public List<Long> getChildrenIDs() {
- List<Long> variableIDList = new ArrayList<Long>();
- if (children != null) {
- for (int i = 0; i < children.size(); i++) {
- long beforeVariableID = children.get(i).getVariableID(CHECK_BEFORE_LINE);
- long afterVariableID = children.get(i).getVariableID(CHECK_AFTER_LINE);
- if (beforeVariableID != NO_SET_VARIABLE_ID) {
- variableIDList.add(beforeVariableID);
- }
- if (afterVariableID != NO_SET_VARIABLE_ID) {
- variableIDList.add(afterVariableID);
- }
- }
- }
- return variableIDList;
- }
-
- public boolean hasChild(long variableID, int checkLocation) {
- if (children != null) {
- for (int i = 0; i < children.size(); i++) {
- if (variableID == children.get(i).getVariableID(checkLocation)) {
- return true;
- }
- }
- }
- return false;
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jungwook Ryu <jungwook.ryu@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.interactive.model;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.cdt.debug.edc.internal.symbols.IArrayType;
-import org.eclipse.cdt.debug.edc.internal.symbols.IConstType;
-import org.eclipse.cdt.debug.edc.internal.symbols.IField;
-import org.eclipse.cdt.debug.edc.internal.symbols.ILexicalBlockScope;
-import org.eclipse.cdt.debug.edc.internal.symbols.IPointerType;
-import org.eclipse.cdt.debug.edc.internal.symbols.ITypedef;
-import org.eclipse.cdt.debug.edc.internal.symbols.LexicalBlockScope;
-import org.eclipse.cdt.debug.edc.internal.symbols.StructType;
-import org.eclipse.cdt.debug.edc.internal.symbols.dwarf.DwarfCompileUnit;
-import org.eclipse.cdt.debug.edc.internal.symbols.dwarf.DwarfDebugInfoProvider;
-import org.eclipse.cdt.debug.edc.internal.symbols.dwarf.DwarfInfoReader;
-import org.eclipse.cdt.debug.edc.internal.symbols.dwarf.LocationExpression;
-import org.eclipse.cdt.debug.edc.internal.symbols.files.ElfExecutableSymbolicsReaderFactory;
-import org.eclipse.cdt.debug.edc.symbols.ICompileUnitScope;
-import org.eclipse.cdt.debug.edc.symbols.IExecutableSymbolicsReader;
-import org.eclipse.cdt.debug.edc.symbols.IFunctionScope;
-import org.eclipse.cdt.debug.edc.symbols.ILineEntry;
-import org.eclipse.cdt.debug.edc.symbols.ILocationProvider;
-import org.eclipse.cdt.debug.edc.symbols.IScope;
-import org.eclipse.cdt.debug.edc.symbols.IType;
-import org.eclipse.cdt.debug.edc.symbols.IVariable;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.tizen.dynamicanalyzer.ui.interactive.data.InteractiveUIData;
-import org.tizen.dynamicanalyzer.util.ByteUtil;
-import org.tizen.dynamicanalyzer.util.Logger;
-
-public class InteractiveParser {
- // If Global variable, Register ID will be 0xFF. It's Protocol with SWAP.
- private static int GLOBAL_VARIABLE_ID = 0xFF;
-
- public static InteractiveUIData parseValue(InteractiveInfo interactiveInfo, int checkLocation,
- Map<Long, byte[]> valueMap) {
- InteractiveUIData uiData = null;
- byte[] value = valueMap.get(interactiveInfo.getVariableID(checkLocation));
- if (value != null && value.length > 0) {
- if (interactiveInfo.isStructType() == false && interactiveInfo.isArray() == false) {
- uiData = parseScalar(interactiveInfo, checkLocation, value);
- } else if (interactiveInfo.isArray()) {
- uiData = parseArray(interactiveInfo, checkLocation, value, valueMap);
- } else if (interactiveInfo.isStructType()) {
- uiData = parseStruct(interactiveInfo, checkLocation, value, valueMap);
- } else {
- Logger.warning("value is not scalar, array, struct.");
- }
- }
- return uiData;
- }
-
- /*
- * TODO Detail variable type parsing, because some C data type is not
- * supported by Java's primitive.
- */
- private static InteractiveUIData parseScalar(InteractiveInfo info, int checkLocation, byte[] data) {
- InteractiveUIData uiData = new InteractiveUIData(info, checkLocation);
- Object value = null;
- switch (info.getType()) {
- case CHAR:
- case UNSIGNED_CHAR:
- case SIGNED_CHAR: {
- if (info.getPointerOrder() > 0) {
- value = ByteUtil.getString(data, 0);
- } else {
- value = new Character((char) data[0]);
- }
- }
- break;
- case INT:
- value = ByteUtil.toInt(data);
- break;
- case UNSIGNED_INT:
- value = ByteUtil.toUnsignedInt(data, 0);
- break;
- case SHORT:
- value = ByteUtil.toShort(data, 0);
- break;
- case UNSIGNED_SHORT:
- value = ByteUtil.toUnsignedShort(data, 0);
- break;
- case LONG:
- if (info.getByteSize() == 4) {
- value = ByteUtil.toInt(data);
- } else if (info.getByteSize() == 8) {
- value = ByteUtil.toLong(data);
- }
- break;
- case UNSIGNED_LONG:
- if (info.getByteSize() == 4) {
- value = ByteUtil.toUnsignedInt(data, 0);
- } else if (info.getByteSize() == 8) {
- value = toUnsignedLong(ByteUtil.toLong(data));
- }
- break;
- case FLOAT:
- value = ByteUtil.toFloat(data, 0);
- break;
- case DOUBLE:
- case LONG_DOUBLE:
- if (info.getByteSize() == 8) {
- value = ByteUtil.toDouble(data, 0);
- } else {
- Logger.warning("Long double is not 8bytes : " + info.getByteSize());
- }
- break;
- default:
- Logger.warning("undefined variable type!!");
- break;
- }
- uiData.setValue(value);
- return uiData;
- }
-
- /*
- * TODO Add a unit test for this method
- * This method is from "UnsignedLongs.java" of Google guava-libraries
- * (apache 2.0 license)
- */
- private static String toUnsignedLong(long x) {
- int radix = 10;
- if (x == 0) {
- return "0";
- } else {
- char[] buf = new char[64];
- int i = buf.length;
- if (x < 0) {
- // Split x into high-order and low-order halves.
- // Individual digits are generated from the bottom half into
- // which
- // bits are moved continously from the top half.
- long top = x >>> 32;
- long bot = (x & 0xffffffffl) + ((top % radix) << 32);
- top /= radix;
- while ((bot > 0) || (top > 0)) {
- buf[--i] = Character.forDigit((int) (bot % radix), radix);
- bot = (bot / radix) + ((top % radix) << 32);
- top /= radix;
- }
- } else {
- // Simple modulo/division approach
- while (x > 0) {
- buf[--i] = Character.forDigit((int) (x % radix), radix);
- x /= radix;
- }
- }
- // Generate string
- return new String(buf, i, buf.length - i);
- }
- }
-
- private static InteractiveUIData parseStruct(InteractiveInfo info, int checkLocation, byte[] data,
- Map<Long, byte[]> valueMap) {
- InteractiveUIData uiData = new InteractiveUIData(info, checkLocation);
- List<InteractiveUIData> children = new ArrayList<InteractiveUIData>();
- if (info.getChildren() != null) {
- for (int i = 0; i < info.getChildren().size(); i++) {
- InteractiveInfo memberInfo = info.getChildren().get(i);
- int offset = memberInfo.getOffset();
- int byteSize = memberInfo.getByteSize();
- InteractiveUIData memberUiData = null;
- /*
- * Note : The sequence of "if/else if" is significant. Do not
- * change sequence without consideration. It's possible 8cases :
- * (single, array) * (scalar, scalar+pointer, struct,
- * struct+pointer) "scalar" means "not Struct" like
- * "int, double, ...".
- */
- /*
- * Case : member is scalar of value. 1case is covered. (single)
- * * (scalar)
- */
- if (memberInfo.isStructType() == false && memberInfo.isPointerType() == false
- && memberInfo.isArray() == false) {
- memberUiData = parseScalar(memberInfo, checkLocation,
- Arrays.copyOfRange(data, offset, offset + byteSize));
- }
- /*
- * Case : member is Array of value. 2cases is covered. (array) *
- * (scalar, struct)
- */
- else if (memberInfo.isArray() && memberInfo.isPointerType() == false) {
- int lastIndex = offset + (memberInfo.getArrayCount() * byteSize);
- memberUiData = parseArray(memberInfo, checkLocation, Arrays.copyOfRange(data, offset, lastIndex), valueMap);
- }
- /*
- * Case : member is Array of pointer. 2cases is covered. (array)
- * * (scalar+pointer, struct+pointer)
- */
- else if (memberInfo.isArray() && memberInfo.isPointerType() == true) {
- int lastIndex = offset + (memberInfo.getArrayCount() * memberInfo.getPointerSize());
- memberUiData = parseArray(memberInfo, checkLocation, Arrays.copyOfRange(data, offset, lastIndex), valueMap);
- }
- /*
- * Case : member is Pointer regardless of scalar, struct. 2cases
- * is covered. (single) * (scalar+pointer, struct+pointer)
- */
- else if (memberInfo.isPointerType()) {
- memberUiData = new InteractiveUIData(memberInfo, checkLocation);
- byte[] stream = valueMap.get(memberInfo.getVariableID(checkLocation));
- if (stream != null) {
- memberUiData = parseValue(memberInfo, checkLocation, valueMap);
- } else {
- int pointerSize = memberInfo.getPointerSize();
- byte[] address = ByteUtil.toBytesN(data, offset, pointerSize);
- if (pointerSize == 4) { // 4byte
- memberUiData.setValue("0x" + Integer.toHexString(ByteUtil.toInt(address)));
- } else if (pointerSize == 8) { // 8byte
- memberUiData.setValue("0x" + Long.toHexString(ByteUtil.toLong(address)));
- }
- }
- }
- /*
- * Case : member is Struct (not Pointer, Array). 1case is
- * covered. (single) * (struct)
- */
- else if (memberInfo.isStructType()) {
- memberUiData = parseStruct(memberInfo, checkLocation,
- Arrays.copyOfRange(data, offset, offset + byteSize), valueMap);
- }
- /*
- * Error Case. This case is impossible.
- */
- else {
- Logger.warning("Unhandled case!!");
- }
- children.add(memberUiData);
- }
- }
- uiData.setChildren(children);
- return uiData;
- }
-
- private static InteractiveUIData parseArray(InteractiveInfo info, int checkLocation, byte[] data, Map<Long, byte[]> valueMap) {
- InteractiveUIData uiData = new InteractiveUIData(info, checkLocation);
- uiData.setArray(true);
- String arrayValue = "[ ";
- List<InteractiveUIData> children = new ArrayList<InteractiveUIData>();
- int index = 0;
- int byteSize = (info.getPointerOrder() > 0) ? info.getPointerSize() : info.getByteSize();
- for (int i = 0; i < info.getArrayCount(); i++) {
- InteractiveUIData elementUiData = null;
- /*
- * Note : The sequence of "if/else if" is significant. Do not change
- * sequence without consideration. It's possible 4cases : (scalar,
- * scalar+pointer, struct, struct+pointer) "scalar" means
- * "not Struct" like "int, double, ...".
- */
- /*
- * Case : Array of simple primitive type (not struct, not pointer).
- * 1case is covered. (scalar)
- */
- if (info.isStructType() == false && info.isPointerType() == false) {
- elementUiData = parseScalar(info, checkLocation, Arrays.copyOfRange(data, index, index + byteSize));
- }
- /*
- * Case : Array of pointer (regardless of struct). 2case is covered.
- * (scalar+pointer, struct+pointer)
- */
- else if (info.isPointerType() == true) {
- int pointerSize = info.getPointerSize();
- byte[] address = ByteUtil.toBytesN(data, index, pointerSize);
- elementUiData = new InteractiveUIData(info, checkLocation);
- if (pointerSize == 4) { // 4byte
- elementUiData.setValue("0x" + Integer.toHexString(ByteUtil.toInt(address)));
- } else if (pointerSize == 8) { // 8byte
- elementUiData.setValue("0x" + Long.toHexString(ByteUtil.toLong(address)));
- }
- }
- /*
- * Case : Array of Struct (not pointer). 1case is covered. (struct)
- */
- else if (info.isStructType()) {
- elementUiData = parseStruct(info, checkLocation, Arrays.copyOfRange(data, index, index + byteSize),
- valueMap);
- }
- /*
- * Error Case. This case is impossible.
- */
- else {
- Logger.warning("Unhandled case!!");
- }
- index += byteSize;
- if (elementUiData != null) {
- children.add(elementUiData);
- arrayValue += elementUiData.getValue() + " , ";
- }
- }
- arrayValue += " ]";
- uiData.setValue(arrayValue);
- uiData.setChildren(children);
- return uiData;
- }
-
- public static InteractiveInfo getInteractiveInfo(String binaryPath, String sourcePath, int lineNum, String varStr,
- int arrayCount, int checkLocation) {
- // parse structure member (ex.structVal->mem1 => [structVal,mem1])
- String[] parsedVar = parseVariableString(varStr);
- InteractiveInfo rootInteractiveInfo = parseDwarf(binaryPath, sourcePath, lineNum, parsedVar[0]);
- if (rootInteractiveInfo != null) {
- InteractiveInfo targetInteractiveInfo = findTargetInteractiveInfo(rootInteractiveInfo, parsedVar);
- targetInteractiveInfo.setVariableName(varStr);
- targetInteractiveInfo.setSourceFileName(sourcePath);
- targetInteractiveInfo.setSourceLineNum(lineNum);
- targetInteractiveInfo.setSourceLineAddress(InteractiveInfo.CHECK_BEFORE_LINE,
- rootInteractiveInfo.getSourceLineAddress(InteractiveInfo.CHECK_BEFORE_LINE));
- targetInteractiveInfo.setSourceLineAddress(InteractiveInfo.CHECK_AFTER_LINE,
- rootInteractiveInfo.getSourceLineAddress(InteractiveInfo.CHECK_AFTER_LINE));
- targetInteractiveInfo.setArrayCount(arrayCount);
- targetInteractiveInfo.setCheckLocation(checkLocation);
- return targetInteractiveInfo;
- }
- return rootInteractiveInfo;
- }
-
- private static String[] parseVariableString(String varStr) {
- String[] parsed = varStr.split("->|\\.");
- return parsed;
- }
-
- private static InteractiveInfo findTargetInteractiveInfo(InteractiveInfo rootInfo, String[] parsedVar) {
- int depth = parsedVar.length;
- InteractiveInfo cursorInfo = rootInfo;
- for (int i = 1; i < depth; i++) {
- List<InteractiveInfo> children = cursorInfo.getChildren();
- for (int ii = 0; ii < children.size(); ii++) {
- if (children.get(ii).getVariableName().equals(parsedVar[i])) {
- cursorInfo = children.get(ii);
- }
- }
- }
- cursorInfo.setTarget(true);
- cursorInfo.setRegisterID(rootInfo.getRegisterID());
- cursorInfo.setRegisterOffset(rootInfo.getRegisterOffset());
- return cursorInfo;
- }
-
- private static InteractiveInfo parseDwarf(String binaryPath, String sourcePath, int lineNum, String varName) {
- Path _binaryPath = new Path(binaryPath);
- Path _sourcePath = new Path(sourcePath);
- ElfExecutableSymbolicsReaderFactory fact = new ElfExecutableSymbolicsReaderFactory();
- IExecutableSymbolicsReader exeReader = fact.createExecutableSymbolicsReader(_binaryPath);
- if (exeReader == null) {
- return null;
- }
- DwarfDebugInfoProvider dip = new DwarfDebugInfoProvider(exeReader);
- DwarfInfoReader dir = new DwarfInfoReader(dip);
- dir.parseInitial();
- dir.parseForAddresses(true);
-
- List<ICompileUnitScope> cuList = dip.getModuleScope().getCompileUnitsForFile(_sourcePath);
- ILineEntry sourceLine = null;
- IFunctionScope funcScope = null; // function in lineNum
- for (int i = 0; i < cuList.size(); i++) {
- ICompileUnitScope cu = cuList.get(i);
- if (!(cu instanceof DwarfCompileUnit)) {
- continue;
- }
- List<IPath> fileList = new ArrayList<IPath>();
- Collection<ILineEntry> lines = dir.parseLineTable(cu, ((DwarfCompileUnit) cu).getAttributeList(), fileList);
- Iterator<ILineEntry> iterLine = lines.iterator();
- while (iterLine.hasNext()) {
- ILineEntry line = iterLine.next();
- if (line.getLineNumber() == lineNum && line.getFilePath().equals(_sourcePath)) {
- sourceLine = line;
- Collection<IScope> cuChildren = cu.getChildren();
- Iterator<IScope> iterScope = cuChildren.iterator();
- while (iterScope.hasNext()) {
- IScope cuChild = iterScope.next();
- if (!(cuChild instanceof IFunctionScope)) {
- continue;
- }
- /*
- * DW_TAG_subprogram
- */
- if (line.getHighAddress().compareTo(cuChild.getHighAddress()) <= 0
- && line.getLowAddress().compareTo(cuChild.getLowAddress()) >= 0) {
- funcScope = (IFunctionScope) cuChild;
- Collection<IScope> funcChildren = cuChild.getChildren();
- Iterator<IScope> iterFunc = funcChildren.iterator();
- /*
- * DW_TAG_lexical_block
- */
- while (iterFunc.hasNext()) {
- InteractiveInfo varInfo = checkLexicalBlock(iterFunc.next(), varName, line, funcScope);
- if (varInfo != null) {
- return varInfo;
- }
- }
- /*
- * DW_TAG_formal_parameter
- */
- Collection<IVariable> params = ((IFunctionScope) cuChild).getParameters();
- InteractiveInfo varInfo = getVariableInfo(params, varName, line, true, funcScope);
- if (varInfo != null) {
- return varInfo;
- }
- /*
- * DW_TAG_variable
- */
- varInfo = getVariableInfo(cuChild.getVariables(), varName, line, true, funcScope);
- if (varInfo != null) {
- return varInfo;
- }
- }
- }
- }
- }
- }
- // Invalid line of source code (for example.. space, comment)
- if (sourceLine == null) {
- return null;
- }
- /*
- * Check global variable
- */
- Collection<IVariable> variables = dip.getModuleScope().getVariablesByName(varName, true);
- return getVariableInfo(variables, varName, sourceLine, false, funcScope);
- }
-
- private static boolean setVariableLocationInfo(ILocationProvider locationProvider, InteractiveInfo variableInfo,
- boolean isLocal, IFunctionScope funcScope) {
- if (!(locationProvider instanceof LocationExpression)) {
- return false;
- }
- /*
- * Case : Local variable
- */
- if (isLocal) {
- int registerID = ((LocationExpression) funcScope.getFrameBaseLocation()).getRegisterID();
- variableInfo.setRegisterID(registerID);
- if (registerID > 0) {
- Object[] offset = new Object[1];
- if (((LocationExpression) locationProvider).getRegisterOffset(offset)) {
- variableInfo.setRegisterOffset((Long) offset[0]);
- return true;
- }
- }
- }
- /*
- * Case : Global variable
- */
- else {
- variableInfo.setRegisterID(GLOBAL_VARIABLE_ID);
- Object[] address = new Object[1];
- if (true == ((LocationExpression) locationProvider).getGlobalVariableAddress(address)) {
- variableInfo.setRegisterOffset((Long) address[0]);
- return true;
- }
- }
- return false;
- }
-
- private static IType findTypeOfArray(IType type) {
- if (!(type instanceof IArrayType) && !((type instanceof ITypedef || type instanceof IConstType))) {
- return type;
- }
- return findTypeOfArray(type.getType());
- }
-
- private static void getTypeInfo(IType type, IFunctionScope funcScope, InteractiveInfo valueInfo) {
- valueInfo.setByteSize(type.getByteSize());
- if (type instanceof IPointerType) {
- valueInfo.increasePointerOrder();
- valueInfo.setPointerSize(type.getByteSize());
- getTypeInfo(type.getType(), funcScope, valueInfo);
- } else if (type instanceof ITypedef || type instanceof IConstType) {
- getTypeInfo(type.getType(), funcScope, valueInfo);
- } else if (type instanceof IArrayType) {
- getTypeInfo(type.getType(), funcScope, valueInfo);
- } else if (type instanceof StructType) {
- valueInfo.setType(VAR_TYPE.STRUCT);
- valueInfo.setTypeName(type.getName());
- // If Linked List, stop parsing to prevent infinite recursive call
- if (valueInfo.getParent() != null && valueInfo.getParent().getTypeName().equals(type.getName())) {
- return;
- }
- List<InteractiveInfo> members = new ArrayList<InteractiveInfo>();
- valueInfo.setChildren(members);
- IField[] fields = ((StructType) type).getFields();
- for (int i = 0; i < fields.length; i++) {
- InteractiveInfo memberInfo = new InteractiveInfo();
- memberInfo.setVariableID(InteractiveInfo.CHECK_BEFORE_LINE, InteractiveIDGenerator.generateID());
- memberInfo.setVariableID(InteractiveInfo.CHECK_AFTER_LINE, InteractiveIDGenerator.generateID());
- memberInfo.setVariableName(fields[i].getName());
- memberInfo.setOffset((int) fields[i].getFieldOffset());
- memberInfo.setFunctionName(funcScope.getName());
- memberInfo.setParent(valueInfo);
- // calculate count of array
- int arrayCount = 0;
- if (fields[i].getType() instanceof IArrayType) {
- IType arrayType = findTypeOfArray(fields[i].getType());
- if (fields.length - 1 == i) { // if last member,
- arrayCount = (type.getByteSize() - memberInfo.getOffset()) / arrayType.getByteSize();
- } else {
- arrayCount = ((int) fields[i + 1].getFieldOffset() - memberInfo.getOffset())
- / arrayType.getByteSize();
- }
- }
- memberInfo.setArrayCount(arrayCount);
- getTypeInfo(fields[i].getType(), funcScope, memberInfo);
- members.add(memberInfo);
- }
- } else {
- if (VAR_TYPE.CHAR.getName().equals(type.getName())) {
- valueInfo.setType(VAR_TYPE.CHAR);
- } else if (VAR_TYPE.UNSIGNED_CHAR.getName().equals(type.getName())) {
- valueInfo.setType(VAR_TYPE.UNSIGNED_CHAR);
- } else if (VAR_TYPE.SIGNED_CHAR.getName().equals(type.getName())) {
- valueInfo.setType(VAR_TYPE.SIGNED_CHAR);
- } else if (VAR_TYPE.INT.getName().equals(type.getName())) {
- valueInfo.setType(VAR_TYPE.INT);
- } else if (VAR_TYPE.UNSIGNED_INT.getName().equals(type.getName())) {
- valueInfo.setType(VAR_TYPE.UNSIGNED_INT);
- } else if (VAR_TYPE.SHORT.getName().equals(type.getName())) {
- valueInfo.setType(VAR_TYPE.SHORT);
- } else if (VAR_TYPE.UNSIGNED_SHORT.getName().equals(type.getName())) {
- valueInfo.setType(VAR_TYPE.UNSIGNED_SHORT);
- } else if (VAR_TYPE.LONG.getName().equals(type.getName())) {
- valueInfo.setType(VAR_TYPE.LONG);
- } else if (VAR_TYPE.UNSIGNED_LONG.getName().equals(type.getName())) {
- valueInfo.setType(VAR_TYPE.UNSIGNED_LONG);
- } else if (VAR_TYPE.FLOAT.getName().equals(type.getName())) {
- valueInfo.setType(VAR_TYPE.FLOAT);
- } else if (VAR_TYPE.DOUBLE.getName().equals(type.getName())) {
- valueInfo.setType(VAR_TYPE.DOUBLE);
- } else if (VAR_TYPE.LONG_DOUBLE.getName().equals(type.getName())) {
- valueInfo.setType(VAR_TYPE.LONG_DOUBLE);
- } else {
- valueInfo.setType(VAR_TYPE.UNDEF);
- }
- }
- }
-
- private static InteractiveInfo getVariableInfo(Collection<IVariable> variables, String varName, ILineEntry line,
- boolean isLocal, IFunctionScope funcScope) {
- Iterator<IVariable> iterVar = variables.iterator();
- while (iterVar.hasNext()) {
- IVariable var = iterVar.next();
- if (var.getName().equals(varName)) {
- InteractiveInfo variableInfo = new InteractiveInfo();
- variableInfo.setVariableID(InteractiveInfo.CHECK_BEFORE_LINE, InteractiveIDGenerator.generateID());
- variableInfo.setVariableID(InteractiveInfo.CHECK_AFTER_LINE, InteractiveIDGenerator.generateID());
- variableInfo.setVariableName(var.getName());
- variableInfo.setSourceLineAddress(InteractiveInfo.CHECK_BEFORE_LINE, line.getLowAddress().getValue()
- .longValue());
- variableInfo.setSourceLineAddress(InteractiveInfo.CHECK_AFTER_LINE, line.getHighAddress().getValue()
- .longValue());
- variableInfo.setFunctionName(funcScope.getName());
- getTypeInfo(var.getType(), funcScope, variableInfo);
- if (setVariableLocationInfo(var.getLocationProvider(), variableInfo, isLocal, funcScope)) {
- return variableInfo;
- } else {
- Logger.warning("Get Location error!!!");
- }
- }
- }
- return null;
- }
-
- private static InteractiveInfo checkLexicalBlock(IScope lexicalScope, String varName, ILineEntry line,
- IFunctionScope funcScope) {
- if (lexicalScope instanceof LexicalBlockScope) {
- if (line.getLowAddress().compareTo(lexicalScope.getHighAddress()) < 0
- && line.getLowAddress().compareTo(lexicalScope.getLowAddress()) >= 0) {
- Collection<IVariable> variables = ((ILexicalBlockScope) lexicalScope).getVariablesInTree();
- return getVariableInfo(variables, varName, line, true, funcScope);
- }
- }
- return null;
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jungwook Ryu <jungwook.ryu@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.interactive.model;
-
-public enum VAR_TYPE {
- UNDEF,
- CHAR("char"),
- UNSIGNED_CHAR("unsigned char"),
- SIGNED_CHAR("signed char"),
- INT("int"),
- UNSIGNED_INT("unsigned int"),
- SHORT("short"),
- UNSIGNED_SHORT("unsigned short"),
- LONG("long"),
- UNSIGNED_LONG("unsigned long"),
- FLOAT("float"),
- DOUBLE("double"),
- LONG_DOUBLE("long double"),
- POINTER,
- ARRAY,
- STRUCT("struct");
-
- final private String name;
-
- private VAR_TYPE() {
- this.name = "";
- }
-
- private VAR_TYPE(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jungwook Ryu <jungwook.ryu@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.interactive.table;
-
-import java.sql.ResultSet;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.nebula.widgets.grid.Grid;
-import org.eclipse.nebula.widgets.grid.GridColumn;
-import org.eclipse.nebula.widgets.grid.GridItem;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Composite;
-import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
-import org.tizen.dynamicanalyzer.common.AnalyzerManager;
-import org.tizen.dynamicanalyzer.common.DASelectionData;
-import org.tizen.dynamicanalyzer.model.FilterProperty;
-import org.tizen.dynamicanalyzer.model.TreeInput;
-import org.tizen.dynamicanalyzer.ui.interactive.InteractivePage;
-import org.tizen.dynamicanalyzer.ui.interactive.data.InteractiveDataManager;
-import org.tizen.dynamicanalyzer.ui.interactive.data.InteractiveUIData;
-import org.tizen.dynamicanalyzer.ui.interactive.data.InteractiveValue;
-import org.tizen.dynamicanalyzer.ui.interactive.model.InteractiveInfo;
-import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat;
-import org.tizen.dynamicanalyzer.ui.widgets.table.DATableHeaderRenderer;
-import org.tizen.dynamicanalyzer.ui.widgets.table.DATreeComposite;
-import org.tizen.dynamicanalyzer.utils.Formatter;
-
-public class InteractiveTable extends DATreeComposite {
- private InteractiveInfo interactiveInfo;
- private Map<Long, Boolean> beforeExpandMap;
-
- public InteractiveTable(Composite parent, int compStyle, int tableStyle) {
- super(parent, compStyle, tableStyle);
-
- table.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- GridItem[] ti = ((Grid) e.widget).getSelection();
- if (null == ti || ti.length == 0) {
- return;
- }
- int size = ti.length;
- List<Object> startData = ((DATableDataFormat) ti[0].getData()).getData();
- List<Object> endData = ((DATableDataFormat) ti[size - 1].getData()).getData();
- long startTime = (Long) startData.get(0);
- long endTime = (Long) endData.get(0);
-
- // Only handle Last selection item.
- DASelectionData data = new DASelectionData(InteractivePage.listViewID, startTime, endTime, ti[size - 1], table);
- AnalyzerManager.getCurrentPage().updateView(data);
- // Relieve multi selection.
- table.setSelection(((Grid) e.widget).getSelectionIndices()[((Grid) e.widget).getSelectionCount() - 1]);
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
- }
-
- @Override
- public void setColumns(String[] columnNames) {
- this.columnNames = columnNames;
- int size = columnNames.length;
- for (int i = 0; i < size; i++) {
- GridColumn column = new GridColumn(table, SWT.NONE);
- column.setText(columnNames[i]);
- if (isTree && i == 0) {
- column.setTree(true);
- }
- column.setCellRenderer(new InteractiveTableCellRenderer());
- column.setHeaderRenderer(new DATableHeaderRenderer());
-
- if (columnAlignment != null) {
- if (columnAlignment.length > i) {
- column.setAlignment(columnAlignment[i]);
- }
- }
-
- column.pack();
-
- if (null != comparator && null != sortTypes) {
- final int type = sortTypes[i];
- // final int sourceColumn = sourceColumns[i];
- final int columnIndex = i;
-
- column.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- comparator.setType(type);
- comparator.setColumn(columnIndex);
- // comparator.setSourceColumn(sourceColumn);
- comparator.reverseDirection();
- updateTable();
- }
- });
- }
- }
- }
-
- public void setInteractiveInfo(InteractiveInfo interactiveInfo) {
- this.interactiveInfo = interactiveInfo;
- }
-
- public void updateTree(long startTime, long endTime) {
- GridItem[] items = table.getItems();
- if (items != null) {
- List<Integer> selectionList = new ArrayList<Integer>();
- for (int i = 0; i < items.length; i++) {
- GridItem item = items[i];
- long time = (Long) ((DATableDataFormat) (item.getData())).getData().get(0);
- if (startTime <= time && time <= endTime) {
- selectionList.add(i);
- }
- }
- int[] sels = new int[selectionList.size()];
- for (int i = 0; i < selectionList.size(); i++) {
- sels[i] = selectionList.get(i);
- }
- table.setSelection(sels);
- }
- updateTree();
- }
-
- @Override
- public void updateTree() {
- beforeExpandMap = (Map<Long, Boolean>) getExpandMap().clone();
- super.updateTree();
- }
-
- @Override
- public List<TreeInput> makeTreeInput() {
- if (interactiveInfo == null) {
- return null;
- }
- ResultSet rs = InteractiveDataManager.getInstance().getValueDataFromDB(interactiveInfo);
- if (rs == null) {
- return null;
- }
- // Key : variableID
- Map<Long, List<InteractiveValue>> valueInfoMap = InteractiveDataManager.getInstance().makeInteractiveValueMap(
- rs);
- if (valueInfoMap == null) {
- return null;
- }
-
- List<InteractiveUIData> beforeUIDataList = new ArrayList<InteractiveUIData>();
- List<InteractiveUIData> afterUIDataList = new ArrayList<InteractiveUIData>();
- boolean result = InteractiveDataManager.getInstance().makeInteractiveUIData(interactiveInfo, valueInfoMap,
- beforeUIDataList, afterUIDataList);
- if (result) {
- List<InteractiveUIData> parsedUIDataList = new ArrayList<InteractiveUIData>();
- parsedUIDataList.addAll(beforeUIDataList);
- parsedUIDataList.addAll(afterUIDataList);
-
- long tableID = 0;
- Collections.sort(parsedUIDataList);
- List<FilterProperty> filterList = getFilterPropertyList();
- List<TreeInput> output = new ArrayList<TreeInput>();
- for (int i = 0; i < parsedUIDataList.size(); i++) {
- InteractiveUIData valueData = parsedUIDataList.get(i);
- if (valueData != null) {
- tableID = setUIDataID(valueData, tableID);
- TreeInput valueInput = makeInput(valueData, valueData.getTime(), false);
- boolean isChildAdded = makeChildTree(valueData, valueInput, valueData.getTime(), valueData.getName(), filterList);
- if (isChildAdded || checkFilter(valueInput, filterList)) {
- output.add(valueInput);
- }
- } else {
- output.add(null);
- }
- }
- return output;
- }
- return null;
- }
-
- @Override
- protected GridItem checkExpand(GridItem gridItem, DATableDataFormat gridData) {
- long seq = gridData.getSelectionKey();
- Object expand = beforeExpandMap.get(seq);
- if (null == expand) {
- if (gridItem.getParent() == null) {
- gridItem.setExpanded(true);
- getExpandMap().put(seq, true);
- } else {
- gridItem.setExpanded(false);
- getExpandMap().put(seq, false);
- }
- } else {
- gridItem.setExpanded((Boolean) expand);
- }
- return gridItem;
- }
-
- private TreeInput makeInput(InteractiveUIData input, long time, boolean isChild) {
- if (input == null) {
- return null;
- }
-
- // table data
- DATableDataFormat tableData = new DATableDataFormat(input.getTableRowID());
- tableData.setObject(input);
-
- List<String> text = new ArrayList<String>();
-
- if (isChild) {
- text.add(input.getName());
- } else {
- String strTime = Formatter.toTimeFormat(input.getTime());
- text.add(strTime + " / " + input.getName());
- }
- text.add(input.getType());
- if (input.getValue() != null) {
- text.add(input.getValue().toString());
- }
-
- TreeInput output = new TreeInput();
- output.setText(text);
- tableData.getData().add(time);
- tableData.setType(AnalyzerConstants.TYPE_TABLE_INTERACTIVE);
- output.setData(tableData);
- return output;
- }
-
- private boolean checkFilter(TreeInput input, List<FilterProperty> filterList) {
- if (filterList.isEmpty()) {
- return true;
- }
- List<String> textList = input.getText();
- for (int i = 0; i < filterList.size(); i++) {
- FilterProperty prop = filterList.get(i);
- if (textList.get(prop.getColumnIndex()).contains(prop.getKeyWord()) == false) {
- return false;
- }
- }
- return true;
- }
-
- private boolean makeChildTree(InteractiveUIData parentData, TreeInput parentInput, long time, String parentName, List<FilterProperty> filterList) {
- boolean isChildAdded = false;
- List<InteractiveUIData> children = parentData.getChildren();
- if (children == null) {
- return isChildAdded;
- }
- for (int i = 0; i < children.size(); i++) {
- InteractiveUIData data = children.get(i);
- if (data == null) {
- continue;
- }
- if (parentData.isArray()) {
- data.setName("[" + i + "]");
- }
- TreeInput input = makeInput(data, time, true);
- boolean isGrandChildAdded = makeChildTree(data, input, time, data.getName(), filterList);
- if (isGrandChildAdded || checkFilter(input, filterList)) {
- parentInput.getChildren().add(input);
- input.setParent(parentName);
- isChildAdded = true;
- }
- }
- return isChildAdded;
- }
-
- private long setUIDataID(InteractiveUIData uiData, long tableRowID) {
- uiData.setTableRowID(tableRowID++);
- if (uiData.getChildren() != null) {
- for (int i = 0; i < uiData.getChildren().size(); i++) {
- if (uiData.getChildren().get(i) == null) {
- continue;
- }
- tableRowID = setUIDataID(uiData.getChildren().get(i), tableRowID);
- }
- }
- return tableRowID;
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jungwook Ryu <jungwook.ryu@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.interactive.table;
-
-import org.eclipse.nebula.widgets.grid.GridItem;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.tizen.dynamicanalyzer.resources.ColorResources;
-import org.tizen.dynamicanalyzer.resources.FontResources;
-import org.tizen.dynamicanalyzer.ui.interactive.data.InteractiveUIData;
-import org.tizen.dynamicanalyzer.ui.interactive.model.InteractiveInfo;
-import org.tizen.dynamicanalyzer.ui.widgets.table.DATableCellRenderer;
-import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat;
-import org.tizen.dynamicanalyzer.util.Logger;
-
-public class InteractiveTableCellRenderer extends DATableCellRenderer {
- @Override
- public void setTree(boolean tree) {
- super.setTree(tree);
- if (tree) {
- toggleRenderer = new InteractiveTableToggleRenderer();
- toggleRenderer.setDisplay(getDisplay());
- }
- }
-
- @Override
- public void paint(GC gc, Object value) {
- GridItem item = (GridItem) value;
-
- gc.setFont(item.getFont(getColumn()));
-
- boolean drawAsSelected = isSelected();
-
- boolean drawBackground = true;
-
- if (isCellSelected()) {
- drawAsSelected = true;
- }
-
- if (drawAsSelected) {
- gc.setForeground(ColorResources.TABLE_CONTENTS_SELECTED_START);
- gc.setBackground(ColorResources.TABLE_CONTENTS_SELECTED_START);
- } else {
- if (item.getParent().isEnabled()) {
- Color bg = item.getBackground();
- if (bg != null) {
- gc.setBackground(bg);
- } else {
- drawBackground = false;
- }
- } else {
- gc.setBackground(getDisplay().getSystemColor(
- SWT.COLOR_WIDGET_BACKGROUND));
- }
- }
-
- if (drawBackground && drawAsSelected) {
- gc.fillGradientRectangle(getBounds().x, getBounds().y,
- getBounds().width, getBounds().height, true);
- } else if (drawBackground) {
- gc.fillRectangle(getBounds().x, getBounds().y + 1,
- getBounds().width, getBounds().height);
- }
-
- int x = leftMargin;
-
- if (isTree()) {
- x += getToggleIndent(item);
-
- if (drawAsSelected) {
- toggleRenderer.setSelected(true);
- } else {
- toggleRenderer.setSelected(false);
- }
- toggleRenderer.setExpanded(item.isExpanded());
-
- toggleRenderer.setHover(getHoverDetail().equals("toggle")); //$NON-NLS-1$
-
- toggleRenderer.setLocation(getBounds().x + x,
- (getBounds().height - toggleRenderer.getBounds().height)
- / 2 + getBounds().y);
- toggleRenderer.paint(gc, item);
-
- x += toggleRenderer.getBounds().width + insideMargin;
- }
-
- Image image = item.getImage(getColumn());
- if (image != null) {
- int y = getBounds().y;
- y += (getBounds().height - image.getBounds().height) / 2;
- gc.drawImage(image, getBounds().x + x, y);
- x += image.getBounds().width + insideMargin;
- }
- int width = getBounds().width - x - rightMargin;
- String text = item.getText(getColumn());
-
- if (getAlignment() == SWT.RIGHT) {
- int len = gc.stringExtent(text).x;
- if (len < width) {
- x += width - len;
- }
- } else if (getAlignment() == SWT.CENTER) {
- int len = gc.stringExtent(text).x;
- if (len < width) {
- x += (width - len) / 2;
- }
- }
-
- if (drawAsSelected) {
- gc.setForeground(ColorResources.TABLE_CONTENTS_SELECTED_FONT_COLOR);
- } else {
- DATableDataFormat tableData = (DATableDataFormat) item.getData();
- InteractiveUIData uiData = (InteractiveUIData) tableData.getObject();
- Color cellColor = ColorResources.TABLE_CONTENTS_FONT_COLOR;
- int checkLocation = uiData.getCheckLocation();
- if (checkLocation == InteractiveInfo.CHECK_BEFORE_LINE) {
- cellColor = ColorResources.SERIES_COLOR_INTERACTIVE_BEFORE;
- } else if (checkLocation == InteractiveInfo.CHECK_AFTER_LINE) {
- cellColor = ColorResources.SERIES_COLOR_INTERACTIVE_AFTER;
- } else {
- Logger.error("Impossible case!!");
- }
- gc.setForeground(cellColor);
- }
- gc.setFont(FontResources.TABLE_CELL_FONT);
- if (isTree() && getColumn() != 0) {
- gc.drawText(text, getBounds().x + x, getBounds().y + textTopMargin,
- true);
- } else if (!isTree() || getColumn() != 0) {
- gc.drawText(text, getBounds().x + x, getBounds().y + textTopMargin,
- true);
- }
- if (item.getParent().getLinesVisible()) {
- gc.setForeground(ColorResources.TABLE_LINE);
- gc.drawLine(getBounds().x, getBounds().y + getBounds().height,
- getBounds().x + getBounds().width - 1, getBounds().y
- + getBounds().height);
- gc.drawLine(getBounds().x + getBounds().width - 1, getBounds().y,
- getBounds().x + getBounds().width - 1, getBounds().y
- + getBounds().height);
- }
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jungwook Ryu <jungwook.ryu@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.interactive.table;
-
-import org.eclipse.nebula.widgets.grid.GridItem;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Rectangle;
-import org.tizen.dynamicanalyzer.resources.ColorResources;
-import org.tizen.dynamicanalyzer.resources.FontResources;
-import org.tizen.dynamicanalyzer.resources.ImageResources;
-import org.tizen.dynamicanalyzer.ui.interactive.data.InteractiveUIData;
-import org.tizen.dynamicanalyzer.ui.interactive.model.InteractiveInfo;
-import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat;
-import org.tizen.dynamicanalyzer.ui.widgets.table.DATableToggleRenderer;
-import org.tizen.dynamicanalyzer.util.Logger;
-
-public class InteractiveTableToggleRenderer extends DATableToggleRenderer {
- public void paint(GC gc, Object value) {
- GridItem item = (GridItem) value;
- DATableDataFormat tableData = (DATableDataFormat) item.getData();
-
- Font font = item.getFont(0);
- if (null == font) {
- gc.setFont(FontResources.TABLE_CELL_FONT);
- } else {
- gc.setFont(font);
- }
-
- InteractiveUIData uiData = (InteractiveUIData) tableData.getObject();
- String text = item.getText(0);
-
- Color cellColor = ColorResources.TABLE_CONTENTS_FONT_COLOR;
- int checkLocation = uiData.getCheckLocation();
- if (checkLocation == InteractiveInfo.CHECK_BEFORE_LINE) {
- cellColor = ColorResources.SERIES_COLOR_INTERACTIVE_BEFORE;
- } else if (checkLocation == InteractiveInfo.CHECK_AFTER_LINE) {
- cellColor = ColorResources.SERIES_COLOR_INTERACTIVE_AFTER;
- } else {
- Logger.error("Impossible case!!");
- }
-
- if (item.hasChildren()) {
- if (isExpanded()) {
- Rectangle r = ImageResources.TREE_OPEN.getBounds();
- int offset = (getBounds().width - r.width) / 2;
- int x = getBounds().x + offset;
- gc.drawImage(ImageResources.TREE_OPEN, x, getBounds().y);
- x += r.width + 5;
- if (isSelected()) {
- gc.setForeground(ColorResources.TABLE_CONTENTS_SELECTED_FONT_COLOR);
- } else {
- gc.setForeground(cellColor);
- }
- gc.drawText(text, x, getBounds().y, true);
- } else {
- Rectangle r = ImageResources.TREE_FOLD.getBounds();
- int offset = (getBounds().width - r.width) / 2;
- int x = getBounds().x + offset;
- gc.drawImage(ImageResources.TREE_FOLD, getBounds().x + offset,
- getBounds().y);
- x += r.width + 5;
- if (isSelected()) {
- gc.setForeground(ColorResources.TABLE_CONTENTS_SELECTED_FONT_COLOR);
- } else {
- gc.setForeground(cellColor);
- }
- gc.drawText(text, x, getBounds().y, true);
- }
- } else {
- Rectangle r = ImageResources.TREE_OPEN.getBounds();
- int offset = (getBounds().width - r.width) / 2;
- int x = getBounds().x + offset;
- x += r.width;
- if (isSelected()) {
- gc.setForeground(ColorResources.TABLE_CONTENTS_SELECTED_FONT_COLOR);
- } else {
- gc.setForeground(cellColor);
- }
- gc.drawText(text, x, getBounds().y, true);
- }
- }
-
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jungwook Ryu <jungwook.ryu@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.interactive.table;
-
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
-import org.tizen.dynamicanalyzer.common.DASelectionData;
-import org.tizen.dynamicanalyzer.model.ColumnData;
-import org.tizen.dynamicanalyzer.nl.InteractivePageLabels;
-import org.tizen.dynamicanalyzer.resources.ColorResources;
-import org.tizen.dynamicanalyzer.ui.interactive.model.InteractiveInfo;
-import org.tizen.dynamicanalyzer.ui.widgets.DAAdvancedViewComposite;
-import org.tizen.dynamicanalyzer.widgets.da.view.DAViewData;
-
-public class InteractiveTableView extends DAAdvancedViewComposite {
- public static final String ID = InteractiveTableView.class.getName();
- protected InteractiveTable treeComp = null;
- protected List<ColumnData> columnData = null;
-
- protected String[] columnNames = {
- InteractivePageLabels.INTERACTIVE_TABLE_TIME,
- InteractivePageLabels.INTERACTIVE_TABLE_TYPE,
- InteractivePageLabels.INTERACTIVE_TABLE_VALUE };
- protected int[] columnSizes = { 200, 150, 0 };
- private int[] columnAlignment = { SWT.LEFT, SWT.RIGHT, SWT.LEFT};
- protected boolean[] columnVisibility = { true, true, true };
- protected int[] sortTypes = { AnalyzerConstants.SORT_TYPE_GRID,
- AnalyzerConstants.SORT_TYPE_NUM, AnalyzerConstants.SORT_TYPE_NONE,
- AnalyzerConstants.SORT_TYPE_NONE };
-
- public InteractiveTableView(Composite parent, int style) {
- super(parent, style, true, true);
- this.setLayout(new FillLayout());
-
- setTitle(InteractivePageLabels.INTERACTIVE_TABLE_VIEW_TITLE);
-
- Composite contents = getContentArea();
- contents.setBackground(ColorResources.WINDOW_BG_COLOR);
- contents.setLayout(new FillLayout());
- treeComp = new InteractiveTable(contents, SWT.NONE, SWT.MULTI
- | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
- /*** setTree set first!!! ***/
- treeComp.setTree(true);
- treeComp.setSortTypes(sortTypes);
- treeComp.setColumnAlignment(columnAlignment);
- treeComp.setColumns(columnNames);
- treeComp.setColumnSize(columnSizes);
- treeComp.setColumnVisibility(columnVisibility);
- treeComp.setTableToolTipEnable(false);
- setTable(treeComp);
- }
-
- @Override
- public void updateView() {
- treeComp.updateTree();
- }
-
- @Override
- public void updateView(DAViewData data) {
- if (data instanceof DASelectionData) {
- DASelectionData selData = (DASelectionData) data;
-
- long start = selData.getStartTime();
- long end = selData.getEndTime();
-
- if (data.getData() instanceof InteractiveInfo) {
- setTitle(((InteractiveInfo)data.getData()).getDescription());
- treeComp.setInteractiveInfo((InteractiveInfo)data.getData());
- treeComp.updateTree(start, end);
- } else {
- treeComp.deselectAll();
- }
- }
- }
-
- @Override
- public void clear() {
- treeComp.clear();
- }
-
- @Override
- public Control getControl() {
- return treeComp;
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jaewon Lim <jaewon81.lim@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.kernel;
-
-import java.util.HashMap;
-import java.util.List;
-
-import org.eclipse.swt.widgets.Composite;
-import org.tizen.dynamicanalyzer.common.Global;
-import org.tizen.dynamicanalyzer.nl.KernelPageLabels;
-import org.tizen.dynamicanalyzer.nl.TimelineChartLabels;
-import org.tizen.dynamicanalyzer.resources.ColorResources;
-import org.tizen.dynamicanalyzer.resources.FontResources;
-import org.tizen.dynamicanalyzer.resources.ImageResources;
-import org.tizen.dynamicanalyzer.ui.common.PopupAnalysisMenuItemClickListener;
-import org.tizen.dynamicanalyzer.ui.common.PopupClearMenuItemClickListener;
-import org.tizen.dynamicanalyzer.ui.common.PopupEndMenuItemClickListener;
-import org.tizen.dynamicanalyzer.ui.common.PopupFromSelectionMenuItemClickListener;
-import org.tizen.dynamicanalyzer.ui.common.PopupStartMenuItemClickListener;
-import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseEventListener;
-import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseTrackAdapter;
-import org.tizen.dynamicanalyzer.ui.kernel.data.FunctionDataDBTable;
-import org.tizen.dynamicanalyzer.ui.kernel.data.KernelDataMaker;
-import org.tizen.dynamicanalyzer.ui.kernel.data.KernelDataManager;
-import org.tizen.dynamicanalyzer.ui.kernel.data.KernelDataPerThread;
-import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
-import org.tizen.dynamicanalyzer.ui.widgets.DADefaultChartBoard;
-import org.tizen.dynamicanalyzer.util.Logger;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChart;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlot;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlot.AutoRangeType;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotTooltip;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartSeries;
-import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoardHeightChangeableItem;
-import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoardItemList;
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenu;
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuItem;
-
-public class CallFlowChart extends DADefaultChartBoard {
- private KernelDataPerThread selectedData = null;
- private boolean dirty = false;
- private final KernelDataMaker dataMaker = KernelDataManager.getInstance()
- .getDataMaker();
- private HashMap<String, DAChartSeries> seriesMap = null;
-
- public CallFlowChart(Composite parent, String title) {
- super(parent, title);
- }
-
- public CallFlowChart(Composite parent, String title, int[] scaleValues) {
- super(parent, title, scaleValues);
- }
-
- public CallFlowChart(Composite parent, String title, int boardStyle) {
- super(parent, title, boardStyle);
- }
-
- @Override
- protected void callBackScaleChanged() {
- updateChart();
- super.callBackScaleChanged();
- }
-
- @Override
- protected void callBackScrollChanged() {
- updateChart();
- super.callBackScrollChanged();
- }
-
- @Override
- protected void callBackSizeChanged() {
- layout(true, true);
- updateChart();
- super.callBackSizeChanged();
- }
-
- public void itemListClear() {
- DAChartBoardItemList itemList = getItemList();
- itemList.clear();
- itemList.setSize(0, 0);
-
- if (null != selectItem) {
- selectItem = null;
- }
- }
-
- public void setSelectedData(KernelDataPerThread data) {
- selectedData = data;
- dirty = true;
- }
-
- public void updateChart() {
- // remove all previous items
- if (dirty) {
- itemListClear();
- if (seriesMap != null) {
- seriesMap.clear();
- seriesMap = null;
- }
- }
-
- if (selectedData == null) {
- redraw();
- update();
- return;
- }
-
- if (dirty) {
- // get data from db
- List<List<Object>> funcnames = dataMaker
- .getFuncnameFromDB(selectedData.getTid());
- int fsize = funcnames.size();
-
- // create board item for these functions
- DAChartBoardHeightChangeableItem funcItem = new DAChartBoardHeightChangeableItem(
- this, KernelPageLabels.CALL_FLOW_BOARD_NAME_TID + " "
- + selectedData.getTid());
- initCallflowChart(funcItem, fsize);
-
- seriesMap = new HashMap<String, DAChartSeries>(fsize * 2);
- DAChart funcChart = funcItem.getChart();
- for (int i = 0; i < fsize; i++) {
- String funcname = (String) funcnames.get(i).get(0);
- DAChartSeries funcseries = new DAChartSeries(funcname, -1,
- ColorResources.RED, true);
- funcChart.addSeries(funcseries);
- funcseries.setData(new Integer(i));
- seriesMap.put(funcname, funcseries);
- }
-
- dirty = false;
- }
-
- drawChart();
- }
-
- private void drawChart() {
- if (selectedData == null) {
- return;
- }
-
- // get data from database and add new item to series
- long starttime = (long) (getVisibleStartTime() * TimelineConstants.MEGA_DOUBLE);
- long endtime = (long) (getVisibleEndTime() * TimelineConstants.MEGA_DOUBLE);
-
- List<List<Object>> functionData = dataMaker.getFunctionDataFromDB(
- starttime, endtime, selectedData.getTid());
- if (functionData == null || functionData.isEmpty()) {
- return;
- }
-
- int fsize = functionData.size();
- ContextSwitchingChartSeriesItem prevItem = null;
- int prevSeriesNum = -1;
-
- for (int i = 0; i < fsize; i++) {
- List<Object> idata = functionData.get(i);
- int funcId = (Integer) idata
- .get(FunctionDataDBTable.COLUMN.FUNCID.index);
- String funcname = Global.getFunctionName(funcId);
- double funcStart = (double) ((Long) idata
- .get(FunctionDataDBTable.COLUMN.STARTTIME.index))
- / TimelineConstants.MEGA_DOUBLE;
- double funcEnd = (double) ((Long) idata
- .get(FunctionDataDBTable.COLUMN.ENDTIME.index))
- / TimelineConstants.MEGA_DOUBLE;
-
- DAChartSeries funcSeries = seriesMap.get(funcname);
- if (funcSeries != null) {
- int curSeriesNum = ((Integer) funcSeries.getData()).intValue();
- ContextSwitchingChartSeriesItem curItem = new ContextSwitchingChartSeriesItem(
- null, funcStart, funcEnd, ColorResources.RED);
-
- // for previous function segment
- if (prevItem != null && prevSeriesNum != curSeriesNum) {
- prevItem.setArrow(curSeriesNum - prevSeriesNum);
- }
- funcSeries.addSeriesItem(curItem);
-
- prevItem = curItem;
- prevSeriesNum = curSeriesNum;
- } else {
- Logger.error("Function series is not exist in call flow chart");
- }
- }
-
- // redraw
- redraw();
- update();
- }
-
- private void initCallflowChart(DAChartBoardHeightChangeableItem chartItem,
- int itemsize) {
- DAChart chart = chartItem.getChart();
- if (null == chart) {
- return;
- }
-
- DAChartPlot plot = chart.getPlot();
- if (null == plot) {
- return;
- }
-
- chartItem.useExpand(false);
- chartItem.setHeightRatio(itemsize * 0.3);
- chart.getPlot().setAutoHeightRange(AutoRangeType.MANUAL);
- chart.getPlot().setShowAxis(false);
- chart.setChartRenderer(new CallFlowChartRenderer());
-
- plot.setBackgroundImage(ImageResources.BG_GRADIENT);
-
- DAChartPlotTooltip tooltip = new DAChartPlotTooltip(-1);
- tooltip.setFont(FontResources.CHART_TOOLTIP_FONT);
- plot.setTooltip(tooltip);
-
- DAPopupMenu popupMenu = new DAPopupMenu(chart);
- popupMenu.setFont(FontResources.CONTEXT_MENU_ITEM_FONT);
-
- DAPopupMenuItem startItem = new DAPopupMenuItem(popupMenu,
- DAPopupMenuItem.NONE);
- startItem.setText(TimelineChartLabels.RANGE_CONTEXT_SET_START);
- startItem.addListener(new PopupStartMenuItemClickListener(startItem,
- this));
-
- DAPopupMenuItem endItem = new DAPopupMenuItem(popupMenu,
- DAPopupMenuItem.NONE);
- endItem.setText(TimelineChartLabels.RANGE_CONTEXT_SET_END);
- endItem.addListener(new PopupEndMenuItemClickListener(endItem, this));
-
- DAPopupMenuItem fromSelectionItem = new DAPopupMenuItem(popupMenu,
- DAPopupMenuItem.NONE);
- fromSelectionItem
- .setText(TimelineChartLabels.RANGE_CONTEXT_SET_FROM_SELECTION);
- fromSelectionItem
- .addListener(new PopupFromSelectionMenuItemClickListener(
- fromSelectionItem, this));
-
- DAPopupMenuItem analysisItem = new DAPopupMenuItem(popupMenu,
- DAPopupMenuItem.NONE);
- analysisItem.setText(TimelineChartLabels.RANGE_CONTEXT_ANALYSIS);
- analysisItem.addListener(new PopupAnalysisMenuItemClickListener());
-
- DAPopupMenuItem clearItem = new DAPopupMenuItem(popupMenu,
- DAPopupMenuItem.NONE);
- clearItem.setText(TimelineChartLabels.RANGE_CONTEXT_CLEAR);
- clearItem.addListener(new PopupClearMenuItemClickListener());
-
- TimelineChartMouseEventListener timelineChartMouseEventListener = new TimelineChartMouseEventListener(
- popupMenu, getTimeline(), KernelPage.pageID);
- chart.addMouseListener(timelineChartMouseEventListener);
- chart.addMouseMoveListener(timelineChartMouseEventListener);
- chart.addMouseTrackListener(new TimelineChartMouseTrackAdapter(
- getTimeline()));
- plot.setMarkers(getMarkers());
- }
-
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jaewon Lim <jaewon81.lim@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.kernel;
-
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.GC;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartSeries;
-import org.tizen.dynamicanalyzer.widgets.helper.ColorResources;
-
-public class CallFlowChartRenderer extends ContextSwitchingChartRenderer {
- @Override
- protected void drawChartSeries(GC gc, DAChartSeries series,
- int seriesIndex) {
- super.drawChartSeries(gc, series, seriesIndex);
- Font oriFont = gc.getFont();
- Font nameAnnotationFont = series.getFont();
- gc.setFont(nameAnnotationFont);
-
- gc.setForeground(ColorResources.SERIES_NAME_ANNOTATION);
- gc.drawText(series.getName(), rect.x + 3, rect.y + rect.height / 2
- - gc.stringExtent(series.getName()).y / 2, true);
-
- gc.setFont(oriFont);
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jaewon Lim <jaewon81.lim@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.kernel;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.ScrollBar;
-import org.tizen.dynamicanalyzer.common.AnalyzerManager;
-import org.tizen.dynamicanalyzer.common.DASelectionData;
-import org.tizen.dynamicanalyzer.nl.KernelPageLabels;
-import org.tizen.dynamicanalyzer.resources.ColorResources;
-import org.tizen.dynamicanalyzer.resources.FontResources;
-import org.tizen.dynamicanalyzer.ui.common.UICommonConstants;
-import org.tizen.dynamicanalyzer.ui.kernel.data.KernelSelectionData;
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
-import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
-import org.tizen.dynamicanalyzer.ui.timeline.logparser.LifecycleLogParser;
-import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
-import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
-import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonRenderer;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotIntervalMarker;
-import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoard;
-import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoardItem;
-import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoardSelectionListener;
-import org.tizen.dynamicanalyzer.widgets.combo.DACustomCombo;
-import org.tizen.dynamicanalyzer.widgets.da.view.DAViewComposite;
-import org.tizen.dynamicanalyzer.widgets.da.view.DAViewData;
-import org.tizen.dynamicanalyzer.widgets.timeline.DATimeline;
-
-public class CallFlowChartView extends DAViewComposite {
- private final Composite contents;
- private CallFlowChart callflowChart;
- private DACustomCombo callflowCombo;
- private final StackLayout stackLayout;
-
- private final RangeDataManager rangeDataManager = RangeDataManager
- .getInstance();
-
- public CallFlowChartView(Composite parent, int style) {
- super(parent, style, false);
- this.setLayout(new FillLayout());
-
- setTitle(KernelPageLabels.CALL_FLOW_CHART_TITLE);
-
- contents = getContentArea();
- contents.setBackground(ColorResources.WINDOW_BG_COLOR);
- stackLayout = new StackLayout();
- contents.setLayout(stackLayout);
- callflowChart = new CallFlowChart(contents,
- KernelPageLabels.CALL_FLOW_CHART_TITLE,
- ContextSwitchingChartView.kernelScaleValue);
- callflowChart.setNameFont(FontResources.CHART_NAME_FONT);
- callflowChart.addSelectionListener(new DAChartBoardSelectionListener() {
- @Override
- public void handleSelectionEvent(DAChartBoardItem item) {
- AnalyzerManager
- .getCurrentPage()
- .updateView(
- new DASelectionData(
- KernelPage.callflowViewID,
- (long) (((DAChartPlotIntervalMarker) callflowChart
- .getMarkers()
- .get(UICommonConstants.SELECTION_MARKER_INDEX))
- .getStartVal() * TimelineConstants.MEGA_DOUBLE),
- (long) (((DAChartPlotIntervalMarker) callflowChart
- .getMarkers()
- .get(UICommonConstants.SELECTION_MARKER_INDEX))
- .getEndVal() * TimelineConstants.MEGA_DOUBLE),
- new Integer(0), null));
- }
- });
-
- ScrollBar hScrollBar = callflowChart.getHScrollBar();
- hScrollBar.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (callflowChart.isMaximumScrolled()) {
- AnalyzerUtil.setLatestTraceMode(KernelPage.pageID, true);
- } else {
- AnalyzerUtil.setLatestTraceMode(KernelPage.pageID, false);
- }
- }
- });
-
- initIntervalMarkers(callflowChart);
-
- stackLayout.topControl = callflowChart;
- callflowCombo = new DACustomCombo(callflowChart.getTitleComp(),
- SWT.NONE);
-
- callflowCombo.setComboGradation(
- ColorResources.FRAME_RATE_COMBO_NORMAL_START,
- ColorResources.FRAME_RATE_COMBO_NORMAL_END,
- ColorResources.FRAME_RATE_COMBO_PUSH_START,
- ColorResources.FRAME_RATE_COMBO_PUSH_END,
- ColorResources.FRAME_RATE_COMBO_HOVER_START,
- ColorResources.FRAME_RATE_COMBO_HOVER_END,
- ColorResources.FRAME_RATE_COMBO_DISABLE_START,
- ColorResources.FRAME_RATE_COMBO_DISABLE_END);
- callflowCombo.setOutlineColors(ColorResources.FRAME_RATE_COMBO_OUTLINE_NORMAL,
- ColorResources.FRAME_RATE_COMBO_OUTLINE_PUSH,
- ColorResources.FRAME_RATE_COMBO_OUTLINE_HOVER,
- ColorResources.FRAME_RATE_COMBO_OUTLINE_DISABLE);
-
- callflowCombo.add(KernelPageLabels.CALL_FLOW_CHART_TITLE);
- callflowCombo.select(0);
- callflowCombo.setEnabled(false);
- callflowCombo.setTextAlign(DACustomCombo.TEXT_ALIGN_LEFT);
- callflowCombo.setComboFont(FontResources.FRAME_RATE_COMBO);
- callflowCombo.setFontColors(ColorResources.ADD_CHART_FONT_COLOR,
- ColorResources.ADD_CHART_FONT_COLOR,
- ColorResources.ADD_CHART_FONT_COLOR,
- ColorResources.ADD_CHART_FONT_COLOR);
- callflowCombo.setItemFont(FontResources.FRAME_RATE_DROPDOWN);
- callflowCombo.setItemFontColor(ColorResources.ADD_CHART_FONT_COLOR);
- callflowCombo.setButtonRenderer(new DACustomButtonRenderer());
-
- DATimeline timeline = callflowChart.getTimeline();
-
- timeline.setTimeTickFont(FontResources.TIMELINE_TICK_FONT);
- timeline.setTimeBalloonFont(FontResources.TIMELINE_BALLOON_FONT);
-
- LifecycleLogParser.getInstance().registerLifecycleBar(
- callflowChart.getLifecycleBar());
- LifecycleLogParser.getInstance().registerTimeline(timeline);
- }
-
- @Override
- public void updateView() {
- callflowChart.updateChart();
-
- /*
- * In case of Latest status, update visibleStartTime of chartBoard.
- * Because Chart should be refreshed automatically even Page change.
- */
- if (AnalyzerUtil.isLatestTraceMode(KernelPage.pageID)) {
- callflowChart.updateVisibleStartTime();
- callflowChart.setTotalEndTime(Toolbar.INSTANCE.getTime(), true);
- } else {
- // set chart end time
- callflowChart.setTotalEndTime(Toolbar.INSTANCE.getTime(), false);
- }
-
- RangeDataManager rangeDataManager = RangeDataManager.getInstance();
- if (rangeDataManager.isBeingAnalyzed()) {
- ((DAChartPlotIntervalMarker) callflowChart.getMarkers().get(
- UICommonConstants.RANGE_ANALYSIS_MARKER_INDEX))
- .setInterval(rangeDataManager.getAnalysisStartTime()
- / TimelineConstants.MEGA_DOUBLE,
- rangeDataManager.getAnalysisEndTime()
- / TimelineConstants.MEGA_DOUBLE);
- } else {
- ((DAChartPlotIntervalMarker) callflowChart.getMarkers().get(
- UICommonConstants.RANGE_ANALYSIS_MARKER_INDEX))
- .setInterval(-1, -1);
- }
-
- ((DAChartPlotIntervalMarker) callflowChart.getMarkers().get(
- UICommonConstants.RANGE_MARKER_INDEX)).setInterval(
- rangeDataManager.getMarkerStartTime()
- / TimelineConstants.MEGA_DOUBLE,
- rangeDataManager.getMarkerEndTime()
- / TimelineConstants.MEGA_DOUBLE);
- }
-
- @Override
- public void updateView(DAViewData data) {
- if (data instanceof DASelectionData) {
- DASelectionData selData = (DASelectionData) data;
-
- Object odata = selData.getData();
- long selectionStartTime, selectionEndTime;
-
- if (!(odata instanceof KernelSelectionData)) {
- selectionStartTime = selData.getStartTime();
- selectionEndTime = selData.getEndTime();
-
- double startTime = (double) selectionStartTime
- / TimelineConstants.MEGA_DOUBLE;
- double endTime = (double) selectionEndTime
- / TimelineConstants.MEGA_DOUBLE;
-
- DAChartBoard chartBoard = (DAChartBoard) stackLayout.topControl;
-
- DAChartPlotIntervalMarker intervalMarker = (DAChartPlotIntervalMarker) chartBoard
- .getMarkers().get(
- UICommonConstants.SELECTION_MARKER_INDEX);
- intervalMarker.setInterval(startTime, endTime);
- } else {
- KernelSelectionData sdata = (KernelSelectionData) odata;
- callflowChart.setSelectedData(sdata.getData());
- callflowChart.updateChart();
- }
- }
- }
-
- @Override
- public void clear() {
- callflowChart.clear();
- initIntervalMarkers(callflowChart);
- }
-
- @Override
- public Control getControl() {
- return callflowChart;
- }
-
- private void initIntervalMarkers(DAChartBoard board) {
- // selection marker
- DAChartPlotIntervalMarker selectionMarker = new DAChartPlotIntervalMarker(
- -1, -1, DAChartPlotIntervalMarker.INTERVAL_MARKER_STYLE_AREA);
- selectionMarker.setBackgroundColor(ColorResources.SELECTION_RANGE);
- selectionMarker.setAlpha((int) (255 * 0.25));
- board.addIntervalMarker(selectionMarker);
-
- // range analysis marker
- DAChartPlotIntervalMarker rangeAnalyzeMarker = new DAChartPlotIntervalMarker(
- -1, -1, DAChartPlotIntervalMarker.INTERVAL_MARKER_STYLE_AREA);
- rangeAnalyzeMarker.setBackgroundColor(ColorResources.YELLOW);
- rangeAnalyzeMarker.setAlpha((int) (255 * 0.25));
- board.addIntervalMarker(rangeAnalyzeMarker);
-
- // range marker
- DAChartPlotIntervalMarker rangeMarker = new DAChartPlotIntervalMarker(
- -1, -1, DAChartPlotIntervalMarker.INTERVAL_MARKER_STYLE_LINE);
- rangeMarker.setForegroundColor(ColorResources.RED);
- rangeMarker.setAlpha((int) (255 * 0.25));
- board.addIntervalMarker(rangeMarker);
- }
-
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jaewon Lim <jaewon81.lim@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.kernel;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.eclipse.swt.widgets.Composite;
-import org.tizen.dynamicanalyzer.common.Global;
-import org.tizen.dynamicanalyzer.nl.KernelPageLabels;
-import org.tizen.dynamicanalyzer.nl.TimelineChartLabels;
-import org.tizen.dynamicanalyzer.resources.ColorResources;
-import org.tizen.dynamicanalyzer.resources.FontResources;
-import org.tizen.dynamicanalyzer.resources.ImageResources;
-import org.tizen.dynamicanalyzer.ui.common.PopupAnalysisMenuItemClickListener;
-import org.tizen.dynamicanalyzer.ui.common.PopupClearMenuItemClickListener;
-import org.tizen.dynamicanalyzer.ui.common.PopupEndMenuItemClickListener;
-import org.tizen.dynamicanalyzer.ui.common.PopupFromSelectionMenuItemClickListener;
-import org.tizen.dynamicanalyzer.ui.common.PopupStartMenuItemClickListener;
-import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseEventListener;
-import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseTrackAdapter;
-import org.tizen.dynamicanalyzer.ui.kernel.data.ContextDataDBTable;
-import org.tizen.dynamicanalyzer.ui.kernel.data.FunctionDataDBTable;
-import org.tizen.dynamicanalyzer.ui.kernel.data.KernelDataMaker;
-import org.tizen.dynamicanalyzer.ui.kernel.data.KernelDataManager;
-import org.tizen.dynamicanalyzer.ui.kernel.data.KernelDataPerThread;
-import org.tizen.dynamicanalyzer.ui.kernel.data.KernelDataPerThreadComparator;
-import org.tizen.dynamicanalyzer.ui.kernel.data.KernelSelectionData;
-import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
-import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
-import org.tizen.dynamicanalyzer.ui.widgets.DADefaultChartBoard;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChart;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlot;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlot.AutoRangeType;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotTooltip;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartSeries;
-import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoardHeightChangeableItem;
-import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoardItem;
-import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoardItemList;
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenu;
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuItem;
-
-public class ContextSwitchingChart extends DADefaultChartBoard {
- public static final String KERNEL_CHART_DATA_TYPE = "kernel_data_type";
-
- private final KernelDataMaker dataMaker = KernelDataManager.getInstance().getDataMaker();
-
- private int savedSelectedPid = 0;
-
- public ContextSwitchingChart(Composite parent, String title) {
- super(parent, title);
- }
-
- public ContextSwitchingChart(Composite parent, String title, int[] scaleValues) {
- super(parent, title, scaleValues);
- }
-
- public ContextSwitchingChart(Composite parent, String title, int boardStyle) {
- super(parent, title, boardStyle);
- }
-
- @Override
- protected void callBackScaleChanged() {
- updateChart();
- super.callBackScaleChanged();
- }
-
- @Override
- protected void callBackScrollChanged() {
- updateChart();
- super.callBackScrollChanged();
- }
-
- @Override
- protected void callBackSizeChanged() {
- layout(true, true);
- updateChart();
- super.callBackSizeChanged();
- }
-
- public void updateChart() {
- List<KernelDataPerThread> threads = dataMaker.getThreadData();
- int thread_size = threads.size();
- boolean isDirty = false;
-
- for (int i = 0; i < thread_size; i++) {
- KernelDataPerThread kdata = threads.get(i);
- DAChartBoardItem bitem = kdata.getContextChart();
- if (bitem == null) {
- // create board item for this thread context
- DAChartBoardHeightChangeableItem coreItem = new DAChartBoardHeightChangeableItem(
- this, getChartName(kdata));
- initContextSwitchChart(coreItem, true);
-
- DAChart coreChart = coreItem.getChart();
- DAChartSeries coreSeries = new DAChartSeries(
- KernelPageLabels.CONTEXT_SWITCH_SERIES_NAME, -1, ColorResources.BLUE);
- coreChart.addSeries(coreSeries);
-
- coreItem.setData(new KernelSelectionData(kdata,
- KernelSelectionData.KERNEL_DATA_TYPE_CONTEXTSWITCH));
- kdata.setContextChart(coreItem);
- isDirty = true;
- } else {
- // delete previous drawing items
- DAChartSeries series = bitem.getChart().getSeries(0);
- if (series != null) {
- series.clear();
- }
- }
-
- bitem = kdata.getFunctionChart();
- if (kdata.getFunclog() != null && bitem == null) {
- // create board item for function
- DAChartBoardHeightChangeableItem functionItem = new DAChartBoardHeightChangeableItem(
- kdata.getContextChart(),
- KernelPageLabels.CONTEXT_SWITCH_BOARD_NAME_FUNC_CHILD);
- initContextSwitchChart(functionItem, false);
-
- DAChart functionChart = functionItem.getChart();
- DAChartSeries functionSeries = new DAChartSeries(
- KernelPageLabels.CONTEXT_SWITCH_SERIES_NAME_CHILD, -1, ColorResources.RED);
- functionChart.addSeries(functionSeries);
-
- functionItem.setData(new KernelSelectionData(kdata,
- KernelSelectionData.KERNEL_DATA_TYPE_FUNCTIONCALL));
- kdata.setFunctionChart(functionItem);
- } else if (bitem != null) {
- // delete previous drawing items
- DAChartSeries series = bitem.getChart().getSeries(0);
- if (series != null) {
- series.clear();
- }
- }
- }
-
- // rearrange items
- if (isDirty) {
- rearrangeChart();
- }
-
- // filtering by pid
- int selectedPid = Toolbar.INSTANCE.getSelectedPid();
- if (isDirty || savedSelectedPid != selectedPid) {
- DAChartBoardItemList itemlist = getItemList();
- thread_size = itemlist.getItemSize();
- for (int i = 0; i < thread_size; i++) {
- if (selectedPid != 0) {
- DAChartBoardItem item = itemlist.get(i);
- KernelSelectionData seldata = (KernelSelectionData) item.getData();
- if (seldata.getData().getPid() == selectedPid) {
- showItem(i);
- } else {
- hideItem(i);
- }
- } else {
- showItem(i);
- }
- }
- savedSelectedPid = selectedPid;
- }
-
- // get data from database and add new item to series
- long starttime = (long) (getVisibleStartTime() * TimelineConstants.MEGA_DOUBLE);
- long endtime = (long) (getVisibleEndTime() * TimelineConstants.MEGA_DOUBLE);
-
- List<List<Object>> contextData = dataMaker.getContextDataFromDB(starttime, endtime);
- List<List<Object>> functionData = dataMaker.getFunctionDataFromDB(starttime, endtime, -1);
- if (contextData != null) {
- int csize = contextData.size();
- for (int i = 0; i < csize; i++) {
- List<Object> idata = contextData.get(i);
- int tid = (Integer) idata.get(ContextDataDBTable.COLUMN.TID.index);
- int cpunum = (Integer) idata.get(ContextDataDBTable.COLUMN.CPUNUM.index);
- double contextStart = (double) ((Long) idata
- .get(ContextDataDBTable.COLUMN.STARTTIME.index))
- / TimelineConstants.MEGA_DOUBLE;
- double contextEnd = (double) ((Long) idata
- .get(ContextDataDBTable.COLUMN.ENDTIME.index))
- / TimelineConstants.MEGA_DOUBLE;
-
- DAChartBoardItem coreItem = findCoreBoardItem(threads, tid);
- assert (coreItem != null);
- DAChartSeries coreSeries = coreItem.getChart().getSeries(0);
-
- if (coreSeries != null) {
- coreSeries.addSeriesItem(new ContextSwitchingChartSeriesItem(
- KernelPageLabels.CONTEXT_SWITCH_SERIES_ITEM_NAME + " "
- + Integer.toString(cpunum), contextStart, contextEnd));
- }
- }
- }
-
- if (functionData != null) {
- int fsize = functionData.size();
- for (int i = 0; i < fsize; i++) {
- List<Object> idata = functionData.get(i);
- int tid = (Integer) idata.get(FunctionDataDBTable.COLUMN.TID.index);
- int funcId = (Integer) idata.get(FunctionDataDBTable.COLUMN.FUNCID.index);
- String funcname = Global.getFunctionName(funcId);
- double funcStart = (double) ((Long) idata
- .get(FunctionDataDBTable.COLUMN.STARTTIME.index))
- / TimelineConstants.MEGA_DOUBLE;
- double funcEnd = (double) ((Long) idata
- .get(FunctionDataDBTable.COLUMN.ENDTIME.index))
- / TimelineConstants.MEGA_DOUBLE;
- int type = (Integer) idata.get(FunctionDataDBTable.COLUMN.STARTTYPE.index)
- + (Integer) idata.get(FunctionDataDBTable.COLUMN.ENDTYPE.index);
-
- DAChartBoardItem functionItem = findFunctionBoardItem(threads, tid);
- assert (functionItem != null);
- DAChartSeries funcSeries = functionItem.getChart().getSeries(0);
- if (funcSeries != null) {
- int style;
- switch (type) {
- case 21:
- case 31:
- style = ContextSwitchingChartSeriesItem.STYLE_OCTAGON_LEFT_ONLY;
- break;
- case 12:
- case 13:
- style = ContextSwitchingChartSeriesItem.STYLE_OCTAGON_RIGHT_ONLY;
- break;
- case 22:
- case 32:
- case 23:
- case 33:
- style = ContextSwitchingChartSeriesItem.STYLE_OCTAGON;
- break;
- case 11:
- default:
- style = ContextSwitchingChartSeriesItem.STYLE_SQUARE;
- break;
- }
-
- funcSeries.addSeriesItem(new ContextSwitchingChartSeriesItem(funcname,
- funcStart, funcEnd, style));
- }
- }
- }
-
- // redraw chart
- redraw();
- update();
- }
-
- private String getChartName(KernelDataPerThread data) {
- String name = KernelPageLabels.CONTEXT_SWITCH_BOARD_NAME_PID + " " + data.getPid() + "\n"
- + KernelPageLabels.CONTEXT_SWITCH_BOARD_NAME_TID + " " + data.getTid();
- return name;
- }
-
- private DAChartBoardItem findCoreBoardItem(List<KernelDataPerThread> threads, int tid) {
- int size = threads.size();
- for (int i = 0; i < size; i++) {
- if (threads.get(i).getTid() == tid)
- return threads.get(i).getContextChart();
- }
-
- return null;
- }
-
- private DAChartBoardItem findFunctionBoardItem(List<KernelDataPerThread> threads, int tid) {
- int size = threads.size();
- for (int i = 0; i < size; i++) {
- if (threads.get(i).getTid() == tid)
- return threads.get(i).getFunctionChart();
- }
-
- return null;
- }
-
- private void rearrangeChart() {
- DAChartBoardItemList itemList = getItemList();
- int listsize = itemList.getItemSize();
-
- TreeMap<KernelDataPerThread, Integer> sortedmap = new TreeMap<KernelDataPerThread, Integer>(
- new KernelDataPerThreadComparator());
-
- for (int i = 0; i < listsize; i++) {
- DAChartBoardItem item = itemList.get(i);
- KernelDataPerThread gdata = ((KernelSelectionData) item.getData()).getData();
- sortedmap.put(gdata, i);
- }
-
- Map.Entry<KernelDataPerThread, Integer> entry;
- ArrayList<Integer> arranged = new ArrayList<Integer>();
- while ((entry = sortedmap.pollFirstEntry()) != null) {
- arranged.add(entry.getValue());
- }
-
- reArrangeItem(arranged.toArray(new Integer[listsize]));
- }
-
- private void initContextSwitchChart(DAChartBoardHeightChangeableItem chartItem, boolean isParent) {
- DAChart chart = chartItem.getChart();
- if (null == chart) {
- return;
- }
-
- DAChartPlot plot = chart.getPlot();
- if (null == plot) {
- return;
- }
-
- chartItem.useExpand(false);
- chartItem.setHeightRatio(1);
- chart.getPlot().setAutoHeightRange(AutoRangeType.MANUAL);
- chart.getPlot().setShowAxis(false);
- chart.setChartRenderer(new ContextSwitchingChartRenderer());
-
- if (isParent) {
- plot.setBackgroundImage(ImageResources.BG_GRADIENT);
- } else {
- plot.setBackgroundImage(ImageResources.BG_CHILD_GRADIENT);
- }
-
- DAChartPlotTooltip tooltip = new DAChartPlotTooltip(-1);
- tooltip.setFont(FontResources.CHART_TOOLTIP_FONT);
- plot.setTooltip(tooltip);
-
- DAPopupMenu popupMenu = new DAPopupMenu(chart);
- popupMenu.setFont(FontResources.CONTEXT_MENU_ITEM_FONT);
-
- DAPopupMenuItem startItem = new DAPopupMenuItem(popupMenu, DAPopupMenuItem.NONE);
- startItem.setText(TimelineChartLabels.RANGE_CONTEXT_SET_START);
- startItem.addListener(new PopupStartMenuItemClickListener(startItem, this));
-
- DAPopupMenuItem endItem = new DAPopupMenuItem(popupMenu, DAPopupMenuItem.NONE);
- endItem.setText(TimelineChartLabels.RANGE_CONTEXT_SET_END);
- endItem.addListener(new PopupEndMenuItemClickListener(endItem, this));
-
- DAPopupMenuItem fromSelectionItem = new DAPopupMenuItem(popupMenu, DAPopupMenuItem.NONE);
- fromSelectionItem.setText(TimelineChartLabels.RANGE_CONTEXT_SET_FROM_SELECTION);
- fromSelectionItem.addListener(new PopupFromSelectionMenuItemClickListener(
- fromSelectionItem, this));
-
- DAPopupMenuItem analysisItem = new DAPopupMenuItem(popupMenu, DAPopupMenuItem.NONE);
- analysisItem.setText(TimelineChartLabels.RANGE_CONTEXT_ANALYSIS);
- analysisItem.addListener(new PopupAnalysisMenuItemClickListener());
-
- DAPopupMenuItem clearItem = new DAPopupMenuItem(popupMenu, DAPopupMenuItem.NONE);
- clearItem.setText(TimelineChartLabels.RANGE_CONTEXT_CLEAR);
- clearItem.addListener(new PopupClearMenuItemClickListener());
-
- TimelineChartMouseEventListener timelineChartMouseEventListener = new TimelineChartMouseEventListener(
- popupMenu, getTimeline(), KernelPage.pageID);
- chart.addMouseListener(timelineChartMouseEventListener);
- chart.addMouseMoveListener(timelineChartMouseEventListener);
- chart.addMouseTrackListener(new TimelineChartMouseTrackAdapter(getTimeline()));
- plot.setMarkers(getMarkers());
- }
-
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jaewon Lim <jaewon81.lim@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.kernel;
-
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Rectangle;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChart;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartRenderer;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartSeries;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartSeriesItem;
-import org.tizen.dynamicanalyzer.widgets.helper.ColorResources;
-
-public class ContextSwitchingChartRenderer extends DAChartRenderer {
- private static final int ARC = 6;
- protected Rectangle rect;
-
- @Override
- protected void drawToGc(GC gc, DAChart chart) {
- if (!preDraw(gc, chart)) {
- return;
- }
-
- for (int i = 0; i < seriesList.size(); i++) {
- drawChartSeries(gc, seriesList.get(i), i);
- }
-
- for (int i = 0; i < seriesList.size(); i++) {
- drawChartSeriesArrow(gc, seriesList.get(i), i);
- }
-
- drawAxis(gc);
- }
-
- protected void drawChartSeries(GC gc, DAChartSeries series, int seriesIndex) {
- int seriesSize = seriesList.size();
- rect = new Rectangle(r.x, r.y + r.height * seriesIndex / seriesSize,
- r.width, r.height / seriesSize);
-
- if (seriesIndex != 0) {
- gc.setForeground(ColorResources.CHART_SEPERATE_LINE);
- gc.drawLine(rect.x, r.height * seriesIndex / seriesSize,
- rect.width, r.height * seriesIndex / seriesSize);
- }
-
- List<DAChartSeriesItem> seriesItems = series.getSeriesItemList();
- if (seriesItems == null) {
- return;
- }
- int seriesItemSize = seriesItems.size();
- if (seriesItemSize < 1) {
- return;
- }
-
- Color seriesColor = series.getColor();
- gc.setForeground(seriesColor);
- gc.setLineStyle(SWT.LINE_SOLID);
- gc.setAntialias(SWT.ON);
-
- int index = series.getPrevIndexByXvalue(plot.getVisibleStartX());
- if (index < 0) {
- index = 0;
- }
-
- for (int i = index; i < seriesItemSize; i++) {
- if (!drawChartSeriesItem(gc,
- (ContextSwitchingChartSeriesItem) seriesItems.get(i),
- seriesColor)) {
- break;
- }
- }
- }
-
- private boolean drawChartSeriesItem(GC gc,
- ContextSwitchingChartSeriesItem seriesItem, Color seriesColor) {
- double x = seriesItem.getX();
- if (x > plot.getVisibleEndX()) {
- return false;
- }
-
- double endX = seriesItem.getEndX();
- if(endX == -1) {
- endX = plot.getValidEndX();
- }
-
- int pixelX = plot.getXPixelFromX(x, r);
- int pixelEndX = plot.getXPixelFromX(endX, r);
-
- gc.setBackground(seriesColor);
- if (seriesItem.getColor() != null) {
- gc.setBackground(seriesItem.getColor());
- }
- Color boarderColor = seriesItem.getBorderColor();
-
- int leftX = pixelX + ARC;
- int rightX = pixelEndX - ARC;
- int upperY = rect.y + (int) Math.round((rect.height * 0.1));
- int underY = rect.y + (int) Math.round((rect.height * 0.9));
- int[] points;
-
- switch (seriesItem.getStyle()) {
- case ContextSwitchingChartSeriesItem.STYLE_OCTAGON:
- if (leftX > rightX) {
- int gap = leftX - rightX;
- leftX = leftX - gap / 2;
- rightX = rightX + gap / 2;
- }
- points = new int[] { leftX, upperY, pixelX, upperY + ARC, pixelX,
- underY - ARC, leftX, underY, rightX, underY, pixelEndX,
- underY - ARC, pixelEndX, upperY + ARC, rightX, upperY };
- gc.fillPolygon(points);
-
- if (boarderColor != null) {
- gc.setForeground(boarderColor);
- gc.drawPolygon(points);
- }
- break;
- case ContextSwitchingChartSeriesItem.STYLE_OCTAGON_LEFT_ONLY:
- if (leftX > pixelEndX) {
- int gap = leftX - pixelEndX;
- leftX = leftX - gap;
- }
- points = new int[] { leftX, upperY, pixelX, upperY + ARC, pixelX,
- underY - ARC, leftX, underY, pixelEndX, underY,
- pixelEndX, upperY, };
- gc.fillPolygon(points);
-
- if (boarderColor != null) {
- gc.setForeground(boarderColor);
- gc.drawPolygon(points);
- }
- break;
- case ContextSwitchingChartSeriesItem.STYLE_OCTAGON_RIGHT_ONLY:
- if (rightX < pixelX) {
- int gap = pixelX - rightX;
- rightX = rightX + gap;
- }
- points = new int[] { pixelX, upperY, pixelX, underY, rightX,
- underY, pixelEndX, underY - ARC, pixelEndX, upperY + ARC,
- rightX, upperY };
- gc.fillPolygon(points);
-
- if (boarderColor != null) {
- gc.setForeground(boarderColor);
- gc.drawPolygon(points);
- }
- break;
- case ContextSwitchingChartSeriesItem.STYLE_SQUARE:
- default:
- gc.fillRectangle(pixelX, rect.y + (int) (rect.height * 0.1),
- pixelEndX - pixelX, (int) (rect.height * 0.8));
-
- if (boarderColor != null) {
- gc.setForeground(boarderColor);
- gc.drawRectangle(pixelX, rect.y + (int) (rect.height * 0.1),
- pixelEndX - pixelX, (int) (rect.height * 0.8));
- }
- break;
- }
-
- String name = seriesItem.getName();
- if (name != null) {
- int extentX = gc.stringExtent(name).x;
- if (extentX < pixelEndX - pixelX) {
- gc.setForeground(ColorResources.BLACK);
- gc.drawText(name, (pixelEndX + pixelX) / 2 - extentX / 2,
- rect.y + rect.height / 2 - gc.stringExtent(name).y / 2,
- true);
- }
- }
-
- return true;
- }
-
- protected void drawChartSeriesArrow(GC gc, DAChartSeries series,
- int seriesIndex) {
- int seriesSize = seriesList.size();
- rect = new Rectangle(r.x, r.y + r.height * seriesIndex / seriesSize,
- r.width, r.height / seriesSize);
-
- List<DAChartSeriesItem> seriesItems = series.getSeriesItemList();
- if (seriesItems == null) {
- return;
- }
- int seriesItemSize = seriesItems.size();
- if (seriesItemSize < 1) {
- return;
- }
-
- int index = series.getPrevIndexByXvalue(plot.getVisibleStartX());
- if (index < 0) {
- index = 0;
- }
-
- for (int i = index; i < seriesItemSize; i++) {
- ContextSwitchingChartSeriesItem seriesItem = (ContextSwitchingChartSeriesItem) seriesItems
- .get(i);
- double x = seriesItem.getX();
- if (x > plot.getVisibleEndX()) {
- return;
- }
-
- int pixelEndX = plot.getXPixelFromX(seriesItem.getEndX(), r);
-
- int arrow = seriesItem.getArrow();
- if (arrow != 0) {
- if (seriesItem.getBorderColor() != null) {
- gc.setForeground(seriesItem.getBorderColor());
- }
- int arrowHeadY = rect.y + rect.height / 2 + rect.height * arrow;
- gc.drawLine(pixelEndX, rect.y + rect.height / 2, pixelEndX,
- arrowHeadY);
- int y = -5;
- if (arrow < 0) {
- y = 5;
- }
- gc.drawLine(pixelEndX, arrowHeadY, pixelEndX - 3, arrowHeadY
- + y);
- gc.drawLine(pixelEndX, arrowHeadY, pixelEndX + 3, arrowHeadY
- + y);
- }
- }
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jaewon Lim <jaewon81.lim@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.kernel;
-
-import org.eclipse.swt.graphics.Color;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartSeriesItem;
-
-public class ContextSwitchingChartSeriesItem extends DAChartSeriesItem {
- public static final int STYLE_SQUARE = 0;
- public static final int STYLE_OCTAGON = 1;
- public static final int STYLE_OCTAGON_LEFT_ONLY = 2;
- public static final int STYLE_OCTAGON_RIGHT_ONLY = 3;
-
- private String name = null;
- private int style = STYLE_SQUARE;
- private double endX = -1;
- private int arrow = 0;
- private Color borderColor = null;
-
- public ContextSwitchingChartSeriesItem(String name, double x) {
- super(x, 0);
- this.name = name;
- setTooltipText(name);
- }
-
- public ContextSwitchingChartSeriesItem(String name, double x,
- Color borderColor) {
- this(name, x);
- this.borderColor = borderColor;
- setTooltipText(name);
- }
-
- public ContextSwitchingChartSeriesItem(String name, double x, int arrow,
- Color borderColor) {
- this(name, x, borderColor);
- this.arrow = arrow;
- setTooltipText(name);
- }
-
- public ContextSwitchingChartSeriesItem(String name, double x, Color color,
- Color borderColor) {
- this(name, x, borderColor);
- this.color = color;
- setTooltipText(name);
- }
-
- public ContextSwitchingChartSeriesItem(String name, double x, int style) {
- this(name, x);
- this.style = style;
- setTooltipText(name);
- }
-
- public ContextSwitchingChartSeriesItem(String name, double x, double endX) {
- super(x, 0);
- this.endX = endX;
- this.name = name;
- setTooltipText(name);
- }
-
- public ContextSwitchingChartSeriesItem(String name, double x, double endX,
- Color borderColor) {
- this(name, x, endX);
- this.borderColor = borderColor;
- setTooltipText(name);
- }
-
- public ContextSwitchingChartSeriesItem(String name, double x, double endX,
- int arrow, Color borderColor) {
- this(name, x, endX, borderColor);
- this.arrow = arrow;
- setTooltipText(name);
- }
-
- public ContextSwitchingChartSeriesItem(String name, double x, double endX,
- Color color, Color borderColor) {
- this(name, x, endX, borderColor);
- this.color = color;
- setTooltipText(name);
- }
-
- public ContextSwitchingChartSeriesItem(String name, double x, double endX,
- int style) {
- this(name, x, endX);
- this.style = style;
- setTooltipText(name);
- }
-
- public String getName() {
- return name;
- }
-
- public int getStyle() {
- return style;
- }
-
- public double getEndX() {
- return endX;
- }
-
- public void setEndX(double endX) {
- this.endX = endX;
- }
-
- public void setStyle(int style) {
- this.style = style;
- }
-
- public void setArrow(int arr) {
- this.arrow = arr;
- }
-
- public int getArrow() {
- return arrow;
- }
-
- public Color getBorderColor() {
- return borderColor;
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jaewon Lim <jaewon81.lim@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.kernel;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.ScrollBar;
-import org.tizen.dynamicanalyzer.common.AnalyzerManager;
-import org.tizen.dynamicanalyzer.common.DASelectionData;
-import org.tizen.dynamicanalyzer.nl.KernelPageLabels;
-import org.tizen.dynamicanalyzer.resources.ColorResources;
-import org.tizen.dynamicanalyzer.resources.FontResources;
-import org.tizen.dynamicanalyzer.ui.common.UICommonConstants;
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
-import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
-import org.tizen.dynamicanalyzer.ui.timeline.logparser.LifecycleLogParser;
-import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
-import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
-import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonRenderer;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotIntervalMarker;
-import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoard;
-import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoardItem;
-import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoardSelectionListener;
-import org.tizen.dynamicanalyzer.widgets.combo.DACustomCombo;
-import org.tizen.dynamicanalyzer.widgets.da.view.DAViewComposite;
-import org.tizen.dynamicanalyzer.widgets.da.view.DAViewData;
-import org.tizen.dynamicanalyzer.widgets.timeline.DATimeline;
-
-public class ContextSwitchingChartView extends DAViewComposite {
- public final static int KERNEL_CHART_HEIGHT = 40;
- public final static int KERNEL_COMBO_ITEM_HEIGHT = 24;
-
- private final Composite contents;
- private ContextSwitchingChart contextChart;
- private DACustomCombo contextCombo;
- private final StackLayout stackLayout;
-
- public static final int[] kernelScaleValue = new int[] { 100, 200, 400,
- 800, 1600 };
-
- public ContextSwitchingChartView(Composite parent, int style) {
- super(parent, style, false);
- this.setLayout(new FillLayout());
-
- setTitle(KernelPageLabels.CONTEXT_SWITCH_CHART_TITLE);
-
- contents = getContentArea();
- contents.setBackground(ColorResources.WINDOW_BG_COLOR);
-
- stackLayout = new StackLayout();
- contents.setLayout(stackLayout);
-
- contextChart = new ContextSwitchingChart(contents,
- KernelPageLabels.CONTEXT_SWITCH_CHART_TITLE, kernelScaleValue);
- contextChart.setNameFont(FontResources.CHART_NAME_FONT);
-
- contextChart.addSelectionListener(new DAChartBoardSelectionListener() {
- @Override
- public void handleSelectionEvent(DAChartBoardItem item) {
- handleSelection(item);
- }
- });
-
- ScrollBar hScrollBar = contextChart.getHScrollBar();
- hScrollBar.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (contextChart.isMaximumScrolled()) {
- AnalyzerUtil.setLatestTraceMode(KernelPage.pageID, true);
- } else {
- AnalyzerUtil.setLatestTraceMode(KernelPage.pageID, false);
- }
- }
- });
-
- initIntervalMarkers(contextChart);
-
- stackLayout.topControl = contextChart;
-
- contextCombo = new DACustomCombo(contextChart.getTitleComp(), SWT.NONE);
-
- contextCombo.setComboGradation(
- ColorResources.FRAME_RATE_COMBO_NORMAL_START,
- ColorResources.FRAME_RATE_COMBO_NORMAL_END,
- ColorResources.FRAME_RATE_COMBO_PUSH_START,
- ColorResources.FRAME_RATE_COMBO_PUSH_END,
- ColorResources.FRAME_RATE_COMBO_HOVER_START,
- ColorResources.FRAME_RATE_COMBO_HOVER_END,
- ColorResources.FRAME_RATE_COMBO_DISABLE_START,
- ColorResources.FRAME_RATE_COMBO_DISABLE_END);
- contextCombo.setOutlineColors(ColorResources.FRAME_RATE_COMBO_OUTLINE_NORMAL,
- ColorResources.FRAME_RATE_COMBO_OUTLINE_PUSH,
- ColorResources.FRAME_RATE_COMBO_OUTLINE_HOVER,
- ColorResources.FRAME_RATE_COMBO_OUTLINE_DISABLE);
-
- contextCombo.add(KernelPageLabels.CONTEXT_SWITCH_CHART_TITLE);
- contextCombo.select(0);
- contextCombo.setEnabled(false);
- contextCombo.setTextAlign(DACustomCombo.TEXT_ALIGN_LEFT);
- contextCombo.setComboFont(FontResources.FRAME_RATE_COMBO);
- contextCombo.setFontColors(ColorResources.ADD_CHART_FONT_COLOR,
- ColorResources.ADD_CHART_FONT_COLOR,
- ColorResources.ADD_CHART_FONT_COLOR,
- ColorResources.ADD_CHART_FONT_COLOR);
- contextCombo.setItemFont(FontResources.FRAME_RATE_DROPDOWN);
- contextCombo.setItemFontColor(ColorResources.ADD_CHART_FONT_COLOR);
- contextCombo.setButtonRenderer(new DACustomButtonRenderer());
-
- DATimeline threadTimeline = contextChart.getTimeline();
-
- threadTimeline.setTimeTickFont(FontResources.TIMELINE_TICK_FONT);
- threadTimeline.setTimeBalloonFont(FontResources.TIMELINE_BALLOON_FONT);
-
- LifecycleLogParser.getInstance().registerLifecycleBar(
- contextChart.getLifecycleBar());
- LifecycleLogParser.getInstance().registerTimeline(threadTimeline);
- }
-
- private void handleSelection(DAChartBoardItem selectItem) {
- if (null == selectItem) {
- AnalyzerManager
- .getCurrentPage()
- .updateView(
- new DASelectionData(
- KernelPage.contextViewID,
- (long) (((DAChartPlotIntervalMarker) contextChart
- .getMarkers()
- .get(UICommonConstants.SELECTION_MARKER_INDEX))
- .getStartVal() * TimelineConstants.MEGA_DOUBLE),
- (long) (((DAChartPlotIntervalMarker) contextChart
- .getMarkers()
- .get(UICommonConstants.SELECTION_MARKER_INDEX))
- .getEndVal() * TimelineConstants.MEGA_DOUBLE),
- new Integer(0), null));
- } else {
- AnalyzerManager
- .getCurrentPage()
- .updateView(
- new DASelectionData(
- KernelPage.contextViewID,
- (long) (((DAChartPlotIntervalMarker) contextChart
- .getMarkers()
- .get(UICommonConstants.SELECTION_MARKER_INDEX))
- .getStartVal() * TimelineConstants.MEGA_DOUBLE),
- (long) (((DAChartPlotIntervalMarker) contextChart
- .getMarkers()
- .get(UICommonConstants.SELECTION_MARKER_INDEX))
- .getEndVal() * TimelineConstants.MEGA_DOUBLE),
- selectItem.getData(), null));
- }
- }
-
- @Override
- public void updateView() {
- contextChart.updateChart();
-
- /*
- * In case of Latest status, update visibleStartTime of chartBoard.
- * Because Chart should be refreshed automatically even Page change.
- */
- if (AnalyzerUtil.isLatestTraceMode(KernelPage.pageID)) {
- contextChart.updateVisibleStartTime();
- contextChart.setTotalEndTime(Toolbar.INSTANCE.getTime(), true);
- } else {
- // set chart end time
- contextChart.setTotalEndTime(Toolbar.INSTANCE.getTime(), false);
- }
-
- RangeDataManager rangeDataManager = RangeDataManager.getInstance();
- if (rangeDataManager.isBeingAnalyzed()) {
- ((DAChartPlotIntervalMarker) contextChart.getMarkers().get(
- UICommonConstants.RANGE_ANALYSIS_MARKER_INDEX))
- .setInterval(rangeDataManager.getAnalysisStartTime()
- / TimelineConstants.MEGA_DOUBLE,
- rangeDataManager.getAnalysisEndTime()
- / TimelineConstants.MEGA_DOUBLE);
- } else {
- ((DAChartPlotIntervalMarker) contextChart.getMarkers().get(
- UICommonConstants.RANGE_ANALYSIS_MARKER_INDEX))
- .setInterval(-1, -1);
- }
-
- ((DAChartPlotIntervalMarker) contextChart.getMarkers().get(
- UICommonConstants.RANGE_MARKER_INDEX)).setInterval(
- rangeDataManager.getMarkerStartTime()
- / TimelineConstants.MEGA_DOUBLE,
- rangeDataManager.getMarkerEndTime()
- / TimelineConstants.MEGA_DOUBLE);
- }
-
- @Override
- public void updateView(DAViewData data) {
- if (data instanceof DASelectionData) {
- DASelectionData selData = (DASelectionData) data;
-
- long start = selData.getStartTime();
- long end = selData.getEndTime();
-
- double startTime = (double) start / TimelineConstants.MEGA_DOUBLE;
- double endTime = (double) end / TimelineConstants.MEGA_DOUBLE;
-
- DAChartBoard chartBoard = (DAChartBoard) stackLayout.topControl;
-
- DAChartPlotIntervalMarker intervalMarker = (DAChartPlotIntervalMarker) chartBoard
- .getMarkers().get(UICommonConstants.SELECTION_MARKER_INDEX);
- intervalMarker.setInterval(startTime, endTime);
- }
- }
-
- @Override
- public void clear() {
- contextChart.clear();
- initIntervalMarkers(contextChart);
- }
-
- @Override
- public Control getControl() {
- return contextChart;
- }
-
- private void initIntervalMarkers(DAChartBoard board) {
- // selection marker
- DAChartPlotIntervalMarker selectionMarker = new DAChartPlotIntervalMarker(
- -1, -1, DAChartPlotIntervalMarker.INTERVAL_MARKER_STYLE_AREA);
- selectionMarker.setBackgroundColor(ColorResources.SELECTION_RANGE);
- selectionMarker.setAlpha((int) (255 * 0.25));
- board.addIntervalMarker(selectionMarker);
-
- // range analysis marker
- DAChartPlotIntervalMarker rangeAnalyzeMarker = new DAChartPlotIntervalMarker(
- -1, -1, DAChartPlotIntervalMarker.INTERVAL_MARKER_STYLE_AREA);
- rangeAnalyzeMarker.setBackgroundColor(ColorResources.YELLOW);
- rangeAnalyzeMarker.setAlpha((int) (255 * 0.25));
- board.addIntervalMarker(rangeAnalyzeMarker);
-
- // range marker
- DAChartPlotIntervalMarker rangeMarker = new DAChartPlotIntervalMarker(
- -1, -1, DAChartPlotIntervalMarker.INTERVAL_MARKER_STYLE_LINE);
- rangeMarker.setForegroundColor(ColorResources.RED);
- rangeMarker.setAlpha((int) (255 * 0.25));
- board.addIntervalMarker(rangeMarker);
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jaewon Lim <jaewon81.lim@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.kernel;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.nebula.widgets.grid.Grid;
-import org.eclipse.nebula.widgets.grid.GridItem;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Composite;
-import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
-import org.tizen.dynamicanalyzer.common.AnalyzerManager;
-import org.tizen.dynamicanalyzer.common.DASelectionData;
-import org.tizen.dynamicanalyzer.common.Global;
-import org.tizen.dynamicanalyzer.database.DBConstants;
-import org.tizen.dynamicanalyzer.model.FilterProperty;
-import org.tizen.dynamicanalyzer.model.TableInput;
-import org.tizen.dynamicanalyzer.ui.kernel.data.ContextDataDBTable;
-import org.tizen.dynamicanalyzer.ui.kernel.data.FunctionDataDBTable;
-import org.tizen.dynamicanalyzer.ui.kernel.data.KernelDataManager;
-import org.tizen.dynamicanalyzer.ui.kernel.data.KernelDataPerThread;
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
-import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
-import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat;
-import org.tizen.dynamicanalyzer.ui.widgets.table.DAWindowingTableComposite;
-import org.tizen.dynamicanalyzer.widgets.helper.Formatter;
-
-public class KernelListTable extends DAWindowingTableComposite {
- private KernelDataPerThread selectedData = null;
- private boolean isCoreSelected = true;
-
- public KernelListTable(Composite parent, int compStyle, int tableStyle) {
- super(parent, compStyle, tableStyle);
- setDataType(0); // timeColumnIdex
- setContextMenu(AnalyzerConstants.CONTEXT_TABLE_RANGE);
-
- table.addSelectionListener(new SelectionListener() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- GridItem[] ti = ((Grid) e.widget).getSelection();
- if (null == ti || ti.length == 0) {
- return;
- }
- int size = ti.length;
- List<Object> startData = ((DATableDataFormat) ti[0].getData()).getData();
- List<Object> endData = ((DATableDataFormat) ti[size - 1].getData()).getData();
- long startTime = (Long) startData.get(timeColumnIndex);
- long endTime = (Long) endData.get(timeColumnIndex);
-
- DASelectionData data = new DASelectionData(KernelPage.listViewID, startTime,
- endTime, ti, table);
- AnalyzerManager.getCurrentPage().updateView(data);
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
- }
-
- @Override
- protected List<TableInput> makeTableInput() {
- List<TableInput> input = new ArrayList<TableInput>();
- List<List<Object>> queriedData = getQueriedObjectData();
- if (queriedData == null) {
- return null;
- }
-
- int size = queriedData.size();
- for (int i = 0; i < size; i++) {
- List<Object> row = queriedData.get(i);
- List<String> text = new ArrayList<String>();
- long seqnum;
- long starttime, endtime, exectime;
- if (isCoreSelected) {
- seqnum = (Long) row.get(ContextDataDBTable.COLUMN.SEQ.index);
- starttime = (Long) row.get(ContextDataDBTable.COLUMN.STARTTIME.index);
- endtime = (Long) row.get(ContextDataDBTable.COLUMN.ENDTIME.index);
- exectime = endtime - starttime;
- text.add(row.get(ContextDataDBTable.COLUMN.SEQ.index).toString());
- text.add(row.get(ContextDataDBTable.COLUMN.PID.index).toString());
- text.add(row.get(ContextDataDBTable.COLUMN.TID.index).toString());
- text.add(row.get(ContextDataDBTable.COLUMN.CPUNUM.index).toString());
- text.add(Formatter.toTimeFormat(starttime));
- text.add(Formatter.toTimeFormat(endtime));
- text.add(Formatter.toTimeFormat(exectime));
- text.add(row.get(ContextDataDBTable.COLUMN.STARTADDR.index).toString());
- text.add(row.get(ContextDataDBTable.COLUMN.ENDADDR.index).toString());
- text.add("");
- } else {
- seqnum = (Long) row.get(FunctionDataDBTable.COLUMN.SEQ.index);
- starttime = (Long) row.get(FunctionDataDBTable.COLUMN.STARTTIME.index);
- endtime = (Long) row.get(FunctionDataDBTable.COLUMN.ENDTIME.index);
- exectime = endtime - starttime;
- text.add(row.get(FunctionDataDBTable.COLUMN.SEQ.index).toString());
- text.add(row.get(FunctionDataDBTable.COLUMN.PID.index).toString());
- text.add(row.get(FunctionDataDBTable.COLUMN.TID.index).toString());
- text.add(row.get(FunctionDataDBTable.COLUMN.CPUNUM.index).toString());
- text.add(Formatter.toTimeFormat(starttime));
- text.add(Formatter.toTimeFormat(endtime));
- text.add(Formatter.toTimeFormat(exectime));
- text.add(row.get(FunctionDataDBTable.COLUMN.STARTADDR.index).toString());
- text.add(row.get(FunctionDataDBTable.COLUMN.ENDADDR.index).toString());
- int funcId = (Integer) row.get(FunctionDataDBTable.COLUMN.FUNCID.index);
- text.add(Global.getFunctionName(funcId));
- }
-
- // create DATableDataFormat
- DATableDataFormat tableData = new DATableDataFormat(seqnum);
- tableData.getData().add(new Long(starttime));
- if (isCoreSelected) {
- tableData.setType(AnalyzerConstants.TYPE_TABLE_CONTEXTSWITCH);
- } else {
- tableData.setType(AnalyzerConstants.TYPE_TABLE_FUNCTIONFRAGMENT);
- }
-
- TableInput tableInput = new TableInput();
- tableInput.setText(text);
- tableInput.setData(tableData);
- input.add(tableInput);
-
- if (RangeDataManager.getInstance().isBeingAnalyzed()) {
- long analysisStartTime = RangeDataManager.getInstance().getAnalysisStartTime();
- long analysisEndTime = RangeDataManager.getInstance().getAnalysisEndTime();
- if (starttime <= analysisEndTime && endtime >= analysisStartTime) {
- tableInput.setInRange(true);
- }
- }
- }
-
- return input;
- }
-
- @Override
- protected int getItemCountByPid() {
- if (selectedData == null) {
- return 0;
- }
-
- int itemCount = 0;
- int selectedPid = Toolbar.INSTANCE.getSelectedPid();
- if (selectedPid == 0 || selectedData.getPid() == selectedPid) {
- if (isCoreSelected) {
- itemCount = selectedData.getCoreFragmentCount();
- } else {
- itemCount = selectedData.getFuncFragmentCount();
- }
- }
-
- return itemCount;
- }
-
- @Override
- protected List<String> getDBTableColumnNames() {
- List<String> columnName = new ArrayList<String>();
- columnName.add("*");
- return columnName;
- }
-
- @Override
- protected String getDBTableName() {
- if (selectedData == null) {
- return null;
- }
-
- String tablename;
- if (isCoreSelected) {
- tablename = KernelDataManager.getInstance().getContextDataTable().getTableName();
- } else {
- tablename = KernelDataManager.getInstance().getFunctionDataTable().getTableName();
- }
-
- return tablename;
- }
-
- @Override
- protected String getSelectQueryOption() {
- String never_option = DBConstants.DBCOLUMN_TID + " = -1";
-
- if (selectedData == null) {
- return never_option;
- }
-
- int selectedPid = Toolbar.INSTANCE.getSelectedPid();
- if (selectedPid == 0 || selectedData.getPid() == selectedPid) {
- String option = DBConstants.DBCOLUMN_TID + " = " + selectedData.getTid() + " order by ";
-
- if (isCoreSelected)
- option += ContextDataDBTable.COLUMN.STARTTIME.name;
- else
- option += FunctionDataDBTable.COLUMN.STARTTIME.name;
-
- return option;
- } else {
- return never_option;
- }
- }
-
- @Override
- protected String getSelectQueryCountOption() {
- String never_option = DBConstants.DBCOLUMN_TID + " = -1";
-
- if (selectedData == null) {
- return never_option;
- }
-
- int selectedPid = Toolbar.INSTANCE.getSelectedPid();
- if (selectedPid == 0 || selectedData.getPid() == selectedPid) {
- String option = DBConstants.DBCOLUMN_TID + " = " + selectedData.getTid();
-
- return option;
- } else {
- return never_option;
- }
- }
-
- public void setSelectedData(KernelDataPerThread kdata, boolean isCore) {
- this.selectedData = kdata;
- this.isCoreSelected = isCore;
- }
-
- @Override
- protected String getTimeColumnName() {
- String timestr;
- if (isCoreSelected)
- timestr = ContextDataDBTable.COLUMN.STARTTIME.name;
- else
- timestr = FunctionDataDBTable.COLUMN.STARTTIME.name;
-
- return timestr;
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jaewon Lim <jaewon81.lim@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.kernel;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
-import org.tizen.dynamicanalyzer.common.DASelectionData;
-import org.tizen.dynamicanalyzer.nl.KernelPageLabels;
-import org.tizen.dynamicanalyzer.resources.ColorResources;
-import org.tizen.dynamicanalyzer.ui.kernel.data.KernelSelectionData;
-import org.tizen.dynamicanalyzer.ui.widgets.table.WindowingTableColumnSizePackListener;
-import org.tizen.dynamicanalyzer.widgets.da.view.DAViewComposite;
-import org.tizen.dynamicanalyzer.widgets.da.view.DAViewData;
-
-public class KernelListView extends DAViewComposite {
- private String[] columnNames = { KernelPageLabels.KERNEL_LIST_VIEW_INDEX,
- KernelPageLabels.KERNEL_LIST_VIEW_PID,
- KernelPageLabels.KERNEL_LIST_VIEW_TID,
- KernelPageLabels.KERNEL_LIST_VIEW_CORE,
- KernelPageLabels.KERNEL_LIST_VIEW_START_TIME,
- KernelPageLabels.KERNEL_LIST_VIEW_END_TIME,
- KernelPageLabels.KERNEL_LIST_VIEW_EXECUTION_TIME,
- KernelPageLabels.KERNEL_LIST_VIEW_START_PC,
- KernelPageLabels.KERNEL_LIST_VIEW_END_PC,
- KernelPageLabels.KERNEL_LIST_VIEW_FUNCTION };
-
- private int[] columnSizes = { 40, 40, 40, 65, 80, 80, 100, 100, 100, 250 };
-
- private int[] columnAlignment = { SWT.RIGHT, SWT.LEFT, SWT.LEFT, SWT.LEFT,
- SWT.LEFT, SWT.LEFT, SWT.LEFT, SWT.LEFT, SWT.LEFT, SWT.LEFT };
-
- int[] sortTypes = { AnalyzerConstants.SORT_TYPE_NUM,
- AnalyzerConstants.SORT_TYPE_NUM, AnalyzerConstants.SORT_TYPE_NUM,
- AnalyzerConstants.SORT_TYPE_NUM, AnalyzerConstants.SORT_TYPE_NUM,
- AnalyzerConstants.SORT_TYPE_NUM, AnalyzerConstants.SORT_TYPE_NUM,
- AnalyzerConstants.SORT_TYPE_NUM, AnalyzerConstants.SORT_TYPE_NUM,
- AnalyzerConstants.SORT_TYPE_STRING };
-
- private boolean[] columnVisibility_core = { true, true, true, true, true,
- true, true, true, true, false };
- private boolean[] columnVisibility_function = { true, true, true, true,
- true, true, true, true, true, true };
-
- KernelListTable tableComp = null;
-
- public KernelListView(Composite parent, int style) {
- super(parent, style, false);
- this.setLayout(new FillLayout());
-
- setTitle(KernelPageLabels.KERNEL_LIST_VIEW_NAME);
-
- Composite contents = getContentArea();
- contents.setBackground(ColorResources.WINDOW_BG_COLOR);
- contents.setLayout(new FillLayout());
- tableComp = new KernelListTable(contents, SWT.NONE, SWT.MULTI
- | SWT.BORDER | SWT.FULL_SELECTION);
- tableComp.setSortTypes(sortTypes);
- tableComp.setColumnAlignment(columnAlignment);
- tableComp.setColumns(columnNames);
- tableComp.setColumnSize(columnSizes);
- tableComp.setColumnVisibility(columnVisibility_function);
- tableComp.setTableToolTipEnable(false);
- contents.addControlListener(new WindowingTableColumnSizePackListener(
- tableComp, columnSizes));
- }
-
- @Override
- public void updateView(DAViewData data) {
- if (data instanceof DASelectionData) {
- DASelectionData selData = (DASelectionData) data;
-
- long start = selData.getStartTime();
- long end = selData.getEndTime();
- Object odata = selData.getData();
-
- if (odata instanceof KernelSelectionData) {
- KernelSelectionData sdata = (KernelSelectionData) odata;
- boolean isCore = (sdata.getType() == KernelSelectionData.KERNEL_DATA_TYPE_CONTEXTSWITCH);
- tableComp.setSelectedData(sdata.getData(), isCore);
- if (isCore) {
- tableComp.setColumnVisibility(columnVisibility_core);
- } else {
- tableComp.setColumnVisibility(columnVisibility_function);
- }
- tableComp.updateTable();
- }
-
- ((KernelListTable) tableComp).setSelectionByTime(start, end);
- tableComp.updateTable();
- }
- }
-
- @Override
- public void updateView() {
- tableComp.updateTable();
- }
-
- @Override
- public void clear() {
- tableComp.getTable().removeAll();
- tableComp.clear();
- }
-
- @Override
- public Control getControl() {
- return tableComp;
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jaewon Lim <jaewon81.lim@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.kernel;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
-import org.tizen.dynamicanalyzer.resources.ColorResources;
-import org.tizen.dynamicanalyzer.shortcut.ShortCutManager;
-import org.tizen.dynamicanalyzer.ui.kernel.data.KernelDataManager;
-import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineTableView;
-import org.tizen.dynamicanalyzer.widgets.da.view.DAContainerComposite;
-import org.tizen.dynamicanalyzer.widgets.da.view.DATabComposite;
-
-public class KernelPage extends DAContainerComposite {
- public static final String pageID = KernelPage.class.getName();
- public static final String contextViewID = ContextSwitchingChartView.class.getName();
- public static final String callflowTabID = "CallFlowTab.id";
- public static final String callflowViewID = CallFlowChartView.class.getName();
- public static final String listViewID = KernelListView.class.getName();
- public static final String statViewID = KernelStatisticInfoView.class.getName();
-
- SashForm baseForm;
- SashForm leftForm;
- SashForm rightForm;
-
- public KernelPage(Composite parent, int style) {
- super(parent, style);
-
- setTitle(AnalyzerLabels.COOLBAR_AREA_KERNEL);
- this.setData(DAContainerComposite.KEY_TOOLTIP, ShortCutManager.COOLBAR_AREA_KERNEL_TOOLTIP);
- this.setBackground(ColorResources.CONFIGURATION_TABLE_COVER_BACKGROUND_COLOR);
- this.setLayout(new FillLayout());
-
- baseForm = new SashForm(this, SWT.HORIZONTAL);
- baseForm.setLayout(new FillLayout());
- baseForm.setForeground(ColorResources.TAB_SELECTED_COLOR_START);
- ((FillLayout) getLayout()).marginHeight = 15;
- ((FillLayout) getLayout()).marginWidth = 5;
-
- leftForm = new SashForm(baseForm, SWT.VERTICAL);
- ContextSwitchingChartView kernelChartView = new ContextSwitchingChartView(leftForm,
- SWT.NONE);
- addView(kernelChartView);
- DATabComposite lefttabView = new DATabComposite(leftForm, SWT.NONE, false);
- addView(callflowTabID, lefttabView);
- {
- CallFlowChartView callflowView = new CallFlowChartView(
- lefttabView.getContentComposite(), SWT.NONE);
- lefttabView.addView(callflowView, false);
-
- KernelListView kernelListView = new KernelListView(lefttabView.getContentComposite(),
- SWT.NONE);
- lefttabView.addView(kernelListView, false);
- }
-
- leftForm.setWeights(new int[] { 60, 40 });
-
- rightForm = new SashForm(baseForm, SWT.VERTICAL);
-
- KernelStatisticInfoView statInfo = new KernelStatisticInfoView(rightForm, SWT.NONE);
- addView(statInfo);
-
- TimelineTableView tabView = new TimelineTableView(rightForm, SWT.NONE);
-// tabView.setObservingViews(TimelineTableView.screenshotViewID,
-// new String[] { KernelPage.listViewID });
-// tabView.setObservingViews(TimelineTableView.callstackViewID,
-// new String[] { KernelPage.listViewID });
- addView(tabView);
-
- rightForm.setWeights(new int[] { 50, 50 });
- baseForm.setWeights(new int[] { 75, 25 });
- }
-
- @Override
- protected void onResized(int width, int height) {
- int wrate = (int) (TimelineTableView.DEFAULT_WIDTH * 100 / width);
- int hrate = (int) (TimelineTableView.DEFAULT_TABLE_VIEW_HEIGHT * 100 / height);
- wrate = (wrate > 100) ? 100 : wrate;
- hrate = (hrate > 100) ? 100 : hrate;
-
- if ((wrate > (100 - 37)) || hrate > 100) {
- return;
- }
-
- baseForm.setWeights(new int[] { 100 - wrate, wrate });
- rightForm.setWeights(new int[] { 100 - hrate, hrate });
- }
-
- @Override
- public void clear() {
- super.clear();
- KernelDataManager.getInstance().clear();
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jaewon Lim <jaewon81.lim@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.kernel;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.ScrollBar;
-import org.eclipse.swt.widgets.Text;
-import org.tizen.dynamicanalyzer.constant.CommonConstants;
-import org.tizen.dynamicanalyzer.nl.KernelPageLabels;
-import org.tizen.dynamicanalyzer.resources.ColorResources;
-import org.tizen.dynamicanalyzer.resources.FontResources;
-import org.tizen.dynamicanalyzer.widgets.da.view.DAViewComposite;
-
-public class KernelStatisticInfoView extends DAViewComposite {
- private Text detailText = null;
- private Label labelMessage = null;
- @SuppressWarnings("unused")
- private int indexScrolledTop = 0;
-
- public KernelStatisticInfoView(Composite parent, int style) {
- super(parent, style, true);
- this.setLayout(new FillLayout());
-
- setTitle(KernelPageLabels.KERNEL_STATISTIC_TITLE);
-
- Composite detailCom = getContentArea();
- detailCom.setBackground(ColorResources.VIEW_BG_COLOR);
- detailCom.setLayout(new FormLayout());
- FormData labelData = new FormData();
- labelData.top = new FormAttachment(0, 0);
- labelData.left = new FormAttachment(0, 0);
- labelData.right = new FormAttachment(100, 0);
- labelData.bottom = new FormAttachment(100, 0);
- detailCom.setLayoutData(labelData);
-
- Composite contents = detailCom;
- contents.setBackground(ColorResources.VIEW_BG_COLOR);
- contents.setLayout(new FormLayout());
-
- detailText = new Text(contents, SWT.BORDER | SWT.V_SCROLL
- | SWT.H_SCROLL);
- detailText.setBackground(ColorResources.VIEW_BG_COLOR);
- detailText.setForeground(ColorResources.TABLE_CONTENTS_FONT_COLOR);
- detailText.setFont(FontResources.DETAIL_INFO_FONT);
-
- FormData buttonData = new FormData();
- buttonData.top = new FormAttachment(labelMessage, 0);
- buttonData.left = new FormAttachment(0, 0);
- buttonData.right = new FormAttachment(100, 0);
- buttonData.bottom = new FormAttachment(100, 0);
- detailText.setLayoutData(buttonData);
-
- Listener listener = new Listener() {
- public void handleEvent(Event e) {
- indexScrolledTop = detailText.getTopIndex();
- }
- };
- ScrollBar hBar = detailText.getHorizontalBar();
- if (hBar != null) {
- hBar.addListener(SWT.Selection, listener);
- }
- ScrollBar vBar = detailText.getVerticalBar();
- if (vBar != null) {
- vBar.addListener(SWT.Selection, listener);
- }
-
- StringBuffer strDetailView = new StringBuffer();
- strDetailView.append(CommonConstants.NEW_LINE);
-// strDetailView.append(leftFormAttachment
-// + NetworkPageLabels.NETWORK_DETAILS_ADDRESS
-// + heightFormAttachment);
-// strDetailView.append(leftFormAttachment
-// + NetworkPageLabels.NETWORK_DETAILS_RECV_SIZE
-// + heightFormAttachment);
-// strDetailView.append(leftFormAttachment
-// + NetworkPageLabels.NETWORK_DETAILS_SEND_SIZE
-// + heightFormAttachment);
-// strDetailView.append(leftFormAttachment
-// + NetworkPageLabels.NETWORK_DETAILS_TOTAL_USE_TIME
-// + heightFormAttachment);
-// strDetailView.append(leftFormAttachment
-// + NetworkPageLabels.NETWORK_DETAILS_API_COUNT
-// + heightFormAttachment);
-// strDetailView.append(leftFormAttachment
-// + NetworkPageLabels.NETWORK_DETAILS_FAILED_API_COUNT
-// + heightFormAttachment);
-// strDetailView.append(leftFormAttachment
-// + NetworkPageLabels.NETWORK_DETAILS_PACKET_MESSAGE
-// + heightFormAttachment);
-// strDetailView.append(NetworkChartManager.getInstance()
-// .getPacketMessage());
- detailText.setText(strDetailView.toString());
- }
-
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jaewon Lim <jaewon81.lim@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.kernel.data;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.tizen.dynamicanalyzer.database.DBColumn;
-import org.tizen.dynamicanalyzer.database.DBConstants;
-import org.tizen.dynamicanalyzer.database.DBTable;
-import org.tizen.dynamicanalyzer.database.IResultSet;
-import org.tizen.dynamicanalyzer.util.Logger;
-
-public class ContextDataDBTable extends DBTable implements IResultSet {
- public static final String TABLENAME = "CONTEXT_SWITCH_DATA";
-
- public enum COLUMN {
- SEQ(0, DBConstants.DBCOLUMN_SEQUENCE_NUMBER),
- PID(1, DBConstants.DBCOLUMN_PID),
- TID(2, DBConstants.DBCOLUMN_TID),
- CPUNUM(3, "CPU_NUM"),
- STARTTIME(4, "START_TIME"),
- STARTADDR(5, "START_PCADDR"),
- ENDTIME(6, "END_TIME"),
- ENDADDR(7, "END_PCADDR");
-
- public final int index;
- public final String name;
-
- COLUMN(int index, String name) {
- this.index = index;
- this.name = name;
- }
- }
-
- @Override
- public String getTableName() {
- return TABLENAME;
- }
-
- public ContextDataDBTable() {
- addColumn(new DBColumn(COLUMN.SEQ.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT8));
- addColumn(new DBColumn(COLUMN.PID.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
- addColumn(new DBColumn(COLUMN.TID.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
- addColumn(new DBColumn(COLUMN.CPUNUM.name, DBConstants.EMPTY, DBConstants.DBTYPE_INT4));
- addColumn(new DBColumn(COLUMN.STARTTIME.name, DBConstants.EMPTY, DBConstants.DBTYPE_INT8));
- addColumn(new DBColumn(COLUMN.STARTADDR.name, DBConstants.EMPTY, DBConstants.DBTYPE_INT8));
- addColumn(new DBColumn(COLUMN.ENDTIME.name, DBConstants.EMPTY, DBConstants.DBTYPE_INT8));
- addColumn(new DBColumn(COLUMN.ENDADDR.name, DBConstants.EMPTY, DBConstants.DBTYPE_INT8));
- }
-
- @Override
- public boolean prepare(PreparedStatement prep, List<Object> rowData) {
- boolean isPrepared = true;
-
- int columnsize = getColumnSize();
- if (columnsize != rowData.size()) {
- isPrepared = false;
- } else {
- try {
- prep.setLong(COLUMN.SEQ.index + 1, (Long) (rowData.get(COLUMN.SEQ.index)));
- prep.setInt(COLUMN.PID.index + 1, (Integer) (rowData.get(COLUMN.PID.index)));
- prep.setInt(COLUMN.TID.index + 1, (Integer) (rowData.get(COLUMN.TID.index)));
- prep.setInt(COLUMN.CPUNUM.index + 1, (Integer) (rowData.get(COLUMN.CPUNUM.index)));
- prep.setLong(COLUMN.STARTTIME.index + 1,
- (Long) (rowData.get(COLUMN.STARTTIME.index)));
- prep.setLong(COLUMN.STARTADDR.index + 1,
- (Long) (rowData.get(COLUMN.STARTADDR.index)));
- prep.setLong(COLUMN.ENDTIME.index + 1, (Long) (rowData.get(COLUMN.ENDTIME.index)));
- prep.setLong(COLUMN.ENDADDR.index + 1, (Long) (rowData.get(COLUMN.ENDADDR.index)));
- } catch (SQLException e) {
- Logger.exception(e);
- isPrepared = false;
- }
- }
-
- return isPrepared;
- }
-
- @Override
- public List<Object> extractDataFromResultSet(ResultSet rs) {
- List<Object> row = new ArrayList<Object>();
- try {
- row.add(Long.valueOf(rs.getLong(1)));
- row.add(Integer.valueOf(rs.getInt(2)));
- row.add(Integer.valueOf(rs.getInt(3)));
- row.add(Integer.valueOf(rs.getInt(4)));
- row.add(Long.valueOf(rs.getLong(5)));
- row.add(Long.valueOf(rs.getLong(6)));
- row.add(Long.valueOf(rs.getLong(7)));
- row.add(Long.valueOf(rs.getLong(8)));
- } catch (SQLException e) {
- Logger.exception(e);
- return null;
- }
-
- return row;
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jaewon Lim <jaewon81.lim@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.kernel.data;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.tizen.dynamicanalyzer.database.DBColumn;
-import org.tizen.dynamicanalyzer.database.DBConstants;
-import org.tizen.dynamicanalyzer.database.DBTable;
-import org.tizen.dynamicanalyzer.util.Logger;
-
-public class FunctionDataDBTable extends DBTable {
- private static final String TABLENAME = "FUNCTION_CALL_DATA";
-
- public enum COLUMN {
- SEQ(0, DBConstants.DBCOLUMN_SEQUENCE_NUMBER),
- PID(1, DBConstants.DBCOLUMN_PID),
- TID(2, DBConstants.DBCOLUMN_TID),
- CPUNUM(3, "CPU_NUM"),
- STARTTIME(4, "START_TIME"),
- STARTTYPE(5, "START_TYPE"),
- STARTADDR(6, "START_PCADDR"),
- ENDTIME(7, "END_TIME"),
- ENDTYPE(8, "END_TYPE"),
- ENDADDR(9, "END_PCADDR"),
- FUNCID(10, "FUNCTION_ID");
-
- public final int index;
- public final String name;
-
- COLUMN(int index, String name) {
- this.index = index;
- this.name = name;
- }
- }
-
- @Override
- public String getTableName() {
- return TABLENAME;
- }
-
- public FunctionDataDBTable() {
- addColumn(new DBColumn(COLUMN.SEQ.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT8));
- addColumn(new DBColumn(COLUMN.PID.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
- addColumn(new DBColumn(COLUMN.TID.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
- addColumn(new DBColumn(COLUMN.CPUNUM.name, DBConstants.EMPTY, DBConstants.DBTYPE_INT4));
- addColumn(new DBColumn(COLUMN.STARTTIME.name, DBConstants.EMPTY, DBConstants.DBTYPE_INT8));
- addColumn(new DBColumn(COLUMN.STARTTYPE.name, DBConstants.EMPTY, DBConstants.DBTYPE_INT4));
- addColumn(new DBColumn(COLUMN.STARTADDR.name, DBConstants.EMPTY, DBConstants.DBTYPE_INT8));
- addColumn(new DBColumn(COLUMN.ENDTIME.name, DBConstants.EMPTY, DBConstants.DBTYPE_INT8));
- addColumn(new DBColumn(COLUMN.ENDTYPE.name, DBConstants.EMPTY, DBConstants.DBTYPE_INT4));
- addColumn(new DBColumn(COLUMN.ENDADDR.name, DBConstants.EMPTY, DBConstants.DBTYPE_INT8));
- addColumn(new DBColumn(COLUMN.FUNCID.name, DBConstants.EMPTY, DBConstants.DBTYPE_INT4));
- }
-
- @Override
- public boolean prepare(PreparedStatement prep, List<Object> rowData) {
- boolean isPrepared = true;
-
- int columnsize = getColumnSize();
- if (columnsize != rowData.size()) {
- isPrepared = false;
- } else {
- try {
- prep.setLong(COLUMN.SEQ.index + 1, (Long) (rowData.get(COLUMN.SEQ.index)));
- prep.setInt(COLUMN.PID.index + 1, (Integer) (rowData.get(COLUMN.PID.index)));
- prep.setInt(COLUMN.TID.index + 1, (Integer) (rowData.get(COLUMN.TID.index)));
- prep.setInt(COLUMN.CPUNUM.index + 1, (Integer) (rowData.get(COLUMN.CPUNUM.index)));
-
- prep.setLong(COLUMN.STARTTIME.index + 1,
- (Long) (rowData.get(COLUMN.STARTTIME.index)));
- prep.setInt(COLUMN.STARTTYPE.index + 1,
- (Integer) (rowData.get(COLUMN.STARTTYPE.index)));
- prep.setLong(COLUMN.STARTADDR.index + 1,
- (Long) (rowData.get(COLUMN.STARTADDR.index)));
-
- prep.setLong(COLUMN.ENDTIME.index + 1, (Long) (rowData.get(COLUMN.ENDTIME.index)));
- prep.setInt(COLUMN.ENDTYPE.index + 1, (Integer) (rowData.get(COLUMN.ENDTYPE.index)));
- prep.setLong(COLUMN.ENDADDR.index + 1, (Long) (rowData.get(COLUMN.ENDADDR.index)));
- prep.setInt(COLUMN.FUNCID.index + 1, (Integer) (rowData.get(COLUMN.FUNCID.index)));
- } catch (SQLException e) {
- Logger.exception(e);
- isPrepared = false;
- }
- }
-
- return isPrepared;
- }
-
- @Override
- public List<Object> extractDataFromResultSet(ResultSet rs) {
- List<Object> row = new ArrayList<Object>();
- try {
- row.add(Long.valueOf(rs.getLong(1)));
- row.add(Integer.valueOf(rs.getInt(2)));
- row.add(Integer.valueOf(rs.getInt(3)));
- row.add(Integer.valueOf(rs.getInt(4)));
- row.add(Long.valueOf(rs.getLong(5)));
- row.add(Integer.valueOf(rs.getInt(6)));
- row.add(Long.valueOf(rs.getLong(7)));
- row.add(Long.valueOf(rs.getLong(8)));
- row.add(Integer.valueOf(rs.getInt(9)));
- row.add(Long.valueOf(rs.getLong(10)));
- row.add(Integer.valueOf(rs.getInt(11)));
- } catch (SQLException e) {
- Logger.exception(e);
- return null;
- }
-
- return row;
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jaewon Lim <jaewon81.lim@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.kernel.data;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Stack;
-
-import org.tizen.dynamicanalyzer.database.DBInserter;
-import org.tizen.dynamicanalyzer.database.DBTable;
-import org.tizen.dynamicanalyzer.database.IResultSet;
-import org.tizen.dynamicanalyzer.protocol.ProtocolConstants;
-import org.tizen.dynamicanalyzer.swap.model.data.ContextSwitchData;
-import org.tizen.dynamicanalyzer.swap.model.data.LogData;
-import org.tizen.dynamicanalyzer.swap.model.data.ProfileData;
-import org.tizen.dynamicanalyzer.util.Logger;
-
-public class KernelDataMaker {
- private static final String queryto_withTime = "where %s < %s and %s > %s order by %s";
- private static final String queryto_withTidAndTime = "where %s = %s and %s < %s and %s > %s order by %s";
- private static final String queryto_withTid = "where %s = %s group by %s";
-
- public static final int START_TYPE_START = 10;
- public static final int START_TYPE_RESUME = 20;
- public static final int START_TYPE_RETURNED = 30;
- public static final int END_TYPE_END = 1;
- public static final int END_TYPE_PAUSED = 2;
- public static final int END_TYPE_CALL = 3;
-
- // 'threads' may be necessary to synchronize but i didn't
- // because i think that it does not make critical error
- private List<KernelDataPerThread> threads;
-
- private DBInserter contextDBInserter = null;
- private DBInserter functionDBInserter = null;
-
- public KernelDataMaker(DBInserter cDBInserter, DBInserter fDBInserter) {
- threads = new ArrayList<KernelDataPerThread>();
-
- contextDBInserter = cDBInserter;
- functionDBInserter = fDBInserter;
- }
-
- private KernelDataPerThread findKernelData(int tid) {
- int size = threads.size();
-
- for (int i = 0; i < size; i++) {
- KernelDataPerThread kdata = threads.get(i);
- if (kdata.getTid() == tid) {
- return kdata;
- }
- }
-
- return null;
- }
-
- public void makeData(List<LogData> inputs) {
- Stack<ProfileData> prefunc;
- Stack<Integer> prefunc_type;
-
- List<List<Object>> contextDataList = new ArrayList<List<Object>>();
- List<List<Object>> functionDataList = new ArrayList<List<Object>>();
-
- int size = inputs.size();
- for (int i = 0; i < size; i++) {
- LogData input = (LogData) inputs.get(i);
-
- switch (input.getMsgID()) {
- case ProtocolConstants.MSG_CONTEXT_SWITCH_EXIT: {
- ContextSwitchData csdata = (ContextSwitchData) input;
- int tid = csdata.getTid();
-
- KernelDataPerThread kdata = findKernelData(tid);
- if (kdata == null) { // thread id is not exist in thread id
- kdata = new KernelDataPerThread(csdata.getPid(), tid, csdata);
- threads.add(kdata);
- } else { // thread id is exist in thread id array
- if (kdata.getCorelog() != null) {
- // TODO : error
- Logger.error("context switch entry log is coming without exit log of previous context");
- } else {
- kdata.setCorelog(csdata);
-
- prefunc = kdata.getFunclog();
- prefunc_type = kdata.getFunclogType();
-
- if (prefunc != null) {
- ProfileData pfdata = prefunc.peek();
- pfdata.setTime(csdata.getTime());
- pfdata.setPcAddr(csdata.getPcAddr());
- pfdata.setCpuNum(csdata.getCpuNum());
-
- prefunc_type.pop();
- prefunc_type.push(START_TYPE_RESUME);
- }
- }
- }
- break;
- }
- case ProtocolConstants.MSG_CONTEXT_SWITCH_ENTRY: {
- ContextSwitchData csdata = (ContextSwitchData) input;
- ContextSwitchData precore;
- int tid = csdata.getTid();
-
- KernelDataPerThread kdata = findKernelData(tid);
- if (kdata == null) { // thread id is not exist
- // TODO : error
- Logger.error("context switch exit log is coming without any entry log");
- } else if ((precore = kdata.getCorelog()) == null) {
- // TODO : error
- Logger.error("context switch exit log is coming without corresponding entry log");
- } else if (precore.getCpuNum() != csdata.getCpuNum()) {
- // TODO : error
- Logger.error("context switch exit log is coming with different cpu num");
- } else {
- kdata.setCorelog(null);
-
- ArrayList<Object> dbdata = new ArrayList<Object>();
- dbdata.add(new Long(precore.getSeq()));
- dbdata.add(new Integer(precore.getPid()));
- dbdata.add(new Integer(precore.getTid()));
- dbdata.add(new Integer(precore.getCpuNum()));
- dbdata.add(new Long(precore.getTime()));
- dbdata.add(new Long(precore.getPcAddr()));
- dbdata.add(new Long(csdata.getTime()));
- dbdata.add(new Long(csdata.getPcAddr()));
- contextDataList.add(dbdata);
- kdata.incCoreFragmentCount();
-
- prefunc = kdata.getFunclog();
- prefunc_type = kdata.getFunclogType();
- if (prefunc != null) {
- if (prefunc.isEmpty() || prefunc_type.isEmpty()) {
- Logger.warning("context switch exit log is coming but there is no function in stack");
- } else {
- ProfileData lastfunc = prefunc.peek();
- int lastfunc_type = prefunc_type.peek();
-
- ArrayList<Object> dbfuncdata = new ArrayList<Object>();
- dbfuncdata.add(new Long(csdata.getSeq()));
- dbfuncdata.add(new Integer(csdata.getPid()));
- dbfuncdata.add(new Integer(csdata.getTid()));
- dbfuncdata.add(new Integer(csdata.getCpuNum()));
- dbfuncdata.add(new Long(lastfunc.getTime()));
- dbfuncdata.add(new Integer(lastfunc_type));
- dbfuncdata.add(new Long(lastfunc.getPcAddr()));
- dbfuncdata.add(new Long(csdata.getTime()));
- dbfuncdata.add(new Integer(END_TYPE_PAUSED));
- dbfuncdata.add(new Long(csdata.getPcAddr()));
- dbfuncdata.add(new Integer(lastfunc.getApiId()));
- functionDataList.add(dbfuncdata);
- kdata.incFuncFragmentCount();
- }
- }
- }
- break;
- }
- case ProtocolConstants.MSG_FUNCTION_ENTRY: {
- ProfileData fndata = null;
- try {
- fndata = (ProfileData) input.clone();
- } catch (CloneNotSupportedException e) {
- Logger.exception(e);
- break;
- }
- int tid = fndata.getTid();
-
- KernelDataPerThread kdata = findKernelData(tid);
- if (kdata == null) {
- // TODO : error
- // Logger.error("function entry log is coming without any context entry log");
- } else {
- assert (kdata.getCorelog() != null);
- if (kdata.getFunclog() == null) {
- kdata.createFunctionStack();
- }
-
- prefunc = kdata.getFunclog();
- prefunc_type = kdata.getFunclogType();
- assert (prefunc != null && prefunc_type != null);
-
- if (prefunc.isEmpty()) {
- assert (prefunc_type.isEmpty());
-
- prefunc.push(fndata);
- prefunc_type.push(START_TYPE_START);
- } else {
- ProfileData lastfunc = prefunc.peek();
- int lastfunc_type = prefunc_type.peek();
-
- ArrayList<Object> dbfuncdata = new ArrayList<Object>();
- dbfuncdata.add(new Long(fndata.getSeq()));
- dbfuncdata.add(new Integer(fndata.getPid()));
- dbfuncdata.add(new Integer(fndata.getTid()));
- dbfuncdata.add(new Integer(fndata.getCpuNum()));
- dbfuncdata.add(new Long(lastfunc.getTime()));
- dbfuncdata.add(new Integer(lastfunc_type));
- dbfuncdata.add(new Long(lastfunc.getPcAddr()));
- dbfuncdata.add(new Long(fndata.getTime()));
- dbfuncdata.add(new Integer(END_TYPE_CALL));
- dbfuncdata.add(new Long(fndata.getPcAddr()));
- dbfuncdata.add(new Integer(lastfunc.getApiId()));
- functionDataList.add(dbfuncdata);
- kdata.incFuncFragmentCount();
-
- prefunc.push(fndata);
- prefunc_type.push(START_TYPE_START);
- }
- }
- break;
- }
- case ProtocolConstants.MSG_FUNCTION_EXIT: {
- ProfileData fndata = (ProfileData) input;
- int tid = fndata.getTid();
-
- KernelDataPerThread kdata = findKernelData(tid);
- if (kdata == null) {
- // TODO : error
- // Logger.error("function entry log is coming without any context entry log");
- } else {
- assert (kdata.getCorelog() != null);
- if (kdata.getFunclog() == null) {
- kdata.createFunctionStack();
- }
-
- prefunc = kdata.getFunclog();
- prefunc_type = kdata.getFunclogType();
- assert (prefunc != null && prefunc_type != null);
-
- if (prefunc.isEmpty() || prefunc_type.isEmpty()) {
- // TODO : error
- Logger.error("function exit log is coming without function entry log");
- } else {
- ProfileData lastfunc = prefunc.pop();
- int lastfunc_type = prefunc_type.pop();
-
- assert (lastfunc.getApiId() == fndata.getApiId());
-
- ArrayList<Object> dbfuncdata = new ArrayList<Object>();
- dbfuncdata.add(new Long(fndata.getSeq()));
- dbfuncdata.add(new Integer(fndata.getPid()));
- dbfuncdata.add(new Integer(fndata.getTid()));
- dbfuncdata.add(new Integer(fndata.getCpuNum()));
- dbfuncdata.add(new Long(lastfunc.getTime()));
- dbfuncdata.add(new Integer(lastfunc_type));
- dbfuncdata.add(new Long(lastfunc.getPcAddr()));
- dbfuncdata.add(new Long(fndata.getTime()));
- dbfuncdata.add(new Integer(END_TYPE_END));
- dbfuncdata.add(new Long(fndata.getPcAddr()));
- dbfuncdata.add(new Integer(lastfunc.getApiId()));
- functionDataList.add(dbfuncdata);
- kdata.incFuncFragmentCount();
-
- if (!prefunc.isEmpty() && !prefunc_type.isEmpty()) {
- prefunc.peek().setTime(fndata.getTime());
- prefunc.peek().setPcAddr(fndata.getPcAddr());
- prefunc_type.pop();
- prefunc_type.push(START_TYPE_RETURNED);
- }
- }
- }
- break;
- }
- default:
- break;
- }
- }
-
- if (!contextDataList.isEmpty()) {
- contextDBInserter.pushData(contextDataList);
- }
-
- if (!functionDataList.isEmpty()) {
- functionDBInserter.pushData(functionDataList);
- }
- }
-
- public void clear() {
- threads.clear();
- }
-
- public List<List<Object>> getContextDataFromDB(long start, long end) {
- String where = String.format(queryto_withTime, ContextDataDBTable.COLUMN.STARTTIME.name,
- end, ContextDataDBTable.COLUMN.ENDTIME.name, start,
- ContextDataDBTable.COLUMN.STARTTIME.name);
-
- DBTable table = KernelDataManager.getInstance().getContextDataTable();
-
- return table.selectAllColumnData(where);
- }
-
- public List<List<Object>> getFunctionDataFromDB(long start, long end, int tid) {
- String where;
-
- if (tid >= 0) {
- where = String.format(queryto_withTidAndTime, FunctionDataDBTable.COLUMN.TID.name, tid,
- FunctionDataDBTable.COLUMN.STARTTIME.name, end,
- FunctionDataDBTable.COLUMN.ENDTIME.name, start,
- FunctionDataDBTable.COLUMN.STARTTIME.name);
- } else {
- where = String.format(queryto_withTime, FunctionDataDBTable.COLUMN.STARTTIME.name, end,
- FunctionDataDBTable.COLUMN.ENDTIME.name, start,
- FunctionDataDBTable.COLUMN.STARTTIME.name);
- }
-
- DBTable table = KernelDataManager.getInstance().getFunctionDataTable();
-
- return table.selectAllColumnData(where);
- }
-
- public List<List<Object>> getFuncnameFromDB(int tid) {
- String where = String.format(queryto_withTid, FunctionDataDBTable.COLUMN.TID.name, tid,
- FunctionDataDBTable.COLUMN.FUNCID.name);
-
- List<String> selectColumn = new ArrayList<String>();
- selectColumn.add(FunctionDataDBTable.COLUMN.FUNCID.name);
-
- DBTable table = KernelDataManager.getInstance().getFunctionDataTable();
-
- return table.selectData(selectColumn, where, new IResultSet() {
- @Override
- public List<Object> extractDataFromResultSet(ResultSet rs) {
- List<Object> row = new ArrayList<Object>();
- try {
- row.add(Integer.valueOf(rs.getInt(1)));
- } catch (SQLException e) {
- Logger.exception(e);
- return null;
- }
-
- return row;
- }
- });
- }
-
- public List<KernelDataPerThread> getThreadData() {
- return threads;
- }
-
- public void addThreadData(KernelDataPerThread data) {
- threads.add(data);
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jaewon Lim <jaewon81.lim@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.kernel.data;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.PriorityQueue;
-
-import org.tizen.dynamicanalyzer.database.DBInserter;
-import org.tizen.dynamicanalyzer.database.DBTable;
-import org.tizen.dynamicanalyzer.database.SqlConnectionManager;
-import org.tizen.dynamicanalyzer.protocol.ProtocolConstants;
-import org.tizen.dynamicanalyzer.swap.logparser.LogPackage;
-import org.tizen.dynamicanalyzer.swap.logparser.Logs;
-import org.tizen.dynamicanalyzer.swap.logparser.PageDataManager;
-import org.tizen.dynamicanalyzer.swap.model.data.LogData;
-import org.tizen.dynamicanalyzer.swap.model.data.LogDataTimeComparator;
-
-public class KernelDataManager extends PageDataManager {
- private static final String PIDTID_QUERY_CONTEXT = "select distinct "
- + ContextDataDBTable.COLUMN.PID.name + ", " + ContextDataDBTable.COLUMN.TID.name
- + " from %s";
-
- private static final String PIDTID_QUERY_FUNCTION = "select distinct "
- + FunctionDataDBTable.COLUMN.PID.name + ", " + FunctionDataDBTable.COLUMN.TID.name
- + " from %s";
-
- private static final String COUNT_QUERY_CONTEXT = "select count(*) from %s where "
- + ContextDataDBTable.COLUMN.TID.name + "=%s";
-
- private static final String COUNT_QUERY_FUNCTION = "select count(*) from %s where "
- + FunctionDataDBTable.COLUMN.TID.name + "=%s";
-
- private static KernelDataManager instance = new KernelDataManager();
- private KernelDataMaker kdataMaker = null;
-
- private ContextDataDBTable contextDataTable = null;
- private FunctionDataDBTable functionDataTable = null;
-
- private KernelDataManager() {
- contextDataTable = new ContextDataDBTable();
- functionDataTable = new FunctionDataDBTable();
- DBInserter cDBInserter = makeInserter(contextDataTable);
- DBInserter fDBInserter = makeInserter(functionDataTable);
-
- kdataMaker = new KernelDataMaker(cDBInserter, fDBInserter);
- }
-
- public DBTable getContextDataTable() {
- return contextDataTable;
- }
-
- public DBTable getFunctionDataTable() {
- return functionDataTable;
- }
-
- public KernelDataMaker getDataMaker() {
- return kdataMaker;
- }
-
- public static KernelDataManager getInstance() {
- return instance;
- }
-
- public void clear() {
- kdataMaker.clear();
- }
-
- private ArrayList<LogData> getLogsFromLogPackage(LogPackage logPack) {
- Logs contextEntryLogs = logPack.getLogs(ProtocolConstants.MSG_CONTEXT_SWITCH_ENTRY);
- Logs contextExitLogs = logPack.getLogs(ProtocolConstants.MSG_CONTEXT_SWITCH_EXIT);
- Logs functionEntryLogs = logPack.getLogs(ProtocolConstants.MSG_FUNCTION_ENTRY);
- Logs functionExitLogs = logPack.getLogs(ProtocolConstants.MSG_FUNCTION_EXIT);
-
- ArrayList<LogData> kernelLogs = new ArrayList<LogData>();
- PriorityQueue<LogData> pqueue = new PriorityQueue<LogData>(5, new LogDataTimeComparator());
-
- List<LogData> contextEntryLogList = null, contextExitLogList = null, functionEntryLogList = null, functionExitLogList = null;
- Iterator<LogData> centryiter = null, cexititer = null, fentryiter = null, fexititer = null;
- if (contextEntryLogs != null) {
- contextEntryLogList = contextEntryLogs.getLogs();
- centryiter = contextEntryLogList.iterator();
- if (centryiter.hasNext())
- pqueue.offer(centryiter.next());
- }
- if (contextExitLogs != null) {
- contextExitLogList = contextExitLogs.getLogs();
- cexititer = contextExitLogList.iterator();
- if (cexititer.hasNext())
- pqueue.offer(cexititer.next());
- }
- if (functionEntryLogs != null) {
- functionEntryLogList = functionEntryLogs.getLogs();
- fentryiter = functionEntryLogList.iterator();
- if (fentryiter.hasNext())
- pqueue.offer(fentryiter.next());
- }
- if (functionExitLogs != null) {
- functionExitLogList = functionExitLogs.getLogs();
- fexititer = functionExitLogList.iterator();
- if (fexititer.hasNext())
- pqueue.offer(fexititer.next());
- }
-
- do {
- LogData top = pqueue.poll();
- if (top == null)
- break;
-
- switch (top.getMsgID()) {
- case ProtocolConstants.MSG_CONTEXT_SWITCH_ENTRY:
- if (centryiter != null && centryiter.hasNext())
- pqueue.offer(centryiter.next());
- break;
- case ProtocolConstants.MSG_CONTEXT_SWITCH_EXIT:
- if (cexititer != null && cexititer.hasNext())
- pqueue.offer(cexititer.next());
- break;
- case ProtocolConstants.MSG_FUNCTION_ENTRY:
- if (fentryiter != null && fentryiter.hasNext())
- pqueue.offer(fentryiter.next());
- break;
- case ProtocolConstants.MSG_FUNCTION_EXIT:
- if (fexititer != null && fexititer.hasNext())
- pqueue.offer(fexititer.next());
- break;
- default:
- break;
- }
-
- kernelLogs.add(top);
- } while (true);
-
- return kernelLogs;
- }
-
- @Override
- protected void makeData(LogPackage pack) {
- ArrayList<LogData> logs = getLogsFromLogPackage(pack);
- if (!logs.isEmpty())
- kdataMaker.makeData(logs);
- }
-
- @Override
- public void openData(Map<String, String> dataMap) {
- kdataMaker.clear();
-
- Map<Integer, KernelDataPerThread> threadMap = new HashMap<Integer, KernelDataPerThread>();
-
- String query = String.format(PIDTID_QUERY_CONTEXT, contextDataTable.getTableName());
- List<List<Object>> contextPidTid = SqlConnectionManager.executeQuery(query);
- query = String.format(PIDTID_QUERY_FUNCTION, functionDataTable.getTableName());
- List<List<Object>> functionPidTid = SqlConnectionManager.executeQuery(query);
-
- if (contextPidTid != null) {
- int threadsize = contextPidTid.size();
- for (int i = 0; i < threadsize; i++) {
- List<Object> row = contextPidTid.get(i);
- int pid = ((Integer) row.get(0)).intValue();
- int tid = ((Integer) row.get(1)).intValue();
-
- KernelDataPerThread kdata = new KernelDataPerThread(pid, tid);
- threadMap.put(Integer.valueOf(tid), kdata);
-
- query = String.format(COUNT_QUERY_CONTEXT, contextDataTable.getTableName(),
- Integer.toString(tid));
- List<List<Object>> coreCount = SqlConnectionManager.executeQuery(query);
- Object count;
- if (coreCount == null) {
- count = Integer.valueOf(0);
- } else {
- count = coreCount.get(0).get(0);
- }
- if (count instanceof Integer) {
- kdata.setCoreFragmentCount(((Integer) count).intValue());
- } else if (count instanceof Long) {
- kdata.setCoreFragmentCount(((Long) count).intValue());
- }
-
- query = String.format(COUNT_QUERY_FUNCTION, functionDataTable.getTableName(),
- Integer.toString(tid));
- List<List<Object>> functionCount = SqlConnectionManager.executeQuery(query);
- if (functionCount == null) {
- count = Integer.valueOf(0);
- } else {
- count = functionCount.get(0).get(0);
- }
- if (count instanceof Integer) {
- kdata.setFunctionFragmentCount(((Integer) count).intValue());
- } else if (count instanceof Long) {
- kdata.setFunctionFragmentCount(((Long) count).intValue());
- }
- }
- }
-
- if (functionPidTid != null) {
- int threadsize = functionPidTid.size();
- for (int i = 0; i < threadsize; i++) {
- List<Object> row = functionPidTid.get(i);
- int tid = ((Integer) row.get(1)).intValue();
-
- KernelDataPerThread kdata = threadMap.get(Integer.valueOf(tid));
- if (kdata != null) {
- kdata.createFunctionStack();
- }
- }
- }
-
- for (Map.Entry<Integer, KernelDataPerThread> entry : threadMap.entrySet()) {
- KernelDataPerThread kdata = entry.getValue();
- kdataMaker.addThreadData(kdata);
- }
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jaewon Lim <jaewon81.lim@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.kernel.data;
-
-import java.util.Stack;
-
-import org.tizen.dynamicanalyzer.swap.model.data.ContextSwitchData;
-import org.tizen.dynamicanalyzer.swap.model.data.ProfileData;
-import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoardItem;
-
-public class KernelDataPerThread {
- private int pid;
- private int tid;
- private ContextSwitchData core_log;
- private Stack<ProfileData> func_log = null;
- private Stack<Integer> func_log_type = null;
-
- private DAChartBoardItem contextChart = null;
- private DAChartBoardItem functionChart = null;
-
- private int coreFragmentCount = 0;
- private int functionFragmentCount = 0;
-
- public KernelDataPerThread(int pid, int tid) {
- this.pid = pid;
- this.tid = tid;
- core_log = null;
- }
-
- public KernelDataPerThread(int pid, int tid, ContextSwitchData corelog) {
- this.pid = pid;
- this.tid = tid;
- core_log = corelog;
- }
-
- public void createFunctionStack() {
- func_log = new Stack<ProfileData>();
- func_log_type = new Stack<Integer>();
- }
-
- public int getPid() {
- return pid;
- }
-
- public int getTid() {
- return tid;
- }
-
- public ContextSwitchData getCorelog() {
- return core_log;
- }
-
- public Stack<ProfileData> getFunclog() {
- return func_log;
- }
-
- public Stack<Integer> getFunclogType() {
- return func_log_type;
- }
-
- public void setCorelog(ContextSwitchData corelog) {
- core_log = corelog;
- }
-
- public DAChartBoardItem getContextChart() {
- return contextChart;
- }
-
- public void setContextChart(DAChartBoardItem contextChart) {
- this.contextChart = contextChart;
- }
-
- public DAChartBoardItem getFunctionChart() {
- return functionChart;
- }
-
- public void setFunctionChart(DAChartBoardItem functionChart) {
- this.functionChart = functionChart;
- }
-
- public void incCoreFragmentCount() {
- coreFragmentCount++;
- }
-
- public void incFuncFragmentCount() {
- functionFragmentCount++;
- }
-
- public int getCoreFragmentCount() {
- return coreFragmentCount;
- }
-
- public int getFuncFragmentCount() {
- return functionFragmentCount;
- }
-
- public void setCoreFragmentCount(int count) {
- this.coreFragmentCount = count;
- }
-
- public void setFunctionFragmentCount(int count) {
- this.functionFragmentCount = count;
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Jaewon Lim <jaewon81.lim@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.kernel.data;
-
-import java.util.Comparator;
-
-public class KernelDataPerThreadComparator implements
- Comparator<KernelDataPerThread> {
-
- @Override
- public int compare(KernelDataPerThread o1, KernelDataPerThread o2) {
- if (o1.getPid() < o2.getPid())
- return -1;
- else if (o1.getPid() > o2.getPid())
- return 1;
- else {
- if (o1.getTid() < o2.getTid())
- return -1;
- else if (o1.getTid() > o2.getTid())
- return 1;
- else
- return 0;
- }
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Hyunjong Park <phjwithyou.park@samsung.com>
- * yeongtaik byeon <yeongtaik.byeon@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.kernel.data;
-
-public class KernelSelectionData {
- public static final int KERNEL_DATA_TYPE_NONE = 0;
- public static final int KERNEL_DATA_TYPE_CONTEXTSWITCH = 1;
- public static final int KERNEL_DATA_TYPE_FUNCTIONCALL = 2;
-
- private KernelDataPerThread kernelData = null;
- private int dataType = KERNEL_DATA_TYPE_NONE;
-
- public KernelSelectionData(KernelDataPerThread data, int type) {
- this.kernelData = data;
- this.dataType = type;
- }
-
- public KernelDataPerThread getData() {
- return kernelData;
- }
-
- public int getType() {
- return dataType;
- }
-}
import org.tizen.dynamicanalyzer.nl.InformationViewLabels;
import org.tizen.dynamicanalyzer.nl.MemoryPageLabels;
import org.tizen.dynamicanalyzer.resources.ColorResources;
-import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackInserter;
import org.tizen.dynamicanalyzer.ui.memory.table.MemoryCallStackTable;
import org.tizen.dynamicanalyzer.ui.widgets.table.DATableComposite;
import org.tizen.dynamicanalyzer.widgets.da.view.DAViewComposite;
private boolean[] columnVisibility = { true, true, true };
Composite contents = null;
- // this definition should be here for creation of instance (register db table)
- @SuppressWarnings("unused")
- private static CallStackInserter inserter = CallStackInserter.getInstance();
-
public MemoryCallStackView(Composite parent, int style) {
super(parent, style, false);
this.setLayout(new FillLayout());
import org.tizen.dynamicanalyzer.resources.ColorResources;
import org.tizen.dynamicanalyzer.resources.FontResources;
import org.tizen.dynamicanalyzer.resources.ImageResources;
-import org.tizen.dynamicanalyzer.ui.common.UICommonConstants;
import org.tizen.dynamicanalyzer.ui.memory.chart.MemoryChartBoard;
import org.tizen.dynamicanalyzer.ui.page.BaseView;
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
-import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
import org.tizen.dynamicanalyzer.ui.timeline.logparser.LifecycleLogParser;
import org.tizen.dynamicanalyzer.ui.toolbar.DAToolBarCustomCombo;
import org.tizen.dynamicanalyzer.ui.toolbar.ToolBarComboListener;
import org.tizen.dynamicanalyzer.util.WorkbenchUtil;
import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonRenderer;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotIntervalMarker;
import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoard;
import org.tizen.dynamicanalyzer.widgets.da.view.DAViewComposite;
import org.tizen.dynamicanalyzer.widgets.da.view.DAViewData;
private DAToolBarCustomCombo processCombo;
- private final RangeDataManager rangeDataManager = RangeDataManager.getInstance();
-
public MemoryChartView(Composite parent, int style) {
super(parent, style, false);
this.setLayout(new FillLayout());
return;
memoryChartBoard.updateChartBoard();
-
- if (RangeDataManager.getInstance().isBeingAnalyzed()) {
- ((DAChartPlotIntervalMarker) memoryChartBoard.getMarkers().get(
- UICommonConstants.RANGE_ANALYSIS_MARKER_INDEX)).setInterval(
- rangeDataManager.getAnalysisStartTime() / TimelineConstants.MEGA_DOUBLE,
- rangeDataManager.getAnalysisEndTime() / TimelineConstants.MEGA_DOUBLE);
- } else {
- ((DAChartPlotIntervalMarker) memoryChartBoard.getMarkers().get(
- UICommonConstants.RANGE_ANALYSIS_MARKER_INDEX)).setInterval(-1, -1);
- }
-
- ((DAChartPlotIntervalMarker) memoryChartBoard.getMarkers().get(
- UICommonConstants.RANGE_MARKER_INDEX)).setInterval(
- rangeDataManager.getMarkerStartTime() / TimelineConstants.MEGA_DOUBLE,
- rangeDataManager.getMarkerEndTime() / TimelineConstants.MEGA_DOUBLE);
}
@Override
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.tizen.dynamicanalyzer.common.AnalyzerManager;
+import org.tizen.dynamicanalyzer.common.DASelectionData;
import org.tizen.dynamicanalyzer.nl.MemoryPageLabels;
import org.tizen.dynamicanalyzer.resources.ColorResources;
import org.tizen.dynamicanalyzer.ui.memory.table.MemoryMapTable;
MemoryMapTable tableComp = null;
- public MemoryMapView(Composite parent, int style) {
+ public MemoryMapView(Composite parent, int style) {
super(parent, style, false);
this.setLayout(new FillLayout());
setTitle(MemoryPageLabels.MEMORY_MAP_VIEW_TITLE);
Composite contents = getContentArea();
contents.setBackground(ColorResources.WINDOW_BG_COLOR);
contents.setLayout(new FillLayout());
- tableComp = new MemoryMapTable(contents, SWT.NONE, SWT.MULTI | SWT.BORDER
+ tableComp = new MemoryMapTable(contents, SWT.NONE, SWT.MULTI | SWT.BORDER
| SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
+ tableComp.setSelectionTime(-1);
}
-
+
@Override
public void updateView() {
if (!AnalyzerManager.isVisibleView(this.getID())) {
}
tableComp.updateTable();
}
-
+
@Override
- public void updateView(DAViewData data) {
+ public void updateView(DAViewData vdata) {
+ if (!(vdata instanceof DASelectionData)) {
+ return;
+ }
+
+ DASelectionData selData = (DASelectionData) vdata;
+ if(selData.getStartTime() == selData.getEndTime()) {
+ tableComp.setSelectionTime(selData.getStartTime());
+ }
+ else {
+ tableComp.setSelectionTime(-1);
+ }
+
+ if (!AnalyzerManager.isVisibleView(this.getID())) {
+ return;
+ }
+
+ tableComp.updateTable();
}
-
+
@Override
public void clear() {
tableComp.clear();
import org.tizen.dynamicanalyzer.setting.SettingDataManager;
import org.tizen.dynamicanalyzer.shortcut.ShortCutManager;
import org.tizen.dynamicanalyzer.ui.memory.chart.MemoryChartBoard;
-import org.tizen.dynamicanalyzer.ui.memory.data.HeapDataManager;
-import org.tizen.dynamicanalyzer.ui.memory.data.MemoryDataManager;
import org.tizen.dynamicanalyzer.ui.memory.table.MemoryPersistentAllocationsTable;
import org.tizen.dynamicanalyzer.ui.memory.table.MemoryStatisticsTable;
import org.tizen.dynamicanalyzer.ui.page.MenuBar;
public static final String mapViewID = MemoryMapView.class.getName();
public static final String persistentAllocsViewID = MemoryPageLabels.MEMORY_ALLOCATION_TRACE_VIEW_TITLE + "View";
public static final String leaksViewID = MemoryPageLabels.MEMORY_LEAKS_VIEW_TITLE + "View";
+ public static final String callstackViewID = MemoryCallStackView.class.getName();
private DATabComposite memoryTabView = null;
+ private DATabComposite memoryRightTabView = null;
MemoryChartView memoryChartView;
MemoryDetailsTableView memoryDetailsTableView;
memoryChartView = new MemoryChartView(topForm, SWT.NONE);
addView(memoryChartView);
-
-
+
memoryTabView = new DATabComposite(bottomLeftForm, SWT.NONE,
false, true);
{
+ memoryTabView.setID(AnalyzerLabels.LEFT_TABLE_VIEW_ID);
memoryDetailsTableView = new MemoryDetailsTableView(memoryTabView.getContentComposite(), SWT.NONE);
memoryTabView.addView(memoryDetailsTableView, false);
- addView(memoryDetailsTableView);
-
+
memoryRangeAnalysisView = new MemoryRangeAnalysisView(memoryTabView.getContentComposite(), SWT.NONE);
memoryTabView.addView(memoryRangeAnalysisView, true);
- addView(memoryRangeAnalysisView);
memoryStatisticsTableView = new MemoryStatisticsTableView(memoryTabView.getContentComposite(), SWT.NONE);
memoryTabView.addView(memoryStatisticsTableView, false);
- addView(memoryStatisticsTableView);
PersistentAllocationsSelectionListener persistentAllocsListener = new PersistentAllocationsSelectionListener(
this);
memoryTabView.getContentComposite(), SWT.NONE, false);
((MemoryPersistentAllocationsTable) memoryPersistentAllocationsTableView.getControl())
.getTable().addSelectionListener(persistentAllocsListener);
- showView(memoryPersistentAllocationsTableView,
+ showView(memoryTabView, memoryPersistentAllocationsTableView,
MenuBar.getInstance().getPersistentAllocationsSelection());
memoryLeaksTableView = new MemoryPersistentAllocationsTableView(
memoryTabView.getContentComposite(), SWT.NONE, true);
((MemoryPersistentAllocationsTable) memoryLeaksTableView.getControl()).getTable()
.addSelectionListener(persistentAllocsListener);
- showView(memoryLeaksTableView, SettingDataManager.INSTANCE
+ showView(memoryTabView, memoryLeaksTableView, SettingDataManager.INSTANCE
.isPreferenceSelected(FlatPreferences.LEAK_SANITIZER));
}
addView(memoryTabView);
- DATabComposite memoryRightTabView = new DATabComposite(bottomRightForm, SWT.NONE, false, true);
+ memoryRightTabView = new DATabComposite(bottomRightForm, SWT.NONE, false, true);
{
+ memoryRightTabView.setID(AnalyzerLabels.RIGHT_TABLE_VIEW_ID);
memoryMapView = new MemoryMapView(memoryRightTabView.getContentComposite(), SWT.NONE);
memoryRightTabView.addView(memoryMapView, false);
- addView(memoryMapView);
memoryCallStackView = new MemoryCallStackView(memoryRightTabView.getContentComposite(), SWT.NONE);
- memoryRightTabView.addView(memoryCallStackView, false);
- addView(memoryCallStackView);
+ showView(memoryRightTabView, memoryCallStackView,
+ MenuBar.getInstance().getPersistentAllocationsSelection()
+ || SettingDataManager.INSTANCE
+ .isPreferenceSelected(FlatPreferences.LEAK_SANITIZER));
}
addView(memoryRightTabView);
}
/**
- * Shows or hides given {@code view} depending on the value of the
- * {@code show} argument.
+ * Shows or hides given {@code view} in given {@code tab} depending on the
+ * value of the {@code show} argument.
*
+ * @param tab {@link DATabComposite} tab composite that should contains
+ * {@code view}
* @param view {@link DABaseComposite} instance
* @param show whether {@code view} should be shown
*/
- private void showView(DABaseComposite view, boolean show) {
+ private void showView(DATabComposite tab, DABaseComposite view, boolean show) {
if (show) {
- memoryTabView.addView(view);
- addView(view);
+ tab.addView(view);
} else {
- memoryTabView.removeView(view.getID(), false);
- removeView(view);
+ tab.removeView(view.getID(), false);
}
resizeTableButton();
}
* @param show whether the table should be shown
*/
public void showPersistentAllocationsView(boolean show) {
- showView(memoryPersistentAllocationsTableView, show);
-
+ showView(memoryTabView, memoryPersistentAllocationsTableView, show);
+ showView(memoryRightTabView, memoryCallStackView,
+ MenuBar.getInstance().getPersistentAllocationsSelection()
+ || SettingDataManager.INSTANCE
+ .isPreferenceSelected(FlatPreferences.LEAK_SANITIZER));
// forces table to be updated when the view will be shown again
if (!show)
memoryPersistentAllocationsTableView.hide();
* @param show whether the table should be shown
*/
public void showLeaksView(boolean show) {
- showView(memoryLeaksTableView, show);
-
+ showView(memoryTabView, memoryLeaksTableView, show);
+ showView(memoryRightTabView, memoryCallStackView,
+ MenuBar.getInstance().getPersistentAllocationsSelection()
+ || SettingDataManager.INSTANCE
+ .isPreferenceSelected(FlatPreferences.LEAK_SANITIZER));
// forces table to be updated when the view will be shown again
if (!show)
memoryLeaksTableView.hide();
@Override
public void clear() {
super.clear();
- MemoryDataManager.getInstance().clear();
- HeapDataManager.getInstance().clear();
}
}
ID = onlyLeaks ? MemoryPage.leaksViewID : MemoryPage.persistentAllocsViewID;
tableComp = new MemoryPersistentAllocationsTable(getContentArea(), SWT.NONE,
- SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL, onlyLeaks);
+ SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL,
+ onlyLeaks);
setDataComposite(tableComp);
}
}
}
- if (DAState.isRunning()) {
+ if (!DAState.isDone()) {
if (!this.isHidden()) {
if (!tableComp.isSelectionPerformed())
hide();
if (selData.getStartTime() == selData.getEndTime()) {
tableComp.setSelectionRange((long) 0, (long) 0);
- if (DAState.isRunning()) {
+ if (!DAState.isDone()) {
hide();
tableComp.clear();
return;
@Override
public void updateView() {
- if (DAState.isRunning()) {
+ if (!DAState.isDone()) {
if (!this.isHidden()) {
if (!tableComp.isSelectionPerformed())
hide();
if (selData.getStartTime() == selData.getEndTime()) {
tableComp.setSelectionRange((long) 0, (long) 0);
- if (DAState.isRunning()) {
+ if (!DAState.isDone()) {
hide();
tableComp.clear();
return;
import java.util.List;\r
\r
import org.eclipse.swt.graphics.Image;\r
-import org.tizen.dynamicanalyzer.nl.TimelineChartLabels;\r
import org.tizen.dynamicanalyzer.resources.FontResources;\r
import org.tizen.dynamicanalyzer.resources.ImageResources;\r
-import org.tizen.dynamicanalyzer.ui.common.PopupRangeAnalysisMenuItemOnChartListener;\r
+import org.tizen.dynamicanalyzer.ui.common.ChartPopupMenu;\r
import org.tizen.dynamicanalyzer.widgets.chart.DAChart;\r
import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlot;\r
import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlot.AutoRangeType;\r
import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoard;\r
import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoardItem;\r
import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenu;\r
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuItem;\r
\r
public class MemoryChart {\r
public DAChart chart;\r
this.chartName = chartName;\r
this.chartBoardItem = chartBoardItem;\r
this.chart = chart;\r
+ this.popupMenu = new ChartPopupMenu(chart);\r
}\r
\r
public DAChartBoardItem getChartItem() {\r
chart = item.getChart();\r
\r
setChartStyle();\r
- popupMenu = new DAPopupMenu(chart);\r
- initPopupMenu(chartBoard, popupMenu);\r
\r
return item;\r
}\r
plot.setAxisFont(FontResources.CHART_AXIS_FONT);\r
}\r
\r
- protected void initPopupMenu(DAChartBoard chartBoard, DAPopupMenu popupMenu) {\r
- popupMenu.setFont(FontResources.CONTEXT_MENU_ITEM_FONT);\r
- DAPopupMenuItem analysisItem = new DAPopupMenuItem(popupMenu);\r
- analysisItem.setText(TimelineChartLabels.RANGE_CONTEXT_ANALYSIS);\r
- analysisItem.addListener(new PopupRangeAnalysisMenuItemOnChartListener(analysisItem, chartBoard, chart));\r
- }\r
- \r
public void pushChild(MemoryChart child) {\r
children.add(child);\r
}\r
import org.tizen.dynamicanalyzer.resources.ImageResources;\r
import org.tizen.dynamicanalyzer.setting.SettingDataManager;\r
import org.tizen.dynamicanalyzer.setting.TargetData;\r
-import org.tizen.dynamicanalyzer.ui.common.PopupRangeAnalysisMenuItemOnChartListener;\r
import org.tizen.dynamicanalyzer.ui.common.TimeLineChartKeyListener;\r
import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseEventListener;\r
import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseTrackAdapter;\r
import org.tizen.dynamicanalyzer.ui.memory.MemoryPage;\r
-import org.tizen.dynamicanalyzer.ui.memory.data.HeapDataManager;\r
+import org.tizen.dynamicanalyzer.ui.memory.data.HeapDataProcessor;\r
import org.tizen.dynamicanalyzer.ui.memory.data.MemoryDataManager;\r
import org.tizen.dynamicanalyzer.ui.memory.data.ProcessMemoryDBTable;\r
+import org.tizen.dynamicanalyzer.ui.memory.data.util.Query;\r
import org.tizen.dynamicanalyzer.ui.page.MenuBar;\r
import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineChartManager;\r
import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;\r
import org.tizen.dynamicanalyzer.widgets.chart.DAChartRenderer;\r
import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoard;\r
import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoardItem;\r
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenu;\r
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuItem;\r
\r
public class MemoryChartBoard extends DADefaultChartBoard {\r
private int allProcessPID = 0;\r
selectionMarker.setBackgroundColor(ColorResources.SELECTION_RANGE);\r
selectionMarker.setAlpha((int) (255 * 0.25));\r
addIntervalMarker(selectionMarker);\r
- \r
- // range analysis marker\r
- DAChartPlotIntervalMarker rangeAnalyzeMarker = new DAChartPlotIntervalMarker(-1, -1,\r
- DAChartPlotIntervalMarker.INTERVAL_MARKER_STYLE_AREA);\r
- rangeAnalyzeMarker.setBackgroundColor(ColorResources.YELLOW);\r
- rangeAnalyzeMarker.setAlpha((int) (255 * 0.25));\r
- addIntervalMarker(rangeAnalyzeMarker);\r
- \r
- // range marker\r
- DAChartPlotIntervalMarker rangeMarker = new DAChartPlotIntervalMarker(-1, -1,\r
- DAChartPlotIntervalMarker.INTERVAL_MARKER_STYLE_LINE);\r
- rangeMarker.setForegroundColor(ColorResources.RED);\r
- rangeMarker.setAlpha((int) (255 * 0.25));\r
- addIntervalMarker(rangeMarker);\r
}\r
\r
public void updateChartBoard() {\r
tooltip.setFont(FontResources.CHART_TOOLTIP_FONT);\r
plot.setTooltip(tooltip);\r
\r
- final MemoryChart tmp = chart;\r
- \r
- DAPopupMenu popupMenu = new DAPopupMenu(chart.getChart());\r
- popupMenu.setFont(FontResources.CONTEXT_MENU_ITEM_FONT);\r
- DAPopupMenuItem analysisItem = new DAPopupMenuItem(popupMenu);\r
- analysisItem.setText(TimelineChartLabels.RANGE_CONTEXT_ANALYSIS);\r
- analysisItem.addListener(new PopupRangeAnalysisMenuItemOnChartListener(analysisItem, this, tmp.getChart()));\r
- \r
- chart.popupMenu = popupMenu;\r
-\r
TimelineChartMouseEventListener memoryChartMouseEventListener = new TimelineChartMouseEventListener(\r
chart.getPopupMenu(), getTimeline(), MemoryPage.pageID);\r
chart.getChart().addMouseListener(memoryChartMouseEventListener);\r
heapChart.chart.getPlot().setAxisRangeY(0, getNormalizedHeight(targetProcessDBData));\r
\r
// Draw Persistent Memory Series only if tracing is stopped\r
- if (!DAState.isRunning() && showPersistentSeries) {\r
+ if (DAState.isDone() && showPersistentSeries) {\r
// no need to select data from DB every time if it is not\r
// changing\r
if (persistentData == null)\r
- persistentData = HeapDataManager.getInstance()\r
- .remainedAllocatedListForRange(start, end, false);\r
+ persistentData = HeapDataProcessor.getInstance()\r
+ .remainedAllocatedListForRange(new Query(start, end));\r
\r
heapChart.showPersistentSeries();\r
heapChart.updatePersistentSeries(persistentData);\r
+++ /dev/null
-/*\r
- * Dynamic Analyzer\r
- *\r
- * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: \r
- * Dongkye Lee <dongkyu6.lee@samsung.com>\r
- * Jaeyong Lee <jae-yong.lee@@samsung.com>\r
- * Gihun Chang <gihun.chang@@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * \r
- */\r
-\r
-package org.tizen.dynamicanalyzer.ui.memory.chart;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.events.MouseEvent;\r
-import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseEventListener;\r
-import org.tizen.dynamicanalyzer.ui.common.UIEventChartContextMenuItem;\r
-import org.tizen.dynamicanalyzer.ui.timeline.chart.ScreenshotChart;\r
-import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineChartManager;\r
-import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;\r
-import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;\r
-import org.tizen.dynamicanalyzer.widgets.chart.DAChart;\r
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlot;\r
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotIntervalMarker;\r
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotMarker;\r
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartSeries;\r
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartSeriesItem;\r
-import org.tizen.dynamicanalyzer.widgets.chart.DAScreenshotChartPlot;\r
-import org.tizen.dynamicanalyzer.widgets.chart.DAUIEventChartPlot;\r
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenu;\r
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuItem;\r
-import org.tizen.dynamicanalyzer.widgets.timeline.DATimeline;\r
-\r
-public class MemoryChartMouseEventListener extends TimelineChartMouseEventListener {\r
-\r
- public MemoryChartMouseEventListener(DAPopupMenu menu, DATimeline timeline, String pageID) {\r
- super(menu, timeline, pageID);\r
- }\r
-\r
- @Override\r
- public void mouseDown(MouseEvent e) {\r
- DAChart chart = (DAChart) e.widget;\r
- DAChartPlot plot = chart.getPlot();\r
- DAChartPlotMarker marker = plot.getMarkers().get(SELECTION_MARKER_INDEX);\r
- if (!(marker instanceof DAChartPlotIntervalMarker)) {\r
- return;\r
- }\r
- DAChartPlotIntervalMarker intervalMarker = (DAChartPlotIntervalMarker) marker;\r
-\r
- double eventTime = plot.getXFromXPixel(e.x);\r
-\r
- if (e.button == 3) {\r
- List<DAPopupMenuItem> itemList = menu.getItems();\r
- DAPopupMenuItem startItem = itemList.get(0);\r
- DAPopupMenuItem endItem = itemList.get(1);\r
- DAPopupMenuItem fromSelectionItem = itemList.get(2);\r
- DAPopupMenuItem analysisItem = itemList.get(3);\r
- DAPopupMenuItem clearItem = itemList.get(4);\r
-\r
- if (eventTime * TimelineConstants.MEGA_DOUBLE <= Toolbar.INSTANCE.getTime()) {\r
- startItem.setEnabled(true);\r
- endItem.setEnabled(true);\r
- analysisItem.setEnabled(rangeDataManager.isAnalyzable());\r
- clearItem.setEnabled(rangeDataManager.isBeingAnalyzed());\r
-\r
- startItem.setDoubleData(eventTime);\r
- endItem.setDoubleData(eventTime);\r
- } else {\r
- startItem.setEnabled(false);\r
- endItem.setEnabled(false);\r
- analysisItem.setEnabled(rangeDataManager.isAnalyzable());\r
- clearItem.setEnabled(rangeDataManager.isBeingAnalyzed());\r
- }\r
-\r
- if (intervalMarker.getStartVal() != intervalMarker.getEndVal()) {\r
- fromSelectionItem.setEnabled(true);\r
- } else {\r
- fromSelectionItem.setEnabled(false);\r
- }\r
-\r
- if (plot instanceof DAUIEventChartPlot) {\r
- List<Integer> startIndexList = new ArrayList<Integer>();\r
- List<Integer> endIndexList = new ArrayList<Integer>();\r
-\r
- for (DAChartSeries chartSeries : chart.getSeriesList()) {\r
- int startIndex = chartSeries.getNextIndexByXvalue(intervalMarker.getStartVal());\r
- int endIndex = chartSeries.getPrevIndexByXvalue(intervalMarker.getEndVal());\r
-\r
- startIndexList.add(startIndex);\r
- endIndexList.add(endIndex + 1);\r
- }\r
- DAPopupMenuItem eventListItem = menu.getItems().get(menu.getItems().size() - 1);\r
- ((UIEventChartContextMenuItem) eventListItem).setChartSeriesList(chart\r
- .getSeriesList());\r
- ((UIEventChartContextMenuItem) eventListItem).setStartIndexList(startIndexList);\r
- ((UIEventChartContextMenuItem) eventListItem).setEndIndexList(endIndexList);\r
-\r
- eventListItem.setEnabled(true);\r
- }\r
-\r
- return;\r
- }\r
-\r
- boolean bShift = false;\r
- if ((e.stateMask & SWT.SHIFT) != 0) {\r
- bShift = true;\r
- }\r
-\r
- if (plot instanceof DAScreenshotChartPlot) {\r
- DAChartSeries series = chart.getSeries(0);\r
- if (series != null) {\r
- int index = series.getPrevIndexByXvalue(eventTime);\r
- if (index >= 0 && index < series.getSeriesItemList().size()) {\r
- DAChartSeriesItem item = series.getSeriesItemList().get(index);\r
- double itemTime = item.getX();\r
- int imageWidth = item.getImage().getBounds().width;\r
- double imageRightTime = itemTime + plot.getXFromXPixel(imageWidth)\r
- - plot.getVisibleStartX();\r
-\r
- if (eventTime > itemTime && eventTime < imageRightTime) {\r
- if (bShift == true && intervalMarker.getStartVal() != -1) {\r
- if (baseTime > eventTime) {\r
- intervalMarker.setInterval(eventTime, baseTime);\r
- } else {\r
- intervalMarker.setInterval(baseTime, eventTime);\r
- }\r
- } else {\r
- intervalMarker.setInterval(itemTime, eventTime);\r
- baseTime = itemTime;\r
- }\r
- } else {\r
- if (bShift == true && intervalMarker.getStartVal() != -1) {\r
- if (baseTime > eventTime) {\r
- intervalMarker.setInterval(eventTime, baseTime);\r
- } else {\r
- intervalMarker.setInterval(baseTime, eventTime);\r
- }\r
- } else {\r
- intervalMarker.setInterval(eventTime, eventTime);\r
- baseTime = eventTime;\r
- }\r
- }\r
- } else {\r
- if (bShift == true && intervalMarker.getStartVal() != -1) {\r
- if (baseTime > eventTime) {\r
- intervalMarker.setInterval(eventTime, baseTime);\r
- } else {\r
- intervalMarker.setInterval(baseTime, eventTime);\r
- }\r
- } else {\r
- intervalMarker.setInterval(eventTime, eventTime);\r
- baseTime = eventTime;\r
- }\r
- }\r
- }\r
-\r
- DAChart chartWidget = ((ScreenshotChart) TimelineChartManager.getInstance().getChartInstance(\r
- TimelineConstants.CHART_TYPE_SCREENSHOT)).getChart();\r
- DAScreenshotChartPlot screenshotChartPlot = (DAScreenshotChartPlot) chartWidget.getPlot();\r
- screenshotChartPlot.setSelectedImageIndex(getHighlightedImageIndex(screenshotChartPlot,\r
- chartWidget.getSeriesList(), e.x));\r
- } else {\r
- if (bShift == true && intervalMarker.getStartVal() != -1) {\r
- if (baseTime > eventTime) {\r
- intervalMarker.setInterval(eventTime, baseTime);\r
- } else {\r
- intervalMarker.setInterval(baseTime, eventTime);\r
- }\r
- } else {\r
- intervalMarker.setInterval(eventTime, eventTime);\r
- baseTime = eventTime;\r
- }\r
- }\r
-\r
- chart.redraw();\r
- }\r
-}\r
*
* Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact:
+ * Contact:
* Dongkye Lee <dongkyu6.lee@samsung.com>
* Jaeyong Lee <jae-yong.lee@@samsung.com>
* Gihun Chang <gihun.chang@@samsung.com>
* 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.
- *
+ *
*/
package org.tizen.dynamicanalyzer.ui.memory.data;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.nio.charset.StandardCharsets;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
-import java.util.Map;
-import java.util.Scanner;
-import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
-import org.tizen.dynamicanalyzer.common.DAState;
import org.tizen.dynamicanalyzer.common.Global;
-import org.tizen.dynamicanalyzer.constant.CommonConstants;
import org.tizen.dynamicanalyzer.database.DBInserter;
import org.tizen.dynamicanalyzer.database.IResultSet;
-import org.tizen.dynamicanalyzer.model.TableInput;
-import org.tizen.dynamicanalyzer.model.TreeInput;
-import org.tizen.dynamicanalyzer.nl.MemoryPageLabels;
-import org.tizen.dynamicanalyzer.project.Project;
import org.tizen.dynamicanalyzer.protocol.Protocol;
import org.tizen.dynamicanalyzer.protocol.ProtocolConstants;
-import org.tizen.dynamicanalyzer.setting.FlatPreferences;
-import org.tizen.dynamicanalyzer.setting.SettingDataManager;
import org.tizen.dynamicanalyzer.swap.logparser.LogPackage;
import org.tizen.dynamicanalyzer.swap.logparser.Logs;
import org.tizen.dynamicanalyzer.swap.logparser.PageDataManager;
import org.tizen.dynamicanalyzer.swap.model.data.LogData;
import org.tizen.dynamicanalyzer.swap.model.data.MemoryData;
-import org.tizen.dynamicanalyzer.ui.memory.table.MemoryPersistentAllocationsTable;
-import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
-import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat;
import org.tizen.dynamicanalyzer.util.Logger;
-import org.tizen.dynamicanalyzer.utils.Formatter;
+/**
+ * Process {@link ProtocolConstants#MSG_PROBE_MEMORY} messages and fill alloc and free db tables.
+ */
public class HeapDataManager extends PageDataManager {
-
- /**
- * Class representing basic SQL query executed by {@link HeapDataManager}.
- */
- private static class Query {
- /**
- * Start time of selected time range.
- */
- public long startTime;
- /**
- * End time of selected time range.
- */
- public long endTime;
- /**
- * String representation of selected PIDs.
- */
- public String pidString;
-
- /**
- * Default constructor.
- */
- public Query() {
- clear();
- }
-
- /**
- * Constructs new instance with given time range.
- *
- * @param startTime start time of selected time range
- * @param endTime end time of selected time range
- */
- public Query(long startTime, long endTime) {
- this.startTime = startTime;
- this.endTime = endTime;
- this.pidString = getTargetPIDString();
- }
-
- /**
- * Resets values of all fields to defaults.
- */
- public void clear() {
- startTime = -1L;
- endTime = -1L;
- pidString = "";
- }
-
- /**
- * Auto-generated method.
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + (int) (endTime ^ (endTime >>> 32));
- result = prime * result + ((pidString == null) ? 0 : pidString.hashCode());
- result = prime * result + (int) (startTime ^ (startTime >>> 32));
- return result;
- }
-
- /**
- * Auto-generated method.
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (!(obj instanceof Query))
- return false;
- Query other = (Query) obj;
- if (endTime != other.endTime)
- return false;
- if (pidString == null) {
- if (other.pidString != null)
- return false;
- } else if (!pidString.equals(other.pidString))
- return false;
- if (startTime != other.startTime)
- return false;
- return true;
- }
-
- /**
- * Constructs string representation of currently selected PIDs.
- *
- * @return string representation of currently selected PIDs
- */
- private static String getTargetPIDString() {
- // TODO: move this method to some utility class and generalize all
- // SQL queries management.
-
- StringBuilder pidliststring = new StringBuilder();
- pidliststring.append(CommonConstants.OPEN_BRACKET);
-
- int targetPID = Toolbar.INSTANCE.getSelectedPid();
-
- if (targetPID > 0)
- pidliststring.append(targetPID);
- else
- for (int pid : Global.getProject().getProcessIDs()) {
- if (pidliststring.length() != 1)
- pidliststring.append(CommonConstants.COMMA);
-
- pidliststring.append(pid);
- }
-
- pidliststring.append(CommonConstants.CLOSE_BRACKET);
-
- return pidliststring.toString();
- }
- }
-
private static HeapDataManager instance = new HeapDataManager();
- private final int TOTAL_PID = -1;
-
private final int MEM_API_TYPE_ALLOC = 0;
private final int MEM_API_TYPE_FREE = 1;
-
- private final int PRESISTENT_SIZE_INDEX = 0;
- private final int PRESISTENT_COUNT_INDEX = 1;
- private final int FREE_COUNT_INDEX = 2;
- private final int TOTAL_SIZE_INDEX = 3;
-
- /**
- * Constant use for generation of unique selection indexes.
- */
- private final int MAX_LIBRARIES_PER_PID = 500;
private int REALLOC_ID;
-
+
private MemAllocDBTable allocateDBTable = new MemAllocDBTable();
private MemFreeDBTable freeDBTable = new MemFreeDBTable();
- private MemLSanTable lsanDBTable = new MemLSanTable();
private DBInserter allocateDBInserter = makeInserter(allocateDBTable);
private DBInserter freeDBInserter = makeInserter(freeDBTable);
- private DBInserter lsanDBInserter = makeInserter(lsanDBTable);
-
- private ArrayList<List<Object>> memoryAllocDataList = new ArrayList<List<Object>> ();
- private ArrayList<List<Object>> memoryfreeDataList = new ArrayList<List<Object>> ();
-
- private volatile List<TableInput> persistentAllocsTableInput = new ArrayList<TableInput>();
- private volatile List<TableInput> leaksTableInput = new ArrayList<TableInput>();
- private volatile List<TreeInput> statisticsTreeInput = new ArrayList<TreeInput>();
-
- private List<List<Object>> preAllocDataList = new ArrayList<List<Object>>();
- private List<List<Object>> preFreeDataList = new ArrayList<List<Object>>();
- private List<List<Object>> preLeaksAllocDataList = new ArrayList<List<Object>>();
- private List<List<Object>> preLeaksFreeDataList = new ArrayList<List<Object>>();
-
- private HashSet<Long> addressMap = new HashSet<Long> ();
-
- private Query lastFullAllocsQuery = new Query();
- private Query lastLeaksQuery = new Query();
-
+
+ private List<List<Object>> memoryAllocDataList;
+ private List<List<Object>> memoryfreeDataList;
+
public static HeapDataManager getInstance() {
return instance;
}
-
- public void clear() {
- memoryAllocDataList.clear();
- memoryfreeDataList.clear();
-
- addressMap.clear();
-
- persistentAllocsTableInput.clear();
- leaksTableInput.clear();
- statisticsTreeInput.clear();
-
- preAllocDataList.clear();
- preFreeDataList.clear();
- preLeaksAllocDataList.clear();
- preLeaksFreeDataList.clear();
-
- lastFullAllocsQuery.clear();
- lastLeaksQuery.clear();
- }
@Override
protected void makeData(LogPackage pack) {
REALLOC_ID = Global.getFunctionID("realloc");
-
- Logs allocatedlogs = getLogsFromLogPackage(pack, ProtocolConstants.MSG_PROBE_MEMORY);
-
- makeHeapData(allocatedlogs);
- }
-
- /**
- * Request MEM_ALLOC_DB for row, where sequence number equals to specified
- * with {@code seqNum}. Report error, if data are corrupted.
- *
- * @param seqNum specified sequence number
- * @return Row data if exist and unique, or null otherwise
- */
- public List<Object> getAllocationRowBySeqFromDB(long seqNum) {
- String where = "WHERE SEQUENCE_NUMBER = " + Long.toString(seqNum);
- List<List<Object>> queryResult = allocateDBTable.selectRequiredColumns(where);
- if (queryResult.size() != 1) {
- Logger.error("Stored data was corrupted!");
- return null;
- }
-
- return queryResult.get(0);
- }
-
- /**
- * Request MEM_ALLOC_DB for ALLOCATOR_ADDRESS value from row with specified sequence number
- * @param seqNum requested sequence number
- * @return allocator's address as Long value or 0 is address couldn't be read from table
- */
- public Long getAllocatorAddrBySeqFromDB(long seqNum) {
- if (!isAllocatorAddrSupported()) return 0L;
- String where = "WHERE SEQUENCE_NUMBER = " + Long.toString(seqNum);
- final String columnName = MemAllocDBTable.COLUMN.ALLOCATOR_ADDRESS.name;
- List<List<Object>> queryResult = allocateDBTable.selectData(
- new ArrayList<String>(Arrays.asList(columnName)), where,
- new IResultSet() {
- @Override
- public List<Object> extractDataFromResultSet(ResultSet rs) {
- List<Object> row = new ArrayList<Object>();
- try {
- if (rs.getMetaData().getColumnCount() > 0)
- row.add(Long.valueOf(rs.getLong(1)));
- else
- row.add(Long.valueOf(0));
- } catch (SQLException e) {
- Logger.exception(e);
- }
- return row;
- }
- });
- if (queryResult.size() != 1) {
- Logger.warning("Could't extract " + columnName + " for seq#" + seqNum + " from "
- + MemAllocDBTable.TABLENAME);
- return 0L;
- }
- return (Long) queryResult.get(0).get(0);
- }
-
- /**
- * Selects all data from basic columns of {@link MemAllocDBTable} using
- * specified {@code query} and optionally filters leaks depending on
- * {@code onlyLeaks} argument.
- *
- * @param query {@link Query} instance
- * @param onlyLeaks whether only leaks data should be selected
- * @return selected data from database
- */
- private List<List<Object>> getAllocationDataFromDB(Query query, boolean onlyLeaks) {
- String where = getTimeWhereQuery(query, MemAllocDBTable.COLUMN.ALLOCATED_TIME.name,
- onlyLeaks);
- where += " ORDER BY " + MemAllocDBTable.COLUMN.SEQUENCE_NUMBER.name;
-
- List<List<Object>> queryResult = allocateDBTable.selectBasicColumns(where);
-
- return queryResult != null ? queryResult : new ArrayList<List<Object>>();
- }
-
- /**
- * Selects all data from basic columns of {@link MemFreeDBTable} using
- * specified {@code query} and optionally filters leaks depending on
- * {@code onlyLeaks} argument.
- *
- * @param query {@link Query} instance
- * @param onlyLeaks whether only leaks data should be selected
- * @return selected data from database
- */
- private List<List<Object>> getFreeDataFromDB(Query query, boolean onlyLeaks) {
- String where = getTimeWhereQuery(query, MemFreeDBTable.COLUMN.FREE_TIME.name, onlyLeaks);
- where += " ORDER BY " + MemFreeDBTable.COLUMN.SEQUENCE_NUMBER.name;
-
- List<List<Object>> queryResult = freeDBTable.selectBasicColumns(where);
-
- return queryResult != null ? queryResult : new ArrayList<List<Object>>();
- }
-
- /**
- * Calculates and caches data for 'Persistent Allocations' or 'Leaks' table
- * depending on {@code onlyLeaks} argument.
- *
- * @param onlyLeaks whether only leaks data should be cached
- */
- public void makeWholePersistentAllocsData(boolean onlyLeaks) {
- if(DAState.isRunning() == true) {
- return;
- }
-
- List<List<Object>> allocDataList = null;
-
- allocDataList = remainedAllocatedListForRange(0L, 0L, onlyLeaks);
-
- if (allocDataList == null || allocDataList.size() == 0)
- return;
-
- int index = 0;
- int size = allocDataList.size();
- List<TableInput> output = new ArrayList<TableInput>();
-
- for (int j = 0; j < size; j++) {
- List<Object> iAllocData = allocDataList.get(j);
- TableInput input = makePersistentAllocsTableInput(iAllocData, index++, onlyLeaks);
- if (input != null)
- output.add(input);
- }
-
- if (onlyLeaks)
- leaksTableInput = output;
- else
- persistentAllocsTableInput = output;
- }
-
- /**
- * Constructs TreeInput list for MemoryStatisticsTable based on selected
- * time range (0 as start and end time means whole range).
- *
- * @param startTime
- * start time of selected range
- * @param endTime
- * end time of selected range
- */
- public void makeStatisticsData(long startTime, long endTime) {
- Query query = new Query(startTime, endTime);
- Map<Integer, Map<Integer, List<Object>>> staticdatas = remainedAllocStaticData(query);
-
- int index = 0;
- List<TreeInput> output = new ArrayList<TreeInput>();
-
- // for each PID
- for (Map.Entry<Integer, Map<Integer, List<Object>>> elem : staticdatas.entrySet()) {
- long persistentSizeForPid = 0;
- long persistentCountForPid = 0;
- long freeCountForPid = 0;
- long totalSizeForPid = 0;
-
- List<TreeInput> children = new ArrayList<TreeInput>();
-
- // calculate initial selection index for pid
- if (elem.getKey() == TOTAL_PID) {
- index = 0;
- } else {
- index = elem.getKey() * MAX_LIBRARIES_PER_PID;
- }
-
- int parentIndex = index++;
-
- // for each library
- for (Map.Entry<Integer, List<Object>> libEntry : elem.getValue().entrySet()) {
- String apiName = Global.getLibraryName(libEntry.getKey());
- TreeInput staticInput = makeTreeInputForDatas(apiName, false,
- libEntry.getValue(), index++);
-
- if (staticInput == null)
- continue;
-
- children.add(staticInput);
-
- persistentSizeForPid += (Long) libEntry.getValue().get(0);
- persistentCountForPid += (Long) libEntry.getValue().get(1);
- freeCountForPid += (Long) libEntry.getValue().get(2);
- totalSizeForPid += (Long) libEntry.getValue().get(3);
- }
-
- List<Object> total = new ArrayList<Object>();
-
- total.add(persistentSizeForPid);
- total.add(persistentCountForPid);
- total.add(freeCountForPid);
- total.add(totalSizeForPid);
- total.add(persistentCountForPid + freeCountForPid);
-
- TreeInput parent;
- if (elem.getKey() == TOTAL_PID) {
- parent = makeTreeInputForDatas("Total", false, total, parentIndex);
- } else {
- parent = makeTreeInputForDatas(elem.getKey().toString(), true, total, parentIndex);
- }
-
- if (parent == null)
- continue;
-
- parent.getChildren().addAll(children);
- output.add(parent);
- }
-
- statisticsTreeInput = output;
- }
-
- /**
- * Gets data for 'Persistent Allocations' table.
- *
- * @return list of {@link TableInput}
- */
- public List<TableInput> getPersistentAllocsTableInput() {
- return persistentAllocsTableInput;
- }
-
- /**
- * Gets data for 'Leaks' table.
- *
- * @return list of {@link TableInput}
- */
- public List<TableInput> getLeaksTableInput() {
- return leaksTableInput;
- }
-
- public List<TreeInput> getStatisticsTreeInput() {
- return statisticsTreeInput;
- }
-
- private Map<Integer, Map<Integer, List<Object>>> remainedAllocStaticData(Query query) {
- updateFullAllocCache(query);
- return makeRemainedAllocatedStatic(preAllocDataList, preFreeDataList);
- }
-
- public List<List<Object>> remainedAllocatedListForRange(long startTime, long endTime,
- boolean onlyLeaks) {
- Query query = new Query(startTime, endTime);
- return remainedAllocatedListForRange(query, onlyLeaks);
- }
-
- private List<List<Object>> remainedAllocatedListForRange(Query query, boolean onlyLeaks) {
- if (onlyLeaks) {
- updateLeaksCache(query);
- return makeRemainedAllocatedList(preLeaksAllocDataList, preLeaksFreeDataList);
- }
-
- updateFullAllocCache(query);
- return makeRemainedAllocatedList(preAllocDataList, preFreeDataList);
- }
-
- /**
- * Updates library entry with id equal to <code>binaryId</code> in given
- * map. It increases allocated and total size by <code>allocSize</code> and
- * increments allocated count.
- *
- * @param libStatisticMap
- * statistics map for libraries
- * @param binaryId
- * library id
- * @param allocSize
- * size of allocation
- */
- private void updateStatisticDataAllocs(Map<Integer, List<Object>> libStatisticMap, int binaryId, long allocSize) {
- if (libStatisticMap.containsKey(binaryId)) {
- List<Object> libstaticdata = libStatisticMap.get(binaryId);
-
- libstaticdata.set(PRESISTENT_SIZE_INDEX, (Long) libstaticdata.get(PRESISTENT_SIZE_INDEX) + allocSize);
- libstaticdata.set(PRESISTENT_COUNT_INDEX, (Long) libstaticdata.get(PRESISTENT_COUNT_INDEX) + 1);
- libstaticdata.set(TOTAL_SIZE_INDEX, (Long) libstaticdata.get(TOTAL_SIZE_INDEX) + allocSize);
-
- libStatisticMap.put(binaryId, libstaticdata);
- } else {
- /*
- * 0: allocated size
- * 1: allocated count
- * 2: free count
- * 3: total size
- */
- libStatisticMap.put(binaryId, Arrays.asList((Object) allocSize, 1l, 0l, allocSize));
- }
- }
-
- /**
- * Updates library entry with id equal to <code>binaryId</code> in given
- * map. It decreases allocated size by <code>freeSize</code>, increments
- * free count and decrements persistent count.
- *
- * @param libStatisticMap
- * statistics map for libraries
- * @param binaryId
- * library id
- * @param freeSize
- * size of freed allocation
- */
- private void updateStatisticDataFrees(Map<Integer, List<Object>> libStatisticMap, int binaryId, long freeSize) {
- if (libStatisticMap.containsKey(binaryId)) {
- List<Object> libstaticdata = libStatisticMap.get(binaryId);
-
- libstaticdata.set(PRESISTENT_SIZE_INDEX, (Long) libstaticdata.get(PRESISTENT_SIZE_INDEX) - freeSize);
- libstaticdata.set(PRESISTENT_COUNT_INDEX, (Long) libstaticdata.get(PRESISTENT_COUNT_INDEX) - 1);
- libstaticdata.set(FREE_COUNT_INDEX, (Long) libstaticdata.get(FREE_COUNT_INDEX) + 1);
-
- libStatisticMap.put(binaryId, libstaticdata);
- }
- }
- /**
- * Constructs data map for Statistics table.
- *
- * @param allocData
- * data from MEM_ALLOC_DB database table
- * @param freeData
- * data from MEM_FREE_DB database table
- * @return constructed map
- */
- private Map<Integer, Map<Integer, List<Object>>> makeRemainedAllocatedStatic(List<List<Object>> allocData,
- List<List<Object>> freeData) {
- Map<Long, List<List<Object>>> addressMap = new HashMap<Long, List<List<Object>>>();
- Map<Integer, Map<Integer, List<Object>>> pidStatisticMap = new HashMap<Integer, Map<Integer, List<Object>>>();
-
- // 'Total' entry
- Map<Integer, List<Object>> libStatisticMapTotal = new HashMap<Integer, List<Object>>();
- pidStatisticMap.put(TOTAL_PID, libStatisticMapTotal);
-
- int allocDataSize = allocData.size();
- for (int j = 0; j < allocDataSize; j++) {
- List<Object> iAllocData = allocData.get(j);
-
- long address = (Long) iAllocData.get(MemAllocDBTable.BASIC_COLUMN.ALLOCATED_ADDRESS.index);
- long alloctime = (Long) iAllocData.get(MemAllocDBTable.BASIC_COLUMN.ALLOCATED_TIME.index);
- long allocSize = (Long) iAllocData.get(MemAllocDBTable.BASIC_COLUMN.ALLOCATED_MEMORY_SIZE.index);
- int binaryId = (Integer) iAllocData.get(MemAllocDBTable.BASIC_COLUMN.CALLER_LIBRARY_ID.index);
- int pid = (Integer) iAllocData.get(MemAllocDBTable.BASIC_COLUMN.PID.index);
-
- if(!addressMap.containsKey(address)) {
- List<List<Object>> newlist = new ArrayList<List<Object>>();
- addressMap.put(address, newlist);
- }
-
- List<Object> onedata = new ArrayList<Object>();
- onedata.add(alloctime);
- onedata.add(allocSize);
- onedata.add(binaryId);
-
- addressMap.get(address).add(onedata);
-
- if (!pidStatisticMap.containsKey(pid))
- pidStatisticMap.put(pid, new HashMap<Integer, List<Object>>());
-
- updateStatisticDataAllocs(pidStatisticMap.get(pid), binaryId, allocSize);
- updateStatisticDataAllocs(libStatisticMapTotal, binaryId, allocSize);
- }
-
- for (int i = 0; i < freeData.size(); i++) {
- List<Object> iFreeData = freeData.get(i);
- long address = (Long) iFreeData.get(MemFreeDBTable.BASIC_COLUMN.ALLOCATED_ADDRESS.index);
- long freetime = (Long) iFreeData.get(MemFreeDBTable.BASIC_COLUMN.FREE_TIME.index);
- int pid = (int) iFreeData.get(MemFreeDBTable.BASIC_COLUMN.PID.index);
- Map<Integer, List<Object>> libStatisticMapPid = pidStatisticMap.get(pid);
-
- if(addressMap.containsKey(address)) {
- int size = addressMap.get(address).size();
-
- for(int removeindex = 0; removeindex < size ; removeindex++) {
- List<Object> onedata = addressMap.get(address).get(removeindex);
-
- if((Long) onedata.get(0) <= freetime) {
- long freeSize = (Long) onedata.get(1);
- int binaryId = (Integer) onedata.get(2);
-
- updateStatisticDataFrees(libStatisticMapPid, binaryId, freeSize);
- updateStatisticDataFrees(libStatisticMapTotal, binaryId, freeSize);
-
- addressMap.get(address).remove(removeindex);
- break;
- }
- }
- }
- }
-
- return pidStatisticMap;
- }
-
- private List<List<Object>> makeRemainedAllocatedList(List<List<Object>> allocData, List<List<Object>> freeData) {
- Map<Long, List<Long>> addressMap = new HashMap<Long, List<Long>>();
- List<List<Object>> output = new ArrayList<List<Object>>();
-
- for (int i = 0; i < freeData.size(); i++) {
- List<Object> iFreeData = freeData.get(i);
-
- long freetime = (Long) iFreeData.get(MemFreeDBTable.BASIC_COLUMN.FREE_TIME.index);
- long address = (Long) iFreeData.get(MemFreeDBTable.BASIC_COLUMN.ALLOCATED_ADDRESS.index);
-
- if(!addressMap.containsKey(address)) {
- List<Long> newlist = new ArrayList<Long>();
- addressMap.put(address, newlist);
- }
-
- addressMap.get(address).add(freetime);
- }
-
- int allocDataSize = allocData.size();
- for (int i = 0; i < allocDataSize; i++) {
- List<Object> iAllocData = allocData.get(i);
- boolean live = true;
- long alloctime = (Long) iAllocData.get(MemAllocDBTable.BASIC_COLUMN.ALLOCATED_TIME.index);
- long address = (Long) iAllocData.get(MemAllocDBTable.BASIC_COLUMN.ALLOCATED_ADDRESS.index);
-
- if(addressMap.containsKey(address)) {
- int size = addressMap.get(address).size();
- for(int j = 0; j < size ; j++) {
- Long freetime = addressMap.get(address).get(j);
-
- if(alloctime <= freetime) {
- live = false;
- addressMap.get(address).remove(j);
- break;
- }
- }
- }
-
- if(live == true) {
- output.add(iAllocData);
- }
- }
-
- return output;
- }
-
- /**
- * Returns text that should be displayed for table entry.
- *
- * @param apiName entry name
- * @param isProcess <code>true</code> if api denotes process pid entry
- * @return displayed text for entry
- */
- private String getDisplayedEntryName(String apiName, boolean isProcess) {
- if (isProcess) {
- return "PID #" + apiName;
- } else {
- if (apiName.equals(Global.getProject().getApplicationInfo().getExecPath()))
- return MemoryPageLabels.MEMORY_MAIN_EXCUTABLE;
- else
- return apiName;
- }
- }
-
- /**
- * Creates {@link TreeInput} entry for Statistics table.
- *
- * @param apiName name of entry
- * @param isProcess flag denotes whether this api name is a process entry or library entry
- * @param staticdata data in format of list of 4 long numbers
- * @param index entry index
- * @return created {@link TreeInput} entry
- */
- public TreeInput makeTreeInputForDatas(String apiName, boolean isProcess,
- List<Object> staticdata, int index) {
- DATableDataFormat tableData = new DATableDataFormat(index);
-
- List<String> text = new ArrayList<String>();
- List<Object> data = new ArrayList<Object>();
-
- if (staticdata == null) {
- Logger.error("No statistics data for '%d' entry!", apiName);
- return null;
- }
-
- String entryName = getDisplayedEntryName(apiName, isProcess);
-
- Long PByte = (Long) staticdata.get(0);
- Long PCount = (Long) staticdata.get(1);
- Long FCount = (Long) staticdata.get(2);
- Long TotalByte = (Long) staticdata.get(3);
- Long TotalCount = PCount + FCount;
-
- text.add(entryName); data.add(apiName);
- text.add(String.format("%,d", TotalCount)); data.add(TotalCount);
- text.add(String.format("%,d", FCount)); data.add(FCount);
- text.add(String.format("%,d", PCount)); data.add(PCount);
- text.add(Formatter.toByteFormat(TotalByte)); data.add(TotalByte);
- text.add(Formatter.toByteFormat(PByte)); data.add(PByte);
-
- tableData.getData().addAll(data);
- tableData.setObject(entryName);
-
- TreeInput output = new TreeInput();
- output.setText(text);
- output.setData(tableData);
-
- return output;
- }
-
- /**
- * Constructs {@link TableInput} for
- * {@link MemoryPersistentAllocationsTable} using specified allocation data,
- * index and adds a 'Leak' column data if {@code onlyLeaks} argument is set
- * to {@code false}.
- *
- * @param allocData data selected from {@link MemAllocDBTable}
- * @param index index of new {@link TableInput}
- * @param onlyLeaks whether new {@link TableInput} will be used in 'Leaks'
- * table, if set to {@code false}, 'Leak' column data will be
- * added
- * @return constructed instance of {@link TableInput} on success and
- * {@code null} otherwise
- */
- public TableInput makePersistentAllocsTableInput(List<Object> allocData, int index,
- boolean onlyLeaks) {
- DATableDataFormat tableData = new DATableDataFormat(index);
-
- List<String> text = new ArrayList<String>();
- List<Object> data = new ArrayList<Object>();
-
- if (allocData == null) {
- Logger.error("very strange case !!");
- return null;
- }
- // 0 : sequence number - hidden column for sorting
- Long seq = (Long) allocData.get(MemAllocDBTable.BASIC_COLUMN.SEQUENCE_NUMBER.index);
- text.add(Long.toString(seq));
- data.add(seq);
- // 1 : allocated time
- long time = (Long) allocData.get(MemAllocDBTable.BASIC_COLUMN.ALLOCATED_TIME.index);
- data.add(Long.valueOf(time));
- try {
- text.add(Formatter.toTimeFormat(time));
- } catch (NumberFormatException e) {
- Logger.exception(e);
- text.add(Long.toString(time));
- }
- // 2 : PID
- int pid = (Integer) allocData.get(MemAllocDBTable.BASIC_COLUMN.PID.index);
- text.add(Integer.toString(pid));
- data.add(pid);
- // 3 : TID
- int tid = (Integer) allocData.get(MemAllocDBTable.BASIC_COLUMN.TID.index);
- text.add(Integer.toString(tid));
- data.add(tid);
- // 4 : address
- Long address = (Long) allocData.get(MemAllocDBTable.BASIC_COLUMN.ALLOCATED_ADDRESS.index);
- text.add("0x" + Long.toHexString(address));
- data.add(address);
- // 5 : size
- Long size = (Long) allocData.get(MemAllocDBTable.BASIC_COLUMN.ALLOCATED_MEMORY_SIZE.index);
- text.add(Long.toString(size));
- data.add(size);
- // 6 : library name
- String libName = Global.getLibraryName((Integer)allocData.get(MemAllocDBTable.BASIC_COLUMN.CALLER_LIBRARY_ID.index));
- if (libName == null || libName.isEmpty()) {
- libName = AnalyzerConstants.UNKNOWN_LIB;
- }
-
- // Check if allocation was made from main binary
- Project project = Global.getProject();
- boolean isMainBinary = project != null && project.getApplicationInfo() != null
- && project.getApplicationInfo().getExecBinaryPath().equals(libName);
-
- // Filter leaks not from application binary
- if (onlyLeaks && !isMainBinary)
- return null;
-
- text.add(libName);
- data.add(libName);
- // 7 : api type
- int apiId = (Integer) allocData.get(MemAllocDBTable.BASIC_COLUMN.API_ID.index);
- String apiName = Global.getFunctionName(apiId);
- text.add(apiName);
- data.add(apiName);
-
- if (!onlyLeaks) {
- // 8 : leak
- boolean leak = false;
-
- if (isMainBinary && SettingDataManager.INSTANCE
- .isPreferenceSelected(FlatPreferences.LEAK_SANITIZER)) {
- updateLeaksCache(new Query(0L, 0L));
- leak = preLeaksAllocDataList.contains(allocData);
- }
-
- text.add(leak ? CommonConstants.YES : CommonConstants.EMPTY);
- data.add(leak ? CommonConstants.YES : CommonConstants.EMPTY);
- }
-
- tableData.setType(AnalyzerConstants.TYPE_TABLE_MEM_ALLOCATEDTRACE);
-
- TreeInput output = new TreeInput();
- output.setText(text);
- tableData.getData().addAll(data);
- output.setData(tableData);
+ Logs allocatedlogs = getLogsFromLogPackage(pack, ProtocolConstants.MSG_PROBE_MEMORY);
- return output;
+ makeHeapData(allocatedlogs);
}
-
- /**
- * Parses given LeakSanitizer report file.
- *
- * @param filepath path to pulled report file on host
- */
- public void parseLSanReportFile(String filepath) {
- Scanner scanner = null;
- List<List<Object>> lsanDataList = new ArrayList<List<Object>>();
-
- String parsingErrorMsg = "Failed to parse file: " + filepath;
- try {
- scanner = new Scanner(new FileInputStream(new File(filepath)), StandardCharsets.US_ASCII.name());
-
- // loop through lines
- while (scanner.hasNextLine()) {
- /**
- * There are 3 long fields separated by space character on each
- * line in data file in following format:
- *
- * <allocation address> <chunk size> <first 4 bytes in chunk>
- */
- String[] fields = scanner.nextLine().split(" ");
- if (fields.length != 3) {
- Logger.error(parsingErrorMsg);
- scanner.close();
- return;
- }
-
- List<Object> row = new ArrayList<Object>();
- for (String field : fields)
- row.add(Long.parseLong(field));
-
- lsanDataList.add(row);
- }
-
- if (!lsanDataList.isEmpty())
- lsanDBInserter.pushData(lsanDataList);
-
- } catch (FileNotFoundException e) {
- Logger.warning("File was not found: " + filepath);
-
- } catch (NumberFormatException e) {
- Logger.error(parsingErrorMsg + CommonConstants.NEW_LINE + e.getMessage());
-
- } finally {
- if (scanner != null)
- scanner.close();
- }
- }
-
private Logs getLogsFromLogPackage(LogPackage logPack, int logCenterConstants) {
Logs logs = logPack.getLogs(logCenterConstants);
if (null == logs || logs.getRawLogs().size() == 0) {
return null;
}
-
+
return logs;
}
Protocol projectProtocol = Global.getCurrentProtocol();
return (projectProtocol.getVersionNum() >= Protocol.VERSION_42.getVersionNum());
}
+
/**
* Extract allocator's address from SWAP message
+ *
* @param logData the SWAP message of MSG_PROBE_MEMORY type saved in {@link MemoryData} format
* @return allocator's address as long value or 0 if protocol doesn't support such data
*/
return allocatorAddress;
}
-
private void makeHeapData(Logs alloclogs) {
- List<LogData> memoryLogList = alloclogs == null ? null : alloclogs.getRawLogs();
-
- if (memoryLogList == null) {
+ if (alloclogs == null)
return;
- }
-
- Collections.sort(memoryLogList, new AscCompare());
-
- int size = memoryLogList.size();
- for (int i = 0; i < size; i++) {
- MemoryData logData = (MemoryData) memoryLogList.get(i);
-
+
+ memoryAllocDataList = new ArrayList<>();
+ memoryfreeDataList = new ArrayList<>();
+
+ for (LogData data : alloclogs.getRawLogs()) {
+ MemoryData logData = (MemoryData) data;
long errorNo = logData.getErrno();
-
+
if (errorNo != 0) {
continue;
}
int pid = logData.getPid();
long calleraddress = logData.getCallerPcAddr();
int binaryid = Global.getBinaryID(pid, logData.getTime(), calleraddress);
-
- if(MEM_API_TYPE_ALLOC == memApiType) {
+
+ if (MEM_API_TYPE_ALLOC == memApiType) {
long allocatorAddr = getAllocatorAddress(logData);
makeAllocData(logData, binaryid, allocatorAddr);
- }
- else if(MEM_API_TYPE_FREE == memApiType) {
+ } else if (MEM_API_TYPE_FREE == memApiType) {
makeFreeData(logData, binaryid);
}
- else{
- continue;
- }
}
- if (memoryAllocDataList.size() > 0) {
- @SuppressWarnings("unchecked")
- List<List<Object>> mList = (List<List<Object>>) memoryAllocDataList.clone();
- memoryAllocDataList.clear();
-
- allocateDBInserter.pushData(mList);
+ if (!memoryAllocDataList.isEmpty()) {
+ allocateDBInserter.pushData(memoryAllocDataList);
}
- if (memoryfreeDataList.size() > 0) {
- @SuppressWarnings("unchecked")
- List<List<Object>> fList = (List<List<Object>>) memoryfreeDataList.clone();
- memoryfreeDataList.clear();
-
- freeDBInserter.pushData(fList);
+ if (!memoryfreeDataList.isEmpty()) {
+ freeDBInserter.pushData(memoryfreeDataList);
}
}
-
+
private void makeAllocData(MemoryData mData, int binaryid, long allocatorAddr) {
- ArrayList<Object> dbAllocData = new ArrayList<Object>();
-
+ List<Object> dbAllocData = new ArrayList<>();
+
int pid = mData.getPid();
int tid = mData.getTid();
long address = mData.getAddress();
long mallocsize = mData.getSize();
-
- if(REALLOC_ID == mData.getApiId()) {
+
+ if (REALLOC_ID == mData.getApiId()) {
try {
Long freeaddress = Long.parseLong(mData.getArgs().replace("0x", "").split(",")[0], 16);
makeFreeData(mData, freeaddress, binaryid);
- }
- catch(NumberFormatException ex) {
+ } catch (NumberFormatException ex) {
Logger.warning("realloc address invalide : %s", mData.getArgs());
}
}
-
+
dbAllocData.add(Long.valueOf(mData.getSeq()));
dbAllocData.add(Integer.valueOf(pid));
dbAllocData.add(Integer.valueOf(tid));
dbAllocData.add(Integer.valueOf(mData.getMsgID()));
dbAllocData.add(Long.valueOf(mallocsize));
dbAllocData.add(allocatorAddr == 0 ? null : Long.valueOf(allocatorAddr));
- memoryAllocDataList.add(dbAllocData);
- //if(!addressMap.contains(address)) {
- // addressMap.add(address);
- //}
+ memoryAllocDataList.add(dbAllocData);
}
private void makeFreeData(MemoryData mData, int binaryid) {
makeFreeData(mData, mData.getAddress(), binaryid);
}
-
+
private void makeFreeData(MemoryData mData, Long address, int binaryid) {
- //if(!addressMap.contains(address)) {
- // return;
- //}
-
- ArrayList<Object> dbFreeData = new ArrayList<Object>();
-
+ ArrayList<Object> dbFreeData = new ArrayList<>();
+
int pid = mData.getPid();
-
+
dbFreeData.add(Long.valueOf(mData.getSeq()));
dbFreeData.add(Integer.valueOf(pid));
dbFreeData.add(Integer.valueOf(mData.getMsgID()));
}
/**
- * Constructs string representation of query conditions: time range, pid
- * list and optional INNER JOIN with {@link MemLSanTable} if
- * {@code onlyLeaks} is set as {@code true}.
+ * Request MEM_ALLOC_DB for row, where sequence number equals to specified
+ * with {@code seqNum}. Report error, if data are corrupted.
*
- * @param query {@link Query} instance
- * @param timecolumn name of the column used for time data
- * @param onlyLeaks whether result should filtered by data from
- * {@link MemLSanTable}
- * @return string representation of query conditions
+ * @param seqNum specified sequence number
+ * @return Row data if exist and unique, or null otherwise
*/
- private String getTimeWhereQuery(Query query, String timecolumn, boolean onlyLeaks) {
- StringBuilder where = new StringBuilder();
- if (onlyLeaks) {
- String table1 = "table1";
- String table2 = "table2";
- String joinCol = MemLSanTable.COLUMN.ALLOCATED_ADDRESS.name;
- String join = String.format("%s INNER JOIN %s %s ON %s.%s = %s.%s ", table1,
- MemLSanTable.TABLENAME, table2, table1, joinCol, table2, joinCol);
- where.append(join);
- }
-
- where.append("WHERE ");
- if (query.startTime != 0 || query.endTime != 0) {
- String timeRange = String.format("%s BETWEEN %s AND %s AND ", timecolumn,
- Long.toString(query.startTime), Long.toString(query.endTime));
- where.append(timeRange);
+ public List<Object> getAllocationRowBySeqFromDB(long seqNum) {
+ String where = "WHERE SEQUENCE_NUMBER = " + Long.toString(seqNum);
+ List<List<Object>> queryResult = allocateDBTable.selectRequiredColumns(where);
+ if (queryResult.size() != 1) {
+ Logger.error("Stored data was corrupted!");
+ return null;
}
- where.append(String.format("PID IN %s", query.pidString));
-
- return where.toString();
- }
-
- /**
- * Selects and caches all data from {@link MemAllocDBTable} and
- * {@link MemFreeDBTable}, using specified {@code query} if it has changed
- * since the last time.
- *
- * @param query {@link Query} instance
- */
- private void updateFullAllocCache(Query query) {
- if (lastFullAllocsQuery.equals(query))
- return;
-
- lastFullAllocsQuery = query;
-
- // TODO: Add check for data size to be loaded from data base.
- // If data size exceeds predefined limit - invoke DALimit.stopTraceAndOpenWarningDialog()
- preAllocDataList = getAllocationDataFromDB(lastFullAllocsQuery, false);
- preFreeDataList = getFreeDataFromDB(lastFullAllocsQuery, false);
+ return queryResult.get(0);
}
/**
- * Selects and caches all data from {@link MemAllocDBTable} and
- * {@link MemFreeDBTable} inner joined with {@link MemLSanTable}, using
- * specified {@code query} if it has changed since the last time.
+ * Request MEM_ALLOC_DB for ALLOCATOR_ADDRESS value from row with specified sequence number
*
- * @param query {@link Query} instance
+ * @param seqNum requested sequence number
+ * @return allocator's address as Long value or 0 is address couldn't be read from table
*/
- private void updateLeaksCache(Query query) {
- if (lastLeaksQuery.equals(query))
- return;
-
- lastLeaksQuery = query;
-
- // TODO: Add check for data size to be loaded from data base.
- // If data size exceeds predefined limit - invoke DALimit.stopTraceAndOpenWarningDialog()
- preLeaksAllocDataList = getAllocationDataFromDB(lastLeaksQuery, true);
- preLeaksFreeDataList = getFreeDataFromDB(lastLeaksQuery, true);
- }
-
- private static class AscCompare implements Comparator<LogData> {
-
- @Override
- public int compare(LogData arg0, LogData arg1) {
-
- return Long.compare(arg0.getSeq(), arg1.getSeq());
+ public Long getAllocatorAddrBySeqFromDB(long seqNum) {
+ if (!isAllocatorAddrSupported())
+ return 0L;
+ String where = "WHERE SEQUENCE_NUMBER = " + Long.toString(seqNum);
+ final String columnName = MemAllocDBTable.COLUMN.ALLOCATOR_ADDRESS.name;
+ List<List<Object>> queryResult = allocateDBTable.selectData(
+ new ArrayList<String>(Arrays.asList(columnName)), where,
+ new IResultSet() {
+ @Override
+ public List<Object> extractDataFromResultSet(ResultSet rs) {
+ List<Object> row = new ArrayList<>();
+ try {
+ if (rs.getMetaData().getColumnCount() > 0)
+ row.add(Long.valueOf(rs.getLong(1)));
+ else
+ row.add(Long.valueOf(0));
+ } catch (SQLException e) {
+ Logger.exception(e);
+ }
+ return row;
+ }
+ });
+ if (queryResult.size() != 1) {
+ Logger.warning("Could't extract " + columnName + " for seq#" + seqNum + " from "
+ + MemAllocDBTable.TABLENAME);
+ return 0L;
}
-
+ return (Long) queryResult.get(0).get(0);
}
-
}
--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Dongkye Lee <dongkyu6.lee@samsung.com>
+ * Jaeyong Lee <jae-yong.lee@@samsung.com>
+ * Gihun Chang <gihun.chang@@samsung.com>
+ *
+ * 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.
+ *
+ */
+
+package org.tizen.dynamicanalyzer.ui.memory.data;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
+import org.tizen.dynamicanalyzer.common.Global;
+import org.tizen.dynamicanalyzer.constant.CommonConstants;
+import org.tizen.dynamicanalyzer.database.SqlConnectionManager;
+import org.tizen.dynamicanalyzer.model.TableInput;
+import org.tizen.dynamicanalyzer.model.TreeInput;
+import org.tizen.dynamicanalyzer.nl.MemoryPageLabels;
+import org.tizen.dynamicanalyzer.project.Project;
+import org.tizen.dynamicanalyzer.setting.FlatPreferences;
+import org.tizen.dynamicanalyzer.setting.SettingDataManager;
+import org.tizen.dynamicanalyzer.ui.memory.data.util.PersistentAllocationsQuerySerializer;
+import org.tizen.dynamicanalyzer.ui.memory.data.util.Query;
+import org.tizen.dynamicanalyzer.ui.memory.data.util.QuerySerializer;
+import org.tizen.dynamicanalyzer.ui.memory.data.util.StatisticsQuerySerializer;
+import org.tizen.dynamicanalyzer.ui.memory.table.MemoryPersistentAllocationsTable;
+import org.tizen.dynamicanalyzer.ui.memory.table.MemoryStatisticsTable;
+import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat;
+import org.tizen.dynamicanalyzer.util.Logger;
+import org.tizen.dynamicanalyzer.utils.Formatter;
+
+/**
+ * Processes memory allocations data and provides data for displaying tables.
+ */
+public class HeapDataProcessor {
+ private static HeapDataProcessor instance = new HeapDataProcessor();
+
+ private final static int TOTAL_PID = -1;
+
+ /**
+ * Constant use for generation of unique selection indexes.
+ */
+ private final static int MAX_LIBRARIES_PER_PID = 500;
+
+ /**
+ * Query serializers
+ */
+ private PersistentAllocationsQuerySerializer persistentSerializer = new PersistentAllocationsQuerySerializer();
+ private StatisticsQuerySerializer statisticsSerializer = new StatisticsQuerySerializer();
+
+ /**
+ * Last query used to select leaks.
+ */
+ private Query lastCachedLeaksQuery = null;
+ /**
+ * Last query used to select persistent allocations.
+ */
+ private Query lastCachedPersistentQuery = null;
+ /**
+ * Last query used to select statistics.
+ */
+ private Query lastCachedStatisticsQuery = null;
+ /**
+ * Last data got from {@link #lastCachedLeaksQuery}.
+ */
+ private List<List<Object>> leaksCacheData = null;
+ /**
+ * Last data got from {@link #lastCachedPersistentQuery}.
+ */
+ private List<List<Object>> persistentCacheData = null;
+ /**
+ * Last data got from {@link #lastCachedStatisticsQuery}.
+ */
+ private Map<Integer, Map<Integer, List<Object>>> statisticsCacheData = null;
+
+ public static HeapDataProcessor getInstance() {
+ return instance;
+ }
+
+ /**
+ * Calculates data for 'Persistent Allocations' or 'Leaks' table based on specified query.
+ * (0 as start and end time means whole range).
+ *
+ * @param query parameters for data calculation
+ */
+ public List<TableInput> getTableInputPersistentAllocsData(Query query) {
+ List<List<Object>> allocDataList = null;
+ List<TableInput> output = new ArrayList<>();
+
+ allocDataList = remainedAllocatedListForRange(query);
+
+ if (allocDataList == null || allocDataList.size() == 0)
+ return output;
+
+ int index = 0;
+
+ for (int j = 0; j < allocDataList.size(); j++) {
+ List<Object> iAllocData = allocDataList.get(j);
+ TableInput input = makePersistentAllocsTableInput(iAllocData, index++, query.onlyLeaks);
+ if (input != null)
+ output.add(input);
+ }
+
+ return output;
+ }
+
+ /**
+ * Constructs TreeInput list for {@link MemoryStatisticsTable} based on specified query.
+ * (0 as start and end time means whole range).
+ */
+ public List<TreeInput> getTreeInputStatisticsData(Query query) {
+ Map<Integer, Map<Integer, List<Object>>> staticdatas = remainedAllocStaticData(query);
+
+ int index = 0;
+ List<TreeInput> output = new ArrayList<>();
+
+ // for each PID
+ for (Map.Entry<Integer, Map<Integer, List<Object>>> elem : staticdatas.entrySet()) {
+ long allocCountForPid = 0;
+ long freeCountForPid = 0;
+ long persistentCountForPid = 0;
+ long totalSizeForPid = 0;
+ long persistentSizeForPid = 0;
+
+ List<TreeInput> children = new ArrayList<>();
+
+ // calculate initial selection index for pid
+ if (elem.getKey() == TOTAL_PID) {
+ index = 0;
+ } else {
+ index = elem.getKey() * MAX_LIBRARIES_PER_PID;
+ }
+
+ int parentIndex = index++;
+
+ // for each library
+ for (Map.Entry<Integer, List<Object>> libEntry : elem.getValue().entrySet()) {
+ String apiName = Global.getLibraryName(libEntry.getKey());
+ TreeInput staticInput = makeTreeInputForStatistics(apiName, false,
+ libEntry.getValue(), index++);
+
+ if (staticInput == null)
+ continue;
+
+ children.add(staticInput);
+
+ allocCountForPid += (Long) libEntry.getValue().get(0);
+ freeCountForPid += (Long) libEntry.getValue().get(1);
+ persistentCountForPid += (Long) libEntry.getValue().get(2);
+ totalSizeForPid += (Long) libEntry.getValue().get(3);
+ persistentSizeForPid += (Long) libEntry.getValue().get(4);
+ }
+
+ List<Object> total = new ArrayList<>();
+
+ total.add(allocCountForPid);
+ total.add(freeCountForPid);
+ total.add(persistentCountForPid);
+ total.add(totalSizeForPid);
+ total.add(persistentSizeForPid);
+
+ TreeInput parent;
+ if (elem.getKey() == TOTAL_PID) {
+ parent = makeTreeInputForStatistics("Total", false, total, parentIndex);
+ } else {
+ parent = makeTreeInputForStatistics(elem.getKey().toString(), true, total, parentIndex);
+ }
+
+ if (parent == null)
+ continue;
+
+ parent.getChildren().addAll(children);
+ output.add(parent);
+ }
+
+ return output;
+ }
+
+ /**
+ * Get all statistics for range specified in query. (0 as start and end time means whole range).
+ *
+ * @return statistics data mapped by PID and library ID
+ */
+ private Map<Integer, Map<Integer, List<Object>>> remainedAllocStaticData(Query query) {
+ if (query.equals(lastCachedStatisticsQuery))
+ return statisticsCacheData;
+
+ lastCachedStatisticsQuery = query;
+ statisticsCacheData = makeRemainedAllocatedStatic(
+ executeQuery(statisticsSerializer, query));
+ return statisticsCacheData;
+ }
+
+ /**
+ * Get all persistent (remained) allocation for range specified in query.
+ * (0 as start and end time means whole range).
+ *
+ * @return list of allocation objects
+ */
+ public List<List<Object>> remainedAllocatedListForRange(Query query) {
+ if (query.onlyLeaks) {
+ if (query.equals(lastCachedLeaksQuery))
+ return leaksCacheData;
+ else {
+ lastCachedLeaksQuery = query;
+ leaksCacheData = executeQuery(persistentSerializer, query);
+ return leaksCacheData;
+ }
+ } else {
+ if (query.equals(lastCachedPersistentQuery))
+ return persistentCacheData;
+ else {
+ lastCachedPersistentQuery = query;
+ persistentCacheData = executeQuery(persistentSerializer, query);
+ return persistentCacheData;
+ }
+ }
+ }
+
+ /**
+ * Execute query in data base.
+ *
+ * @return list of fetched objects
+ */
+ private List<List<Object>> executeQuery(QuerySerializer serializer, Query query) {
+ List<List<Object>> result = SqlConnectionManager
+ .executeQuery(serializer.toSqlString(query));
+ return result != null ? result : Collections.emptyList();
+ }
+
+ /**
+ * Constructs data map for Statistics table.
+ *
+ * @param statisticsData data received from DB
+ * @return constructed map
+ */
+ private Map<Integer, Map<Integer, List<Object>>>
+ makeRemainedAllocatedStatic(List<List<Object>> statisticsData) {
+ Map<Integer, Map<Integer, List<Object>>> pidStatisticMap = new HashMap<>();
+
+ // 'Total' entry
+ Map<Integer, List<Object>> libStatisticMapTotal = new HashMap<>();
+ pidStatisticMap.put(TOTAL_PID, libStatisticMapTotal);
+
+ for (List<Object> row : statisticsData) {
+
+ if (row == null || row.size() != 7)
+ continue;
+
+ int pid = (Integer) row.get(0);
+ int binaryId = (Integer) row.get(1);
+
+ List<Object> tableData = new ArrayList<>();
+ tableData.add((Long) row.get(2));
+ tableData.add((Long) row.get(3));
+ tableData.add((Long) row.get(4));
+ tableData.add((Long) row.get(5));
+ tableData.add((Long) row.get(6));
+
+ if (!pidStatisticMap.containsKey(pid))
+ pidStatisticMap.put(pid, new HashMap<Integer, List<Object>>());
+
+ pidStatisticMap.get(pid).put(binaryId, tableData);
+ libStatisticMapTotal.put(binaryId, tableData);
+ }
+
+ return pidStatisticMap;
+ }
+
+ /**
+ * Returns text that should be displayed for table entry.
+ *
+ * @param apiName entry name
+ * @param isProcess <code>true</code> if api denotes process pid entry
+ * @return displayed text for entry
+ */
+ private String getDisplayedEntryName(String apiName, boolean isProcess) {
+ if (isProcess) {
+ return "PID #" + apiName;
+ } else {
+ if (apiName.equals(Global.getProject().getApplicationInfo().getExecPath()))
+ return MemoryPageLabels.MEMORY_MAIN_EXCUTABLE;
+ else
+ return apiName;
+ }
+ }
+
+ /**
+ * Creates {@link TreeInput} entry for Statistics table.
+ *
+ * @param apiName name of entry
+ * @param isProcess flag denotes whether this api name is a process entry or library entry
+ * @param statisticsData data in format of list of 5 long numbers
+ * @param index entry index
+ * @return created {@link TreeInput} entry
+ */
+ private TreeInput makeTreeInputForStatistics(String apiName, boolean isProcess,
+ List<Object> statisticsData, int index) {
+ DATableDataFormat tableData = new DATableDataFormat(index);
+
+ List<String> text = new ArrayList<>();
+ List<Object> data = new ArrayList<>();
+
+ if (statisticsData == null) {
+ Logger.error("No statistics data for '%d' entry!", apiName);
+ return null;
+ }
+
+ String entryName = getDisplayedEntryName(apiName, isProcess);
+
+ Long TotalCount = (Long) statisticsData.get(0);
+ Long FCount = (Long) statisticsData.get(1);
+ Long PCount = (Long) statisticsData.get(2);
+ Long TotalByte = (Long) statisticsData.get(3);
+ Long PByte = (Long) statisticsData.get(4);
+
+ text.add(entryName); data.add(apiName);
+ text.add(String.format("%,d", TotalCount)); data.add(TotalCount);
+ text.add(String.format("%,d", FCount)); data.add(FCount);
+ text.add(String.format("%,d", PCount)); data.add(PCount);
+ text.add(Formatter.toByteFormat(TotalByte)); data.add(TotalByte);
+ text.add(Formatter.toByteFormat(PByte)); data.add(PByte);
+
+ tableData.getData().addAll(data);
+ tableData.setObject(entryName);
+
+ TreeInput output = new TreeInput();
+ output.setText(text);
+ output.setData(tableData);
+
+ return output;
+ }
+
+ /**
+ * Constructs {@link TableInput} for
+ * {@link MemoryPersistentAllocationsTable} using specified allocation data,
+ * index and adds a 'Leak' column data if {@code onlyLeaks} argument is set
+ * to {@code false}.
+ *
+ * @param allocData data selected from {@link MemAllocDBTable}
+ * @param index index of new {@link TableInput}
+ * @param onlyLeaks whether new {@link TableInput} will be used in 'Leaks'
+ * table, if set to {@code false}, 'Leak' column data will be
+ * added
+ * @return constructed instance of {@link TableInput} on success and
+ * {@code null} otherwise
+ */
+ public TableInput makePersistentAllocsTableInput(List<Object> allocData, int index,
+ boolean onlyLeaks) {
+ DATableDataFormat tableData = new DATableDataFormat(index);
+
+ List<String> text = new ArrayList<>();
+ List<Object> data = new ArrayList<>();
+
+ if (allocData == null) {
+ Logger.error("very strange case !!");
+ return null;
+ }
+ // 0 : sequence number - hidden column for sorting
+ Long seq = (Long) allocData.get(MemAllocDBTable.BASIC_COLUMN.SEQUENCE_NUMBER.index);
+ text.add(Long.toString(seq));
+ data.add(seq);
+ // 1 : allocated time
+ long time = (Long) allocData.get(MemAllocDBTable.BASIC_COLUMN.ALLOCATED_TIME.index);
+ data.add(Long.valueOf(time));
+ try {
+ text.add(Formatter.toTimeFormat(time));
+ } catch (NumberFormatException e) {
+ Logger.exception(e);
+ text.add(Long.toString(time));
+ }
+ // 2 : PID
+ int pid = (Integer) allocData.get(MemAllocDBTable.BASIC_COLUMN.PID.index);
+ text.add(Integer.toString(pid));
+ data.add(pid);
+ // 3 : TID
+ int tid = (Integer) allocData.get(MemAllocDBTable.BASIC_COLUMN.TID.index);
+ text.add(Integer.toString(tid));
+ data.add(tid);
+ // 4 : address
+ Long address = (Long) allocData.get(MemAllocDBTable.BASIC_COLUMN.ALLOCATED_ADDRESS.index);
+ text.add("0x" + Long.toHexString(address));
+ data.add(address);
+ // 5 : size
+ Long size = (Long) allocData.get(MemAllocDBTable.BASIC_COLUMN.ALLOCATED_MEMORY_SIZE.index);
+ text.add(Long.toString(size));
+ data.add(size);
+ // 6 : library name
+ String libName = Global.getLibraryName((Integer)allocData.get(MemAllocDBTable.BASIC_COLUMN.CALLER_LIBRARY_ID.index));
+ if (libName == null || libName.isEmpty()) {
+ libName = AnalyzerConstants.UNKNOWN_LIB;
+ }
+
+ // Check if allocation was made from main binary
+ Project project = Global.getProject();
+ boolean isMainBinary = project != null && project.getApplicationInfo() != null
+ && project.getApplicationInfo().getExecBinaryPath().equals(libName);
+
+ // Filter leaks not from application binary
+ if (onlyLeaks && !isMainBinary)
+ return null;
+
+ text.add(libName);
+ data.add(libName);
+ // 7 : api type
+ int apiId = (Integer) allocData.get(MemAllocDBTable.BASIC_COLUMN.API_ID.index);
+ String apiName = Global.getFunctionName(apiId);
+ text.add(apiName);
+ data.add(apiName);
+
+ if (!onlyLeaks) {
+ // 8 : leak
+ boolean leak = false;
+
+ if (isMainBinary && SettingDataManager.INSTANCE
+ .isPreferenceSelected(FlatPreferences.LEAK_SANITIZER)) {
+
+ leak = LsanDataManager.getInstance().getLeaksMap().containsKey(address);
+ }
+
+ text.add(leak ? CommonConstants.YES : CommonConstants.EMPTY);
+ data.add(leak ? CommonConstants.YES : CommonConstants.EMPTY);
+ }
+
+ tableData.setType(AnalyzerConstants.TYPE_TABLE_MEM_ALLOCATEDTRACE);
+
+ TreeInput output = new TreeInput();
+ output.setText(text);
+ tableData.getData().addAll(data);
+ output.setData(tableData);
+
+ return output;
+ }
+}
--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Dongkye Lee <dongkyu6.lee@samsung.com>
+ * Jaeyong Lee <jae-yong.lee@@samsung.com>
+ * Gihun Chang <gihun.chang@@samsung.com>
+ *
+ * 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.
+ *
+ */
+
+package org.tizen.dynamicanalyzer.ui.memory.data;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Scanner;
+
+import org.tizen.dynamicanalyzer.constant.CommonConstants;
+import org.tizen.dynamicanalyzer.database.DBInserter;
+import org.tizen.dynamicanalyzer.swap.logparser.LogPackage;
+import org.tizen.dynamicanalyzer.swap.logparser.PageDataManager;
+import org.tizen.dynamicanalyzer.util.Logger;
+
+/**
+ * Processes leak sanitizer data and fills corresponding db table.
+ */
+public class LsanDataManager extends PageDataManager {
+ private static LsanDataManager instance = new LsanDataManager();
+ private MemLSanTable lsanDBTable = new MemLSanTable();
+
+ private DBInserter lsanDBInserter = makeInserter(lsanDBTable);
+
+ /**
+ * Map with leaks reported by LSAN tool.
+ */
+ private Map<Long, List<Object>> leaksMap = new HashMap<>();
+
+ public static LsanDataManager getInstance() {
+ return instance;
+ }
+
+ /**
+ * Get info about all leaks.
+ *
+ * @return map address -> leaked allocation object
+ */
+ public Map<Long, List<Object>> getLeaksMap() {
+ return leaksMap;
+ }
+
+ /**
+ * Clears leaks cache.
+ */
+ @Override
+ protected void resetBeforeStart() {
+ leaksMap.clear();
+ }
+
+ /**
+ * Selects and caches all data from {@link MemLSanTable}.
+ * Data will be loaded only once during saved trace loading.
+ */
+ @Override
+ public void openData(Map<String, String> dataMap) {
+ // TODO: Add check for data size to be loaded from data base.
+ // If data size exceeds predefined limit - invoke DALimit.stopTraceAndOpenWarningDialog()
+ constructLeaksMap(lsanDBTable.selectAllObjectData());
+ }
+
+ /**
+ * Processes and caches leaks data in the map.
+ *
+ * @param leaks list of leaked allocations objects
+ */
+ private void constructLeaksMap(List<List<Object>> leaks) {
+ leaksMap.clear();
+
+ for (List<Object> row : leaks) {
+ leaksMap.put((Long) row.get(MemLSanTable.COLUMN.ALLOCATED_ADDRESS.index), row);
+ }
+ }
+
+ /**
+ * Parses given LeakSanitizer report file.
+ *
+ * @param filepath path to pulled report file on host
+ */
+ public void parseLSanReportFile(String filepath) {
+ Scanner scanner = null;
+ List<List<Object>> lsanDataList = new ArrayList<>();
+
+ String parsingErrorMsg = "Failed to parse file: " + filepath;
+
+ try {
+ scanner = new Scanner(new FileInputStream(new File(filepath)), StandardCharsets.US_ASCII.name());
+
+ // loop through lines
+ while (scanner.hasNextLine()) {
+ /**
+ * There are 3 long fields separated by space character on each
+ * line in data file in following format:
+ * <allocation address> <chunk size> <first 4 bytes in chunk>
+ */
+ String[] fields = scanner.nextLine().split(" ");
+ if (fields.length != 3) {
+ Logger.error(parsingErrorMsg);
+ scanner.close();
+ return;
+ }
+
+ List<Object> row = new ArrayList<>();
+ for (String field : fields)
+ row.add(Long.parseLong(field));
+
+ lsanDataList.add(row);
+ }
+
+ if (!lsanDataList.isEmpty())
+ lsanDBInserter.pushData(lsanDataList);
+
+ } catch (FileNotFoundException e) {
+ Logger.warning("File was not found: " + filepath);
+
+ } catch (NumberFormatException e) {
+ Logger.error(parsingErrorMsg + CommonConstants.NEW_LINE + e.getMessage());
+
+ } finally {
+ if (scanner != null)
+ scanner.close();
+ }
+
+ constructLeaksMap(lsanDataList);
+ }
+
+ @Override
+ protected void makeData(LogPackage pack) {
+ // do nothing here
+ }
+}
public MemAllocDBTable() {
// required columns
- addColumn(new DBColumn(COLUMN.SEQUENCE_NUMBER.name, DBConstants.PRIMARY_KEY, DBConstants.DBTYPE_INT8));
+ addColumn(new DBColumn(COLUMN.SEQUENCE_NUMBER.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT8));
addColumn(new DBColumn(COLUMN.PID.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
addColumn(new DBColumn(COLUMN.TID.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
addColumn(new DBColumn(COLUMN.API_ID.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
// optional columns
addColumn(new DBColumn(COLUMN.ALLOCATOR_ADDRESS.name, DBConstants.EMPTY, DBConstants.DBTYPE_LONG));
- setIndexColumn(COLUMN.PID.index);
- setIndexColumn(COLUMN.SEQUENCE_NUMBER.index);
- setIndexColumn(COLUMN.ALLOCATED_TIME.index);
+ setPrimaryKey(COLUMN.SEQUENCE_NUMBER.index, COLUMN.PID.index, COLUMN.ALLOCATED_TIME.index);
+ addIndex(COLUMN.ALLOCATED_ADDRESS.index, COLUMN.ALLOCATED_TIME.index, COLUMN.PID.index);
+ addIndex(COLUMN.PID.index, COLUMN.CALLER_LIBRARY_ID.index, COLUMN.ALLOCATED_ADDRESS.index,
+ COLUMN.ALLOCATED_TIME.index);
}
@Override
* Get names of basic columns of the table
* @return ordered list of columns' names
*/
- private List<String> getBasicColumns() {
- List<String> columns = new ArrayList<String>();
+ public static List<String> getBasicColumns() {
+ List<String> columns = new ArrayList<>();
for (MemAllocDBTable.BASIC_COLUMN col : MemAllocDBTable.BASIC_COLUMN.values()) {
columns.add(col.name);
}
}
public MemFreeDBTable() {
- addColumn(new DBColumn(COLUMN.SEQUENCE_NUMBER.name, DBConstants.PRIMARY_KEY, DBConstants.DBTYPE_INT8));
+ addColumn(new DBColumn(COLUMN.SEQUENCE_NUMBER.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT8));
addColumn(new DBColumn(COLUMN.PID.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
addColumn(new DBColumn(COLUMN.MESSAGE_ID.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
addColumn(new DBColumn(COLUMN.FREE_TIME.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
addColumn(new DBColumn(COLUMN.ALLOCATED_ADDRESS.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
addColumn(new DBColumn(COLUMN.CALLER_LIBRARY_ID.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
-
- setIndexColumn(COLUMN.PID.index);
- setIndexColumn(COLUMN.FREE_TIME.index);
- setIndexColumn(COLUMN.SEQUENCE_NUMBER.index);
+
+ setPrimaryKey(COLUMN.SEQUENCE_NUMBER.index, COLUMN.PID.index, COLUMN.FREE_TIME.index);
+ addIndex(COLUMN.ALLOCATED_ADDRESS.index, COLUMN.FREE_TIME.index, COLUMN.PID.index);
+ addIndex(COLUMN.PID.index, COLUMN.CALLER_LIBRARY_ID.index, COLUMN.ALLOCATED_ADDRESS.index,
+ COLUMN.FREE_TIME.index);
}
@Override
addColumn(new DBColumn(COLUMN.ALLOC_COUNT.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
addColumn(new DBColumn(COLUMN.FREE_SIZE.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
addColumn(new DBColumn(COLUMN.FREE_COUNT.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
-
- setIndexColumn(COLUMN.PID.index);
- setIndexColumn(COLUMN.CALL_TIME.index);
+
+ addIndex(COLUMN.PID.index, COLUMN.CALL_TIME.index);
}
@Override
addColumn(new DBColumn(COLUMN.ALLOCATED_MEMORY_SIZE.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
addColumn(new DBColumn(COLUMN.ALLOCATED_FIRST_FOUR_BYTES.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
- setIndexColumn(COLUMN.ALLOCATED_ADDRESS.index);
+ addIndex(COLUMN.ALLOCATED_ADDRESS.index);
}
@Override
addColumn(new DBColumn(COLUMN.HEAP_ALLOCATION_BYTE.name, DBConstants.EMPTY, DBConstants.BIGINT_ARRAY));
addColumn(new DBColumn(COLUMN.TID.name, DBConstants.EMPTY, DBConstants.INTEGER_ARRAY));
addColumn(new DBColumn(COLUMN.THREAD_LOAD.name, DBConstants.EMPTY, DBConstants.FLOAT_ARRAY));
-
- setIndexColumn(COLUMN.SAMPLING_TIME.index);
- setIndexColumn(COLUMN.PID.index);
+
+ addIndex(COLUMN.SAMPLING_TIME.index, COLUMN.PID.index);
}
@Override
addColumn(new DBColumn(COLUMN.MEMORY_USAGE_SYSTEM.name, DBConstants.EMPTY, DBConstants.DBTYPE_LONG));
addColumn(new DBColumn(COLUMN.PROCESS_PID_OTHER.name, DBConstants.EMPTY, DBConstants.INTEGER_ARRAY));
addColumn(new DBColumn(COLUMN.PROCESS_LOAD_OTHER.name, DBConstants.EMPTY, DBConstants.FLOAT_ARRAY));
- setIndexColumn(COLUMN.SAMPLING_TIME.ordinal());
+ addIndex(COLUMN.SAMPLING_TIME.ordinal());
}
@Override
--- /dev/null
+package org.tizen.dynamicanalyzer.ui.memory.data.util;
+
+import org.tizen.dynamicanalyzer.ui.memory.data.MemAllocDBTable;
+import org.tizen.dynamicanalyzer.ui.memory.data.MemFreeDBTable;
+import org.tizen.dynamicanalyzer.ui.memory.data.MemLSanTable;
+
+/**
+ * Helper class to serialize query for extracting persistent allocations from database.
+ */
+public class PersistentAllocationsQuerySerializer implements QuerySerializer {
+ /**
+ * Constructs join query for tables restricted by time interval.
+ *
+ * @param q {@link Query} instance with necessary conditions
+ * @param columns desired columns in result set
+ */
+ private static String getIntervalJoinQuery(Query q, String columns) {
+ StringBuilder queryFormat = new StringBuilder();
+ queryFormat.append(String.format("SELECT %s FROM ", columns));
+ queryFormat.append(String.format("(SELECT * FROM %s ", MemAllocDBTable.TABLENAME));
+ queryFormat.append(String.format(" WHERE %s BETWEEN %s AND %s) as allocT ",
+ MemAllocDBTable.COLUMN.ALLOCATED_TIME.name, q.startTime, q.endTime));
+ queryFormat.append("LEFT JOIN ");
+ queryFormat.append(String.format("(SELECT * FROM %s ", MemFreeDBTable.TABLENAME));
+ queryFormat.append(String.format(" WHERE %s BETWEEN %s AND %s) as freeT ",
+ MemFreeDBTable.COLUMN.FREE_TIME.name, q.startTime, q.endTime));
+ return queryFormat.toString();
+ }
+
+ /**
+ * Constructs join query for full db tables.
+ *
+ * @param columns desired columns in result set
+ */
+ private static String getFullJoinQuery(String columns) {
+ return String.format("SELECT %s FROM %s allocT LEFT JOIN %s freeT ", columns,
+ MemAllocDBTable.TABLENAME, MemFreeDBTable.TABLENAME);
+ }
+
+ /**
+ * Constructs SQL representation of query conditions: time range, pid
+ * list and optional INNER JOIN with {@link MemLSanTable} if
+ * {@code onlyLeaks} is set as {@code true}.
+ *
+ * @return SQL representation of query conditions
+ */
+ @Override
+ public String toSqlString(Query q) {
+ String basicColumns = String.join(", ", MemAllocDBTable.getBasicColumns());
+ StringBuilder queryFormat = new StringBuilder();
+ if (q.startTime != 0 || q.endTime != 0) {
+ queryFormat.append(getIntervalJoinQuery(q, basicColumns));
+ } else {
+ queryFormat.append(getFullJoinQuery(basicColumns));
+ }
+
+ queryFormat.append(String.format(
+ "ON allocT.%s = freeT.%s AND allocT.%s <= freeT.%s AND allocT.%s = freeT.%s ",
+ MemAllocDBTable.COLUMN.ALLOCATED_ADDRESS.name,
+ MemFreeDBTable.COLUMN.ALLOCATED_ADDRESS.name,
+ MemAllocDBTable.COLUMN.ALLOCATED_TIME.name, MemFreeDBTable.COLUMN.FREE_TIME.name,
+ MemAllocDBTable.COLUMN.PID.name, MemFreeDBTable.COLUMN.PID.name));
+
+ if (q.onlyLeaks) {
+ queryFormat.append(String.format("INNER JOIN %s lsanT ON allocT.%s = lsanT.%s ",
+ MemLSanTable.TABLENAME, MemAllocDBTable.COLUMN.ALLOCATED_ADDRESS.name,
+ MemLSanTable.COLUMN.ALLOCATED_ADDRESS.name));
+ }
+
+ queryFormat.append(
+ String.format("WHERE freeT.%s IS NULL ", MemFreeDBTable.COLUMN.FREE_TIME.name));
+
+ // only selected PIDs
+ queryFormat.append(String.format("AND allocT.%s IN %s ", MemAllocDBTable.COLUMN.PID.name,
+ q.pidString));
+
+ return queryFormat.toString();
+ }
+}
--- /dev/null
+package org.tizen.dynamicanalyzer.ui.memory.data.util;
+
+import org.tizen.dynamicanalyzer.common.Global;
+import org.tizen.dynamicanalyzer.constant.CommonConstants;
+import org.tizen.dynamicanalyzer.ui.memory.data.HeapDataProcessor;
+import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
+
+/**
+ * Class representing basic SQL query executed by {@link HeapDataProcessor}.
+ */
+public class Query {
+ /**
+ * Start time of selected time range.
+ */
+ public long startTime;
+ /**
+ * End time of selected time range.
+ */
+ public long endTime;
+ /**
+ * String representation of selected PIDs.
+ */
+ public String pidString;
+ /**
+ * Flag denotes whether only allocations confirmed by LSAN tool should be selected.
+ */
+ public boolean onlyLeaks;
+
+ /**
+ * Default constructor.
+ */
+ public Query() {
+ clear();
+ }
+
+ /**
+ * See {@link #Query(long, long, boolean)}.
+ */
+ public Query(long startTime, long endTime) {
+ this(startTime, endTime, false);
+ }
+
+ /**
+ * Construct new instance with given time range and onlyLeaks property.
+ *
+ * @param startTime start time of selected time range
+ * @param endTime end time of selected time range
+ * @param onlyLeaks pnlyLeaks flag
+ */
+ public Query(long startTime, long endTime, boolean onlyLeaks) {
+ this.startTime = startTime;
+ this.endTime = endTime;
+ this.onlyLeaks = onlyLeaks;
+ this.pidString = getTargetPIDString();
+ }
+
+ /**
+ * Resets values of all fields to defaults.
+ */
+ public void clear() {
+ startTime = -1L;
+ endTime = -1L;
+ pidString = "";
+ onlyLeaks = false;
+ }
+
+ /**
+ * Auto-generated method.
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (int) (endTime ^ (endTime >>> 32));
+ result = prime * result + (onlyLeaks ? 1231 : 1237);
+ result = prime * result + ((pidString == null) ? 0 : pidString.hashCode());
+ result = prime * result + (int) (startTime ^ (startTime >>> 32));
+ return result;
+ }
+
+ /**
+ * Auto-generated method.
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (!(obj instanceof Query))
+ return false;
+ Query other = (Query) obj;
+ if (endTime != other.endTime)
+ return false;
+ if (onlyLeaks != other.onlyLeaks)
+ return false;
+ if (pidString == null) {
+ if (other.pidString != null)
+ return false;
+ } else if (!pidString.equals(other.pidString))
+ return false;
+ if (startTime != other.startTime)
+ return false;
+ return true;
+ }
+
+ /**
+ * Constructs string representation of currently selected PIDs.
+ *
+ * @return string representation of currently selected PIDs
+ */
+ private static String getTargetPIDString() {
+ // TODO: move this method to some utility class and generalize all
+ // SQL queries management.
+
+ StringBuilder pidliststring = new StringBuilder();
+ pidliststring.append(CommonConstants.OPEN_BRACKET);
+
+ int targetPID = Toolbar.INSTANCE.getSelectedPid();
+
+ if (targetPID > 0)
+ pidliststring.append(targetPID);
+ else
+ for (int pid : Global.getProject().getProcessIDs()) {
+ if (pidliststring.length() != 1)
+ pidliststring.append(CommonConstants.COMMA);
+
+ pidliststring.append(pid);
+ }
+
+ pidliststring.append(CommonConstants.CLOSE_BRACKET);
+
+ return pidliststring.toString();
+ }
+
+}
--- /dev/null
+package org.tizen.dynamicanalyzer.ui.memory.data.util;
+
+/**
+ * Base interface for {@link Query} serializers.
+ *
+ * @author d.nikiforov
+ */
+@FunctionalInterface
+public interface QuerySerializer {
+ /**
+ * Serializes specified {@link Query} into SQL query.
+ *
+ * @param q {@link Query} instance with necessary conditions
+ * @return serialized string
+ */
+ public abstract String toSqlString(Query q);
+}
--- /dev/null
+package org.tizen.dynamicanalyzer.ui.memory.data.util;
+
+import org.tizen.dynamicanalyzer.ui.memory.data.MemAllocDBTable;
+import org.tizen.dynamicanalyzer.ui.memory.data.MemFreeDBTable;
+import org.tizen.dynamicanalyzer.ui.memory.table.MemoryStatisticsTable;
+
+/**
+ * Helper class to serialise query for extracting data for 'Statistics' table
+ * from database.
+ *
+ * @author d.nikiforov
+ */
+public class StatisticsQuerySerializer implements QuerySerializer {
+ /**
+ * Constructs SQL representation of query conditions (time range and pid list)
+ * for {@link MemoryStatisticsTable}.
+ *
+ * <i>Resulting SQL query is constructed based on the assumption that there are no
+ * double allocations in the DB.</i>
+ *
+ * @return SQL representation of query conditions
+ * @see {@link Query}
+ */
+ @Override
+ public String toSqlString(Query q) {
+ StringBuilder queryFormat = new StringBuilder();
+ // @formatter:off
+ /**
+ * All aggregate functions are explicitly casted to BIGINT (java.lang.Long)
+ * because they can be casted implicitly to DECIMAL due to overflow.
+ */
+ queryFormat.append(String.format("SELECT %1$s, " // PID
+ + "%2$s, " // Caller library ID
+ + "CAST (COUNT(*) AS BIGINT), " // Allocations count
+ + "CAST (COUNT(%3$s) AS BIGINT), " // Free count
+ + "CAST (COUNT(CASE WHEN %3$s IS NULL THEN 1 ELSE NULL END) AS BIGINT), " // Persistent count
+ + "CAST (SUM(%4$s) AS BIGINT), " // Allocations size
+ + "CAST (SUM(CASE WHEN %3$s IS NULL THEN %4$s ELSE 0 END) AS BIGINT) ", // Persistent size
+ MemAllocDBTable.COLUMN.PID.name,
+ MemAllocDBTable.COLUMN.CALLER_LIBRARY_ID.name,
+ MemFreeDBTable.COLUMN.FREE_TIME.name,
+ MemAllocDBTable.COLUMN.ALLOCATED_MEMORY_SIZE));
+
+ queryFormat.append(String.format("FROM ("
+ + "SELECT DISTINCT %1$s, %2$s, %3$s, %4$s," // PID, Library, Allocated size, Allocation time
+ + "(SELECT TOP 1 DISTINCT %9$s" // select only first entry with only 'Free time' column
+ + " FROM %10$s as freeT" // from MEM_FREE_DB table
+ + " WHERE allocT.%1$s = freeT.%6$s" // same PID
+ + " AND allocT.%2$s = freeT.%7$s" // same library
+ + " AND allocT.%5$s = freeT.%8$s" // same address
+ + " AND allocT.%4$s <= freeT.%9$s", // free time is larger or equal to allocation time
+ MemAllocDBTable.COLUMN.PID.name,
+ MemAllocDBTable.COLUMN.CALLER_LIBRARY_ID.name,
+ MemAllocDBTable.COLUMN.ALLOCATED_MEMORY_SIZE.name,
+ MemAllocDBTable.COLUMN.ALLOCATED_TIME.name,
+ MemAllocDBTable.COLUMN.ALLOCATED_ADDRESS.name,
+ MemFreeDBTable.COLUMN.PID.name,
+ MemFreeDBTable.COLUMN.CALLER_LIBRARY_ID.name,
+ MemFreeDBTable.COLUMN.ALLOCATED_ADDRESS.name,
+ MemFreeDBTable.COLUMN.FREE_TIME.name,
+ MemFreeDBTable.TABLENAME));
+ // @formatter:on
+
+ // add time range condition if there is any
+ if (q.endTime > 0)
+ queryFormat.append(String.format(" AND %s <= %s", MemFreeDBTable.COLUMN.FREE_TIME, q.endTime));
+
+ queryFormat.append(String.format(" ORDER BY %1$s ASC) AS %1$s" // sorted in ascending order by free time
+ + " FROM %2$s as allocT ", // from MEM_ALLOC_DB table
+ MemFreeDBTable.COLUMN.FREE_TIME, MemAllocDBTable.TABLENAME));
+
+ queryFormat.append(String.format("WHERE %s in %s", MemAllocDBTable.COLUMN.PID.name, q.pidString));
+
+ // add time range condition if there is any
+ if (q.startTime > 0 || q.endTime > 0) {
+ queryFormat.append(String.format(" AND %s BETWEEN %s AND %s",
+ MemAllocDBTable.COLUMN.ALLOCATED_TIME, q.startTime, q.endTime));
+ }
+
+ // execute aggregate functions for all entries grouped by their PID and Library ID
+ queryFormat.append(String.format(") GROUP BY %s, %s",
+ MemAllocDBTable.COLUMN.PID.name,
+ MemAllocDBTable.COLUMN.CALLER_LIBRARY_ID.name));
+
+ return queryFormat.toString();
+ }
+}
package org.tizen.dynamicanalyzer.ui.memory.table;
-import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
import org.eclipse.nebula.widgets.grid.GridItem;
import org.eclipse.swt.SWT;
import org.tizen.dynamicanalyzer.common.DASelectionData;
import org.tizen.dynamicanalyzer.common.Global;
import org.tizen.dynamicanalyzer.model.TableInput;
-import org.tizen.dynamicanalyzer.project.callstack.RuntimeCallstackManager;
import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackUnit;
import org.tizen.dynamicanalyzer.ui.memory.MemoryPage;
import org.tizen.dynamicanalyzer.ui.memory.data.HeapDataManager;
import org.tizen.dynamicanalyzer.ui.memory.data.MemAllocDBTable;
-import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineTableView;
+import org.tizen.dynamicanalyzer.ui.timeline.calltrace.CallTraceDataManager;
import org.tizen.dynamicanalyzer.ui.widgets.table.DATableComposite;
import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat;
import org.tizen.dynamicanalyzer.util.Logger;
@Override
public void widgetSelected(SelectionEvent e) {
AnalyzerManager.getCurrentPage().updateView(
- new DAViewData(TimelineTableView.tabID, null));
+ new DAViewData(MemoryPage.callstackViewID, null));
GridItem[] sels = table.getSelection();
if (sels.length <= 0) {
return;
long time = (long) getMemAllocationDataByColumnIndex(memAllocationData, MemoryPersistentAllocationsTableIndex.TIMESTAMP.getIndex());
long allocCallerAddr = getCallerAddr(memAllocationData, seqNum);
int pid = (int) getMemAllocationDataByColumnIndex(memAllocationData, MemoryPersistentAllocationsTableIndex.PID.getIndex());
+ int tid = (int) getMemAllocationDataByColumnIndex(memAllocationData, MemoryPersistentAllocationsTableIndex.TID.getIndex());
String allocCallerPath = (String) getMemAllocationDataByColumnIndex(memAllocationData, MemoryPersistentAllocationsTableIndex.LIBRARY.getIndex());
String allocName = (String) getMemAllocationDataByColumnIndex(memAllocationData, MemoryPersistentAllocationsTableIndex.CALLED.getIndex());
- Map<Long, CallStackUnit> addrMap = Global.getRuntimeCallstackManager()
- .getCallStackApiAddrByPidMap(pid);
- if ((null == addrMap) || (addrMap.isEmpty())) {
+ long allocAddr = (long) HeapDataManager.getInstance().getAllocatorAddrBySeqFromDB(seqNum);
+ String allocPath = Global.getLibraryName(Global.getBinaryID(pid, time, allocAddr));
+ fillAllocationFields(allocName, allocCallerAddr, allocCallerPath, allocAddr, allocPath, pid,
+ tid, time);
+
+ List<CallStackUnit> callStack = CallTraceDataManager.getInstance().getCallstackForTable(pid,
+ tid, time);
+ if ((null == callStack) || (callStack.isEmpty())) {
return;
}
- List<Long> addrs = getAddrs(seqNum);
- if (null == addrs) {
- // FIXME: actually below is too strong suggestion, any other issue
- // may occur while getting addresses
- // This case may occurred if sequence number is above Long.MAX_VALUE
- addrs = getAddrs(Long.MAX_VALUE);
- if (null == addrs) {
- Logger.error("Function entry or exit not found");
- return;
- }
- }
- long allocAddr = (long) HeapDataManager.getInstance().getAllocatorAddrBySeqFromDB(seqNum);
- String allocPath = Global.getLibraryName(Global.getBinaryID(pid, time, allocAddr));
- fillAllocationFields(time, pid, allocName, allocCallerAddr, allocCallerPath,
- allocAddr, allocPath);
// --------------------------------
- if (addrs.isEmpty())
- return;
- if (allocCallerPath.equals(Global.getLibraryName(addrMap.get(addrs.get(0)).getBinaryID()))) {
+ if (allocCallerPath != null && allocCallerPath.equals(callStack.get(0).getPath())) {
// this case occurred when allocation performed from profiled application.
- lastItem.setText(0, addrMap.get(addrs.get(0)).getFunctionName());
- if (addrs.size() > 1)
- lastItem.setData(
- AnalyzerConstants.MEM_CALLSTACK_KEY_CALLER_ADDRESS,
- addrs.get(1));
- lastItem.setData(
- AnalyzerConstants.MEM_CALLSTACK_KEY_FUNCTION_START_ADDRESS,
- addrMap.get(addrs.get(0)).getFunctionStartAddr());
+ lastItem.setText(0, callStack.get(0).getFunctionName());
+ lastItem.setData(AnalyzerConstants.MEM_CALLSTACK_KEY_CALLER_ADDRESS, callStack.get(0)
+ .getCallerAddress());
+ lastItem.setData(AnalyzerConstants.CALLSTACK_KEY_ADDR,
+ callStack.get(0).getAddr());
// in this case addrs first element is already in table, so it
// should be removed.
- addrs.remove(0);
+ callStack.remove(0);
}
// --------------------------------
- if (!addrs.isEmpty())
- fillCallstackFields(addrs, addrMap, pid, time);
+ if (!callStack.isEmpty())
+ fillCallstackFields(callStack);
}
/**
* Add 2 items to Memory callstack table: 1 - called allocation function
* info, 2 - information about allocation caller.
- * @param time time when allocation was performed
- * @param pid identifier of process
* @param allocName name of called allocation function
* @param allocCallerAddr address of allocation caller instruction
* @param allocCallerPath library from where allocation was called
* @param allocAddr address of allocator
* @param allocPath library which allocator belongs to
*/
- private void fillAllocationFields(long time, int pid,
- String allocName, long allocCallerAddr, String allocCallerPath, long allocAddr, String allocPath) {
+ private void fillAllocationFields(String allocName, long allocCallerAddr,
+ String allocCallerPath, long allocAddr, String allocPath, int pid, int tid, long time) {
DATableDataFormat callstackTableData = new DATableDataFormat(allocCallerAddr);
callstackTableData.setType(AnalyzerConstants.TYPE_TABLE_MEM_CALLSTACK);
callstackTableData.setObject(allocCallerAddr);
- GridItem gridItem = createGridItem(callstackTableData, 0L, pid, time, "", allocCallerAddr, 0L);
+ GridItem gridItem = createGridItem(callstackTableData,
+ new CallStackUnit(allocAddr, allocCallerAddr, pid, tid, time, 0));
gridItem.setText(0, allocName);
gridItem.setText(1, allocAddr == 0 ? UNKNOWN : formatLongAddr(allocAddr));
gridItem.setText(2, allocPath.isEmpty() ? UNKNOWN_LIBRARY : allocPath);
- gridItem = createGridItem(callstackTableData, allocCallerAddr, pid, time, allocCallerPath,
- 0L, 0L);
+ gridItem = createGridItem(callstackTableData,
+ new CallStackUnit(allocAddr, allocCallerAddr, pid, tid, time, 0));
gridItem.setText(0, UNKNOWN);
String addrInput = (allocCallerAddr == 0) ? UNKNOWN : formatLongAddr(allocCallerAddr); //$NON-NLS-1$
gridItem.setText(1, addrInput);
}
/**
- * Add a callstack of function from where allocation was called.
+ * Create GUI representation for callstack of function from where allocation
+ * was called.
*
- * @param addrs list with addresses of functions in callstack
- * @param addrMap map with callstack units, contains info about each
- * function in callstack
- * @param pid identifier of process
- * @param time time when allocation was performed
+ * @param callStack of function from where allocation was called
*/
- private void fillCallstackFields(List<Long> addrs,
- Map<Long, CallStackUnit> addrMap, int pid, long time) {
+ private void fillCallstackFields(List<CallStackUnit> callStack) {
- for (int i = 0; i < addrs.size(); i++) {
- String hexAddr = Formatter.toHexString(addrs.get(i).toString());
- CallStackUnit api = addrMap.get(addrs.get(i));
+ for (int i = 0; i < callStack.size(); i++) {
+ String hexAddr = Formatter.toHexString("" + callStack.get(i).getAddr());
+ CallStackUnit api = callStack.get(i);
if (null == api) {
Logger.debug("callstackunit for addr : " + hexAddr
+ " not found");
break;
}
- long address = addrs.get(i);
+ long address = api.getAddr();
// setData block
DATableDataFormat callstackTableData = new DATableDataFormat(address);
callstackTableData.setType(AnalyzerConstants.TYPE_TABLE_MEM_CALLSTACK);
callstackTableData.setObject(address);
- long nextAddr = 0L;
- if (i + 1 < addrs.size())
- nextAddr = addrs.get(i + 1);
- GridItem gridItem = createGridItem(callstackTableData, address, pid,
- time, api.getPath(), nextAddr, api.getFunctionStartAddr());
+ GridItem gridItem = createGridItem(callstackTableData, api);
String addrInput = (address == 0) ? UNKNOWN : hexAddr; //$NON-NLS-1$
gridItem.setText(1, addrInput.toLowerCase());
gridItem.setText(0, api.getFunctionName());
}
/**
- * Create grid item for Callstack table.
+ * Create grid item for callstack unit to put into Callstack table.
*
- * @param callstackTableData represents data for item
- * @param addr address of instruction described in this table item
- * @param pid process identifier
- * @param time time when allocation was performed
- * @param allocPath library from where allocation was called
- * @param callerAddr address of caller
- * @param memFuncAddr address of source code
+ * @param callstackTableData GUI representation of data
+ * @param api callstack unit
* @return GridItem representing all this data
*/
private GridItem createGridItem(DATableDataFormat callstackTableData,
- long addr, int pid, long time, String allocPath,
- long callerAddr, long memFuncAddr) {
+ CallStackUnit api) {
GridItem gridItem = new GridItem(table, SWT.NONE);
gridItem.setData(callstackTableData);
- gridItem.setData(AnalyzerConstants.CALLSTACK_KEY_ADDR, addr);
- gridItem.setData(AnalyzerConstants.CALLSTACK_KEY_PID, pid);
- gridItem.setData(AnalyzerConstants.CALLSTACK_KEY_TIME, time);
- gridItem.setData(AnalyzerConstants.CALLSTACK_KEY_LIBNAME, allocPath);
- gridItem.setData(AnalyzerConstants.MEM_CALLSTACK_KEY_CALLER_ADDRESS,
- callerAddr);
- gridItem.setData(
- AnalyzerConstants.MEM_CALLSTACK_KEY_FUNCTION_START_ADDRESS,
- memFuncAddr);
+ gridItem.setData(AnalyzerConstants.CALLSTACK_KEY_ADDR, api.getAddr());
+ gridItem.setData(AnalyzerConstants.CALLSTACK_KEY_PID, api.getPid());
+ gridItem.setData(AnalyzerConstants.CALLSTACK_KEY_TIME, api.getTime());
+ gridItem.setData(AnalyzerConstants.CALLSTACK_KEY_LIBNAME, api.getPath());
+ gridItem.setData(AnalyzerConstants.MEM_CALLSTACK_KEY_CALLER_ADDRESS, api.getCallerAddress());
lastItem = gridItem;
return gridItem;
}
* corrupted. In latter case error is being reported.
*/
private List<Object> getAllocationInfo(long seqNum) {
- return HeapDataManager.getInstance()
- .getAllocationRowBySeqFromDB(seqNum);
- }
-
- /**
- * Find current callstack for the moment, when allocation was performed.
- *
- * @param seqNum sequence number of the allocation
- * @return unmodifiable list of addresses
- */
- private List<Long> getAddrs(long seqNum) {
- List<Long> res = new ArrayList<Long>();
- RuntimeCallstackManager callstackManager = Global
- .getRuntimeCallstackManager();
- if (callstackManager.getCallStackDataBySeqMap().floorEntry(seqNum) == null)
- return null;
- res.addAll(callstackManager.getCallStackDataBySeqMap()
- .floorEntry(seqNum).getValue().getAddrs());
- return res;
+ return HeapDataManager.getInstance().getAllocationRowBySeqFromDB(seqNum);
}
@Override
import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;\r
import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat;\r
import org.tizen.dynamicanalyzer.ui.widgets.table.DATreeComposite;\r
-import org.tizen.dynamicanalyzer.ui.widgets.table.DefaultTableComparator;\r
import org.tizen.dynamicanalyzer.util.Logger;\r
import org.tizen.dynamicanalyzer.utils.Formatter;\r
\r
Current = (long) -1;\r
\r
setTableName(MemoryPageLabels.MEMORY_DETAILS_VIEW_TITLE);\r
- setComparator(new DefaultTableComparator());\r
\r
setTree(true);\r
\r
\r
setTableToolTipEnable(false);\r
\r
- comparator.setType(AnalyzerConstants.SORT_TYPE_NONE);\r
- comparator.setColumn(0);\r
- \r
}\r
\r
public void setSelectionRange(Long start, Long end, Long current) {\r
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat;
import org.tizen.dynamicanalyzer.ui.widgets.table.DATreeComposite;
import org.tizen.dynamicanalyzer.ui.widgets.table.DefaultTableComparator;
+import org.tizen.dynamicanalyzer.util.Logger;
+import org.tizen.dynamicanalyzer.utils.Formatter;
public class MemoryMapTable extends DATreeComposite {
*/
int keyindex = 0;
+ /**
+ * Time to show memory map for.
+ */
+ long selectionTime = -1;
+
+ /**
+ * Suffix used to explain selection time.
+ */
+ String selectionSuffix;
+
public MemoryMapTable(Composite parent, int style, int tableStyle) {
super(parent, style, tableStyle);
return result;
}
+ /**
+ * Set time to show memory map for.
+ */
+ public void setSelectionTime(long time) {
+ selectionTime = time;
+ selectionSuffix = String.format(" (%s)",
+ (selectionTime == -1) ? "current" : "at " + Formatter.toTimeFormat(selectionTime));
+ }
+
@Override
public List<TreeInput> makeTreeInput() {
keyindex = 0;
for (Integer pid : pidList) {
TreeInput parentInput = makeProcessHeaderTreeInput(pid);
- ProcessMemoryMap pmap = project.getProcessInformation(pid)
- .getLastProcessMemoryMap();
+ ProcessMemoryMap pmap;
+ if (selectionTime == -1)
+ pmap = project.getProcessInformation(pid).getLastProcessMemoryMap();
+ else
+ pmap = project.getProcessInformation(pid).getProcessMemoryMap(selectionTime);
- Map<Integer, LibraryObject> binarymap = pmap.getAllLibraryID();
+ if (pmap == null) {
+ Logger.warning("Missing process information for #%d (%s)", pid, selectionSuffix);
+ continue;
+ }
+ Map<Long, LibraryObject> binarymap = pmap.getAllMappings();
- // for every library
- for (Map.Entry<Integer, LibraryObject> entry : binarymap.entrySet()) {
- int binId = entry.getKey();
+ // for every library mapping
+ for (Entry<Long, LibraryObject> entry : binarymap.entrySet()) {
+ int binId = entry.getValue().getBinaryID();
String binPath = project.getDeviceStatusInfo()
.getBinaryInfo(binId).getTargetBinaryPath();
List<String> text = new ArrayList<>();
List<Object> data = new ArrayList<>();
- String headerCaption = String.format("PID #%d", pid);
+ String headerCaption = String.format("PID #%d%s", pid, selectionSuffix);
// PID column
text.add(headerCaption);
data.add(pid);
package org.tizen.dynamicanalyzer.ui.memory.table;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
import org.eclipse.nebula.widgets.grid.Grid;
import org.eclipse.nebula.widgets.grid.GridItem;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
import org.tizen.dynamicanalyzer.common.AnalyzerManager;
import org.tizen.dynamicanalyzer.common.DASelectionData;
import org.tizen.dynamicanalyzer.common.DAState;
import org.tizen.dynamicanalyzer.common.Global;
import org.tizen.dynamicanalyzer.model.TableInput;
+import org.tizen.dynamicanalyzer.model.TreeInput;
+import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
import org.tizen.dynamicanalyzer.nl.MemoryPageLabels;
import org.tizen.dynamicanalyzer.ui.memory.MemoryPersistentAllocationsTableView;
-import org.tizen.dynamicanalyzer.ui.memory.data.HeapDataManager;
+import org.tizen.dynamicanalyzer.ui.memory.data.HeapDataProcessor;
+import org.tizen.dynamicanalyzer.ui.memory.data.util.Query;
import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
import org.tizen.dynamicanalyzer.ui.widgets.table.DATableComposite;
import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat;
private Long EndTime;
private boolean onlyLeaks;
+ /**
+ * Last query used to get data on some range.
+ */
+ Query lastPartQuery = null;
+ /**
+ * Last task to fetch persistent data on some range.
+ */
+ CompletableFuture<List<TableInput>> partDataTask = null;
+ /**
+ * Last task to fetch persistent data on whole range.
+ */
+ CompletableFuture<List<TableInput>> wholeDataTask = null;
+ /**
+ * Table input stub to show when fetch operation is in progress.
+ */
+ List<TableInput> processingStub;
+
public MemoryPersistentAllocationsTable(Composite parent, int style, int tableStyle,
boolean onlyLeaks) {
super(parent, style, tableStyle);
}
});
+
+ processingStub = Arrays.asList(makeProcessingStub());
+ }
+
+ /**
+ * Make stub to indicate that data is under construction now.
+ */
+ private TableInput makeProcessingStub() {
+ DATableDataFormat tableData = new DATableDataFormat(0);
+
+ List<String> text = new ArrayList<>();
+ List<Object> data = new ArrayList<>();
+
+ // 0 : sequence number - hidden column for sorting
+ text.add("");
+ data.add(0);
+ // 1 : allocated time
+ text.add(AnalyzerLabels.TABLE_PROCESSING_DATA);
+ data.add(0);
+
+ text.add("");
+ data.add(0);
+
+ text.add("");
+ data.add(0);
+
+ text.add("");
+ data.add(0);
+
+ text.add("");
+ data.add(0);
+
+ text.add("");
+ data.add(0);
+
+ text.add("");
+ data.add(0);
+
+ if (!onlyLeaks) {
+ text.add("");
+ data.add(0);
+ }
+
+ TreeInput output = new TreeInput();
+ output.setText(text);
+ tableData.getData().addAll(data);
+ output.setData(tableData);
+
+ return output;
}
-
+
public void setSelectionRange(Long start, Long end){
StartTime = start;
EndTime = end;
public boolean isSelectionPerformed() {
return StartTime != EndTime;
}
- @Override
- protected List<TableInput> makeTableInput() {
- List<TableInput> output = new ArrayList<TableInput>();
- if(Global.getProject() == null) {
- return output;
+
+ /**
+ * Make table input for specific interval.
+ */
+ private List<TableInput> makeIntervalTableInput() throws InterruptedException, ExecutionException {
+ Query newQuery = new Query(StartTime, EndTime, onlyLeaks);
+
+ if (newQuery.equals(lastPartQuery)) {
+ if (partDataTask.isDone()) {
+ return partDataTask.get();
+ }
+ } else {
+ lastPartQuery = newQuery;
+ if (partDataTask != null) {
+ partDataTask.cancel(true);
+ }
+
+ partDataTask = CompletableFuture.supplyAsync(
+ () -> HeapDataProcessor.getInstance()
+ .getTableInputPersistentAllocsData(newQuery));
+ partDataTask.thenRun(() -> Display.getDefault().asyncExec(this::updateTable));
}
- if(DAState.isRunning() == false) {
- if(StartTime == 0 && EndTime == 0 && Toolbar.INSTANCE.getSelectedPid() <= 0) {
- List<TableInput> wholedata;
- if (onlyLeaks)
- wholedata = HeapDataManager.getInstance().getLeaksTableInput();
- else
- wholedata = HeapDataManager.getInstance().getPersistentAllocsTableInput();
+ return processingStub;
+ }
- if(wholedata.size() != 0) {
- return wholedata;
- }
+ /**
+ * Make table input for whole tracing time.
+ */
+ private List<TableInput> makeFullTableInput() throws InterruptedException, ExecutionException {
+ if (DAState.isDone()) {
+ if (wholeDataTask == null) {
+ wholeDataTask = CompletableFuture.supplyAsync(
+ () -> HeapDataProcessor.getInstance()
+ .getTableInputPersistentAllocsData(
+ new Query(StartTime, EndTime, onlyLeaks)));
+ wholeDataTask.thenRun(() -> Display.getDefault().asyncExec(this::updateTable));
+
+ }
+
+ if (wholeDataTask.isDone()) {
+ return wholeDataTask.get();
+ } else {
+ return processingStub;
}
}
-
- List<List<Object>> allocDataList = null;
-
- allocDataList = HeapDataManager.getInstance().remainedAllocatedListForRange(StartTime,
- EndTime, onlyLeaks);
- if (allocDataList == null || allocDataList.size() == 0)
- return output;
-
- int index = 0;
- int size = allocDataList.size();
-
- for (int j = 0; j < size; j++) {
- List<Object> iAllocData = allocDataList.get(j);
+ return Collections.emptyList();
+ }
- TableInput alloInput = HeapDataManager.getInstance()
- .makePersistentAllocsTableInput(iAllocData, index++, onlyLeaks);
- if (alloInput != null){
- output.add(alloInput);
+ /**
+ * TODO Time Consuming Process : make progress bar for this task in the future.
+ */
+ @Override
+ protected List<TableInput> makeTableInput() {
+ if(Global.getProject() == null) {
+ return Collections.emptyList();
+ }
+
+ try {
+ if (StartTime != 0 || EndTime != 0) {
+ return makeIntervalTableInput();
+ } else {
+ return makeFullTableInput();
}
+ } catch (InterruptedException | ExecutionException e) {
+ Logger.error(e);
+ return Collections.emptyList();
}
- return output;
}
-
+
public void removeSelection() {
table.removeAll();
updateTable();
StartTime = (long)0;
EndTime = (long)0;
+
+ wholeDataTask = null;
+ lastPartQuery = null;
+ partDataTask = null;
}
public void cleanColumnsWeights() {
package org.tizen.dynamicanalyzer.ui.memory.table;\r
\r
import java.util.ArrayList;\r
+import java.util.Arrays;\r
+import java.util.Collections;\r
import java.util.List;\r
+import java.util.concurrent.CompletableFuture;\r
+import java.util.concurrent.ExecutionException;\r
\r
import org.eclipse.swt.SWT;\r
import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Display;\r
import org.tizen.dynamicanalyzer.common.AnalyzerConstants;\r
+import org.tizen.dynamicanalyzer.common.DAState;\r
import org.tizen.dynamicanalyzer.common.Global;\r
import org.tizen.dynamicanalyzer.model.TreeInput;\r
+import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;\r
import org.tizen.dynamicanalyzer.nl.MemoryPageLabels;\r
-import org.tizen.dynamicanalyzer.ui.memory.data.HeapDataManager;\r
+import org.tizen.dynamicanalyzer.ui.memory.data.HeapDataProcessor;\r
+import org.tizen.dynamicanalyzer.ui.memory.data.util.Query;\r
+import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat;\r
import org.tizen.dynamicanalyzer.ui.widgets.table.DATreeComposite;\r
import org.tizen.dynamicanalyzer.ui.widgets.table.DefaultTableComparator;\r
+import org.tizen.dynamicanalyzer.util.Logger;\r
\r
public class MemoryStatisticsTable extends DATreeComposite {\r
-
+\r
private int[] columnSizes = {265, 140, 90, 90, 90, 110, 15};\r
-
+\r
private int[] columnAlignment = { SWT.LEFT, SWT.RIGHT, SWT.RIGHT, SWT.RIGHT,\r
SWT.RIGHT, SWT.RIGHT, SWT.RIGHT};\r
\r
private Long StartTime;\r
private Long EndTime;\r
\r
+ /**\r
+ * Last query used to get data on some range.\r
+ */\r
+ Query lastPartQuery = null;\r
+ /**\r
+ * Last task to fetch persistent data on some range.\r
+ */\r
+ CompletableFuture<List<TreeInput>> partStatisticsTask = null;\r
+ /**\r
+ * Last task to fetch persistent data on whole range.\r
+ */\r
+ CompletableFuture<List<TreeInput>> wholeStatisticsTask = null;\r
+ /**\r
+ * Tree input stub to show when data fetch is in progress.\r
+ */\r
+ List<TreeInput> processingStub;\r
+\r
private String[] columnNames = {\r
- MemoryPageLabels.MEMORY_STATISTICS_VIEW_PATH,
+ MemoryPageLabels.MEMORY_STATISTICS_VIEW_PATH,\r
MemoryPageLabels.MEMORY_STATISTICS_VIEW_TOTAL,\r
MemoryPageLabels.MEMORY_STATISTICS_VIEW_FREED,\r
MemoryPageLabels.MEMORY_STATISTICS_VIEW_PERSISTENT,\r
AnalyzerConstants.SORT_TYPE_NONE\r
};\r
\r
- public MemoryStatisticsTable(Composite parent, int style, int tableStyle) {
+ public MemoryStatisticsTable(Composite parent, int style, int tableStyle) {\r
super(parent, style, tableStyle); \r
\r
StartTime = (long)0;\r
\r
comparator.setType(AnalyzerConstants.SORT_TYPE_NUM);\r
comparator.setColumn(1);\r
-
+\r
+ processingStub = Arrays.asList(makeProcessingStub());\r
+ }\r
+\r
+ /**\r
+ * Make stub to indicate that data is under construction now.\r
+ */\r
+ private TreeInput makeProcessingStub() {\r
+ DATableDataFormat tableData = new DATableDataFormat(0);\r
+\r
+ List<String> text = new ArrayList<>();\r
+ List<Object> data = new ArrayList<>();\r
+\r
+ text.add(AnalyzerLabels.TABLE_PROCESSING_DATA);\r
+ data.add("");\r
+\r
+ text.add("");\r
+ data.add(0);\r
+\r
+ text.add("");\r
+ data.add(0);\r
+\r
+ text.add("");\r
+ data.add(0);\r
+\r
+ text.add("");\r
+ data.add(0);\r
+\r
+ text.add("");\r
+ data.add(0);\r
+\r
+ tableData.getData().addAll(data);\r
+ tableData.setObject(AnalyzerLabels.TABLE_PROCESSING_DATA);\r
+\r
+ TreeInput output = new TreeInput();\r
+ output.setText(text);\r
+ output.setData(tableData);\r
+\r
+ return output;\r
}\r
-
- public void setSelectionRange(Long start, Long end){
+\r
+ public void setSelectionRange(Long start, Long end){\r
StartTime = start;\r
EndTime = end;\r
}\r
return StartTime != EndTime;\r
}\r
\r
+ /**\r
+ * Make table input for specific interval.\r
+ */\r
+ private List<TreeInput> makeIntervalTableInput()\r
+ throws InterruptedException, ExecutionException {\r
+ Query newQuery = new Query(StartTime, EndTime);\r
+\r
+ if (newQuery.equals(lastPartQuery)) {\r
+ if (partStatisticsTask.isDone()) {\r
+ return partStatisticsTask.get();\r
+ }\r
+ } else {\r
+ lastPartQuery = newQuery;\r
+ if (partStatisticsTask != null)\r
+ partStatisticsTask.cancel(true);\r
+\r
+ partStatisticsTask = CompletableFuture.supplyAsync(() -> HeapDataProcessor.getInstance()\r
+ .getTreeInputStatisticsData(new Query(StartTime, EndTime)));\r
+ partStatisticsTask.thenRun(() -> Display.getDefault().asyncExec(this::updateTree));\r
+ }\r
+\r
+ return processingStub;\r
+ }\r
+\r
+ /**\r
+ * Make table input for whole tracing time.\r
+ */\r
+ private List<TreeInput> makeFullTableInput() throws InterruptedException, ExecutionException {\r
+ if (DAState.isDone()) {\r
+ if (wholeStatisticsTask == null) {\r
+ wholeStatisticsTask = CompletableFuture.supplyAsync(() -> HeapDataProcessor\r
+ .getInstance().getTreeInputStatisticsData(new Query(0, 0)));\r
+ wholeStatisticsTask.thenRun(() -> Display.getDefault().asyncExec(this::updateTree));\r
+ }\r
+\r
+ if (wholeStatisticsTask.isDone())\r
+ return wholeStatisticsTask.get();\r
+ else\r
+ return processingStub;\r
+ }\r
+\r
+ return Collections.emptyList();\r
+ }\r
+\r
+ /**\r
+ * TODO Time Consuming Process : make progress bar for this task in the future.\r
+ */\r
@Override\r
public List<TreeInput> makeTreeInput() {\r
- List<TreeInput> output = new ArrayList<TreeInput>();
if(Global.getProject() == null) {\r
- return output;\r
+ return Collections.emptyList();\r
+ }\r
+\r
+ try {\r
+ if (StartTime != 0 || EndTime != 0) {\r
+ return makeIntervalTableInput();\r
+ } else {\r
+ return makeFullTableInput();\r
+ }\r
+ } catch (InterruptedException | ExecutionException e) {\r
+ Logger.error(e);\r
+ return Collections.emptyList();\r
}\r
-
- HeapDataManager.getInstance().makeStatisticsData(StartTime, EndTime);\r
- return HeapDataManager.getInstance().getStatisticsTreeInput();\r
}\r
-
+\r
public void removeSelection() { \r
table.removeAll();\r
updateTable();\r
}\r
-
+ \r
@Override\r
public void clear() {\r
table.removeAll();\r
getSelectionIndex().clear();\r
- getSelections().clear();
+ getSelections().clear();\r
\r
StartTime = (long)0;\r
EndTime = (long)0;\r
+\r
+ lastPartQuery = null;\r
+ partStatisticsTask = null;\r
+ wholeStatisticsTask = null;\r
}\r
-}
+}\r
import org.tizen.dynamicanalyzer.resources.ColorResources;
import org.tizen.dynamicanalyzer.ui.network.data.NetworkDataManager;
import org.tizen.dynamicanalyzer.ui.network.data.type.NetworkSelectionType;
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
import org.tizen.dynamicanalyzer.ui.widgets.DAAdvancedViewComposite;
import org.tizen.dynamicanalyzer.util.Logger;
}
preSelectionPId = selectedPid;
- // Change Analyzer
- long newAnalysisStartTime = 0;
- long newAnalysisEndTime = 0;
- if (RangeDataManager.getInstance().isBeingAnalyzed()) {
- newAnalysisStartTime = RangeDataManager.getInstance().getAnalysisStartTime();
- newAnalysisEndTime = RangeDataManager.getInstance().getAnalysisEndTime();
- } else {
- newAnalysisStartTime = 0;
- newAnalysisEndTime = 0;
- }
- if (newAnalysisStartTime != preAnalysisStartTime
- || newAnalysisEndTime != preAnalysisEndTime) {
- preAnalysisStartTime = newAnalysisStartTime;
- preAnalysisEndTime = newAnalysisEndTime;
- isUpdate = true;
- }
// Change Selection
if (isChangedSelected) {
isChangedSelected = false;
import org.tizen.dynamicanalyzer.constant.CommonConstants;
import org.tizen.dynamicanalyzer.nl.NetworkPageLabels;
import org.tizen.dynamicanalyzer.nl.ThreadPageLabels;
-import org.tizen.dynamicanalyzer.nl.TimelineChartLabels;
import org.tizen.dynamicanalyzer.resources.ColorResources;
import org.tizen.dynamicanalyzer.resources.FontResources;
import org.tizen.dynamicanalyzer.resources.ImageResources;
-import org.tizen.dynamicanalyzer.ui.common.PopupRangeAnalysisMenuItemOnChartListener;
+import org.tizen.dynamicanalyzer.ui.common.ChartPopupMenu;
import org.tizen.dynamicanalyzer.ui.common.TimeLineChartKeyListener;
import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseEventListener;
import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseTrackAdapter;
import org.tizen.dynamicanalyzer.widgets.chart.DAChartSeries;
import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoardItem;
import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenu;
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuItem;
public class NetworkChartBoard extends DADefaultChartBoard {
selectionMarker.setBackgroundColor(ColorResources.SELECTION_RANGE);
selectionMarker.setAlpha((int) (255 * 0.25));
addIntervalMarker(selectionMarker);
-
- // range analysis marker
- DAChartPlotIntervalMarker rangeAnalyzeMarker = new DAChartPlotIntervalMarker(-1, -1,
- DAChartPlotIntervalMarker.INTERVAL_MARKER_STYLE_AREA);
- rangeAnalyzeMarker.setBackgroundColor(ColorResources.YELLOW);
- rangeAnalyzeMarker.setAlpha((int) (255 * 0.25));
- addIntervalMarker(rangeAnalyzeMarker);
-
- // range marker
- DAChartPlotIntervalMarker rangeMarker = new DAChartPlotIntervalMarker(-1, -1,
- DAChartPlotIntervalMarker.INTERVAL_MARKER_STYLE_LINE);
- rangeMarker.setForegroundColor(ColorResources.RED);
- rangeMarker.setAlpha((int) (255 * 0.25));
- addIntervalMarker(rangeMarker);
}
private void initNetworkChart(final DAChart chart, boolean isParent) {
tooltip.setFont(FontResources.CHART_TOOLTIP_FONT);
plot.setTooltip(tooltip);
- DAPopupMenu popupMenu = new DAPopupMenu(chart);
+ DAPopupMenu popupMenu = new ChartPopupMenu(chart);
popupMenu.setFont(FontResources.CONTEXT_MENU_ITEM_FONT);
-
- DAPopupMenuItem analysisItem = new DAPopupMenuItem(popupMenu);
- analysisItem.setText(TimelineChartLabels.RANGE_CONTEXT_ANALYSIS);
- analysisItem.addListener(new PopupRangeAnalysisMenuItemOnChartListener(analysisItem, this, chart));
TimelineChartMouseEventListener timelineChartMouseEventListener = new TimelineChartMouseEventListener(
popupMenu, getTimeline(), NetworkPage.pageID);
import org.tizen.dynamicanalyzer.ui.common.UICommonConstants;
import org.tizen.dynamicanalyzer.ui.network.data.NetworkDataManager;
import org.tizen.dynamicanalyzer.ui.page.BaseView;
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
import org.tizen.dynamicanalyzer.ui.timeline.logparser.LifecycleLogParser;
import org.tizen.dynamicanalyzer.ui.toolbar.DAToolBarCustomCombo;
private DAToolBarCustomCombo processCombo;
- private final RangeDataManager rangeDataManager = RangeDataManager.getInstance();
-
public NetworkChartView(Composite parent, int style) {
super(parent, style, false);
this.setLayout(new FillLayout());
} else {
networkChartBoard.setTotalEndTime(Toolbar.INSTANCE.getTime(), false);
}
-
- if (RangeDataManager.getInstance().isBeingAnalyzed()) {
- ((DAChartPlotIntervalMarker) networkChartBoard.getMarkers().get(
- UICommonConstants.RANGE_ANALYSIS_MARKER_INDEX)).setInterval(
- rangeDataManager.getAnalysisStartTime() / TimelineConstants.MEGA_DOUBLE,
- rangeDataManager.getAnalysisEndTime() / TimelineConstants.MEGA_DOUBLE);
- } else {
- ((DAChartPlotIntervalMarker) networkChartBoard.getMarkers().get(
- UICommonConstants.RANGE_ANALYSIS_MARKER_INDEX)).setInterval(-1, -1);
- }
-
- ((DAChartPlotIntervalMarker) networkChartBoard.getMarkers().get(
- UICommonConstants.RANGE_MARKER_INDEX)).setInterval(
- rangeDataManager.getMarkerStartTime() / TimelineConstants.MEGA_DOUBLE,
- rangeDataManager.getMarkerEndTime() / TimelineConstants.MEGA_DOUBLE);
-
}
@Override
return networkChartBoard;
}
- public void setRangeMarker(double starttime, double endtime) {
- ((DAChartPlotIntervalMarker) networkChartBoard.getMarkers().get(
- UICommonConstants.RANGE_MARKER_INDEX)).setInterval(starttime, endtime);
- }
-
public DAChartBoard getChartBoard(){
return networkChartBoard;
}
this.setBackground(ColorResources.WHITE);
this.setLayout(new FillLayout());
-// ((FillLayout) getLayout()).marginHeight = 15;
-// ((FillLayout) getLayout()).marginWidth = 5;
-
NetworkChartView networkChartView = new NetworkChartView(topForm, SWT.NONE);
addView(networkChartView);
networkAPITableView = new DATabComposite(bottomLeftForm, SWT.NONE, false, true);
{
+ networkAPITableView.setID(AnalyzerLabels.LEFT_TABLE_VIEW_ID);
NetworkAPIListView networkApiListView = new NetworkAPIListView(networkAPITableView.getContentComposite(), SWT.NONE);
networkAPITableView.addView(networkApiListView);
- addView(networkApiListView);
}
addView(networkAPITableView);
-
+
DATabComposite networkDetailTableView = new DATabComposite(bottomRightForm, SWT.NONE, false, true);
{
+ networkDetailTableView.setID(AnalyzerLabels.RIGHT_TABLE_VIEW_ID);
NetworkDetailView detailInfo = new NetworkDetailView(networkDetailTableView.getContentComposite(), SWT.NONE);
networkDetailTableView.addView(detailInfo);
- addView(detailInfo);
}
addView(networkDetailTableView);
}
import org.tizen.dynamicanalyzer.resources.ColorResources;
import org.tizen.dynamicanalyzer.ui.network.data.NetworkDataManager;
import org.tizen.dynamicanalyzer.ui.network.data.type.NetworkSelectionType;
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
import org.tizen.dynamicanalyzer.ui.widgets.DAAdvancedViewComposite;
import org.tizen.dynamicanalyzer.util.Logger;
}
preSelectionPId = selectedPid;
- // Change Analyzer
- long newAnalysisStartTime = 0;
- long newAnalysisEndTime = 0;
- if (RangeDataManager.getInstance().isBeingAnalyzed()) {
- newAnalysisStartTime = RangeDataManager.getInstance().getAnalysisStartTime();
- newAnalysisEndTime = RangeDataManager.getInstance().getAnalysisEndTime();
- } else {
- newAnalysisStartTime = 0;
- newAnalysisEndTime = 0;
- }
- if (newAnalysisStartTime != preAnalysisStartTime
- || newAnalysisEndTime != preAnalysisEndTime) {
- preAnalysisStartTime = newAnalysisStartTime;
- preAnalysisEndTime = newAnalysisEndTime;
- isUpdate = true;
- }
// Change Selection
if (isChangedSelected) {
isChangedSelected = false;
addColumn(new DBColumn(API_TYPE, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
addColumn(new DBColumn(CALLER_PC_ADDRESS, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
addColumn(new DBColumn(LIB_NAME, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
- setIndexColumn(DB_API_TIME_INDEX);
+ addIndex(DB_API_TIME_INDEX);
}
public void insert(List<List<Object>> insetData) {
--- /dev/null
+package org.tizen.dynamicanalyzer.ui.notification;
+
+import java.util.ArrayList;
+import java.util.ListIterator;
+
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.dynamicanalyzer.util.WorkbenchUtil;
+import org.tizen.dynamicanalyzer.widgets.notification.DAPopupNotification;
+
+/**
+ * Manages shown notification pop-ups.
+ *
+ * @author d.nikiforov
+ */
+public class NotificationManager {
+
+ /**
+ * Should not be instantiated.
+ */
+ private NotificationManager() {
+ throw new IllegalAccessError();
+ }
+
+ /**
+ * Maximum number of displayed notifications.
+ */
+ private static final int MAX_NOTIFICATIONS_CAPACITY = 3;
+ /**
+ * Margin between two notifications.
+ */
+ private static final int VERTICAL_SPACING = 10;
+
+ /**
+ * Shown notifications.
+ */
+ private static ArrayList<DAPopupNotification> notifications = new ArrayList<>();
+
+ /**
+ * Removes notification from the list of shown notifications once it is
+ * disposed.
+ */
+ private static final DisposeListener listener = (DisposeEvent e) -> {
+ Shell disposedShell = (Shell) e.widget;
+ DAPopupNotification disposedNotification = (DAPopupNotification) disposedShell.getData();
+ removeNotification(disposedNotification);
+ };
+
+ /**
+ * Shows notification popup with specified text.
+ *
+ * @param title notification title
+ */
+ public static void showNotification(String title) {
+ showNotification(title, null, null);
+ }
+
+ /**
+ * Shows notification popup with specified text.
+ *
+ * @param title notification title
+ * @param message notification message
+ */
+ public static void showNotification(String title, String message) {
+ showNotification(title, message, null);
+ }
+
+ /**
+ * Shows notification popup with specified text.
+ *
+ * @param title notification title
+ * @param message notification message
+ * @param details notification details
+ */
+ public static void showNotification(String title, String message, String details) {
+ Display.getDefault().syncExec(() -> {
+ Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell();
+ DAPopupNotification newNotification = new DAPopupNotification(shell, title, message,
+ details);
+
+ addNotification(newNotification);
+
+ newNotification.addDisposeListener(listener);
+ newNotification.open();
+ });
+ }
+
+ /**
+ * Adds notification to the list of shown notifications and moves previous
+ * notifications higher.
+ *
+ * @param added notification to add
+ */
+ private static synchronized void addNotification(DAPopupNotification added) {
+ // if max capacity is reached, close the first notification
+ if (notifications.size() == MAX_NOTIFICATIONS_CAPACITY) {
+ DAPopupNotification first = notifications.get(0);
+ first.removeDisposeListener(listener);
+ first.close();
+ notifications.remove(first);
+ }
+
+ // move shown notifications up
+ notifications.listIterator().forEachRemaining((notification) -> {
+ Point newLocation = notification.getLocation();
+ newLocation.y -= (notification.getSize().y + VERTICAL_SPACING);
+ notification.setLocation(newLocation);
+ });
+
+ // add notification
+ notifications.add(added);
+ }
+
+ /**
+ * Removes the specified notification from the list of shown notifications.
+ *
+ * @param removed
+ */
+ private static synchronized void removeNotification(DAPopupNotification removed) {
+ int index = notifications.indexOf(removed);
+ if (index < 0)
+ // nothing to remove
+ return;
+
+ // move down all notifications older than removed
+ ListIterator<DAPopupNotification> it = notifications.listIterator(index);
+ while(it.hasPrevious()) {
+ DAPopupNotification notification = it.previous();
+ Point newLocation = notification.getLocation();
+ newLocation.y += (notification.getSize().y + VERTICAL_SPACING);
+ notification.setLocation(newLocation);
+ }
+
+ // remove notification
+ notifications.remove(removed);
+ }
+}
glLeftTableView = new DATabComposite(bottomLeftForm, SWT.NONE, false, true);
{
+ glLeftTableView.setID(AnalyzerLabels.LEFT_TABLE_VIEW_ID);
GLStatisticsTableView glStatisticsView = new GLStatisticsTableView(glLeftTableView.getContentComposite(), SWT.NONE);
glLeftTableView.addView(glStatisticsView);
- addView(glStatisticsView);
-
+
GLAPIListView glAPIListView = new GLAPIListView(glLeftTableView.getContentComposite(), SWT.NONE);
glLeftTableView.addView(glAPIListView);
- addView(glAPIListView);
}
addView(glLeftTableView);
-
+
glRightTableView = new DATabComposite(bottomRightForm, SWT.NONE, false, true);
{
+ glRightTableView.setID(AnalyzerLabels.RIGHT_TABLE_VIEW_ID);
GLRedundantTableView glRedundantView = new GLRedundantTableView(glRightTableView.getContentComposite(), SWT.NONE);
glRightTableView.addView(glRedundantView);
- addView(glRedundantView);
-
+
GLContextTableView glContextTableView = new GLContextTableView(glRightTableView.getContentComposite(), SWT.NONE);
glRightTableView.addView(glContextTableView);
- addView(glContextTableView);
-
+
GLProgramTableView glProgramTableView = new GLProgramTableView(glRightTableView.getContentComposite(), SWT.NONE);
glRightTableView.addView(glProgramTableView);
- addView(glProgramTableView);
-
+
GLTextureTableView glTextureTableView = new GLTextureTableView(glRightTableView.getContentComposite(), SWT.NONE);
glRightTableView.addView(glTextureTableView);
- addView(glTextureTableView);
}
addView(glRightTableView);
}
import java.util.List;
import org.eclipse.swt.graphics.Image;
-import org.tizen.dynamicanalyzer.nl.TimelineChartLabels;
import org.tizen.dynamicanalyzer.resources.FontResources;
import org.tizen.dynamicanalyzer.resources.ImageResources;
import org.tizen.dynamicanalyzer.swap.logparser.LogPackage;
-import org.tizen.dynamicanalyzer.ui.common.PopupRangeAnalysisMenuItemOnChartListener;
import org.tizen.dynamicanalyzer.widgets.chart.DAChart;
import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlot;
import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlot.AutoRangeType;
import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoard;
import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoardItem;
import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenu;
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuItem;
public abstract class GLChart {
protected DAChart chart;
public abstract void parseLogPackage(LogPackage logPack);
- public DAChartBoardItem createBoardItem(final DAChartBoard chartBoard, boolean enablePopupMenu) {
+ public DAChartBoardItem createBoardItem(final DAChartBoard chartBoard) {
DAChartBoardItem item = new DAChartBoardItem(chartBoard, chartName,
chartIcon, chartStyle);
chart = item.getChart();
setChartStyle();
- if(enablePopupMenu){
- popupMenu = new DAPopupMenu(chart);
- initPopupMenu(chartBoard, popupMenu);
- }
return item;
}
- protected void initPopupMenu(DAChartBoard chartBoard, DAPopupMenu popupMenu) {
- popupMenu.setFont(FontResources.CONTEXT_MENU_ITEM_FONT);
-
- DAPopupMenuItem analysisItem = new DAPopupMenuItem(popupMenu);
- analysisItem.setText(TimelineChartLabels.RANGE_CONTEXT_ANALYSIS);
- analysisItem.addListener(new PopupRangeAnalysisMenuItemOnChartListener(analysisItem, chartBoard, chart));
- }
-
public void clear() {
List<DAChartSeries> seriesList = chart.getSeriesList();
for (DAChartSeries series : seriesList) {
selectionMarker.setBackgroundColor(ColorResources.SELECTION_RANGE);
selectionMarker.setAlpha((int) (255 * 0.25));
addIntervalMarker(selectionMarker);
-
- // range analysis marker
- DAChartPlotIntervalMarker rangeAnalyzeMarker = new DAChartPlotIntervalMarker(
- -1, -1, DAChartPlotIntervalMarker.INTERVAL_MARKER_STYLE_AREA);
- rangeAnalyzeMarker.setBackgroundColor(ColorResources.YELLOW);
- rangeAnalyzeMarker.setAlpha((int) (255 * 0.25));
- addIntervalMarker(rangeAnalyzeMarker);
-
- // range marker
- DAChartPlotIntervalMarker rangeMarker = new DAChartPlotIntervalMarker(
- -1, -1, DAChartPlotIntervalMarker.INTERVAL_MARKER_STYLE_LINE);
- rangeMarker.setForegroundColor(ColorResources.RED);
- rangeMarker.setAlpha((int) (255 * 0.25));
- addIntervalMarker(rangeMarker);
}
}
}
@Override
- public DAChartBoardItem createBoardItem(DAChartBoard chartBoard, boolean enablePopupMenu) {
- DAChartBoardItem item = super.createBoardItem(chartBoard, enablePopupMenu);
+ public DAChartBoardItem createBoardItem(DAChartBoard chartBoard) {
+ DAChartBoardItem item = super.createBoardItem(chartBoard);
chart.addSeries(frameRateSeries);
chart.getPlot().setSeriesHeightRange(true);
chart.getPlot().setAutoHeightRange(AutoRangeType.AUTO);
import org.tizen.dynamicanalyzer.ui.common.TimeLineChartKeyListener;
import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseEventListener;
import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseTrackAdapter;
-import org.tizen.dynamicanalyzer.ui.common.UICommonConstants;
import org.tizen.dynamicanalyzer.ui.opengl.GLPage;
import org.tizen.dynamicanalyzer.ui.opengl.chart.listener.GLFrameRateMouseListener;
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
import org.tizen.dynamicanalyzer.ui.timeline.chart.CPUChart;
import org.tizen.dynamicanalyzer.ui.timeline.chart.ScreenshotChart;
import org.tizen.dynamicanalyzer.ui.timeline.chart.TimelineChart;
import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineChartManager;
-import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineDataManager;
import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
import org.tizen.dynamicanalyzer.widgets.chart.DAChart;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotIntervalMarker;
import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoard;
import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoardItem;
AnalyzerUtil.translateSecToMicroSec(getVisibleStartTime()),
AnalyzerUtil.translateSecToMicroSec(getVisibleEndTime()));
- double timelineMarkerStartTime = RangeDataManager.getInstance().getMarkerStartTime()
- / TimelineConstants.MEGA_DOUBLE;
- double timelineMarkerEndTime = RangeDataManager.getInstance().getMarkerEndTime()
- / TimelineConstants.MEGA_DOUBLE;
-
- double analysisStartTime = RangeDataManager.getInstance().getAnalysisStartTime()
- / TimelineConstants.MEGA_DOUBLE;
- double analysisEndTime = RangeDataManager.getInstance().getAnalysisEndTime()
- / TimelineConstants.MEGA_DOUBLE;
-
- if (RangeDataManager.getInstance().isBeingAnalyzed()) {
-
- ((DAChartPlotIntervalMarker) getMarkers().get(
- UICommonConstants.RANGE_ANALYSIS_MARKER_INDEX)).setInterval(analysisStartTime,
- analysisEndTime);
- } else {
- ((DAChartPlotIntervalMarker) getMarkers().get(
- UICommonConstants.RANGE_ANALYSIS_MARKER_INDEX)).setInterval(-1, -1);
- }
updateViewFromDBData();
}
initIntervalMarkers();
GLFrameRateChart frameRateChart = GLFrameRateChart.getInstance();
- DAChartBoardItem frameRateChartItem = frameRateChart.createBoardItem(this, true);
+ DAChartBoardItem frameRateChartItem = frameRateChart.createBoardItem(this);
DAChart frameRateChartWidget = frameRateChartItem.getChart();
GLFrameRateMouseListener glFrameRateMouseEventListener = new GLFrameRateMouseListener(
}
@Override
- public DAChartBoardItem createBoardItem(DAChartBoard chartBoard, boolean enablePopupMenu) {
- DAChartBoardItem item = super.createBoardItem(chartBoard, enablePopupMenu);
+ public DAChartBoardItem createBoardItem(DAChartBoard chartBoard) {
+ DAChartBoardItem item = super.createBoardItem(chartBoard);
chart.addSeries(frameTimeSeries);
chart.getPlot().setSeriesHeightRange(true);
import org.eclipse.swt.widgets.Composite;
import org.tizen.dynamicanalyzer.ui.common.TimeLineChartKeyListener;
import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseTrackAdapter;
-import org.tizen.dynamicanalyzer.ui.common.UICommonConstants;
import org.tizen.dynamicanalyzer.ui.opengl.GLPage;
import org.tizen.dynamicanalyzer.ui.opengl.chart.listener.GLFrameTimeBoundMouseListener;
import org.tizen.dynamicanalyzer.ui.opengl.chart.listener.GLFrameTimeMouseListener;
import org.tizen.dynamicanalyzer.ui.opengl.data.GLDataManager;
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
import org.tizen.dynamicanalyzer.widgets.chart.DAChart;
import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlot;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotIntervalMarker;
import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoardItem;
public class GLFrameTimeChartBoard extends GLChartBoard {
setTotalEndTime(totalEndTime, false);
}
- double timelineMarkerStartTime = RangeDataManager.getInstance()
- .getMarkerStartTime() / TimelineConstants.MEGA_DOUBLE;
- double timelineMarkerEndTime = RangeDataManager.getInstance()
- .getMarkerEndTime() / TimelineConstants.MEGA_DOUBLE;
-
- double analysisStartTime = RangeDataManager.getInstance()
- .getAnalysisStartTime() / TimelineConstants.MEGA_DOUBLE;
- double analysisEndTime = RangeDataManager.getInstance()
- .getAnalysisEndTime() / TimelineConstants.MEGA_DOUBLE;
-
- if (RangeDataManager.getInstance().isBeingAnalyzed()) {
- ((DAChartPlotIntervalMarker) getMarkers().get(
- UICommonConstants.RANGE_ANALYSIS_MARKER_INDEX))
- .setInterval(analysisStartTime, analysisEndTime);
- } else {
- ((DAChartPlotIntervalMarker) getMarkers().get(
- UICommonConstants.RANGE_ANALYSIS_MARKER_INDEX))
- .setInterval(-1, -1);
- }
-
- ((DAChartPlotIntervalMarker) getMarkers().get(
- UICommonConstants.RANGE_MARKER_INDEX)).setInterval(
- timelineMarkerStartTime, timelineMarkerEndTime);
-
- ((DAChartPlotIntervalMarker) getMarkers().get(
- UICommonConstants.RANGE_ANALYSIS_MARKER_INDEX)).setInterval(-1,
- -1);
-
updateViewFromDBData();
}
initIntervalMarkers();
GLFrameTimeChart frameTimeChart = GLFrameTimeChart.getInstance();
- DAChartBoardItem frameTimeChartItem = frameTimeChart.createBoardItem(
- this, false);
+ DAChartBoardItem frameTimeChartItem = frameTimeChart.createBoardItem(this);
DAChart frameTimeChartWidget = frameTimeChartItem.getChart();
GLFrameTimeMouseListener glFrameChartMouseEventListener = new GLFrameTimeMouseListener(
package org.tizen.dynamicanalyzer.ui.opengl.chart.listener;
-import java.util.List;
-
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseEvent;
import org.tizen.dynamicanalyzer.common.AnalyzerManager;
import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotIntervalMarker;
import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotMarker;
import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenu;
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuItem;
import org.tizen.dynamicanalyzer.widgets.timeline.DATimeline;
import org.tizen.dynamicanalyzer.widgets.timeline.MarkerManager;
double eventTime = plot.getXFromXPixel(e.x);
if (e.button == 3) {
- List<DAPopupMenuItem> itemList = menu.getItems();
- for(DAPopupMenuItem item : itemList) {
- item.setDoubleData(eventTime);
- }
+ if (menu != null)
+ menu.getItems().forEach((item) -> item.setDoubleData(eventTime));
return;
}
addColumn(new DBColumn(TID, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
addColumn(new DBColumn(CALLER_PC_ADDRESS, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
addColumn(new DBColumn(LIB_NAME, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
- setIndexColumn(TABLE_FRAME_INDEX_INDEX);
+ addIndex(TABLE_FRAME_INDEX_INDEX);
}
public void insert(List<GLAPIData> apiData) {
DBConstants.DBTYPE_INT4));
addColumn(new DBColumn(ELEMENT_ARRAY_BUFFER_USAGE, DBConstants.NOT_NULL,
DBConstants.DBTYPE_INT4));
- setIndexColumn(TABLE_CONTEXT_ID_INDEX);
+ addIndex(TABLE_CONTEXT_ID_INDEX);
}
public GLBufferSizeType getBufferSize(long contextID, long selectedSeq) {
for (int i = 0; i < length; i++) {
addColumn(new DBColumn(columnName[i], options[i], types[i]));
}
- setIndexColumn(TABLE_CONTEXT_ID_INDEX);
+ addIndex(TABLE_CONTEXT_ID_INDEX);
}
public String[] getColumnName() {
addColumn(new DBColumn(FRAME_MAKING_TIME, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
addColumn(new DBColumn(ERROR_INFO, DBConstants.NOT_NULL, DBConstants.DBTYPE_BOOLEAN));
addColumn(new DBColumn(PID, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
- setIndexColumn(TABLE_CHART_TIME_INDEX);
+ addIndex(TABLE_CHART_TIME_INDEX);
}
public int getFrameSize() {
addColumn(new DBColumn(CHANGE_SEQ, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
addColumn(new DBColumn(FRAME_RATE_INDEX, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
addColumn(new DBColumn(FRAME_TIME_INDEX, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
- setIndexColumn(TABLE_CONTEXT_ID_INDEX);
- setIndexColumn(TABLE_CONTEXT_DB_INDEX_INDEX);
- setIndexColumn(TABLE_CHANGE_SEQ_INDEX);
+ addIndex(TABLE_CONTEXT_ID_INDEX, TABLE_CONTEXT_DB_INDEX_INDEX, TABLE_CHANGE_SEQ_INDEX);
}
public void insertData(long contextId, int stateIndex, long seq, int frameRateIndex,
import org.tizen.dynamicanalyzer.constant.CommonConstants;
import org.tizen.dynamicanalyzer.model.FilterProperty;
import org.tizen.dynamicanalyzer.model.TableInput;
-import org.tizen.dynamicanalyzer.ui.file.FileChartView;
-import org.tizen.dynamicanalyzer.ui.file.FilePage;
-import org.tizen.dynamicanalyzer.ui.memory.MemoryChartView;
-import org.tizen.dynamicanalyzer.ui.memory.MemoryPage;
-import org.tizen.dynamicanalyzer.ui.network.NetworkChartView;
-import org.tizen.dynamicanalyzer.ui.network.NetworkPage;
import org.tizen.dynamicanalyzer.ui.opengl.GLPage;
-import org.tizen.dynamicanalyzer.ui.opengl.chart.GLChartView;
import org.tizen.dynamicanalyzer.ui.opengl.data.GLDataManager;
import org.tizen.dynamicanalyzer.ui.opengl.data.DB.GLAPIDBTableManager;
import org.tizen.dynamicanalyzer.ui.opengl.data.type.GLAPIData;
import org.tizen.dynamicanalyzer.ui.opengl.data.type.GLConstantDefine;
import org.tizen.dynamicanalyzer.ui.opengl.data.type.GLES20ErrorDefine;
import org.tizen.dynamicanalyzer.ui.opengl.data.type.GLSelectionData;
-import org.tizen.dynamicanalyzer.ui.page.BaseView;
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
-import org.tizen.dynamicanalyzer.ui.thread.ThreadPage;
-import org.tizen.dynamicanalyzer.ui.thread.chart.ThreadChartView;
-import org.tizen.dynamicanalyzer.ui.timeline.TimelinePage;
-import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineChartView;
-import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
-import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
import org.tizen.dynamicanalyzer.ui.widgets.table.DATableComposite;
import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat;
-import org.tizen.dynamicanalyzer.util.WorkbenchUtil;
-import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
import org.tizen.dynamicanalyzer.utils.Formatter;
import org.tizen.dynamicanalyzer.widgets.timeline.MarkerManager;
} else if(e.keyCode == SWT.F5) {
if(DAState.isStartable() && Toolbar.INSTANCE.getStartButton().getState() == DACustomButton.STATE_NORMAL) { //start trace
MarkerManager.INSTANCE.clearMarkerList();
- CommandAction.startTrace(false);
+ CommandAction.startTrace();
} else if(DAState.isRunning() && Toolbar.INSTANCE.getStartButton().getState() == DACustomButton.STATE_NORMAL) { //stop trace
CommandAction.stopTrace(new DAResult(ErrorCode.SUCCESS), false);
}
return;
}
- TimelineTableView tableView = (TimelineTableView) AnalyzerUtil.getView(TimelinePage.pageID, TimelineTableView.class.getName());
+ TimelineTableView tableView = (TimelineTableView) AnalyzerUtil.getView(TimelinePage.pageID, AnalyzerLabels.LEFT_TABLE_VIEW_ID);
MenuItem source = (MenuItem) arg0.getSource();
if (menuName.equals(MenuBarLabels.VIEW_FUNCTION_PROFILING)) {
if(source.getSelection()) {
Object result = dialog.open();
if (null != result) {
+ // TODO Time Consuming Process : make progress bar for this task
+ // or move this in another thread in the future.
if (!CommandAction.saveToZip((String) result)) {
UIActionHolder.getUIAction().showWarning(AnalyzerLabels.SAVE_FAILED);
}
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
-import org.tizen.dynamicanalyzer.common.Global;
import org.tizen.dynamicanalyzer.setting.SettingConstants;
import org.tizen.dynamicanalyzer.setting.SettingDataManager;
import org.tizen.dynamicanalyzer.swap.logparser.PageDataManager;
import org.tizen.dynamicanalyzer.ui.hierarchy.HierarchyDataManager;
import org.tizen.dynamicanalyzer.ui.hierarchy.HierarchyPage;
import org.tizen.dynamicanalyzer.ui.info.screenshot.ScreenshotDataManager;
-import org.tizen.dynamicanalyzer.ui.interactive.InteractivePage;
-import org.tizen.dynamicanalyzer.ui.interactive.data.InteractiveDataManager;
-import org.tizen.dynamicanalyzer.ui.kernel.KernelPage;
-import org.tizen.dynamicanalyzer.ui.kernel.data.KernelDataManager;
import org.tizen.dynamicanalyzer.ui.memory.MemoryPage;
import org.tizen.dynamicanalyzer.ui.memory.data.HeapDataManager;
+import org.tizen.dynamicanalyzer.ui.memory.data.LsanDataManager;
import org.tizen.dynamicanalyzer.ui.memory.data.MemoryDataManager;
import org.tizen.dynamicanalyzer.ui.network.NetworkPage;
import org.tizen.dynamicanalyzer.ui.network.data.NetworkDataManager;
import org.tizen.dynamicanalyzer.ui.timeline.calltrace.CallTraceDataManager;
import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineDataManager;
import org.tizen.dynamicanalyzer.ui.timeline.dlog.DLogDataManager;
-import org.tizen.dynamicanalyzer.ui.userinterface.UIDataManager;
-import org.tizen.dynamicanalyzer.ui.userinterface.UIPage;
import org.tizen.dynamicanalyzer.util.Logger;
import org.tizen.dynamicanalyzer.widgets.da.view.DABaseComposite;
SettingConstants.PAGE_NAME_OPENGL);
glPageInfo.addDataManager(GLDataManager.class);
- PageInfo kernelPageInfo = new PageInfo(KernelPage.class,
- SettingConstants.PAGE_NAME_KERNEL);
- kernelPageInfo.addDataManager(KernelDataManager.class);
-
PageInfo networkPageInfo = new PageInfo(NetworkPage.class,
SettingConstants.PAGE_NAME_NETWORK);
networkPageInfo.addDataManager(NetworkDataManager.class);
SettingConstants.PAGE_NAME_TIME_LINE, true);
timelinePageInfo.addDataManager(TimelineDataManager.class);
timelinePageInfo.addDataManager(CallTraceDataManager.class);
- // InteractiveDataManager is not supported in CLI mode
- if (Global.isGUIMode()) {
- timelinePageInfo.addDataManager(InteractiveDataManager.class);
- }
timelinePageInfo.addDataManager(ScreenshotDataManager.class);
timelinePageInfo.addDataManager(MemoryDataManager.class);
timelinePageInfo.addDataManager(DLogDataManager.class);
timelinePageInfo.addDataManager(FunctionUsageProfiler.class);
timelinePageInfo.addDataManager(SummaryDataManager.class);
- PageInfo uiPageInfo = new PageInfo(UIPage.class,
- SettingConstants.PAGE_NAME_UI);
- uiPageInfo.addDataManager(UIDataManager.class);
-
- PageInfo interactivePageInfo = new PageInfo(InteractivePage.class,
- SettingConstants.PAGE_NAME_INTERACTIVE);
- // InteractiveDataManager is not supported in CLI mode
- if (Global.isGUIMode())
- interactivePageInfo.addDataManager(InteractiveDataManager.class);
-
PageInfo hierarchyPageInfo = new PageInfo(HierarchyPage.class,
SettingConstants.PAGE_NAME_HIERARCHY);
hierarchyPageInfo.addDataManager(HierarchyDataManager.class);
SettingConstants.PAGE_NAME_MEMORY);
memoryPageInfo.addDataManager(MemoryDataManager.class);
memoryPageInfo.addDataManager(HeapDataManager.class);
+ memoryPageInfo.addDataManager(LsanDataManager.class);
// Register pages to ordered list
// Add new entry here for each new page introduced in Dynamic Analyzer
networkPageInfo,
filePageInfo,
glPageInfo,
- uiPageInfo,
- kernelPageInfo,
- interactivePageInfo,
hierarchyPageInfo,
summaryPageInfo));
Set<String> selectedPageSet = SettingDataManager.INSTANCE.getSelectedPageList(targetName);
// add default pages
selectedPageSet.addAll(defaultPages);
- // Add interactive page when needed
- if (Global.isGUIMode() && !InteractiveDataManager.getInstance().getVariableInfoList().isEmpty()) {
- selectedPageSet.add(SettingConstants.PAGE_NAME_INTERACTIVE);
- }
return selectedPageSet;
}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Seokgil Kang <seokgil.kang@samsung.com>
- * WooJin Jung <woojin2.jung@samsung.com>
- * Jooyoul Lee <jy.exe.lee@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.range;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.PriorityQueue;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
-import org.tizen.dynamicanalyzer.common.AnalyzerManager;
-import org.tizen.dynamicanalyzer.common.DASelectionData;
-import org.tizen.dynamicanalyzer.database.SqlConnectionManager;
-import org.tizen.dynamicanalyzer.project.callstack.BaseCallstackManager;
-import org.tizen.dynamicanalyzer.project.callstack.RangeCallstackManager;
-import org.tizen.dynamicanalyzer.protocol.ProtocolConstants;
-import org.tizen.dynamicanalyzer.swap.model.data.ProfileData;
-import org.tizen.dynamicanalyzer.swap.model.data.WebProfileData;
-import org.tizen.dynamicanalyzer.ui.summary.SummaryDataManager;
-import org.tizen.dynamicanalyzer.ui.summary.profiling.FunctionSampleDBTable;
-import org.tizen.dynamicanalyzer.ui.summary.profiling.ProfileDataMaker;
-import org.tizen.dynamicanalyzer.ui.summary.profiling.RangeProfileDataMaker;
-import org.tizen.dynamicanalyzer.ui.summary.profiling.WebProfileDataMaker;
-import org.tizen.dynamicanalyzer.ui.timeline.TimelinePage;
-import org.tizen.dynamicanalyzer.ui.timeline.calltrace.FunctionEntryDBTable;
-import org.tizen.dynamicanalyzer.ui.timeline.calltrace.FunctionExitDBTable;
-import org.tizen.dynamicanalyzer.ui.timeline.calltrace.WebFunctionEntryDBTable;
-import org.tizen.dynamicanalyzer.ui.timeline.calltrace.WebFunctionExitDBTable;
-import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
-import org.tizen.dynamicanalyzer.util.Logger;
-import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
-import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
-import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener;
-import org.tizen.dynamicanalyzer.widgets.da.view.DABaseComposite;
-import org.tizen.dynamicanalyzer.widgets.da.view.DAContainerComposite;
-import org.tizen.dynamicanalyzer.widgets.da.view.DATabButton;
-import org.tizen.dynamicanalyzer.widgets.da.view.DATabComposite;
-import org.tizen.dynamicanalyzer.widgets.timeline.MarkerManager;
-
-public class RangeDataManager implements Runnable {
- private static RangeDataManager instance = null;
- private Thread rangeThread = null;
- private Map<Integer, WebProfileDataMaker> webProfileDataMakerMap = null;
- private Map<Integer, ProfileDataMaker> profileDataMakerMap = null;
- private BaseCallstackManager rangeCallstackManager = null;
-
- private long markerStartTime = 0;
- private long markerEndTime = 0;
- private long analysisStartTime = 0;
- private long analysisEndTime = 0;
-
- private boolean isBeingAnalyzed = false;
-
- private enum Function {
- SEQ(1), // ResultSet column index starts from 1
- PID(2),
- TID(3),
- FUNCTIONID(4),
- BINARYID(5),
- TIME(6),
- CALLERPCADDR(7),
- PCADDR(8);
-
- public final int index;
-
- Function(int index) {
- this.index = index;
- }
- }
-
- private enum Sample {
- TIME(1), PID(2), TID(3), PCADDR(4);
-
- public final int index;
-
- Sample(int index) {
- this.index = index;
- }
- }
-
- private RangeDataManager() {
- rangeCallstackManager = new RangeCallstackManager();
- }
-
- public synchronized void clearRange() {
- rangeCallstackManager.clear();
- if (profileDataMakerMap != null)
- profileDataMakerMap.clear();
-
- if (webProfileDataMakerMap != null) {
- webProfileDataMakerMap.clear();
- }
- }
-
- public void initRange() {
- clearRange();
- analysisStartTime = 0;
- analysisEndTime = 0;
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- isBeingAnalyzed = false;
-
- DATabComposite mainTab = AnalyzerUtil.getMainTab();
- if (null != mainTab.getView(RangePage.pageID)) {
- // mainTab.removeView(page.getViewName(), true);
- mainTab.removeView(RangePage.pageID, true);
- }
- }
- });
- }
-
- public void startRangeThread() {
- clearRange();
- if (null == rangeThread || !rangeThread.isAlive()) {
- rangeThread = new Thread(null, getInstance(), "Range data manager thread"); //$NON-NLS-1$
- rangeThread.start();
-
- analysisStartTime = markerStartTime;
- analysisEndTime = markerEndTime;
- isBeingAnalyzed = true;
- }
- }
-
- public void startRangeAnalysis() {
- if (!isBeingAnalyzed) {
- DATabComposite mainTab = AnalyzerUtil.getMainTab();
- DABaseComposite rangePage = new RangePage(mainTab.getContentComposite(), SWT.NONE);
- DATabButton rangeTab = mainTab.addView(null, rangePage, true, true);
- rangeTab.addCloseButtonListener(new DACustomButtonClickEventListener() {
- @Override
- public void handleClickEvent(DACustomButton button) {
- RangeDataManager.getInstance().initRange();
- }
- });
- startRangeThread();
- } else {
- startRangeThread();
- }
- }
-
- public void stopUpdateLogThread() {
- if (null != rangeThread && rangeThread.isAlive()) {
- rangeThread.interrupt();
- }
- }
-
- public synchronized static RangeDataManager getInstance() {
- if (null == instance) {
- instance = new RangeDataManager();
- }
- return instance;
- }
-
- public List<Integer> getPidsOfProfileDataMakerMap() {
- ArrayList<Integer> pids = new ArrayList<Integer>();
- pids.addAll(getProfileDataMakerMap().keySet());
- return pids;
- }
-
- public synchronized Map<Integer, ProfileDataMaker> getProfileDataMakerMap() {
- if (null == profileDataMakerMap) {
- profileDataMakerMap = new HashMap<Integer, ProfileDataMaker>();
- }
- return profileDataMakerMap;
- }
-
- public ProfileDataMaker getProfileDataMakerByPid(int pid) {
- ProfileDataMaker profileDataMaker = getProfileDataMakerMap().get(pid);
- if (null == profileDataMaker) {
- // if (DACommunicator.isSWAPVersion()) {
- profileDataMaker = new RangeProfileDataMaker(rangeCallstackManager);
- // }
- profileDataMaker.setPid(pid);
- getProfileDataMakerMap().put(pid, profileDataMaker);
- }
- return profileDataMaker;
- }
-
- public List<Integer> getPidsOfWebProfileDataMakerMap() {
- ArrayList<Integer> pids = new ArrayList<Integer>();
- pids.addAll(getWebProfileDataMakerMap().keySet());
- return pids;
- }
-
- public synchronized Map<Integer, WebProfileDataMaker> getWebProfileDataMakerMap() {
- if (null == webProfileDataMakerMap) {
- webProfileDataMakerMap = new HashMap<Integer, WebProfileDataMaker>();
- }
- return webProfileDataMakerMap;
- }
-
- public WebProfileDataMaker getWebProfileDataMakerByPid(int pid) {
- WebProfileDataMaker webProfileDataMaker = getWebProfileDataMakerMap().get(pid);
- if (null == webProfileDataMaker) {
- webProfileDataMaker = new WebProfileDataMaker(pid);
- getWebProfileDataMakerMap().put(pid, webProfileDataMaker);
- }
- return webProfileDataMaker;
- }
-
- public void setMarkerStartTime(long startTime) {
- markerStartTime = startTime;
- if (startTime > markerEndTime) {
- markerEndTime = startTime;
- }
- }
-
- public void setMarkerEndTime(long endTime) {
- markerEndTime = endTime;
- if (endTime < markerStartTime) {
- markerStartTime = endTime;
- }
- }
-
- public void setRangeFromMarkerList(long time) {
- List<Long> markerTimeListLong = MarkerManager.INSTANCE
- .getMarkerTimeListLong();
-
- if(markerTimeListLong.size() >= 1 && !markerTimeListLong.contains(time)) {
- int findIndex = -1;
-
- for(int i = 0; i < markerTimeListLong.size(); i++) {
- if(markerTimeListLong.get(i) > time) {
- findIndex = i;
- break;
- }
- }
-
- if(findIndex == 0) {
- markerStartTime = 0;
- markerEndTime = markerTimeListLong.get(findIndex);
- } else if(findIndex == -1) {
- markerStartTime = markerTimeListLong.get(markerTimeListLong.size()-1);
- markerEndTime = Toolbar.INSTANCE.getTime();
- } else {
- markerStartTime = markerTimeListLong.get(findIndex-1);
- markerEndTime = markerTimeListLong.get(findIndex);
- }
-
- // if click analyze range, setDlogselection false.
- Toolbar.INSTANCE.setDlogSelection(false);
-
- AnalyzerManager.getCurrentPage().updateView(
- new DASelectionData(TimelinePage.timelineViewID, markerStartTime, markerEndTime, null, null));
- }
- }
-
- public long getMarkerStartTime() {
- return markerStartTime;
- }
-
- public long getMarkerEndTime() {
- return markerEndTime;
- }
-
- public long getAnalysisStartTime() {
- return analysisStartTime;
- }
-
- public long getAnalysisEndTime() {
- return analysisEndTime;
- }
-
- public boolean isBeingAnalyzed() {
- return isBeingAnalyzed;
- }
-
- public boolean isAnalyzable() {
- if (markerStartTime >= 0 && markerEndTime >= 0
- && (markerStartTime != analysisStartTime || markerEndTime != analysisEndTime)) {
- return true;
- } else {
- return false;
- }
- }
-
- public boolean isClearable() {
- if (markerStartTime >= 0 || markerEndTime >= 0) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public void run() {
- // case 1 : profile data
- ResultSet rsEntry = null;
- ResultSet rsExit = null;
- ResultSet rsSample = null;
- PriorityQueue<ProfileData> pQueue = new PriorityQueue<ProfileData>(3,
- new Comparator<ProfileData>() {
- public int compare(ProfileData pData1, ProfileData pData2) {
- long time1 = pData1.getTime();
- long time2 = pData2.getTime();
- if (time1 < time2) {
- return -1;
- } else if (time1 > time2) {
- return 1;
- } else {
- return 0;
- }
- }
- });
-
- try {
- String query = String.format(FunctionEntryDBTable.SELECT_QUERY, markerStartTime,
- markerEndTime);
- rsEntry = SqlConnectionManager.executeQueryRS(query);
-
- query = String.format(FunctionExitDBTable.SELECT_QUERY, markerStartTime, markerEndTime);
- rsExit = SqlConnectionManager.executeQueryRS(query);
-
- query = String.format(FunctionSampleDBTable.SELECT_QUERY, markerStartTime,
- markerEndTime);
- rsSample = SqlConnectionManager.executeQueryRS(query);
-
- if (rsEntry == null || rsExit == null || rsSample == null) {
- Logger.error("failed to query function profiling data in range");
- } else {
- if (rsEntry.next()) {
- ProfileData pEntry = makeFunctionProfileData(
- ProtocolConstants.MSG_FUNCTION_ENTRY, rsEntry);
- pQueue.offer(pEntry);
- }
- if (rsExit.next()) {
- ProfileData pExit = makeFunctionProfileData(
- ProtocolConstants.MSG_FUNCTION_EXIT, rsExit);
- pQueue.offer(pExit);
- }
- if (rsSample.next()) {
- ProfileData pSample = makeSampleProfileData(rsSample);
- pQueue.offer(pSample);
- }
- // handle entry/exit/sample data one by one in
- // chronological order
- while (true) {
- ProfileData top = pQueue.poll();
- if (top == null) {
- break;
- }
- ProfileDataMaker profileDataMaker = getProfileDataMakerByPid(top.getPid());
-
- switch (top.getMsgID()) {
- case ProtocolConstants.MSG_FUNCTION_ENTRY:
- if (rsEntry.next()) {
- ProfileData pEntry = makeFunctionProfileData(
- ProtocolConstants.MSG_FUNCTION_ENTRY, rsEntry);
- pQueue.offer(pEntry);
- }
- rangeCallstackManager.makeUserCallstack(top, profileDataMaker);
- break;
- case ProtocolConstants.MSG_FUNCTION_EXIT:
- if (rsExit.next()) {
- ProfileData pExit = makeFunctionProfileData(
- ProtocolConstants.MSG_FUNCTION_EXIT, rsExit);
- pQueue.offer(pExit);
- }
- rangeCallstackManager.makeUserCallstack(top, profileDataMaker);
- break;
- case ProtocolConstants.MSG_DATA_SAMPLE:
- if (rsSample.next()) {
- ProfileData pSample = makeSampleProfileData(rsSample);
- pQueue.offer(pSample);
- }
- profileDataMaker.makeFunctionUsageProfileData(top);
- break;
- default: // never goes here
- Logger.error("Wrong data from selecting function profiling data inside range");
- break;
- }
- }
- }
- } catch (SQLException e) {
- Logger.exception(e);
- } finally {
- if (rsEntry != null) {
- SqlConnectionManager.releaseResultSet(rsEntry);
- }
- if (rsExit != null) {
- SqlConnectionManager.releaseResultSet(rsExit);
- }
- if (rsSample != null) {
- SqlConnectionManager.releaseResultSet(rsSample);
- }
- }
-
- // make web profile data
- makeWebProfileDataForRange();
-
-
- AnalyzerUtil.changePage(RangePage.pageID);
- final DAContainerComposite page = AnalyzerManager.getCurrentPage();
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- page.updateView();
- }
- });
- }
-
- private ProfileData makeFunctionProfileData(int id, ResultSet rs) {
- ProfileData profileData = null;
- try {
- long seq = rs.getLong(Function.SEQ.index);
- int pid = rs.getInt(Function.PID.index);
- int tid = rs.getInt(Function.TID.index);
- int functionId = rs.getInt(Function.FUNCTIONID.index);
- int binaryId = rs.getInt(Function.BINARYID.index);
- long time = rs.getLong(Function.TIME.index);
- long callerPcAddr = rs.getLong(Function.CALLERPCADDR.index);
- long pcAddr = rs.getLong(Function.PCADDR.index);
-
- profileData = new ProfileData(id, seq, pid, tid, functionId, binaryId, time,
- callerPcAddr, pcAddr);
- } catch (SQLException e) {
- Logger.exception(e);
- }
- return profileData;
- }
-
- private ProfileData makeSampleProfileData(ResultSet rs) {
- ProfileData profileData = null;
- try {
- long time = rs.getLong(Sample.TIME.index);
- int pid = rs.getInt(Sample.PID.index);
- int tid = rs.getInt(Sample.TID.index);
- long pcAddr = rs.getLong(Sample.PCADDR.index);
-
- profileData = new ProfileData(time, pid, tid, pcAddr);
- } catch (SQLException e) {
- Logger.exception(e);
- }
- return profileData;
- }
-
- private WebProfileData makeWebProfileData(int id, ResultSet rs) {
- WebProfileData profileData = null;
- try {
- long seq = rs.getLong(1);
- int pid = rs.getInt(2);
- int tid = rs.getInt(3);
- int functionLineNumber = rs.getInt(4);
- String functionName = rs.getString(5);
- String functionURL = rs.getString(6);
- long time = rs.getLong(7);
-
- profileData = new WebProfileData(id, seq, pid, tid, functionLineNumber, functionName, functionURL, time);
- } catch (SQLException e) {
- Logger.exception(e);
- }
- return profileData;
- }
-
- private void makeWebProfileDataForRange() {
- ResultSet rsWebEntry = null;
- ResultSet rsWebExit = null;
- // TODO: code improvement regarding use of priority Queue
- PriorityQueue<WebProfileData> pWebQueue = new PriorityQueue<WebProfileData>(3,
- new Comparator<WebProfileData>() {
- public int compare(WebProfileData pData1, WebProfileData pData2) {
- long time1 = pData1.getTime();
- long time2 = pData2.getTime();
- if (time1 < time2) {
- return -1;
- } else if (time1 > time2) {
- return 1;
- } else {
- return 0;
- }
- }
- });
-
- try {
- String query = String.format(WebFunctionEntryDBTable.SELECT_QUERY, markerStartTime, markerEndTime);
- rsWebEntry = SqlConnectionManager.executeQueryRS(query);
-
- query = String.format(WebFunctionExitDBTable.SELECT_QUERY, markerStartTime, markerEndTime);
- rsWebExit = SqlConnectionManager.executeQueryRS(query);
-
-
- if (rsWebEntry == null || rsWebExit == null) {
- Logger.error("failed to query web function profiling data in range");
- } else {
- if (rsWebEntry.next()) {
- WebProfileData pWebEntry = makeWebProfileData(ProtocolConstants.MSG_WEB_FUNCTION_ENTRY, rsWebEntry);
- pWebQueue.offer(pWebEntry);
- }
- if (rsWebExit.next()) {
- WebProfileData pWebExit = makeWebProfileData(ProtocolConstants.MSG_WEB_FUNCTION_EXIT, rsWebExit);
- pWebQueue.offer(pWebExit);
- }
- // handle entry/exit data one by one in
- // chronological order
- while (true) {
- WebProfileData top = pWebQueue.poll();
- if (top == null) {
- break;
- }
-
- WebProfileDataMaker profiler = getWebProfileDataMakerByPid(top.getPid());
-
- switch (top.getMsgID()) {
- case ProtocolConstants.MSG_WEB_FUNCTION_ENTRY:
- if (rsWebEntry.next()) {
- WebProfileData pWebEntry = makeWebProfileData(ProtocolConstants.MSG_WEB_FUNCTION_ENTRY, rsWebEntry);
- pWebQueue.offer(pWebEntry);
- }
-
- profiler.makeWebFunctionUsageProfileData(top);
- break;
- case ProtocolConstants.MSG_WEB_FUNCTION_EXIT:
- if (rsWebExit.next()) {
- WebProfileData pWebExit = makeWebProfileData(ProtocolConstants.MSG_WEB_FUNCTION_EXIT, rsWebExit);
- pWebQueue.offer(pWebExit);
- }
- profiler.makeWebFunctionUsageProfileData(top);
- break;
- default: // never goes here
- Logger.error("Wrong data from selecting web function profiling data inside range");
- break;
- }
- }
- }
- } catch (SQLException e) {
- Logger.exception(e);
- } finally {
- if (rsWebEntry != null) {
- SqlConnectionManager.releaseResultSet(rsWebEntry);
- }
- if (rsWebExit != null) {
- SqlConnectionManager.releaseResultSet(rsWebExit);
- }
- }
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Seokgil Kang <seokgil.kang@samsung.com>
- * Jooyoul Lee <jy.exe.lee@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.range;
-
-import org.eclipse.swt.widgets.Composite;
-import org.tizen.dynamicanalyzer.nl.SummaryLabels;
-import org.tizen.dynamicanalyzer.ui.summary.failed.FailedApiListView;
-import org.tizen.dynamicanalyzer.ui.summary.failed.FailedApiTable;
-
-public class RangeFailedApiListView extends FailedApiListView {
-
- public RangeFailedApiListView(Composite parent, int style) {
- super(parent, style);
- setTitle(SummaryLabels.FAILED_API_LIST_VIEW_TITLE);
- ((FailedApiTable) tableComp).setRangeTable(true);
- tableComp.setTableName(SummaryLabels.RANGE_PAGE_FAILED_TABLE_NAME);
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Seokgil Kang <seokgil.kang@samsung.com>
- * Jooyoul Lee <jy.exe.lee@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.range;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
-import org.tizen.dynamicanalyzer.shortcut.ShortCutManager;
-import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineTableView;
-import org.tizen.dynamicanalyzer.ui.widgets.table.DATableComposite;
-import org.tizen.dynamicanalyzer.widgets.da.view.DAContainerComposite;
-import org.tizen.dynamicanalyzer.resources.ColorResources;
-
-public class RangePage extends DAContainerComposite {
- public static final String pageID = RangePage.class.getName();
- public static final String failedListViewID = RangeFailedApiListView.class
- .getName();
- public static final String profilingViewID = RangeProfilingView.class
- .getName();
- public static final String warningListViewID = RangeWarningListView.class
- .getName();
- public static final String warningDerailViewID = RangeWarningDetailView.class
- .getName();
-
- SashForm upperForm;
- SashForm bottomForm;
- SashForm baseForm;
- SashForm warningForm;
-
- public RangePage(Composite parent, int style) {
- super(parent, style);
- setTitle(AnalyzerLabels.COOLBAR_AREA_RANGE);
- this.setData(DAContainerComposite.KEY_TOOLTIP,
- ShortCutManager.COOLBAR_AREA_RANGE_TOOLTIP);
- this.setBackground(ColorResources.CONFIGURATION_TABLE_COVER_BACKGROUND_COLOR);
- this.setLayout(new FillLayout());
-
- baseForm = new SashForm(this, SWT.VERTICAL);
- baseForm.setLayout(new FillLayout());
- baseForm.setForeground(ColorResources.TAB_SELECTED_COLOR_START);
- ((FillLayout) getLayout()).marginHeight = 15;
- ((FillLayout) getLayout()).marginWidth = 5;
-
- upperForm = new SashForm(baseForm, SWT.HORIZONTAL);
-
- // FAILED_APILIST_VIEW_INDEX = 0;
- RangeFailedApiListView failedApiListView = new RangeFailedApiListView(
- upperForm, SWT.NONE);
- ((DATableComposite) failedApiListView.getControl()).getTable()
- .setSelectionEnabled(true);
- addView(failedApiListView);
-
- // INFO_VIEW_INDEX = 2;
- TimelineTableView tabView = new TimelineTableView(upperForm,
- SWT.NONE);
-// tabView.setObservingViews(TimelineTableView.callstackViewID,
-// new String[] { RangePage.failedListViewID,
-// RangePage.leakViewID, RangePage.warningListViewID });
- addView(tabView);
-
- upperForm.setWeights(new int[] { 37, 40, 23 });
-
- bottomForm = new SashForm(baseForm, SWT.HORIZONTAL);
- // FUNCTION_PROFILING_VIEW_INDEX = 3;
- RangeProfilingView userFunctionProfilingView = new RangeProfilingView(
- bottomForm, SWT.NONE);
- addView(userFunctionProfilingView);
-
- warningForm = new SashForm(bottomForm, SWT.VERTICAL);
- bottomForm.setWeights(new int[] { 70, 30 });
-
- // WARNING_VIEW_INDEX = 4;
- RangeWarningListView warningListView = new RangeWarningListView(
- warningForm, SWT.NONE);
- addView(warningListView);
-
- // WARNING_VIEW_DETAIL_INDEX = 5;
- RangeWarningDetailView warningDetailView = new RangeWarningDetailView(
- warningForm, SWT.NONE);
- addView(warningDetailView);
- warningForm.setWeights(new int[] { 70, 30 });
- }
-
- @Override
- protected void onResized(int width, int height) {
- int wrate = (int) (TimelineTableView.DEFAULT_WIDTH * 100 / width);
- int hrate = (int) (TimelineTableView.DEFAULT_TABLE_VIEW_HEIGHT * 100 / height);
- wrate = (wrate > 100) ? 100 : wrate;
- hrate = (hrate > 100) ? 100 : hrate;
-
- if ((wrate > (100 - 37)) || hrate > 100) {
- return;
- }
-
- upperForm.setWeights(new int[] { 37, 100 - 37 - wrate, wrate });
- baseForm.setWeights(new int[] { hrate, 100 - hrate });
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Seokgil Kang <seokgil.kang@samsung.com>
- * Jooyoul Lee <jy.exe.lee@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.range;
-
-import org.eclipse.swt.widgets.Composite;
-import org.tizen.dynamicanalyzer.common.Global;
-import org.tizen.dynamicanalyzer.nl.SummaryLabels;
-import org.tizen.dynamicanalyzer.project.AppInfo;
-import org.tizen.dynamicanalyzer.ui.summary.profiling.FunctionUsageProfilingView;
-import org.tizen.dynamicanalyzer.ui.widgets.table.DATreeComposite;
-
-public class RangeProfilingView extends FunctionUsageProfilingView {
-
- public RangeProfilingView(Composite parent, int style) {
- super(parent, style);
-
- // set profiling table in range page
- changeTable(Global.getProject().getApplicationInfo().getAppType().equals(AppInfo.APPTYPE_WEB));
- setTitle(SummaryLabels.FUNCTION_USER_PROFILING_VIEW_TITLE);
-
- // TODO: check why setRangeTable is called twice
- setRangeTable(true);
- ((DATreeComposite)stackLayout.topControl).setTableName(SummaryLabels.RANGE_PAGE_PROFILING_TABLE_NAME);
- setRangeTable(true);
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Seokgil Kang <seokgil.kang@samsung.com>
- * Jooyoul Lee <jy.exe.lee@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.range;
-
-import org.eclipse.swt.widgets.Composite;
-import org.tizen.dynamicanalyzer.ui.summary.warning.WarningDetailView;
-
-public class RangeWarningDetailView extends WarningDetailView {
-
- public RangeWarningDetailView(Composite parent, int style) {
- super(parent, style);
- selectionViewId = RangePage.warningListViewID;
- isRange = true;
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Seokgil Kang <seokgil.kang@samsung.com>
- * Jooyoul Lee <jy.exe.lee@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.range;
-
-import org.eclipse.swt.widgets.Composite;
-import org.tizen.dynamicanalyzer.nl.SummaryLabels;
-import org.tizen.dynamicanalyzer.ui.summary.warning.WarningListView;
-import org.tizen.dynamicanalyzer.ui.summary.warning.WarningTable;
-
-public class RangeWarningListView extends WarningListView {
-
- public RangeWarningListView(Composite parent, int style) {
- super(parent, style);
- setTitle(SummaryLabels.WARNING_LIST_VIEW_TITLE);
- ((WarningTable) tableComp).setRangeTable(true);
- tableComp.setTableName(SummaryLabels.RANGE_PAGE_WARNING_TABLE_NAME);
- }
-}
import org.tizen.dynamicanalyzer.common.AnalyzerManager;
import org.tizen.dynamicanalyzer.common.DASelectionData;
import org.tizen.dynamicanalyzer.common.Global;
-import org.tizen.dynamicanalyzer.constant.CommonConstants;
import org.tizen.dynamicanalyzer.error.ErrorCodeManager;
import org.tizen.dynamicanalyzer.listeners.SummaryMouseDoubleClickListener;
import org.tizen.dynamicanalyzer.model.FilterProperty;
import org.tizen.dynamicanalyzer.model.TableInput;
import org.tizen.dynamicanalyzer.nl.SummaryLabels;
import org.tizen.dynamicanalyzer.swap.model.data.ProbeCommonData;
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
-import org.tizen.dynamicanalyzer.ui.range.RangePage;
import org.tizen.dynamicanalyzer.ui.summary.SummaryDataManager;
import org.tizen.dynamicanalyzer.ui.summary.SummaryPage;
import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
import org.tizen.dynamicanalyzer.utils.Formatter;
public class FailedApiTable extends DATableComposite {
- private boolean isRange = false;
-
private final FailedApiDataMaker failedApiDataMaker = SummaryDataManager
.getInstance().getFailedApiDataMaker();
long time = dataFormat.getLogData().getTime();
String id = SummaryPage.failedViewID;
- if (isRange) {
- id = RangePage.failedListViewID;
- }
DASelectionData selData = new DASelectionData(id, time, 0,
items, table);
AnalyzerManager.getCurrentPage().updateView(selData);
SummaryPage.failedViewID));
}
- public void setRangeTable(boolean isRange) {
- this.isRange = isRange;
- }
-
- // protected List<TableInput> makeTableInput() {
- // List<FailedData> failedList = null;
- // if (isRange) {
- // failedList = RangeDataManager.getInstance().getFailedChecker()
- // .getFailedList();
- // } else {
- // failedList = AnalyzerManager.getFailedChecker().getFailedList();
- // }
- //
- // List<TableInput> input = new ArrayList<TableInput>();
- // int size = failedList.size();
- // for (int i = 0; i < size; i++) {
- // FailedData failedData = failedList.get(i);
- // int selectedPid = ToolbarArea.INSTANCE.getSelectedPid();
- // if (selectedPid != 0) {
- // if (selectedPid != failedData.getPid()) {
- // continue;
- // }
- // }
- //
- // // create text
- // List<String> text = new ArrayList<String>();
- // List<Object> data = new ArrayList<Object>();
- //
- // text.add(Long.toString(failedData.getSeq())); // 0
- // data.add(new Long(failedData.getSeq()));
- // String time = Formatter.toTimeFormat(failedData.getTime());
- // text.add(time); // 1
- // data.add(new Long(failedData.getTime()));
- //
- // text.add(failedData.getName()); // 2
- // data.add(failedData.getName());
- //
- // text.add(failedData.getArgs()); // 3
- // data.add(failedData.getArgs());
- //
- // text.add(failedData.getReturn()); // 4
- // data.add(failedData.getReturn());
- //
- // try {
- // String errCode = ErrorCodeManager.getInatance()
- // .getErrorCode(failedData.getErrorCode()).name();
- // if (null == errCode) {
- // // FIXME : for debug
- // errCode = "undefined error number"; //$NON-NLS-1$
- // }
- // text.add(errCode); // 5
- // data.add(new Long(failedData.getErrorCode()));
- // } catch (NullPointerException e) {
- // Logger.debug("debug");
- // continue;
- // }
- // String errMsg = ErrorCodeManager.getInatance().getErrorDescription(
- // failedData.getErrorCode());
- // if (null == errMsg) {
- // // FIXME : for debug
- // errMsg = "undefined error number"; //$NON-NLS-1$
- // }
- // text.add(errMsg); // 6
- // data.add(new Long(failedData.getErrorCode()));
- //
- // text.add(Integer.toString(failedData.getPid())); // 7
- // data.add(new Integer(failedData.getPid()));
- //
- // data.add(new Long(failedData.getCallerPc())); // 8
- // data.add(failedData.getLibName()); // 9
- //
- // // create images
- //
- // // create DATableDataFormat
- // DATableDataFormat tableData = new DATableDataFormat(
- // failedData.getSeq());
- // tableData.setObject(failedData);
- // tableData.setLogData(failedData.getData());
- // tableData.getData().addAll(data);
- // tableData.setType(AnalyzerConstants.TYPE_TABLE_FAILED);
- //
- // TableInput tableInput = new TableInput();
- // tableInput.setText(text);
- // tableInput.setData(tableData);
- // input.add(tableInput);
- //
- // if (RangeDataManager.getInstance().isBeingAnalyzed()) {
- // long failedTime = failedData.getTime();
- // long startTime = RangeDataManager.getInstance()
- // .getAnalysisStartTime();
- // long endTime = RangeDataManager.getInstance()
- // .getAnalysisEndTime();
- // if (failedTime >= startTime && failedTime <= endTime) {
- // tableInput.setInRange(true);
- // }
- // }
- // }
- // return input;
- // }
-
protected List<TableInput> makeTableInput() {
List<List<Object>> failedData = null;
int selectedPid = Toolbar.INSTANCE.getSelectedPid();
if (!filterList.isEmpty()) {
// if filter is set by user
List<String> whereQueryList = convertFilterProperty2Query(filterList);
- if (isRange) {
- Long markerStartTime = Long.valueOf(RangeDataManager.getInstance()
- .getMarkerStartTime());
- Long markerEndTime = Long.valueOf(RangeDataManager.getInstance()
- .getMarkerEndTime());
- failedData = failedApiDataMaker.getFailedApiDataFromDBForRange(
- markerStartTime, markerEndTime, selectedPid, whereQueryList);
- } else {
- failedData = failedApiDataMaker.getFailedApiDataFromDB(selectedPid,
- whereQueryList);
- }
+ failedData = failedApiDataMaker.getFailedApiDataFromDB(selectedPid, whereQueryList);
} else {
- if (isRange) {
- Long markerStartTime = Long.valueOf(RangeDataManager.getInstance()
- .getMarkerStartTime());
- Long markerEndTime = Long.valueOf(RangeDataManager.getInstance()
- .getMarkerEndTime());
- failedData = failedApiDataMaker.getFailedApiDataFromDBForRange(
- markerStartTime, markerEndTime, selectedPid, null);
- } else {
- failedData = failedApiDataMaker.getFailedApiDataFromDB(selectedPid, null);
- }
+ failedData = failedApiDataMaker.getFailedApiDataFromDB(selectedPid, null);
}
if (failedData == null)
tableInput.setText(text);
tableInput.setData(tableData);
input.add(tableInput);
-
- if (RangeDataManager.getInstance().isBeingAnalyzed()) {
- long failedTime = time;
- long startTime = RangeDataManager.getInstance()
- .getAnalysisStartTime();
- long endTime = RangeDataManager.getInstance()
- .getAnalysisEndTime();
- if (failedTime >= startTime && failedTime <= endTime) {
- tableInput.setInRange(true);
- }
- }
}
return input;
}
}
public FunctionSampleDBTable() {
- addColumn(new DBColumn(COLUMN.SEQUENCE_NUMBER.name, DBConstants.PRIMARY_KEY, DBConstants.DBTYPE_LONG));
+ addColumn(new DBColumn(COLUMN.SEQUENCE_NUMBER.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
addColumn(new DBColumn(COLUMN.SAMPLE_TIME.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
addColumn(new DBColumn(COLUMN.PID.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
addColumn(new DBColumn(COLUMN.TID.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.NavigableMap;
import org.tizen.dynamicanalyzer.common.Global;
import org.tizen.dynamicanalyzer.constant.CommonConstants;
import org.tizen.dynamicanalyzer.nl.SummaryLabels;
import org.tizen.dynamicanalyzer.project.BinaryInfo;
import org.tizen.dynamicanalyzer.protocol.ProtocolConstants;
-import org.tizen.dynamicanalyzer.setting.Feature;
import org.tizen.dynamicanalyzer.setting.FlatPreferences;
import org.tizen.dynamicanalyzer.setting.SettingDataManager;
-import org.tizen.dynamicanalyzer.setting.TargetData;
import org.tizen.dynamicanalyzer.swap.logparser.LogPackage;
import org.tizen.dynamicanalyzer.swap.logparser.Logs;
import org.tizen.dynamicanalyzer.swap.logparser.PageDataManager;
public ProfileDataMaker getProfileDataMakerByPid(int pid) {
ProfileDataMaker profileDataMaker = profileDataMakerMap.get(pid);
if (null == profileDataMaker) {
- profileDataMaker = new RuntimeProfileDataMaker();
+ profileDataMaker = new ProfileDataMaker();
profileDataMaker.setPid(pid);
profileDataMakerMap.put(pid, profileDataMaker);
}
public void clear() {
lastSampleSeq = -1;
isSetSamplePeriod = false;
+ for (int pid : getPidsOfProfileDataMakerMap()) {
+ ProfileDataMaker profiler = getProfileDataMakerByPid(pid);
+ profiler.clear();
+ }
profileDataMakerMap.clear();
webProfileDataMakerMap.clear();
ProfilingData.clear(); // reset internal sequence number
@Override
protected void makeData(LogPackage pack) {
-
- // TODO: will get sample_time from Project.java
if (!isSetSamplePeriod) {
- SAMPLE_TIME = SettingDataManager.INSTANCE.getPreferenceValue(FlatPreferences.FUNCTION_SAMPLING_RATE);
- if (SAMPLE_TIME < 0) {
- SAMPLE_TIME = Feature.FUNCTION_SAMPLING_RATE.getData().getDefaultValue();
- }
+ SAMPLE_TIME = SettingDataManager.INSTANCE
+ .getPreferenceValue(FlatPreferences.FUNCTION_SAMPLING_RATE);
}
if (SAMPLE_TIME > 0) {
-
Logs logs = pack.getLogs(ProtocolConstants.MSG_DATA_SAMPLE);
if (null != logs && logs.getRawLogs().size() != 0) {
List<List<Object>> insertData = new ArrayList<List<Object>>();
List<Object> insertRowData = new ArrayList<Object>();
ProfileData sampleLog = (ProfileData) sample.get(i);
getInstance().getProfileDataMakerByPid(sample.get(i).getPid())
- .makeFunctionUsageProfileData(sampleLog);
- // set LastSampleSeq
- NavigableMap<Long, Long> seqByTimeMap = Global.getRuntimeCallstackManager()
- .getSeqTimeByTidMap(sampleLog.getTid(), false);
-
- if (null != seqByTimeMap) {
- // find the time of callstackdata which was made
- // right before the current sample time
- // callstackdatas made before that time is needless
- Long lastTime = seqByTimeMap.floorKey(sampleLog.getTime());
- if (lastTime != null) {
- Long lastSeq = seqByTimeMap.get(lastTime);
- setLastSampleSeq(lastSeq);
- }
- }
-
+ .prepareFunctionUsageProfileData(sampleLog);
+
// save to DB
try {
insertRowData.add(new Long(sampleLog.getSeq()));
WebProfilingData pData = pDataList.get(j);
try {
- insertRowData.add(new Integer(pData.getProfilingDataID()));
+ insertRowData.add(new Integer(pData.getProfilingDataID()));
insertRowData.add(new Integer(pData.getFunctionLineNumber()));
insertRowData.add(pData.getFunctionName());
insertRowData.add(pData.getFunctionURL());
}
}
}
-
+
@Override
protected void onThreadStop() {
+ saveWebProfilingData();
+ }
+
+ /**
+ * Save native Profiling Data to database.
+ */
+ public void doSaveProfilingData() {
saveProfilingData();
saveProfilingChildData();
- saveWebProfilingData();
}
}
}
contents.layout();
}
-
- protected void setRangeTable(boolean isRange) {
- if (stackLayout.topControl == nativeTable) {
- nativeTable.setRangeTable(isRange);
- } else {
- webTable.setRangeTable(isRange);
- }
- }
}
* WooJin Jung <woojin2.jung@samsung.com>
* Jooyoul Lee <jy.exe.lee@samsung.com>
* Juyoung Kim <j0.kim@samsung.com>
+ * Petr Privalov <p.privalov@partner.samsung.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Contributors:
* - S-Core Co., Ltd
- *
+ *
*/
package org.tizen.dynamicanalyzer.ui.summary.profiling;
import java.util.concurrent.ConcurrentHashMap;
import org.tizen.dynamicanalyzer.common.Global;
+import org.tizen.dynamicanalyzer.constant.CommonConstants;
import org.tizen.dynamicanalyzer.project.AppInfo;
import org.tizen.dynamicanalyzer.project.BinaryInfo;
-import org.tizen.dynamicanalyzer.project.callstack.BaseCallstackManager;
import org.tizen.dynamicanalyzer.protocol.ProtocolConstants;
-import org.tizen.dynamicanalyzer.swap.model.data.LogData;
import org.tizen.dynamicanalyzer.swap.model.data.ProfileData;
-import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackItem;
import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackUnit;
+import org.tizen.dynamicanalyzer.ui.timeline.calltrace.CallTraceDataManager;
+import org.tizen.dynamicanalyzer.ui.timeline.calltrace.FunctionEntryDBTable;
import org.tizen.dynamicanalyzer.util.Logger;
import org.tizen.dynamicanalyzer.utils.Formatter;
-public abstract class ProfileDataMaker {
+public class ProfileDataMaker {
static class CallstackTree {
ProfilingData me;
CallstackTree parent;
}
}
- private Map<Integer, CallstackTree> callstackTreeByTidMap = new HashMap<Integer, CallstackTree>();
+ private Map<Integer, CallstackTree> callstackTreeByTidMap = new HashMap<>();
protected int totalSampleCount = 0;
- protected BaseCallstackManager callstackManager = null;
private int pid = 0;
/**
private ProfilingData dependentLib = null;
private String appBinName = null;
- public ProfileDataMaker(BaseCallstackManager callstackManager) {
- this.callstackManager = callstackManager;
- }
-
public void clear() {
getProfilingDataMap().clear();
getChildListMap().clear();
public Map<Integer, ProfilingData> getProfilingDataMap() {
if (null == profilingDataMap) {
- profilingDataMap = new ConcurrentHashMap<Integer, ProfilingData>();
+ profilingDataMap = new ConcurrentHashMap<>();
}
return profilingDataMap;
}
public Map<String, ProfilingChildData> getChildListMap() {
if (null == childListMap) {
- childListMap = new ConcurrentHashMap<String, ProfilingChildData>();
+ childListMap = new ConcurrentHashMap<>();
}
return childListMap;
}
public Map<String, String> getSymbolIDHash() {
if (null == symbolIDHash) {
- symbolIDHash = new ConcurrentHashMap<String, String>();
+ symbolIDHash = new ConcurrentHashMap<>();
}
return symbolIDHash;
}
public CallstackTree getCurrentCallstackTree(int tid) {
- CallstackTree current = callstackTreeByTidMap.get(tid);
- return current;
+ return callstackTreeByTidMap.get(tid);
}
public void putCurrentCallstackTree(int tid, CallstackTree current) {
callstackTreeByTidMap.put(tid, current);
- return;
}
public String getCpuRate(ProfilingData data, boolean exclusive) {
- int count = 0;
- double rate = 0.;
+ int count;
+ double rate;
if (exclusive) {
count = data.getExCount();
if (totalSampleCount == 0) {
}
public String getCpuTime(ProfilingData data, boolean exclusive) {
- int count = 0;
+ int count;
if (exclusive) {
count = data.getExCount();
} else {
return Long.toString(count * FunctionUsageProfiler.SAMPLE_TIME);
}
- protected void checkUserCall(CallStackUnit csa, ProfilingData parent, ProfilingData pp,
- LogData log) {
+ /**
+ * For given {@link CallStackUnit} object (which represents FUNCTION_ENTRY
+ * or FUNCTION_SAMPLING message occurrence) update tree of
+ * {@link ProfilingData} objects with root in given Parent node.
+ *
+ * @param csu {@link CallStackUnit}
+ * @param parent parent item
+ */
+ private void checkUserCall(CallStackUnit csu, ProfilingData parent) {
AppInfo appInfo = Global.getProject().getApplicationInfo();
BinaryInfo binfo = Global.getProject().getDeviceStatusInfo()
.getBinaryInfo(appInfo.getExecBinaryPath());
if ((null != binfo.getTargetBinaryPath())
- && (binfo.getTargetBinaryPath().equals(csa.getPath()))) {
+ && (binfo.getTargetBinaryPath().equals(csu.getPath()))) {
if (null == appBin) {
- CallStackUnit appBinCsa = new CallStackUnit(-1, FunctionUsageProfiler.APPLICATION,
- log);
+ CallStackUnit appBinCsa = new CallStackUnit(FunctionUsageProfiler.APPLICATION);
appBin = makeNewProfilingData(appBinCsa, true);
appBin.setKey(FunctionUsageProfiler.APPLICATION_KEY);
- appBinName = csa.getPath();
+ appBinName = csu.getPath();
}
parent.setParent(appBin.getName());
appBin.addChild(parent);
- if (null != pp) {
- pp = appBin;
- }
} else {
if (null == dependentLib) {
- CallStackUnit dependentLibBinCsa = new CallStackUnit(-2,
- FunctionUsageProfiler.DEPENDENT_LIB, log);
+ CallStackUnit dependentLibBinCsa = new CallStackUnit(
+ FunctionUsageProfiler.DEPENDENT_LIB);
dependentLib = makeNewProfilingData(dependentLibBinCsa, true);
dependentLib.setKey(FunctionUsageProfiler.DEPENDENT_LIB_KEY);
}
parent.setParent(dependentLib.getName());
dependentLib.addChild(parent);
- if (null != pp) {
- pp = dependentLib;
+ }
+ }
+
+ /**
+ * For given FUNCTION_SAMPLE message update corresponding item in
+ * {@code profilingDataMap}. This method counts exclusive time.
+ *
+ * It is to be called during the tracing process. It is to be called only
+ * one time for each FUNCTION_SAMPLE message.
+ *
+ * @param sampleLog FUNCTION_SAMPLE message
+ */
+ public void prepareFunctionUsageProfileData(ProfileData sampleLog){
+ totalSampleCount++;
+
+ long selfAddr = sampleLog.getPcAddr();
+ int samplepid = sampleLog.getPid();
+ int tid = sampleLog.getTid();
+ long sampleTime = sampleLog.getTime();
+
+ int binId = Global.getBinaryID(samplepid, sampleTime, selfAddr);
+ String inputPath = Global.getLibraryName(binId);
+ String inputFuncName;
+ CallStackUnit callstackUnit = CallTraceDataManager.getInstance().getLastEntry(pid, tid,
+ sampleTime);
+ if (callstackUnit == null || callstackUnit.getBinaryID() != binId) {
+ inputFuncName = FunctionUsageProfiler.UNKNOWN;
+ callstackUnit = new CallStackUnit(selfAddr, 0, samplepid, tid, sampleTime, 0);
+ } else {
+ inputFuncName = callstackUnit.getFunctionName();
+ }
+
+ ProfilingData parent = getProfilingDataByKey(inputPath);
+ // exclusive cpu time
+ if (null == parent) {
+ parent = makeNewProfilingData(callstackUnit, true);
+ checkUserCall(callstackUnit, parent);
+ if (inputFuncName.equals(FunctionUsageProfiler.UNKNOWN)) {
+ parent.addExCount();
+ } else {
+ ProfilingData child = makeNewProfilingData(callstackUnit, false);
+ parent.addChild(child);
+ child.addExCount();
+ child.setParent(parent.getName());
+ }
+ } else {
+ if (inputFuncName.equals(FunctionUsageProfiler.UNKNOWN)) {
+ parent.addExCount();
+ } else {
+ ProfilingData child = getProfilingDataByKey(callstackUnit.getSymbol());
+ if (null == child) {
+ child = makeNewProfilingData(callstackUnit, false);
+ parent.addChild(child);
+ child.setParent(parent.getName());
+ }
+ child.addExCount();
}
}
}
- abstract public void makeFunctionUsageProfileData(ProfileData sampleLog);
+ /**
+ * For given database record , which represents stored FUNCTION_SAMPLE
+ * message, update corresponding item in {@code profilingDataMap}. This
+ * method counts inclusive time.
+ *
+ * It is to be called after the tracing process.
+ * It is to be called only one time for each database record.
+ *
+ * @param dbrecord Sampling message row in the same way as in database
+ */
+ public void finalizeFunctionUsageProfileData(List<Object> dbrecord) {
+
+ long selfAddr = (long) dbrecord.get(FunctionSampleDBTable.COLUMN.PC_ADDRESS.index);
+ int samplepid = (int) dbrecord.get(FunctionSampleDBTable.COLUMN.PID.index);
+ int tid = (int) dbrecord.get(FunctionSampleDBTable.COLUMN.TID.index);
+ long sampleTime = (long) dbrecord.get(FunctionSampleDBTable.COLUMN.SAMPLE_TIME.index);
+
+ int binId = Global.getBinaryID(samplepid, sampleTime, selfAddr);
+ String inputPath = Global.getLibraryName(binId);
+ String inputFuncName;
+ CallStackUnit callstackUnit = CallTraceDataManager.getInstance().getLastEntry(pid, tid,
+ sampleTime);
+ if (callstackUnit == null || callstackUnit.getBinaryID() != binId) {
+ inputFuncName = FunctionUsageProfiler.UNKNOWN;
+ callstackUnit = new CallStackUnit(selfAddr, 0, samplepid, tid, sampleTime, 0);
+ } else {
+ inputFuncName = callstackUnit.getFunctionName();
+ }
+ ProfilingData parent = getProfilingDataByKey(inputPath);
+
+ List<CallStackUnit> callstack = CallTraceDataManager.getInstance()
+ .getCallstackForTable(samplepid, tid, sampleTime);
+
+ // sampling before first entry in profiling app, or in another
+ // thread.
+ // Simply copy data from Exclusive part.
+ if (inputFuncName.equals(FunctionUsageProfiler.UNKNOWN)) {
+ parent.addInCount();
+ } else {
+ Logger.warning("Unexpected occurence of " + CommonConstants.NEW_LINE
+ + callstackUnit.getSymbol());
+ ProfilingData child = getProfilingDataByKey(callstackUnit.getSymbol());
+ if (null == child) {
+ child = makeNewProfilingData(callstackUnit, false);
+ }
+ child.addInCount();
+ }
+ for (int i = 0; i < callstack.size(); i++) {
+ CallStackUnit callstackCsa = callstack.get(i);
+
+ if (callstackCsa.getFunctionName().equals(FunctionUsageProfiler.UNKNOWN)) {
+ ProfilingData inParent = getProfilingDataByKey(callstackCsa.getPath());
+ ProfilingData pp;
+ if (null == inParent) {
+ inParent = makeNewProfilingData(callstackCsa, true);
+ checkUserCall(callstackCsa, inParent);
+ }
+ inParent.addInCount();
+
+ if (null != inParent.getParent()) {
+ String pInParentName = inParent.getParent();
+ pp = getProfilingDataByKey(pInParentName);
+ if (null != pp) {
+ pp.addInCount();
+ }
+ }
+ continue;
+ }
+ ProfilingData fupData = getProfilingDataByKey(callstackCsa.getSymbol());
+ ProfilingData inParent;
+ if (null == fupData) {
+ inParent = getProfilingDataByKey(callstackCsa.getPath());
+ if (null == inParent) {
+ inParent = makeNewProfilingData(callstackCsa, true);
+ checkUserCall(callstackCsa, inParent);
+ }
+ fupData = makeNewProfilingData(callstackCsa, false);
+ fupData.setParent(inParent.getName());
+ inParent.addChild(fupData);
+ } else {
+ String pName = fupData.getParent();
+ inParent = getProfilingDataByKey(pName);
+ if (inParent == null) {
+ Logger.error("ProfilingData: function item without library item");
+ continue;
+ }
+ }
+
+ if (i == callstack.size() - 1) {
+ inParent.addInCount();
+ if (null != inParent.getParent()) {
+ String pInParentName = inParent.getParent();
+ ProfilingData pp = getProfilingDataByKey(pInParentName);
+ if (null != pp) {
+ pp.addInCount();
+ }
+ }
+ }
+ fupData.addInCount();
+ }
+ }
protected ProfilingData makeNewProfilingData(CallStackUnit inputData, boolean isParent) {
ProfilingData newProfilingData = new ProfilingData(inputData, isParent, this);
return newProfilingData;
}
- public void makeFupDataForCallTrace(CallStackUnit inputCallstackApiData, ProfileData log) {
+ /**
+ * For given FUNCTION_ENTRY message update corresponding item in
+ * {@code profilingDataMap}. This method counts call count.
+ *
+ * It is to be called during the tracing process.
+ * It is to be called only one time for each FUNCTION_SAMPLE message.
+ *
+ * @param pData FUNCTION_ENTRY message
+ */
+ public void prepareFUPDataForCallTrace(ProfileData pData) {
+
+ int type = pData.getMsgID();
+ int binId = pData.getBinaryId();
+ String path = Global.getLibraryName(binId);
+ int functionID = pData.getApiId();
+ String fName = Global.getFunctionName(functionID);
+ CallStackUnit unit = new CallStackUnit(pData.getPcAddr(), pData.getCallerPcAddr(),
+ pData.getPid(), pData.getTid(), pData.getTid(), functionID, binId, fName, path);
+
+ if (type == ProtocolConstants.MSG_FUNCTION_ENTRY) {
+ ProfilingData parent = getProfilingDataByKey(path);
+ if (parent == null) {
+ parent = makeNewProfilingData(unit, true);
+ checkUserCall(unit, parent);
+ ProfilingData child = makeNewProfilingData(unit, false);
+ parent.addChild(child);
+ child.setParent(parent.getName());
+ child.addCallCount();
+ } else {
+ ProfilingData child = getProfilingDataByKey(unit.getSymbol());
+ if (null == child) {
+ child = makeNewProfilingData(unit, false);
+ parent.addChild(child);
+ child.setParent(parent.getName());
+ }
+ child.addCallCount();
+ }
+ }
+
+ }
+
+ /**
+ * For given database record , which represents stored FUNCTION_ENTRY
+ * message update corresponding item in {@code profilingDataMap}. This
+ * method counts both exclusive and inclusive elapsed time.
+ *
+ * It is to be called after the tracing process.
+ * It is to be called only one time for each database record.
+ *
+ * @param entry db representation of function entry\exit message
+ */
+ public void finalizeFUPDataForCallTrace(List<Object> entry) {
long exeTime = 0;
- int type = log.getMsgID();
- int tid = log.getTid();
- long time = log.getTime();
- long startTime;
+ long addr = (long) (entry.get(FunctionEntryDBTable.COLUMN.START_PC_ADDRESS.index));
+ long callerAddr = (long) (entry.get(FunctionEntryDBTable.COLUMN.CALLER_PC_ADDRESS.index));
+ int type = (boolean) (entry.get(FunctionEntryDBTable.COLUMN.IS_ENTRY.index)) ? ProtocolConstants.MSG_FUNCTION_ENTRY
+ : ProtocolConstants.MSG_FUNCTION_EXIT;
+ int entrypid = (int) (entry.get(FunctionEntryDBTable.COLUMN.PID.index));
+ int tid = (int) (entry.get(FunctionEntryDBTable.COLUMN.TID.index));
+ long time = (long) (entry.get(FunctionEntryDBTable.COLUMN.START_TIME.index));
+ int functionID = (int) (entry.get(FunctionEntryDBTable.COLUMN.FUNCTION_ID.index));
+ String fName = Global.getFunctionName(functionID);
+ int binId = (int) (entry.get(FunctionEntryDBTable.COLUMN.BINARY_ID.index));
+ CallStackUnit unit = new CallStackUnit(addr, callerAddr, entrypid, tid, time, functionID,
+ binId, fName, Global.getLibraryName(binId));
- List<CallStackItem> userCallstack = callstackManager.getUserCallstack(tid);
- int size = userCallstack.size();
+ long startTime;
+ // called from FunctionEntryIndexer
if (type == ProtocolConstants.MSG_FUNCTION_EXIT) {
- if (size == 0
- || userCallstack.get(size - 1).getCallStackUnit().getFunctionId() != inputCallstackApiData
- .getFunctionId()) {
- Logger.debug("exit without entry or EXIT self is not the same as top of user callstack :"
- + inputCallstackApiData.getFunctionName()); //$NON-NLS-1$
+ List<CallStackUnit> callstack = CallTraceDataManager.getInstance()
+ .getCallstackForSampling(entrypid, tid, time);
+
+ if (callstack == null || callstack.isEmpty()
+ || callstack.get(0).getAddr() != addr) {
return;
}
- startTime = userCallstack.get(size - 1).getStartTime();
- if (startTime != -1) {
+
+ startTime = callstack.get(0).getTime();
+ if (startTime > 0) {
exeTime += time - startTime;
}
+ unit = callstack.get(0);
}
- ProfilingData parent = getProfilingDataByKey(inputCallstackApiData.getPath());
+ ProfilingData parent = getProfilingDataByKey(unit.getPath());
+ ProfilingData child;
if (null == parent) {
- parent = makeNewProfilingData(inputCallstackApiData, true);
- checkUserCall(inputCallstackApiData, parent, null, log);
-
- ProfilingData child = makeNewProfilingData(inputCallstackApiData, false);
+ Logger.warning("Unexpected occurence of library\n" + unit.getPath());
+ parent = makeNewProfilingData(unit, true);
+ checkUserCall(unit, parent);
+ child = makeNewProfilingData(unit, false);
parent.addChild(child);
- child.addElapsedTime(exeTime);
child.setParent(parent.getName());
- if (type != ProtocolConstants.MSG_FUNCTION_EXIT) {
- child.addCallCount();
- }
+ child.addElapsedTime(exeTime);
+
} else { // null != parent
- ProfilingData child = getProfilingDataByKey(inputCallstackApiData.getSymbol());
+ child = getProfilingDataByKey(unit.getSymbol());
if (null == child) {
- child = makeNewProfilingData(inputCallstackApiData, false);
+ Logger.warning(
+ "Unexpected occurence of " + CommonConstants.NEW_LINE + unit.getSymbol());
+ child = makeNewProfilingData(unit, false);
parent.addChild(child);
child.setParent(parent.getName());
}
child.addElapsedTime(exeTime);
- if (type != ProtocolConstants.MSG_FUNCTION_EXIT) {
- child.addCallCount();
- }
+ }
- // calculate internal time
- CallstackTree current = getCurrentCallstackTree(tid);
- if (type == ProtocolConstants.MSG_FUNCTION_EXIT) {
- if (null == current) {
- // bug
- Logger.debug("exit without entry - range only :" + inputCallstackApiData.getFunctionName()); //$NON-NLS-1$
- } else {
- CallstackTree parentCt = current.getParent();
- if (null != parentCt) {
- parentCt.addChildExeTime(current.getThis().getLastElapsedTime());
- }
- child.addExclusiveElapsedTime(current.getExclusiveExeTime());
- putCurrentCallstackTree(tid, current.getParent());
- }
+ // calculate internal time
+ CallstackTree current = getCurrentCallstackTree(tid);
+ if (type == ProtocolConstants.MSG_FUNCTION_EXIT) {
+ if (null == current) {
+ // bug
+ Logger.debug("exit without entry - range only :" + unit.getFunctionName()); //$NON-NLS-1$
} else {
- if (null == current) {
- CallstackTree ct = new CallstackTree(child, null);
- putCurrentCallstackTree(tid, ct);
- } else {
- CallstackTree ct = new CallstackTree(child, current);
- putCurrentCallstackTree(tid, ct);
+ CallstackTree parentCt = current.getParent();
+ if (null != parentCt) {
+ parentCt.addChildExeTime(exeTime);
}
+ child.addExclusiveElapsedTime(current.getExclusiveExeTime());
+ putCurrentCallstackTree(tid, current.getParent());
+ }
+ } else {
+ if (null == current) {
+ CallstackTree ct = new CallstackTree(child, null);
+ putCurrentCallstackTree(tid, ct);
+ } else {
+ CallstackTree ct = new CallstackTree(child, current);
+ putCurrentCallstackTree(tid, ct);
}
}
}
private long inElapsedTime = 0;
private long lastExeTime = 0;
private long exElapsedTime = 0;
- private int lastSampleID = -1;
private int functionId = -1;
private ProfileDataMaker profiler = null;
this.profiler = profiler;
}
- public void addChild(ProfilingData child) {
+ public synchronized void addChild(ProfilingData child) {
int childID = child.getProfilingDataID();
getChildData().getChildren().add(childID);
}
this.key = key;
}
- public String getParent() {
+ public synchronized String getParent() {
return parent;
}
- public void setParent(String parentKey) {
+ public synchronized void setParent(String parentKey) {
this.parent = parentKey;
}
return exCount;
}
- public void addExCount() {
+ public synchronized void addExCount() {
exCount++;
}
return inCount;
}
- public void addInCount(int sampleID) {
- if (sampleID == lastSampleID) {
- return;
- } else {
- inCount++;
- lastSampleID = sampleID;
- return;
- }
+ public synchronized void addInCount() {
+ inCount++;
}
public int getCallCount() {
return callCount;
}
- public void addCallCount() {
+ public synchronized void addCallCount() {
callCount++;
}
- public void addElapsedTime(long time) {
+ public synchronized void addElapsedTime(long time) {
lastExeTime = time;
inElapsedTime += time;
}
return lastExeTime;
}
- public void addExclusiveElapsedTime(long time) {
+ public synchronized void addExclusiveElapsedTime(long time) {
exElapsedTime += time;
}
return exElapsedTime;
}
- public boolean isParent() {
+ public synchronized boolean isParent() {
if (getChildData().getChildren().isEmpty()) {
return false;
}
}
public List<ProfilingData> getChildList() {
- List<ProfilingData> output = new ArrayList<ProfilingData>();
+ List<ProfilingData> output = new ArrayList<>();
List<Integer> childIDs = getChildData().getChildren();
for (int i = 0; i < childIDs.size(); i++) {
import org.tizen.dynamicanalyzer.model.FilterProperty;
import org.tizen.dynamicanalyzer.model.TreeInput;
import org.tizen.dynamicanalyzer.nl.SummaryLabels;
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
-import org.tizen.dynamicanalyzer.ui.range.RangePage;
import org.tizen.dynamicanalyzer.ui.summary.SummaryPage;
import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat;
public class ProfilingTable extends DATreeComposite {
- private boolean isRange = false;
-
public ProfilingTable(Composite parent, int compStyle, int tableStyle) {
super(parent, compStyle, tableStyle);
setComparator(new TreeDataComparator());
GridItem[] items = table.getSelection();
String id = SummaryPage.profilingViewID;
- if (isRange) {
- id = RangePage.profilingViewID;
- }
DASelectionData selData = new DASelectionData(id, 0, 0, items,
table);
AnalyzerManager.getCurrentPage().updateView(selData);
}
private List<Integer> getPidsOfProfileDataMakerMap() {
- if (isRange) {
- return RangeDataManager.getInstance()
- .getPidsOfProfileDataMakerMap();
- } else {
- return FunctionUsageProfiler.getInstance()
- .getPidsOfProfileDataMakerMap();
- }
+ return FunctionUsageProfiler.getInstance().getPidsOfProfileDataMakerMap();
}
private ProfileDataMaker getProfileDataMakerByPid(int pid) {
- if (isRange) {
- return RangeDataManager.getInstance()
- .getProfileDataMakerByPid(pid);
- } else {
- return FunctionUsageProfiler.getInstance()
- .getProfileDataMakerByPid(pid);
- }
+ return FunctionUsageProfiler.getInstance().getProfileDataMakerByPid(pid);
}
private void createColumn(Object parent, ColumnData data, int index) {
}
}
- public void setRangeTable(boolean isRange) {
- this.isRange = isRange;
- }
-
@Override
public List<TreeInput> makeTreeInput() {
int selectedPid = Toolbar.INSTANCE.getSelectedPid();
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * WooJin Jung <woojin2.jung@samsung.com>
- * Jooyoul Lee <jy.exe.lee@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-package org.tizen.dynamicanalyzer.ui.summary.profiling;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.tizen.dynamicanalyzer.common.path.PathConstants;
-import org.tizen.dynamicanalyzer.project.callstack.BaseCallstackManager;
-import org.tizen.dynamicanalyzer.swap.model.data.ProfileData;
-import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackItem;
-import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackUnit;
-
-public class RangeProfileDataMaker extends ProfileDataMaker {
-
- public RangeProfileDataMaker(BaseCallstackManager callstackManager) {
- super(callstackManager);
- }
-
- @Override
- public void makeFunctionUsageProfileData(ProfileData sampleLog) {
- totalSampleCount++;
- List<Long> addrs = new ArrayList<Long>();
- long selfAddr = sampleLog.getPcAddr();
- int pid = sampleLog.getPid();
- int tid = sampleLog.getTid();
- long sampleTime = sampleLog.getTime();
-
- Map<Long, CallStackUnit> addrMap = callstackManager.getCallStackApiAddrByPidMap(pid);
-
- CallStackUnit selfCallstackUnit = addrMap.get(selfAddr);
- if (null == selfCallstackUnit) {
- selfCallstackUnit = new CallStackUnit(selfAddr, callstackManager.getCallStackSymbol(
- selfAddr, pid, sampleTime), sampleLog);
- addrMap.put(selfAddr, selfCallstackUnit);
- }
-
- List<CallStackItem> userCallstack = callstackManager.getUserCallstack(tid);
- int callstackSize = userCallstack.size();
-
- for (int i = 0; i < callstackSize; i++) {
- long addr = userCallstack.get(i).getCallStackUnit().getAddr();
- addrs.add(addr);
- }
- addrs.add(selfAddr);
-
- // drop samples of probe library
- if (selfCallstackUnit.getPath().startsWith(PathConstants.DA_REMOTE_PROBE_PATH)) {
- return;
- }
-
- String inputPath = selfCallstackUnit.getPath();
- String inputFuncName = selfCallstackUnit.getFunctionName();
-
- ProfilingData parent = getProfilingDataByKey(inputPath);
- // exclusive cpu time
- if (null == parent) {
- parent = makeNewProfilingData(selfCallstackUnit, true);
- checkUserCall(selfCallstackUnit, parent, null, sampleLog);
- if (inputFuncName.equals(FunctionUsageProfiler.UNKNOWN)) {
- parent.addExCount();
- } else {
- ProfilingData child = makeNewProfilingData(selfCallstackUnit, false);
- parent.addChild(child);
- child.addExCount();
- child.setParent(parent.getName());
- }
- } else {
- if (inputFuncName.isEmpty()) {
- parent.addExCount();
- } else {
- ProfilingData child = getProfilingDataByKey(selfCallstackUnit.getSymbol());
- if (null == child) {
- child = makeNewProfilingData(selfCallstackUnit, false);
- parent.addChild(child);
- child.setParent(parent.getName());
- }
- child.addExCount();
- }
- }
-
- // inclusive cpu time
- int size = 0;
- if (null != addrs) {
- size = addrs.size();
- }
- for (int i = 0; i < size; i++) {
- CallStackUnit callstackCsa = addrMap.get(addrs.get(i));
-
- if (callstackCsa.getFunctionName().equals(FunctionUsageProfiler.UNKNOWN)) {
- ProfilingData inParent = getProfilingDataByKey(callstackCsa.getPath());
- ProfilingData pp = null;
- if (null == inParent) {
- inParent = makeNewProfilingData(callstackCsa, true);
- checkUserCall(callstackCsa, inParent, pp, sampleLog);
- }
- inParent.addInCount(totalSampleCount);
-
- if (null != inParent.getParent()) {
- String pInParentName = inParent.getParent();
- pp = getProfilingDataByKey(pInParentName);
- if (null != pp) {
- pp.addInCount(totalSampleCount);
- }
- }
- } else {
- ProfilingData fupData = getProfilingDataByKey(callstackCsa.getSymbol());
- if (null == fupData) {
- ProfilingData inParent = getProfilingDataByKey(callstackCsa.getPath());
- if (null == inParent) {
- inParent = makeNewProfilingData(callstackCsa, true);
- checkUserCall(callstackCsa, inParent, null, sampleLog);
- }
- fupData = makeNewProfilingData(callstackCsa, false);
- fupData.setParent(inParent.getName());
-
- inParent.addChild(fupData);
- inParent.addInCount(totalSampleCount);
- if (null != inParent.getParent()) {
- String pInParentName = inParent.getParent();
- ProfilingData pp = getProfilingDataByKey(pInParentName);
- if (null != pp) {
- pp.addInCount(totalSampleCount);
- }
- }
- } else {
- String pName = fupData.getParent();
- ProfilingData inParent = getProfilingDataByKey(pName);
- inParent.addInCount(totalSampleCount);
-
- if (null != inParent.getParent()) {
- String pInParentName = inParent.getParent();
- ProfilingData ppData = getProfilingDataByKey(pInParentName);
- if (null != ppData) {
- ppData.addInCount(totalSampleCount);
- }
- }
- }
- fupData.addInCount(totalSampleCount);
- }
- }
- }
-
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * WooJin Jung <woojin2.jung@samsung.com>
- * Jooyoul Lee <jy.exe.lee@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-package org.tizen.dynamicanalyzer.ui.summary.profiling;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.tizen.dynamicanalyzer.common.Global;
-import org.tizen.dynamicanalyzer.common.path.PathConstants;
-import org.tizen.dynamicanalyzer.swap.model.data.ProfileData;
-import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackData;
-import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackUnit;
-import org.tizen.dynamicanalyzer.util.Logger;
-
-public class RuntimeProfileDataMaker extends ProfileDataMaker {
-
- public RuntimeProfileDataMaker() {
- super(Global.getRuntimeCallstackManager());
- }
-
- public void makeFunctionUsageProfileData(ProfileData sampleLog) {
- totalSampleCount++;
- List<Long> addrs = new ArrayList<Long>();
- long selfAddr = sampleLog.getPcAddr();
- int pid = sampleLog.getPid();
- int tid = sampleLog.getTid();
- long sampleTime = sampleLog.getTime();
-
- CallStackData callstackData;
- Map<Long, CallStackUnit> addrMap = callstackManager.getCallStackApiAddrByPidMap(pid);
-
- CallStackUnit callstackUnit = addrMap.get(selfAddr);
- if (null == callstackUnit) {
- CallStackUnit newCallstackUnit = new CallStackUnit(selfAddr,
- callstackManager.getCallStackSymbol(selfAddr, pid, sampleTime), sampleLog);
- addrMap.put(selfAddr, newCallstackUnit);
- }
-
- long userCallstackSeq = callstackManager.getSeqOfUserCallstackForTime(tid, sampleTime);
- if (-1 != userCallstackSeq) {
- callstackData = callstackManager.getCallStackDataBySeqMap().get(userCallstackSeq);
- if (null == callstackData) {
- Logger.debug("CallStackData is not found for seq : " + userCallstackSeq);
- addrs.add(selfAddr);
- } else {
- addrs.addAll(callstackData.getAddrs());
- for (int i = 0; i < addrs.size(); i++) {
- if (addrs.get(i) == 0) {
- addrs.remove(i);
- }
- }
- addrs.add(0, selfAddr);
- }
- } else {
- // Logger.debug("makeFunctionUsageProfileData : cannot find seq by time");
- addrs.add(selfAddr);
- }
-
- CallStackUnit inputData = addrMap.get(selfAddr);
- if (null == inputData) {
- return;
- }
-
- // drop samples of probe library
- if (inputData.getPath().startsWith(PathConstants.DA_REMOTE_PROBE_PATH)) {
- return;
- }
-
- String inputPath = inputData.getPath();
- String inputFuncName = inputData.getFunctionName();
-
- ProfilingData parent = getProfilingDataByKey(inputPath);
- // exclusive cpu time
- if (null == parent) {
- parent = makeNewProfilingData(inputData, true);
- checkUserCall(inputData, parent, null, sampleLog);
- if (inputFuncName.equals(FunctionUsageProfiler.UNKNOWN)) {
- parent.addExCount();
- } else {
- ProfilingData child = makeNewProfilingData(inputData, false);
- parent.addChild(child);
- child.addExCount();
- child.setParent(parent.getName());
- }
- } else {
- if (inputFuncName.isEmpty()) {
- parent.addExCount();
- } else {
- ProfilingData child = getProfilingDataByKey(inputData.getSymbol());
- if (null == child) {
- child = makeNewProfilingData(inputData, false);
- parent.addChild(child);
- child.setParent(parent.getName());
- }
- child.addExCount();
- }
- }
-
- // inclusive cpu time
- int size = 0;
- if (null != addrs) {
- size = addrs.size();
- }
- for (int i = 0; i < size; i++) {
- CallStackUnit callstackCsa = addrMap.get(addrs.get(i));
-
- if (callstackCsa.getFunctionName().equals(FunctionUsageProfiler.UNKNOWN)) {
- ProfilingData inParent = getProfilingDataByKey(callstackCsa.getPath());
- ProfilingData pp = null;
- if (null == inParent) {
- inParent = makeNewProfilingData(callstackCsa, true);
- checkUserCall(callstackCsa, inParent, pp, sampleLog);
- }
- inParent.addInCount(totalSampleCount);
-
- if (null != inParent.getParent()) {
- String pInParentName = inParent.getParent();
- pp = getProfilingDataByKey(pInParentName);
- if (null != pp) {
- pp.addInCount(totalSampleCount);
- }
- }
- } else {
- ProfilingData fupData = getProfilingDataByKey(callstackCsa.getSymbol());
- if (null == fupData) {
- ProfilingData inParent = getProfilingDataByKey(callstackCsa.getPath());
- if (null == inParent) {
- inParent = makeNewProfilingData(callstackCsa, true);
- checkUserCall(callstackCsa, inParent, null, sampleLog);
- }
- fupData = makeNewProfilingData(callstackCsa, false);
- fupData.setParent(inParent.getName());
-
- inParent.addChild(fupData);
- inParent.addInCount(totalSampleCount);
- if (null != inParent.getParent()) {
- String pInParentName = inParent.getParent();
- ProfilingData pp = getProfilingDataByKey(pInParentName);
- if (null != pp) {
- pp.addInCount(totalSampleCount);
- }
- }
- } else {
- String pName = fupData.getParent();
- ProfilingData inParent = getProfilingDataByKey(pName);
- if (inParent == null) {
- Logger.error("ProfilingData: function item without library item");
- continue;
- }
- inParent.addInCount(totalSampleCount);
-
- if (null != inParent.getParent()) {
- String pInParentName = inParent.getParent();
- ProfilingData ppData = getProfilingDataByKey(pInParentName);
- if (null != ppData) {
- ppData.addInCount(totalSampleCount);
- }
- }
- }
- fupData.addInCount(totalSampleCount);
- }
- }
- }
-}
import org.tizen.dynamicanalyzer.constant.CommonConstants;
import org.tizen.dynamicanalyzer.model.TreeInput;
import org.tizen.dynamicanalyzer.nl.SummaryLabels;
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
-import org.tizen.dynamicanalyzer.ui.range.RangePage;
import org.tizen.dynamicanalyzer.ui.summary.SummaryPage;
import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat;
AnalyzerConstants.SORT_TYPE_NUM,
AnalyzerConstants.SORT_TYPE_STRING,
AnalyzerConstants.SORT_TYPE_NUM };
-
- private boolean isRange = false;
public WebProfilingTable(Composite parent, int compStyle, int tableStyle) {
super(parent, compStyle, tableStyle);
GridItem[] items = table.getSelection();
String id = SummaryPage.profilingViewID;
- if (isRange) {
- id = RangePage.profilingViewID;
- }
DASelectionData selData = new DASelectionData(id, 0, 0, items, table);
AnalyzerManager.getCurrentPage().updateView(selData);
}
}
private List<Integer> getPidsOfProfileDataMakerMap() {
- if (isRange) {
- return RangeDataManager.getInstance().getPidsOfWebProfileDataMakerMap();
- } else {
- return FunctionUsageProfiler.getInstance().getPidsOfWebProfileDataMakerMap();
- }
+ return FunctionUsageProfiler.getInstance().getPidsOfWebProfileDataMakerMap();
}
private WebProfileDataMaker getProfileDataMakerByPid(int pid) {
- if (isRange) {
- return RangeDataManager.getInstance().getWebProfileDataMakerByPid(pid);
- } else {
- return FunctionUsageProfiler.getInstance().getWebProfileDataMakerByPid(pid);
- }
- }
-
- public void setRangeTable(boolean isRange) {
- this.isRange = isRange;
+ return FunctionUsageProfiler.getInstance().getWebProfileDataMakerByPid(pid);
}
}
\ No newline at end of file
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Composite;
import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
-import org.tizen.dynamicanalyzer.common.AnalyzerManager;
import org.tizen.dynamicanalyzer.common.DASelectionData;
import org.tizen.dynamicanalyzer.listeners.SummaryMouseDoubleClickListener;
import org.tizen.dynamicanalyzer.model.FilterProperty;
import org.tizen.dynamicanalyzer.model.TableInput;
import org.tizen.dynamicanalyzer.swap.model.data.LogDataFactory;
import org.tizen.dynamicanalyzer.swap.model.data.ProbeCommonData;
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
-import org.tizen.dynamicanalyzer.ui.range.RangePage;
import org.tizen.dynamicanalyzer.ui.summary.SummaryDataManager;
import org.tizen.dynamicanalyzer.ui.summary.SummaryPage;
import org.tizen.dynamicanalyzer.ui.timeline.TimelinePage;
-import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineTableView;
import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
import org.tizen.dynamicanalyzer.ui.widgets.table.DATableComposite;
import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat;
import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
public class WarningTable extends DATableComposite {
- private boolean isRange = false;
-
private final WarningDataMaker warningDataMaker =
SummaryDataManager.getInstance().getWarningDataMaker();
long time = dataFormat.getLogData().getTime();
String id = SummaryPage.warningListViewID;
- if (isRange) {
- id = RangePage.warningListViewID;
- }
DASelectionData selData = new DASelectionData(id, time, 0,
items, table);
// AnalyzerManager.getCurrentPage().updateView(selData);
table.addMouseListener(new SummaryMouseDoubleClickListener(
SummaryPage.warningListViewID));
}
-
- public void setRangeTable(boolean isRange) {
- this.isRange = isRange;
- }
-
-// protected List<TableInput> makeTableInput() {
-// List<WarningData> warningList = null;
-// if (isRange) {
-// warningList = RangeDataManager.getInstance().getWarningChecker()
-// .getWarningData();
-// } else {
-// warningList = AnalyzerManager.getWarningChecker().getWarningData();
-// }
-// List<TableInput> input = new ArrayList<TableInput>();
-// int size = warningList.size();
-// for (int i = 0; i < size; i++) {
-// // create text
-// List<String> text = new ArrayList<String>();
-// List<String> data = new ArrayList<String>();
-// WarningData warningData = warningList.get(i);
-//
-// text.add(Long.toString(warningData.getSeq()));
-// data.add(Long.toString(warningData.getSeq()));
-//
-// text.add(warningData.getCategory());
-// data.add(warningData.getCategory());
-//
-// text.add(Integer.toString(warningData.getPid()));
-// data.add(Integer.toString(warningData.getPid()));
-// String message = WarningChecker.messageMaker(warningData, true);
-// text.add(message);
-// data.add(message);
-// // create images
-//
-// // create DATableDataFormat
-// DATableDataFormat tableData = new DATableDataFormat(warningData
-// .getLogData().getSeq());
-// tableData.getData().addAll(text);
-// tableData.setLogData(warningData.getLogData());
-// tableData.setType(AnalyzerConstants.TYPE_TABLE_WARNING);
-// TableInput tableInput = new TableInput();
-// tableInput.setText(text);
-// tableInput.setData(tableData);
-// input.add(tableInput);
-// }
-// return input;
-// }
protected List<TableInput> makeTableInput() {
List<List<Object>> warningData = null;
}
private boolean isVaildData(List<Object> idata){
- Long markerStartTime = null;
- Long markerEndTime = null;
- if (isRange) {
- markerStartTime = Long.valueOf(RangeDataManager.getInstance().getMarkerStartTime());
- markerEndTime = Long.valueOf(RangeDataManager.getInstance().getMarkerEndTime());
- }else{
- markerStartTime = (long) 0;
- markerEndTime = Toolbar.INSTANCE.getTime();
- }
+ Long markerStartTime = 0l;
+ Long markerEndTime = Toolbar.INSTANCE.getTime();
Long startTime = (Long)idata.get(WarningDataDBTable.COLUMN.START_TIME.index);
Long endTime = (Long)idata.get(WarningDataDBTable.COLUMN.END_TIME.index);
import org.tizen.dynamicanalyzer.common.DASelectionData;
import org.tizen.dynamicanalyzer.nl.ThreadPageLabels;
import org.tizen.dynamicanalyzer.resources.ColorResources;
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
import org.tizen.dynamicanalyzer.ui.thread.type.ThreadPageData;
import org.tizen.dynamicanalyzer.ui.timeline.TimelinePage;
import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
return;
}
- long newAnalysisStartTime = 0;
- long newAnalysisEndTime = 0;
-
- if (RangeDataManager.getInstance().isBeingAnalyzed()) {
- newAnalysisStartTime = RangeDataManager.getInstance().getAnalysisStartTime();
- newAnalysisEndTime = RangeDataManager.getInstance().getAnalysisEndTime();
- } else {
- newAnalysisStartTime = 0;
- newAnalysisEndTime = 0;
- }
-
- if (newAnalysisStartTime != analysisStartTime || newAnalysisEndTime != analysisEndTime) {
- analysisStartTime = newAnalysisStartTime;
- analysisEndTime = newAnalysisEndTime;
- tableComp.updateTable();
-
- return;
- }
-
int selectedPid = Toolbar.INSTANCE.getSelectedPid();
if (preSelectionPid != -1 && preSelectionPid != selectedPid) {
tableComp.updateTable();
this.setBackground(ColorResources.WHITE);
this.setLayout(new FillLayout());
-// ((FillLayout) getLayout()).marginHeight = 15;
-// ((FillLayout) getLayout()).marginWidth = 5;
-
ThreadChartView threadChartView = new ThreadChartView(topForm, SWT.NONE);
addView(threadChartView);
threadApiTableView = new DATabComposite(bottomLeftForm, SWT.NONE, false, true);
{
+ threadApiTableView.setID(AnalyzerLabels.LEFT_TABLE_VIEW_ID);
ThreadAPIListView threadAPIListView = new ThreadAPIListView(threadApiTableView.getContentComposite(),
SWT.NONE);
threadApiTableView.addView(threadAPIListView);
- addView(threadAPIListView);
}
addView(threadApiTableView);
threadDetailTableView = new DATabComposite(bottomRightForm, SWT.NONE, false, true);
{
+ threadDetailTableView.setID(AnalyzerLabels.RIGHT_TABLE_VIEW_ID);
ThreadDetailInfoView threadDetailInfoView = new ThreadDetailInfoView(
threadDetailTableView.getContentComposite(), SWT.NONE);
threadDetailTableView.addView(threadDetailInfoView);
- addView(threadDetailInfoView);
}
addView(threadDetailTableView);
}
import org.eclipse.swt.widgets.Composite;
import org.tizen.dynamicanalyzer.database.SqlConnectionManager;
import org.tizen.dynamicanalyzer.nl.ThreadPageLabels;
-import org.tizen.dynamicanalyzer.nl.TimelineChartLabels;
import org.tizen.dynamicanalyzer.resources.ColorResources;
import org.tizen.dynamicanalyzer.resources.FontResources;
import org.tizen.dynamicanalyzer.resources.ImageResources;
-import org.tizen.dynamicanalyzer.ui.common.PopupRangeAnalysisMenuItemOnChartListener;
+import org.tizen.dynamicanalyzer.ui.common.ChartPopupMenu;
import org.tizen.dynamicanalyzer.ui.common.TimeLineChartKeyListener;
import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseEventListener;
import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseTrackAdapter;
import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotTooltip;
import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoardItem;
import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenu;
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuItem;
public class SyncChartBoard extends DADefaultChartBoard {
private List<SyncChart> syncChartItemList = new ArrayList<SyncChart>();
selectionMarker.setBackgroundColor(ColorResources.SELECTION_RANGE);
selectionMarker.setAlpha((int) (255 * 0.25));
addIntervalMarker(selectionMarker);
-
- // range analysis marker
- DAChartPlotIntervalMarker rangeAnalyzeMarker = new DAChartPlotIntervalMarker(-1, -1,
- DAChartPlotIntervalMarker.INTERVAL_MARKER_STYLE_AREA);
- rangeAnalyzeMarker.setBackgroundColor(ColorResources.YELLOW);
- rangeAnalyzeMarker.setAlpha((int) (255 * 0.25));
- addIntervalMarker(rangeAnalyzeMarker);
-
- // range marker
- DAChartPlotIntervalMarker rangeMarker = new DAChartPlotIntervalMarker(-1, -1,
- DAChartPlotIntervalMarker.INTERVAL_MARKER_STYLE_LINE);
- rangeMarker.setForegroundColor(ColorResources.RED);
- rangeMarker.setAlpha((int) (255 * 0.25));
- addIntervalMarker(rangeMarker);
-
}
protected void initChart(final DAChart chart, boolean isParent) {
tooltip.setFont(FontResources.CHART_TOOLTIP_FONT);
plot.setTooltip(tooltip);
- DAPopupMenu popupMenu = new DAPopupMenu(chart);
+ DAPopupMenu popupMenu = new ChartPopupMenu(chart);
popupMenu.setFont(FontResources.CONTEXT_MENU_ITEM_FONT);
-
- DAPopupMenuItem analysisItem = new DAPopupMenuItem(popupMenu);
- analysisItem.setText(TimelineChartLabels.RANGE_CONTEXT_ANALYSIS);
- analysisItem.addListener(new PopupRangeAnalysisMenuItemOnChartListener(analysisItem, this, chart));
TimelineChartMouseEventListener timelineChartMouseEventListener = new TimelineChartMouseEventListener(
popupMenu, getTimeline(), ThreadPage.pageID);
import org.eclipse.swt.widgets.Composite;
import org.tizen.dynamicanalyzer.database.SqlConnectionManager;
import org.tizen.dynamicanalyzer.nl.ThreadPageLabels;
-import org.tizen.dynamicanalyzer.nl.TimelineChartLabels;
import org.tizen.dynamicanalyzer.resources.FontResources;
import org.tizen.dynamicanalyzer.resources.ImageResources;
-import org.tizen.dynamicanalyzer.ui.common.PopupRangeAnalysisMenuItemOnChartListener;
+import org.tizen.dynamicanalyzer.ui.common.ChartPopupMenu;
import org.tizen.dynamicanalyzer.ui.common.TimeLineChartKeyListener;
import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseEventListener;
import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseTrackAdapter;
DAChartPlotTooltip tooltip = new DAChartPlotTooltip(-1);
tooltip.setFont(FontResources.CHART_TOOLTIP_FONT);
plot.setTooltip(tooltip);
- DAPopupMenu popupMenu = new DAPopupMenu(chart);
+ DAPopupMenu popupMenu = new ChartPopupMenu(chart);
plot.setBackgroundImage(ImageResources.BG_GRADIENT);
popupMenu.setFont(FontResources.CONTEXT_MENU_ITEM_FONT);
- DAPopupMenuItem analysisItem = new DAPopupMenuItem(popupMenu);
- analysisItem.setText(TimelineChartLabels.RANGE_CONTEXT_ANALYSIS);
- analysisItem.addListener(new PopupRangeAnalysisMenuItemOnChartListener(analysisItem, this, chart));
-
///Add Keylistener 0215
TimeLineChartKeyListener timelineKeyListener = new TimeLineChartKeyListener(this);
chart.addKeyListener(timelineKeyListener);
import org.tizen.dynamicanalyzer.swap.model.data.ProbeCommonData;
import org.tizen.dynamicanalyzer.ui.common.UICommonConstants;
import org.tizen.dynamicanalyzer.ui.page.BaseView;
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
import org.tizen.dynamicanalyzer.ui.thread.ThreadPage;
import org.tizen.dynamicanalyzer.ui.thread.type.ThreadPageThreadData;
import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
updateProcessCombo();
if (stackLayout.topControl == syncChartBoard) {
updateTimeLine(syncChartBoard);
- updateRange(syncChartBoard);
syncChartBoard.updateChart();
} else {
updateTimeLine(threadChartBoard);
- updateRange(threadChartBoard);
threadChartBoard.updateChart();
}
}
- private void updateRange(DAChartBoard chartBoard) {
- if (RangeDataManager.getInstance().isBeingAnalyzed()) {
- ((DAChartPlotIntervalMarker) chartBoard.getMarkers().get(
- UICommonConstants.RANGE_ANALYSIS_MARKER_INDEX)).setInterval(RangeDataManager
- .getInstance().getAnalysisStartTime() / TimelineConstants.MEGA_DOUBLE,
- RangeDataManager.getInstance().getAnalysisEndTime()
- / TimelineConstants.MEGA_DOUBLE);
- } else {
- ((DAChartPlotIntervalMarker) chartBoard.getMarkers().get(
- UICommonConstants.RANGE_ANALYSIS_MARKER_INDEX)).setInterval(-1, -1);
- }
- ((DAChartPlotIntervalMarker) chartBoard.getMarkers().get(
- UICommonConstants.RANGE_MARKER_INDEX)).setInterval(RangeDataManager.getInstance()
- .getMarkerStartTime() / TimelineConstants.MEGA_DOUBLE, RangeDataManager
- .getInstance().getMarkerEndTime() / TimelineConstants.MEGA_DOUBLE);
- }
-
private void updateTimeLine(DAChartBoard chartBoard) {
/*
* In case of Latest status, update visibleStartTime of chartBoard.
return 0;
}
- public void setRangeMarker(double starttime, double endtime) {
- DAChartBoard currentChart = (DAChartBoard) stackLayout.topControl;
-
- ((DAChartPlotIntervalMarker) currentChart.getMarkers().get(
- UICommonConstants.RANGE_MARKER_INDEX)).setInterval(starttime, endtime);
- }
-
@Override
public void clear() {
syncChartBoard.contentsClear();
addColumn(new DBColumn(COLUMN.SYNC_VALUE.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
addColumn(new DBColumn(COLUMN.BLOCK_END_TIME.name, DBConstants.NOT_NULL,
DBConstants.DBTYPE_LONG));
- setIndexColumn(COLUMN.SYNC_DATA_ID.index);
+ addIndex(COLUMN.SYNC_DATA_ID.index);
}
public List<List<Object>> getSyncEventFromDB() {
addColumn(new DBColumn(COLUMN.RETURN_VALUE.name, DBConstants.EMPTY, DBConstants.DBTYPE_VARCHAR,
DALimit.FUNCTION_RETURN_VALUE_LENGTH));
addColumn(new DBColumn(COLUMN.ERROR_NUMBER.name, DBConstants.EMPTY, DBConstants.DBTYPE_LONG));
- setIndexColumn(COLUMN.THREAD_DATA_ID.index);
+ addIndex(COLUMN.THREAD_DATA_ID.index);
}
public List<List<Object>> getThreadAPIFromDB() {
addColumn(new DBColumn(COLUMN.THREAD_TYPE.name, DBConstants.NOT_NULL,
DBConstants.DBTYPE_INT4));
addColumn(new DBColumn(COLUMN.CALLER_ID.name, DBConstants.EMPTY, DBConstants.DBTYPE_INT4));
- setIndexColumn(COLUMN.THREAD_DATA_ID.index);
+ addIndex(COLUMN.THREAD_DATA_ID.index);
}
public List<List<Object>> getThreadEventFromDB() {
public LifeCycleDBTable() {
addColumn(new DBColumn(LIFE_CHANGE_TIME, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
addColumn(new DBColumn(LIFE_STATUS, DBConstants.EMPTY, DBConstants.DBTYPE_INT4));
- setIndexColumn(COLUMN.LIFE_CHANGE_TIME.ordinal());
+ addIndex(COLUMN.LIFE_CHANGE_TIME.ordinal());
}
@Override
addColumn(new DBColumn(PROCESS_PID_OTHER, DBConstants.EMPTY, DBConstants.INTEGER_ARRAY));
addColumn(new DBColumn(PROCESS_LOAD_OTHER, DBConstants.EMPTY, DBConstants.FLOAT_ARRAY));
addColumn(new DBColumn(DEVICE_STATUS, DBConstants.EMPTY, DBConstants.INTEGER_ARRAY));
- setIndexColumn(COLUMN.SAMPLING_TIME.ordinal());
+ addIndex(COLUMN.SAMPLING_TIME.ordinal());
}
@Override
addColumn(new DBColumn(HEAP_ALLOCATION_BYTE, DBConstants.EMPTY, DBConstants.BIGINT_ARRAY));
addColumn(new DBColumn(TID, DBConstants.EMPTY, DBConstants.INTEGER_ARRAY));
addColumn(new DBColumn(THREAD_LOAD, DBConstants.EMPTY, DBConstants.FLOAT_ARRAY));
- setIndexColumn(COLUMN.SAMPLING_TIME.ordinal());
+ addIndex(COLUMN.SAMPLING_TIME.ordinal());
}
@Override
import org.tizen.dynamicanalyzer.shortcut.ShortCutManager;
import org.tizen.dynamicanalyzer.ui.info.callstack.CallstackView;
import org.tizen.dynamicanalyzer.ui.info.screenshot.ScreenshotDataManager;
-import org.tizen.dynamicanalyzer.ui.interactive.data.InteractiveDataManager;
import org.tizen.dynamicanalyzer.ui.summary.SummaryDataManager;
import org.tizen.dynamicanalyzer.ui.summary.profiling.FunctionUsageProfiler;
import org.tizen.dynamicanalyzer.ui.timeline.calltrace.CallTraceDataManager;
this.setData(KEY_TOOLTIP, ShortCutManager.COOLBAR_AREA_TIMELINE_TOOLTIP);
this.setBackground(ColorResources.WHITE);
this.setLayout(new FillLayout());
-
-// ((FillLayout) getLayout()).marginHeight = 15;
-// ((FillLayout) getLayout()).marginWidth = 5;
timelineChartView = new TimelineChartView(topForm, SWT.NONE);
addView(timelineChartView);
timelineTableView = new TimelineTableView(bottomLeftForm, SWT.NONE);
+ timelineTableView.setID(AnalyzerLabels.LEFT_TABLE_VIEW_ID);
addView(timelineTableView);
DATabComposite timelineCallStackTableView = new DATabComposite(bottomRightForm, SWT.NONE, false, true);
{
+ timelineCallStackTableView.setID(AnalyzerLabels.RIGHT_TABLE_VIEW_ID);
CallstackView callstack = new CallstackView(timelineCallStackTableView.getContentComposite(), SWT.NONE);
timelineCallStackTableView.addView(callstack, false);
- addView(callstack);
}
addView(timelineCallStackTableView);
}
// clear data managers
TimelineDataManager.getInstance().clear();
CallTraceDataManager.getInstance().clear();
- InteractiveDataManager.getInstance().clear();
ScreenshotDataManager.getInstance().clear();
FunctionUsageProfiler.getInstance().clear();
SummaryDataManager.getInstance().clear();
addColumn(new DBColumn(POINT_Y, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
addColumn(new DBColumn(INFO_STRING, DBConstants.NOT_NULL, DBConstants.DBTYPE_VARCHAR, MAX_INFO_LEN));
addColumn(new DBColumn(INFO_INTEGER, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
- setIndexColumn(COLUMN.EVENT_TIME.ordinal());
+ addIndex(COLUMN.EVENT_TIME.ordinal());
}
@Override
package org.tizen.dynamicanalyzer.ui.timeline.calltrace;
+import java.sql.SQLException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
+import org.eclipse.swt.widgets.Display;
import org.tizen.dynamicanalyzer.common.Global;
-import org.tizen.dynamicanalyzer.communicator.UnsupportedProtocolException;
+import org.tizen.dynamicanalyzer.database.DBTable;
+import org.tizen.dynamicanalyzer.project.LibraryObject;
import org.tizen.dynamicanalyzer.project.ProcessInformation;
+import org.tizen.dynamicanalyzer.project.ProcessMemoryMap;
import org.tizen.dynamicanalyzer.protocol.ProtocolConstants;
import org.tizen.dynamicanalyzer.swap.logparser.LogPackage;
import org.tizen.dynamicanalyzer.swap.logparser.Logs;
import org.tizen.dynamicanalyzer.swap.model.data.LogData;
import org.tizen.dynamicanalyzer.swap.model.data.ProfileData;
import org.tizen.dynamicanalyzer.swap.model.data.WebProfileData;
+import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackUnit;
+import org.tizen.dynamicanalyzer.ui.summary.profiling.FunctionUsageProfiler;
+import org.tizen.dynamicanalyzer.ui.summary.profiling.ProfilingTable;
+import org.tizen.dynamicanalyzer.ui.widgets.table.DATableComposite;
+import org.tizen.dynamicanalyzer.ui.widgets.table.DATableRegistry;
import org.tizen.dynamicanalyzer.util.Logger;
public class CallTraceDataManager extends PageDataManager {
// native function
private FunctionEntryDBTable functionEntryTable = null;
- private FunctionExitDBTable functionExitTable = null;
// web function
private WebFunctionEntryDBTable webFunctionEntryTable = null;
private CallTraceDataManager() {
functionEntryTable = new FunctionEntryDBTable();
- functionExitTable = new FunctionExitDBTable();
webFunctionEntryTable = new WebFunctionEntryDBTable();
webFunctionExitTable = new WebFunctionExitDBTable();
return functionEntryTable;
}
- public FunctionExitDBTable getFunctionExitTable() {
- return functionExitTable;
- }
-
public WebFunctionEntryDBTable getWebFunctionEntryTable() {
return webFunctionEntryTable;
}
private void makeNativeData(LogPackage pack) {
Logs entryLogs = pack.getLogs(ProtocolConstants.MSG_FUNCTION_ENTRY);
- if (null != entryLogs && entryLogs.getRawLogs().size() != 0) {
+ if (null != entryLogs && !entryLogs.getRawLogs().isEmpty()) {
List<LogData> inputs = entryLogs.getLogs();
- List<List<Object>> insertData = new ArrayList<List<Object>>();
+ List<List<Object>> insertData = new ArrayList<>();
int size = inputs.size();
for (int i = 0; i < size; i++) {
- List<Object> insertRowData = new ArrayList<Object>();
ProfileData pData = (ProfileData) inputs.get(i);
// probe type 4 is for file analysis with non-target process
// no need to insert into DB
- try {
- if (pData.getProbeType() == ProtocolConstants.FUNCTION_TYPE_FILE) {
- continue;
- }
- } catch (UnsupportedProtocolException e) {
- // do nothing
- }
-
- try {
- insertRowData.add(new Long(pData.getSeq()));
- insertRowData.add(new Integer(pData.getPid()));
- insertRowData.add(new Integer(pData.getTid()));
- insertRowData.add(new Integer(pData.getApiId()));
- insertRowData.add(new Integer(pData.getBinaryId()));
- insertRowData.add(new Long(pData.getTime()));
- insertRowData.add(new Long(pData.getCallerPcAddr()));
- insertRowData.add(new Long(pData.getPcAddr()));
- insertRowData.add(new String(pData.getArgs()));
- } catch (ArrayIndexOutOfBoundsException e) {
- Logger.exception(e);
+ if (pData.getProbeType() == ProtocolConstants.FUNCTION_TYPE_FILE) {
+ continue;
}
- insertData.add(insertRowData);
+ insertData.add(createEntryRowData(pData));
// for calltrace table windowing
ProcessInformation process = Global.getProject().getProcessInformation(
pData.getPid());
process.addFunctionEntryLogCount();
}
- if (insertData.size() > 0) {
+ if (!insertData.isEmpty()) {
functionEntryTable.insertData(insertData);
}
}
Logs exitLogs = pack.getLogs(ProtocolConstants.MSG_FUNCTION_EXIT);
- if (null != exitLogs && exitLogs.getRawLogs().size() != 0) {
+ if (null != exitLogs && !exitLogs.getRawLogs().isEmpty()) {
List<LogData> inputs = exitLogs.getLogs();
- List<List<Object>> insertData = new ArrayList<List<Object>>();
+ List<List<Object>> insertData = new ArrayList<>();
int size = inputs.size();
for (int i = 0; i < size; i++) {
- List<Object> insertRowData = new ArrayList<Object>();
ProfileData pData = (ProfileData) inputs.get(i);
-
- try {
- insertRowData.add(new Long(pData.getEntrySeq()));
- insertRowData.add(new Long(pData.getSeq()));
- insertRowData.add(new Long(pData.getTime()));
- insertRowData.add(new String(pData.getReturn()));
- } catch (ArrayIndexOutOfBoundsException e) {
- Logger.exception(e);
- }
- insertData.add(insertRowData);
+ insertData.add(createExitRowData(pData));
}
- if (insertData.size() > 0) {
- functionExitTable.insertData(insertData);
+ if (!insertData.isEmpty()) {
+ functionEntryTable.insertData(insertData);
}
}
}
+ private List<Object> createEntryRowData(ProfileData pData) {
+ List<Object> insertRowData = new ArrayList<>();
+ insertRowData.add(Boolean.TRUE);// IS_ENTRY
+ insertRowData.add(pData.getSeq());// SEQ
+ insertRowData.add(pData.getPid());// PID
+ insertRowData.add(pData.getTid());// TID
+ if (pData.getApiId() >= 0)
+ insertRowData.add(pData.getApiId());// FunctionID
+ else
+ insertRowData.add(0);// FunctionID
+ insertRowData.add(pData.getBinaryId());// BinaryID
+ insertRowData.add(pData.getTime());// START_TIME
+ insertRowData.add(0L);// END_TIME
+ insertRowData.add(pData.getCallerPcAddr());// Caller_Address
+ insertRowData.add(pData.getPcAddr());// Self_Address
+ insertRowData.add(pData.getArgs());// ARGS
+ insertRowData.add("");// Return value
+ return insertRowData;
+ }
+
+ private List<Object> createExitRowData(ProfileData pData) {
+ List<Object> insertRowData = new ArrayList<>();
+ insertRowData.add(Boolean.FALSE);// IS_ENTRY
+ insertRowData.add(pData.getSeq());// SEQ
+ insertRowData.add(pData.getPid());// PID
+ insertRowData.add(pData.getTid());// TID
+ insertRowData.add(0);// FunctionID
+ insertRowData.add(0);// BinaryID
+ insertRowData.add(pData.getTime());// START_TIME
+ insertRowData.add(pData.getTime());// END_TIME
+ insertRowData.add(pData.getCallerPcAddr());// Caller_Address
+ insertRowData.add(pData.getPcAddr());// Self_Address
+ insertRowData.add("");// ARGS
+ insertRowData.add(pData.getReturn());// Return value
+ return insertRowData;
+ }
+
private void makeWebData(LogPackage pack) {
Logs entryLogs = pack.getLogs(ProtocolConstants.MSG_WEB_FUNCTION_ENTRY);
- if (null != entryLogs && entryLogs.getRawLogs().size() != 0) {
+ if (null != entryLogs && !entryLogs.getRawLogs().isEmpty()) {
List<LogData> inputs = entryLogs.getLogs();
- List<List<Object>> insertData = new ArrayList<List<Object>>();
+ List<List<Object>> insertData = new ArrayList<>();
int size = inputs.size();
for (int i = 0; i < size; i++) {
- List<Object> insertRowData = new ArrayList<Object>();
+ List<Object> insertRowData = new ArrayList<>();
WebProfileData pData = (WebProfileData) inputs.get(i);
- try {
- insertRowData.add(new Long(pData.getSeq()));
- insertRowData.add(new Integer(pData.getPid()));
- insertRowData.add(new Integer(pData.getTid()));
- insertRowData.add(new Integer(pData.getFunctionLineNumber()));
- insertRowData.add(pData.getFunctionName());
- insertRowData.add(pData.getFunctionURL());
- insertRowData.add(new Long(pData.getTime()));
- } catch (ArrayIndexOutOfBoundsException e) {
- Logger.exception(e);
- }
+ insertRowData.add(pData.getSeq());
+ insertRowData.add(pData.getPid());
+ insertRowData.add(pData.getTid());
+ insertRowData.add(pData.getFunctionLineNumber());
+ insertRowData.add(pData.getFunctionName());
+ insertRowData.add(pData.getFunctionURL());
+ insertRowData.add(pData.getTime());
+
insertData.add(insertRowData);
// for calltrace table windowing
pData.getPid());
process.addFunctionEntryLogCount();
}
- if (insertData.size() > 0) {
+ if (!insertData.isEmpty()) {
webFunctionEntryTable.insertData(insertData);
}
}
Logs exitLogs = pack.getLogs(ProtocolConstants.MSG_WEB_FUNCTION_EXIT);
- if (null != exitLogs && exitLogs.getRawLogs().size() != 0) {
+ if (null != exitLogs && !exitLogs.getRawLogs().isEmpty()) {
List<LogData> inputs = exitLogs.getLogs();
- List<List<Object>> insertData = new ArrayList<List<Object>>();
+ List<List<Object>> insertData = new ArrayList<>();
int size = inputs.size();
for (int i = 0; i < size; i++) {
- List<Object> insertRowData = new ArrayList<Object>();
+ List<Object> insertRowData = new ArrayList<>();
WebProfileData pData = (WebProfileData) inputs.get(i);
- try {
- insertRowData.add(new Long(pData.getEntrySeq()));
- insertRowData.add(new Long(pData.getSeq()));
- insertRowData.add(new Long(pData.getTime()));
- } catch (ArrayIndexOutOfBoundsException e) {
- Logger.exception(e);
- }
+ insertRowData.add(pData.getEntrySeq());
+ insertRowData.add(pData.getSeq());
+ insertRowData.add(pData.getTime());
+
insertData.add(insertRowData);
}
- if (insertData.size() > 0) {
+ if (!insertData.isEmpty()) {
webFunctionExitTable.insertData(insertData);
}
}
}
+
+ /**
+ * Update Function Entry DB table: for each entry it finds corresponding
+ * exit and updates entry record with corresponding exit time.
+ */
+ public void addCallStackIndexes() {
+ ArrayList<Thread> threads = new ArrayList<>();
+ for (int pid : Global.getProject().getProcessIDs()) {
+ try {
+ threads.add(new Thread(new FunctionEntryIndexer(functionEntryTable, pid),
+ "Function Entry Indexer"));
+ threads.get(threads.size() - 1).start();
+ } catch (SQLException e) {
+ Logger.error("failed to connect to database: " + e);
+ }
+ }
+ threads.forEach(arg0 -> {
+ try {
+ arg0.join();
+ } catch (InterruptedException e) {
+ Logger.error(e);
+ Thread.currentThread().interrupt();
+ }
+ });
+ final DATableComposite profiling = DATableRegistry.getTable(ProfilingTable.class.getName());
+ if (profiling != null) {
+ Display.getDefault().syncExec(profiling::updateTable);
+ }
+ FunctionUsageProfiler.getInstance().doSaveProfilingData();
+ }
+
+ /**
+ * Builds callstack for specified pid, tid and time. Note: It works
+ * correctly only when Function Entry DB table updated with exit times for
+ * all entries. If specified time equals to Exit time of some function, this
+ * function will be added to callstack.
+ *
+ * @param pid pid
+ * @param tid tid
+ * @param time time in microseconds
+ *
+ * @return List of {@link CallStackUnit} ordered to be a call stack, where
+ * last function control entered in is on the top.
+ */
+ public List<CallStackUnit> getCallstackForSampling(Integer pid, Integer tid, Long time) {
+ return getCallStack(pid, tid, time, true);
+ }
+
+ /**
+ * Builds callstack for specified pid, tid and time. Note: It works
+ * correctly only when Function Entry DB table updated with exit times for
+ * all entries. If specified time equals to Exit time of some function, this
+ * function will not be added to callstack.
+ *
+ * @param pid pid
+ * @param tid tid
+ * @param time time in microseconds
+ *
+ * @return List of {@link CallStackUnit} ordered to be a call stack, where
+ * last function control entered in is on the top.
+ */
+ public List<CallStackUnit> getCallstackForTable(Integer pid, Integer tid, Long time) {
+ return getCallStack(pid, tid, time, false);
+ }
+
+ /**
+ * Builds callstack for specified pid, tid and time.
+ * Note: It works correctly only when Function Entry DB table updated
+ * with exit times for all entries.
+ *
+ * @param pid pid
+ * @param tid tid
+ * @param time time in microseconds
+ * @param calledforExit indicate whether we should add function if its exit
+ * time equals to specified or not
+ *
+ * @return List of {@link CallStackUnit} ordered to be a call stack, where
+ * last function control entered in is on the top.
+ */
+ private List<CallStackUnit> getCallStack(Integer pid, Integer tid, Long time,
+ boolean calledforExit) {
+ String where = DBTable.WHERE + FunctionEntryDBTable.COLUMN.START_TIME.name + "<=" + time
+ + DBTable.AND + "(" + FunctionEntryDBTable.COLUMN.END_TIME.name
+ + (calledforExit ? ">=" : '>') + time
+ + DBTable.OR + FunctionEntryDBTable.COLUMN.END_TIME.name + "=0"
+ + ')' + DBTable.AND + FunctionEntryDBTable.COLUMN.IS_ENTRY.name + DBTable.AND
+ + FunctionEntryDBTable.COLUMN.PID.name + '=' + pid + DBTable.AND
+ + FunctionEntryDBTable.COLUMN.TID.name + '=' + tid
+ + DBTable.ORDER_BY + FunctionEntryDBTable.COLUMN.START_TIME.name + DBTable.DESC;
+ List<List<Object>> list = functionEntryTable.selectAllColumnData(where);
+ if (list == null || list.isEmpty())
+ return Collections.emptyList();
+ List<CallStackUnit> res = new ArrayList<>();
+ ProcessMemoryMap memMap = Global.getProject().getProcessInformation(pid)
+ .getProcessMemoryMap(time);
+ CallStackUnit unknown = new CallStackUnit();
+ for (int i = 0; i < list.size(); i++) {
+ List<Object> buf = list.get(i);
+ long address = (long) buf.get(FunctionEntryDBTable.COLUMN.START_PC_ADDRESS.index);
+ long callerAddress = (long) buf
+ .get(FunctionEntryDBTable.COLUMN.CALLER_PC_ADDRESS.index);
+ int dbpid = (int) buf.get(FunctionEntryDBTable.COLUMN.PID.index);
+ int dbtid = (int) buf.get(FunctionEntryDBTable.COLUMN.TID.index);
+ long dbtime = (long) buf.get(FunctionEntryDBTable.COLUMN.START_TIME.index);
+ int functionID = (int) buf.get(FunctionEntryDBTable.COLUMN.FUNCTION_ID.index);
+ int binaryID = (int) buf.get(FunctionEntryDBTable.COLUMN.BINARY_ID.index);
+ String functionName = Global.getFunctionName(functionID);
+ String path = Global.getLibraryName(binaryID);
+ CallStackUnit api = new CallStackUnit(address, callerAddress, dbpid, dbtid, dbtime,
+ functionID, binaryID, functionName, path);
+ res.add(api);
+ if (i < list.size() - 1 && calledFromUnknown(callerAddress, memMap, list.get(i + 1)))
+ res.add(unknown);
+ }
+ return res;
+ }
+
+ /**
+ * Check whether current caller address doesn't belong to library that is
+ * specified as next in call stack.
+ *
+ * @param callerAddress caller address of current {@link CallStackUnit}
+ * @param memMap {@link ProcessMemoryMap} actual for call stack creating
+ * time.
+ * @param list database representation of next call stack unit
+ *
+ * @return {@code true} if next callStack unit does not call current.
+ */
+ private boolean calledFromUnknown(long callerAddress, ProcessMemoryMap memMap,
+ List<Object> list) {
+ LibraryObject lib = memMap.getLibraryByAddress(callerAddress);
+ // called from library that is not mapped.
+ if (lib == null)
+ return true;
+ // called from not profiled library
+ if (lib.getBinaryID() != (Integer) list.get(FunctionEntryDBTable.COLUMN.BINARY_ID.index))
+ return true;
+ return false;
+ }
+
+ /**
+ * Select entries with specified function id,
+ *
+ * @return list of records from db table.
+ */
+ public List<List<Object>> getCallTrace() {
+ String where = DBTable.WHERE + FunctionEntryDBTable.COLUMN.IS_ENTRY.name + DBTable.AND
+ + FunctionEntryDBTable.COLUMN.FUNCTION_ID + ">" + 0 + DBTable.ORDER_BY
+ + FunctionEntryDBTable.COLUMN.START_TIME.name;
+ return functionEntryTable.selectAllColumnData(where);
+ }
+
+ /**
+ * Return last entry performed in thread for specified time.
+ *
+ * @param pid pid
+ * @param tid tid
+ * @param time time in microseconds
+ *
+ * @return {@link CallStackUnit} representing last performed entry.
+ */
+ public CallStackUnit getLastEntry(Integer pid, Integer tid, Long time) {
+ String where = DBTable.WHERE + FunctionEntryDBTable.COLUMN.START_TIME.name + "<="
+ + time + DBTable.AND + FunctionEntryDBTable.COLUMN.IS_ENTRY.name + DBTable.AND
+ + FunctionEntryDBTable.COLUMN.PID.name + "=" + pid + DBTable.AND
+ + FunctionEntryDBTable.COLUMN.TID.name + "=" + tid
+ + DBTable.ORDER_BY + FunctionEntryDBTable.COLUMN.START_TIME.name + DBTable.DESC
+ + " limit 1";
+ List<List<Object>> list = functionEntryTable.selectAllColumnData(where);
+ if (list == null || list.isEmpty()) {
+ return null;
+ }
+ long address = (long) list.get(0).get(FunctionEntryDBTable.COLUMN.START_PC_ADDRESS.index);
+ long callerAddress = (long) list.get(0).get(
+ FunctionEntryDBTable.COLUMN.CALLER_PC_ADDRESS.index);
+ int dbpid = (int) list.get(0).get(FunctionEntryDBTable.COLUMN.PID.index);
+ int dbtid = (int) list.get(0).get(FunctionEntryDBTable.COLUMN.TID.index);
+ long dbtime = (long) list.get(0).get(FunctionEntryDBTable.COLUMN.START_TIME.index);
+ int functionID = (int) list.get(0).get(FunctionEntryDBTable.COLUMN.FUNCTION_ID.index);
+ int binaryID = (int) list.get(0).get(FunctionEntryDBTable.COLUMN.BINARY_ID.index);
+ String functionName = Global.getFunctionName(functionID);
+ String path = Global.getLibraryName(binaryID);
+ return new CallStackUnit(address, callerAddress, dbpid, dbtid, dbtime, functionID, binaryID,
+ functionName, path);
+ }
+
+ /**
+ * Return last entry performed in thread for specified time in specified
+ * function.
+ *
+ * @param pid pid
+ * @param tid tid
+ * @param time time in microseconds
+ * @param functionID function id
+ *
+ * @return {@link CallStackUnit} representing last performed entry in
+ * specified function performed before specified time.
+ */
+ public CallStackUnit getLastEntryInFunction(int pid, int tid, long time, int functionID) {
+ String where = DBTable.WHERE + FunctionEntryDBTable.COLUMN.START_TIME.name + "<=" + time
+ + DBTable.AND + FunctionEntryDBTable.COLUMN.IS_ENTRY.name + DBTable.AND
+ + FunctionEntryDBTable.COLUMN.PID.name + "=" + pid + DBTable.AND
+ + FunctionEntryDBTable.COLUMN.TID.name + "=" + tid + DBTable.AND
+ + FunctionEntryDBTable.COLUMN.FUNCTION_ID.name + "=" + functionID + DBTable.ORDER_BY
+ + FunctionEntryDBTable.COLUMN.START_TIME.name + DBTable.DESC + " limit 1";
+ List<List<Object>> list = functionEntryTable.selectAllColumnData(where);
+ if (list == null || list.isEmpty()) {
+ return null;
+ }
+
+ long address = (long) list.get(0).get(FunctionEntryDBTable.COLUMN.START_PC_ADDRESS.index);
+ long callerAddress = (long) list.get(0).get(
+ FunctionEntryDBTable.COLUMN.CALLER_PC_ADDRESS.index);
+ int epid = (int) list.get(0).get(FunctionEntryDBTable.COLUMN.PID.index);
+ int etid = (int) list.get(0).get(FunctionEntryDBTable.COLUMN.TID.index);
+ long etime = (long) list.get(0).get(FunctionEntryDBTable.COLUMN.START_TIME.index);
+ int efunctionID = (int) list.get(0).get(FunctionEntryDBTable.COLUMN.FUNCTION_ID.index);
+ int binaryID = (int) list.get(0).get(FunctionEntryDBTable.COLUMN.BINARY_ID.index);
+ String functionName = Global.getFunctionName(functionID);
+ String path = Global.getLibraryName(binaryID);
+ return new CallStackUnit(address, callerAddress, epid, etid, etime,
+ efunctionID, binaryID, functionName, path);
+ }
}
import org.tizen.dynamicanalyzer.model.TableInput;
import org.tizen.dynamicanalyzer.nl.TimelinePageLabels;
import org.tizen.dynamicanalyzer.project.BinaryInfo;
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
import org.tizen.dynamicanalyzer.ui.timeline.TimelinePage;
import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
import org.tizen.dynamicanalyzer.ui.widgets.table.DATableComposite;
int size = queriedData.size();
for (int i = 0; i < size; i++) {
List<Object> rowData = queriedData.get(i);
- List<String> text = new ArrayList<String>();
+ List<String> text = new ArrayList<>();
long time = (Long) rowData.get(FunctionEntryDBTable.COLUMN.START_TIME.index);
String strTime = Formatter.toTimeFormat(time);
tableInput.setText(text);
tableInput.setData(tableData);
input.add(tableInput);
-
- if (RangeDataManager.getInstance().isBeingAnalyzed()) {
- long analysisStartTime = RangeDataManager.getInstance().getAnalysisStartTime();
- long analysisEndTime = RangeDataManager.getInstance().getAnalysisEndTime();
- if (time >= analysisStartTime && time <= analysisEndTime) {
- tableInput.setInRange(true);
- }
- }
}
return input;
}
* <code>null</code> if there is no required data in the DB
*/
private List<List<Object>> getFunctionEntryData() {
- return CallTraceDataManager.getInstance().getFunctionEntryTable().selectAllObjectData();
+ return CallTraceDataManager.getInstance().getCallTrace();
}
/**
public class FunctionEntryDBTable extends DBTable {
public static final String TABLENAME="FUNCTION_ENTRY";
+ public static final int FUNCTION_RETURN_VALUE_LENGTH = 1024;
// for range analysis
- private static final String SELECT_COLUMN =
+ private static final String SELECT_ENTRY_COLUMN =
COLUMN.SEQUENCE_NUMBER.name + CommonConstants.COMMA +
COLUMN.PID.name + CommonConstants.COMMA +
COLUMN.TID.name + CommonConstants.COMMA +
COLUMN.START_TIME.name + CommonConstants.COMMA +
COLUMN.CALLER_PC_ADDRESS.name + CommonConstants.COMMA +
COLUMN.START_PC_ADDRESS.name;
- public static final String SELECT_QUERY =
- "select " + SELECT_COLUMN + " from " + TABLENAME +
- " where " + COLUMN.START_TIME.name + " between %s and %s";
+ private static final String SELECT_EXIT_COLUMN =
+ COLUMN.SEQUENCE_NUMBER.name + CommonConstants.COMMA +
+ COLUMN.PID.name + CommonConstants.COMMA +
+ COLUMN.TID.name + CommonConstants.COMMA +
+ COLUMN.END_TIME.name + CommonConstants.COMMA +
+ COLUMN.CALLER_PC_ADDRESS.name + CommonConstants.COMMA +
+ COLUMN.START_PC_ADDRESS.name;
+ public static final String SELECT_ENTRY_QUERY =
+ SELECT + SELECT_ENTRY_COLUMN + FROM + TABLENAME +
+ " where " + COLUMN.IS_ENTRY.name + " and " + COLUMN.START_TIME.name
+ + " between %s and %s";
+ public static final String SELECT_EXIT_QUERY =
+ SELECT + SELECT_EXIT_COLUMN + FROM + TABLENAME +
+ " where not " + COLUMN.IS_ENTRY.name + " and " + COLUMN.END_TIME.name
+ + " between %s and %s";
// to make callstack for sample, probe
public static final String USERCALLSTACK_QUERY =
- "select " + COLUMN.SEQUENCE_NUMBER.name + " from " + TABLENAME +
+ SELECT + COLUMN.SEQUENCE_NUMBER.name + FROM + TABLENAME +
" where " + COLUMN.START_TIME.name + " = (select max( " + COLUMN.START_TIME.name +
") from " + TABLENAME + " where " + COLUMN.START_TIME.name + " <= %s )";
// to get function entry time concerning sequence number
" where " + COLUMN.FUNCTION_ID.name + " = %s and " + COLUMN.SEQUENCE_NUMBER.name + " < %s";
public enum COLUMN {
- SEQUENCE_NUMBER(0, DBConstants.DBCOLUMN_SEQUENCE_NUMBER),
- PID(1, DBConstants.DBCOLUMN_PID),
- TID(2, DBConstants.DBCOLUMN_TID),
- FUNCTION_ID(3, DBConstants.DBCOLUMN_FUNCTION_ID),
- BINARY_ID(4, "BINARY_ID"),
- START_TIME(5, DBConstants.DBCOLUMN_START_TIME),
- CALLER_PC_ADDRESS(6, DBConstants.DBCOLUMN_CALLER_PC_ADDRESS),
- START_PC_ADDRESS(7, "START_PC_ADDRESS"),
- ARGUMENT(8, DBConstants.DBCOLUMN_ARGUMENT);
-
+ IS_ENTRY(0, DBConstants.DBCOLUMN_IS_ENTRY),
+ SEQUENCE_NUMBER(1, DBConstants.DBCOLUMN_SEQUENCE_NUMBER),
+ PID(2, DBConstants.DBCOLUMN_PID),
+ TID(3, DBConstants.DBCOLUMN_TID),
+ FUNCTION_ID(4, DBConstants.DBCOLUMN_FUNCTION_ID),
+ BINARY_ID(5, "BINARY_ID"),
+ START_TIME(6, DBConstants.DBCOLUMN_START_TIME),
+ END_TIME(7, DBConstants.DBCOLUMN_END_TIME),
+ CALLER_PC_ADDRESS(8, DBConstants.DBCOLUMN_CALLER_PC_ADDRESS),
+ START_PC_ADDRESS(9, DBConstants.DBCOLUMN_START_PC_ADDRESS),
+ ARGUMENT(10, DBConstants.DBCOLUMN_ARGUMENT),
+ RETURN_VALUE(11, DBConstants.DBCOLUMN_RETURN_VALUE);
+
public final int index;
public final String name;
}
public FunctionEntryDBTable() {
+ addColumn(new DBColumn(COLUMN.IS_ENTRY.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_BOOLEAN));
addColumn(new DBColumn(COLUMN.SEQUENCE_NUMBER.name, DBConstants.PRIMARY_KEY, DBConstants.DBTYPE_LONG));
addColumn(new DBColumn(COLUMN.PID.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
addColumn(new DBColumn(COLUMN.TID.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
- addColumn(new DBColumn(COLUMN.FUNCTION_ID.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
- addColumn(new DBColumn(COLUMN.BINARY_ID.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
- addColumn(new DBColumn(COLUMN.START_TIME.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
+ addColumn(new DBColumn(COLUMN.FUNCTION_ID.name, DBConstants.EMPTY, DBConstants.DBTYPE_INT4));
+ addColumn(new DBColumn(COLUMN.BINARY_ID.name, DBConstants.EMPTY, DBConstants.DBTYPE_INT4));
+ addColumn(new DBColumn(COLUMN.START_TIME.name, DBConstants.EMPTY, DBConstants.DBTYPE_LONG));
+ addColumn(new DBColumn(COLUMN.END_TIME.name, DBConstants.EMPTY, DBConstants.DBTYPE_LONG));
addColumn(new DBColumn(COLUMN.CALLER_PC_ADDRESS.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
addColumn(new DBColumn(COLUMN.START_PC_ADDRESS.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
- addColumn(new DBColumn(COLUMN.ARGUMENT.name, DBConstants.EMPTY,
- DBConstants.DBTYPE_VARCHAR, DALimit.FUNCTION_ARGUMENTS_VALUE_LENGTH));
- setIndexColumn(COLUMN.START_TIME.index);
+ addColumn(new DBColumn(COLUMN.ARGUMENT.name, DBConstants.EMPTY, DBConstants.DBTYPE_VARCHAR, DALimit.FUNCTION_ARGUMENTS_VALUE_LENGTH));
+ addColumn(new DBColumn(COLUMN.RETURN_VALUE.name, DBConstants.EMPTY, DBConstants.DBTYPE_VARCHAR, FUNCTION_RETURN_VALUE_LENGTH));
+ addIndex(COLUMN.START_TIME.index);
}
- public List<List<Object>> getFunctionEntryFromDB() {
- return selectAllColumnData(null);
- }
-
@Override
public boolean prepare(PreparedStatement prep, List<Object> rowData) {
boolean isPrepared = true;
isPrepared = false;
} else {
try {
+ prep.setBoolean(COLUMN.IS_ENTRY.index+1, (Boolean)(rowData.get(COLUMN.IS_ENTRY.index)));
prep.setLong(COLUMN.SEQUENCE_NUMBER.index + 1, (Long) (rowData.get(COLUMN.SEQUENCE_NUMBER.index)));
prep.setInt(COLUMN.PID.index + 1, (Integer) (rowData.get(COLUMN.PID.index)));
- prep.setInt(COLUMN.TID.index + 1, (Integer) (rowData.get(COLUMN.TID.index)));
+ prep.setInt(COLUMN.TID.index + 1, (Integer) (rowData.get(COLUMN.TID.index)));
prep.setInt(COLUMN.FUNCTION_ID.index + 1, (Integer) (rowData.get(COLUMN.FUNCTION_ID.index)));
prep.setInt(COLUMN.BINARY_ID.index + 1, (Integer) (rowData.get(COLUMN.BINARY_ID.index)));
prep.setLong(COLUMN.START_TIME.index + 1, (Long) (rowData.get(COLUMN.START_TIME.index)));
+ prep.setLong(COLUMN.END_TIME.index + 1, (Long) (rowData.get(COLUMN.END_TIME.index)));
prep.setLong(COLUMN.CALLER_PC_ADDRESS.index + 1, (Long) (rowData.get(COLUMN.CALLER_PC_ADDRESS.index)));
prep.setLong(COLUMN.START_PC_ADDRESS.index + 1, (Long) (rowData.get(COLUMN.START_PC_ADDRESS.index)));
-
String argumentStr = clipString((String) (rowData.get(COLUMN.ARGUMENT.index)),
DALimit.FUNCTION_ARGUMENTS_VALUE_LENGTH, rowData.get(COLUMN.SEQUENCE_NUMBER.index).toString());
prep.setString(COLUMN.ARGUMENT.index + 1, argumentStr);
-
+ String retStr = clipString((String) (rowData.get(COLUMN.RETURN_VALUE.index)),
+ FUNCTION_RETURN_VALUE_LENGTH, rowData.get(COLUMN.SEQUENCE_NUMBER.index).toString());
+ prep.setString(COLUMN.RETURN_VALUE.index + 1, retStr);
} catch (SQLException e) {
Logger.exception(e);
isPrepared = false;
public List<Object> extractDataFromResultSet(ResultSet rs) {
List<Object> row = new ArrayList<Object>();
try {
- row.add(Long.valueOf(rs.getLong(1)));
- row.add(Integer.valueOf(rs.getInt(2)));
- row.add(Integer.valueOf(rs.getInt(3)));
- row.add(Integer.valueOf(rs.getInt(4)));
- row.add(Integer.valueOf(rs.getInt(5)));
- row.add(Long.valueOf(rs.getLong(6)));
- row.add(Long.valueOf(rs.getLong(7)));
- row.add(Long.valueOf(rs.getLong(8)));
- row.add(rs.getString(9));
+ row.add(Boolean.valueOf(rs.getBoolean(1)));// IS_ENTRY
+ row.add(Long.valueOf(rs.getLong(2)));// SEQ
+ row.add(Integer.valueOf(rs.getInt(3)));// PID
+ row.add(Integer.valueOf(rs.getInt(4)));// TID
+ row.add(Integer.valueOf(rs.getInt(5)));// FUNCTION_ID
+ row.add(Integer.valueOf(rs.getInt(6)));// BINARY_ID
+ row.add(Long.valueOf(rs.getLong(7)));// START_TIME
+ row.add(Long.valueOf(rs.getLong(8)));// END_TIME
+ row.add(Long.valueOf(rs.getLong(9)));// CALLER_PC_ADDRESS
+ row.add(Long.valueOf(rs.getLong(10)));// START_PC_ADDRESS
+ row.add(rs.getString(11));// ARGUMENT
+ row.add(rs.getString(12));// RETURN_VALUE
} catch (SQLException e) {
Logger.exception(e);
return null;
--- /dev/null
+package org.tizen.dynamicanalyzer.ui.timeline.calltrace;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayDeque;
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.List;
+
+import org.tizen.dynamicanalyzer.common.Global;
+import org.tizen.dynamicanalyzer.database.DBTable;
+import org.tizen.dynamicanalyzer.database.SqlConnectionManager;
+import org.tizen.dynamicanalyzer.util.Logger;
+
+/**
+ * This class is launched when tracing process is stopped. It updates data in
+ * FUNCTION_ENTRY db table with corresponding exit time.
+ *
+ * @author p.privalov@partner.samsung.com
+ *
+ */
+public class FunctionEntryIndexer implements Runnable {
+
+ /**
+ * FUNCTION_ENTRY db table
+ */
+ FunctionEntryDBTable dbTable;
+
+ /**
+ * Map that is filled in analyzing process, that holds actual callstack for
+ * each pid in any moment.
+ */
+ HashMap<Integer, Deque<Long>> callstackByTid = new HashMap<>();
+
+ /**
+ * PID of process which entries and exits are indexed.
+ */
+ final int pid;
+
+ /**
+ * Statement used to execute batched updates.
+ */
+ Statement statement;
+
+ /**
+ * Time step in microseconds. Determine chunk of the trace to be updated.
+ * used to limit memory consumption.
+ */
+ static final long TIMESTEP = 200000;
+
+ /**
+ * Public constructor.
+ *
+ * @param dbTable {@link FunctionEntryDBTable} to work with table directly.
+ * @param pid PID of process which entries and exits are indexed.
+ *
+ * @throws SQLException if it is failed to connect to database.
+ */
+ public FunctionEntryIndexer(FunctionEntryDBTable dbTable, int pid) throws SQLException {
+ this.dbTable = dbTable;
+ this.pid = pid;
+ // conn will be closed with statement
+ Connection conn = SqlConnectionManager.getUpdateConnection(); //NOSONAR
+ conn.setAutoCommit(true);
+ statement = conn.createStatement();
+ }
+
+ @Override
+ public void run() {
+ Logger.debug("Indexing begins");
+ long totalTime = Global.getProject().getTotalStopTime();
+ FunctionProfilingDataUpdater functionProfilingDataUpdater = new FunctionProfilingDataUpdater(
+ dbTable, pid);
+ long time = 0;
+ while(time<totalTime){
+ updateFunctionEntryTable(time);
+ functionProfilingDataUpdater.updateProfilingInfo(time);
+ time += TIMESTEP;
+ }
+ functionProfilingDataUpdater.updateRates(totalTime);
+ try {
+ SqlConnectionManager.putUpdateConnection(statement.getConnection());
+ } catch (SQLException e) {
+ Logger.error("Failed to close database connection: " + e);
+ }
+ Logger.debug("Indexing finished");
+ }
+
+ /**
+ * Put record in callstack, corresponding to its tid. Performed for Entries.
+ *
+ * @param list list of objects, represents record from DB table
+ */
+ private void putEntryToMap(List<Object> list) {
+ int tid = (int) list.get(FunctionEntryDBTable.COLUMN.TID.index);
+ Deque<Long> callstack = callstackByTid.get(tid);
+ if (callstack == null) {
+ callstack = new ArrayDeque<>();
+ callstackByTid.put(tid, callstack);
+ }
+ callstack.push((Long) list.get(FunctionEntryDBTable.COLUMN.START_TIME.index));
+ }
+
+ /**
+ * Exception to indicate Entry without corresponding exit.
+ */
+ static final class ExitWithoutEntryException extends Exception {
+ private static final long serialVersionUID = -8929551670368096651L;
+ public ExitWithoutEntryException(String string) {
+ super(string);
+ }
+ }
+
+ /**
+ * Remove record from callstack and create update query to update
+ * corresponding record in DB table. Performed for Exits.
+ *
+ * @param list list of objects, represents record from DB table
+ * @return String that represents db update query, that should be added to
+ * batch.
+ * @throws ExitWithoutEntryException if failed to found corresponding ENTRY
+ */
+ private String updateEntryWithCorrespondingExitTimeAndRemoveFromMap(List<Object> list)
+ throws ExitWithoutEntryException {
+ int tid = (int) list.get(FunctionEntryDBTable.COLUMN.TID.index);
+ Deque<Long> callstack = callstackByTid.get(tid);
+ if (callstack == null || callstack.isEmpty()) {
+ throw new ExitWithoutEntryException(
+ "exit without entry " + list.get(FunctionEntryDBTable.COLUMN.END_TIME.index));
+ }
+ Long entryTime = callstack.pop();
+ return DBTable.UPDATE + dbTable.getTableName() + " set "
+ + FunctionEntryDBTable.COLUMN.END_TIME.name + " = "
+ + list.get(FunctionEntryDBTable.COLUMN.END_TIME.index) + DBTable.WHERE
+ + FunctionEntryDBTable.COLUMN.START_TIME.name + " = " + entryTime + DBTable.AND
+ + FunctionEntryDBTable.COLUMN.TID.name + "=" + tid;
+
+ }
+
+ /**
+ * Create callstack and update DB records for records with START_TIME value
+ * in interval from {@code time} to {@code time + TIMESTEP}.
+ *
+ * @param time specified time.
+ */
+ private void updateFunctionEntryTable(long time) {
+ String where = DBTable.WHERE + FunctionEntryDBTable.COLUMN.START_TIME.name + ">" + time
+ + DBTable.AND + FunctionEntryDBTable.COLUMN.START_TIME.name + "<="
+ + (time + TIMESTEP) + DBTable.ORDER_BY
+ + FunctionEntryDBTable.COLUMN.START_TIME.name;
+
+ for (List<Object> list : dbTable.selectAllColumnData(where)) {
+ if ((Boolean) (list.get(FunctionEntryDBTable.COLUMN.IS_ENTRY.index))) {
+ putEntryToMap(list);
+ } else {
+ try {
+ statement.addBatch(updateEntryWithCorrespondingExitTimeAndRemoveFromMap(list));
+ } catch (SQLException | ExitWithoutEntryException e) {
+ Logger.error("Failed to add update query:" + e);
+ }
+ }
+ }
+ try {
+ statement.executeBatch();
+ statement.clearBatch();
+ } catch (SQLException e) {
+ Logger.error("Failed to connect to database or to perform update: " + e);
+ }
+ }
+}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * WooJin Jung <woojin2.jung@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.timeline.calltrace;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.tizen.dynamicanalyzer.constant.CommonConstants;
-import org.tizen.dynamicanalyzer.database.DBColumn;
-import org.tizen.dynamicanalyzer.database.DBConstants;
-import org.tizen.dynamicanalyzer.database.DBTable;
-import org.tizen.dynamicanalyzer.util.Logger;
-
-public class FunctionExitDBTable extends DBTable {
- private static final String TABLENAME="FUNCTION_EXIT";
- public static final int FUNCTION_RETURN_VALUE_LENGTH = 1024;
- // for range analysis
- private static final String SELECT_COLUMN =
- COLUMN.EXIT_SEQUENCE_NUMBER.name + CommonConstants.COMMA +
- FunctionEntryDBTable.COLUMN.PID.name + CommonConstants.COMMA +
- FunctionEntryDBTable.COLUMN.TID.name + CommonConstants.COMMA +
- FunctionEntryDBTable.COLUMN.FUNCTION_ID.name + CommonConstants.COMMA +
- FunctionEntryDBTable.COLUMN.BINARY_ID.name + CommonConstants.COMMA +
- COLUMN.END_TIME.name + CommonConstants.COMMA +
- FunctionEntryDBTable.COLUMN.CALLER_PC_ADDRESS.name + CommonConstants.COMMA +
- FunctionEntryDBTable.COLUMN.START_PC_ADDRESS.name;
-
- public static final String SELECT_QUERY =
- "select " + SELECT_COLUMN + " from " + TABLENAME +
- CommonConstants.COMMA + FunctionEntryDBTable.TABLENAME + " where " +
- COLUMN.ENTRY_SEQUENCE_NUMBER.name + CommonConstants.EQUAL + FunctionEntryDBTable.COLUMN.SEQUENCE_NUMBER.name +
- " and " + COLUMN.END_TIME.name + " between %s and %s";
- // to make callstack for sample, probe
- public static final String USERCALLSTACK_QUERY =
- "select " + COLUMN.EXIT_SEQUENCE_NUMBER.name + " from " + TABLENAME +
- " where " + COLUMN.END_TIME.name + " = (select max( " + COLUMN.END_TIME.name +
- ") from " + TABLENAME + " where " + COLUMN.END_TIME.name + " <= %s )";
-
- public enum COLUMN {
- ENTRY_SEQUENCE_NUMBER(0, "ENTRY_SEQUENCE_NUMBER"),
- EXIT_SEQUENCE_NUMBER(1, "EXIT_SEQUENCE_NUMBER"),
- END_TIME(2, DBConstants.DBCOLUMN_END_TIME),
- RETURN_VALUE(3, DBConstants.DBCOLUMN_RETURN_VALUE);
-
- public final int index;
- public final String name;
-
- COLUMN(int index, String name) {
- this.index = index;
- this.name = name;
- }
- }
-
- @Override
- public String getTableName() {
- return TABLENAME;
- }
-
- public FunctionExitDBTable() {
- addColumn(new DBColumn(COLUMN.ENTRY_SEQUENCE_NUMBER.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
- addColumn(new DBColumn(COLUMN.EXIT_SEQUENCE_NUMBER.name, DBConstants.PRIMARY_KEY, DBConstants.DBTYPE_LONG));
- addColumn(new DBColumn(COLUMN.END_TIME.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
- addColumn(new DBColumn(COLUMN.RETURN_VALUE.name, DBConstants.EMPTY,
- DBConstants.DBTYPE_VARCHAR, FUNCTION_RETURN_VALUE_LENGTH));
- setIndexColumn(COLUMN.END_TIME.index);
- }
-
- public List<List<Object>> getFunctionExitFromDB() {
- return selectAllColumnData(null);
- }
-
- @Override
- public boolean prepare(PreparedStatement prep, List<Object> rowData) {
- boolean isPrepared = true;
-
- int columnsize = getColumnSize();
- if (columnsize != rowData.size()) {
- isPrepared = false;
- } else {
- try {
- prep.setLong(COLUMN.ENTRY_SEQUENCE_NUMBER.index + 1, (Long) (rowData.get(COLUMN.ENTRY_SEQUENCE_NUMBER.index)));
- prep.setLong(COLUMN.EXIT_SEQUENCE_NUMBER.index + 1, (Long) (rowData.get(COLUMN.EXIT_SEQUENCE_NUMBER.index)));
- prep.setLong(COLUMN.END_TIME.index + 1, (Long) (rowData.get(COLUMN.END_TIME.index)));
-
- String retStr = clipString((String) (rowData.get(COLUMN.RETURN_VALUE.index)),
- FUNCTION_RETURN_VALUE_LENGTH, rowData.get(COLUMN.EXIT_SEQUENCE_NUMBER.index).toString());
- prep.setString(COLUMN.RETURN_VALUE.index + 1, retStr);
- } catch (SQLException e) {
- Logger.exception(e);
- isPrepared = false;
- }
- }
-
- return isPrepared;
- }
-
- @Override
- public List<Object> extractDataFromResultSet(ResultSet rs) {
- List<Object> row = new ArrayList<Object>();
- try {
- row.add(Long.valueOf(rs.getLong(1)));
- row.add(Long.valueOf(rs.getLong(2)));
- row.add(Long.valueOf(rs.getLong(3)));
- row.add(rs.getString(4));
- } catch (SQLException e) {
- Logger.exception(e);
- return null;
- }
-
- return row;
- }
-}
--- /dev/null
+package org.tizen.dynamicanalyzer.ui.timeline.calltrace;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.tizen.dynamicanalyzer.database.DBTable;
+import org.tizen.dynamicanalyzer.ui.summary.profiling.FunctionSampleDBTable;
+import org.tizen.dynamicanalyzer.ui.summary.profiling.FunctionUsageProfiler;
+import org.tizen.dynamicanalyzer.ui.summary.profiling.ProfileDataMaker;
+
+/**
+ * This class contains methods used to update FunctionProfiling data when
+ * tracing process is stopped and callstack data has been updated. It calls
+ * {@code ProfileDataMaker.finalizeFunctionUsageProfileData()} and
+ * {@code ProfileDataMaker.finalizeFUPDataForCallTrace()} of the corresponding
+ * {@link ProfileDataMaker}
+ *
+ * @author p.privalov@partner.samsung.com
+ *
+ */
+public class FunctionProfilingDataUpdater {
+
+ /**
+ * FUNCTION_ENTRY db table, that was previously updated(partially) by
+ * {@link FunctionEntryIndexer}
+ */
+ FunctionEntryDBTable updatedFunctionEntryDBTable;
+ /**
+ * PID of process which entries and exits were indexed.
+ */
+ final int pid;
+
+ /**
+ * FUNCTION_SAMPLE db table
+ */
+ FunctionSampleDBTable sampleTable;
+ /**
+ * Data from FUNCTION_SAMPLE db table
+ */
+ List<List<Object>> samplingDBTableData = new ArrayList<>();
+ /**
+ * Lowest time in sampling db table
+ */
+ long lowestSamplingTime;
+
+ /**
+ * Corresponding to specified {@code pid} {@link ProfileDataMaker}.
+ */
+ ProfileDataMaker dataMaker;
+
+ /**
+ * Public constructor.
+ *
+ * @param dbTable FUNCTION_ENTRY db table, that was previously
+ * updated(partially) by {@link FunctionEntryIndexer}
+ * @param pid PID of process which entries and exits were indexed.
+ */
+ protected FunctionProfilingDataUpdater(FunctionEntryDBTable dbTable, int pid) {
+ this.updatedFunctionEntryDBTable = dbTable;
+ this.pid = pid;
+ sampleTable = FunctionUsageProfiler.getInstance().getFunctionSampleTable();
+ this.dataMaker = FunctionUsageProfiler.getInstance().getProfileDataMakerByPid(pid);
+ samplingDBTableData = sampleTable.selectAllColumnData(
+ DBTable.ORDER_BY + FunctionSampleDBTable.COLUMN.SAMPLE_TIME.name + DBTable.DESC);
+ updateLowestSamplingTime();
+ }
+
+ /**
+ * Updates function profiling table with data dependent from callstack. This
+ * method is used to count <b>inclusive</b> CPU time and rate for each
+ * function and elapsed time. It works over chunk of data base with records
+ * which START_TIME or SAMPLE_TIME value is in range from {@code startTime}
+ * to {@code startTime + FunctionEntryIndexer.TIMESTEP}.
+ *
+ * @param startTime specified start time.
+ */
+ void updateProfilingInfo(long startTime) {
+
+ String where = DBTable.WHERE + FunctionEntryDBTable.COLUMN.START_TIME.name + ">" + startTime
+ + DBTable.AND + FunctionEntryDBTable.COLUMN.START_TIME.name + "<="
+ + (startTime + FunctionEntryIndexer.TIMESTEP) + DBTable.ORDER_BY
+ + FunctionEntryDBTable.COLUMN.START_TIME.name;
+
+ String samplingWhere = DBTable.WHERE + FunctionSampleDBTable.COLUMN.PID.name + "=" + pid
+ + DBTable.AND + FunctionSampleDBTable.COLUMN.SAMPLE_TIME.name + ">" + startTime
+ + DBTable.AND + FunctionSampleDBTable.COLUMN.SAMPLE_TIME.name + "<="
+ + (startTime + FunctionEntryIndexer.TIMESTEP) + DBTable.ORDER_BY
+ + FunctionSampleDBTable.COLUMN.SAMPLE_TIME.name + DBTable.DESC;
+ samplingDBTableData.addAll(0, sampleTable.selectAllColumnData(samplingWhere));
+ updateLowestSamplingTime();
+ for (List<Object> list : updatedFunctionEntryDBTable.selectAllColumnData(where)) {
+ long time = (long) list.get(FunctionEntryDBTable.COLUMN.START_TIME.index);
+ updateRates(time);
+ dataMaker.finalizeFUPDataForCallTrace(list);
+ }
+ }
+
+ /**
+ * Perform {@code ProfileDataMaker.finalizeFunctionUsageProfileData()} for
+ * db records from FUNCTION_SAMPLE db table which SAMPLE_TIME is less then
+ * specified {@code time}. Processed records are removed from
+ * {@code samplingDBTableData} and {@code lowestSamplingTime} is updated. Thus
+ * the function processes sampling events on intervals from each next
+ * lowestSamplingTime till given {@code time}.
+ *
+ * @param time specified time
+ */
+ void updateRates(long time) {
+ while (!samplingDBTableData.isEmpty() && lowestSamplingTime < time) {
+ List<Object> dbrecord = samplingDBTableData.remove(samplingDBTableData.size() - 1);
+ dataMaker.finalizeFunctionUsageProfileData(dbrecord);
+ updateLowestSamplingTime();
+ }
+ }
+
+ /**
+ * Update {@code lowestSamplingTime} field with the lowest sampling time
+ * value among records of {@code samplingDBTableData}.
+ */
+ private void updateLowestSamplingTime() {
+ if (!samplingDBTableData.isEmpty())
+ lowestSamplingTime = (long) samplingDBTableData.get(samplingDBTableData.size() - 1)
+ .get(FunctionSampleDBTable.COLUMN.SAMPLE_TIME.index);
+ }
+}
import org.tizen.dynamicanalyzer.constant.CommonConstants;
import org.tizen.dynamicanalyzer.model.TableInput;
import org.tizen.dynamicanalyzer.nl.TimelinePageLabels;
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
import org.tizen.dynamicanalyzer.ui.widgets.table.DATableComposite;
import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat;
import org.tizen.dynamicanalyzer.utils.Formatter;
tableInput.setText(contentText);
tableInput.setData(tableData);
input.add(tableInput);
-
- if (RangeDataManager.getInstance().isBeingAnalyzed()) {
- long analysisStartTime = RangeDataManager.getInstance()
- .getAnalysisStartTime();
- long analysisEndTime = RangeDataManager.getInstance()
- .getAnalysisEndTime();
- if (time >= analysisStartTime && time <= analysisEndTime) {
- tableInput.setInRange(true);
- }
- }
}
return input;
}
addColumn(new DBColumn(COLUMN.FUNCTION_URL.name, DBConstants.NOT_NULL,
DBConstants.DBTYPE_VARCHAR, DALimit.FILEPATH_LENGTH));
addColumn(new DBColumn(COLUMN.START_TIME.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
- setIndexColumn(COLUMN.START_TIME.index);
+ addIndex(COLUMN.START_TIME.index);
}
@Override
addColumn(new DBColumn(COLUMN.ENTRY_SEQUENCE_NUMBER.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
addColumn(new DBColumn(COLUMN.EXIT_SEQUENCE_NUMBER.name, DBConstants.PRIMARY_KEY, DBConstants.DBTYPE_LONG));
addColumn(new DBColumn(COLUMN.END_TIME.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
- setIndexColumn(COLUMN.END_TIME.index);
+ addIndex(COLUMN.END_TIME.index);
}
@Override
import org.tizen.dynamicanalyzer.resources.ColorResources;
import org.tizen.dynamicanalyzer.resources.FontResources;
import org.tizen.dynamicanalyzer.resources.ImageResources;
+import org.tizen.dynamicanalyzer.ui.common.ChartPopupMenu;
import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseEventListener;
import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseTrackAdapter;
import org.tizen.dynamicanalyzer.ui.timeline.SystemDataDBTable;
processChartPlot.setShowAxis(true);
processChartPlot.setMarkers(chartBoard.getMarkers());
- DAPopupMenu processChartPopupMenu = new DAPopupMenu(processesChart);
- initPopupMenu(chartBoard, processChartPopupMenu);
+ DAPopupMenu processChartPopupMenu = new ChartPopupMenu(processesChart);
TimelineChartMouseEventListener timelineChartMouseEventListener = new TimelineChartMouseEventListener(
processChartPopupMenu, chartBoard.getTimeline(), pageID);
import org.tizen.dynamicanalyzer.resources.ColorResources;
import org.tizen.dynamicanalyzer.resources.FontResources;
import org.tizen.dynamicanalyzer.resources.ImageResources;
+import org.tizen.dynamicanalyzer.ui.common.ChartPopupMenu;
import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseEventListener;
import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseTrackAdapter;
import org.tizen.dynamicanalyzer.ui.timeline.SystemDataDBTable;
appUsageChartPlot.setShowAxis(true);
appUsageChartPlot.setMarkers(board.getMarkers());
- DAPopupMenu appUsageChartPopupMenu = new DAPopupMenu(appUsageChart);
- initPopupMenu(board, appUsageChartPopupMenu);
+ DAPopupMenu appUsageChartPopupMenu = new ChartPopupMenu(appUsageChart);
TimelineChartMouseEventListener timelineChartMouseEventListener = new TimelineChartMouseEventListener(
appUsageChartPopupMenu, board.getTimeline(), pageID);
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.NavigableMap;
import org.eclipse.swt.widgets.Display;
import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
import org.tizen.dynamicanalyzer.resources.ImageResources;
import org.tizen.dynamicanalyzer.swap.platform.BinarySettingData;
import org.tizen.dynamicanalyzer.swap.platform.BinarySettingManager;
+import org.tizen.dynamicanalyzer.ui.common.ChartPopupMenu;
import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseEventListener;
import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseTrackAdapter;
import org.tizen.dynamicanalyzer.ui.timeline.TargetProcessDBTable;
import org.tizen.dynamicanalyzer.widgets.chart.DAChartSeriesItem;
import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoard;
import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoardItem;
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenu;
public class HeapChart extends TimelineChart {
private List<Integer> librarySequenceList = new ArrayList<Integer>();
for (BinarySettingData binData : binDataList) {
String libraryPath = binData.getBinaryPath();
BinaryInfo binInfo = project.getDeviceStatusInfo().getBinaryInfo(libraryPath);
- LibraryObject libObj = pmap.getLibraryByBinaryID(binInfo.getID());
- if (null != libObj) {
+ NavigableMap<Long, LibraryObject> libObjMap = pmap.getLibraryMappingByBinaryID(binInfo.getID());
+ if (libObjMap != null && libObjMap.size() > 0) {
DAChartSeries libraryAllocSeries = new DAChartSeries(libraryPath,
DAChartSeries.SERIES_STYLE_AREA);
- chartSeriesMap.put(libObj.getBinaryID(), libraryAllocSeries);
+ chartSeriesMap.put(binInfo.getID(), libraryAllocSeries);
}
}
}
chart.getPlot().setAxisUnitType(parentPlot.getAxisUnitType());
chart.getPlot().setShowAxis(parentPlot.isShowAxis());
- popupMenu = new DAPopupMenu(chart);
- initPopupMenu(parent.getChartBoard(), popupMenu);
+ popupMenu = new ChartPopupMenu(chart);
TimelineChartMouseEventListener timelineChartMouseEventListener = new TimelineChartMouseEventListener(
popupMenu, parent.getChartBoard().getTimeline(), pageID);
import org.tizen.dynamicanalyzer.common.Global;
import org.tizen.dynamicanalyzer.nl.TimelineChartLabels;
-import org.tizen.dynamicanalyzer.project.Project;
import org.tizen.dynamicanalyzer.protocol.ProtocolConstants;
import org.tizen.dynamicanalyzer.resources.ColorResources;
import org.tizen.dynamicanalyzer.resources.ImageResources;
+import org.tizen.dynamicanalyzer.ui.common.ChartPopupMenu;
import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseEventListener;
import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseTrackAdapter;
import org.tizen.dynamicanalyzer.ui.memory.data.ProcessMemoryDBTable;
import org.tizen.dynamicanalyzer.widgets.chart.DAChartSeriesItem;
import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoard;
import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoardItem;
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenu;
public class ProcessMemoryChart extends TimelineChart {
private final int VSS = 0;
chart.getPlot().setAxisUnitType(parentPlot.getAxisUnitType());
chart.getPlot().setShowAxis(parentPlot.isShowAxis());
- popupMenu = new DAPopupMenu(chart);
- initPopupMenu(parent.getChartBoard(), popupMenu);
+ popupMenu = new ChartPopupMenu(chart);
TimelineChartMouseEventListener timelineChartMouseEventListener = new TimelineChartMouseEventListener(
popupMenu, parent.getChartBoard().getTimeline(), pageID);
import java.util.List;
import org.eclipse.swt.graphics.Image;
-import org.tizen.dynamicanalyzer.nl.TimelineChartLabels;
import org.tizen.dynamicanalyzer.resources.FontResources;
import org.tizen.dynamicanalyzer.resources.ImageResources;
-import org.tizen.dynamicanalyzer.ui.common.PopupRangeAnalysisMenuItemOnChartListener;
+import org.tizen.dynamicanalyzer.ui.common.ChartPopupMenu;
import org.tizen.dynamicanalyzer.widgets.chart.DAChart;
import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlot;
import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlot.AutoRangeType;
import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoard;
import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoardItem;
import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenu;
-import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuItem;
public abstract class TimelineChart {
protected DAChart chart;
chart = item.getChart();
setChartStyle();
- popupMenu = new DAPopupMenu(chart);
- initPopupMenu(chartBoard, popupMenu);
+ popupMenu = new ChartPopupMenu(chart);
+ popupMenu.setFont(FontResources.CONTEXT_MENU_ITEM_FONT);
return item;
}
- protected void initPopupMenu(DAChartBoard chartBoard, DAPopupMenu popupMenu) {
- popupMenu.setFont(FontResources.CONTEXT_MENU_ITEM_FONT);
- DAPopupMenuItem analysisItem = new DAPopupMenuItem(popupMenu);
- analysisItem.setText(TimelineChartLabels.RANGE_CONTEXT_ANALYSIS);
- analysisItem.addListener(new PopupRangeAnalysisMenuItemOnChartListener(analysisItem, chartBoard, chart));
- }
-
public void clear() {
List<DAChartSeries> seriesList = chart.getSeriesList();
for (DAChartSeries series : seriesList) {
import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseTrackAdapter;
import org.tizen.dynamicanalyzer.ui.common.UICommonConstants;
import org.tizen.dynamicanalyzer.ui.page.BaseView;
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
import org.tizen.dynamicanalyzer.ui.timeline.TimelinePage;
import org.tizen.dynamicanalyzer.ui.timeline.chart.TimelineChart;
import org.tizen.dynamicanalyzer.ui.timeline.logparser.LifecycleLogParser;
private final TimelineChartManager timelineChartManager = TimelineChartManager
.getInstance();
- private final RangeDataManager rangeDataManager = RangeDataManager
- .getInstance();
private final LifecycleLogParser lifecycleLogParser = LifecycleLogParser
.getInstance();
chartBoard.setTotalEndTime(time, false);
}
- if (RangeDataManager.getInstance().isBeingAnalyzed()) {
- ((DAChartPlotIntervalMarker) chartBoard.getMarkers().get(
- UICommonConstants.RANGE_ANALYSIS_MARKER_INDEX))
- .setInterval(rangeDataManager.getAnalysisStartTime()
- / TimelineConstants.MEGA_DOUBLE,
- rangeDataManager.getAnalysisEndTime()
- / TimelineConstants.MEGA_DOUBLE);
- } else {
- ((DAChartPlotIntervalMarker) chartBoard.getMarkers().get(
- UICommonConstants.RANGE_ANALYSIS_MARKER_INDEX))
- .setInterval(-1, -1);
- }
-
- ((DAChartPlotIntervalMarker) chartBoard.getMarkers().get(
- UICommonConstants.RANGE_MARKER_INDEX)).setInterval(
- rangeDataManager.getMarkerStartTime()
- / TimelineConstants.MEGA_DOUBLE,
- rangeDataManager.getMarkerEndTime()
- / TimelineConstants.MEGA_DOUBLE);
-
timelineChartManager.addNewCustomChart();
}
selectionMarker.setBackgroundColor(ColorResources.SELECTION_RANGE);
selectionMarker.setAlpha((int) (255 * 0.25));
board.addIntervalMarker(selectionMarker);
-
- // range analysis marker
- DAChartPlotIntervalMarker rangeAnalyzeMarker = new DAChartPlotIntervalMarker(
- -1, -1, DAChartPlotIntervalMarker.INTERVAL_MARKER_STYLE_AREA);
- rangeAnalyzeMarker.setBackgroundColor(ColorResources.YELLOW);
- rangeAnalyzeMarker.setAlpha((int) (255 * 0.25));
- board.addIntervalMarker(rangeAnalyzeMarker);
-
- // range marker
- DAChartPlotIntervalMarker rangeMarker = new DAChartPlotIntervalMarker(
- -1, -1, DAChartPlotIntervalMarker.INTERVAL_MARKER_STYLE_LINE);
- rangeMarker.setForegroundColor(ColorResources.SELECTION_LINE);
- rangeMarker.setAlpha((int) (255 * 0.25));
- board.addIntervalMarker(rangeMarker);
- }
-
- public void setRangeMarker(double starttime, double endtime) {
- ((DAChartPlotIntervalMarker) chartBoard.getMarkers().get(
- UICommonConstants.RANGE_MARKER_INDEX)).setInterval(
- starttime, endtime);
}
public DAChartBoard getChartBoard(){
import org.tizen.dynamicanalyzer.ui.info.process.ProcessView;
import org.tizen.dynamicanalyzer.ui.info.screenshot.ImageViewer;
import org.tizen.dynamicanalyzer.ui.info.screenshot.ScreenshotView;
-import org.tizen.dynamicanalyzer.ui.summary.failed.FailedApiListView;
-import org.tizen.dynamicanalyzer.ui.summary.profiling.FunctionUsageProfilingView;
-import org.tizen.dynamicanalyzer.ui.summary.warning.WarningDataView;
import org.tizen.dynamicanalyzer.ui.timeline.calltrace.CallTraceView;
import org.tizen.dynamicanalyzer.ui.timeline.dlog.DlogView;
import org.tizen.dynamicanalyzer.widgets.da.view.DATabComposite;
public class TimelineTableView extends DATabComposite {
- public static final String tabID = TimelineTableView.class.getName();
public static final String screenshotViewID = ScreenshotView.class.getName();
public static final String callstackViewID = CallstackView.class.getName();
public static final String imageViewerID = ImageViewer.class.getName();
+ DesignConstants.TAB_BUTTON_HEIGHT;
{
- ID = tabID;
+ ID = TimelineTableView.class.getName();
}
public TimelineTableView(Composite parent, int style) {
import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;\r
import org.tizen.dynamicanalyzer.ui.widgets.table.DATableComposite;\r
import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat;\r
-import org.tizen.dynamicanalyzer.ui.widgets.table.DefaultTableComparator;\r
import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;\r
import org.tizen.dynamicanalyzer.utils.Formatter;\r
import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotIntervalMarker;\r
setColumns(columnNames);\r
setColumnSize(columnSizes);\r
setColumnVisibility(columnVisibility);\r
- \r
- setComparator(new DefaultTableComparator()); \r
\r
- \r
initDlogListeners();\r
}\r
\r
import org.eclipse.swt.widgets.Shell;
import org.tizen.dynamicanalyzer.appearance.DesignConstants;
import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
-import org.tizen.dynamicanalyzer.common.AnalyzerManager;
import org.tizen.dynamicanalyzer.model.TableInput;
import org.tizen.dynamicanalyzer.nl.TimelinePageLabels;
import org.tizen.dynamicanalyzer.nl.WidgetLabels;
import org.tizen.dynamicanalyzer.resources.ColorResources;
import org.tizen.dynamicanalyzer.resources.FontResources;
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
-import org.tizen.dynamicanalyzer.ui.timeline.TimelinePage;
-import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineChartView;
-import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
import org.tizen.dynamicanalyzer.ui.widgets.table.DATableComposite;
import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat;
import org.tizen.dynamicanalyzer.ui.widgets.table.DATableHeaderRenderer;
private DACustomButtonClickEventListener okButtonListener = new DACustomButtonClickEventListener() {
@Override
public void handleClickEvent(DACustomButton button) {
- RangeDataManager rangeDataManager = RangeDataManager.getInstance();
- TimelineChartView tview = (TimelineChartView) AnalyzerManager
- .getCurrentPage().getView(TimelinePage.timelineViewID);
-
- Double startTime = (Double) uiEventListTable.getTable().getData(
- KEY_START_TIME);
- Double endTime = (Double) uiEventListTable.getTable().getData(
- KEY_END_TIME);
-
- if (startTime == null || endTime == null) {
- return;
- }
-
- if (startTime != -1 && endTime != -1 && startTime > endTime) {
- double temp = startTime;
- startTime = endTime;
- endTime = temp;
- }
-
- if (startTime != -1) {
- rangeDataManager
- .setMarkerStartTime((long) (startTime * TimelineConstants.MEGA_DOUBLE));
- double revisedEndTime = rangeDataManager.getMarkerEndTime();
-
- tview.setRangeMarker(startTime, revisedEndTime
- / TimelineConstants.MEGA_DOUBLE);
- }
-
- if (endTime != -1) {
- rangeDataManager
- .setMarkerEndTime((long) (endTime * TimelineConstants.MEGA_DOUBLE));
-
- double revisedStartTime = rangeDataManager.getMarkerStartTime();
-
- tview.setRangeMarker(revisedStartTime
- / TimelineConstants.MEGA_DOUBLE, endTime);
- }
-
shell.dispose();
}
};
import org.tizen.dynamicanalyzer.shortcut.ShortCutManager;
import org.tizen.dynamicanalyzer.ui.common.explorer.DeviceExplorerDialog;
import org.tizen.dynamicanalyzer.ui.page.BaseView;
+import org.tizen.dynamicanalyzer.ui.timeline.TimelinePage;
import org.tizen.dynamicanalyzer.ui.toolbar.opentrace.OpenTraceDialog;
import org.tizen.dynamicanalyzer.ui.toolbar.setting.PreferencesDialog;
import org.tizen.dynamicanalyzer.ui.widgets.SearchDialog;
import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener;
import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonRenderer;
import org.tizen.dynamicanalyzer.widgets.button.toggle.DACustomToggleButton;
+import org.tizen.dynamicanalyzer.widgets.chart.DAChart;
+import org.tizen.dynamicanalyzer.widgets.chart.DAChartRenderer;
+import org.tizen.dynamicanalyzer.widgets.chart.DANotificationOnChartRenderer;
import org.tizen.dynamicanalyzer.widgets.combo.DACustomCombo;
import org.tizen.dynamicanalyzer.widgets.combo.DACustomComboSelectionListener;
import org.tizen.dynamicanalyzer.widgets.da.base.ProgressDialog;
if (DAState.isStartable()) {
MarkerManager.INSTANCE.clearMarkerList();
- CommandAction.startTrace(false);
+ CommandAction.startTrace();
} else if (DAState.isRunning()) {
CommandAction.stopTrace(new DAResult(ErrorCode.SUCCESS), false);
} else {
}
}
+ /**
+ * Check if connected device type corresponds to target. If check failed
+ * then lock application combo and start button.
+ *
+ * @return true if check passed, false otherwise.
+ */
+ public boolean checkThatConnectedCorrespondsToTarget() {
+ TimelinePage tP = (TimelinePage) AnalyzerUtil.getTabPage(TimelinePage.pageID);
+ DAChart chart = tP.getTimelineChartView().getChartBoard().getItemList().get(0).getChart();
+ if(SettingDataManager.INSTANCE.checkConnectedTargetType()){
+ chart.setChartRenderer(new DAChartRenderer());
+ return true;
+ }
+ startButton.setButtonEnabled(false);
+ appCombo.setEnabled(false);
+ chart.setChartRenderer(new DANotificationOnChartRenderer(
+ UserErrorWarningLabels.ERR_GUIDE_SELECT_ANOTHER_DEVICE));
+ return false;
+ }
+
private void setAppComboState(boolean enabled) {
- if (enabled) {
+ if (enabled && checkThatConnectedCorrespondsToTarget()) {
DeviceInfo device = Global.getCurrentDeviceInfo();
if (device != null) {
appCombo.setEnabled(true);
}
private void setStartButtonState(boolean enabled) {
- if (enabled) {
+ if (enabled && checkThatConnectedCorrespondsToTarget()) {
DeviceInfo device = Global.getCurrentDeviceInfo();
if (device != null) {
String selDev = deviceCombo.getText();
import org.eclipse.swt.widgets.Shell;
import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
import org.tizen.dynamicanalyzer.common.AnalyzerManager;
+import org.tizen.dynamicanalyzer.common.DAState;
import org.tizen.dynamicanalyzer.common.Global;
import org.tizen.dynamicanalyzer.common.path.PathManager;
import org.tizen.dynamicanalyzer.handlers.CommonAction;
}
public void openTraceComplete() {
+ DAState.changeCurrentState(DAState.DONE);
+
if (null != dialog) {
// waitingThreads();
Display.getDefault().syncExec(new Runnable() {
import org.tizen.dynamicanalyzer.resources.FontResources;
import org.tizen.dynamicanalyzer.setting.SettingDataManager;
import org.tizen.dynamicanalyzer.shortcut.ShortCutManager;
+import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
import org.tizen.dynamicanalyzer.widgets.da.base.DAMessageBox;
public class FlatFeatureDialog extends DAMessageBox {
private FlatFeatureDialogSelectedFeaturePage selectedFeaturePage = null;
private Composite buttonContentsComp = null;
- final public int WINDOW_WIDTH = 1010;
+ final public int WINDOW_WIDTH = 1030;
final public int WINDOW_HEIGHT = 620;
final public int TITLE_BAR = 30;
final public int FEATURE_HEIGHT = 489 + TITLE_HEIGHT;
final public int SELECTED_LEFT = TARGET_COMP_WIDTH + FEATURE_WIDTH;
- final public int SELECTED_WIDTH = 285; // SelectedList have to draw line
+ final public int SELECTED_WIDTH = 305; // SelectedList have to draw line
final public int SELECTED_HEIGHT = 489 + TITLE_HEIGHT;
public FlatFeatureDialog(Shell parentShell) {
private Listener okListener = new Listener() {
@Override
public void handleEvent(Event event) {
- // TODO Auto-generated method stub
+ Toolbar.INSTANCE.checkThatConnectedCorrespondsToTarget();
doApply();
doRun();
import org.tizen.dynamicanalyzer.setting.SettingDataManager;
import org.tizen.dynamicanalyzer.setting.TargetData;
import org.tizen.dynamicanalyzer.util.Logger;
+import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
import org.tizen.dynamicanalyzer.widgets.button.toggle.DACustomToggleButton;
import org.tizen.dynamicanalyzer.widgets.da.view.DABaseComposite;
private DACustomToggleButton delToggle = null;
private Cursor daCursor = null;
- private int TITLE_FONT_SIZE = 0;
- private int ICON_SIZE = 0;
-
- private int WIDTH = 0;
- private int HEIGHT = 0;
- private int LINE = 0;
- private int ITEM_LEFT = 0;
- private int TITLE_HEIGHT = 0;
- private int TITLE_TOP = 0;
- private int BODY_HEIGHT = 0;
- private int BODY_TOP = 0;
- private int BODY_TOP_MARGIN = 0;
- private int ITEM_DIST = 0;
- private int ICON_TITLE_DIST = 0;
- private int ITEM_TITLE_TOP = 0;
- private int ITEM_TITLE_LEFT = 0;
- private int ITEM_TITLE_WIDTH = 0;
- private int CANCEL_SIZE = 0;
- private int CANCEL_TOP = 0;
- private int CANCEL_RIGHT = 0;
- private int NOITEM_UPPER_MARGIN = 0;
- private int NOITEM_LEFT_MARGIN = 0;
- private int VSCROLL_MARGIN = -3;
+ /**
+ * Size constants
+ */
+ // TODO: Add handling at MAC
+ private static int TITLE_FONT_SIZE = 10 + 6;
+ private static int ICON_SIZE = 40;
+ private static int ITEM_LEFT = 20;
+ private static int BODY_TOP_MARGIN = 30;
+ private static int ITEM_DIST = 23;
+ private static int ICON_TITLE_DIST = 15;
+ private static int ITEM_TITLE_TOP = (ICON_SIZE - TITLE_FONT_SIZE) / 2;
+ private static int ITEM_TITLE_LEFT = ITEM_LEFT + ICON_SIZE + ICON_TITLE_DIST;
+ private static int ITEM_TITLE_WIDTH = 145;
+ private static int BUTTON_SIZE = 15;
+ private static int BUTTON_TOP = (ICON_SIZE - BUTTON_SIZE) / 2;
+ private static int BUTTON_RIGHT = -30;
+ private static int BUTTON_SPACING = -10;
+ private static int VSCROLL_MARGIN = -3;
+
+ /**
+ * Calculated sizes
+ */
+ private int width = 0;
+ private int height = 0;
+ private int line = 0;
+ private int titleHeight = 0;
+ private int titleTop = 0;
+ private int bodyHeight = 0;
+ private int bodyTop = 0;
+ private int noItemUpperMargin = 0;
+ private int noItemTopMargin = 0;
public FlatFeatureDialogSelectedFeaturePage(Composite parent, FlatFeatureDialog parentObject, int style) {
super(parent, style);
selectedComp = parent;
featureDialog = parentObject;
- // TODO: Add handling at MAC
- TITLE_FONT_SIZE = 10 + 6;
- ICON_SIZE = 40;
- CANCEL_SIZE = 15;
-
- WIDTH = featureDialog.SELECTED_WIDTH;
- HEIGHT = featureDialog.SELECTED_HEIGHT;
- LINE = featureDialog.LINE;
- ITEM_LEFT = 20;
- TITLE_HEIGHT = featureDialog.TITLE_HEIGHT;
- TITLE_TOP = (TITLE_HEIGHT - TITLE_FONT_SIZE)/2;
- BODY_TOP = TITLE_HEIGHT + LINE + 1;
- BODY_HEIGHT = HEIGHT - TITLE_HEIGHT - LINE;
- BODY_TOP_MARGIN = 30;
- ITEM_DIST = 23;
- ICON_TITLE_DIST = 15;
- ITEM_TITLE_TOP = (ICON_SIZE - TITLE_FONT_SIZE)/2;
- ITEM_TITLE_LEFT = ITEM_LEFT + ICON_SIZE + ICON_TITLE_DIST;
- ITEM_TITLE_WIDTH = 158;
- CANCEL_TOP = (ICON_SIZE - CANCEL_SIZE)/2;
- CANCEL_RIGHT = -30;
- NOITEM_UPPER_MARGIN = (BODY_HEIGHT-TITLE_FONT_SIZE)/2;
- NOITEM_LEFT_MARGIN = 15; // TODO: Replace '15' with string length
+ width = featureDialog.SELECTED_WIDTH;
+ height = featureDialog.SELECTED_HEIGHT;
+ line = featureDialog.LINE;
+ titleHeight = featureDialog.TITLE_HEIGHT;
+ titleTop = (titleHeight - TITLE_FONT_SIZE) / 2;
+ bodyTop = titleHeight + line + 1;
+ bodyHeight = height - titleHeight - line;
+ noItemUpperMargin = (bodyHeight - TITLE_FONT_SIZE) / 2;
+ noItemTopMargin = 15; // TODO: Replace '15' with string length
createSelectedFeatureComposite();
}
}
private Listener cursorListener = new Listener() {
+ private Cursor arrowCursor = new Cursor(getShell().getDisplay(), SWT.CURSOR_ARROW);
+ private Cursor handCursor = new Cursor(getShell().getDisplay(), SWT.CURSOR_HAND);
+
public void handleEvent(Event event) {
if (event.type == SWT.MouseEnter || event.type == SWT.MouseExit) {
- DACustomToggleButton toggleButton = (DACustomToggleButton) event.widget;
+ DACustomButton toggleButton = (DACustomButton) event.widget;
toggleButton.setFocus();
if (event.type == SWT.MouseEnter)
- daCursor = new Cursor(getShell().getDisplay(), SWT.CURSOR_HAND);
+ daCursor = handCursor;
else if (event.type == SWT.MouseExit)
- daCursor = new Cursor(getShell().getDisplay(), SWT.CURSOR_ARROW);
+ daCursor = arrowCursor;
else
return;
}
};
- private Listener clickListener = new Listener() {
- public void handleEvent(Event event) {
- DACustomToggleButton toggleButton = (DACustomToggleButton) event.widget;
- TargetData target = SettingDataManager.INSTANCE.getTarget(null);
- target.removeSelectedFlatFeature(toggleButton.getText());
- featureDialog.getFeatureListPage().featureToggleUnselect(toggleButton.getText());
- createSelectedFeatureComposite();
- }
+ private Listener deleteClickListener = (Event event) -> {
+ DACustomToggleButton toggleButton = (DACustomToggleButton) event.widget;
+ TargetData target = SettingDataManager.INSTANCE.getTarget(null);
+ target.removeSelectedFlatFeature(toggleButton.getText());
+ featureDialog.getFeatureListPage().featureToggleUnselect(toggleButton.getText());
+ createSelectedFeatureComposite();
+ };
+
+ /**
+ * Opens preferences dialog for selected configurable feature.
+ */
+ private Listener configClickListener = (Event event) -> {
+ DACustomButton toggleButton = (DACustomButton) event.widget;
+ FlatFeature selectedFeature = FlatFeature.getFlatFeature((String) (toggleButton.getData()));
+ new PreferencesDialog(getShell()).open(selectedFeature);
};
/**
// label
selectedFeatureLabel = new Label(selectedComp, SWT.TRANSPARENT);
FormData data = new FormData();
- data.top = new FormAttachment(0, TITLE_TOP);
+ data.top = new FormAttachment(0, titleTop);
data.left = new FormAttachment(0, ITEM_LEFT);
- data.width = WIDTH - ITEM_LEFT;
- data.height = TITLE_HEIGHT - TITLE_TOP - TITLE_FONT_SIZE+6;
+ data.width = width - ITEM_LEFT;
+ data.height = titleHeight - titleTop - TITLE_FONT_SIZE + 6;
selectedFeatureLabel.setLayoutData(data);
selectedFeatureLabel.setText(ConfigureLabels.SETTING_DIALOG_SELECTED_TITLE);
selectedFeatureLabel.setBackground(ColorResources.FEATURE_TITLE_BACKGROUND);
selectedComp.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
e.gc.setForeground(ColorResources.FEATURE_LINE);
- e.gc.drawLine(0, TITLE_HEIGHT + LINE, WIDTH, TITLE_HEIGHT + LINE);
+ e.gc.drawLine(0, titleHeight + line, width, titleHeight + line);
}
});
selecetedScrolledComp = new ScrolledComposite(selectedComp, SWT.V_SCROLL);
selecetedScrolledComp.setLayout(new FormLayout());
data = new FormData();
- data.top = new FormAttachment(0, BODY_TOP);
+ data.top = new FormAttachment(0, bodyTop);
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(100, VSCROLL_MARGIN);
data.bottom = new FormAttachment(100, 0);
selecetedScrolledComp.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
e.gc.setForeground(ColorResources.FEATURE_FEATURELISTCOMP_LINE);
- e.gc.drawLine(0, 0, WIDTH, 0);
+ e.gc.drawLine(0, 0, width, 0);
}
});
// label : No Item Selected
noItemLabel = new Label(selectedInputComp, SWT.TRANSPARENT);
data = new FormData();
- data.top = new FormAttachment(0, NOITEM_UPPER_MARGIN);
- data.left = new FormAttachment(0, NOITEM_LEFT_MARGIN);
- data.width = WIDTH - NOITEM_LEFT_MARGIN;
- data.height = TITLE_HEIGHT;
+ data.top = new FormAttachment(0, noItemUpperMargin);
+ data.left = new FormAttachment(0, noItemTopMargin);
+ data.width = width - noItemTopMargin;
+ data.height = titleHeight;
noItemLabel.setLayoutData(data);
noItemLabel.setText(ConfigureLabels.SETTING_DIALOG_NO_ITEM_SELECTED);
noItemLabel.setBackground(ColorResources.FEATURE_FEATURELISTCOMP_NORMAL_BACKGROUND);
delToggle = createToggleButton(selectedInputComp,
ImageResources.DELETE,
delImagePoint, feature.getName(), null,
- CANCEL_SIZE, CANCEL_SIZE,
- topPosition + CANCEL_TOP,
- WIDTH - CANCEL_SIZE + CANCEL_RIGHT);
- delToggle.addListener(SWT.MouseUp, clickListener);
+ BUTTON_SIZE, BUTTON_SIZE,
+ topPosition + BUTTON_TOP,
+ width - BUTTON_SIZE + BUTTON_RIGHT);
+ delToggle.addListener(SWT.MouseUp, deleteClickListener);
delToggle.addListener(SWT.MouseEnter, cursorListener);
delToggle.addListener(SWT.MouseExit, cursorListener);
+ if (feature.isConfigurable()) {
+ // configuration button
+ DACustomButton confToggle = new DACustomButton(selectedInputComp,
+ ImageResources.CONFIG_FEATURE_NORMAL,
+ ImageResources.CONFIG_FEATURE_PUSH,
+ ImageResources.CONFIG_FEATURE_HOVER,
+ ImageResources.CONFIG_FEATURE_NORMAL);
+ confToggle.setBackground(ColorResources.FEATURE_FEATURELISTCOMP_NORMAL_BACKGROUND);
+ confToggle.setButtonImagePoint(new Point(0, 0));
+ confToggle.setData(feature.getName());
+
+ data = new FormData(BUTTON_SIZE, BUTTON_SIZE);
+ data.right = new FormAttachment(delToggle, BUTTON_SPACING);
+ data.top = new FormAttachment(0, topPosition + BUTTON_TOP);
+ confToggle.setLayoutData(data);
+
+ confToggle.addListener(SWT.MouseUp, configClickListener);
+ confToggle.addListener(SWT.MouseEnter, cursorListener);
+ confToggle.addListener(SWT.MouseExit, cursorListener);
+ }
+
topPosition += (ICON_SIZE + ITEM_DIST);
}
*/
package org.tizen.dynamicanalyzer.ui.toolbar.setting;
+import java.util.List;
import java.util.Map;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.tizen.dynamicanalyzer.common.DAState;
+import org.tizen.dynamicanalyzer.communicator.DeviceInfo;
+import org.tizen.dynamicanalyzer.communicator.DeviceManager;
+import org.tizen.dynamicanalyzer.communicator.IDeviceStatusListener;
import org.tizen.dynamicanalyzer.nl.ConfigureLabels;
import org.tizen.dynamicanalyzer.resources.ColorResources;
import org.tizen.dynamicanalyzer.resources.FontResources;
import org.tizen.dynamicanalyzer.resources.ImageResources;
import org.tizen.dynamicanalyzer.setting.SettingDataManager;
import org.tizen.dynamicanalyzer.setting.TargetData;
+import org.tizen.dynamicanalyzer.util.Logger;
+import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
import org.tizen.dynamicanalyzer.widgets.button.toggle.DACustomFeatureToggleButton;
import org.tizen.dynamicanalyzer.widgets.button.toggle.DACustomFeatureToggleButtonGroup;
import org.tizen.dynamicanalyzer.widgets.da.view.DABaseComposite;
+import org.tizen.dynamicanalyzer.widgets.tooltip.DACustomTooltip;
public class FlatFeatureDialogTargetPage extends DABaseComposite {
+ private static final int TOOLTIP_HORIZONTAL_OFFSET = 20;
+ private static final int CONNECTION_IMAGE_TOP_MARGIN = 18;
+ private static final int CONNECTION_IMAGE_LEFT_MARGIN = 145;
+
private enum ProfileDisplayInfo {
PROFILE_NAME_MOBILE(0, ConfigureLabels.TARGET_NAME_FLAT_MOBILE_FOCUS,
ImageResources.TARGET_NAME_FLAT_MOBILE_SEL,
private Image focusImage = null;
private Image normalImage = null;
private Image overImage = null;
+ private boolean connected = false;
public static int imageWidth = 40;
-
+
private ProfileDisplayInfo(int id, String displayName, Image focusImage, Image normalImage, Image overImage) {
this.displayName = displayName;
this.focusImage = focusImage;
}
public static Image getImage(String displayName) {
- ProfileDisplayInfo[] profiles = ProfileDisplayInfo.values();
- for (ProfileDisplayInfo profile : profiles) {
- if (profile.displayName.equals(displayName)) {
- return profile.normalImage;
- }
- }
- return null;
+ ProfileDisplayInfo profile = getProfileByName(displayName);
+ return profile != null ? profile.normalImage : null;
}
+
public static Image getFocusImage(String displayName) {
- ProfileDisplayInfo[] profiles = ProfileDisplayInfo.values();
- for (ProfileDisplayInfo profile : profiles) {
+ ProfileDisplayInfo profile = getProfileByName(displayName);
+ return profile != null ? profile.focusImage : null;
+ }
+
+ public static Image getOverImage(String displayName) {
+ ProfileDisplayInfo profile = getProfileByName(displayName);
+ return profile != null ? profile.overImage : null;
+ }
+
+ /**
+ * Gets connection status of a profile with specified name.
+ *
+ * @param displayName displayed name of the profile
+ * @return if profile is found then its connection status is returned
+ * ({@code true} if connected), if it is not found then
+ * {@code false} is returned
+ */
+ public static boolean getConnected(String displayName) {
+ ProfileDisplayInfo profile = getProfileByName(displayName);
+ return profile != null && profile.connected;
+ }
+
+ /**
+ * Gets {@link ProfileDisplayInfo} value by its name.
+ *
+ * @param displayName displayed name of the profile
+ * @return found {@link ProfileDisplayInfo} or {@code null} if there is
+ * no such profile
+ */
+ private static ProfileDisplayInfo getProfileByName(String displayName) {
+ for (ProfileDisplayInfo profile : ProfileDisplayInfo.values()) {
if (profile.displayName.equals(displayName)) {
- return profile.focusImage;
+ return profile;
}
}
return null;
}
- public static Image getOverImage(String displayName) {
- ProfileDisplayInfo[] profiles = ProfileDisplayInfo.values();
- for (ProfileDisplayInfo profile : profiles) {
- if (profile.displayName.equals(displayName)) {
- return profile.overImage;
+
+ /**
+ * Updates 'connected' field of the profile with specified name.
+ *
+ * @param displayName name of the profile which connection status should
+ * be updated
+ */
+ public static void updateConnectionStatus(String displayName) {
+ ProfileDisplayInfo profile = getProfileByName(displayName);
+ if (profile == null)
+ return;
+
+ profile.updateConnectionStatus();
+ }
+
+ /**
+ * Updates 'connected' field of the profile based on the list of
+ * connected devices.
+ */
+ private void updateConnectionStatus() {
+ List<DeviceInfo> devices = DeviceManager.getDevices();
+
+ connected = false;
+ for (DeviceInfo devInfo : devices) {
+ if (devInfo.getPlatformName().equals(displayName)) {
+ connected = true;
+ break;
}
}
- return null;
+
+ Logger.debug(displayName + (connected ? " connected" : " disconnected"));
+ }
+
+ static {
+ // initialize 'connected' field for all profiles
+ for (ProfileDisplayInfo profile : ProfileDisplayInfo.values())
+ profile.updateConnectionStatus();
}
};
private int TARGET_LIST_ITEM_LABEL_MARGIN = 0;
private int TARGET_LIST_ITEM_TITLE_MARGIN = 0;
+ /**
+ * Tooltip displaying focused target connection status
+ */
+ DACustomTooltip tooltip = new DACustomTooltip() {
+
+ @Override
+ public void setTooltipMessage() {
+ tooltipMessage.clear();
+ }
+
+ @Override
+ public void setTooltipMessage(String text) {
+ tooltipMessage.clear();
+ tooltipMessage.add(text);
+ }
+ };
+
public FlatFeatureDialogTargetPage(Composite parent, FlatFeatureDialog parentObject, int style) {
super(parent, style);
this.setLayout(new FormLayout());
}
};
+ /**
+ * Draws connection status icon.
+ */
+ private PaintListener paintListener = (PaintEvent e) -> {
+ DACustomFeatureToggleButton toggleButton = (DACustomFeatureToggleButton) e.widget;
+ Image icon = ProfileDisplayInfo.getConnected(toggleButton.getText())
+ ? ImageResources.TARGET_CONNECTED
+ : ImageResources.TARGET_DISCONNECTED;
+
+ e.gc.drawImage(icon, CONNECTION_IMAGE_LEFT_MARGIN, CONNECTION_IMAGE_TOP_MARGIN);
+ };
+
private DACustomFeatureToggleButton createToggleButton(Composite composit,
Image image, Image pushImage, Image hoverImage, Point imagePoint,
String title, Point fontPoint,
data.height = height;
toggle.setLayoutData(data);
+ toggle.addListener(SWT.MouseHover, (Event event) -> {
+ openTooltip(toggle);
+ });
+ toggle.addListener(SWT.MouseExit, (Event event) -> {
+ tooltip.close();
+ });
+
+ // update profiles' connection statuses and redraw button
+ // once some device got connected/disconnected
+ IDeviceStatusListener deviceListener = (connected, device) -> {
+ Display.getDefault().asyncExec(() -> {
+ /**
+ * XXX: Due to a very bad design of sdblib we cannot get
+ * platform name of the device after it got disconnected, so we
+ * have to ignore passed arguments and check each platform on
+ * connection. For the sake of code simplicity do this for both
+ * when 'connected' is true and false.
+ */
+ ProfileDisplayInfo.updateConnectionStatus(toggle.getText());
+ toggle.redraw();
+ toggle.update();
+
+ updateToggleData(toggle);
+
+ // update tooltip if it is shown for this toggle (cursor is
+ // hovering over this toggle)
+ Point cursor = composit.toControl(Display.getCurrent().getCursorLocation());
+ if (toggle.getBounds().contains(cursor))
+ openTooltip(toggle);
+ });
+ };
+
+ DeviceManager.addDeviceStatusListener(deviceListener);
+
+ // when toggle is disposed, remove listener
+ toggle.addDisposeListener((DisposeEvent e) -> {
+ DeviceManager.removeDeviceStatusListener(deviceListener);
+ });
+
+ updateToggleData(toggle);
+
return toggle;
}
toggle.addListener(SWT.MouseUp, clickListener);
toggle.addListener(SWT.MouseEnter, cursorListener);
toggle.addListener(SWT.MouseExit, cursorListener);
+ toggle.addPaintListener(paintListener);
// set next position
topPosition += (TARGET_LIST_ITEM_HEIGHT + TARGET_LIST_ITEM_MARGIN);
targetComp.setEnabled(false);
}
}
+
+ /**
+ * Updates data of the {@code toggle} depending on current connection status
+ * of the corresponding target.
+ *
+ * @param toggle toggle to update
+ */
+ private void updateToggleData(DACustomButton toggle) {
+ boolean targetConnected = ProfileDisplayInfo.getConnected(toggle.getText());
+ toggle.setData(targetConnected
+ ? ConfigureLabels.TARGET_CONNECTED
+ : ConfigureLabels.TARGET_DISCONNECTED);
+ }
+
+ /**
+ * Opens tooltip for the specified {@code toggle}.
+ *
+ * @param toggle toggle for which tooltip should be shown
+ */
+ private void openTooltip(DACustomButton toggle) {
+ Point p = Display.getCurrent().getCursorLocation();
+ tooltip.open(toggle.getParent().getShell());
+ tooltip.setTooltipMessage((String) toggle.getData());
+ tooltip.setTooltipLocation(p, 0, TOOLTIP_HORIZONTAL_OFFSET);
+ }
}
package org.tizen.dynamicanalyzer.ui.toolbar.setting;
+import java.util.ArrayList;
+import java.util.EnumMap;
+import java.util.List;
+
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.DisposeEvent;
import org.tizen.dynamicanalyzer.shortcut.ShortCutManager;
import org.tizen.dynamicanalyzer.ui.memory.MemoryPage;
import org.tizen.dynamicanalyzer.ui.page.MenuBar;
+import org.tizen.dynamicanalyzer.util.Logger;
import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener;
private Composite memoryProfilingView = null;
+ private List<Composite> configs = new ArrayList<Composite>();
+ private EnumMap<FlatFeature, Composite> featureConfigs = new EnumMap<FlatFeature, Composite>(
+ FlatFeature.class);
+ private FlatFeature selectedFeature = null;
+
public PreferencesDialog(Shell parentShell) {
super(parentShell);
}
+ /**
+ * Opens Preferences dialog with only selected {@code feature} configuration
+ * controls visible.
+ *
+ * @param feature feature to configure
+ * @return result of Preferences dialog processing
+ */
+ public Object open(FlatFeature feature) {
+ selectedFeature = feature;
+ return open();
+ }
+
protected boolean run() {
if (opened) {
return false;
drawButtonCom();
- setSelectedOptions();
+ setOptions(false);
// Disable configuration preferences if DAState is RUNNING
if (DAState.isRunning())
disableConfiguration();
+ // If some feature is selected for this dialog then dispose all
+ // unrelated configuration options
+ if (selectedFeature != null) {
+ Composite selectedConfig = featureConfigs.get(selectedFeature);
+ for (Composite config : configs)
+ if (config != selectedConfig)
+ config.dispose();
+
+ scrolledComp.layout(true);
+ }
+
opened = true;
ShortCutManager.getInstance().setEnabled(!opened);
shell.open();
generalBaseView.setBackground(ColorResources.DIALOG_CONTENT_BACKGROUND);
generalBaseView.setLayout(parentLayout);
+ configs.add(generalBaseView);
+
// Add 'General' button
DACustomButton generalExtend = createFoldingButton(generalBaseView, PreferencesDialogLabels.GENERAL);
screenshotBaseView.setBackground(ColorResources.DIALOG_CONTENT_BACKGROUND);
screenshotBaseView.setLayout(parentLayout);
+ configs.add(screenshotBaseView);
+ featureConfigs.put(FlatFeature.SCREENSHOT, screenshotBaseView);
+
// Add 'Screenshot feature' button
DACustomButton screenshotExtend = createFoldingButton(screenshotBaseView,
PreferencesDialogLabels.SCREENSHOT);
memoryProfilingBaseView.setBackground(ColorResources.DIALOG_CONTENT_BACKGROUND);
memoryProfilingBaseView.setLayout(parentLayout);
+ configs.add(memoryProfilingBaseView);
+ featureConfigs.put(FlatFeature.MEMORY_ALLOC, memoryProfilingBaseView);
+
// Add 'Memory Profiling' button
DACustomButton memoryProfilingExtend = createFoldingButton(memoryProfilingBaseView,
PreferencesDialogLabels.HEAP_ALLOCATION);
@Override
public void widgetSelected(SelectionEvent arg0) {
- resetToDefault();
+ setOptions(true);
scrolledComp.setFocus();
}
});
}
- private void setSelectedOptions() {
- int value = SettingDataManager.INSTANCE.getPreferenceValue(FlatPreferences.SOURCE_VIEW);
- if (value == 1) {
- sourceviewtoggle.setToggled(true);
- MenuBar.getInstance().setSourceView(true);
- } else {
- sourceviewtoggle.setToggled(false);
- MenuBar.getInstance().setSourceView(false);
+ /**
+ * Reflect current or default settings on the controls.
+ *
+ * @param reset whether settings should be reset to default values
+ */
+ private void setOptions(boolean reset) {
+ // 'preferences' mode
+ if (selectedFeature == null) {
+ setGeneralOptions(reset);
+ setScreenshotOptions(reset);
+ setHeapAllocationOptions(reset);
+ return;
}
- value = SettingDataManager.INSTANCE.getPreferenceValue(FlatPreferences.SYSTEM_SAMPLING_RATE);
+ // 'feature configuration' mode
+ switch (selectedFeature) {
+ case SCREENSHOT:
+ setScreenshotOptions(reset);
+ break;
+ case MEMORY_ALLOC:
+ setHeapAllocationOptions(reset);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * Reflect current of default settings on the controls in the 'General'
+ * section.
+ *
+ * @param reset whether settings should be reset to default values
+ */
+ private void setGeneralOptions(boolean reset) {
+ int value = SettingDataManager.INSTANCE.getPreferenceValue(FlatPreferences.SOURCE_VIEW,
+ reset);
+ sourceviewtoggle.setToggled(value == 1);
+ MenuBar.getInstance().setSourceView(value == 1);
+
+ value = SettingDataManager.INSTANCE.getPreferenceValue(FlatPreferences.SYSTEM_SAMPLING_RATE,
+ reset);
systemRateCombo.setText(String.valueOf(value));
- value = SettingDataManager.INSTANCE.getPreferenceValue(FlatPreferences.FUNCTION_SAMPLING_RATE);
+ value = SettingDataManager.INSTANCE
+ .getPreferenceValue(FlatPreferences.FUNCTION_SAMPLING_RATE, reset);
functionRateCombo.setText(String.valueOf(value));
+ }
+ /**
+ * Reflect current of default settings on the controls in the 'Screenshot
+ * feature' section.
+ *
+ * @param reset whether settings should be reset to default values
+ */
+ private void setScreenshotOptions(boolean reset) {
if (screenshotFeatureEnabled) {
- value = SettingDataManager.INSTANCE.getPreferenceValue(FlatPreferences.SCREENSHOT_PERIODICALLY);
+ int value = SettingDataManager.INSTANCE
+ .getPreferenceValue(FlatPreferences.SCREENSHOT_PERIODICALLY, reset);
boolean enabled = (value != 0);
periodicallyToggle.setToggled(enabled);
if (enabled)
screenshotRateCombo.setText(String.valueOf(value));
- enabled = SettingDataManager.INSTANCE.isPreferenceSelected(FlatPreferences.SCREENSHOT_ON_SCENE_TRANSITION);
+ enabled = SettingDataManager.INSTANCE
+ .isPreferenceSelected(FlatPreferences.SCREENSHOT_ON_SCENE_TRANSITION, reset);
onSceneTransitionToggle.setToggled(enabled);
onSceneTransitionToggle.setButtonEnabled(true);
} else {
onSceneTransitionToggle.setToggled(false);
onSceneTransitionToggle.setButtonEnabled(false);
}
+ }
+ /**
+ * Reflect current of default settings on the controls in the 'Heap
+ * Allocation feature' section.
+ *
+ * @param reset whether settings should be reset to default values
+ */
+ private void setHeapAllocationOptions(boolean reset) {
if (leakSanitizerEnabled) {
- leakSanitizerToggle.setToggled(SettingDataManager.INSTANCE
- .isPreferenceSelected(FlatPreferences.LEAK_SANITIZER));
+ boolean enabled = SettingDataManager.INSTANCE
+ .isPreferenceSelected(FlatPreferences.LEAK_SANITIZER, reset);
+ leakSanitizerToggle.setToggled(enabled);
leakSanitizerToggle.setButtonEnabled(true);
} else {
leakSanitizerToggle.setToggled(false);
}
}
- private void resetToDefault() {
- int value = FlatPreferences.SOURCE_VIEW.getDefaultValue();
- if (value == 1) {
- sourceviewtoggle.setToggled(true);
- } else {
- sourceviewtoggle.setToggled(false);
- }
-
- value = FlatPreferences.SYSTEM_SAMPLING_RATE.getDefaultValue();
- systemRateCombo.setText(String.valueOf(value));
-
- value = FlatPreferences.FUNCTION_SAMPLING_RATE.getDefaultValue();
- functionRateCombo.setText(String.valueOf(value));
-
- if (screenshotFeatureEnabled) {
- value = FlatPreferences.SCREENSHOT_PERIODICALLY.getDefaultValue();
-
- boolean periodically = (value != 0);
-
- periodicallyToggle.setToggled(periodically);
- screenshotRateCombo.setEnabled(periodically);
- if (periodically)
- screenshotRateCombo.setText(String.valueOf(value));
-
- value = FlatPreferences.SCREENSHOT_ON_SCENE_TRANSITION.getDefaultValue();
- onSceneTransitionToggle.setToggled(value != 0);
- }
-
- if (leakSanitizerEnabled) {
- value = FlatPreferences.LEAK_SANITIZER.getDefaultValue();
- leakSanitizerToggle.setToggled(value == 1);
- }
- }
-
private DACustomExtendButton createFoldingButton(Composite parent, String text) {
DACustomExtendButton foldingbutton = new DACustomExtendButton(parent,
ImageResources.DROP_ARROW_DOWN_NOR, ImageResources.DROP_ARROW_DOWN_NOR,
return label;
}
+ /**
+ * Saves all configured options.
+ */
private void applyPreferenceData() {
+ // 'preferences' mode
+ if (selectedFeature == null) {
+ saveGeneralOptions();
+ saveScreenshotOptions();
+ saveHeapAllocationOptions();
+ return;
+ }
+
+ // 'feature configuration' mode
+ switch (selectedFeature) {
+ case SCREENSHOT:
+ saveScreenshotOptions();
+ break;
+ case MEMORY_ALLOC:
+ saveHeapAllocationOptions();
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * Saves options from the 'General' section.
+ */
+ private void saveGeneralOptions() {
boolean sourceViewEnabled = sourceviewtoggle.isToggled();
MenuBar.getInstance().setSourceView(sourceViewEnabled);
- SettingDataManager.INSTANCE.setPreferenceValue(FlatPreferences.SOURCE_VIEW, sourceViewEnabled ? 1 : 0);
+ SettingDataManager.INSTANCE.setPreferenceValue(FlatPreferences.SOURCE_VIEW,
+ sourceViewEnabled ? 1 : 0);
String ratestring = systemRateCombo.getText();
try {
int rate = Integer.parseInt(ratestring);
SettingDataManager.INSTANCE.setPreferenceValue(FlatPreferences.SYSTEM_SAMPLING_RATE, rate);
- } catch (Exception ex) {
-
- return;
+ } catch (NumberFormatException ex) {
+ Logger.warning("Failed to save system sampling rate: " + ex.getLocalizedMessage());
}
ratestring = functionRateCombo.getText();
try {
int rate = Integer.parseInt(ratestring);
SettingDataManager.INSTANCE.setPreferenceValue(FlatPreferences.FUNCTION_SAMPLING_RATE, rate);
- } catch (Exception ex) {
-
- return;
+ } catch (NumberFormatException ex) {
+ Logger.warning("Failed to save function sampling rate: " + ex.getLocalizedMessage());
}
-
- int rate = 0;
+ }
+
+ /**
+ * Saves options from the 'Screenshot feature' section.
+ */
+ private void saveScreenshotOptions() {
if (periodicallyToggle.isToggled()) {
- ratestring = screenshotRateCombo.getText();
+ String ratestring = screenshotRateCombo.getText();
try {
- rate = Integer.parseInt(ratestring);
- } catch (Exception ex) {
- return;
+ int rate = Integer.parseInt(ratestring);
+ SettingDataManager.INSTANCE
+ .setPreferenceValue(FlatPreferences.SCREENSHOT_PERIODICALLY, rate);
+ } catch (NumberFormatException ex) {
+ Logger.warning("Failed to save screenshots rate: " + ex.getLocalizedMessage());
}
+ } else {
+ SettingDataManager.INSTANCE.setPreferenceValue(FlatPreferences.SCREENSHOT_PERIODICALLY, 0);
}
- SettingDataManager.INSTANCE.setPreferenceValue(FlatPreferences.SCREENSHOT_PERIODICALLY, rate);
SettingDataManager.INSTANCE.setPreferenceSelected(
FlatPreferences.SCREENSHOT_ON_SCENE_TRANSITION,
onSceneTransitionToggle.isToggled());
+ }
+ /**
+ * Saves options from the 'Heap Allocation feature' section.
+ */
+ private void saveHeapAllocationOptions() {
SettingDataManager.INSTANCE.setPreferenceSelected(FlatPreferences.LEAK_SANITIZER,
leakSanitizerToggle.isToggled());
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Heeyoung Hwang <heeyoung1008.hwang@samsung.com>
- * Hyunjong Park <phjwithyou.park@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.userinterface;
-
-import java.util.HashMap;
-import java.util.List;
-
-import org.tizen.dynamicanalyzer.constant.CommonConstants;
-import org.tizen.dynamicanalyzer.protocol.ProtocolConstants;
-import org.tizen.dynamicanalyzer.swap.logparser.LogPackage;
-import org.tizen.dynamicanalyzer.swap.logparser.Logs;
-import org.tizen.dynamicanalyzer.swap.logparser.PageDataManager;
-import org.tizen.dynamicanalyzer.swap.model.data.ControlData;
-import org.tizen.dynamicanalyzer.swap.model.data.LogData;
-import org.tizen.dynamicanalyzer.swap.model.data.SceneData;
-import org.tizen.dynamicanalyzer.ui.userinterface.control.UIControlListDataChecker;
-import org.tizen.dynamicanalyzer.ui.userinterface.profiling.UIFunctionProfilingDataChecker;
-import org.tizen.dynamicanalyzer.ui.userinterface.scene.UISceneDataChecker;
-
-public class UIDataManager extends PageDataManager {
- private static UIDataManager instance = new UIDataManager();
-
- private UIControlListDataChecker controlListDataChecker = null;
- private UISceneDataChecker sceneTransformDataChecker = null;
- private UIFunctionProfilingDataChecker functionProfilingDataChecker = null;
- private HashMap<String, Long> findScreenshotViewHashMap = new HashMap<String, Long>();
-
- private String strTableSeleteClassName = null;
-
- public static UIDataManager getInstance() {
- return instance;
- }
-
- private UIDataManager() {
- }
-
- public void clear() {
- controlListDataChecker = null;
- sceneTransformDataChecker = null;
- functionProfilingDataChecker = null;
- strTableSeleteClassName = null;
- findScreenshotViewHashMap.clear();
- }
-
- public UIControlListDataChecker getControlDataChecker() {
- if (null == controlListDataChecker) {
- controlListDataChecker = new UIControlListDataChecker();
- }
- return controlListDataChecker;
- }
-
- public UISceneDataChecker getSceneTransformDataChecker() {
- if (null == sceneTransformDataChecker) {
- sceneTransformDataChecker = new UISceneDataChecker();
- }
- return sceneTransformDataChecker;
- }
-
- public UIFunctionProfilingDataChecker getfunctionProfilingDataChecker() {
- if (null == functionProfilingDataChecker) {
- functionProfilingDataChecker = new UIFunctionProfilingDataChecker();
- }
- return functionProfilingDataChecker;
- }
-
- public void setTableSeleteClassName(String data) {
- strTableSeleteClassName = data;
- }
-
- public String getTableSeleteClassName() {
- if (strTableSeleteClassName == null) {
- strTableSeleteClassName = CommonConstants.ZERO;
- }
- return strTableSeleteClassName;
- }
-
- public HashMap<String, Long> getFindScreenshotViewHashMap() {
- return findScreenshotViewHashMap;
- }
-
- @Override
- protected void makeData(LogPackage pack) {
- Logs logs = pack.getLogs(ProtocolConstants.MSG_PROBE_UICONTROL);
- if (null != logs && logs.getRawLogs() != null && logs.getRawLogs().size() != 0) {
- List<LogData> inputs = logs.getLogs();
- int size = inputs.size();
- for (int i = 0; i < size; i++) {
- getControlDataChecker().parserLog((ControlData) inputs.get(i));
- }
- }
-
- logs = pack.getLogs(ProtocolConstants.MSG_PROBE_SCENE);
- if (null != logs && logs.getRawLogs() != null && logs.getRawLogs().size() != 0) {
- List<LogData> inputs = logs.getLogs();
- int size = inputs.size();
- for (int i = 0; i < size; i++) {
- getSceneTransformDataChecker().parserLog((SceneData) inputs.get(i));
- }
- }
-
- UIDataManager.getInstance().getfunctionProfilingDataChecker().updateUIApiTreeSet();
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Heeyoung Hwang <heeyoung1008.hwang@samsung.com>
- * Hyunjong Park <phjwithyou.park@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.userinterface;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
-import org.tizen.dynamicanalyzer.resources.ColorResources;
-import org.tizen.dynamicanalyzer.shortcut.ShortCutManager;
-import org.tizen.dynamicanalyzer.swap.logparser.DataManagerRegistry;
-import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineTableView;
-import org.tizen.dynamicanalyzer.ui.userinterface.control.UIControlListView;
-import org.tizen.dynamicanalyzer.ui.userinterface.profiling.UIFunctionProfilingView;
-import org.tizen.dynamicanalyzer.ui.userinterface.scene.UISceneListView;
-import org.tizen.dynamicanalyzer.widgets.da.view.DAContainerComposite;
-
-public class UIPage extends DAContainerComposite {
- public static final String pageID = UIPage.class.getName();
- public static final String controlListViewID = UIControlListView.class.getName();
- public static final String sceneListViewID = UISceneListView.class.getName();
- public static final String profilingViewID = UIFunctionProfilingView.class.getName();
-
- SashForm baseForm;
- SashForm upperForm;
- SashForm bottomForm;
-
- public UIPage(Composite parent, int style) {
- super(parent, style);
- setTitle(AnalyzerLabels.COOLBAR_AREA_UI);
- this.setBackground(ColorResources.CONFIGURATION_TABLE_COVER_BACKGROUND_COLOR);
- this.setData(DAContainerComposite.KEY_TOOLTIP, ShortCutManager.COOLBAR_AREA_UI_TOOLTIP);
- this.setLayout(new FillLayout());
- baseForm = new SashForm(this, SWT.VERTICAL);
- baseForm.setLayout(new FillLayout());
- baseForm.setForeground(ColorResources.TAB_SELECTED_COLOR_START);
- ((FillLayout) getLayout()).marginHeight = 15;
- ((FillLayout) getLayout()).marginWidth = 5;
-
- upperForm = new SashForm(baseForm, SWT.HORIZONTAL);
-
- UIControlListView topLeftFirst = new UIControlListView(upperForm, SWT.NONE);
- addView(topLeftFirst);
-
- UISceneListView topLeftSencond = new UISceneListView(upperForm, SWT.NONE);
- addView(topLeftSencond);
-
- upperForm.setWeights(new int[] { 40, 60});
-
- bottomForm = new SashForm(baseForm, SWT.HORIZONTAL);
- UIFunctionProfilingView bottomLeftFirst = new UIFunctionProfilingView(bottomForm, SWT.NONE);
- addView(bottomLeftFirst);
-
- TimelineTableView tabView = new TimelineTableView(upperForm, SWT.NONE);
-// tabView.setObservingViews(TimelineTableView.screenshotViewID, new String[] {
-// UIPage.sceneListViewID, UIPage.controlListViewID });
-// tabView.setObservingViews(TimelineTableView.callstackViewID, new String[] {
-// UIPage.sceneListViewID, UIPage.controlListViewID });
- addView(tabView);
-
- bottomForm.setWeights(new int[] { 77, 23 });
-
- baseForm.setSashWidth(SASH_WIDTH);
- upperForm.setSashWidth(SASH_WIDTH);
- bottomForm.setSashWidth(SASH_WIDTH);
-
- DataManagerRegistry.registerPageDataManager(UIDataManager.getInstance());
- }
-
- @Override
- protected void onResized(int width, int height) {
- int wrate = (int) (TimelineTableView.DEFAULT_WIDTH * 100 / width);
- int hrate = (int) (TimelineTableView.DEFAULT_TABLE_VIEW_HEIGHT * 100 / height);
- wrate = (wrate > 100) ? 100 : wrate;
- hrate = (hrate > 100) ? 100 : hrate;
-
- if ((wrate > (100 - 37)) || hrate > 100) {
- return;
- }
-
- upperForm.setWeights(new int[] { 100 - wrate, wrate });
- baseForm.setWeights(new int[] { 100 - hrate, hrate });
- }
-
- @Override
- public void clear() {
- super.clear();
- UIDataManager.getInstance().clear();
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Heeyoung Hwang <heeyoung1008.hwang@samsung.com>
- * Hyunjong Park <phjwithyou.park@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.userinterface.control;
-
-import org.tizen.dynamicanalyzer.constant.CommonConstants;
-import org.tizen.dynamicanalyzer.swap.model.data.LogData;
-
-public class UIControlListData {
- public static final int USER_INTERFACE_CONTROL_LIST_CONTROL = 0;
- public static final int USER_INTERFACE_CONTROL_LIST_CLASS_NAME = 1;
- public static final int USER_INTERFACE_CONTROL_LIST_INITIALIZER_TIME = 2;
- public static final int USER_INTERFACE_CONTROL_LIST_TERMININATE_TIME = 3;
- public static final int USER_INTERFACE_CONTROL_LIST_PROCESS_ID = 4;
- public static final int USER_INTERFACE_CONTROL_LIST_DATABLEDATAFORMAT_CLASSNAME_INDEX = 20;
-
- private String strCalssKeyName = null;
- private long strSequence = -1;
- private int pID = -1;
- private long strTime = -1;
- private String strAPIName = null;
- private String strInitializeTime = null;
- private String strTerminateTime = null;
-
- private String strParentName = null;
- private String strParentClassName = null;
- private long strParentPointer = -1;
- private String strChildName = null;
- private String strChildClassName = null;
- private long strChildPointer = -1;
- private String strControlType = null;
-
- private LogData data;
-
- public UIControlListData(LogData input) {
- data = input;
- }
-
- public LogData getData() {
- return data;
- }
-
- public void setSequence(long seq) {
- strSequence = seq;
- }
-
- public long getSequence() {
- return strSequence;
- }
-
- public void setCalssKeyName(String data) {
- strCalssKeyName = data;
- }
-
- public String getCalssKeyName() {
- if (strCalssKeyName == null) {
- strCalssKeyName = CommonConstants.EMPTY;
- }
- return strCalssKeyName;
- }
-
- public void setTime(long time) {
- strTime = time;
- }
-
- public long getTime() {
- return strTime;
- }
-
- public void setControlType(String data) {
- strControlType = data;
- }
-
- public String getControlType() {
- if (strControlType == null) {
- strControlType = CommonConstants.DASH;
- }
- return strControlType;
- }
-
- public void setAPIName(String data) {
- strAPIName = data;
- }
-
- public String getAPIName() {
- if (strAPIName == null) {
- strAPIName = CommonConstants.EMPTY;
- }
- return strAPIName;
- }
-
- public void setInitializeTime(String data) {
- strInitializeTime = data;
- }
-
- public String getInitializeTime() {
- if (strInitializeTime == null) {
- strInitializeTime = CommonConstants.EMPTY;
- }
- return strInitializeTime;
- }
-
- public void setTerminateTime(String data) {
- strTerminateTime = data;
- }
-
- public String getTerminateTime() {
- if (strTerminateTime == null) {
- strTerminateTime = CommonConstants.EMPTY;
- }
- return strTerminateTime;
- }
-
- public void setParentPointer(long data) {
- strParentPointer = data;
- }
-
- public long getParentPointer() {
- return strParentPointer;
- }
-
- public void setParentName(String data) {
- strParentName = data;
- }
-
- public String getParentName() {
- if (strParentName == null) {
- strParentName = CommonConstants.EMPTY;
- }
- return strParentName;
- }
-
- public void setParentClassName(String data) {
- strParentClassName = data;
- }
-
- public String getParentClassName() {
- if (strParentClassName == null) {
- strParentClassName = CommonConstants.EMPTY;
- }
- return strParentClassName;
- }
-
- public void setChildName(String data) {
- strChildName = data;
- }
-
- public String getChildName() {
- if (strChildName == null) {
- strChildName = CommonConstants.EMPTY;
- }
- return strChildName;
- }
-
- public void setChildClassName(String data) {
- strChildClassName = data;
- }
-
- public String getChildClassName() {
- if (strChildClassName == null) {
- strChildClassName = CommonConstants.EMPTY;
- }
- return strChildClassName;
- }
-
- public void setChildPointer(long data) {
- strChildPointer = data;
- }
-
- public long getChildPointer() {
- return strChildPointer;
- }
-
- public String getPID() {
- return Integer.toString(pID);
- }
-
- public void setPID(int pID) {
- this.pID = pID;
- }
-
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Heeyoung Hwang <heeyoung1008.hwang@samsung.com>
- * Hyunjong Park <phjwithyou.park@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-package org.tizen.dynamicanalyzer.ui.userinterface.control;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.tizen.dynamicanalyzer.common.SymbolManager;
-import org.tizen.dynamicanalyzer.constant.CommonConstants;
-import org.tizen.dynamicanalyzer.swap.model.data.ControlData;
-import org.tizen.dynamicanalyzer.ui.userinterface.UIDataManager;
-import org.tizen.dynamicanalyzer.ui.userinterface.profiling.UIFunctionProfilingData;
-import org.tizen.dynamicanalyzer.util.Logger;
-
-public class UIControlListDataChecker {
- private List<UIControlListData> controlList = null;
- private List<String> removeCallControlList = null;
- private long preSeq = -1;
-
- public void parserLog(ControlData input) {
- String stClassName = getClassName(input.getApiName()).trim();
- if (stClassName.contains("AddFrame") || stClassName.contains("AddControl")) {//$NON-NLS-1$ //$NON-NLS-2$
- if (isExistData(input.getParentClassName(),
- input.getChildClassName()) == true) {
- return;
- }
- if (preSeq == input.getSeq()) {
- return;
- }
-
- addSortData(makeUIControlListData(input));
- setUIControlListTimeData();
-
- preSeq = input.getSeq();
-
- } else if (stClassName.trim().contains("RemoveControl")) {//$NON-NLS-1$
- getRemoveCallControlList().add(input.getChildClassName());
- } else if (stClassName.trim().contains("SetName")//$NON-NLS-1$
- || stClassName.contains("RemoveFrame")//$NON-NLS-1$
- || stClassName.contains("RemoveAllControl")) {//$NON-NLS-1$
- return;
- } else {
- Logger.debug("wrong type log : " + stClassName.trim());
- }
- }
-
- private UIControlListData makeUIControlListData(ControlData input) {
- UIControlListData controlData = new UIControlListData(input);
-
- controlData.setSequence(input.getSeq());
-
- controlData.setTime(input.getTime());
-
- controlData.setAPIName(getClassName(input.getApiName()).trim());
-
- controlData.setInitializeTime(CommonConstants.DASH);
- controlData.setTerminateTime(CommonConstants.DASH);
-
- controlData.setParentName(input.getParentName());
-
- controlData.setParentClassName(input.getParentClassName());
- controlData.setParentPointer(input.getParentPointer());
-
- controlData.setChildName(input.getChildName());
- controlData.setPID(input.getPid());
-
- StringBuilder childClassNameDemangling = new StringBuilder(
- input.getChildClassName());
-
- childClassNameDemangling.insert(0, "_Z");//$NON-NLS-1$
- String childClassName = SymbolManager
- .demanglingFunctionName(childClassNameDemangling.toString());
-
- controlData.setChildClassName(childClassName);
-
- controlData.setChildPointer(input.getChildPointer());
-
- controlData.setControlType(input.getChildName());
-
- controlData.setCalssKeyName(getClassName(input));
- return controlData;
- }
-
- private boolean isExistData(String parentClassNam, String childClassName) {
- if (getRemoveCallControlList() == null) {
- return false;
- } else {
- int nSize = getRemoveCallControlList().size();
- for (int i = 0; i < nSize; i++) {
- if (getRemoveCallControlList().get(i).equals(parentClassNam)
- || getRemoveCallControlList().get(i).equals(
- childClassName)) {
- return true;
- }
- }
- return false;
- }
- }
-
- private void addSortData(UIControlListData data) {
- int nSize = getDataList().size();
- for (int i = 0; i < nSize; i++) {
- if (data.getParentPointer() == 0) {
- getDataList().add(0, data);
- return;
- } else if (getDataList().get(i).getChildPointer() == data
- .getParentPointer()) {
- getDataList().add(i + 1, data);
- return;
- } else if (getDataList().get(i).getParentPointer() == data
- .getChildPointer()) {
- int insertIndex = 0;
- if (i - 1 < 0) {
- insertIndex = 0;
- } else {
- insertIndex = i - 1;
- }
- getDataList().add(insertIndex, data);
- return;
- }
- }
- getDataList().add(data);
- }
-
- private String getClassName(String apiName) {
- String[] splitApiNameList = apiName.split(CommonConstants.DOUBLE_COLON);
- String strApiName = CommonConstants.EMPTY;
- if (splitApiNameList.length == 1) {
- strApiName = splitApiNameList[0].trim();
- } else {
- String clasName = splitApiNameList[1].trim();
- if (clasName.contains(CommonConstants.OPEN_BRACKET)) {
- String[] splitClassNameList = clasName.split("\\(");//$NON-NLS-1$
- strApiName = splitClassNameList[0];
- }
- }
- return strApiName;
- }
-
- public void notificationFromUserInterfaceFunctionProfilingDataChecker() {
- if (controlList != null) {
- setUIControlListTimeData();
- }
- }
-
- private void setUIControlListTimeData() {
- UIDataManager uiManager = UIDataManager.getInstance();
- List<UIFunctionProfilingData> controlList = uiManager
- .getfunctionProfilingDataChecker().getDataList();
- for (int i = 0; i < controlList.size(); i++) {
- String[] splitProfilingList = controlList.get(i).getAPIName()
- .split(CommonConstants.DOUBLE_COLON);
- String strProfilingClassName = new String(
- splitProfilingList[0].trim());
- String strProfilingAPIName = new String(
- splitProfilingList[splitProfilingList.length - 1].trim());
- for (int j = 0; j < getDataList().size(); j++) {
- if (getDataList().get(j).getChildClassName().trim()
- .contains(strProfilingClassName)) {
- if (i < controlList.size()) {
- if (strProfilingAPIName.trim().contains(
- "OnInitializing")) { //$NON-NLS-1$
- getDataList().get(j).setInitializeTime(
- controlList.get(i).getExclElapsedTime());
- } else if (strProfilingAPIName.trim().contains(
- "OnTerminating")) { //$NON-NLS-1${
- getDataList().get(j).setTerminateTime(
- controlList.get(i).getExclElapsedTime());
- }
- }
- }
- }
- }
- }
-
- private String getDemanglingName(String uiClassName) {
- String demangleName = CommonConstants.EMPTY;
- StringBuilder childClassNameDemangling = new StringBuilder(uiClassName);
- if (childClassNameDemangling.indexOf("_Z") != 0) {//$NON-NLS-1$
- childClassNameDemangling.insert(0, "_Z");//$NON-NLS-1$
- demangleName = SymbolManager
- .demanglingFunctionName(childClassNameDemangling.toString());
- }
- return demangleName;
- }
-
- public String getClassName(ControlData dataFormat) {
- String apiName = dataFormat.getApiName();
- if (apiName.contains("AddFrame")) {//$NON-NLS-1$
- String className = dataFormat.getChildClassName();
- return getDemanglingName(className);
- }
- String controlTyp = dataFormat.getChildName();
-
- String className = CommonConstants.EMPTY;
- if (controlTyp.contains("Panel") || controlTyp.contains("Form")) {//$NON-NLS-1$//$NON-NLS-2$
- className = dataFormat.getChildClassName();
- } else {
- className = dataFormat.getParentClassName();
- }
- return getDemanglingName(className);
- }
-
- public List<UIControlListData> getDataList() {
- if (null == controlList) {
- controlList = new ArrayList<UIControlListData>();
- }
- return controlList;
- }
-
- public List<String> getRemoveCallControlList() {
- if (null == removeCallControlList) {
- removeCallControlList = new ArrayList<String>();
- }
- return removeCallControlList;
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Heeyoung Hwang <heeyoung1008.hwang@samsung.com>
- * Hyunjong Park <phjwithyou.park@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.userinterface.control;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.nebula.widgets.grid.GridColumn;
-import org.eclipse.nebula.widgets.grid.GridItem;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Composite;
-import org.tizen.dynamicanalyzer.common.AnalyzerManager;
-import org.tizen.dynamicanalyzer.common.DASelectionData;
-import org.tizen.dynamicanalyzer.common.Global;
-import org.tizen.dynamicanalyzer.model.FilterProperty;
-import org.tizen.dynamicanalyzer.model.TreeInput;
-import org.tizen.dynamicanalyzer.project.ImageInfo;
-import org.tizen.dynamicanalyzer.swap.model.data.ControlData;
-import org.tizen.dynamicanalyzer.swap.model.data.LogData;
-import org.tizen.dynamicanalyzer.ui.summary.profiling.ProfilingData;
-import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
-import org.tizen.dynamicanalyzer.ui.userinterface.UIDataManager;
-import org.tizen.dynamicanalyzer.ui.userinterface.UIPage;
-import org.tizen.dynamicanalyzer.ui.widgets.table.DATableCellRenderer;
-import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat;
-import org.tizen.dynamicanalyzer.ui.widgets.table.DATableHeaderRenderer;
-import org.tizen.dynamicanalyzer.ui.widgets.table.DATreeComposite;
-
-public class UIControlListTable extends DATreeComposite {
- public boolean selfUpdate = false;
-
- public UIControlListTable(Composite parent, int compStyle, int tableStyle) {
- super(parent, compStyle, tableStyle);
-
- table.addSelectionListener(new SelectionListener() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- GridItem[] items = table.getSelection();
- if (items.length <= 0) {
- return;
- }
- DATableDataFormat dataFormat = (DATableDataFormat) items[0].getData();
- ControlData data = (ControlData) dataFormat.getLogData();
- String className = UIDataManager.getInstance().getControlDataChecker()
- .getClassName(data);
- UIDataManager.getInstance().setTableSeleteClassName(className);
- long time = getSnapsotForScene(className, data.getTime());
-
- DASelectionData selData = new DASelectionData(UIPage.controlListViewID, time, 0,
- items, table);
- AnalyzerManager.getCurrentPage().updateView(selData);
-
- setSelfUpdate(true);
- updateTree();
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
- });
-
- table.addMouseListener(new MouseListener() {
-
- @Override
- public void mouseUp(MouseEvent e) {
- // do nothing
- }
-
- @Override
- public void mouseDown(MouseEvent e) {
- // do nothing
- }
-
- @Override
- public void mouseDoubleClick(MouseEvent e) {
- GridItem[] items = (GridItem[]) table.getSelection();
- if (null == items || items.length == 0) {
- return;
- }
- GridItem item = items[0];
- if (item.isExpanded()) {
- setExpand(item, false);
- } else {
- setExpand(item, true);
- }
- setSelfUpdate(true);
- updateTree();
- }
- });
- }
-
- private long getSnapsotForScene(String className, long strTime) {
- Long time = UIDataManager.getInstance().getFindScreenshotViewHashMap().get(className);
- if (null == time) {
- return strTime;
- }
- if (time == -1) {
- time = strTime;
- }
-
- ImageInfo lastimg = Global.getLeastImageInfoByTime(strTime);
- if (lastimg == null) {
- return strTime;
- } else {
- return lastimg.getTime();
- }
- }
-
- @Override
- public void setColumns(String[] columnNames) {
- int size = columnNames.length;
- for (int i = 0; i < size; i++) {
- GridColumn column = new GridColumn(table, SWT.NONE);
- column.setText(columnNames[i]);
- if (isTree && i == 0) {
- column.setTree(true);
- }
- column.setCellRenderer(new DATableCellRenderer());
- column.setHeaderRenderer(new DATableHeaderRenderer());
-
- if (columnAlignment != null) {
- if (columnAlignment.length > i) {
- column.setAlignment(columnAlignment[i]);
- }
- }
-
- column.pack();
-
- if (null != comparator && null != sortTypes) {
- final int type = sortTypes[i];
- // final int sourceColumn = sourceColumns[i];
- final int columnIndex = i;
- column.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- comparator.setType(type);
- comparator.setColumn(columnIndex);
- // comparator.setSourceColumn(sourceColumn);
- comparator.reverseDirection();
- updateTree();
- }
- });
- }
- }
- }
-
- public List<ProfilingData> difference(ArrayList<ProfilingData> base,
- ArrayList<ProfilingData> target) {
- @SuppressWarnings("unchecked")
- ArrayList<ProfilingData> result = (ArrayList<ProfilingData>) base.clone();
- result.removeAll(target);
- return result;
- }
-
- private TreeInput makeInput(UIControlListData input) {
-
- DATableDataFormat tableData = new DATableDataFormat(input.getSequence());
- LogData inputData = input.getData();
- tableData.setLogData(inputData);
-
- tableData.setObject(input.getChildClassName());
- List<String> text = new ArrayList<String>();
- text.add(input.getChildClassName());
- text.add(input.getInitializeTime());
- text.add(input.getTerminateTime());
- text.add(input.getControlType());
- text.add(input.getPID());
-
- TreeInput output = new TreeInput();
- output.setText(text);
- output.setData(tableData);
-
- output.setParent(Long.toString(input.getParentPointer()));
- output.setChild(Long.toString(input.getChildPointer()));
-
- String strSelectedClassname = UIDataManager.getInstance().getTableSeleteClassName();
- boolean isUpdate = true;
-
- if ((isSelfUpdate() == true) && (input.getControlType().trim().equals("Frame") == false)//$NON-NLS-1$
- && (input.getControlType().trim().equals("Form") == false)//$NON-NLS-1$
- && (input.getControlType().trim().equals("Panel") == false)) {//$NON-NLS-1$
- isUpdate = false;
- }
- if (strSelectedClassname.equals(input.getCalssKeyName()) && (isUpdate == true)) {
- output.setSecondSelection(true);
- }
- return output;
- }
-
- // !! recursive!!
- public boolean makeChildTree(TreeInput nodeParent, TreeInput currentNode, int nNodeDepth) {
- if (nodeParent.getChild().trim().equals(currentNode.getParent().trim())) {
- nodeParent.getChildren().add(currentNode);
- return true;
- } else {
- for (int i = 0; i < nodeParent.getChildren().size(); i++) {
- if (makeChildTree(nodeParent.getChildren().get(i), currentNode, nNodeDepth++) == true) {
- break;
- }
- }
- }
- return false;
- }
-
- @Override
- public List<TreeInput> makeTreeInput() {
- List<UIControlListData> controlList = UIDataManager.getInstance().getControlDataChecker()
- .getDataList();
- List<TreeInput> output = new ArrayList<TreeInput>();
- int size = controlList.size();
- int nNodeDepth = 0;
- for (int i = 0; i < size; i++) {
- int selectedPid = Toolbar.INSTANCE.getSelectedPid();
- if (selectedPid != 0) {
- String pid = controlList.get(i).getPID().trim();
- if (!pid.equals(Integer.toString(selectedPid))) {
- continue;
- }
- }
- // Logger.debug("sort " + i + " "
- // +controlList.get(i).getDebugLog());
- TreeInput currentNode = makeInput(controlList.get(i));
-
- if (isRootNode(controlList, i)) {
- output.add(currentNode);
- } else { // first Parent Node, Last Child Node
- for (int j = 0; j < output.size(); j++) {
- if (makeChildTree(output.get(j), currentNode, nNodeDepth++) == true) {
- break;
- }
- }
- }
-
- }
- return output;
-
- }
-
- public boolean isRootNode(List<UIControlListData> controlList, int index) {
- boolean isRootNode = true;
- if (!controlList.get(index).getChildName().trim().equals("Frame")//$NON-NLS-1$
- && !controlList.get(index).getChildName().trim().equals("Form")) {//$NON-NLS-1$
- return false;
- }
- for (int i = 0; i < index; i++) {
- if (controlList.get(i).getChildPointer() == (controlList.get(index).getParentPointer())) {
-
- isRootNode = false;
- break;
- }
- }
- return isRootNode;
- }
-
- public boolean isSelfUpdate() {
- return selfUpdate;
- }
-
- public void setSelfUpdate(boolean update) {
- selfUpdate = update;
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Heeyoung Hwang <heeyoung1008.hwang@samsung.com>
- * Hyunjong Park <phjwithyou.park@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.userinterface.control;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
-import org.tizen.dynamicanalyzer.common.DASelectionData;
-import org.tizen.dynamicanalyzer.nl.UserInterfacePageLabels;
-import org.tizen.dynamicanalyzer.resources.ColorResources;
-import org.tizen.dynamicanalyzer.ui.userinterface.UIDataManager;
-import org.tizen.dynamicanalyzer.ui.userinterface.UIPage;
-import org.tizen.dynamicanalyzer.widgets.da.view.DAViewComposite;
-import org.tizen.dynamicanalyzer.widgets.da.view.DAViewData;
-
-public class UIControlListView extends DAViewComposite {
-
- UIDataManager tManager = UIDataManager.getInstance();
-
- private String[] columnNames = {
- UserInterfacePageLabels.USERINTERFACE_CONTROL_LIST_VIEW_COLUMN_0,
- UserInterfacePageLabels.USERINTERFACE_CONTROL_LIST_VIEW_COLUMN_1,
- UserInterfacePageLabels.USERINTERFACE_CONTROL_LIST_VIEW_COLUMN_2,
- UserInterfacePageLabels.USERINTERFACE_CONTROL_LIST_VIEW_COLUMN_3,
- UserInterfacePageLabels.USERINTERFACE_CONTROL_LIST_VIEW_COLUMN_4 };
- private int[] columnSizes = { 250, 110, 110, 100, 70 };
-
- UIControlListTable treeComp = null;
- private boolean[] columnVisibility = { true, true, true, true, true, true };
- private int[] columnAlignment = { SWT.LEFT, SWT.RIGHT, SWT.RIGHT, SWT.LEFT,
- SWT.RIGHT };
- int[] sortTypes = { AnalyzerConstants.SORT_TYPE_NONE,
- AnalyzerConstants.SORT_TYPE_NUM, AnalyzerConstants.SORT_TYPE_NUM,
- AnalyzerConstants.SORT_TYPE_NUM, AnalyzerConstants.SORT_TYPE_NUM };
-
- public UIControlListView(Composite parent, int style) {
- super(parent, style, true);
- this.setLayout(new FillLayout());
-
- setTitle(UserInterfacePageLabels.USERINTERFACE_CONTROL_LIST_VIEW_NAME);
-
- Composite contents = getContentArea();
- contents.setBackground(ColorResources.WINDOW_BG_COLOR);
- contents.setLayout(new FillLayout());
- treeComp = new UIControlListTable(contents, SWT.NONE, SWT.SINGLE
- | SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
- /*** setTree set first!!! ***/
- treeComp.setTableName(UserInterfacePageLabels.USERINTERFACE_CONTROL_LIST_VIEW_NAME);
- treeComp.setTree(true);
- treeComp.setSortTypes(sortTypes);
- treeComp.setColumnAlignment(columnAlignment);
- treeComp.setColumns(columnNames);
- treeComp.setColumnSize(columnSizes);
- treeComp.setColumnVisibility(columnVisibility);
- treeComp.setTableToolTipEnable(false);
- treeComp.setTableToolTipListener(null);
-
- }
-
- @Override
- public void updateView() {
- treeComp.updateTree();
- }
-
- public void updateView(DAViewData data) {
- if (data instanceof DASelectionData) {
- DASelectionData selData = (DASelectionData) data;
-
- /* only ui page update */
- if (selData.getViewID().equals(UIPage.profilingViewID)
- || selData.getViewID().equals(UIPage.sceneListViewID)) {
- treeComp.setSelfUpdate(false);
- treeComp.updateTree();
- }
- }
-
- // other view selection occurred
- treeComp.deselectAll();
- }
-
- @Override
- public void clear() {
- treeComp.clear();
- }
-
- @Override
- public Control getControl() {
- return treeComp;
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Heeyoung Hwang <heeyoung1008.hwang@samsung.com>
- * Hyunjong Park <phjwithyou.park@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.userinterface.profiling;
-
-import org.eclipse.nebula.widgets.grid.GridColumnGroup;
-import org.eclipse.nebula.widgets.grid.internal.DefaultColumnGroupHeaderRenderer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.tizen.dynamicanalyzer.resources.ColorResources;
-import org.tizen.dynamicanalyzer.resources.FontResources;
-
-public class UIFunctionProfilingColumnGroupRenderer extends
- DefaultColumnGroupHeaderRenderer {
-
- int bottomMargin = 4;
-
- @Override
- public boolean notify(int arg0, Point arg1, Object arg2) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public void paint(GC gc, Object arg1) {
- GridColumnGroup column = (GridColumnGroup) arg1;
- gc.setBackground(ColorResources.TABLE_HEADER_BG);
- Rectangle rect = getBounds();
- gc.fillRectangle(rect.x, rect.y, rect.width, rect.height);
- gc.setForeground(ColorResources.TABLE_LINE);
- gc.drawLine(rect.x - 1, rect.y, rect.x - 1, rect.y + rect.height);
- gc.drawLine(rect.x - 1, rect.y - 1 + rect.height, rect.x + rect.width,
- rect.y - 1 + rect.height);
- gc.setForeground(ColorResources.TABLE_HEADER_FONT_COLOR);
- gc.setFont(FontResources.TABLE_HEADER_FONT);
- String inputText = column.getText();
- Point textSize = gc.textExtent(inputText, SWT.DRAW_MNEMONIC);
- int textWidth = textSize.x;
- int y = getBounds().y + getBounds().height - bottomMargin
- - gc.getFontMetrics().getHeight();
- int x = rect.x + (rect.width - textWidth) / 2;
- gc.drawString(inputText, x, y, true);
- }
-
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Heeyoung Hwang <heeyoung1008.hwang@samsung.com>
- * Hyunjong Park <phjwithyou.park@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.userinterface.profiling;
-
-import java.util.ArrayList;
-
-import org.tizen.dynamicanalyzer.constant.CommonConstants;
-import org.tizen.dynamicanalyzer.swap.model.data.LogData;
-import org.tizen.dynamicanalyzer.ui.summary.profiling.ProfilingData;
-import org.tizen.dynamicanalyzer.utils.Formatter;
-
-public class UIFunctionProfilingData {
- public static final int USER_INTERFACE_PROFILING_LIST_API_NAME = 0;
- public static final int USER_INTERFACE_PROFILING_LIST_EXCL_CPU_TIME = 1;
- public static final int USER_INTERFACE_PROFILING_LIST_INCL_CPU_TIME = 2;
- public static final int USER_INTERFACE_PROFILING_LIST_INCL_ESAPSED_TIME = 3;
- public static final int USER_INTERFACE_PROFILING_LIST_EXCL_ESAPSED_TIME = 4;
- public static final int USER_INTERFACE_PROFILING_LIST_EXCL_CPU_AVG_TIME = 5;
- public static final int USER_INTERFACE_PROFILING_LIST_INCL_CPU_AVG_TIME = 6;
- public static final int USER_INTERFACE_PROFILING_LIST_INCL_ESAPSED_AVG_TIME = 7;
- public static final int USER_INTERFACE_PROFILING_LIST_EXCL_ESAPSED_AVG_TIME = 8;
- public static final int USER_INTERFACE_PROFILING_DATABLEDATAFORMAT_CLASSNAME_INDEX = 10;
-
- private String strClassKeyName = null;
- private int strUIFunctionDataID = -1;
- private int pid = -1;
- private long longTime = -1;
- private String strKey = null;
-
- private String strAPIName = null;
- private String strExclCPUTime = null;
- private String strInclCPUTime = null;
- private String strInclElapsedTime = null;
- private String strExclElapsedTime = null;
- private String strExclCPUAvgTime = null;
- private String strInclCPUAvgTime = null;
- private String strInclElapsedAvgTime = null;
- private String strExclElapsedAvgTime = null;
-
- private String strParent = null;
- private String strTreeKey = null;
-
- private LogData data = null;
-
- private ArrayList<ProfilingData> profilingData = new ArrayList<ProfilingData>();
-
- public UIFunctionProfilingData(String[] input) {
- }
-
- public UIFunctionProfilingData(LogData input) {
- data = input;
- }
-
- public UIFunctionProfilingData(ProfilingData input) {
- if (null != input) {
- profilingData.add(input);
- }
- }
-
- public ArrayList<ProfilingData> getProfilingData() {
- return profilingData;
- }
-
- public UIFunctionProfilingData() {
- }
-
- public LogData getData() {
- return data;
- }
-
- public void setUIFunctionDataID(int data) {
- strUIFunctionDataID = data;
- }
-
- public int getUIFunctionDataID() {
- return strUIFunctionDataID;
- }
-
- public void setClassKeyName(String data) {
- strClassKeyName = data;
- }
-
- public String getClassKeyName() {
- if (strClassKeyName == null) {
- strClassKeyName = CommonConstants.EMPTY;
- }
- return strClassKeyName;
- }
-
- public void setKey(String data) {
- strKey = data;
- }
-
- public String getKey() {
- if (strKey == null) {
- strKey = CommonConstants.EMPTY;
- }
- return strKey;
- }
-
- public void setTime(long data) {
- longTime = data;
- }
-
- public String getTime() {
- return Formatter.toTimeFormat(longTime);
- }
-
- public void setParent(String data) {
- strParent = data;
- }
-
- public String getParent() {
- if (strParent == null) {
- strParent = CommonConstants.EMPTY;
- }
- return strParent;
- }
-
- public void setTreeKey(String data) {
- strTreeKey = data;
- }
-
- public String getTreeKey() {
- if (strTreeKey == null) {
- strTreeKey = CommonConstants.EMPTY;
- }
- return strTreeKey;
- }
-
- public void setAPIName(String data) {
- strAPIName = data;
- }
-
- public String getAPIName() {
- if (strAPIName == null) {
- strAPIName = CommonConstants.EMPTY;
- }
- return strAPIName;
- }
-
- public void setExclCPUTime(String data) {
- strExclCPUTime = data;
- }
-
- public String getExclCPUTime() {
- if (strExclCPUTime == null) {
- strExclCPUTime = CommonConstants.EMPTY;
- }
- return strExclCPUTime;
- }
-
- public void setExclCPUAvgTime(String data) {
- strExclCPUAvgTime = data;
- }
-
- public String getExclCPUAvgTime() {
- if (strExclCPUAvgTime == null) {
- strExclCPUAvgTime = CommonConstants.EMPTY;
- }
- return strExclCPUAvgTime;
- }
-
- public void setInclCPUTime(String data) {
- strInclCPUTime = data;
- }
-
- public String getInclCPUTime() {
- if (strInclCPUTime == null) {
- strInclCPUTime = CommonConstants.EMPTY;
- }
- return strInclCPUTime;
- }
-
- public void setInclCPUAvgTime(String data) {
- strInclCPUAvgTime = data;
- }
-
- public String getInclCPUAvgTime() {
- if (strInclCPUAvgTime == null) {
- strInclCPUAvgTime = CommonConstants.EMPTY;
- }
- return strInclCPUAvgTime;
- }
-
- public void setInclElapsedTime(String data) {
- strInclElapsedTime = data;
- }
-
- public String getInclElapsedTime() {
- if (strInclElapsedTime == null) {
- strInclElapsedTime = CommonConstants.EMPTY;
- }
- return strInclElapsedTime;
- }
-
- public void setInclElapsedAvgTime(String data) {
- strInclElapsedAvgTime = data;
- }
-
- public String getInclElapsedAvgTime() {
- if (strInclElapsedAvgTime == null) {
- strInclElapsedAvgTime = CommonConstants.EMPTY;
- }
- return strInclElapsedAvgTime;
- }
-
- public void setExclElapsedTime(String data) {
- strExclElapsedTime = data;
- }
-
- public String getExclElapsedTime() {
- if (strExclElapsedTime == null) {
- strExclElapsedTime = CommonConstants.EMPTY;
- }
- return strExclElapsedTime;
- }
-
- public void setExclElapsedAvgTime(String data) {
- strExclElapsedAvgTime = data;
- }
-
- public String getExclElapsedAvgTime() {
- if (strExclElapsedAvgTime == null) {
- strExclElapsedAvgTime = CommonConstants.EMPTY;
- }
- return strExclElapsedAvgTime;
- }
-
- public int getPid() {
- return pid;
- }
-
- public void setPid(int pid) {
- this.pid = pid;
- }
-
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Heeyoung Hwang <heeyoung1008.hwang@samsung.com>
- * Hyunjong Park <phjwithyou.park@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.userinterface.profiling;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.TreeSet;
-
-import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
-import org.tizen.dynamicanalyzer.common.path.PathManager;
-import org.tizen.dynamicanalyzer.communicator.DACommunicator;
-import org.tizen.dynamicanalyzer.communicator.DeviceNotFoundException;
-import org.tizen.dynamicanalyzer.constant.CommonConstants;
-import org.tizen.dynamicanalyzer.setting.SettingDataManager;
-import org.tizen.dynamicanalyzer.ui.summary.profiling.FunctionUsageProfiler;
-import org.tizen.dynamicanalyzer.ui.summary.profiling.ProfileDataMaker;
-import org.tizen.dynamicanalyzer.ui.summary.profiling.ProfilingData;
-import org.tizen.dynamicanalyzer.ui.userinterface.UIDataManager;
-import org.tizen.dynamicanalyzer.util.CommonUtil;
-import org.tizen.dynamicanalyzer.util.Logger;
-import org.tizen.dynamicanalyzer.utils.Formatter;
-
-public class UIFunctionProfilingDataChecker {
- List<UIFunctionProfilingData> profilingList;
- static private TreeSet<UIFunctionProfilingTreeSetData> userInterfaceFunctionTree = new TreeSet<UIFunctionProfilingTreeSetData>();
-
- static boolean InitUIApiList = false;
- static List<String> isUiApiCheckList = new ArrayList<String>();
- static final String UI_API_TRUE = "true";//$NON-NLS-1$
- static final String UI_API_FALSE = "false";//$NON-NLS-1$
- static int nUserProfilingDataCount = 0;
-
- public boolean addProfilingData(ProfilingData input) {
-
- getUIApiListFile();
- boolean bTreeSearch = userInterfaceFunctionTree.contains(makeTreeSetData(input.getName()));
- if (bTreeSearch) { // Find Same Api name
-
- int nChangedIndex = 0;
- boolean bUpdateData = false;
-
- if (!existRootData(input)) {
- makeRootParentData(input);
- }
-
- int nListSize = getDataList().size();
- for (int i = 0; i < nListSize; i++) {
- String apiName = getDataList().get(i).getAPIName();
- if ((apiName != null) && (apiName.equals(input.getName()))) {
- getDataList().remove(i);
- nChangedIndex = i;
- bUpdateData = true;
- break;
- }
- }
-
- UIFunctionProfilingData pd = new UIFunctionProfilingData();
- int pid = input.getProfileDataMaker().getPid();
- ProfileDataMaker profiler = FunctionUsageProfiler.getInstance()
- .getProfileDataMakerByPid(pid);
- String exTime = CommonConstants.DASH, inTime = CommonConstants.DASH, exeTime = CommonConstants.DASH, inExeTime = CommonConstants.DASH, exAvgTime = CommonConstants.DASH, inAvgTime = CommonConstants.DASH, exeAvgTime = CommonConstants.DASH, inExeAvgTime = CommonConstants.DASH;
- try {
- exTime = profiler.getCpuTime(input, true);
- exAvgTime = getAvgTime(Integer.parseInt(exTime), input.getCallCount(), 2);
- exTime = Formatter.toTimeFormat2(exTime);
-
- inTime = profiler.getCpuTime(input, false);
- inAvgTime = getAvgTime(Integer.parseInt(inTime), input.getCallCount(), 2);
- inTime = Formatter.toTimeFormat2(inTime);
- exeTime = Formatter.toTimeFormat4(input.getElapsedTime());
- exeAvgTime = getAvgTime(input.getElapsedTime(), input.getCallCount(), 1);
- inExeTime = Formatter.toTimeFormat4(input.getExclusiveElapsedTime());
- inExeAvgTime = getAvgTime(input.getExclusiveElapsedTime(), input.getCallCount(), 1);
- } catch (NumberFormatException e) {
- Logger.exception(e);
- }
-
- pd.setPid(input.getProfileDataMaker().getPid());
- pd.setUIFunctionDataID(input.getProfilingDataID());
- pd.setKey(input.getKey());
- pd.setAPIName(input.getName());
- pd.setExclCPUTime(exTime);
- pd.setInclCPUTime(inTime);
- pd.setInclElapsedTime(exeTime);
- pd.setExclElapsedTime(inExeTime);
- pd.setExclCPUAvgTime(exAvgTime);
- pd.setInclCPUAvgTime(inAvgTime);
- pd.setInclElapsedAvgTime(exeAvgTime);
- pd.setExclElapsedAvgTime(inExeAvgTime);
- pd.setParent(input.getParent());
- // TODO: ProfilingData.getSaveData is deprecated, below code must be fixed.
- // pd.setCalssKeyName(getClassName(input.getSaveData())); // index 10;
-
- if (bUpdateData == true) {
- getDataList().add(nChangedIndex, pd);
- } else {
- getDataList().add(pd);
- }
- return true;
- } else {
- return false;
- }
- }
-
- public UIFunctionProfilingDataChecker() {
- getUIApiListFile();
- }
-
- public synchronized List<UIFunctionProfilingData> getDataList() {
- if (null == profilingList) {
- profilingList = new ArrayList<UIFunctionProfilingData>();
- }
- return profilingList;
- }
-
- public void updateUIApiTreeSet() {
- List<Integer> pids = FunctionUsageProfiler.getInstance().getPidsOfProfileDataMakerMap();
- for (int i = 0; i < pids.size(); i++) {
- ProfileDataMaker profiler = FunctionUsageProfiler.getInstance()
- .getProfileDataMakerByPid(pids.get(i));
- if (profiler.getAppBin() == null) {
- return;
- }
- List<ProfilingData> children = profiler.getAppBin().getChildList().get(0)
- .getChildList();
- int size = children.size();
- getUIApiListFile();
- for (int j = 0; j < size; j++) {
- if (j >= isUiApiCheckList.size()) {
- isUiApiCheckList.add(j, UI_API_TRUE);
- }
- if (isUiApiCheckList.get(j).equals(UI_API_TRUE)) {
- ProfilingData data = children.get(j);
- if (addProfilingData(data)) {
- isUiApiCheckList.add(j, UI_API_TRUE);
- } else {
- isUiApiCheckList.add(j, UI_API_FALSE);
- }
- }
- }
- UIDataManager tManager = UIDataManager.getInstance();
- tManager.getControlDataChecker()
- .notificationFromUserInterfaceFunctionProfilingDataChecker();
- }
- }
-
- public void cleanUIProfilingMemberData() {
- isUiApiCheckList = null;
- isUiApiCheckList = new ArrayList<String>();
- nUserProfilingDataCount = 0;
- }
-
- private String getAvgTime(long nTime, int nCount, int nType) {
- String strRetrun = "00.000";//$NON-NLS-1$
- long time = -1;
- if (nTime == 0) {
- return strRetrun;
- } else if (nCount == 0) {
- time = nTime;
- } else {
- // avg exe time
- time = (nTime / nCount);
- }
- if (nType == 1) {
- strRetrun = Formatter.toTimeFormat4(time);
- } else {
- strRetrun = Formatter.toTimeFormat2(time);
- }
- return strRetrun;
- }
-
- public boolean existRootData(ProfilingData input) {
- boolean existRootData = false;
- for (UIFunctionProfilingData data : getDataList()) {
- if (data.getAPIName().equals(input.getParent())) {
- existRootData = true;
- break;
- }
- }
- return existRootData;
- }
-
- private void makeRootParentData(ProfilingData input) {
- UIFunctionProfilingData pd = new UIFunctionProfilingData();
- String exTime = CommonConstants.DASH, inTime = CommonConstants.DASH, exeTime = CommonConstants.DASH, inExeTime = CommonConstants.DASH, exAvgTime = CommonConstants.DASH, inAvgTime = CommonConstants.DASH, exeAvgTime = CommonConstants.DASH, inExeAvgTime = CommonConstants.DASH;
- pd.setPid(input.getProfileDataMaker().getPid());
- pd.setUIFunctionDataID(0);
- pd.setKey(input.getKey());
- pd.setAPIName(input.getParent());
- pd.setParent(CommonConstants.EMPTY);
- pd.setExclCPUTime(exTime);
- pd.setInclCPUTime(inTime);
- pd.setInclElapsedTime(exeTime);
- pd.setExclElapsedTime(inExeTime);
- pd.setExclCPUAvgTime(exAvgTime);
- pd.setInclCPUAvgTime(inAvgTime);
- pd.setInclElapsedAvgTime(exeAvgTime);
- pd.setExclElapsedAvgTime(inExeAvgTime);
- getDataList().add(pd);
- }
-
- private UIFunctionProfilingTreeSetData makeTreeSetData(String inputData) {
- UIFunctionProfilingTreeSetData returnData = null;
- if (inputData.contains(CommonConstants.OPEN_BRACKET)) {
- String[] splitInpuDataList = inputData.split("\\("); //$NON-NLS-1$
- String strApiName = null;
-
- String[] splitApiNameAndReturnValues = splitInpuDataList[0]
- .split(CommonConstants.SPACE);
-
- if (splitApiNameAndReturnValues[splitApiNameAndReturnValues.length - 1]
- .contains(CommonConstants.DOUBLE_COLON)) {
-
- String[] apiNameList = splitApiNameAndReturnValues[splitApiNameAndReturnValues.length - 1]
- .split(CommonConstants.DOUBLE_COLON);
- strApiName = new String(apiNameList[apiNameList.length - 1].trim());
- } else {
- strApiName = new String(
- splitApiNameAndReturnValues[splitApiNameAndReturnValues.length - 1].trim());
- }
- String strParameter = new String(splitInpuDataList[splitInpuDataList.length - 1].trim());
- if (strParameter.contains(CommonConstants.COMMA)) {
- String[] splitParameterList = strParameter.split(CommonConstants.COMMA);
- returnData = new UIFunctionProfilingTreeSetData(strApiName, splitParameterList);
- } else {
- String[] splitParameterList = strParameter.split("\\)"); //$NON-NLS-1$
- if (strParameter.contains("void")) {//$NON-NLS-1$
- returnData = new UIFunctionProfilingTreeSetData(strApiName, null);
- } else if (splitParameterList.length == 0) {
- returnData = new UIFunctionProfilingTreeSetData(strApiName, null);
- } else {
- returnData = new UIFunctionProfilingTreeSetData(strApiName, splitParameterList);
- }
- }
- } else {
- returnData = new UIFunctionProfilingTreeSetData(inputData, null);
- }
- return returnData;
- }
-
- private void getUIApiListFile() {
- if (InitUIApiList == false) {
- InitUIApiList = true;
- } else {
- return;
- }
-
- boolean isEmulator = false;
- try {
- if (!DACommunicator.isEmulator()) {
- isEmulator = true;
- }
- } catch (DeviceNotFoundException e1) {
- // this exception is occurred, if 'open' save file and device is not connected
- Logger.warning("Device is not found");
- // do not return, assume device is emulator
- }
-
- String platform = SettingDataManager.INSTANCE.getPlatform();
- if (platform == null) {
- return;
- }
-
- String sourcePath = PathManager.getTizenHeaderPath(isEmulator, platform);
- File sourceFolder = new File(sourcePath);
- if (!sourceFolder.exists() && !sourceFolder.isDirectory()) {
- Logger.debug("Not Found the tizen_header_file folder : " + sourcePath);
- return;
- }
-
- String uiFileOptionList = null;
- String uiApiOptionList = null;
- String uiOptionList = getUIApiOptionList();
- if (uiOptionList == null) {
- return;
- }
- if (uiOptionList.contains(CommonConstants.SEMICOLON) == false) {
- return;
- }
- String[] splitInpuDataList = uiOptionList.split(CommonConstants.SEMICOLON);
- for (int i = 0; i < splitInpuDataList.length; i++) {
- if (splitInpuDataList[i].contains("file")) {//$NON-NLS-1$
- if (splitInpuDataList[i].contains(CommonConstants.DOUBLE_COLON) == false) {
- return;
- }
- String[] splitDataList = splitInpuDataList[i].split(CommonConstants.DOUBLE_COLON);
- uiFileOptionList = splitDataList[splitDataList.length - 1];
- } else {
- if (splitInpuDataList[i].contains(CommonConstants.DOUBLE_COLON) == false) {
- return;
- }
- String[] splitDataList = splitInpuDataList[i].split(CommonConstants.DOUBLE_COLON);
- uiApiOptionList = splitDataList[splitDataList.length - 1];
- }
- }
-
- if (uiFileOptionList == null) {
- return;
- }
- if (uiFileOptionList.contains(AnalyzerConstants.DATA_PARSING_TOKEN) == false) {
- return;
- }
- String[] splitUiFileOptionList = uiFileOptionList
- .split(AnalyzerConstants.DATA_PARSING_TOKEN);
- if (uiApiOptionList == null) {
- return;
- }
- if (uiApiOptionList.contains(AnalyzerConstants.DATA_PARSING_TOKEN) == false) {
- return;
- }
- String[] splitUiApiOptionList = uiApiOptionList.split(AnalyzerConstants.DATA_PARSING_TOKEN);
-
- File[] files = sourceFolder.listFiles();
- if (files == null) {
- return;
- }
- String filename = null;
- int filelength = files.length;
- for (int i = 0; i < filelength; i++) {
- filename = files[i].getName();
- if (isOptionValue(splitUiFileOptionList, filename)) {
- // Logger.debug("ui filename : "+filename);
- BufferedReader in = null;
- String content;
- try {
- in = new BufferedReader(new FileReader(files[i]));
- String strInputData;
- while (null != (content = in.readLine())) {
- if (!content.equals(CommonConstants.EMPTY)) {
- strInputData = content.trim();
- if (strInputData.startsWith("virtual")) {//$NON-NLS-1$
- if (isOptionValue(splitUiApiOptionList, strInputData)) {
- userInterfaceFunctionTree.add(makeTreeSetData(strInputData));
- // Logger.debug("- ui header : "+strInputData);
- }
- }
- }
- }
- } catch (FileNotFoundException e) {
- Logger.exception(e);
- } catch (IOException e) {
- Logger.exception(e);
- } finally {
- CommonUtil.tryClose(in);
- }
- }
- }
- }
-
- private boolean isOptionValue(String[] optionList, String strCmp) {
- boolean bSucces = true;
- for (int j = 0; j < optionList.length; j++) {
- if (optionList[j].contains(CommonConstants.PLUS)) {
- int chartIndex = optionList[j].indexOf(CommonConstants.PLUS);
- String uiAddOption = optionList[j].substring(chartIndex + 1).trim();
- if (strCmp.contains(uiAddOption)) {
- bSucces = true;
- } else {
- bSucces = false;
- break;
- }
- } else {
- int chartIndex = optionList[j].indexOf(CommonConstants.DASH);
- String uiMinusOption = optionList[j].substring(chartIndex + 1).trim();
- if (strCmp.contains(uiMinusOption)) {
- bSucces = false;
- }
- }
- }
- return bSucces;
- }
-
- private String getUIApiOptionList() {
- String uiApiOptionList = null;
- ;
- String configFileName = AnalyzerConstants.USER_INTERFACE_API_LIST_FILE_NAME;
- File configFolder = new File(PathManager.DA_CONFIG_FOLDER_PATH);
- if (!configFolder.isDirectory()) {
- Logger.debug("Not Exist UI API List Option Path ");
- return CommonConstants.EMPTY;
- }
- File apiListFile = new File(configFolder, configFileName);
- if (!apiListFile.isFile()) {
- Logger.debug("Not Exist UI API List Option File");
- return CommonConstants.EMPTY;
- } else {
- BufferedReader in = null;
- String content;
- try {
- in = new BufferedReader(new FileReader(apiListFile));
- StringBuffer inputData = new StringBuffer();
- while (null != (content = in.readLine())) {
- if (!content.equals(CommonConstants.EMPTY)) {
- inputData.append(content);
- }
- }
- uiApiOptionList = inputData.toString();
- } catch (FileNotFoundException e) {
- Logger.exception(e);
- } catch (IOException e) {
- Logger.exception(e);
- } finally {
- CommonUtil.tryClose(in);
- }
- }
- return uiApiOptionList;
- }
-
- @SuppressWarnings("unused")
- private String getClassName(List<String> dataFormat) {
- String[] splitApiNameList = dataFormat.get(2).split(CommonConstants.DOUBLE_COLON);
- if (splitApiNameList.length - 2 < 0) {
- return CommonConstants.EMPTY;
- }
- String className = new String(splitApiNameList[splitApiNameList.length - 2].trim());
- return className;
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Heeyoung Hwang <heeyoung1008.hwang@samsung.com>
- * Hyunjong Park <phjwithyou.park@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.userinterface.profiling;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.nebula.widgets.grid.Grid;
-import org.eclipse.nebula.widgets.grid.GridColumn;
-import org.eclipse.nebula.widgets.grid.GridColumnGroup;
-import org.eclipse.nebula.widgets.grid.GridItem;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Composite;
-import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
-import org.tizen.dynamicanalyzer.common.AnalyzerManager;
-import org.tizen.dynamicanalyzer.common.DASelectionData;
-import org.tizen.dynamicanalyzer.constant.CommonConstants;
-import org.tizen.dynamicanalyzer.model.ColumnData;
-import org.tizen.dynamicanalyzer.model.FilterProperty;
-import org.tizen.dynamicanalyzer.model.TreeInput;
-import org.tizen.dynamicanalyzer.nl.UserInterfacePageLabels;
-import org.tizen.dynamicanalyzer.ui.summary.profiling.ProfilingData;
-import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
-import org.tizen.dynamicanalyzer.ui.userinterface.UIDataManager;
-import org.tizen.dynamicanalyzer.ui.userinterface.UIPage;
-import org.tizen.dynamicanalyzer.ui.widgets.table.DATableCellRenderer;
-import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat;
-import org.tizen.dynamicanalyzer.ui.widgets.table.DATableHeaderRenderer;
-import org.tizen.dynamicanalyzer.ui.widgets.table.DATreeComposite;
-import org.tizen.dynamicanalyzer.ui.widgets.table.TreeDataComparator;
-
-public class UIFunctionProfilingTable extends DATreeComposite {
- public UIFunctionProfilingTable(Composite parent, int compStyle,
- int tableStyle) {
- super(parent, compStyle, tableStyle);
- setComparator(new TreeDataComparator());
-
- comparator.setType(AnalyzerConstants.SORT_TYPE_NUM);
- comparator.setColumn(2);
- comparator.reverseDirection();
-
- table.addSelectionListener(new SelectionListener() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- GridItem[] items = table.getSelection();
- if (items.length <= 0) {
- return;
- }
- DATableDataFormat dataFormat = (DATableDataFormat) items[0]
- .getData();
- String className = (String) dataFormat.getData().get(
- dataFormat.getData().size() - 1);
- UIDataManager.getInstance().setTableSeleteClassName(className);
-
- DASelectionData selData = new DASelectionData(
- UIPage.profilingViewID, 0, 0, items, table);
- AnalyzerManager.getCurrentPage().updateView(selData);
- updateTree();
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
- });
-
- table.addMouseListener(new MouseListener() {
-
- @Override
- public void mouseUp(MouseEvent e) {
- // do nothing
- }
-
- @Override
- public void mouseDown(MouseEvent e) {
- // do nothing
- }
-
- @Override
- public void mouseDoubleClick(MouseEvent e) {
- GridItem[] items = (GridItem[]) table.getSelection();
- if (null == items || items.length == 0) {
- return;
- }
- GridItem item = items[0];
- if (item.isExpanded()) {
- setExpand(item, false);
- } else {
- setExpand(item, true);
- }
- updateTree();
- }
- });
- }
-
- public void setColumns(List<ColumnData> columnData) {
- int size = columnData.size();
- int index = 0;
- for (int i = 0; i < size; i++) {
- if (columnData.get(i).isParent()) {
- GridColumnGroup columnGroup = new GridColumnGroup(table,
- SWT.NONE);
- columnGroup
- .setHeaderRenderer(new UIFunctionProfilingColumnGroupRenderer());
- columnGroup.setText(columnData.get(i).getText());
- List<ColumnData> children = columnData.get(i).getChildren();
- int childSize = children.size();
- for (int ii = 0; ii < childSize; ii++) {
- createColumn(columnGroup, children.get(ii), index++);
- }
- } else {
- createColumn(table, columnData.get(i), index++);
- }
- }
- }
-
- private void createColumn(Object parent, ColumnData columnData, int index) {
- GridColumn column = null;
- if (parent instanceof GridColumnGroup) {
- GridColumnGroup group = (GridColumnGroup) parent;
- column = new GridColumn(group, SWT.NONE);
- } else {
- Grid table = (Grid) parent;
- column = new GridColumn(table, SWT.NONE);
- }
-
- column.setCellRenderer(new DATableCellRenderer());
- column.setHeaderRenderer(new DATableHeaderRenderer());
- column.setText(columnData.getText());
- if (columnAlignment != null) {
- if (columnAlignment.length > index) {
- column.setAlignment(columnAlignment[index]);
- }
- }
- if (columnData.getWidth() == 0) {
- column.pack();
- } else {
- column.setWidth(columnData.getWidth());
- }
- if (isTree && index == 0) {
- column.setTree(true);
- }
-
- if (null != comparator && null != sortTypes) {
- final int type = sortTypes[index];
- final int columnIndex = index;
- column.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- comparator.setType(type);
- comparator.setColumn(columnIndex);
- comparator.reverseDirection();
- updateTree();
- }
- });
- }
- }
-
- public List<ProfilingData> difference(ArrayList<ProfilingData> base,
- ArrayList<ProfilingData> target) {
- @SuppressWarnings("unchecked")
- ArrayList<ProfilingData> result = (ArrayList<ProfilingData>) base
- .clone();
- result.removeAll(target);
- return result;
- }
-
- private TreeInput makeInput(UIFunctionProfilingData input) {
-
- DATableDataFormat tableData = new DATableDataFormat(input.getUIFunctionDataID());
- List<String> inputData = new ArrayList<String>();
-
- // make input data
- inputData.add(Integer.toString(input.getUIFunctionDataID()));
- inputData.add(input.getAPIName());
- inputData.add(input.getInclElapsedTime());
- inputData.add(input.getInclElapsedAvgTime());
- inputData.add(input.getExclElapsedTime());
- inputData.add(input.getExclElapsedAvgTime());
- inputData.add(input.getInclCPUTime());
- inputData.add(input.getInclCPUAvgTime());
- inputData.add(input.getExclCPUTime());
- inputData.add(input.getExclCPUAvgTime());
- inputData.add(input.getClassKeyName());
-
- tableData.getData().addAll(inputData);
- if (input.getParent().equals(CommonConstants.EMPTY)) {
- tableData.setObject(input.getAPIName() + CommonConstants.SPACE
- + CommonConstants.OPEN_BRACKET
- + UserInterfacePageLabels.PID + input.getPid()
- + CommonConstants.CLOSE_BRACKET);
- } else {
- tableData.setObject(input.getAPIName());
- }
-
- List<String> text = new ArrayList<String>();
- text.add(input.getAPIName());
- text.add(input.getInclElapsedTime());
- text.add(input.getInclElapsedAvgTime());
- text.add(input.getExclElapsedTime());
- text.add(input.getExclElapsedAvgTime());
- text.add(input.getInclCPUTime());
- text.add(input.getInclCPUAvgTime());
- text.add(input.getExclCPUTime());
- text.add(input.getExclCPUAvgTime());
-
- TreeInput output = new TreeInput();
- output.setText(text);
- output.setData(tableData);
-
- String strSelectedClassname = UIDataManager.getInstance()
- .getTableSeleteClassName();
- if (strSelectedClassname.equals(input.getClassKeyName())) {
- output.setSecondSelection(true);
- }
- return output;
- }
-
- // !! recursive!!
- public boolean makeChildTree(TreeInput nodeParent, TreeInput currentNode,
- int nNodeDepth) {
- String strParentName = nodeParent.getText().get(
- UIFunctionProfilingData.USER_INTERFACE_PROFILING_LIST_API_NAME);
- if (currentNode.getParent().trim().equals(strParentName)) {
- nodeParent.getChildren().add(currentNode);
- return true;
- } else {
- for (int i = 0; i < nodeParent.getChildren().size(); i++) {
- if (makeChildTree(nodeParent.getChildren().get(i), currentNode,
- nNodeDepth++) == true) {
- break;
- }
- }
- }
- return false;
- }
-
- @Override
- public List<TreeInput> makeTreeInput() {
- UIDataManager tManager = UIDataManager.getInstance();
- List<UIFunctionProfilingData> controlList = tManager
- .getfunctionProfilingDataChecker().getDataList();
- List<TreeInput> output = new ArrayList<TreeInput>();
- int size = controlList.size();
- int nNodeDepth = 0;
- for (int i = 0; i < size; i++) {
- int selectedPid = Toolbar.INSTANCE.getSelectedPid();
- if (selectedPid != 0) {
- int pid = controlList.get(i).getPid();
-
- if (pid != selectedPid) {
- continue;
- }
- }
-
- TreeInput currentNode = makeInput(controlList.get(i));
- currentNode.setParent(controlList.get(i).getParent());
- if (controlList.get(i).getParent().equals(CommonConstants.EMPTY)) {
- output.add(currentNode);
- } else {
- for (int j = 0; j < output.size(); j++) {
- if (makeChildTree(output.get(j), currentNode, nNodeDepth++) == true) {
- break;
- }
- }
- }
- }
- return output;
-
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Heeyoung Hwang <heeyoung1008.hwang@samsung.com>
- * Hyunjong Park <phjwithyou.park@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.userinterface.profiling;
-
-public class UIFunctionProfilingTreeSetData implements Comparable<UIFunctionProfilingTreeSetData> {
- private String apiName = null;
- private String[] parameter = null;
- private int nParameterlength = 0;
-
- public UIFunctionProfilingTreeSetData(String apiName, String[] parameter) {
- this.apiName = apiName;
- if (parameter == null) {
- this.parameter = null;
- this.nParameterlength = 0;
- } else {
- this.parameter = parameter;
- this.nParameterlength = parameter.length;
- }
- }
-
- @Override
- public int compareTo(UIFunctionProfilingTreeSetData op) {
- // Logger.debug("op.apiName.trim() : " + op.apiName.trim());
- if (apiName.trim().equals(op.apiName.trim())) {
- if (nParameterlength == op.nParameterlength) {
- for (int i = 0; i < nParameterlength; i++) {
- if (parameter[i].trim().equals(op.parameter[i].trim())) {
- continue;
- } else {
- return 1;
- }
- }
- return 0;
- } else {
- if (nParameterlength > op.nParameterlength) {
- return 1;
- } else {
- return -1;
- }
- }
- } else {
- return apiName.trim().compareTo(op.apiName.trim());
- }
- }
-
- @Override
- public String toString() {
- return String.format("%s|%d", apiName, nParameterlength);
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Heeyoung Hwang <heeyoung1008.hwang@samsung.com>
- * Hyunjong Park <phjwithyou.park@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.userinterface.profiling;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
-import org.tizen.dynamicanalyzer.common.DASelectionData;
-import org.tizen.dynamicanalyzer.model.ColumnData;
-import org.tizen.dynamicanalyzer.nl.UserInterfacePageLabels;
-import org.tizen.dynamicanalyzer.resources.ColorResources;
-import org.tizen.dynamicanalyzer.ui.userinterface.UIDataManager;
-import org.tizen.dynamicanalyzer.ui.userinterface.UIPage;
-import org.tizen.dynamicanalyzer.widgets.da.view.DAViewComposite;
-import org.tizen.dynamicanalyzer.widgets.da.view.DAViewData;
-
-public class UIFunctionProfilingView extends DAViewComposite {
- List<ColumnData> columnData = null;
-
- private String[] columnNames = {
- UserInterfacePageLabels.USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_COLUMN_0,
- UserInterfacePageLabels.USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_COLUMN_1,
- UserInterfacePageLabels.USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_COLUMN_2,
- UserInterfacePageLabels.USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_COLUMN_3,
- UserInterfacePageLabels.USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_COLUMN_4,
- UserInterfacePageLabels.USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_COLUMN_5,
- UserInterfacePageLabels.USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_COLUMN_6,
- UserInterfacePageLabels.USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_COLUMN_7,
- UserInterfacePageLabels.USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_COLUMN_8 };
- private int[] columnSizes = { 355, 80, 80, 80, 80, 80, 80, 80, 80 };
- private int[] columnAlignment = { SWT.LEFT, SWT.RIGHT, SWT.RIGHT,
- SWT.RIGHT, SWT.RIGHT, SWT.RIGHT, SWT.RIGHT, SWT.RIGHT, SWT.RIGHT };
- UIFunctionProfilingTable treeComp = null;
- private boolean[] columnVisibility = { true, true, true, true, true, true,
- true, true, true };
- int[] sortTypes = { AnalyzerConstants.SORT_TYPE_STRING,
- AnalyzerConstants.SORT_TYPE_STRING,
- AnalyzerConstants.SORT_TYPE_STRING,
- AnalyzerConstants.SORT_TYPE_STRING,
- AnalyzerConstants.SORT_TYPE_STRING,
- AnalyzerConstants.SORT_TYPE_STRING,
- AnalyzerConstants.SORT_TYPE_STRING,
- AnalyzerConstants.SORT_TYPE_STRING,
- AnalyzerConstants.SORT_TYPE_STRING };
-
- public UIFunctionProfilingView(Composite parent, int style) {
- super(parent, style, true);
- this.setLayout(new FillLayout());
-
- setTitle(UserInterfacePageLabels.USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_NAME);
-
- Composite contents = getContentArea();
- contents.setBackground(ColorResources.WINDOW_BG_COLOR);
- contents.setLayout(new FillLayout());
- treeComp = new UIFunctionProfilingTable(contents, SWT.NONE, SWT.SINGLE
- | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
- /*** setTree set first!!! ***/
- treeComp.setTree(true);
- treeComp.setSortTypes(sortTypes);
- treeComp.setColumnAlignment(columnAlignment);
- createColumnData();
- treeComp.setColumns(columnData);
- treeComp.setColumnSize(columnSizes);
- treeComp.setColumnVisibility(columnVisibility);
- treeComp.setTableToolTipEnable(false);
- treeComp.setTableName(UserInterfacePageLabels.USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_NAME);
- }
-
- private void createColumnData() {
- int columnIndex = 0;
- columnData = new ArrayList<ColumnData>();
- ColumnData data0 = new ColumnData(columnNames[columnIndex++]);
- columnData.add(data0);
-
- ColumnData dataInc1 = new ColumnData(
- UserInterfacePageLabels.USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_INCLUSIVE_ELAPSED_TIME);
- ColumnData dataInc1Child1 = new ColumnData(columnNames[columnIndex++]);
- ColumnData dataInc1Child2 = new ColumnData(columnNames[columnIndex++]);
- dataInc1.getChildren().add(dataInc1Child1);
- dataInc1.getChildren().add(dataInc1Child2);
- columnData.add(dataInc1);
-
- ColumnData dataExc1 = new ColumnData(
- UserInterfacePageLabels.USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_EXCLUSIVE_ELAPSED_TIME);
- ColumnData dataExc1Child1 = new ColumnData(columnNames[columnIndex++]);
- ColumnData dataExc1Child2 = new ColumnData(columnNames[columnIndex++]);
- dataExc1.getChildren().add(dataExc1Child1);
- dataExc1.getChildren().add(dataExc1Child2);
- columnData.add(dataExc1);
-
- ColumnData dataInc2 = new ColumnData(
- UserInterfacePageLabels.USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_INCLUSIVE_CPU_TIME);
- ColumnData dataInc2Child1 = new ColumnData(columnNames[columnIndex++]);
- ColumnData dataInc2Child2 = new ColumnData(columnNames[columnIndex++]);
- dataInc2.getChildren().add(dataInc2Child1);
- dataInc2.getChildren().add(dataInc2Child2);
- columnData.add(dataInc2);
-
- ColumnData dataExc2 = new ColumnData(
- UserInterfacePageLabels.USERINTERFACE_UIFUNCTIONPROFILING_LIST_VIEW_EXCLUSIVE_CPU_TIME);
- ColumnData dataExc2Child1 = new ColumnData(columnNames[columnIndex++]);
- ColumnData dataExc2Child2 = new ColumnData(columnNames[columnIndex++]);
- dataExc2.getChildren().add(dataExc2Child1);
- dataExc2.getChildren().add(dataExc2Child2);
- columnData.add(dataExc2);
- }
-
- @Override
- public void updateView() {
- treeComp.updateTree();
- }
-
- @Override
- public void updateView(DAViewData data) {
- if (data instanceof DASelectionData) {
- DASelectionData selData = (DASelectionData) data;
-
- /* only ui page update */
- if (selData.getViewID().equals(UIPage.controlListViewID)
- || selData.getViewID().equals(UIPage.sceneListViewID)) {
- treeComp.updateTree();
- }
- }
-
- // other view selection occurred
- treeComp.deselectAll();
- }
-
- @Override
- public void clear() {
- treeComp.clear();
- UIDataManager.getInstance().getfunctionProfilingDataChecker()
- .cleanUIProfilingMemberData();
- }
-
- @Override
- public Control getControl() {
- return treeComp;
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Heeyoung Hwang <heeyoung1008.hwang@samsung.com>
- * Hyunjong Park <phjwithyou.park@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.userinterface.scene;
-
-import org.tizen.dynamicanalyzer.common.SymbolManager;
-import org.tizen.dynamicanalyzer.constant.CommonConstants;
-import org.tizen.dynamicanalyzer.swap.model.data.LogData;
-import org.tizen.dynamicanalyzer.utils.Formatter;
-
-public class UISceneData {
- public static final int USER_INTERFACE_SCENE_TRANSFORMS_LISTL_SCENE_NAME = 0;
- public static final int USER_INTERFACE_SCENE_TRANSFORMS_LIST_TIME = 1;
- public static final int USER_INTERFACE_SCENE_TRANSFORMS_LIST_PID = 2;
- public static final int USER_INTERFACE_SCENE_TRANSFORMS_LIST_FORM_NAME = 3;
- public static final int USER_INTERFACE_SCENE_TRANSFORMS_LIST_PANEL_NAME = 4;
- public static final int USER_INTERFACE_SCENE_TRANSFORMS_LIST_TRANSFORM_TIME = 5;
- public static final int USER_INTERFACE_SCENE_TRANSFORMS_LIST_DATABLEDATAFORMAT_CLASSNAME_INDEX = 21;
-
- private String strCalssKeyName = null;
- private long strSequence = -1;
- private int strPID = -1;
- private long strTime = -1;
- private String strSceneName = null;
- private String strTransformTime = null;
- private String strFormName = null;
- private String strPanelName = null;
-
- private LogData data;
-
- public UISceneData(LogData sceneLoginput) {
- if (null != sceneLoginput) {
- data = sceneLoginput;
- }
- }
-
- public LogData getData() {
- return data;
- }
-
- public void setSequence(long data) {
- strSequence = data;
- }
-
- public long getSequence() {
- return strSequence;
- }
-
- public void setCalssKeyName(String data) {
- strCalssKeyName = data;
- }
-
- public String getCalssKeyName() {
- if (strCalssKeyName == null) {
- strCalssKeyName = CommonConstants.EMPTY;
- }
- return strCalssKeyName;
- }
-
- public void setTime(long data) {
- strTime = data;
- }
-
- public String getTime() {
- return Formatter.toTimeFormat(strTime);
- }
-
- public void setSceneName(String data) {
-// strSceneName = getDemanglingName(data);
- strSceneName = data;
- }
-
- public String getSceneName() {
- if (strSceneName == null
- || strSceneName.trim().equals(CommonConstants.EMPTY)) {
- strSceneName = CommonConstants.DASH;
- }
- return strSceneName;
- }
-
- public void setTransformTime(String data) {
- strTransformTime = data;
- }
-
- public String getTransformTime() {
- if (strTransformTime == null) {
- strTransformTime = CommonConstants.EMPTY;
- }
- return strTransformTime;
- }
-
- public void setFormName(String data) {
- strFormName = getDemanglingName(data);
- }
-
- public String getFormName() {
- if (strFormName == null
- || strFormName.trim().equals(CommonConstants.EMPTY)) {
- strFormName = CommonConstants.DASH;
- }
- return strFormName;
- }
-
- public void setPanelName(String data) {
- strPanelName = data;
- }
-
- public String getPanelName() {
- if (strPanelName == null
- || strPanelName.trim().equals(CommonConstants.EMPTY)) {
- strPanelName = CommonConstants.DASH;
- }
- return strPanelName;
- }
-
- public String getPID() {
- return Integer.toString(strPID);
- }
-
- public void setPID(int strPID) {
- this.strPID = strPID;
- }
-
- public String getDemanglingName(String name) {
- String demanglingName = CommonConstants.EMPTY;
- StringBuilder childClassNameDemangling = new StringBuilder(name);
- if(!childClassNameDemangling.toString().contains("_Z")){//$NON-NLS-1$
- childClassNameDemangling.insert(0, "_Z");//$NON-NLS-1$
- }
- demanglingName = SymbolManager
- .demanglingFunctionName(childClassNameDemangling.toString());
- return demanglingName;
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Heeyoung Hwang <heeyoung1008.hwang@samsung.com>
- * Hyunjong Park <phjwithyou.park@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.userinterface.scene;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.tizen.dynamicanalyzer.common.SymbolManager;
-import org.tizen.dynamicanalyzer.constant.CommonConstants;
-import org.tizen.dynamicanalyzer.swap.model.data.SceneData;
-import org.tizen.dynamicanalyzer.ui.userinterface.UIDataManager;
-import org.tizen.dynamicanalyzer.utils.Formatter;
-
-public class UISceneDataChecker {
-
- List<UISceneData> transfomSceneList;
-
- public void parserLog(SceneData input) {
- UISceneData sceneData = new UISceneData(input);
- sceneData.setSequence(input.getSeq());
- sceneData.setTime(input.getTime());
- sceneData.setPID(input.getPid());
- sceneData.setSceneName(input.getSceneName());
- sceneData.setFormName(input.getFormName());
- sceneData.setPanelName(input.getPanelName());
- sceneData.setCalssKeyName(getClassName(input));
-
- sceneData
- .setTransformTime(getTransitionTime(input.getTransitionTime()));
-
- getDataList().add(sceneData);
- UIDataManager.getInstance().getFindScreenshotViewHashMap()
- .put(getClassName(input), input.getTime());
- }
-
- public List<UISceneData> getDataList() {
- if (null == transfomSceneList) {
- transfomSceneList = new ArrayList<UISceneData>();
- }
- return transfomSceneList;
- }
-
- private String getTransitionTime(long time) {
- if (time == -1 || time == 0) {
- return "00:00.000";//$NON-NLS-1$
- }
- String strTime = Long.toString(time);
- strTime = strTime + "00";//$NON-NLS-1$
- return Formatter.toTimeFormat(strTime);
- }
-
- public String getClassName(SceneData dataFormat) {
- String className = CommonConstants.EMPTY;
- String panelName = dataFormat.getPanelName();
- if (panelName.trim().equals(CommonConstants.EMPTY)) { //
- className = dataFormat.getFormName();
- } else {
- className = panelName;
- }
- StringBuilder childClassNameDemangling = new StringBuilder(className);
- childClassNameDemangling.insert(0, "_Z");//$NON-NLS-1$
- className = SymbolManager
- .demanglingFunctionName(childClassNameDemangling.toString());
- return className;
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Heeyoung Hwang <heeyoung1008.hwang@samsung.com>
- * Hyunjong Park <phjwithyou.park@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.userinterface.scene;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.nebula.widgets.grid.GridItem;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Composite;
-import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
-import org.tizen.dynamicanalyzer.common.AnalyzerManager;
-import org.tizen.dynamicanalyzer.common.DASelectionData;
-import org.tizen.dynamicanalyzer.common.Global;
-import org.tizen.dynamicanalyzer.model.FilterProperty;
-import org.tizen.dynamicanalyzer.model.TableInput;
-import org.tizen.dynamicanalyzer.project.ImageInfo;
-import org.tizen.dynamicanalyzer.swap.model.data.SceneData;
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
-import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
-import org.tizen.dynamicanalyzer.ui.userinterface.UIDataManager;
-import org.tizen.dynamicanalyzer.ui.userinterface.UIPage;
-import org.tizen.dynamicanalyzer.ui.widgets.table.DATableComposite;
-import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat;
-
-public class UISceneListTable extends DATableComposite {
-
- public UISceneListTable(Composite parent, int style, int tableStyle) {
- super(parent, style, tableStyle);
- setContextMenu(AnalyzerConstants.CONTEXT_TABLE_RANGE);
- table.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- GridItem[] items = table.getSelection();
- if (items.length <= 0) {
- return;
- }
-
- DATableDataFormat dataFormat = (DATableDataFormat) items[0]
- .getData();
-
- SceneData data = (SceneData) dataFormat.getLogData();
-
- String className = UIDataManager.getInstance()
- .getSceneTransformDataChecker().getClassName(data);
-
- UIDataManager.getInstance().setTableSeleteClassName(className);
-
- long time = getScreensotForScene(data.getTime());
-
- DASelectionData selData = new DASelectionData(
- UIPage.sceneListViewID, time, 0, items, table);
- AnalyzerManager.getCurrentPage().updateView(selData);
-
- updateTable();
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
- }
-
- private long getScreensotForScene(long strTime) {
- ImageInfo lastimg = Global.getLeastImageInfoByTime(strTime);
- if(lastimg == null) {
- return strTime;
- } else {
- return lastimg.getTime();
- }
- }
-
- protected List<TableInput> makeTableInput() {
- List<UISceneData> transfomSceneList = UIDataManager.getInstance()
- .getSceneTransformDataChecker().getDataList();
-
- List<TableInput> input = new ArrayList<TableInput>();
- int size = transfomSceneList.size();
- for (int i = 0; i < size; i++) {
-
- int selectedPid = Toolbar.INSTANCE.getSelectedPid();
- if (selectedPid != 0) {
- if (!transfomSceneList.get(i).getPID()
- .equals(Integer.toString(selectedPid))) {
- continue;
- }
- }
-
- List<String> text = new ArrayList<String>();
- UISceneData sceneTransformsData = transfomSceneList.get(i);
- SceneData inputData = (SceneData) sceneTransformsData.getData();
-
- DATableDataFormat tableData = new DATableDataFormat(
- sceneTransformsData.getSequence());
- tableData.setLogData(inputData);
- text.add(sceneTransformsData.getTime()); // Time
- text.add(sceneTransformsData.getPID()); // Precess ID
- text.add(sceneTransformsData.getSceneName()); // Scene Name
- text.add(sceneTransformsData.getFormName()); // Form Name
- text.add(sceneTransformsData.getPanelName()); // Panel Name
- text.add(sceneTransformsData.getTransformTime()); // Panel Name
-
- TableInput tableInput = new TableInput();
- tableInput.setText(text);
- tableInput.setData(tableData);
- input.add(tableInput);
-
- String strSelectedClassname = UIDataManager.getInstance()
- .getTableSeleteClassName();
- if (strSelectedClassname.equals(sceneTransformsData
- .getCalssKeyName())) {
- tableInput.setSecondSelection(true);
- }
-
- if (RangeDataManager.getInstance().isBeingAnalyzed()) {
- long time = tableData.getLogData().getTime();
- long analysisStartTime = RangeDataManager.getInstance()
- .getAnalysisStartTime();
- long analysisEndTime = RangeDataManager.getInstance()
- .getAnalysisEndTime();
- if (time >= analysisStartTime && time <= analysisEndTime) {
- tableInput.setInRange(true);
- }
- }
- }
- return input;
- }
-}
+++ /dev/null
-/*
- * Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Heeyoung Hwang <heeyoung1008.hwang@samsung.com>
- * Hyunjong Park <phjwithyou.park@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.dynamicanalyzer.ui.userinterface.scene;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
-import org.tizen.dynamicanalyzer.common.DASelectionData;
-import org.tizen.dynamicanalyzer.nl.UserInterfacePageLabels;
-import org.tizen.dynamicanalyzer.resources.ColorResources;
-import org.tizen.dynamicanalyzer.ui.userinterface.UIPage;
-import org.tizen.dynamicanalyzer.ui.widgets.table.DATableComposite;
-import org.tizen.dynamicanalyzer.widgets.da.view.DAViewComposite;
-import org.tizen.dynamicanalyzer.widgets.da.view.DAViewData;
-
-public class UISceneListView extends DAViewComposite {
- DATableComposite tableComp = null;
-
- private int[] columnSizes = { 70, 70, 120, 120, 120, 120 };
- private boolean[] columnVisibility = { true, true, true, true, true };
- private int[] columnAlignment = { SWT.RIGHT, SWT.RIGHT, SWT.LEFT, SWT.LEFT,
- SWT.LEFT, SWT.RIGHT };
-
- private String[] columnNames = {
- UserInterfacePageLabels.USERINTERFACE_SCENETRANSFORM_LIST_VIEW_COLUMN_0,
- UserInterfacePageLabels.USERINTERFACE_SCENETRANSFORM_LIST_VIEW_COLUMN_1,
- UserInterfacePageLabels.USERINTERFACE_SCENETRANSFORM_LIST_VIEW_COLUMN_2,
- UserInterfacePageLabels.USERINTERFACE_SCENETRANSFORM_LIST_VIEW_COLUMN_3,
- UserInterfacePageLabels.USERINTERFACE_SCENETRANSFORM_LIST_VIEW_COLUMN_4,
- UserInterfacePageLabels.USERINTERFACE_SCENETRANSFORM_LIST_VIEW_COLUMN_5 };
-
- int[] sortTypes = { AnalyzerConstants.SORT_TYPE_NUM,
- AnalyzerConstants.SORT_TYPE_NUM,
- AnalyzerConstants.SORT_TYPE_STRING,
- AnalyzerConstants.SORT_TYPE_STRING,
- AnalyzerConstants.SORT_TYPE_STRING,
- AnalyzerConstants.SORT_TYPE_STRING };
-
- public UISceneListView(Composite parent, int style) {
- super(parent, style, true);
- this.setLayout(new FillLayout());
-
- setTitle(UserInterfacePageLabels.USERINTERFACE_SCENETRANSFORM_LIST_VIEW_NAME);
-
- Composite contents = getContentArea();
- contents.setBackground(ColorResources.WINDOW_BG_COLOR);
- contents.setLayout(new FillLayout());
- tableComp = new UISceneListTable(contents, SWT.NONE, SWT.MULTI
- | SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
- tableComp
- .setTableName(UserInterfacePageLabels.USERINTERFACE_SCENETRANSFORM_LIST_VIEW_NAME);
- tableComp.setSortTypes(sortTypes);
- tableComp.setColumnAlignment(columnAlignment);
- tableComp.setColumns(columnNames);
- tableComp.setColumnSize(columnSizes);
- tableComp.setColumnVisibility(columnVisibility);
- tableComp.setTableToolTipEnable(false);
-
- }
-
- @Override
- public void updateView() {
- tableComp.updateTable();
- }
-
- @Override
- public void updateView(DAViewData data) {
- if (data instanceof DASelectionData) {
- DASelectionData selData = (DASelectionData) data;
-
- /* only ui page update */
- if (selData.getViewID().equals(UIPage.controlListViewID)
- || selData.getViewID().equals(UIPage.profilingViewID)
- || selData.getViewID().equals(UIPage.sceneListViewID)) {
- tableComp.updateTable();
- }
- }
-
- // other view selection occurred
- tableComp.deselectAll();
- }
-
- @Override
- public void clear() {
- tableComp.clear();
- }
-
- @Override
- public Control getControl() {
- return tableComp;
- }
-}
package org.tizen.dynamicanalyzer.ui.widgets;
import org.eclipse.swt.widgets.Composite;
+import org.tizen.dynamicanalyzer.common.Global;
import org.tizen.dynamicanalyzer.nl.TimelineChartLabels;
+import org.tizen.dynamicanalyzer.project.AppInfo;
import org.tizen.dynamicanalyzer.resources.ColorResources;
import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoard;
import org.tizen.dynamicanalyzer.widgets.lifecycle.LifecycleData;
* preparation phase.
*/
public class DADefaultChartBoard extends DAChartBoard {
+
/**
* Default lifecycle data for preparation phase.
*/
private static final LifecycleData defaultLifecycleData = new LifecycleData(0,
ColorResources.LIFECYCLE_PREPARING, TimelineChartLabels.LIFECYCLE_PREPARING);
+ public DADefaultChartBoard(Composite parent, String title) {
+ super(parent, title);
+ }
+
public DADefaultChartBoard(Composite parent, String title, int boardStyle) {
- super(parent, title, boardStyle, defaultLifecycleData);
+ super(parent, title, boardStyle);
}
public DADefaultChartBoard(Composite parent, String title, int[] scaleValues) {
- super(parent, title, scaleValues, defaultLifecycleData);
+ super(parent, title, scaleValues);
}
- public DADefaultChartBoard(Composite parent, String title) {
- super(parent, title, defaultLifecycleData);
- }
+ @Override
+ protected void reinitLifecycleData() {
+ if (lifecycleBar == null)
+ return;
+ super.reinitLifecycleData();
+ if (Global.getCurrentApplication() != null
+ && !Global.getCurrentApplication().getAppType().equals(AppInfo.APPTYPE_WEB))
+ lifecycleBar.addLifecycleData(defaultLifecycleData);
+ }
}
package org.tizen.dynamicanalyzer.ui.widgets.table;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Date;
import java.util.HashMap;
import java.util.List;
import org.eclipse.nebula.widgets.grid.GridColumn;
import org.eclipse.nebula.widgets.grid.GridItem;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
import org.tizen.dynamicanalyzer.common.SymbolManager.SourceLine;
+import org.tizen.dynamicanalyzer.common.path.PathManager;
import org.tizen.dynamicanalyzer.communicator.IDECommunicator;
import org.tizen.dynamicanalyzer.constant.CommonConstants;
+import org.tizen.dynamicanalyzer.handlers.UIActionHolder;
import org.tizen.dynamicanalyzer.listeners.TableTooltipListener;
import org.tizen.dynamicanalyzer.model.FilterProperty;
import org.tizen.dynamicanalyzer.model.FindProperty;
import org.tizen.dynamicanalyzer.model.TableInput;
-import org.tizen.dynamicanalyzer.nl.TimelineChartLabels;
+import org.tizen.dynamicanalyzer.nl.UserErrorWarningLabels;
+import org.tizen.dynamicanalyzer.project.Project;
import org.tizen.dynamicanalyzer.resources.ColorResources;
import org.tizen.dynamicanalyzer.resources.FontResources;
import org.tizen.dynamicanalyzer.resources.ImageResources;
import org.tizen.dynamicanalyzer.swap.model.data.LogData;
-import org.tizen.dynamicanalyzer.ui.common.PopupAnalysisMenuItemClickListener;
import org.tizen.dynamicanalyzer.ui.memory.table.MemoryPersistentAllocationsTable;
import org.tizen.dynamicanalyzer.ui.memory.table.MemoryStatisticsTable;
-import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
import org.tizen.dynamicanalyzer.ui.widgets.DAGrid;
import org.tizen.dynamicanalyzer.ui.widgets.FilterDialog;
import org.tizen.dynamicanalyzer.ui.widgets.SearchDialog;
*/
private boolean mousePressed;
- protected RangeDataManager rangeDataManager = RangeDataManager.getInstance();
/**
* Length of queue of runnable tasks assigned to the table.
*/
protected static final Image filterImg = ImageResources.COLUMN_FILTER_NORMAL;
protected static final int filterImgOffset = 12;
- private static final int MINIMAL_COLUMN_SIZE = 20;
+ private static final int MINIMAL_COLUMN_SIZE = 30;
public DATableComposite(Composite parent, int style) {
this(parent, SWT.NONE, style);
addMouseWheelListener();
addSelectionListener();
addKeyListener();
+ addCopyItemsToPopup();
+
me = this;
setTableToolTipListener(new TableTooltipListener(table));
dialog.open();
}
}
+ } else if (e.keyCode == 'c' || e.keyCode == SWT.INSERT) {
+ if (ctrlPressed) {
+ ctrlPressed = false;
+ copySelectionToCliboard();
+ }
}
}
});
}
+ /**
+ * Initialize {@code popupMenu} if it is not initialized yet and add "Copy"
+ * item and "Export" item, which purpose is to copy selected table items to
+ * the clip board or entire table to file correspondingly.
+ */
+ private void addCopyItemsToPopup() {
+ if (popupMenu == null) {
+ popupMenu = new DATablePopupMenu(table);
+ popupMenu.setFont(FontResources.CONTEXT_MENU_ITEM_FONT);
+ }
+ if(popupMenu.getItems()!=null && !popupMenu.getItems().isEmpty())
+ new DAPopupMenuItem(popupMenu, DAPopupMenuItem.SEPARATOR);
+ DAPopupMenuItem copy = new DAPopupMenuItem(popupMenu);
+ copy.setText("Copy");
+ copy.addListener(new DAPopupMenuListener() {
+ @Override
+ public void widgetSelected(DAPopupMenuItem menuItem) {
+ copySelectionToCliboard();
+ }
+ });
+ DAPopupMenuItem export = new DAPopupMenuItem(popupMenu);
+ export.setText("Export to file");
+ export.addListener(new DAPopupMenuListener() {
+ @Override
+ public void widgetSelected(DAPopupMenuItem menuItem) {
+ exportTableToFile();
+ }
+ });
+ }
+
+ /**
+ * Copy selection data of the table to clip board.
+ */
+ private void copySelectionToCliboard() {
+ final Clipboard clip = new Clipboard(getDisplay());
+ String txt = getFormatedString(table.getSelection(), CommonConstants.TAB);
+ Object[] textData = new Object[] { txt };
+ Transfer[] textTransfer = new Transfer[] { TextTransfer.getInstance() };
+ clip.setContents(textData, textTransfer);
+ }
+
+ /**
+ * Open {@link FileDialog} to specify destination file and copy entire data
+ * of the table to the file. Data will be stored in TSV.
+ */
+ private void exportTableToFile() {
+ FileDialog fd = new FileDialog(getShell(), SWT.SAVE);
+ fd.setFilterPath(PathManager.DA_SAVE_PATH);
+ fd.setText("Export table to file");
+ fd.setFileName(Project.constructSaveName(getTableName(), new Date()) + ".tsv");
+ String path = fd.open();
+ if (path == null)
+ return;
+ File dest = new File(path);
+ String txt = getFormatedString(table.getItems(), CommonConstants.TAB);
+ if (dest.exists() && !dest.delete()) {
+ UIActionHolder.getUIAction()
+ .showWarning(UserErrorWarningLabels.ERR_FAILED_TO_DELETE_FILE + ' ' + path);
+ Logger.info(UserErrorWarningLabels.ERR_FAILED_TO_DELETE_FILE + ' ' + path);
+ return;
+ }
+ try (FileWriter fo = new FileWriter(dest)) {
+ fo.write(txt);
+ fo.flush();
+ } catch (IOException e) {
+ UIActionHolder.getUIAction()
+ .showWarning(UserErrorWarningLabels.ERR_FAILED_TO_WRITE_TO_FILE);
+ Logger.error(e);
+ }
+ }
+
+ /**
+ * Build String representation of data from {@code source} and put it into
+ * string, where values separated with {@code delimiter} and rows separated
+ * with {@code CommonConstants.NEW_LINE}.
+ *
+ * @param source GridItems to be copied
+ * @param delimiter Character to separate values in row
+ *
+ * @return String in delimiter-separated format.
+ */
+ private String getFormatedString(GridItem[] source, String delimiter) {
+ StringBuilder sb = new StringBuilder();
+ for (GridItem item : source) {
+ for (int i = 0; i < table.getColumnCount(); i++) {
+ if (table.getColumn(i).isVisible()) {
+ if (item.getText(i).contains(delimiter)) {
+ sb.append('"');
+ sb.append(item.getText(i));
+ sb.append('"');
+ } else {
+ sb.append(item.getText(i));
+ }
+ sb.append(delimiter);
+ }
+ }
+ sb.deleteCharAt(sb.length() - 1);
+ sb.append(CommonConstants.NEW_LINE);
+ }
+ return sb.toString();
+ }
+
public void setTree(boolean tree) {
isTree = tree;
}
}
tableClone.addAll(input);
if (null != comparator) {
- Collections.sort(input, comparator);
+ // TODO Time Consuming Process : make progress bar for this task
+ // or move this in another thread in the future.
+ sortTable(input);
}
int[] sels = new int[selSeqs.size()];
int iii = 0;
table.update();
}
+ /**
+ * Sort input data rows by item stored in {@code comparator.column} field.
+ * Add "sort" icon to corresponding column. If table is filtered, it can not
+ * be sorted by the column on which has been filtered.
+ *
+ * @param input input data
+ */
+ protected void sortTable(List<? extends TableInput> input) {
+ GridColumn c = table.getColumn(comparator.column);
+ if (c.getImage() != null && ImageResources.FILTER_IMAGES.contains(c.getImage()))
+ // Filtered by value in this column
+ return;
+ for (GridColumn column : table.getColumns()) {
+ if (c.equals(column))
+ continue;
+ column.setSort(SWT.NONE);
+ if (!ImageResources.FILTER_IMAGES.contains(column.getImage())) {
+ column.setImage(null);
+ }
+ }
+ c.setSort(comparator.dirUp ? SWT.UP : SWT.DOWN);
+ Collections.sort(input, comparator);
+ }
+
protected abstract List<TableInput> makeTableInput();
public HashMap<Long, Long> getSelections() {
filterPropertyList.clear();
}
- protected void actionSetStartEnd(int type) {
- GridItem item = table.getItem(mousePoint);
- if (null != item) {
- LogData data = ((DATableDataFormat) item.getData()).getLogData();
- long inputTime = data.getTime();
- if (type == START_TIME) {
- rangeDataManager.setMarkerStartTime(inputTime);
- } else if (type == END_TIME) {
- rangeDataManager.setMarkerEndTime(inputTime);
- }
- }
- }
-
public void setContextMenu(final int context) {
if (popupMenu == null) {
popupMenu = new DATablePopupMenu(table);
popupMenu.setFont(FontResources.CONTEXT_MENU_ITEM_FONT);
}
- if ((context & AnalyzerConstants.CONTEXT_TABLE_RANGE) != 0) {
- if(popupMenu.getItems()!=null && !popupMenu.getItems().isEmpty())
- new DAPopupMenuItem(popupMenu, DAPopupMenuItem.SEPARATOR);
- setRangeContext();
- }
if ((context & AnalyzerConstants.CONTEXT_TABLE_SOURCE) != 0) {
if(popupMenu.getItems()!=null && !popupMenu.getItems().isEmpty())
new DAPopupMenuItem(popupMenu, DAPopupMenuItem.SEPARATOR);
}
String text = menuItem.getText(); // TODO need to identity method instead of String
- if (text.equals(TimelineChartLabels.RANGE_CONTEXT_SET_START)
- || text.equals(TimelineChartLabels.RANGE_CONTEXT_SET_END)) {
- if (!menuItem.isEnabled()) {
- menuItem.setEnabled(true);
- }
- } else if (text.equals(TimelineChartLabels.RANGE_CONTEXT_ANALYSIS)) {
- if (rangeDataManager.isAnalyzable()) {
- menuItem.setEnabled(true);
- } else {
- menuItem.setEnabled(false);
- }
- } else if (text.equals(TimelineChartLabels.RANGE_CONTEXT_CLEAR)) {
- if (rangeDataManager.isBeingAnalyzed()) {
- menuItem.setEnabled(true);
- } else {
- menuItem.setEnabled(false);
- }
- } else if (text.equals("View caller source")) {
+ if (text.equals("View caller source")) {
SourceLine sl = tableListener.getCallerSourceLine(gridItem);
if (null == sl || sl.getError() != AnalyzerConstants.SOURCELINE_NOERROR) {
menuItem.setEnabled(false);
});
}
- private void setRangeContext() {
- DAPopupMenuItem startItem = new DAPopupMenuItem(popupMenu);
- startItem.setText(TimelineChartLabels.RANGE_CONTEXT_SET_START);
- startItem.addListener(new DAPopupMenuListener() {
- @Override
- public void widgetSelected(DAPopupMenuItem menuItem) {
- actionSetStartEnd(START_TIME);
- }
- });
-
- DAPopupMenuItem endItem = new DAPopupMenuItem(popupMenu);
- endItem.setText(TimelineChartLabels.RANGE_CONTEXT_SET_END);
- endItem.addListener(new DAPopupMenuListener() {
-
- @Override
- public void widgetSelected(DAPopupMenuItem menuItem) {
- actionSetStartEnd(END_TIME);
- }
- });
-
- DAPopupMenuItem analysisItem = new DAPopupMenuItem(popupMenu);
- analysisItem.setText(TimelineChartLabels.RANGE_CONTEXT_ANALYSIS);
- analysisItem.addListener(new PopupAnalysisMenuItemClickListener());
-
- DAPopupMenuItem clearItem = new DAPopupMenuItem(popupMenu);
- clearItem.setText(TimelineChartLabels.RANGE_CONTEXT_CLEAR);
- clearItem.addListener(new DAPopupMenuListener() {
- @Override
- public void widgetSelected(DAPopupMenuItem menuItem) {
- rangeDataManager.initRange();
- }
- });
- }
-
public void setAutoColumnPackEnabled(boolean enabled) {
autoColumnPack = enabled;
}
return;
}
+ cleanColumnsImages();
+ table.getColumn(index).setImage(ImageResources.DA_IC_FILTER);
+ table.getColumn(index).setSort(SWT.NONE);
String startData = item.getText(index);
filterTable(startData, index);
}
@Override
public void widgetSelected(DAPopupMenuItem menuItem) {
isFilter = false;
+ cleanColumnsImages();
updateTable();
}
});
}
/**
+ * Remove images from columns' headers. For all table's columns predefined
+ * images is set to null.
+ */
+ private void cleanColumnsImages() {
+ for (GridColumn column : table.getColumns()) {
+ column.setImage(null);
+ }
+ }
+
+ /**
* Method to filter table that will hide elements with specified field
* differ from specified value.
*
import org.eclipse.nebula.widgets.grid.GridColumn;
import org.eclipse.nebula.widgets.grid.internal.CheckBoxRenderer;
import org.eclipse.nebula.widgets.grid.internal.DefaultColumnHeaderRenderer;
-import org.eclipse.nebula.widgets.grid.internal.SortArrowRenderer;
import org.eclipse.nebula.widgets.grid.internal.TextUtils;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display;
import org.tizen.dynamicanalyzer.resources.ColorResources;
import org.tizen.dynamicanalyzer.resources.FontResources;
+import org.tizen.dynamicanalyzer.resources.ImageResources;
public class DATableHeaderRenderer extends DefaultColumnHeaderRenderer {
int leftMargin = 6;
int rightMargin = 6;
- int topMargin = 3;
- // int bottomMargin = 3;
- int arrowMargin = 6;
+
int insideMargin = 3;
+ int imageRightMargin = 9;
int alignment;
boolean check = false;
Color bgColor = ColorResources.TABLE_HEADER_BG;
Color fontColor = ColorResources.TABLE_HEADER_FONT_COLOR;
- private SortArrowRenderer arrowRenderer = new SortArrowRenderer();
protected CheckBoxRenderer checkRenderer = null;
public DATableHeaderRenderer() {
- alignment = SWT.CENTER;
+ alignment = SWT.LEFT;
}
public DATableHeaderRenderer(int style) {
public void setDisplay(Display display) {
super.setDisplay(display);
- arrowRenderer.setDisplay(display);
if (checkRenderer != null) {
checkRenderer.setDisplay(display);
}
boolean flat = (column.getParent().getCellSelectionEnabled() && !column.getMoveable());
+ // drawSelected means that item is clicked.
boolean drawSelected = ((isMouseDown() && isHover()));
// column bg color
pushedDrawingOffset = 1;
}
+ // x - current offset from left side
int x = leftMargin;
if (check) {
x += checkRenderer.getBounds().width + insideMargin;
}
- if (column.getImage() != null) {
- gc.drawImage(column.getImage(), getBounds().x + x + pushedDrawingOffset, getBounds().y
- + topMargin + pushedDrawingOffset);
- x += column.getImage().getBounds().width + insideMargin;
- }
-
+ // width of remained space inside column header
int width = getBounds().width - x;
- if (column.getSort() == SWT.NONE) {
- width -= rightMargin;
+ // If table sorted or any Image associated with the current column the
+ // corresponding image should be printed at right of the column's
+ // header.
+ if (column.getImage() != null || column.getSort() != SWT.NONE) {
+ column.setImage(refineImage(column));
+
+ gc.drawImage(column.getImage(),
+ getBounds().x + getBounds().width - imageRightMargin - column.getImage().getBounds().width
+ +pushedDrawingOffset,
+ getBounds().y + (getBounds().height - column.getImage().getBounds().height) / 2
+ + pushedDrawingOffset);
+ width -= column.getImage().getBounds().width + insideMargin + imageRightMargin;
} else {
- width -= arrowMargin + arrowRenderer.getSize().x + arrowMargin;
+ width -= rightMargin;
}
// font color
gc.setForeground(fontColor);
gc.setFont(FontResources.TABLE_HEADER_FONT);
+ // Define short text representation
String inputText = TextUtils.getShortString(gc, column.getText(), width);
Point textSize = gc.textExtent(inputText, SWT.DRAW_MNEMONIC);
int textX;
if (alignment == SWT.CENTER) {
- textX = r.x + (r.width - textSize.x) / 2;
+ textX = r.x + x + (width - textSize.x) / 2;
} else if (alignment == SWT.LEFT) {
textX = r.x + x;
} else {
- textX = r.x + r.width - textSize.x - rightMargin;
+ textX = r.x + x + width - textSize.x;
}
int y = getBounds().y + (getBounds().height - textSize.y) / 2;
gc.drawString(inputText, textX + pushedDrawingOffset, y + pushedDrawingOffset, true);
+ }
- if (column.getSort() != SWT.NONE) {
- arrowRenderer.setSelected(column.getSort() == SWT.UP);
- if (drawSelected) {
- arrowRenderer.setLocation(getBounds().x + getBounds().width - arrowMargin
- - arrowRenderer.getBounds().width + 1, getBounds().y
- + ((getBounds().height - arrowRenderer.getBounds().height) / 2) + 1);
- } else {
- arrowRenderer.setLocation(getBounds().x + getBounds().width - arrowMargin
- - arrowRenderer.getBounds().width, getBounds().y
- + ((getBounds().height - arrowRenderer.getBounds().height) / 2));
- }
- arrowRenderer.paint(gc, null);
+ /**
+ * Define the actual image for the header of the given {@code column},
+ * depending on the sort and filter state.
+ *
+ * @param column {@link GridColumn} which image should be refined
+ * @return {@link Image} to add to {@code column}'s header
+ */
+ private Image refineImage(GridColumn column) {
+ if (column.getSort() == SWT.NONE
+ && ImageResources.FILTER_IMAGES.contains(column.getImage())) {
+ if (isHover())
+ if (isMouseDown())
+ return ImageResources.DA_IC_FILTER_PRESSED;
+ else
+ return ImageResources.DA_IC_FILTER_OVER;
+ else
+ return ImageResources.DA_IC_FILTER;
+ }
+ if (column.getSort() == SWT.UP) {
+ if (isHover())
+ if (isMouseDown())
+ return ImageResources.SORTED_INC_SELECTED;
+ else
+ return ImageResources.SORTED_INC_OVER;
+ else
+ return ImageResources.SORTED_INC;
+ }
+ if (column.getSort() == SWT.DOWN) {
+ if (isHover())
+ if (isMouseDown())
+ return ImageResources.SORTED_DESC_SELECTED;
+ else
+ return ImageResources.SORTED_DESC_OVER;
+ else
+ return ImageResources.SORTED_DESC;
}
+ return column.getImage();
}
}
table.clearFiltering();
}
}
+
+ /**
+ * Check if specified table is created and return link to it.
+ *
+ * @param name table class name
+ * @return {@link DATableComposite} representing specified table or null if
+ * it is not created.
+ */
+ public static DATableComposite getTable(String name) {
+ for (DATableComposite table : tables) {
+ if (table.getClass().getName().equals(name))
+ return table;
+ }
+ return null;
+ }
}
package org.tizen.dynamicanalyzer.ui.widgets.table;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
// !! recursive
private void createTree(List<TreeInput> input, Object parent) {
if (null != comparator) {
- Collections.sort(input, comparator);
+ sortTable(input);
}
int rootSize = input.size();
// -- loop?
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.ScrollBar;
import org.eclipse.swt.widgets.Shell;
import org.tizen.dynamicanalyzer.common.DAState;
previousItemCount = -1;
}
- @Override
- protected void actionSetStartEnd(int type) {
- GridItem item = table.getItem(mousePoint);
- if (null != item) {
- long inputTime = (Long) ((DATableDataFormat) item.getData()).getData().get(
- timeColumnIndex);
-
- if (type == START_TIME) {
- rangeDataManager.setMarkerStartTime(inputTime);
- } else if (type == END_TIME) {
- rangeDataManager.setMarkerEndTime(inputTime);
- }
- }
- }
-
protected List<List<Object>> getQueriedObjectData() {
return queriedObjectData;
}
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
public class ZipUtils {
- private static final int COMPRESSION_LEVEL = 8;
-
- private static final int BUFFER_SIZE = 1024 * 2;
-
- /**
- * Compress to output file
- * @param sourcePath - Target directory
- * @param output - zip file name
- * @throws Exception
- */
- public static void zip(String sourcePath, String output) throws Exception {
-
- // If sourcePath is not a directory, make exception.
- File sourceFile = new File(sourcePath);
- if (!sourceFile.isFile() && !sourceFile.isDirectory()) {
- throw new Exception("Can't find directory.");
- }
-
- //
- if(!output.toLowerCase().endsWith(".zip") ) {
- output += ".zip";
- }
-
- FileOutputStream fos = null;
- BufferedOutputStream bos = null;
- ZipOutputStream zos = null;
-
- try {
- fos = new FileOutputStream(output);
- bos = new BufferedOutputStream(fos);
- zos = new ZipOutputStream(bos);
- zos.setLevel(COMPRESSION_LEVEL); // Compression level - Max 9, Default 8
- zipEntry(sourceFile, sourcePath, zos); // make Zip file
- zos.finish(); // ZipOutputStream finish
- } finally {
- if (zos != null) {
- zos.close();
- }
- if (bos != null) {
- bos.close();
- }
- if (fos != null) {
- fos.close();
- }
- }
- }
-
- /**
- * Compress
- * @param sourceFile
- * @param sourcePath
- * @param zos
- * @throws Exception
- */
- private static void zipEntry(File sourceFile, String sourcePath, ZipOutputStream zos) throws Exception {
- // If sourceFile is a directory, call zipEntry again.
- if (sourceFile.isDirectory()) {
- if (sourceFile.getName().equalsIgnoreCase(".metadata")) { // .metadata is unnecessary.
- return;
- }
- File[] fileArray = sourceFile.listFiles(); // children files of sourceFile
- for (int i = 0; i < fileArray.length; i++) {
- zipEntry(fileArray[i], sourcePath, zos);
- }
- } else { // sourcehFile is a file
- BufferedInputStream bis = null;
- try {
- String sFilePath = sourceFile.getPath();
- String zipEntryName = sFilePath.substring(sourcePath.length() + 1, sFilePath.length());
-
- bis = new BufferedInputStream(new FileInputStream(sourceFile));
- ZipEntry zentry = new ZipEntry(zipEntryName);
- zentry.setTime(sourceFile.lastModified());
- zos.putNextEntry(zentry);
-
- byte[] buffer = new byte[BUFFER_SIZE];
- int cnt = 0;
- while ((cnt = bis.read(buffer, 0, BUFFER_SIZE)) != -1) {
- zos.write(buffer, 0, cnt);
- }
- zos.closeEntry();
- } finally {
- if (bis != null) {
- bis.close();
- }
- }
- }
- }
-
- /**
- * Decompress Zip file
- *
- * @param zipFile
- * @param targetDir
- * @param fileNameToLowerCase
- * @throws Exception
- */
- public static void unzip(File zipFile, File targetDir, boolean fileNameToLowerCase) throws Exception {
- FileInputStream fis = null;
- ZipInputStream zis = null;
- ZipEntry zentry = null;
-
- try {
- fis = new FileInputStream(zipFile); // FileInputStream
- zis = new ZipInputStream(fis); // ZipInputStream
-
- while ((zentry = zis.getNextEntry()) != null) {
- String fileNameToUnzip = zentry.getName();
- if (fileNameToLowerCase) { // fileName toLowerCase
- fileNameToUnzip = fileNameToUnzip.toLowerCase();
- }
-
- File targetFile = new File(targetDir, fileNameToUnzip);
-
- if (zentry.isDirectory()) {
- File childFolder = new File(targetFile.getAbsolutePath());
- if(!childFolder.exists()) {
- childFolder.mkdirs();
- }
- } else {
- File parentFolder = new File(targetFile.getParent());
- if(!parentFolder.exists()) {
- parentFolder.mkdirs();
- }
- unzipEntry(zis, targetFile);
- }
- }
- } finally {
- if (zis != null) {
- zis.close();
- }
- if (fis != null) {
- fis.close();
- }
- }
- }
-
- /**
- * Decompress one Zip file
- *
- * @param zis - Zip Input Stream
- * @param filePath
- * @return
- * @throws Exception
- */
- protected static File unzipEntry(ZipInputStream zis, File targetFile) throws Exception {
- FileOutputStream fos = null;
- try {
- fos = new FileOutputStream(targetFile);
-
- byte[] buffer = new byte[BUFFER_SIZE];
- int len = 0;
- while ((len = zis.read(buffer)) != -1) {
- fos.write(buffer, 0, len);
- }
- } finally {
- if (fos != null) {
- fos.close();
- }
- }
- return targetFile;
- }
+ private static final int COMPRESSION_LEVEL = 8;
+
+ private static final int BUFFER_SIZE = 1024 * 2;
+
+ private static final String METADATA = ".metadata";
+
+ /**
+ * Compress collected trace into the specified zip file. If path to file
+ * does not exist, it will be created, if creation is permitted.
+ *
+ * @param sourcePath path to the collected trace
+ * @param output full name of the specified zip file
+ * @return {@code true} if trace archived successfully
+ * @throws IOException if any IOExceptions occurred during archiving
+ */
+ public static boolean zip(String sourcePath, String output) throws IOException {
+
+ // If sourcePath is not a directory, make exception.
+ File sourceFile = new File(sourcePath);
+ if (!sourceFile.isFile() && !sourceFile.isDirectory()) {
+ Logger.error("Can't find directory " + sourcePath);
+ return false;
+ }
+
+ File target = new File(output);
+ File tParent = target.getParentFile();
+ if ((!tParent.exists() || !tParent.isDirectory()) && !tParent.mkdirs()) {
+ Logger.error("Can't create directory for output file "+output);
+ return false;
+ }
+
+ if (!output.toLowerCase().endsWith(".zip")) {
+ output += ".zip";
+ }
+
+ try (FileOutputStream fos = new FileOutputStream(output);
+ ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(fos))) {
+ zos.setLevel(COMPRESSION_LEVEL); // Compression level - Max 9,
+ // Default 8
+ zipEntry(sourceFile, sourcePath, zos); // make Zip file
+ zos.finish(); // ZipOutputStream finish
+ }
+ return true;
+ }
+
+ /**
+ * Recursively compress {@link File} into zip archive: Compress file as is
+ * if it is not directory, and compress all child files otherwise.
+ *
+ * @param sourceFile file or directory to copy
+ * @param sourcePath path to {@code sourceFile}
+ * @param zos stream to zip archive
+ * @throws IOException if any occurres
+ */
+ private static void zipEntry(File sourceFile, String sourcePath, ZipOutputStream zos)
+ throws IOException {
+ // If sourceFile is a directory, call zipEntry again.
+ if (sourceFile.isDirectory()) {
+ if (sourceFile.getName().equalsIgnoreCase(METADATA)) { // .metadata is unnecessary.
+ return;
+ }
+ File[] fileArray = sourceFile.listFiles(); // children files of sourceFile
+ for (int i = 0; i < fileArray.length; i++) {
+ zipEntry(fileArray[i], sourcePath, zos);
+ }
+ } else { // sourcehFile is a file
+ try (BufferedInputStream bis = new BufferedInputStream(
+ new FileInputStream(sourceFile));) {
+ String sFilePath = sourceFile.getPath();
+ String zipEntryName = sFilePath.substring(sourcePath.length() + 1,
+ sFilePath.length());
+
+ ZipEntry zentry = new ZipEntry(zipEntryName);
+ zentry.setTime(sourceFile.lastModified());
+ zos.putNextEntry(zentry);
+
+ byte[] buffer = new byte[BUFFER_SIZE];
+ int cnt = 0;
+ while ((cnt = bis.read(buffer, 0, BUFFER_SIZE)) != -1) {
+ zos.write(buffer, 0, cnt);
+ }
+ zos.closeEntry();
+ }
+ }
+ }
+
+ /**
+ * Extract zip file to the specified target directory.
+ *
+ * @param zipFile archive to extract
+ * @param targetDir target directory
+ * @param fileNameToLowerCase indicate whether file names of extracted files
+ * should be turned to lower case or not
+ * @throws IOException if any occurres
+ */
+ public static void unzip(File zipFile, File targetDir, boolean fileNameToLowerCase)
+ throws IOException {
+ ZipEntry zentry = null;
+
+ try (FileInputStream fis = new FileInputStream(zipFile);
+ ZipInputStream zis = new ZipInputStream(fis)) {
+
+ while ((zentry = zis.getNextEntry()) != null) {
+ String fileNameToUnzip = zentry.getName();
+ if (fileNameToLowerCase) { // fileName toLowerCase
+ fileNameToUnzip = fileNameToUnzip.toLowerCase();
+ }
+
+ File targetFile = new File(targetDir, fileNameToUnzip);
+
+ if (zentry.isDirectory()) {
+ File childFolder = new File(targetFile.getAbsolutePath());
+ if (!childFolder.exists()) {
+ childFolder.mkdirs();
+ }
+ } else {
+ File parentFolder = new File(targetFile.getParent());
+ if (!parentFolder.exists()) {
+ parentFolder.mkdirs();
+ }
+ unzipEntry(zis, targetFile);
+ }
+ }
+ }
+ }
+
+ /**
+ * Extract zip entry into file or directory.
+ *
+ * @param zis {@link ZipInputStream} stream from zip archive.
+ * @param targetFile {@link File} target file
+ * @throws IOException
+ */
+ protected static void unzipEntry(ZipInputStream zis, File targetFile) throws IOException {
+ try (FileOutputStream fos = new FileOutputStream(targetFile)) {
+
+ byte[] buffer = new byte[BUFFER_SIZE];
+ int len = 0;
+ while ((len = zis.read(buffer)) != -1) {
+ fos.write(buffer, 0, len);
+ }
+ }
+ }
}
\ No newline at end of file
+* 2.5.1
+- Fix a regression of hidden in tracing time Call Trace table (regression in DA 2.5.0)
+- Show filter icon after filtering above sorting (SRADA-1364)
+- Fix a regression of inserting an "unknown" API item into callstack (SRADA-1362)
+- Disable sorting in Memory Details table (SRADA-1366)
+- Fix popup menu behavior broken with previous redesign of callstack (regression in DA 2.5.0)
+- Improve memory usage and performance for HeapAllocation profiling (SRADA-1231)
+ - Add primary keys and indexes for database tables
+ - Update HSQLDB to 2.3.4 version
+ - Heavy queries to database are executed in separate threads
+ - All data calculation for Statistics and Persistent Allocations tables is
+ moved to database
+ - Increase max memory available to DA from 512MB to 1GB
+- Fix incorrect memory map building (SRADA-1327)
+- Add device serial number to pop-up notifications (SRADA-1255)
+- Removed redundant double updates in left table views (SRADA-1374)
+ - Remove deprecated logic related to Interactive, Kernel, Range Analysis
+ and User Interface pages
+ - Replace 'Analyze range' pop-up menu item for charts with 'Select range'
+- Fix synchronization issues in DeviceManager and NotificationManager (regression in DA 2.5.0)
+- Fix NullPointerException in TableTooltipListener (SRADA-1390)
+- Fix JIRA defects:
+ SPTSDKUX-3428: Tracing data is not being saved in given path but no failure message shown
+== Dmitriy Nikiforov <d.nikiforov@partner.samsung.com> February 28, 2017
+* 2.5.0
+- Fix bug with incorrect callstack construction (SRADA-1274):
+ - Callstack is shown only after tracing is stopped
+ - Function Profiling data processing totally redesigned
+- Fix behaviour of Cancel button in start tracing progress bar (SRADA-1105)
+- Fix memory map building (SRADA-1327)
+- Fix bug with Core Usage feature not working when it's only one selected (SRADA-947)
+- Fix Memory Callstack table to be shown only when needed (SRADA-1350)
+- Enable function profiling for application libraries (SRADA-1287)
+- Show memory map for selected time (SRADA-1116)
+- Add ability to copy data from tables (SRADA-1226)
+- Add ability to export data from tables to file (SRADA-1336)
+- Add filter/sort icons for the tables (SRADA-1334)
+- Add notification popups on devices connect/disconnect (SRADA-1255)
+- Add target connection status icons in Feature dialog (SRADA-1254)
+- Add guide text on timeline page if connected device doesn't match selected (SRADA-1256)
+- Add possibility to configure features in Feature dialog (SRADA-1333)
+- Disable logging of SWAP messages by default to improve performance (SRADA-1348)
+- Improve memory usage for HeapAllocation profiling (SRADA-1231)
+- Refactor HeapDataManager class (SRADA-1231)
+- Java version compliance changed to 1.8 in main pom.xml and in projects: org.tizen.dynamicanalyzer,
+org.tizen.dynamicanalyzer.widgets
+- Fix JIRA defects:
+ SPTSDKUX-2998 Lifecycle bar is showing wrong status for web project
+== Maria Guseva <m.guseva@samsung.com> February 08, 2017
* 2.4.5
-== Maria Guseva <m.guseva@samsung.com> December 21, 2016
- Add native widget applications to blacklist
- Update warning message text for unsupported applications
- Fix JIRA defects:
SPTSDKUX-2885: UI is distorted while clicking on screenshot feature in prefrences window.
SPTSDKUX-2966: Search not working for Range Analysis tab
SPTSDKUX-2972: Dynamic analyzer placement is change when check / uncheck Detail option from View menu
+== Maria Guseva <m.guseva@samsung.com> December 21, 2016
* 2.4.4
- Apply a workaround for non-root sdbd
- Make Persistent Allocations table to be hidden by default
* 2.4.1
- Add support for multi-application packages
- Fix Persistent Allocations table update after filtering
+- Improve table columns resize behaviour
- Fix FindBugs issues of Performance category in widgets and common packages
- Fix JIRA defects:
SPTSDKUX-2449: Error Pop-up shows for the First time when clicking on start Trace for Web Project on Emulator (UIHV)
Source:dynamic-analyzer
-Version:2.4.5
+Version:2.5.1
Maintainer:Gihun Chang <gihun.chang@samsung.com>, WooJin Jung <woojin2.jung@samsung.com>, Jaewon Lim <jaewon81.lim@samsung.com>, Seokgil Kang <seokgil.kang@samsung.com>
Package:dynamic-analyzer-product
<modelVersion>4.0.0</modelVersion>
<groupId>org.tizen.dynamicanalyzer</groupId>
<artifactId>dynamic-analyzer</artifactId>
- <version>2.4.5-SNAPSHOT</version>
+ <version>2.5.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<version>${tycho-version}</version>
<configuration>
<compilerArgument>-warn:+discouraged,forbidden</compilerArgument>
- <source>1.7</source>
- <target>1.7</target>
+ <source>1.8</source>
+ <target>1.8</target>
</configuration>
<dependencies>
<dependency>