From: jungwook.ryu Date: Wed, 2 Apr 2014 08:20:06 +0000 (+0900) Subject: [Title] Revision Table Context menu X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4f5e2eb88bfb8b1c847f3e38fec34b1eeb7e8f9c;p=sdk%2Ftools%2Fdynamic-analyzer.git [Title] Revision Table Context menu [Desc.] view caller, definition source on popup & open caller, definition source on IDE. it implemented in calltrace table. [Issue] - --- diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerConstants.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerConstants.java index 301e4c2..3f00146 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerConstants.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerConstants.java @@ -1,324 +1,327 @@ -/* - * Dynamic Analyzer - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * Jooyoul Lee - * Juyoung Kim - * - * 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.common; - -import org.tizen.dynamicanalyzer.nl.AnalyzerLabels; - -public class AnalyzerConstants { - // if log change occurs then increase save data version!! - public static final String SAVE_DATA_VERSION = "0.88"; //$NON-NLS-1$ - public static final boolean CHECK_INTERNAL = true; - - public static final String DA_VERSION_SWAP = "3.0"; - public static final String DA_VERSION_OLD = "2.2"; - - /* folder names */ - public static final String TEMP_FOLDER_RUN_PREFIX = ".RUN"; //$NON-NLS-1$ - public static final String IMAGE_FOLDER_NAME = "img"; //$NON-NLS-1$ - public static final String SMALL_IMAGE_FOLDER_NAME = "small"; //$NON-NLS-1$ - public static final String XML_FOLDER_NAME = "xml"; //$NON-NLS-1$ - public static final String LICENSE_FILE_NAME = "license"; //$NON-NLS-1$ - public static final String USER_INTERFACE_API_LIST_FILE_NAME = "user_interface_api_list"; //$NON-NLS-1$ - - public static final String API_NAME_FILE_NAME = "apis"; //$NON-NLS-1$ - - public static final String READELF_BIN = "readelf"; //$NON-NLS-1$ - - public static final String VERSION_NAME = "version"; //$NON-NLS-1$ - public static final String DATABASE_NAME = "da.trace"; //$NON-NLS-1$ - public static final String DEFAULT_IMAGE_NAME = "noImage.jpg"; //$NON-NLS-1$ - public final static String PROBE_LIB_TIZEN = "da_probe_tizen.so"; //$NON-NLS-1$ - public final static String PROBE_LIB_OSP = "da_probe_osp.so"; //$NON-NLS-1$ - - /* Save Data table */ - public static final String LEAK_DATA_TABLE_NAME = "LeakData"; //$NON-NLS-1$ - public static final String FAILED_DATA_TABLE_NAME = "FailedData"; //$NON-NLS-1$ - - /* thread names */ - public static final String LOG_QUEUE_OBSERVING_THREAD = "Log Queue Observing thread"; //$NON-NLS-1$ - public static final String COMMUNICATOR_RECEIVE_THREAD = "Communicator Receive Thread"; //$NON-NLS-1$ - public static final String MESSAGE_INTERNAL_IMAGE_THREAD = "Internal Image Process Thread"; //$NON-NLS-1$ - public static final String STOP_LOG_THREAD = "Stop Log Thread"; //$NON-NLS-1$ - public static final String BATTERY_RECEIVE_THREAD = "Battery Receive Thread"; //$NON-NLS-1$ - public static final String SLP_APP_RUN_THREAD = "SLP App Run Thread"; //$NON-NLS-1$ - public static final String OPEN_TRACE_THREAD = "Open trace input thread"; //$NON-NLS-1$ - public static final String INSERT_LOG_THREAD = "Insert log thread"; //$NON-NLS-1$ - public static final String IDE_COMMUNICATOR_THREAD = "IDE Communicator thread"; //$NON-NLS-1$ - public static final String SEND_MESSAGE_THREAD = "Send message thread"; //$NON-NLS-1$ - public static final String START_STOP_THREAD = "Start stop thread"; //$NON-NLS-1$ - public static final String FILE_CHART_MANAGER_THREAD = "File Chart Manager thread"; //$NON-NLS-1$ - public static final String THREAD_CHART_MANAGER_THREAD = "Thread Chart Manager thread"; //$NON-NLS-1$ - public static final String NETWORK_CHART_MANAGER_THREAD = "Network Chart Manager thread"; //$NON-NLS-1$ - public static final String KERNEL_CHART_MANAGER_THREAD = "Kernel Chart Manager thread"; //$NON-NLS-1$ - public static final String FUNCTION_USAGE_PROFILING_THREAD = "Function usage profiling thread"; //$NON-NLS-1$ - public static final String USER_INTERFACE_PAGE_MANAGER_THREAD = "User Interface Page Managerthread"; //$NON-NLS-1$ - public static final String SQL_INSERTER_THREAD = "sql_inserter_thread"; //$NON-NLS-1$ - public static final String HEART_BEAT_THREAD = "heart beat thread"; //$NON-NLS-1$ - - /* log parsing token and callstack parsing token, etc... */ - public static final String CALLSTACK_START = "callstack_start"; //$NON-NLS-1$ - public static final String CALLSTACK_END = "callstack_end"; //$NON-NLS-1$ - public static final String CALLSTACK_CUT_MEMORY_TOKEN = "\\["; //$NON-NLS-1$ - public static final String CALLSTACK_API_TOKEN = "\\("; //$NON-NLS-1$ - public static final String CALLSTACK_API_TOKEN_STRING = "("; //$NON-NLS-1$ - public static final String CALLSTACK_API_EMPTY_TOKEN = "\\)"; //$NON-NLS-1$ - public static final String CALLSTACK_API_OFFSET_TOKEN = "\\+"; //$NON-NLS-1$ - public static final String CLASS = "class"; //$NON-NLS-1$ - public static final String DATA_PARSING_TOKEN = "`,"; //$NON-NLS-1$ - - /* timer intervals */ - public static final int SOCKET_CHECK_INTERVAL = 10; - public static final int DATA_SOCKET_TIMEOUT = 50000; - public static final int CONTROL_SOCKET_TIMEOUT = 10000; - - public static final int SOCKET_FORWARD_INTERVAL = 1000; - public static final int LOG_CHECK_INTERVAL = 1000; - public static final int SAVE_PREPARE_TIME = 2000; - public static final long TIMER_START_TIME_DEFAULT = 1000; - public static final int TIMER_INTERVAL_DEFAULT = 1000; - - /* project save index */ - public static final int PROJECT_VERSION_INDEX = 0; - public static final int PROJECT_DEVICE_INDEX = 1; - public static final int PROJECT_PACKAGE_ID_INDEX = 2; - public static final int PROJECT_APP_NAME_INDEX = 3; - public static final int PROJECT_CREATE_TIME_INDEX = 4; - public static final int PROJECT_LAST_TIME_INDEX = 5; - public static final int PROJECT_STOP_TIME_INDEX = 6; - public static final int PROJECT_PROF_START_TIME_INDEX = 7; - public static final int PROJECT_LOG_COUNT_INDEX = 8; - public static final int PROJECT_SYSTEM_COUNT_INDEX = 9; - public static final int PROJECT_PROFILE_COUNT_INDEX = 10; - public static final int PROJECT_SAVE_PATH_INDEX = 11; - public static final int PROJECT_MAIN_PID_INDEX = 12; - - - /* save return values */ - public static final int ERROR_EXTENSION_FAIL = -1; - public static final int SUCCESS = 1; - public static final int ERROR_SAVE_FAIL = 0; - public static final int FAIL = -2; - - /* data size */ - public static final int INSERT_DATA_PACKAGE_SIZE = 80; - public static final int MAX_REPEAT_COUNT = 5; - - /* log parsing size */ - public static final int DATABASE_READ_SIZE = 100; - - public static final String MSG_START = "100"; //$NON-NLS-1$ - public static final String MSG_STOP = "101"; //$NON-NLS-1$ - public static final String MSG_OPTION = "103"; //$NON-NLS-1$ - public static final String MSG_VERSION = "999"; //$NON-NLS-1$ - public static final String MSG_OK = "901"; //$NON-NLS-1$ - public static final String MSG_NOT_OK = "902"; //$NON-NLS-1$ - public static final String MSG_SCREENSHOT = "103"; //$NON-NLS-1$ - - public static final int MSG_RECORD = 801; - public static final int MSG_REPLAY = 802; - - public static final long FEATURE_OFF = 0x0000; - public static final long FEATURE_ON = 0x1; - - public static final long RESERVED_1 = FEATURE_ON; - public static final long RESERVED_2 = FEATURE_ON << 1; - public static final long FEATURE_FUNCTION_SAMPLING = 0x80000; // 19 - public static final long FEATURE_FUNCTION_PROFILING = (RESERVED_1 << 2)|FEATURE_FUNCTION_SAMPLING; - public static final long FEATURE_ALLOCATION = FEATURE_ON << 3;//0x0008; - - - - - - public static final long FEATURE_FILE_API = 0x0010; // 4 - public static final long FEATURE_THREAD_API = 0x0020; // 5 - public static final long FEATURE_OSP_UI_API = 0x0040; //6 - public static final long FEATURE_SCREENSHOT = 0x0080; //7 - public static final long FEATURE_USER_EVENT = 0x0100; //8 - public static final long FEATURE_RECORDING = 0x0200; //9 - - public static final long FEATURE_SYSCALL_FILE = 0x0400; //10 - public static final long FEATURE_SYSCALL_IPC = 0x0800; // 11 - public static final long FEATURE_SYSCALL_PROCESS = 0x1000; //12 - public static final long FEATURE_SYSCALL_SIGNAL = 0x2000; //13 - public static final long FEATURE_SYSCALL_NETWORK = 0x4000; //14 - public static final long FEATURE_SYSCALL_DESC = 0x8000; //15 - - public static final long FEATURE_CONTEXT_SWITCHING = 0x10000; //16 - public static final long FEATURE_NETWORK_API = 0x20000; //17 - public static final long FEATURE_OPENGL_API = 0x40000; //18 - - public static final long SYSTEM_CPU = 0x100000; //20 - public static final long SYSTEM_PROCESSES = 0x200000; //21 - public static final long SYSTEM_MEMORY = 0x400000; //22 - public static final long SYSTEM_DISK = 0x800000; //23 - public static final long SYSTEM_NETWORK = 0x1000000; //24 - public static final long SYSTEM_DEVICE = 0x2000000; //25 - public static final long SYSTEM_RESERVED = 0x8000000; //27 - - public static final long SYSTEM_ENERGY = 0x4000000; //26 - - public static final long MEMORY_API_PROBING_NO_FILTER = 0x10000000; //28 - public static final long FILE_API_PROBING_NO_FILTER = 0x20000000; //29 - public static final long THREAD_API_PROBING_NO_FILTER = 0x40000000; //30 - public static final long OSP_UI_API_PROBING_NO_FILTER = 0x80000000; //31 -// public static final long NETWORK_API_PROBING_NO_FILTER = FEATURE_ON << 32; // prefeature -// public static final long OPENGL_API_PROBING_NO_FILTER = FEATURE_ON << 33;// prefeaturen - public static final long NETWORK_API_PROBING_NO_FILTER = FEATURE_ON; // prefeature - public static final long OPENGL_API_PROBING_NO_FILTER = FEATURE_ON <<1;// prefeaturen - - public static final long SCREENSHOT_PERIODIC = 10;//must modification - public static final long SCREENSHOT_PERIODIC_AUTO = 1;//must modification - public static final long FUNCTION_PROFILING_SAMPLING_PERIODIC = 10;//must modification - public static final long SYSTEM_INFOMATION_SAMPLING_PERIODIC = 1000;//must modification - - - /* Message Type */ - public static final int MSG_APP_INFO = 1; //$NON-NLS-1$ - public static final int MSG_USER_PROFILING_SAMPLE = 3; //$NON-NLS-1$ - public static final int MSG_DEVICE_LOG = 4; //$NON-NLS-1$ - public static final int MSG_LOG = 5; //$NON-NLS-1$ - public static final int MSG_IMAGE = 6; //$NON-NLS-1$ - public static final int MSG_TERMINATE = 7; //$NON-NLS-1$ - public static final int MSG_DEBUG = 9; //$NON-NLS-1$ - - public static final int SCREENSHOT_OFF = 0; - public static final int SCREENSHOT_ON = 1; - - public static final int DAEMON_LISTEN_TRY = 50; - - /* app info */ - public static final int APP_INFO_SYSTEM_MEMORY_SIZE = 0; - public static final int APP_INFO_STORAGE_SIZE = 1; - public static final int APP_INFO_BLUETOOTH_SUPPORT = 2; - public static final int APP_INFO_GPS_SUPPORT = 3; - public static final int APP_INFO_WIFI_SUPPORT = 4; - public static final int APP_INFO_CAMERA_COUNT = 5; - public static final int APP_INFO_NETWORK_TYPE = 6; - public static final int APP_INFO_MAX_BRIGHTNESS = 7; - public static final int APP_INFO_WIDTH = 8; - public static final int APP_INFO_HEIGHT = 9; - public static final int APP_INFO_THEME = 10; - public static final int APP_INFO_VERSION = 11; - public static final int APP_INFO_SCALE = 12; - public static final int APP_INFO_REMOVABLE = 13; - public static final int APP_INFO_COMMENT = 14; - public static final int APP_INFO_PID = 15; - public static final int APP_INFO_START_TIME = 16; - public static final int APP_INFO_PIE_BUILD = 17; - public static final int APP_INFO_BASE_ADDRESS = 18; - public static final int APP_INFO_APP_TYPE = 19; - public static final int APP_INFO_BINARY_PATH = 20; - public static final int APP_INFO_SIZE = 21; - - /* app type */ - public static final int APP_TYPE_TIZEN = 1; - public static final int APP_TYPE_OSP = 4; - - /* Source Line errors */ - public static final int SOURCELINE_NOERROR = 0; - public static final int SOURCELINE_NULL_PATH = 1; - public static final int SOURCELINE_NULL_ADDRESS = 2; - public static final int SOURCELINE_FILE_NOT_FOUND = 3; - public static final int SOURCELINE_BAD_ADDRESS = 4; - public static final int SOURCELINE_NO_SYMBOL_INFORMATION = 5; - public static final int SOURCELINE_NO_MATCHING_LINE = 6; - public static final int SOURCELINE_UNKNOWN_ERROR = 7; - public static final int SOURCELINE_NO_SOURCELINE_DATA = 8; - public static final int SOURCELINE_PIE_BUILD = 9; - public static final int SOURCE_FILE_NOT_FOUND = 10; - - public static final String[] sourcelineErrorMsg = { - AnalyzerLabels.EMPTY_STRING, - AnalyzerLabels.ANALYZER_CONSTANTS_SOURCELINE_NULL_PATH, - AnalyzerLabels.ANALYZER_CONSTANTS_SOURCELINE_NULL_ADDRESS, - AnalyzerLabels.ANALYZER_CONSTANTS_SOURCELINE_FILE_NOT_FOUND, - AnalyzerLabels.ANALYZER_CONSTANTS_SOURCELINE_BAD_ADDRESS, - AnalyzerLabels.ANALYZER_CONSTANTS_SOURCELINE_NO_SYMBOL_INFORMATION, - AnalyzerLabels.ANALYZER_CONSTANTS_SOURCELINE_NO_MATCHING_LINE, - AnalyzerLabels.ANALYZER_CONSTANTS_SOURCELINE_UNKNOWN_ERROR, - AnalyzerLabels.ANALYZER_CONSTANTS_SOURCELINE_NO_SOURCELINE_DATA, - AnalyzerLabels.ANALYZER_CONSTANTS_SOURCELINE_PIE_BUILD, - AnalyzerLabels.ANALYZER_CONSTANTS_SOURCELINE_NOT_FOUND }; - - // user call check - public final static String USER_BIN_POS = "/opt/usr/apps/"; //$NON-NLS-1$ - public final static int USER_CALL = 2; - public final static int INTERNAL_CALL = 1; - public final static int USER_CALL_CHECK_ERROR = -1; - public final static String VIRTUAL_THUNK = "virtual base override"; - - // comparator type - public final static int SORT_TYPE_NONE = 0; - public final static int SORT_TYPE_NUM = 1; - public final static int SORT_TYPE_STRING = 2; - public final static int SORT_TYPE_GRID = 3; - - // function usage profile data type - public final static int FUPD_APPLICATION = 1; - public final static int FUPD_DEPENDENT_LIB = 2; - - public final static String DAEMONLOG_PREFIX = "da_daemon_log_";//$NON-NLS-1$ - public final static int DAEMONLOG_COUNT = 3; - - /*** version 3.0 */ - public final static int MSG_KEEP_ALIVE = 0x0001; - public final static int MSG_START_SWAP = 0x0002; - public final static int MSG_STOP_SWAP = 0x0003; - public final static int MSG_CONFIG = 0x0004; - public final static int MSG_BINARY_INFO = 0x0005; - public final static int MSG_TARGET_INFO = 0x0007; - public final static int MSG_SWAP_INST_ADD = 0x0008; - public final static int MSG_SWAP_INST_REMOVE = 0x0009; - public final static int MSG_GET_SCREENSHOT = 0x0010; - - public final static int MSG_KEEP_ALIVE_ACK = 0x1001; - public final static int MSG_START_ACK = 0x1002; - public final static int MSG_STOP_ACK = 0x1003; - public final static int MSG_CONFIG_ACK = 0x1004; - public final static int MSG_BINARY_INFO_ACK = 0x1005; - public final static int MSG_TARGET_INFO_ACK = 0x1007; - public final static int MSG_SWAP_INST_ADD_ACK = 0x1008; - public final static int MSG_SWAP_INST_REMOVE_ACK = 0x1009; - public final static int MSG_WAIT_ACK = 0x1010; - - public final static int TYPE_TABLE_CALLSTACK = 0x0001; - public final static int TYPE_TABLE_FAILED = 0x0002; - public final static int TYPE_TABLE_LEAK = 0x0004; - public final static int TYPE_TABLE_WARNING = 0x0008; - public final static int TYPE_TABLE_NORMAL = 0x0010; - public final static int TYPE_TABLE_CALLTRACE = 0x0020; - public final static int TYPE_TABLE_CONTEXTSWITCH = 0x0040; - public final static int TYPE_TABLE_FUNCTIONFRAGMENT = 0x0080; - - public final static String CALLSTACK_KEY_PID = "pid";//$NON-NLS-1$ - public final static String CALLSTACK_KEY_ADDR = "address";//$NON-NLS-1$ - public final static String CALLSTACK_KEY_TIME = "time";//$NON-NLS-1$ - public final static String CALLSTACK_KEY_LIBNAME = "libName";//$NON-NLS-1$ - - public final static int SASH_WIDTH = 4; -} +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Jooyoul Lee + * Juyoung Kim + * + * 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.common; + +import org.tizen.dynamicanalyzer.nl.AnalyzerLabels; + +public class AnalyzerConstants { + // if log change occurs then increase save data version!! + public static final String SAVE_DATA_VERSION = "0.88"; //$NON-NLS-1$ + public static final boolean CHECK_INTERNAL = true; + + public static final String DA_VERSION_SWAP = "3.0"; + public static final String DA_VERSION_OLD = "2.2"; + + /* folder names */ + public static final String TEMP_FOLDER_RUN_PREFIX = ".RUN"; //$NON-NLS-1$ + public static final String IMAGE_FOLDER_NAME = "img"; //$NON-NLS-1$ + public static final String SMALL_IMAGE_FOLDER_NAME = "small"; //$NON-NLS-1$ + public static final String XML_FOLDER_NAME = "xml"; //$NON-NLS-1$ + public static final String LICENSE_FILE_NAME = "license"; //$NON-NLS-1$ + public static final String USER_INTERFACE_API_LIST_FILE_NAME = "user_interface_api_list"; //$NON-NLS-1$ + + public static final String API_NAME_FILE_NAME = "apis"; //$NON-NLS-1$ + + public static final String READELF_BIN = "readelf"; //$NON-NLS-1$ + + public static final String VERSION_NAME = "version"; //$NON-NLS-1$ + public static final String DATABASE_NAME = "da.trace"; //$NON-NLS-1$ + public static final String DEFAULT_IMAGE_NAME = "noImage.jpg"; //$NON-NLS-1$ + public final static String PROBE_LIB_TIZEN = "da_probe_tizen.so"; //$NON-NLS-1$ + public final static String PROBE_LIB_OSP = "da_probe_osp.so"; //$NON-NLS-1$ + + /* Save Data table */ + public static final String LEAK_DATA_TABLE_NAME = "LeakData"; //$NON-NLS-1$ + public static final String FAILED_DATA_TABLE_NAME = "FailedData"; //$NON-NLS-1$ + + /* thread names */ + public static final String LOG_QUEUE_OBSERVING_THREAD = "Log Queue Observing thread"; //$NON-NLS-1$ + public static final String COMMUNICATOR_RECEIVE_THREAD = "Communicator Receive Thread"; //$NON-NLS-1$ + public static final String MESSAGE_INTERNAL_IMAGE_THREAD = "Internal Image Process Thread"; //$NON-NLS-1$ + public static final String STOP_LOG_THREAD = "Stop Log Thread"; //$NON-NLS-1$ + public static final String BATTERY_RECEIVE_THREAD = "Battery Receive Thread"; //$NON-NLS-1$ + public static final String SLP_APP_RUN_THREAD = "SLP App Run Thread"; //$NON-NLS-1$ + public static final String OPEN_TRACE_THREAD = "Open trace input thread"; //$NON-NLS-1$ + public static final String INSERT_LOG_THREAD = "Insert log thread"; //$NON-NLS-1$ + public static final String IDE_COMMUNICATOR_THREAD = "IDE Communicator thread"; //$NON-NLS-1$ + public static final String SEND_MESSAGE_THREAD = "Send message thread"; //$NON-NLS-1$ + public static final String START_STOP_THREAD = "Start stop thread"; //$NON-NLS-1$ + public static final String FILE_CHART_MANAGER_THREAD = "File Chart Manager thread"; //$NON-NLS-1$ + public static final String THREAD_CHART_MANAGER_THREAD = "Thread Chart Manager thread"; //$NON-NLS-1$ + public static final String NETWORK_CHART_MANAGER_THREAD = "Network Chart Manager thread"; //$NON-NLS-1$ + public static final String KERNEL_CHART_MANAGER_THREAD = "Kernel Chart Manager thread"; //$NON-NLS-1$ + public static final String FUNCTION_USAGE_PROFILING_THREAD = "Function usage profiling thread"; //$NON-NLS-1$ + public static final String USER_INTERFACE_PAGE_MANAGER_THREAD = "User Interface Page Managerthread"; //$NON-NLS-1$ + public static final String SQL_INSERTER_THREAD = "sql_inserter_thread"; //$NON-NLS-1$ + public static final String HEART_BEAT_THREAD = "heart beat thread"; //$NON-NLS-1$ + + /* log parsing token and callstack parsing token, etc... */ + public static final String CALLSTACK_START = "callstack_start"; //$NON-NLS-1$ + public static final String CALLSTACK_END = "callstack_end"; //$NON-NLS-1$ + public static final String CALLSTACK_CUT_MEMORY_TOKEN = "\\["; //$NON-NLS-1$ + public static final String CALLSTACK_API_TOKEN = "\\("; //$NON-NLS-1$ + public static final String CALLSTACK_API_TOKEN_STRING = "("; //$NON-NLS-1$ + public static final String CALLSTACK_API_EMPTY_TOKEN = "\\)"; //$NON-NLS-1$ + public static final String CALLSTACK_API_OFFSET_TOKEN = "\\+"; //$NON-NLS-1$ + public static final String CLASS = "class"; //$NON-NLS-1$ + public static final String DATA_PARSING_TOKEN = "`,"; //$NON-NLS-1$ + + /* timer intervals */ + public static final int SOCKET_CHECK_INTERVAL = 10; + public static final int DATA_SOCKET_TIMEOUT = 50000; + public static final int CONTROL_SOCKET_TIMEOUT = 10000; + + public static final int SOCKET_FORWARD_INTERVAL = 1000; + public static final int LOG_CHECK_INTERVAL = 1000; + public static final int SAVE_PREPARE_TIME = 2000; + public static final long TIMER_START_TIME_DEFAULT = 1000; + public static final int TIMER_INTERVAL_DEFAULT = 1000; + + /* project save index */ + public static final int PROJECT_VERSION_INDEX = 0; + public static final int PROJECT_DEVICE_INDEX = 1; + public static final int PROJECT_PACKAGE_ID_INDEX = 2; + public static final int PROJECT_APP_NAME_INDEX = 3; + public static final int PROJECT_CREATE_TIME_INDEX = 4; + public static final int PROJECT_LAST_TIME_INDEX = 5; + public static final int PROJECT_STOP_TIME_INDEX = 6; + public static final int PROJECT_PROF_START_TIME_INDEX = 7; + public static final int PROJECT_LOG_COUNT_INDEX = 8; + public static final int PROJECT_SYSTEM_COUNT_INDEX = 9; + public static final int PROJECT_PROFILE_COUNT_INDEX = 10; + public static final int PROJECT_SAVE_PATH_INDEX = 11; + public static final int PROJECT_MAIN_PID_INDEX = 12; + + + /* save return values */ + public static final int ERROR_EXTENSION_FAIL = -1; + public static final int SUCCESS = 1; + public static final int ERROR_SAVE_FAIL = 0; + public static final int FAIL = -2; + + /* data size */ + public static final int INSERT_DATA_PACKAGE_SIZE = 80; + public static final int MAX_REPEAT_COUNT = 5; + + /* log parsing size */ + public static final int DATABASE_READ_SIZE = 100; + + public static final String MSG_START = "100"; //$NON-NLS-1$ + public static final String MSG_STOP = "101"; //$NON-NLS-1$ + public static final String MSG_OPTION = "103"; //$NON-NLS-1$ + public static final String MSG_VERSION = "999"; //$NON-NLS-1$ + public static final String MSG_OK = "901"; //$NON-NLS-1$ + public static final String MSG_NOT_OK = "902"; //$NON-NLS-1$ + public static final String MSG_SCREENSHOT = "103"; //$NON-NLS-1$ + + public static final int MSG_RECORD = 801; + public static final int MSG_REPLAY = 802; + + public static final long FEATURE_OFF = 0x0000; + public static final long FEATURE_ON = 0x1; + + public static final long RESERVED_1 = FEATURE_ON; + public static final long RESERVED_2 = FEATURE_ON << 1; + public static final long FEATURE_FUNCTION_SAMPLING = 0x80000; // 19 + public static final long FEATURE_FUNCTION_PROFILING = (RESERVED_1 << 2)|FEATURE_FUNCTION_SAMPLING; + public static final long FEATURE_ALLOCATION = FEATURE_ON << 3;//0x0008; + + + + + + public static final long FEATURE_FILE_API = 0x0010; // 4 + public static final long FEATURE_THREAD_API = 0x0020; // 5 + public static final long FEATURE_OSP_UI_API = 0x0040; //6 + public static final long FEATURE_SCREENSHOT = 0x0080; //7 + public static final long FEATURE_USER_EVENT = 0x0100; //8 + public static final long FEATURE_RECORDING = 0x0200; //9 + + public static final long FEATURE_SYSCALL_FILE = 0x0400; //10 + public static final long FEATURE_SYSCALL_IPC = 0x0800; // 11 + public static final long FEATURE_SYSCALL_PROCESS = 0x1000; //12 + public static final long FEATURE_SYSCALL_SIGNAL = 0x2000; //13 + public static final long FEATURE_SYSCALL_NETWORK = 0x4000; //14 + public static final long FEATURE_SYSCALL_DESC = 0x8000; //15 + + public static final long FEATURE_CONTEXT_SWITCHING = 0x10000; //16 + public static final long FEATURE_NETWORK_API = 0x20000; //17 + public static final long FEATURE_OPENGL_API = 0x40000; //18 + + public static final long SYSTEM_CPU = 0x100000; //20 + public static final long SYSTEM_PROCESSES = 0x200000; //21 + public static final long SYSTEM_MEMORY = 0x400000; //22 + public static final long SYSTEM_DISK = 0x800000; //23 + public static final long SYSTEM_NETWORK = 0x1000000; //24 + public static final long SYSTEM_DEVICE = 0x2000000; //25 + public static final long SYSTEM_RESERVED = 0x8000000; //27 + + public static final long SYSTEM_ENERGY = 0x4000000; //26 + + public static final long MEMORY_API_PROBING_NO_FILTER = 0x10000000; //28 + public static final long FILE_API_PROBING_NO_FILTER = 0x20000000; //29 + public static final long THREAD_API_PROBING_NO_FILTER = 0x40000000; //30 + public static final long OSP_UI_API_PROBING_NO_FILTER = 0x80000000; //31 +// public static final long NETWORK_API_PROBING_NO_FILTER = FEATURE_ON << 32; // prefeature +// public static final long OPENGL_API_PROBING_NO_FILTER = FEATURE_ON << 33;// prefeaturen + public static final long NETWORK_API_PROBING_NO_FILTER = FEATURE_ON; // prefeature + public static final long OPENGL_API_PROBING_NO_FILTER = FEATURE_ON <<1;// prefeaturen + + public static final long SCREENSHOT_PERIODIC = 10;//must modification + public static final long SCREENSHOT_PERIODIC_AUTO = 1;//must modification + public static final long FUNCTION_PROFILING_SAMPLING_PERIODIC = 10;//must modification + public static final long SYSTEM_INFOMATION_SAMPLING_PERIODIC = 1000;//must modification + + + /* Message Type */ + public static final int MSG_APP_INFO = 1; //$NON-NLS-1$ + public static final int MSG_USER_PROFILING_SAMPLE = 3; //$NON-NLS-1$ + public static final int MSG_DEVICE_LOG = 4; //$NON-NLS-1$ + public static final int MSG_LOG = 5; //$NON-NLS-1$ + public static final int MSG_IMAGE = 6; //$NON-NLS-1$ + public static final int MSG_TERMINATE = 7; //$NON-NLS-1$ + public static final int MSG_DEBUG = 9; //$NON-NLS-1$ + + public static final int SCREENSHOT_OFF = 0; + public static final int SCREENSHOT_ON = 1; + + public static final int DAEMON_LISTEN_TRY = 50; + + /* app info */ + public static final int APP_INFO_SYSTEM_MEMORY_SIZE = 0; + public static final int APP_INFO_STORAGE_SIZE = 1; + public static final int APP_INFO_BLUETOOTH_SUPPORT = 2; + public static final int APP_INFO_GPS_SUPPORT = 3; + public static final int APP_INFO_WIFI_SUPPORT = 4; + public static final int APP_INFO_CAMERA_COUNT = 5; + public static final int APP_INFO_NETWORK_TYPE = 6; + public static final int APP_INFO_MAX_BRIGHTNESS = 7; + public static final int APP_INFO_WIDTH = 8; + public static final int APP_INFO_HEIGHT = 9; + public static final int APP_INFO_THEME = 10; + public static final int APP_INFO_VERSION = 11; + public static final int APP_INFO_SCALE = 12; + public static final int APP_INFO_REMOVABLE = 13; + public static final int APP_INFO_COMMENT = 14; + public static final int APP_INFO_PID = 15; + public static final int APP_INFO_START_TIME = 16; + public static final int APP_INFO_PIE_BUILD = 17; + public static final int APP_INFO_BASE_ADDRESS = 18; + public static final int APP_INFO_APP_TYPE = 19; + public static final int APP_INFO_BINARY_PATH = 20; + public static final int APP_INFO_SIZE = 21; + + /* app type */ + public static final int APP_TYPE_TIZEN = 1; + public static final int APP_TYPE_OSP = 4; + + /* Source Line errors */ + public static final int SOURCELINE_NOERROR = 0; + public static final int SOURCELINE_NULL_PATH = 1; + public static final int SOURCELINE_NULL_ADDRESS = 2; + public static final int SOURCELINE_FILE_NOT_FOUND = 3; + public static final int SOURCELINE_BAD_ADDRESS = 4; + public static final int SOURCELINE_NO_SYMBOL_INFORMATION = 5; + public static final int SOURCELINE_NO_MATCHING_LINE = 6; + public static final int SOURCELINE_UNKNOWN_ERROR = 7; + public static final int SOURCELINE_NO_SOURCELINE_DATA = 8; + public static final int SOURCELINE_PIE_BUILD = 9; + public static final int SOURCE_FILE_NOT_FOUND = 10; + + public static final String[] sourcelineErrorMsg = { + AnalyzerLabels.EMPTY_STRING, + AnalyzerLabels.ANALYZER_CONSTANTS_SOURCELINE_NULL_PATH, + AnalyzerLabels.ANALYZER_CONSTANTS_SOURCELINE_NULL_ADDRESS, + AnalyzerLabels.ANALYZER_CONSTANTS_SOURCELINE_FILE_NOT_FOUND, + AnalyzerLabels.ANALYZER_CONSTANTS_SOURCELINE_BAD_ADDRESS, + AnalyzerLabels.ANALYZER_CONSTANTS_SOURCELINE_NO_SYMBOL_INFORMATION, + AnalyzerLabels.ANALYZER_CONSTANTS_SOURCELINE_NO_MATCHING_LINE, + AnalyzerLabels.ANALYZER_CONSTANTS_SOURCELINE_UNKNOWN_ERROR, + AnalyzerLabels.ANALYZER_CONSTANTS_SOURCELINE_NO_SOURCELINE_DATA, + AnalyzerLabels.ANALYZER_CONSTANTS_SOURCELINE_PIE_BUILD, + AnalyzerLabels.ANALYZER_CONSTANTS_SOURCELINE_NOT_FOUND }; + + // user call check + public final static String USER_BIN_POS = "/opt/usr/apps/"; //$NON-NLS-1$ + public final static int USER_CALL = 2; + public final static int INTERNAL_CALL = 1; + public final static int USER_CALL_CHECK_ERROR = -1; + public final static String VIRTUAL_THUNK = "virtual base override"; + + // comparator type + public final static int SORT_TYPE_NONE = 0; + public final static int SORT_TYPE_NUM = 1; + public final static int SORT_TYPE_STRING = 2; + public final static int SORT_TYPE_GRID = 3; + + // function usage profile data type + public final static int FUPD_APPLICATION = 1; + public final static int FUPD_DEPENDENT_LIB = 2; + + public final static String DAEMONLOG_PREFIX = "da_daemon_log_";//$NON-NLS-1$ + public final static int DAEMONLOG_COUNT = 3; + + /*** version 3.0 */ + public final static int MSG_KEEP_ALIVE = 0x0001; + public final static int MSG_START_SWAP = 0x0002; + public final static int MSG_STOP_SWAP = 0x0003; + public final static int MSG_CONFIG = 0x0004; + public final static int MSG_BINARY_INFO = 0x0005; + public final static int MSG_TARGET_INFO = 0x0007; + public final static int MSG_SWAP_INST_ADD = 0x0008; + public final static int MSG_SWAP_INST_REMOVE = 0x0009; + public final static int MSG_GET_SCREENSHOT = 0x0010; + + public final static int MSG_KEEP_ALIVE_ACK = 0x1001; + public final static int MSG_START_ACK = 0x1002; + public final static int MSG_STOP_ACK = 0x1003; + public final static int MSG_CONFIG_ACK = 0x1004; + public final static int MSG_BINARY_INFO_ACK = 0x1005; + public final static int MSG_TARGET_INFO_ACK = 0x1007; + public final static int MSG_SWAP_INST_ADD_ACK = 0x1008; + public final static int MSG_SWAP_INST_REMOVE_ACK = 0x1009; + public final static int MSG_WAIT_ACK = 0x1010; + + public final static int TYPE_TABLE_CALLSTACK = 0x0001; + public final static int TYPE_TABLE_FAILED = 0x0002; + public final static int TYPE_TABLE_LEAK = 0x0004; + public final static int TYPE_TABLE_WARNING = 0x0008; + public final static int TYPE_TABLE_NORMAL = 0x0010; + public final static int TYPE_TABLE_CALLTRACE = 0x0020; + public final static int TYPE_TABLE_CONTEXTSWITCH = 0x0040; + public final static int TYPE_TABLE_FUNCTIONFRAGMENT = 0x0080; + + public final static int CONTEXT_TABLE_RANGE = 0x0001; + public final static int CONTEXT_TABLE_SOURCE = 0x0002; + + public final static String CALLSTACK_KEY_PID = "pid";//$NON-NLS-1$ + public final static String CALLSTACK_KEY_ADDR = "address";//$NON-NLS-1$ + public final static String CALLSTACK_KEY_TIME = "time";//$NON-NLS-1$ + public final static String CALLSTACK_KEY_LIBNAME = "libName";//$NON-NLS-1$ + + public final static int SASH_WIDTH = 4; +} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/listeners/TableTooltipListener.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/listeners/TableTooltipListener.java index 4405e43..7a4bb28 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/listeners/TableTooltipListener.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/listeners/TableTooltipListener.java @@ -1,541 +1,596 @@ -/* - * Dynamic Analyzer - * - * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * Jooyoul Lee - * Juyoung Kim - * - * 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.listeners; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.util.List; - -import org.eclipse.nebula.widgets.grid.Grid; -import org.eclipse.nebula.widgets.grid.GridItem; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Cursor; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.layout.GridLayout; -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.eclipse.swt.widgets.Shell; -import org.tizen.dynamicanalyzer.common.AnalyzerConstants; -import org.tizen.dynamicanalyzer.common.AnalyzerManager; -import org.tizen.dynamicanalyzer.common.SymbolManager; -import org.tizen.dynamicanalyzer.common.SymbolManager.SourceLine; -import org.tizen.dynamicanalyzer.communicator.IDECommunicator; -import org.tizen.dynamicanalyzer.constant.CommonConstants; -import org.tizen.dynamicanalyzer.nl.AnalyzerLabels; -import org.tizen.dynamicanalyzer.resources.ColorResources; -import org.tizen.dynamicanalyzer.resources.FontResources; -import org.tizen.dynamicanalyzer.resources.ImageResources; -import org.tizen.dynamicanalyzer.swap.channel.control.BinaryInfo; -import org.tizen.dynamicanalyzer.swap.channel.data.LibraryObject; -import org.tizen.dynamicanalyzer.swap.channel.data.ProcessInfo; -import org.tizen.dynamicanalyzer.swap.channel.data.ProcessInfoPackage; -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.swap.model.data.UserFunctionData; -import org.tizen.dynamicanalyzer.swap.platform.BinarySettingData; -import org.tizen.dynamicanalyzer.swap.platform.BinarySettingManager; -import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea; -import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat; -import org.tizen.dynamicanalyzer.util.CommonUtil; -import org.tizen.dynamicanalyzer.util.WorkbenchUtil; -import org.tizen.dynamicanalyzer.widgets.da.base.DADialog; - -public class TableTooltipListener implements Listener { - - private Grid grid = null; - private Shell tooltip; - private Object oldItem; - private boolean enabled = true; - - private static final int MARGIN = 5; - private static final int SPACING = 0; - private static final int SOURCE_LINE_TOP = 5; - private static final int SOURCE_LINE_BOTTOM = 11; - private static final int TOOLTIP_OFFSET = 5; - private static final Cursor sourceCursor = new Cursor(null, - ImageResources.VIEW_SOURCE_CURSOR.getImageData(), 0, 0); - private static Cursor defaultCursor = null; - - public TableTooltipListener(Grid table) { - this.grid = table; - defaultCursor = grid.getCursor(); - } - - public void handleEvent(Event event) { - if (!ToolbarArea.getInstance().getSourceViewEnable()) { - return; - } - - int columnHeight = grid.getHeaderHeight(); - boolean isHeader = false; - if (event.y < columnHeight) { - isHeader = true; - } - - boolean isToggled = ToolbarArea.getInstance().isSourceViewEnabled(); - if (enabled && !isHeader) { - setViewCursor(isToggled); - } - - GridItem gridItem = null; - switch (event.type) { - case SWT.Dispose: - disposeTooltip(); - break; - case SWT.KeyDown: - break; - case SWT.KeyUp: - setViewCursor(isToggled); - break; - case SWT.MouseEnter: - grid.setFocus(); - if (isToggled && enabled) { - createTooltip(event); - } - break; - case SWT.MouseExit: - disposeTooltip(); - break; - case SWT.MouseMove: - gridItem = grid.getItem(new Point(event.x, event.y)); - if (null == oldItem) { - oldItem = gridItem; - } - if (null != tooltip) { - if (null != gridItem) { - if (!gridItem.equals((GridItem) oldItem)) { - oldItem = gridItem; - } else { - return; - } - } - tooltip.dispose(); - tooltip = null; - } - break; - case SWT.MouseDoubleClick: - if (isToggled && enabled) { - openIDE(event); - } - break; - case SWT.MouseHover: - grid.setFocus(); - if (isToggled && enabled) { - createTooltip(event); - } - break; - default: - break; - } - } - - public void setEnable(boolean enabled) { - this.enabled = enabled; - } - - private void setViewCursor(boolean toggled) { - if (!toggled) { - grid.setCursor(defaultCursor); - disposeTooltip(); - } else { - grid.setCursor(sourceCursor); - } - } - - private void createErrorPopup(String message) { - Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell(); - DADialog warning = new DADialog(shell, SWT.NONE); - warning.setMessage(message); - warning.setIcon(ImageResources.DIALOG_WARNING_ICON); - warning.open(); - } - - private void createErrorTooltip(Event event, int errno) { - // Creates tooltip. - Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell(); - tooltip = new Shell(shell, SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL); - tooltip.setBackground(ColorResources.TOOLTIP); - GridLayout gridLayout = new GridLayout(); - gridLayout.marginTop = MARGIN; - gridLayout.marginBottom = MARGIN; - gridLayout.marginLeft = MARGIN; - gridLayout.marginRight = MARGIN; - gridLayout.verticalSpacing = SPACING; - tooltip.setLayout(gridLayout); - - // Creates tooltip title label. - Label title = new Label(tooltip, SWT.NONE); - title.setForeground(ColorResources.BLACK); - title.setBackground(ColorResources.TOOLTIP); - String text = AnalyzerConstants.sourcelineErrorMsg[errno]; - title.setText(text); - - tooltipShow(event.x, event.y); - } - - private String getSourcePath(GridItem item, SourceLine sourceLine) { - String filePath = null; - String libName = getLibPath(item); - - BinarySettingData binData = BinarySettingManager.getInstance() - .getRealBinarySetting(libName); - - if (null != binData && null != binData.getUserSourcePath() - && !binData.getUserSourcePath().isEmpty()) { - String fileName = getSourceFilePath(sourceLine.getFilePath()); - filePath = binData.getUserSourcePath() + File.separator + fileName; - } else { - if (!isLibrary(libName)) { - filePath = sourceLine.getFilePath(); - } else { - filePath = binData.getDebugSourcePath() - + sourceLine.getFilePath(); - } - } - return filePath; - } - - private String getSourceFilePath(String sourcePath) { - int index = sourcePath.lastIndexOf("src/"); - String filePath = sourcePath.substring(index + 4, sourcePath.length()); - return filePath; - } - - private void createTooltip(Event event) { - GridItem item = grid.getItem(new Point(event.x, event.y)); - if (null != item) { - disposeTooltip(); - - // Gets source path and line. - SourceLine sl = getSourceLine(item); - if (null == sl - || sl.getError() != AnalyzerConstants.SOURCELINE_NOERROR) { - createErrorTooltip(event, sl.getError()); - return; - } - - // Creates tooltip. - Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell(); - tooltip = new Shell(shell, SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL); - tooltip.setBackground(ColorResources.TOOLTIP); - GridLayout gridLayout = new GridLayout(); - gridLayout.marginTop = MARGIN; - gridLayout.marginBottom = MARGIN; - gridLayout.marginLeft = MARGIN; - gridLayout.marginRight = MARGIN; - gridLayout.verticalSpacing = SPACING; - tooltip.setLayout(gridLayout); - - // Creates tooltip title label. - Label title = new Label(tooltip, SWT.NONE); - title.setFont(FontResources.TOOLTIP); - title.setForeground(ColorResources.BLACK); - title.setBackground(ColorResources.TOOLTIP); - - // Sets tooltip title text. - String filePath = getSourcePath(item, sl); - int line = sl.getLineNumber(); - title.setText(filePath + CommonConstants.SPACE - + CommonConstants.SPACE + CommonConstants.NEW_LINE); - - // Creates tooltip label. - Label top = new Label(tooltip, SWT.NONE); - top.setForeground(ColorResources.BLACK); - top.setBackground(ColorResources.TOOLTIP); - - Label center = new Label(tooltip, SWT.NONE); - center.setForeground(ColorResources.RED); - center.setBackground(ColorResources.TOOLTIP); - - Label bottom = new Label(tooltip, SWT.NONE); - bottom.setForeground(ColorResources.BLACK); - bottom.setBackground(ColorResources.TOOLTIP); - - // Makes tooltip text. - BufferedReader reader = null; - StringBuilder topStr = new StringBuilder(CommonConstants.EMPTY); - StringBuilder centerStr = new StringBuilder(CommonConstants.EMPTY); - StringBuilder bottomStr = new StringBuilder(CommonConstants.EMPTY); - try { - reader = new BufferedReader(new FileReader(filePath)); - int topStart = line - SOURCE_LINE_TOP; - if (0 > topStart - 1) { - topStart = 1; - } - int topEnd = line; - int bottomStart = line + 1; - int bottomEnd = line + SOURCE_LINE_BOTTOM; - - for (int i = 0; i < topStart - 1; i++) { - reader.readLine(); - } - - String temp = null; - for (int i = topStart; i < topEnd; i++) { - if (null != (temp = reader.readLine())) { - topStr.append(i + CommonConstants.TAB + temp); - } else { - break; - } - if (i != topEnd - 1) { - topStr.append(CommonConstants.NEW_LINE); - } - } - - if (null != (temp = reader.readLine())) { - centerStr.append(line + CommonConstants.TAB + temp); - } - - for (int i = bottomStart; i < bottomEnd; i++) { - if (null != (temp = reader.readLine())) { - bottomStr.append(i + CommonConstants.TAB + temp); - } else { - break; - } - if (i != bottomEnd - 1) { - bottomStr.append(CommonConstants.NEW_LINE); - } - } - } catch (FileNotFoundException e) { - // e.printStackTrace(); - createErrorTooltip(event, - AnalyzerConstants.SOURCE_FILE_NOT_FOUND); - } catch (IOException e) { - e.printStackTrace(); - } finally { - CommonUtil.tryClose(reader); - } - - // Sets tooltip text. - top.setText(topStr.toString()); - center.setText(centerStr.toString()); - bottom.setText(bottomStr.toString()); - - tooltipShow(event.x, event.y); - } - } - - private void tooltipShow(int x, int y) { - Point size = tooltip.computeSize(SWT.DEFAULT, SWT.DEFAULT); - Point pt = grid.toDisplay(x, y); - Rectangle displayRect = Display.getCurrent().getBounds(); - // 1. right side check! - pt.x = ((pt.x + size.x) > displayRect.width) ? pt.x - size.x - - TOOLTIP_OFFSET : pt.x + TOOLTIP_OFFSET; - // 2. bottom check! - pt.y = ((pt.y + size.y) > displayRect.height) ? pt.y - size.y - - TOOLTIP_OFFSET : pt.y + TOOLTIP_OFFSET; - tooltip.setBounds(pt.x, pt.y, size.x, size.y); - tooltip.setVisible(true); - } - - private void disposeTooltip() { - if (null != tooltip && !tooltip.isDisposed()) { - tooltip.dispose(); - tooltip = null; - } - } - - private SourceLine getSourceLine(GridItem item) { - // Gets source path and line. - DATableDataFormat tableData = (DATableDataFormat) item.getData(); - LogData data = null; - long addr = -1; - // boolean isPieBuild = AnalyzerUtil.isPieBuild(data.getPid()); - boolean isPieBuild = true; - int pid = -1; - long time = 0; - String libName = null; - - switch (tableData.getType()) { - case AnalyzerConstants.TYPE_TABLE_CALLSTACK: - addr = (Long) item.getData(AnalyzerConstants.CALLSTACK_KEY_ADDR); - pid = (Integer) item.getData(AnalyzerConstants.CALLSTACK_KEY_PID); - time = (Long) item.getData(AnalyzerConstants.CALLSTACK_KEY_TIME); - libName = (String) item - .getData(AnalyzerConstants.CALLSTACK_KEY_LIBNAME); - break; - case AnalyzerConstants.TYPE_TABLE_FAILED: - List failedData = tableData.getData(); - addr = Long.parseLong(failedData.get(8)); - pid = Integer.parseInt(failedData.get(7)); - time = Long.parseLong(failedData.get(1)); - libName = failedData.get(9); - break; - case AnalyzerConstants.TYPE_TABLE_LEAK: - List leakData = tableData.getData(); - addr = Long.parseLong(leakData.get(9)); - pid = Integer.parseInt(leakData.get(1)); - time = Long.parseLong(leakData.get(4)); - libName = leakData.get(7); - break; - case AnalyzerConstants.TYPE_TABLE_WARNING: - data = tableData.getLogData(); - ProbeCommonData pData = (ProbeCommonData) data; - addr = pData.getCallerPcAddr(); - pid = data.getPid(); - time = data.getTime(); - libName = pData.getLibName(); - break; - case AnalyzerConstants.TYPE_TABLE_CALLTRACE: - data = tableData.getLogData(); - if (data instanceof UserFunctionData) { - addr = ((UserFunctionData) data).getCallerPcAddr(); - libName = ((UserFunctionData) data).getLibName(); - } else if (data instanceof ProfileData) { - // addr = ((ProfileData) data).getPcAddr(); - // config - addr = ((ProfileData) data).getCallerPcAddr(); - libName = ((ProfileData) data).getLibName(); - } - pid = data.getPid(); - time = data.getTime(); - break; - default: // normal - data = tableData.getLogData(); - ProbeCommonData wData = (ProbeCommonData) data; - addr = wData.getCallerPcAddr(); - pid = data.getPid(); - time = data.getTime(); - libName = wData.getLibName(); - } - - // libName = getLibPath(item); - - ProcessInfoPackage processInfoPkg = AnalyzerManager.getProject() - .getProcessInfo(pid); - ProcessInfo processInfo = processInfoPkg.getProcessInfo(time); - BinaryInfo binInfo = processInfo.getTargetBinary(addr); - if (binInfo == null) { - SourceLine sl = new SourceLine(); - sl.setError(AnalyzerConstants.SOURCELINE_NO_SOURCELINE_DATA); - return sl; - } - isPieBuild = (binInfo.getType() == 1) ? true : false; - - // String baseAddr = Long.toString(AnalyzerManager.getProject() - // .getBaseAddress(pid, time)); - String baseAddr = null; - String path = null; - // if (libName.equals(processInfo.getMainTargetBinaryPath())) { - if (!isLibrary(libName)) { - baseAddr = Long.toString(processInfo.getLowestAddress()); - } else { - LibraryObject libObj = processInfo.getLibObjHash().get(libName); - if (null != libObj) { - baseAddr = Long.toString(libObj.getLowestAddress()); - } else { - SourceLine sl = new SourceLine(); - sl.setError(AnalyzerConstants.SOURCELINE_NO_SOURCELINE_DATA); - return sl; - } - } - - BinarySettingData binData = BinarySettingManager.getInstance() - .getRealBinarySetting(binInfo.getTargetBinaryPath()); - if (null != binData) { - String debugPath = binData.getDebugFilePath(); - if (null != debugPath && !debugPath.isEmpty()) { - path = debugPath; - } else { - path = binInfo.getTempBinaryPath(); - } - } else { - path = binInfo.getTempBinaryPath(); - } - SourceLine sl = SymbolManager.addr2line(path, addr, isPieBuild, - baseAddr); - return sl; - } - - private void openIDE(Event event) { - SourceLine sl = null; - GridItem item = grid.getItem(new Point(event.x, event.y)); - if (null == item) { - return; - } - sl = getSourceLine(item); - - if ((null == sl) || (!sl.isValid()) - || (IDECommunicator.isConnected() == false)) { - createErrorPopup(AnalyzerLabels.IDE_NOT_LAUNCHED); - return; - } - - String filePath = getSourcePath(item, sl); - int lineNum = sl.getLineNumber(); - IDECommunicator.sendCodeInfoToIDE(filePath, Integer.toString(lineNum)); - } - - private String getLibPath(GridItem item) { - DATableDataFormat tableData = (DATableDataFormat) item.getData(); - String libName = null; - switch (tableData.getType()) { - case AnalyzerConstants.TYPE_TABLE_CALLSTACK: - // addr = (Long) tableData.getObject(); - libName = item.getText(2); - break; - case AnalyzerConstants.TYPE_TABLE_FAILED: - List failedData = tableData.getData(); - libName = failedData.get(9); - break; - case AnalyzerConstants.TYPE_TABLE_LEAK: - List leakData = tableData.getData(); - libName = leakData.get(7); - break; - case AnalyzerConstants.TYPE_TABLE_WARNING: - ProbeCommonData pData = (ProbeCommonData) tableData.getLogData(); - libName = pData.getLibName(); - break; - case AnalyzerConstants.TYPE_TABLE_CALLTRACE: - LogData data = tableData.getLogData(); - if (data instanceof UserFunctionData) { - libName = ((UserFunctionData) data).getLibName(); - } else if (data instanceof ProfileData) { - libName = ((ProfileData) data).getLibName(); - } - break; - default: // normal - ProbeCommonData wData = (ProbeCommonData) tableData.getLogData(); - libName = wData.getLibName(); - } - return libName; - } - - private boolean isLibrary(String binaryPath) { - if (binaryPath.contains(".so")) { - return true; - } - return false; - } -} +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Jooyoul Lee + * Juyoung Kim + * + * 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.listeners; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.util.List; + +import org.eclipse.nebula.widgets.grid.Grid; +import org.eclipse.nebula.widgets.grid.GridItem; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Cursor; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.GridLayout; +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.eclipse.swt.widgets.Shell; +import org.tizen.dynamicanalyzer.common.AnalyzerConstants; +import org.tizen.dynamicanalyzer.common.AnalyzerManager; +import org.tizen.dynamicanalyzer.common.SymbolManager; +import org.tizen.dynamicanalyzer.common.SymbolManager.SourceLine; +import org.tizen.dynamicanalyzer.communicator.IDECommunicator; +import org.tizen.dynamicanalyzer.constant.CommonConstants; +import org.tizen.dynamicanalyzer.nl.AnalyzerLabels; +import org.tizen.dynamicanalyzer.resources.ColorResources; +import org.tizen.dynamicanalyzer.resources.FontResources; +import org.tizen.dynamicanalyzer.resources.ImageResources; +import org.tizen.dynamicanalyzer.swap.channel.control.BinaryInfo; +import org.tizen.dynamicanalyzer.swap.channel.data.LibraryObject; +import org.tizen.dynamicanalyzer.swap.channel.data.ProcessInfo; +import org.tizen.dynamicanalyzer.swap.channel.data.ProcessInfoPackage; +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.swap.model.data.UserFunctionData; +import org.tizen.dynamicanalyzer.swap.platform.BinarySettingData; +import org.tizen.dynamicanalyzer.swap.platform.BinarySettingManager; +import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea; +import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat; +import org.tizen.dynamicanalyzer.util.CommonUtil; +import org.tizen.dynamicanalyzer.util.WorkbenchUtil; +import org.tizen.dynamicanalyzer.widgets.da.base.DADialog; + +public class TableTooltipListener implements Listener { + + private Grid grid = null; + private GridItem oldItem = null; + private Shell tooltip; + private boolean enabled = true; /* source view */ + private boolean onViewSourceFromContext = false; + + + private static final int MARGIN = 5; + private static final int SPACING = 0; + private static final int SOURCE_LINE_TOP = 5; + private static final int SOURCE_LINE_BOTTOM = 11; + private static final int TOOLTIP_OFFSET = 5; + private static final Cursor sourceCursor = new Cursor(null, + ImageResources.VIEW_SOURCE_CURSOR.getImageData(), 0, 0); + private static Cursor defaultCursor = null; + + public TableTooltipListener(Grid table) { + this.grid = table; + defaultCursor = grid.getCursor(); + } + + public void handleEvent(Event event) { + if (!ToolbarArea.getInstance().getSourceViewEnable()) { + return; + } + + int columnHeight = grid.getHeaderHeight(); + boolean isHeader = false; + if (event.y < columnHeight) { + isHeader = true; + } + + boolean isToggled = ToolbarArea.getInstance().isSourceViewEnabled(); + if (enabled && !isHeader) { + setViewCursor(isToggled); + } + + switch (event.type) { + case SWT.Dispose: + disposeTooltip(); + break; + case SWT.KeyDown: + break; + case SWT.KeyUp: + setViewCursor(isToggled); + break; + case SWT.MouseEnter: +// grid.setFocus(); + if (isToggled && enabled && !onViewSourceFromContext) { +//// createTooltip(event); + GridItem item = grid.getItem(new Point(event.x, event.y)); + SourceLine sl = getCallerSourceLine(item); + viewSource(event.x, event.y, sl, false); + } + break; + case SWT.MouseExit: + if (!onViewSourceFromContext) { + disposeTooltip(); + } + break; + case SWT.MouseMove: + if (!onViewSourceFromContext) { + GridItem gridItem = grid.getItem(new Point(event.x, event.y)); + if (null == oldItem) { + oldItem = gridItem; + } + if (null != tooltip) { + if (null != gridItem) { + if (!gridItem.equals((GridItem) oldItem)) { + oldItem = gridItem; + } else { + return; + } + } + tooltip.dispose(); + tooltip = null; + } + } + break; + case SWT.MouseDoubleClick: + if (isToggled && enabled) { +// openIDE(event); + GridItem item = grid.getItem(new Point(event.x, event.y)); + SourceLine sl = getCallerSourceLine(item); + openIDE(sl, item); + } + break; + case SWT.MouseHover: +// grid.setFocus(); + if (isToggled && enabled && !onViewSourceFromContext) { +// createTooltip(event); + GridItem item = grid.getItem(new Point(event.x, event.y)); + SourceLine sl = getCallerSourceLine(item); + viewSource(event.x, event.y, sl, false); + } + break; + default: + break; + } + } + + public void setEnable(boolean enabled) { + this.enabled = enabled; + } + + public SourceLine getCallerSourceLine(GridItem item) { + if (item == null) { + return null; + } + // Gets source path and line. + DATableDataFormat tableData = (DATableDataFormat) item.getData(); + LogData data = null; + long addr = -1; + // boolean isPieBuild = AnalyzerUtil.isPieBuild(data.getPid()); + int pid = -1; + long time = 0; + String libName = null; + + switch (tableData.getType()) { + case AnalyzerConstants.TYPE_TABLE_CALLSTACK: + addr = (Long) item.getData(AnalyzerConstants.CALLSTACK_KEY_ADDR); + pid = (Integer) item.getData(AnalyzerConstants.CALLSTACK_KEY_PID); + time = (Long) item.getData(AnalyzerConstants.CALLSTACK_KEY_TIME); + libName = (String) item + .getData(AnalyzerConstants.CALLSTACK_KEY_LIBNAME); + break; + case AnalyzerConstants.TYPE_TABLE_FAILED: + List failedData = tableData.getData(); + addr = Long.parseLong(failedData.get(8)); + pid = Integer.parseInt(failedData.get(7)); + time = Long.parseLong(failedData.get(1)); + libName = failedData.get(9); + break; + case AnalyzerConstants.TYPE_TABLE_LEAK: + List leakData = tableData.getData(); + addr = Long.parseLong(leakData.get(9)); + pid = Integer.parseInt(leakData.get(1)); + time = Long.parseLong(leakData.get(4)); + libName = leakData.get(7); + break; + case AnalyzerConstants.TYPE_TABLE_WARNING: + data = tableData.getLogData(); + ProbeCommonData pData = (ProbeCommonData) data; + addr = pData.getCallerPcAddr(); + pid = data.getPid(); + time = data.getTime(); + libName = pData.getLibName(); + break; + case AnalyzerConstants.TYPE_TABLE_CALLTRACE: + data = tableData.getLogData(); + if (data instanceof UserFunctionData) { + addr = ((UserFunctionData) data).getCallerPcAddr(); + libName = ((UserFunctionData) data).getLibName(); + } else if (data instanceof ProfileData) { + addr = ((ProfileData) data).getCallerPcAddr(); + libName = ((ProfileData) data).getLibName(); + } + pid = data.getPid(); + time = data.getTime(); + break; + default: // normal + data = tableData.getLogData(); + ProbeCommonData wData = (ProbeCommonData) data; + addr = wData.getCallerPcAddr(); + pid = data.getPid(); + time = data.getTime(); + libName = wData.getLibName(); + } + return getSourceLine(addr, pid, time, libName); + } + + public SourceLine getDefinitionSourceLine(GridItem item) { + if (item == null) { + return null; + } + DATableDataFormat tableData = (DATableDataFormat) item.getData(); + long addr = -1; + String libName = null; + int pid = -1; + long time = 0; + + switch (tableData.getType()) { + case AnalyzerConstants.TYPE_TABLE_CALLTRACE: + LogData data = tableData.getLogData(); + if (data instanceof UserFunctionData) { + addr = ((UserFunctionData) data).getPcAddr(); + libName = ((UserFunctionData) data).getLibName(); + } else if (data instanceof ProfileData) { + addr = ((ProfileData) data).getPcAddr(); + libName = ((ProfileData) data).getLibName(); + } + pid = data.getPid(); + time = data.getTime(); + break; + default: + /* + * Do Nothing. + */ + break; + } + return getSourceLine(addr, pid, time, libName); + } + + public void viewSource(int x, int y, SourceLine sl, boolean onViewSourceFromContext) { + this.onViewSourceFromContext = onViewSourceFromContext; + GridItem item = grid.getItem(new Point(x, y)); + if (null != item) { + disposeTooltip(); + + if (null == sl + || sl.getError() != AnalyzerConstants.SOURCELINE_NOERROR) { + createErrorTooltip(x, y, sl.getError()); + return; + } + + // Creates tooltip. + Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell(); + final Display display = shell.getDisplay(); + display.addFilter(SWT.FocusOut, new Listener() { + @Override + public void handleEvent(Event event) { + disposeTooltip(); + display.removeFilter(SWT.FocusOut, this); + } + }); + display.addFilter(SWT.MouseDown, new Listener() { + @Override + public void handleEvent(Event event) { + disposeTooltip(); + display.removeFilter(SWT.MouseDown, this); + } + }); + tooltip = new Shell(shell, SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL); + tooltip.setBackground(ColorResources.TOOLTIP); + GridLayout gridLayout = new GridLayout(); + gridLayout.marginTop = MARGIN; + gridLayout.marginBottom = MARGIN; + gridLayout.marginLeft = MARGIN; + gridLayout.marginRight = MARGIN; + gridLayout.verticalSpacing = SPACING; + tooltip.setLayout(gridLayout); + + // Creates tooltip title label. + Label title = new Label(tooltip, SWT.NONE); + title.setFont(FontResources.TOOLTIP); + title.setForeground(ColorResources.BLACK); + title.setBackground(ColorResources.TOOLTIP); + + // Sets tooltip title text. + String filePath = getSourcePath(item, sl); + int line = sl.getLineNumber(); + title.setText(filePath + CommonConstants.SPACE + + CommonConstants.SPACE + CommonConstants.NEW_LINE); + + // Creates tooltip label. + Label top = new Label(tooltip, SWT.NONE); + top.setForeground(ColorResources.BLACK); + top.setBackground(ColorResources.TOOLTIP); + + Label center = new Label(tooltip, SWT.NONE); + center.setForeground(ColorResources.RED); + center.setBackground(ColorResources.TOOLTIP); + + Label bottom = new Label(tooltip, SWT.NONE); + bottom.setForeground(ColorResources.BLACK); + bottom.setBackground(ColorResources.TOOLTIP); + + // Makes tooltip text. + BufferedReader reader = null; + StringBuilder topStr = new StringBuilder(CommonConstants.EMPTY); + StringBuilder centerStr = new StringBuilder(CommonConstants.EMPTY); + StringBuilder bottomStr = new StringBuilder(CommonConstants.EMPTY); + try { + reader = new BufferedReader(new FileReader(filePath)); + int topStart = line - SOURCE_LINE_TOP; + if (0 > topStart - 1) { + topStart = 1; + } + int topEnd = line; + int bottomStart = line + 1; + int bottomEnd = line + SOURCE_LINE_BOTTOM; + + for (int i = 0; i < topStart - 1; i++) { + reader.readLine(); + } + + String temp = null; + for (int i = topStart; i < topEnd; i++) { + if (null != (temp = reader.readLine())) { + topStr.append(i + CommonConstants.TAB + temp); + } else { + break; + } + if (i != topEnd - 1) { + topStr.append(CommonConstants.NEW_LINE); + } + } + + if (null != (temp = reader.readLine())) { + centerStr.append(line + CommonConstants.TAB + temp); + } + + for (int i = bottomStart; i < bottomEnd; i++) { + if (null != (temp = reader.readLine())) { + bottomStr.append(i + CommonConstants.TAB + temp); + } else { + break; + } + if (i != bottomEnd - 1) { + bottomStr.append(CommonConstants.NEW_LINE); + } + } + } catch (FileNotFoundException e) { + // e.printStackTrace(); + createErrorTooltip(x, y, + AnalyzerConstants.SOURCE_FILE_NOT_FOUND); + } catch (IOException e) { + e.printStackTrace(); + } finally { + CommonUtil.tryClose(reader); + } + + // Sets tooltip text. + top.setText(topStr.toString()); + center.setText(centerStr.toString()); + bottom.setText(bottomStr.toString()); + + tooltipShow(x, y); + } + + } + + public void openIDE(SourceLine sl, GridItem gridItem) { + if (null == gridItem) { + return; + } + if ((null == sl) || (!sl.isValid()) + || (IDECommunicator.isConnected() == false)) { + createErrorPopup(AnalyzerLabels.IDE_NOT_LAUNCHED); + return; + } + String filePath = getSourcePath(gridItem, sl); + int lineNum = sl.getLineNumber(); + IDECommunicator.sendCodeInfoToIDE(filePath, Integer.toString(lineNum)); + } + + private void setViewCursor(boolean toggled) { + if (!toggled) { + grid.setCursor(defaultCursor); +// disposeTooltip(); + } else { + grid.setCursor(sourceCursor); + } + } + + private void createErrorPopup(String message) { + Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell(); + DADialog warning = new DADialog(shell, SWT.NONE); + warning.setMessage(message); + warning.setIcon(ImageResources.DIALOG_WARNING_ICON); + warning.open(); + } + + private void createErrorTooltip(int x, int y, int errno) { + // Creates tooltip. + Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell(); + tooltip = new Shell(shell, SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL); + tooltip.setBackground(ColorResources.TOOLTIP); + GridLayout gridLayout = new GridLayout(); + gridLayout.marginTop = MARGIN; + gridLayout.marginBottom = MARGIN; + gridLayout.marginLeft = MARGIN; + gridLayout.marginRight = MARGIN; + gridLayout.verticalSpacing = SPACING; + tooltip.setLayout(gridLayout); + + // Creates tooltip title label. + Label title = new Label(tooltip, SWT.NONE); + title.setForeground(ColorResources.BLACK); + title.setBackground(ColorResources.TOOLTIP); + String text = AnalyzerConstants.sourcelineErrorMsg[errno]; + title.setText(text); + + tooltipShow(x, y); + } + + private String getSourcePath(GridItem item, SourceLine sourceLine) { + String filePath = null; + String libName = getLibPath(item); + + BinarySettingData binData = BinarySettingManager.getInstance() + .getRealBinarySetting(libName); + + if (null != binData && null != binData.getUserSourcePath() + && !binData.getUserSourcePath().isEmpty()) { + String fileName = getSourceFilePath(sourceLine.getFilePath()); + filePath = binData.getUserSourcePath() + File.separator + fileName; + } else { + if (!isLibrary(libName)) { + filePath = sourceLine.getFilePath(); + } else { + filePath = binData.getDebugSourcePath() + + sourceLine.getFilePath(); + } + } + return filePath; + } + + private String getSourceFilePath(String sourcePath) { + int index = sourcePath.lastIndexOf("src/"); + String filePath = sourcePath.substring(index + 4, sourcePath.length()); + return filePath; + } + + private void tooltipShow(int x, int y) { + Point size = tooltip.computeSize(SWT.DEFAULT, SWT.DEFAULT); + Point pt = grid.toDisplay(x, y); + Rectangle displayRect = Display.getCurrent().getBounds(); + // 1. right side check! + pt.x = ((pt.x + size.x) > displayRect.width) ? pt.x - size.x + - TOOLTIP_OFFSET : pt.x + TOOLTIP_OFFSET; + // 2. bottom check! + pt.y = ((pt.y + size.y) > displayRect.height) ? pt.y - size.y + - TOOLTIP_OFFSET : pt.y + TOOLTIP_OFFSET; + tooltip.setBounds(pt.x, pt.y, size.x, size.y); + tooltip.setVisible(true); + } + + private void disposeTooltip() { + if (null != tooltip && !tooltip.isDisposed()) { + tooltip.dispose(); + tooltip = null; + onViewSourceFromContext = false; + } + } + + private String getLibPath(GridItem item) { + DATableDataFormat tableData = (DATableDataFormat) item.getData(); + String libName = null; + switch (tableData.getType()) { + case AnalyzerConstants.TYPE_TABLE_CALLSTACK: + // addr = (Long) tableData.getObject(); + libName = item.getText(2); + break; + case AnalyzerConstants.TYPE_TABLE_FAILED: + List failedData = tableData.getData(); + libName = failedData.get(9); + break; + case AnalyzerConstants.TYPE_TABLE_LEAK: + List leakData = tableData.getData(); + libName = leakData.get(7); + break; + case AnalyzerConstants.TYPE_TABLE_WARNING: + ProbeCommonData pData = (ProbeCommonData) tableData.getLogData(); + libName = pData.getLibName(); + break; + case AnalyzerConstants.TYPE_TABLE_CALLTRACE: + LogData data = tableData.getLogData(); + if (data instanceof UserFunctionData) { + libName = ((UserFunctionData) data).getLibName(); + } else if (data instanceof ProfileData) { + libName = ((ProfileData) data).getLibName(); + } + break; + default: // normal + ProbeCommonData wData = (ProbeCommonData) tableData.getLogData(); + libName = wData.getLibName(); + } + return libName; + } + + private boolean isLibrary(String binaryPath) { + if (binaryPath.contains(".so")) { + return true; + } + return false; + } + + private SourceLine getSourceLine(long addr, int pid, long time, String libName) { + ProcessInfoPackage processInfoPkg = AnalyzerManager.getProject() + .getProcessInfo(pid); + ProcessInfo processInfo = processInfoPkg.getProcessInfo(time); + BinaryInfo binInfo = processInfo.getTargetBinary(addr); + if (binInfo == null) { + SourceLine sl = new SourceLine(); + sl.setError(AnalyzerConstants.SOURCELINE_NO_SOURCELINE_DATA); + return sl; + } + boolean isPieBuild = (binInfo.getType() == 1) ? true : false; + + String baseAddr = null; + String path = null; + if (!isLibrary(libName)) { + baseAddr = Long.toString(processInfo.getLowestAddress()); + } else { + LibraryObject libObj = processInfo.getLibObjHash().get(libName); + if (null != libObj) { + baseAddr = Long.toString(libObj.getLowestAddress()); + } else { + SourceLine sl = new SourceLine(); + sl.setError(AnalyzerConstants.SOURCELINE_NO_SOURCELINE_DATA); + return sl; + } + } + + BinarySettingData binData = BinarySettingManager.getInstance() + .getRealBinarySetting(binInfo.getTargetBinaryPath()); + if (null != binData) { + String debugPath = binData.getDebugFilePath(); + if (null != debugPath && !debugPath.isEmpty()) { + path = debugPath; + } else { + path = binInfo.getTempBinaryPath(); + } + } else { + path = binInfo.getTempBinaryPath(); + } + SourceLine sl = SymbolManager.addr2line(path, addr, isPieBuild, + baseAddr); + return sl; + } +} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/kernel/KernelListTable.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/kernel/KernelListTable.java index 9d34755..5af41fd 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/kernel/KernelListTable.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/kernel/KernelListTable.java @@ -54,7 +54,7 @@ public class KernelListTable extends DAWindowingTableComposite { public KernelListTable(Composite parent, int compStyle, int tableStyle) { super(parent, compStyle, tableStyle); setDataType(false, KernelDataMaker.CONTEXT_DATA_COLUMN_INDEX_STARTTIME); - setRangePopup(); + setContextMenu(AnalyzerConstants.CONTEXT_TABLE_RANGE); table.addSelectionListener(new SelectionListener() { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/summary/failed/FailedApiTable.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/summary/failed/FailedApiTable.java index 73e3c8d..32473f6 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/summary/failed/FailedApiTable.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/summary/failed/FailedApiTable.java @@ -52,7 +52,7 @@ public class FailedApiTable extends DATableComposite { public FailedApiTable(Composite parent, int style, int tableStyle) { super(parent, style, tableStyle); - setRangePopup(); + setContextMenu(AnalyzerConstants.CONTEXT_TABLE_RANGE); table.addSelectionListener(new SelectionListener() { @Override diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/summary/leaks/LeakTable.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/summary/leaks/LeakTable.java index 6712caf..c4d0fcd 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/summary/leaks/LeakTable.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/summary/leaks/LeakTable.java @@ -56,7 +56,7 @@ public class LeakTable extends DATreeComposite { public LeakTable(Composite parent, int compStyle, int tableStyle) { super(parent, compStyle, tableStyle); - setRangePopup(); + setContextMenu(AnalyzerConstants.CONTEXT_TABLE_RANGE); table.addListener(SWT.Expand, new Listener() { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/summary/warning/WarningTable.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/summary/warning/WarningTable.java index a612366..35b0320 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/summary/warning/WarningTable.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/summary/warning/WarningTable.java @@ -49,7 +49,7 @@ public class WarningTable extends DATableComposite { public WarningTable(Composite parent, int compStyle, int tableStyle) { super(parent, compStyle, tableStyle); - setRangePopup(); + setContextMenu(AnalyzerConstants.CONTEXT_TABLE_RANGE); table.addSelectionListener(new SelectionListener() { @Override diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/calltrace/CallTraceTable.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/calltrace/CallTraceTable.java index f1a8d25..24f90e4 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/calltrace/CallTraceTable.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/calltrace/CallTraceTable.java @@ -59,7 +59,7 @@ import org.tizen.dynamicanalyzer.utils.Formatter; public class CallTraceTable extends DAWindowingTableComposite { public CallTraceTable(Composite parent, int compStyle, int tableStyle) { super(parent, compStyle, tableStyle); - setRangePopup(); + setContextMenu(AnalyzerConstants.CONTEXT_TABLE_SOURCE | AnalyzerConstants.CONTEXT_TABLE_RANGE); table.addSelectionListener(new SelectionListener() { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/userinterface/scene/UISceneListTable.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/userinterface/scene/UISceneListTable.java index 98d4dab..fb7c19e 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/userinterface/scene/UISceneListTable.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/userinterface/scene/UISceneListTable.java @@ -33,6 +33,7 @@ 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.model.TableInput; @@ -49,7 +50,7 @@ public class UISceneListTable extends DATableComposite { public UISceneListTable(Composite parent, int style, int tableStyle) { super(parent, style, tableStyle); - setRangePopup(); + setContextMenu(AnalyzerConstants.CONTEXT_TABLE_RANGE); table.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/table/DAApiListTableComposite.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/table/DAApiListTableComposite.java index 4b1b10b..3a7636f 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/table/DAApiListTableComposite.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/table/DAApiListTableComposite.java @@ -39,7 +39,7 @@ public class DAApiListTableComposite extends DATableComposite { public DAApiListTableComposite(Composite parent, int compStyle, int tableStyle) { super(parent, compStyle, tableStyle); - setRangePopup(); + setContextMenu(AnalyzerConstants.CONTEXT_TABLE_RANGE); setComparator(new DefaultTableComparator()); comparator.setType(AnalyzerConstants.SORT_TYPE_NUM); diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/table/DATableComposite.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/table/DATableComposite.java index dfd078e..a04f4f7 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/table/DATableComposite.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/table/DATableComposite.java @@ -48,10 +48,14 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Event; 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.communicator.IDECommunicator; import org.tizen.dynamicanalyzer.constant.CommonConstants; import org.tizen.dynamicanalyzer.listeners.TableTooltipListener; import org.tizen.dynamicanalyzer.model.FindProperty; import org.tizen.dynamicanalyzer.model.TableInput; +import org.tizen.dynamicanalyzer.nl.AnalyzerLabels; import org.tizen.dynamicanalyzer.nl.TimelineChartLabels; import org.tizen.dynamicanalyzer.resources.ColorResources; import org.tizen.dynamicanalyzer.resources.FontResources; @@ -602,11 +606,145 @@ public abstract class DATableComposite extends Composite { } } } - - public void setRangePopup() { - popupMenu = new DAPopupMenu(table); - popupMenu.setFont(FontResources.CONTEXT_MENU_ITEM_FONT); - DAPopupMenuItem startItem = new DAPopupMenuItem(popupMenu); + + public void setContextMenu(final int context) { + popupMenu = new DAPopupMenu(table); + popupMenu.setFont(FontResources.CONTEXT_MENU_ITEM_FONT); + + if ((context & AnalyzerConstants.CONTEXT_TABLE_RANGE) != 0) { + setRangeContext(); + } + if ((context & AnalyzerConstants.CONTEXT_TABLE_RANGE) != 0 && + (context & AnalyzerConstants.CONTEXT_TABLE_SOURCE) != 0) { + new DAPopupMenuItem(popupMenu, DAPopupMenuItem.SEPARATOR); + } + if ((context & AnalyzerConstants.CONTEXT_TABLE_SOURCE) != 0) { + setSourceContext(); + } + table.addListener(SWT.MouseDown, new Listener() { + @Override + public void handleEvent(Event event) { + // 3 means mouse right button click + if (event.button == 3) { + List menuItems = popupMenu.getItems(); + int size = menuItems.size(); + GridItem item = table.getItem(mousePoint); + for (int i = 0; i < size; i++) { + DAPopupMenuItem menuItem = menuItems.get(i); + if ((menuItem.getType() != DAPopupMenuItem.SEPARATOR)) { + setEnableContextMenuItem(menuItem, item); + } + } + } + } + }); + } + + private void setEnableContextMenuItem(DAPopupMenuItem menuItem, GridItem gridItem) { + if (gridItem == null) { + menuItem.setEnabled(false); + return; // when gridItem is null, not need to process + } + + 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")) { + SourceLine sl = tableListener.getCallerSourceLine(gridItem); + if (null == sl || sl.getError() != AnalyzerConstants.SOURCELINE_NOERROR) { + menuItem.setEnabled(false); + } else { + menuItem.setEnabled(true); + } + } else if (text.equals("View declaration source")) { + SourceLine sl = tableListener.getDefinitionSourceLine(gridItem); + if (null == sl || sl.getError() != AnalyzerConstants.SOURCELINE_NOERROR) { + menuItem.setEnabled(false); + } else { + menuItem.setEnabled(true); + } + } else if (text.equals("Open caller source")) { + SourceLine sl = tableListener.getCallerSourceLine(gridItem); + if ((null == sl) || (!sl.isValid()) + || (IDECommunicator.isConnected() == false)) { + menuItem.setEnabled(false); + } else { + menuItem.setEnabled(true); + } + } else if (text.equals("Open declaration source")) { + SourceLine sl = tableListener.getDefinitionSourceLine(gridItem); + if ((null == sl) || (!sl.isValid()) + || (IDECommunicator.isConnected() == false)) { + menuItem.setEnabled(false); + } else { + menuItem.setEnabled(true); + } + } + } + + private void setSourceContext() { + DAPopupMenuItem viewCallerItem = new DAPopupMenuItem(popupMenu); + viewCallerItem.setText("View caller source"); + viewCallerItem.addListener(new DAPopupMenuListener() { + @Override + public void widgetSelected(DAPopupMenuItem menuItem) { + GridItem item = table.getItem(new Point(mousePoint.x, mousePoint.y)); + SourceLine sl = tableListener.getCallerSourceLine(item); + tableListener.viewSource(mousePoint.x, mousePoint.y, sl, true); + } + }); + + DAPopupMenuItem viewDeclarationItem = new DAPopupMenuItem(popupMenu); + viewDeclarationItem.setText("View declaration source"); + viewDeclarationItem.addListener(new DAPopupMenuListener() { + @Override + public void widgetSelected(DAPopupMenuItem menuItem) { + GridItem item = table.getItem(new Point(mousePoint.x, mousePoint.y)); + SourceLine sl = tableListener.getDefinitionSourceLine(item); + tableListener.viewSource(mousePoint.x, mousePoint.y, sl, true); + } + }); + + DAPopupMenuItem openCallerItem = new DAPopupMenuItem(popupMenu); + openCallerItem.setText("Open caller source"); + openCallerItem.addListener(new DAPopupMenuListener() { + @Override + public void widgetSelected(DAPopupMenuItem menuItem) { + GridItem item = table.getItem(new Point(mousePoint.x, mousePoint.y)); + SourceLine sl = tableListener.getCallerSourceLine(item); + tableListener.openIDE(sl, item); + } + }); + + DAPopupMenuItem openDeclarationItem = new DAPopupMenuItem(popupMenu); + openDeclarationItem.setText("Open declaration source"); + openDeclarationItem.addListener(new DAPopupMenuListener() { + @Override + public void widgetSelected(DAPopupMenuItem menuItem) { + GridItem item = table.getItem(new Point(mousePoint.x, mousePoint.y)); + SourceLine sl = tableListener.getDefinitionSourceLine(item); + tableListener.openIDE(sl, item); + } + }); + } + + private void setRangeContext() { + DAPopupMenuItem startItem = new DAPopupMenuItem(popupMenu); startItem.setText(TimelineChartLabels.RANGE_CONTEXT_SET_START); startItem.addListener(new DAPopupMenuListener() { @Override @@ -637,47 +775,8 @@ public abstract class DATableComposite extends Composite { rangeDataManager.initRange(); } }); - - table.addListener(SWT.MouseDown, new Listener() { - - @Override - public void handleEvent(Event event) { - // 3 means mouse right button click - if (event.button == 3) { - List menuItems = popupMenu.getItems(); - int size = menuItems.size(); - GridItem item = table.getItem(mousePoint); - - for (int i = 0; i < size; i++) { - if (i == 0 || i == 1) { - if (null != item) { - if (!menuItems.get(i).isEnabled()) { - menuItems.get(i).setEnabled(true); - } - } else { - if (menuItems.get(i).isEnabled()) { - menuItems.get(i).setEnabled(false); - } - } - } else if (i == 2) { - if (rangeDataManager.isAnalyzable()) { - menuItems.get(i).setEnabled(true); - } else { - menuItems.get(i).setEnabled(false); - } - } else if (i == 3) { - if (rangeDataManager.isBeingAnalyzed()) { - menuItems.get(i).setEnabled(true); - } else { - menuItems.get(i).setEnabled(false); - } - } - } - } - } - }); } - + public void setAutoColumnPackEnabled(boolean enabled) { autoColumnPack = enabled; }