public class DACustomCombo extends Canvas {
private static final DALogger DA_LOG = DALogger.getInstance();
-
+
public static final int MAX_SIZE = 10;
public static final int STATE_NORMAL = 0;
public static final int STATE_HOVER = 1;
private Font itemFont = null;
private Color itemFontColor = null;
private IDACustomComboPopupRenderer popupRenderer = new DACustomComboPopupRenderer();
-
+
// combo button
private int state = STATE_NORMAL; // 0 normal 1 hover 2 push 3 disable
protected DACustomButtonAttribute attr;
private IDACustomButtonRenderer comboRenderer = new DACustomComboRenderer();
-
+
// arrow button
private static final int arrowButtonHeight = 15;
private DACustomButton upArrowButton = null;
- private DACustomButton downArrowButton = null;
+ private DACustomButton downArrowButton = null;
private Image buttonUp = null;
private Image buttonDown = null;
private List<Color> arrowColors = null;
public void setFontPoint(Point fontPoint) {
attr.setFontPoint(fontPoint);
}
-
+
public String getText() {
if (selection < 0) {
return attr.getText();
if (buttonUp == null) {
upArrowButton.setText(Messages.DACustomCombo_1);
} else {
- upArrowButton.setButtonImages(buttonUp,
- buttonUp, buttonUp, buttonUp);
+ upArrowButton.setButtonImages(buttonUp, buttonUp, buttonUp, buttonUp);
}
FormData data = new FormData();
data.top = new FormAttachment(0, 0);
if (null == buttonDown) {
downArrowButton.setText(Messages.DACustomCombo_2);
} else {
- downArrowButton.setButtonImages(buttonDown,
- buttonDown, buttonDown, buttonDown);
+ downArrowButton.setButtonImages(buttonDown, buttonDown, buttonDown,
+ buttonDown);
}
data = new FormData();
data.top = new FormAttachment(popup, 0);
data.height = arrowButtonHeight;
downArrowButton.setLayoutData(data);
downArrowButton.addListener(SWT.MouseExit, downButtonMouseListener);
- downArrowButton
- .addListener(SWT.MouseEnter, downButtonMouseListener);
+ downArrowButton.addListener(SWT.MouseEnter, downButtonMouseListener);
downArrowButton.addListener(SWT.MouseUp, downButtonMouseListener);
downArrowButton.addListener(SWT.FocusIn, downButtonMouseListener);
downArrowButton.addListener(SWT.FocusOut, downButtonMouseListener);
}
getRects().clear();
- DA_LOG.debug("rects clear and add new rects. count is :"
- + boundSize);
+ DA_LOG.debug("rects clear and add new rects. count is :" + boundSize);
for (int i = 0; i < boundSize; i++) {
- Rectangle r = new Rectangle(2, 2 + i * height, shellWidth - 2,
- height);
+ Rectangle r = new Rectangle(2, 2 + i * height, shellWidth - 2, height);
getRects().add(r);
}
childShell.open();
for (int i = 0; i < size; i++) {
input.add(items.get(tmpItemIndex + i));
}
- popupRenderer.draw(e.gc, popup, getRects(), tmpSelection,
- input, itemFont, itemFontColor);
+ popupRenderer.draw(e.gc, popup, getRects(), tmpSelection, input, itemFont,
+ itemFontColor);
}
};
if (index < 0) {
return false;
}
-
+
itemIndex = 0;
int size = items.size();
if (size < MAX_SIZE) {
DA_LOG.debug("Combo indexing bug!");
return false;
}
-
+
selection = index;
select(selection);
}
} else {
setText(DAWidgetConstants.EMPTY_STRING);
}
- childShell.close();
+ if (childShell != null) {
+ childShell.close();
+ }
childShell = null;
}
DA_LOG.debug("DACustomCombo drawType : " + state);
}
}
-
+
private PaintListener comboPaintListener = new PaintListener() {
@Override
- public void paintControl(PaintEvent e) {
+ public void paintControl(PaintEvent e) {
comboRenderer.draw(e.gc, combo, state, attr);
}
};
}
return DAWidgetConstants.EMPTY_STRING;
}
-
+
public void setComboColors(Color normal, Color push, Color hover, Color disable) {
attr.setColor(STATE_NORMAL, normal);
attr.setColor(STATE_HOVER, hover);
attr.setColor(STATE_DISABLE, disable);
attr.setDrawType(TYPE_COLOR);
}
-
- public void setComboGradation(Color normalStart, Color normalEnd,
- Color pushStart, Color pushEnd, Color hoverStart, Color hoverEnd,
- Color disableStart, Color disableEnd) {
+
+ public void setComboGradation(Color normalStart, Color normalEnd, Color pushStart,
+ Color pushEnd, Color hoverStart, Color hoverEnd, Color disableStart,
+ Color disableEnd) {
attr.setColor(0, normalStart);
attr.setColor(1, normalEnd);
attr.setColor(2, hoverStart);
attr.setColor(4, pushStart);
attr.setColor(5, pushEnd);
attr.setColor(6, disableStart);
- attr.setColor(7, disableEnd);
+ attr.setColor(7, disableEnd);
attr.setDrawType(TYPE_GRADATION);
}
-
+
public void setImages(Image normal, Image hover, Image push, Image disable) {
if (null == normal || null == hover || null == push || null == disable) {
DA_LOG.debug("DACustomCombo setImages parameter is null");
attr.setDrawType(TYPE_IMAGE);
}
- public void setOutlineColors(Color normal, Color push, Color hover,
- Color disable) {
+ public void setOutlineColors(Color normal, Color push, Color hover, Color disable) {
attr.setOutlineColor(STATE_NORMAL, normal);
attr.setOutlineColor(STATE_HOVER, hover);
attr.setOutlineColor(STATE_PUSH, push);
attr.setButtonImage(STATE_PUSH, push);
attr.setButtonImage(STATE_DISABLE, disable);
}
-
+
public void setComboImagePoint(Point comboImagePoint) {
attr.setButtonImagePoint(comboImagePoint);
}
-
+
private Listener upButtonMouseListener = new Listener() {
@Override
public void handleEvent(Event event) {
Rectangle rect = upButton.getBounds();
if (event.type == SWT.MouseExit) {
- if (event.y < rect.y || event.x < rect.x
- || event.x > rect.x + rect.width) {
+ if (event.y < rect.y || event.x < rect.x || event.x > rect.x + rect.width) {
closePopup(CLOSE_WAITING_TIME);
}
}
int x = event.x;
int y = event.y;
- if (x < 0 || x > rectangle.width || y < 0
- || y > rectangle.height) {
+ if (x < 0 || x > rectangle.width || y < 0 || y > rectangle.height) {
return;
}
}
Rectangle rect = upButton.getClientArea();
if (event.type == SWT.MouseExit) {
- if (event.y > rect.y || event.x < rect.x
- || event.x > rect.x + rect.width) {
+ if (event.y > rect.y || event.x < rect.x || event.x > rect.x + rect.width) {
closePopup(CLOSE_WAITING_TIME);
}
}
int x = event.x;
int y = event.y;
- if (x < 0 || x > rectangle.width || y < 0
- || y > rectangle.height) {
+ if (x < 0 || x > rectangle.width || y < 0 || y > rectangle.height) {
return;
}
}
itemIndex = 0;
}
- public void setComboButtonColor(Color normal, Color push, Color hover,
- Color disable) {
+ public void setComboButtonColor(Color normal, Color push, Color hover, Color disable) {
arrowColors = new ArrayList<Color>();
arrowColors.add(normal);
arrowColors.add(hover);
arrowColors.add(disable);
}
- public void setComboButtonImage(Image normal, Image push, Image hover,
- Image disable) {
+ public void setComboButtonImage(Image normal, Image push, Image hover, Image disable) {
arrowImages = new ArrayList<Image>();
arrowImages.add(normal);
arrowImages.add(push);
}
return arrowOutlineColors;
}
-
- public void setArrowOutlineColors(Color normal, Color push, Color hover,
- Color disable) {
+
+ public void setArrowOutlineColors(Color normal, Color push, Color hover, Color disable) {
List<Color> comboArrowOutlineColors = getArrowOutlineColors();
comboArrowOutlineColors.add(normal);
comboArrowOutlineColors.add(hover);
comboArrowOutlineColors.add(push);
comboArrowOutlineColors.add(disable);
}
-
+
private DACustomButton makeButton() {
DACustomButton button = null;
if (arrowImages != null) {
// image
- button = new DACustomButton(childShell,
- arrowImages.get(STATE_NORMAL), arrowImages.get(STATE_PUSH),
- arrowImages.get(STATE_HOVER),
+ button = new DACustomButton(childShell, arrowImages.get(STATE_NORMAL),
+ arrowImages.get(STATE_PUSH), arrowImages.get(STATE_HOVER),
arrowImages.get(STATE_DISABLE));
} else if (arrowColors != null) {
if (arrowColors.size() > 4) {
// gradation
- button = new DACustomButton(childShell,
- arrowColors.get(STATE_NORMAL),
+ button = new DACustomButton(childShell, arrowColors.get(STATE_NORMAL),
arrowColors.get(STATE_NORMAL + 1),
arrowColors.get(STATE_PUSH * 2),
arrowColors.get(STATE_PUSH * 2 + 1),
// color
button = new DACustomButton(childShell, SWT.NONE);
button.setColors(arrowColors.get(STATE_NORMAL),
- arrowColors.get(STATE_PUSH),
- arrowColors.get(STATE_HOVER),
+ arrowColors.get(STATE_PUSH), arrowColors.get(STATE_HOVER),
arrowColors.get(STATE_DISABLE));
}
-
+
if (arrowOutlineColors != null) {
button.setOutlineColors(arrowOutlineColors.get(STATE_NORMAL),
- arrowOutlineColors.get(STATE_PUSH),
- arrowOutlineColors.get(STATE_HOVER),
+ arrowOutlineColors.get(STATE_PUSH),
+ arrowOutlineColors.get(STATE_HOVER),
arrowOutlineColors.get(STATE_DISABLE));
}
} else {
attr.setFont(font);
}
- public void setFontColors(Color normal, Color push, Color hover,
- Color disable) {
+ public void setFontColors(Color normal, Color push, Color hover, Color disable) {
attr.setFontColor(STATE_NORMAL, normal);
attr.setFontColor(STATE_PUSH, push);
attr.setFontColor(STATE_HOVER, hover);
attr.setFontColor(STATE_DISABLE, disable);
}
-
+
public void setItemFontColor(Color itemFontColor) {
this.itemFontColor = itemFontColor;
}
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 LIB_EXT = ".so"; //$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 final static String CALLSTACK_KEY_TIME = "time";//$NON-NLS-1$
public final static String CALLSTACK_KEY_LIBNAME = "libName";//$NON-NLS-1$
- public final static String WITHOUT_EXECUTABLE = "<Without executable>";//$NON-NLS-1$
public final static String APPCONTROL = "_AppControl";//$NON-NLS-1$
+ public final static String RUNNING_PROCESS = "<Running process>";//$NON-NLS-1$
+ public final static String WITHOUT_EXECUTABLE = "<Without executable>";//$NON-NLS-1$
+ public final static String COMMON_EXECUTABLE = "<Common executable>";//$NON-NLS-1$
public final static int SASH_WIDTH = 4;
}
public static final String CMD_REMOVE = "rm -rf"; //$NON-NLS-1$
public static final String CMD_APPLICATION_LIST = "/usr/bin/pkginfo --listpkg";
+ public static final String CMD_PROCESS_LIST = "ps -ew -o pid,command";
public static final String CMD_UPLOAD_FILE_LIST = "du -b " + //$NON-NLS-1$
PathConstants.DA_REMOTE_PATH + AnalyzerConstants.READELF_BIN;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
import org.eclipse.swt.widgets.Display;
import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
private static SmartDevelopmentBridge sdbBridge = null;
- private static List<String> packageInfoMultiLines = new ArrayList<String>();
+ private static List<String> cmdResultMultiLines = new ArrayList<String>();
private static List<DeviceInfo> devices = null;
setNewBridge();
isRunning = false;
devices = null;
- packageInfoMultiLines.clear();
+ cmdResultMultiLines.clear();
filterMultiLines.clear();
uploadDataResult.clear();
unittestList.clear();
if (null == GlobalInformation.getCurrentDeviceInfo()) {
return null;
}
- List<AppInfo> appInfoList = GlobalInformation.getCurrentDeviceInfo().getAppInfoList();
+ List<AppInfo> appInfoList = GlobalInformation.getCurrentDeviceInfo()
+ .getAppInfoList();
HashMap<String, AppInfo> appInfoHash = GlobalInformation.getCurrentDeviceInfo()
.getAppInfoHash();
List<AppInfo> backList = new ArrayList<AppInfo>();
backList.addAll(appInfoHash.values());
- packageInfoMultiLines.clear();
+ cmdResultMultiLines.clear();
CommunicatorUtils.execShellCommand(AnalyzerShellCommands.CMD_APPLICATION_LIST,
new MultiLineReceiver() {
@Override
public void processNewLines(String[] appLines) {
for (int i = 0; i < appLines.length; i++) {
- packageInfoMultiLines.add(appLines[i]);
+ cmdResultMultiLines.add(appLines[i]);
}
}
});
+ cmdResultMultiLines.add("");
+
checkUnittest();
checkIME();
- int size = packageInfoMultiLines.size();
+ // add lines for running process
+ cmdResultMultiLines.add(AppInfo.PROPERTY.APPID.name + ":"
+ + AnalyzerConstants.RUNNING_PROCESS);
+ cmdResultMultiLines.add(AppInfo.PROPERTY.PACKAGE.name + ":"
+ + AnalyzerConstants.RUNNING_PROCESS);
+ cmdResultMultiLines.add(AppInfo.PROPERTY.LABEL.name + ":"
+ + AnalyzerConstants.RUNNING_PROCESS);
+ cmdResultMultiLines.add(AppInfo.PROPERTY.APPTYPE.name + ":"
+ + AppInfo.APPTYPE_RUNNING);
+ cmdResultMultiLines.add("");
+
+ // add lines for without-executable
+ cmdResultMultiLines.add(AppInfo.PROPERTY.APPID.name + ":"
+ + AnalyzerConstants.COMMON_EXECUTABLE);
+ cmdResultMultiLines.add(AppInfo.PROPERTY.PACKAGE.name + ":"
+ + AnalyzerConstants.COMMON_EXECUTABLE);
+ cmdResultMultiLines.add(AppInfo.PROPERTY.LABEL.name + ":"
+ + AnalyzerConstants.COMMON_EXECUTABLE);
+ cmdResultMultiLines.add(AppInfo.PROPERTY.APPTYPE.name + ":"
+ + AppInfo.APPTYPE_EXEC);
+ cmdResultMultiLines.add("");
+
+ // add lines for without-executable
+ cmdResultMultiLines.add(AppInfo.PROPERTY.APPID.name + ":"
+ + AnalyzerConstants.WITHOUT_EXECUTABLE);
+ cmdResultMultiLines.add(AppInfo.PROPERTY.PACKAGE.name + ":"
+ + AnalyzerConstants.WITHOUT_EXECUTABLE);
+ cmdResultMultiLines.add(AppInfo.PROPERTY.LABEL.name + ":"
+ + AnalyzerConstants.WITHOUT_EXECUTABLE);
+ cmdResultMultiLines.add(AppInfo.PROPERTY.APPTYPE.name + ":"
+ + AppInfo.APPTYPE_NONE);
+ cmdResultMultiLines.add("");
+
+ int size = cmdResultMultiLines.size();
for (int i = 0; i < size; i++) {
- String line = packageInfoMultiLines.get(i);
- if (line.contains("Appid")) {
+ String line = cmdResultMultiLines.get(i);
+ if (line.startsWith("Appid")) {
List<String> lines = new ArrayList<String>();
int ii;
- for (ii = 0;; ii++) {
- String inputLine = packageInfoMultiLines.get(ii + i);
+ for (ii = 0; ii + i < size; ii++) {
+ String inputLine = cmdResultMultiLines.get(ii + i);
if (inputLine.isEmpty()) {
+ continue;
+ } else if (ii != 0 && inputLine.startsWith("Appid")) {
break;
}
- lines.add(packageInfoMultiLines.get(ii + i));
+ lines.add(cmdResultMultiLines.get(ii + i));
}
- AppInfo appInfo = makePackageInfo(GlobalInformation.getCurrentDeviceInfo(), lines);
- if (null != appInfo
- && (appInfo.getInfo(AppInfo.PROPERTY.APPTYPE.index).contains(
- AppInfo.APPTYPE_CPP)
- || appInfo.getInfo(AppInfo.PROPERTY.APPTYPE.index).contains(
- AppInfo.APPTYPE_WEB) || appInfo.getInfo(
- AppInfo.PROPERTY.APPTYPE.index).contains(AppInfo.APPTYPE_CAPP))) {
+ i += ii - 1;
+
+ AppInfo appInfo = makePackageInfo(
+ GlobalInformation.getCurrentDeviceInfo(), lines);
+ if (null != appInfo) {
// && appInfo.getInfo(AppInfo.MULTIPLE_INDEX).equals(
// AppInfo.FLAG_ZERO)
// && appInfo.getInfo(AppInfo.NODISPLAY_INDEX).equals(
backList.remove(appInfoHash.get(appId));
}
}
- i += ii;
}
}
if (!backList.isEmpty()) {
}
}
- // TODO : reconstruct real app list for app combo
- // relation between package and app?
- List<AppInfo> appcomboList = new ArrayList<AppInfo>();
- for (AppInfo app : appInfoList) {
- String appid = app.getInfo(AppInfo.PROPERTY.APPID.index);
- String pkgid = app.getInfo(AppInfo.PROPERTY.PACKAGE.index);
- if (appid.startsWith(pkgid) && !appid.contains(AnalyzerConstants.APPCONTROL)) {
- appcomboList.add(app);
+ return appInfoList;
+ }
+
+ public static Map<Integer, String> getProcessListFromTarget() {
+ if (null == GlobalInformation.getCurrentDeviceInfo()) {
+ return null;
+ }
+
+ Map<Integer, String> processMap = new TreeMap<Integer, String>();
+
+ cmdResultMultiLines.clear();
+
+ CommunicatorUtils.execShellCommand(AnalyzerShellCommands.CMD_PROCESS_LIST,
+ new MultiLineReceiver() {
+ @Override
+ public void processNewLines(String[] appLines) {
+ for (int i = 0; i < appLines.length; i++) {
+ cmdResultMultiLines.add(appLines[i]);
+ }
+ }
+ });
+
+ int size = cmdResultMultiLines.size();
+
+ // first line is column name line (PID COMMAND)
+ for (int i = 1; i < size; i++) {
+ String line = cmdResultMultiLines.get(i);
+ line = line.trim();
+
+ String[] splitline = line.split(CommonConstants.SPACE, 2);
+
+ if (splitline.length == 2) {
+ int pid = Integer.parseInt(splitline[0]);
+
+ processMap.put(Integer.valueOf(pid), splitline[1]);
}
}
- return appcomboList;
+ return processMap;
}
private static boolean isUnittest(String pkgId) {
for (int i = 0; i < lines.size(); i++) {
String line = lines.get(i);
int index = line.indexOf(":");
- String data = line.substring(index + 1, line.length()).trim();
- appInfo.setInfo(i, data);
+ if (index > 0) {
+ String key = line.substring(0, index).trim();
+ String data = line.substring(index + 1, line.length()).trim();
+
+ AppInfo.PROPERTY p = AppInfo.PROPERTY.get(key);
+ if (p != null) {
+ appInfo.setInfo(p.index, data);
+ }
+ }
}
String pkgId = appInfo.getInfo(AppInfo.PROPERTY.PACKAGE.index);
if (null != GlobalInformation.getCurrentDeviceInfo()) {
int size = GlobalInformation.getCurrentDeviceInfo().getAppInfoList().size();
for (int i = 0; i < size; i++) {
- AppInfo pkgInfo = GlobalInformation.getCurrentDeviceInfo().getAppInfoList().get(i);
+ AppInfo pkgInfo = GlobalInformation.getCurrentDeviceInfo()
+ .getAppInfoList().get(i);
if (pkgInfo.getInfo(AppInfo.PROPERTY.LABEL.index).equals(appLabel)) {
return pkgInfo;
}
if (null != GlobalInformation.getCurrentDeviceInfo()) {
int size = GlobalInformation.getCurrentDeviceInfo().getAppInfoList().size();
for (int i = 0; i < size; i++) {
- AppInfo ai = GlobalInformation.getCurrentDeviceInfo().getAppInfoList().get(i);
+ AppInfo ai = GlobalInformation.getCurrentDeviceInfo().getAppInfoList()
+ .get(i);
if (ai.getInfo(AppInfo.PROPERTY.PACKAGE.index).equals(pkgid)) {
return ai;
}
}
public static void removeCommand(String path) {
- CommunicatorUtils.execShellCommand(AnalyzerShellCommands.CMD_REMOVE + CommonConstants.SPACE
- + path);
+ CommunicatorUtils.execShellCommand(AnalyzerShellCommands.CMD_REMOVE
+ + CommonConstants.SPACE + path);
}
public static boolean isTargetEmulator() {
}
});
- DA_LOG.debug("device changed : " + device.getSerialNumber() + " " + changeMask);
+ DA_LOG.debug("device changed : " + device.getSerialNumber() + " "
+ + changeMask);
if (1 == changeMask) {
if (!AnalyzerManager.isRunning()) {
DeviceInfo devInfo = new DeviceInfo(device);
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
- ToolbarArea.getInstance().setDeviceComboItems(selectedDevice, deviceSerials);
+ ToolbarArea.getInstance().setDeviceComboItems(selectedDevice,
+ deviceSerials);
}
});
}
private static void clearDeviceAppInfo() {
GlobalInformation.setCurrentDeviceInfo(null);
GlobalInformation.setCurrentApplication(null);
- packageInfoMultiLines.clear();
+ cmdResultMultiLines.clear();
}
public static DeviceInfo setSelectedDeviceBySerial(String serial) {
DA_LOG.debug("Failed to get " + from); //$NON-NLS-1$
}
- AnalyzerUtil.checkLogs(PathManager.DA_LOG_PATH, DAEMONLOG_PREFIX, DAEMONLOG_COUNT);
+ AnalyzerUtil
+ .checkLogs(PathManager.DA_LOG_PATH, DAEMONLOG_PREFIX, DAEMONLOG_COUNT);
}
// public static String getLocalhost() {
}
public static BufferedReader getSockBufferedReader() {
- return GlobalInformation.getCurrentDeviceInfo().getCommunicator().getDataBufferedReader();
+ return GlobalInformation.getCurrentDeviceInfo().getCommunicator()
+ .getDataBufferedReader();
}
public static void closeAll() {
}
public static HostResult handleControlMessage(String msg) {
- return GlobalInformation.getCurrentDeviceInfo().getCommunicator().handleControlMessage(msg);
+ return GlobalInformation.getCurrentDeviceInfo().getCommunicator()
+ .handleControlMessage(msg);
}
public static HostResult sendBinaryInfoMessageForLib(List<BinarySettingData> input) {
if (isSWAPVersion()) {
- return ((Communicator30) GlobalInformation.getCurrentDeviceInfo().getCommunicator())
- .sendBinaryInfoMessageForLib(input);
+ return ((Communicator30) GlobalInformation.getCurrentDeviceInfo()
+ .getCommunicator()).sendBinaryInfoMessageForLib(input);
}
return null;
}
public static HostResult sendSWAPMessage(int messageId, List<BinarySettingData> input) {
if (isSWAPVersion()) {
- return ((Communicator30) GlobalInformation.getCurrentDeviceInfo().getCommunicator())
- .sendSWAPMessage(messageId, input);
+ return ((Communicator30) GlobalInformation.getCurrentDeviceInfo()
+ .getCommunicator()).sendSWAPMessage(messageId, input);
}
return null;
}
public static HostResult sendScreenShotMessage() {
if (isSWAPVersion()) {
- return ((Communicator30) GlobalInformation.getCurrentDeviceInfo().getCommunicator())
- .sendScreenShotRequest();
+ return ((Communicator30) GlobalInformation.getCurrentDeviceInfo()
+ .getCommunicator()).sendScreenShotRequest();
}
return null;
}
import org.tizen.dynamicanalyzer.util.CommonUtil;
import org.tizen.dynamicanalyzer.util.DALogger;
import org.tizen.dynamicanalyzer.util.WorkbenchUtil;
+import org.tizen.dynamicanalyzer.utils.RpmUtil;
import org.tizen.dynamicanalyzer.widgets.da.base.DADialog;
import org.tizen.dynamicanalyzer.workbench.SingletonFocusManager;
private static final String PROJECT_TYPE_LIBRARY = "4";
private static final int APPNAME_LENGTH = 20;
- private FileChannel fchannel = null; // maintain lock during DA running
+ private FileChannel fchannel = null; // maintain lock during DA running
private static BufferedWriter writer = null;
private static Thread instance;
DACommunicator.getAppListFromTarget();
AppInfo appInfo = null;
- final String appName;
if (projectType.equals(PROJECT_TYPE_OSP) || projectType.equals(PROJECT_TYPE_EFL)
|| projectType.equals(PROJECT_TYPE_WEBAPP)) {
appInfo = DACommunicator.getPkgInfoByAppPkgId(binaryOfTarget);
if (appInfo == null) {
- popupNotSupported(binaryOfTarget);
+ popupMessageUnsupportedApp(binaryOfTarget);
return;
}
SingletonFocusManager.setFocusToDA();
} else if (projectType.equals(PROJECT_TYPE_LIBRARY)) {
if (localPackagePathList.size() > 0) {
+ String mainrpm = null;
+ String debugrpm = null;
+ String srcrpm = null;
+
+ for (int i = 0; i < localPackagePathList.size(); i++) {
+ String path = localPackagePathList.get(i);
+ if (path.endsWith(RpmUtil.RPM_EXT)
+ && path.contains(RpmUtil.DEBUGINFO)) {
+ debugrpm = path;
+ } else if (path.endsWith(RpmUtil.RPM_EXT)
+ && path.contains(RpmUtil.DEBUGSOURCE)) {
+ srcrpm = path;
+ } else if (path.endsWith(RpmUtil.RPM_EXT)) {
+ mainrpm = path;
+ }
+ }
+
+ if (mainrpm != null) {
+ List<String> libfilelist = new ArrayList<String>();
+ List<String> filelist = RpmUtil.getFileListInRpm(mainrpm);
+ int filecount = filelist.size();
+ for (int i = 0; i < filecount; i++) {
+ String filepath = filelist.get(i);
+ int index = filepath.lastIndexOf("/");
+ String filename = filepath.substring(index + 1);
+ // search for libxxx.so or libxxx.so.x.x (library files)
+ if (filename.endsWith(AnalyzerConstants.LIB_EXT)
+ || filename.contains(AnalyzerConstants.LIB_EXT
+ + CommonConstants.DOT)) {
+ libfilelist.add(filepath);
+ }
+ }
+ if (libfilelist.size() > 0) {
+
+ } else {
+ DA_LOG.error("there is no library in rpm for library tracing");
+ popupMessage("Library tracing cannot be started.\nLibrary is not found in rpm.");
+ }
+ } else {
+ DA_LOG.error("there is no main rpm for library tracing");
+ popupMessage("Library tracing cannot be started.\nRpm is not found.");
+ }
} else {
DA_LOG.error("rpm package for library is not set");
}
} else {
// TODO : get appInfo from executable path
- popupNotSupported(executablePath);
- return;
+ popupMessageUnsupportedApp(executablePath);
}
}
- private void popupNotSupported(final String appName) {
+ private void popupMessageUnsupportedApp(final String appName) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell();
import java.io.InputStreamReader;
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.ElfSymbolExtractor;
import org.tizen.dynamicanalyzer.common.path.PathManager;
public final int index;
public final String name;
+ private static Map<String, PROPERTY> nameMap = new HashMap<String, PROPERTY>();
+ static {
+ for (PROPERTY p : PROPERTY.values()) {
+ nameMap.put(p.name, p);
+ }
+ }
+
private PROPERTY(int index, String name) {
this.index = index;
this.name = name;
}
+
+ public static PROPERTY get(String name) {
+ return nameMap.get(name);
+ }
}
public static final String LOCALPKGPATH = "LocalPackagePaths";
public static final String APPTYPE_CPP = "c++";//$NON-NLS-1$
public static final String APPTYPE_CAPP = "capp";//$NON-NLS-1$
public static final String APPTYPE_WEB = "webapp";//$NON-NLS-1$
+ public static final String APPTYPE_RUNNING = "running";//$NON-NLS-1$
+ public static final String APPTYPE_EXEC = "executable";//$NON-NLS-1$
+ public static final String APPTYPE_NONE = "none";//$NON-NLS-1$
+
public static final String FLAG_ZERO = "0";//$NON-NLS-1$
public static final String FLAG_ONE = "1";//$NON-NLS-1$
private String execFileName = null;
private List<String> localPackagePath = null;
+ private Map<Integer, String> runningProcesses = null;
private List<String> properties = new ArrayList<String>();
return properties.get(index);
}
+ public Map<Integer, String> getRunningProcesses() {
+ return runningProcesses;
+ }
+
+ public void setRunningProcesses(Map<Integer, String> runningProc) {
+ this.runningProcesses = runningProc;
+ }
+
public List<AddrSymbolPair> getSymbols(String sourceBinaryPath) {
List<AddrSymbolPair> symbols = null;
if (localPackagePath != null) {
abstract public void makeCallstackWithoutBacktrace(LogData inputData);
- abstract public boolean isIrregularUserCall(LogData input);
-
public void offerCallStackUnit(CallStackUnit csu) {
if (callstackInserter != null) {
callstackInserter.startInserterThread();
}
- // check irregular enter/exit log (multiple logs from 1 function call)
- public boolean isIrregularUserCall(LogData log) {
- ProfileData input = (ProfileData) log;
- Map<Long, CallStackUnit> addrMap = getCallStackApiAddrByPidMap(input.getPid());
- HashMap<Integer, DuplicateUserCall> dupUserCallMap = getDupUserCallByTidMap();
-
- boolean isPieBuild = isPieBuild(input.getPid(), input.getTime());
- ProcessMemoryMap pmap = AnalyzerManager.getProject()
- .getProcessInformation(input.getPid()).getProcessMemoryMap(log.getTime());
- if (pmap == null) {
- return false;
- }
-
- String sourceBinPath = AnalyzerUtil.getBinarySourcePath(input.getPid(),
- input.getTime());
- if (null == sourceBinPath || sourceBinPath.isEmpty()) {
- return false;
- }
-
- String baseAddr = Long.toString(pmap.getMainbinary().getLowestAddress());
- String strSelfAddr = Long.toString(input.getPcAddr());
-
- int tid = input.getTid();
- long selfAddr = input.getPcAddr();
-
- CallStackUnit selfCallstackUnit = addrMap.get(selfAddr);
-
- if (null == selfCallstackUnit) {
- String strSelfFuncName = SymbolManager.addr2func(sourceBinPath, strSelfAddr,
- isPieBuild, baseAddr);
- String strSelfSymbol = getUserFunctionPosition(input.getPid(),
- input.getTime())
- + AnalyzerConstants.CALLSTACK_API_TOKEN_STRING + strSelfFuncName;
- selfCallstackUnit = new CallStackUnit(selfAddr, strSelfSymbol, log);
- addrMap.put(selfAddr, selfCallstackUnit);
- }
-
- List<CallStackItem> userCallstack = getUserCallstack(tid);
- int size = userCallstack.size();
-
- int eventType = input.getId();
- if (size > 0) {
- if (eventType == MSG_FUNCTION_ENTRY) {
- CallStackUnit topCallstackUnit = userCallstack.get(size - 1)
- .getCallStackUnit();
- if (topCallstackUnit.equals(selfCallstackUnit)) {
- DuplicateUserCall dupUserCall = dupUserCallMap.get(tid);
- if (null == dupUserCall) {
- dupUserCall = new DuplicateUserCall(selfCallstackUnit);
- dupUserCallMap.put(tid, dupUserCall);
- } else {
- if (dupUserCall.getDupCallstackUnit().equals(selfCallstackUnit)) {
- dupUserCall.increaseDupCallCount();
- } else {
- DA_LOG.debug("isIrregularUserCall : dup callstack check error"); //$NON-NLS-1$
- }
- }
- return true;
- }
- } else if (eventType == MSG_FUNCTION_EXIT) {
- DuplicateUserCall dupUserCall = dupUserCallMap.get(tid);
- if (null != dupUserCall) {
- if (dupUserCall.getDupCallstackUnit().equals(selfCallstackUnit)) {
- dupUserCall.decreaseDupCallCount();
- if (0 == dupUserCall.getDupCallCount()) {
- dupUserCallMap.remove(tid);
- }
- } else {
- DA_LOG.debug("isIrregularUserCall : dup callstack check error"); //$NON-NLS-1$
- }
- return true;
- }
- }
- }
- return false;
- }
-
public void clear() {
callstackApiAddrByPidMap.clear();
callstackDataBySeqMap.clear();
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.NavigableMap;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
PackageInfo pkgInfo = DACommunicator.getSelectedPackage();
List<AppInfo> apps = pkgInfo.getAppInfos();
- // for (AppInfo app : apps)
- for (int ii = apps.size() - 1; ii >= 0; ii--) {
- AppInfo app = apps.get(ii);
- // TODO : remove
- if (app.getAppId().contains(AnalyzerConstants.APPCONTROL)) {
- continue;
- }
-
- // TODO : make new protocol field or message for launched app and
- // instrucmented app
- if (!app.getAppId().startsWith(app.getPackageId())) {
- continue;
- }
-
- BinaryInfo binInfo = AnalyzerManager.getProject().getDeviceStatusInfo()
- .getBinaryInfo(app.getExecPath());
- String temppath = binInfo.getTempBinaryPath();
- if (temppath == null) {
- // this means the app binary does not exist in device
- continue;
- }
+ if (pkgInfo.getPackageId().equals(AnalyzerConstants.RUNNING_PROCESS)) {
+ // if running process is selected for tracing
+ Map<Integer, String> selectedProcess = apps.get(0).getRunningProcesses();
+ if (selectedProcess != null && selectedProcess.size() > 0) {
+ for (Map.Entry<Integer, String> entry : selectedProcess.entrySet()) {
+ BinaryInfo binInfo = AnalyzerManager.getProject()
+ .getDeviceStatusInfo().getBinaryInfo(entry.getValue());
+ String temppath = binInfo.getTempBinaryPath();
+ if (temppath == null) {
+ // this means the app binary does not exist in device
+ continue;
+ }
- ApplicationInst appInst = new ApplicationInst();
-
- // TODO : add more app type or launch type (core app and efl app)
- String appType = app.getInfo(AppInfo.PROPERTY.APPTYPE.index);
- if (appType.contains(AppInfo.APPTYPE_CPP)) {
- appInst.setApplicationType(ApplicationInst.APPTYPE_TIZEN);
- appInst.setApplicationId(app.getAppId());
- } else if (appType.contains(AppInfo.APPTYPE_WEB)) {
- appInst.setApplicationType(ApplicationInst.APPTYPE_WEB);
- appInst.setApplicationId(app.getAppId());
-// } else if (appType.contains(AppInfo.APPTYPE_CAPP)) {
-// appInst.setApplicationType(ApplicationInst.APPTYPE_TIZEN);
-// appInst.setApplicationId(app.getAppId());
- } else {
- appInst.setApplicationType(ApplicationInst.APPTYPE_COMMON_EXEC);
- appInst.setApplicationId(CommonConstants.EMPTY);
+ ApplicationInst appInst = new ApplicationInst();
+ appInst.setApplicationType(ApplicationInst.APPTYPE_PROCESS);
+ appInst.setApplicationId(entry.getKey().toString());
+ appInst.setExecutablePath(entry.getValue());
+
+ List<FunctionInst> functionInstList = getFunctionInstList(apps.get(0), temppath);
+ appInst.getFunctionInstList().addAll(functionInstList);
+ appInst.setFunctionCount(functionInstList.size());
+ output.getAppInstList().add(appInst);
+ }
}
+ } else if (pkgInfo.getPackageId().equals(AnalyzerConstants.WITHOUT_EXECUTABLE)) {
+ // TODO : if no executable is selected for tracing (system wide
+ // tracing)
+ return null;
+ } else { // normal application is selected
+ for (int k = apps.size() - 1; k >= 0; k--) {
+ AppInfo app = apps.get(k);
+ // TODO : remove
+ if (app.getAppId().contains(AnalyzerConstants.APPCONTROL)) {
+ continue;
+ }
- appInst.setExecutablePath(app.getExecPath());
- DA_LOG.debug("Set execute path : " + app.getExecPath());
- List<AddrSymbolPair> symbols = app.getSymbols(temppath);
- List<FunctionInst> functionInstList = appInst.getFunctionInstList();
+ // TODO : make new protocol field or message for launched app
+ // and instrucmented app
+ if (!app.getAppId().startsWith(app.getPackageId())) {
+ continue;
+ }
- int size = (symbols == null) ? 0 : symbols.size();
- int exSize = 0;
- for (int i = 0; i < size; i++) {
- AddrSymbolPair addrSymbol = symbols.get(i);
- String symbol = addrSymbol.getSymbol();
- // FIXME: black list hard coded.
- if (symbol.contains("__i686.get_pc_thunk")) {
- exSize++;
+ BinaryInfo binInfo = AnalyzerManager.getProject().getDeviceStatusInfo()
+ .getBinaryInfo(app.getExecPath());
+ String temppath = binInfo.getTempBinaryPath();
+ if (temppath == null) {
+ // this means the app binary does not exist in device
continue;
}
- FunctionInst functionInst = new FunctionInst();
- functionInst.setAddr(addrSymbol.getAddr());
- functionInst.setArgs(getFunctionArgs(addrSymbol.getSymbol()));
- functionInstList.add(functionInst);
- // for debug
- // System.out.print("DEBUG : addr ");
- // AnalyzerUtil.printHexdecimal(addrSymbol.getAddr());
- // System.out.print(" symbol " + addrSymbol.getSymbol()
- // + " args ");
- // ByteUtils.printByteArray(functionInst.getArgs());
- // System.out.println();
+ ApplicationInst appInst = new ApplicationInst();
+
+ // TODO : add more app type or launch type (core and efl app)
+ String appType = app.getInfo(AppInfo.PROPERTY.APPTYPE.index);
+ if (appType.contains(AppInfo.APPTYPE_CPP)) {
+ appInst.setApplicationType(ApplicationInst.APPTYPE_TIZEN);
+ appInst.setApplicationId(app.getAppId());
+ } else if (appType.contains(AppInfo.APPTYPE_WEB)) {
+ appInst.setApplicationType(ApplicationInst.APPTYPE_WEB);
+ appInst.setApplicationId(app.getAppId());
+ // } else if (appType.contains(AppInfo.APPTYPE_CAPP)) {
+ // appInst.setApplicationType(ApplicationInst.APPTYPE_TIZEN);
+ // appInst.setApplicationId(app.getAppId());
+ } else {
+ appInst.setApplicationType(ApplicationInst.APPTYPE_COMMON_EXEC);
+ appInst.setApplicationId(CommonConstants.EMPTY);
+ }
+
+ appInst.setExecutablePath(app.getExecPath());
+ DA_LOG.debug("Set execute path : " + app.getExecPath());
+
+ List<FunctionInst> functionInstList = getFunctionInstList(app, temppath);
+ appInst.getFunctionInstList().addAll(functionInstList);
+ appInst.setFunctionCount(functionInstList.size());
+ output.getAppInstList().add(appInst);
}
- appInst.setFunctionCount(size - exSize);
- // appInst.setFunctionCount(0);
- output.getAppInstList().add(appInst);
}
return output;
}
+
+ private List<FunctionInst> getFunctionInstList(AppInfo app, String temppath) {
+ List<AddrSymbolPair> symbols = app.getSymbols(temppath);
+ List<FunctionInst> functionInstList = new ArrayList<FunctionInst>();
+
+ int size = (symbols == null) ? 0 : symbols.size();
+ for (int i = 0; i < size; i++) {
+ AddrSymbolPair addrSymbol = symbols.get(i);
+ String symbol = addrSymbol.getSymbol();
+ // FIXME: black list hard coded.
+ if (symbol.contains("__i686.get_pc_thunk")) {
+ continue;
+ }
+
+ FunctionInst functionInst = new FunctionInst();
+ functionInst.setAddr(addrSymbol.getAddr());
+ functionInst.setArgs(getFunctionArgs(addrSymbol.getSymbol()));
+ functionInstList.add(functionInst);
+ }
+
+ return functionInstList;
+ }
public HostResult sendBinaryInfoMessage(AppInfo selectedApp) {
// send config message
List<String> paths = new ArrayList<String>();
byte[] msgBinInfo = ByteUtil.toBytes(AnalyzerConstants.MSG_BINARY_INFO);
+ byte[] preMsg = null;
DeviceInfo curDevice = GlobalInformation.getCurrentDeviceInfo();
- PackageInfo pkgInfo = curDevice.getPackageInfoHash().get(
- selectedApp.getInfo(AppInfo.PROPERTY.PACKAGE.index));
- List<AppInfo> apps = pkgInfo.getAppInfos();
- if (null == apps) {
- return HostResult.ERR_BIN_INFO_GET_FAIL;
- }
+ if (AnalyzerConstants.RUNNING_PROCESS.equals(selectedApp.getAppId())) {
+ Map<Integer, String> selProcess = selectedApp.getRunningProcesses();
+ int binCount = selProcess.size();
+ preMsg = ByteUtil.getByte(binCount);
+
+ for (Map.Entry<Integer, String> entry : selProcess.entrySet()) {
+ paths.add(entry.getValue());
+ preMsg = ByteUtil.getByte(preMsg, entry.getValue());
+ }
+ } else if (AnalyzerConstants.WITHOUT_EXECUTABLE.equals(selectedApp.getAppId())) {
+ // do not send message for system wide trace
+ return HostResult.SUCCESS;
+ } else {
+ PackageInfo pkgInfo = curDevice.getPackageInfoHash().get(
+ selectedApp.getPackageId());
+ List<AppInfo> apps = pkgInfo.getAppInfos();
+ if (null == apps) {
+ return HostResult.ERR_BIN_INFO_GET_FAIL;
+ }
- int binCount = apps.size();
- byte[] preMsg = ByteUtil.getByte(binCount);
+ int binCount = apps.size();
+ preMsg = ByteUtil.getByte(binCount);
- for (AppInfo app : apps) {
- String targetPath = app.getExecPath();
- paths.add(targetPath);
- preMsg = ByteUtil.getByte(preMsg, targetPath);
+ for (AppInfo app : apps) {
+ String targetPath = app.getExecPath();
+ paths.add(targetPath);
+ preMsg = ByteUtil.getByte(preMsg, targetPath);
+ }
}
int length = preMsg.length;
if (binaryType < 0) {
// binary does not exist in target
+ // so do not try to download binary from target
return;
}
// if (pData.getProbeType()
// == AnalyzerConstants.FUNCTION_TYPE_APPINST) {
- ProcessInformation process = AnalyzerManager.getProject()
- .getProcessInformation(pData.getPid());
+// ProcessInformation process = AnalyzerManager.getProject()
+// .getProcessInformation(pData.getPid());
String apiName = pData.getApiName();
// _end indicates end of BSS (uninitialized data) section
pData.setApiName(apiName);
}
}
- // System.out.println("@@@@ " + pData.getApiName() +
- // " @@@@@");
- if (process.isDropLog()) {
- apiName = pData.getApiName();
- if (apiName.contains("main")) {
- process.setDropLog(false);
- } else {
- continue;
- }
- }
-
- // irregular call check still necessary?
- // if (AnalyzerManager.getCallstackManager()
- // .isIrregularUserCall(pData)) {
- // continue;
- // }
+
+ // TODO : droplog is necessary?
+// if (process.isDropLog()) {
+// apiName = pData.getApiName();
+// if (apiName.contains("main")) {
+// process.setDropLog(false);
+// } else {
+// continue;
+// }
+// }
List<Integer> functionStack = getFunctionEntryStack(pData.getTid());
// entry / exit pair matching
}
- // check irregular enter/exit log (multiple logs from 1 function call)
- public boolean isIrregularUserCall(LogData data) {
- UserFunctionData input = (UserFunctionData) data;
- Map<Long, CallStackUnit> addrMap = getCallStackApiAddrByPidMap(input.getPid());
- HashMap<Integer, DuplicateUserCall> dupUserCallMap = getDupUserCallByTidMap();
-
- boolean isPieBuild = AnalyzerUtil.isPieBuild(input.getPid(), input.getTime());
- ProcessMemoryMap pmap = AnalyzerManager.getProject()
- .getProcessInformation(input.getPid())
- .getProcessMemoryMap(input.getTime());
- if (pmap == null) {
- return false;
- }
-
- String binPath = AnalyzerUtil.getProcessLocalBinaryPath(input.getPid(),
- input.getTime());
- if (null == binPath || binPath.isEmpty()) {
- return false;
- }
-
- String baseAddr = Long.toString(pmap.getMainbinary().getLowestAddress());
- String strSelfAddr = Long.toString(input.getPcAddr());
-
- int tid = input.getTid();
- long selfAddr = input.getPcAddr();
-
- CallStackUnit selfCallstackUnit = addrMap.get(selfAddr);
-
- if (null == selfCallstackUnit) {
- String strSelfFuncName = SymbolManager.addr2func(binPath, strSelfAddr,
- isPieBuild, baseAddr);
- String strSelfSymbol = getUserFunctionPosition()
- + AnalyzerConstants.CALLSTACK_API_TOKEN_STRING + strSelfFuncName;
- selfCallstackUnit = new CallStackUnit(selfAddr, strSelfSymbol, input);
- addrMap.put(selfAddr, selfCallstackUnit);
- }
-
- List<CallStackItem> userCallstack = getUserCallstack(tid);
- int size = userCallstack.size();
-
- int eventType = input.getType();
- if (size > 0) {
- if (eventType == LogCenterConstants.USER_FUNCTION_EVENT_TYPE_ENTER) {
- CallStackUnit topCallstackUnit = userCallstack.get(size - 1)
- .getCallStackUnit();
- if (topCallstackUnit.equals(selfCallstackUnit)) {
- DuplicateUserCall dupUserCall = dupUserCallMap.get(tid);
- if (null == dupUserCall) {
- dupUserCall = new DuplicateUserCall(selfCallstackUnit);
- dupUserCallMap.put(tid, dupUserCall);
- } else {
- if (dupUserCall.getDupCallstackUnit().equals(selfCallstackUnit)) {
- dupUserCall.increaseDupCallCount();
- } else {
- DA_LOG.debug("isIrregularUserCall : dup callstack check error"); //$NON-NLS-1$
- }
- }
- return true;
- }
- } else if (eventType == LogCenterConstants.USER_FUNCTION_EVENT_TYPE_EXIT) {
- DuplicateUserCall dupUserCall = dupUserCallMap.get(tid);
- if (null != dupUserCall) {
- if (dupUserCall.getDupCallstackUnit().equals(selfCallstackUnit)) {
- dupUserCall.decreaseDupCallCount();
- if (0 == dupUserCall.getDupCallCount()) {
- dupUserCallMap.remove(tid);
- }
- } else {
- DA_LOG.debug("isIrregularUserCall : dup callstack check error"); //$NON-NLS-1$
- }
- return true;
- }
- }
- }
- return false;
- }
-
public void clear() {
callstackApiAddrByPidMap.clear();
callstackDataBySeqMap.clear();
--- /dev/null
+package org.tizen.dynamicanalyzer.ui.toolbar;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+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.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.dynamicanalyzer.communicator.DACommunicator;
+import org.tizen.dynamicanalyzer.constant.CommonConstants;
+import org.tizen.dynamicanalyzer.model.DeviceInfo;
+import org.tizen.dynamicanalyzer.resources.ColorResources;
+import org.tizen.dynamicanalyzer.ui.widgets.DAGrid;
+import org.tizen.dynamicanalyzer.ui.widgets.table.DATableCellRenderer;
+import org.tizen.dynamicanalyzer.ui.widgets.table.DATableHeaderRenderer;
+import org.tizen.dynamicanalyzer.util.DALogger;
+import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
+import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener;
+import org.tizen.dynamicanalyzer.widgets.da.base.DAButton;
+
+public class ProcessExplorer extends Composite {
+ private static final DALogger DA_LOG = DALogger.getInstance();
+
+ protected Grid table = null;
+ protected DACustomButton unselectAllButton = null;
+ protected DACustomButton refreshButton = null;
+
+ protected DeviceInfo device = null;
+ protected Map<Integer, String> initialProcesses = null;
+
+ private DACustomButtonClickEventListener unselectedAllButtonClickListener = new DACustomButtonClickEventListener() {
+
+ @Override
+ public void handleClickEvent(DACustomButton button) {
+ int itemcount = table.getItemCount();
+ for (int i = 0; i < itemcount; i++) {
+ GridItem item = table.getItem(i);
+ item.setChecked(0, false);
+ }
+
+ if (initialProcesses != null) {
+ initialProcesses.clear();
+ }
+ }
+ };
+
+ private DACustomButtonClickEventListener refreshButtonClickListener = new DACustomButtonClickEventListener() {
+
+ @Override
+ public void handleClickEvent(DACustomButton button) {
+ updateData();
+ }
+ };
+
+ ProcessExplorer(Composite parent) {
+ super(parent, SWT.NONE);
+ this.setLayout(new FormLayout());
+ this.setBackground(ColorResources.DIALOG_BG_UPPER);
+
+ table = new DAGrid(this, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
+ table.setHeaderVisible(true);
+ table.setBackground(ColorResources.TABLE_CONTENTS_NORMAL);
+ table.setForeground(ColorResources.TABLE_CONTENTS_FONT_COLOR);
+ setColumn();
+ // table.setEmptyCellRenderer(new DAFileExplorerEmptyCellRenderer());
+ table.setItemHeight(20);
+
+ FormData data = new FormData();
+ data.top = new FormAttachment(0, 0);
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(100, 0);
+ data.bottom = new FormAttachment(94, 0);
+ table.setLayoutData(data);
+
+ unselectAllButton = new DAButton(this, SWT.NONE);
+ data = new FormData();
+ data.top = new FormAttachment(table, 5);
+ data.left = new FormAttachment(29, 0);
+ data.right = new FormAttachment(49, 0);
+ data.height = 25;
+ unselectAllButton.setLayoutData(data);
+ unselectAllButton.setText("Unselect All");
+ unselectAllButton.addClickListener(unselectedAllButtonClickListener);
+
+ refreshButton = new DAButton(this, SWT.NONE);
+ data = new FormData();
+ data.top = new FormAttachment(table, 5);
+ data.left = new FormAttachment(51, 0);
+ data.right = new FormAttachment(71, 0);
+ data.height = 25;
+ refreshButton.setLayoutData(data);
+ refreshButton.setText("Refresh");
+ refreshButton.addClickListener(refreshButtonClickListener);
+ }
+
+ private void setColumn() {
+ GridColumn checkColumn = new GridColumn(table, SWT.CHECK);
+ checkColumn.setCellRenderer(new DATableCellRenderer());
+ checkColumn.setHeaderRenderer(new DATableHeaderRenderer(SWT.LEFT));
+ checkColumn.setText("");
+ checkColumn.setWidth(25);
+
+ GridColumn pidColumn = new GridColumn(table, SWT.NONE);
+ pidColumn.setCellRenderer(new DATableCellRenderer());
+ pidColumn.setHeaderRenderer(new DATableHeaderRenderer(SWT.LEFT));
+ pidColumn.setText("PID");
+ pidColumn.setAlignment(SWT.LEFT);
+ pidColumn.setWidth(50);
+
+ GridColumn nameColumn = new GridColumn(table, SWT.NONE);
+ nameColumn.setCellRenderer(new DATableCellRenderer());
+ nameColumn.setHeaderRenderer(new DATableHeaderRenderer(SWT.LEFT));
+ nameColumn.setText("Process Name");
+ nameColumn.setAlignment(SWT.LEFT);
+ nameColumn.setWidth(355);
+ }
+
+ public void setDeviceInfo(DeviceInfo dev) {
+ this.device = dev;
+ }
+
+ public void updateData() {
+ if (device == null) {
+ DA_LOG.warning("Device is empty");
+ return;
+ }
+
+ table.removeAll();
+
+ Map<Integer, String> processes = DACommunicator.getProcessListFromTarget();
+ if (processes == null) {
+ return;
+ }
+
+ int size = 0;
+ int maxnamelen = 0;
+ for (Map.Entry<Integer, String> entry : processes.entrySet()) {
+ String name = entry.getValue();
+
+ // remove 'ps' process and filtered by '/'
+ if (name.startsWith(CommonConstants.SLASH)) {
+ int namelen = name.length();
+ if (maxnamelen < namelen) {
+ maxnamelen = namelen;
+ }
+
+ GridItem item = new GridItem(table, SWT.NONE);
+ item.setCheckable(0, false);
+ item.setText(1, entry.getKey().toString());
+ item.setText(2, name);
+
+ if (initialProcesses != null
+ && initialProcesses.containsKey(entry.getKey())) {
+ item.setChecked(0, true);
+ }
+
+ size++;
+ }
+ }
+
+ if (maxnamelen > 55) {
+ table.getColumn(2).setWidth((int) (maxnamelen * 6.5));
+ } else {
+ table.getColumn(2).setWidth(355);
+ }
+
+ table.getVerticalBar().setMaximum(size);
+ table.update();
+ }
+
+ public Map<Integer, String> getSelectedProcess() {
+ Map<Integer, String> selected = new TreeMap<Integer, String>();
+
+ int itemcount = table.getItemCount();
+ for (int i = 0; i < itemcount; i++) {
+ GridItem item = table.getItem(i);
+ if (item.getChecked(0)) {
+ int pid = Integer.parseInt(item.getText(1));
+ String[] splitcmd = item.getText(2).split(CommonConstants.SPACE, 2);
+ selected.put(Integer.valueOf(pid), splitcmd[0]);
+ }
+ }
+
+ if (selected.size() == 0) {
+ return null;
+ } else {
+ return selected;
+ }
+ }
+
+ public void setSelectedProcess(Map<Integer, String> proc) {
+ initialProcesses = proc;
+ }
+}
--- /dev/null
+package org.tizen.dynamicanalyzer.ui.toolbar;
+
+import java.util.Map;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Rectangle;
+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.Shell;
+import org.tizen.dynamicanalyzer.appearance.DesignConstants;
+import org.tizen.dynamicanalyzer.common.GlobalInformation;
+import org.tizen.dynamicanalyzer.nl.WidgetLabels;
+import org.tizen.dynamicanalyzer.resources.ColorResources;
+import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
+import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener;
+import org.tizen.dynamicanalyzer.widgets.da.base.DAButton;
+import org.tizen.dynamicanalyzer.widgets.da.base.DAMessageBox;
+
+public class ProcessExplorerDialog extends DAMessageBox {
+ private ProcessExplorer explorer = null;
+ private DACustomButton okButton = null;
+ private DACustomButton cancelButton = null;
+
+ public ProcessExplorerDialog(Shell parentShell) {
+ super(parentShell);
+ shell.setLayout(new FormLayout());
+ shell.setSize(446, 600);
+ shell.setBackground(ColorResources.DIALOG_BG_UPPER);
+ shell.setText("Select process");
+
+ explorer = new ProcessExplorer(shell);
+ FormData data = new FormData();
+ data.top = new FormAttachment(0, 17);
+ data.left = new FormAttachment(0, 6);
+ data.height = 476;
+ data.width = 434;
+ explorer.setLayoutData(data);
+ explorer.setDeviceInfo(GlobalInformation.getCurrentDeviceInfo());
+
+ Composite buttonComp = new Composite(shell, SWT.NONE);
+ buttonComp.setLayout(new FormLayout());
+ buttonComp.setBackground(ColorResources.DIALOG_BG_LOWER);
+
+ buttonComp.addPaintListener(new PaintListener() {
+
+ @Override
+ public void paintControl(PaintEvent e) {
+ Composite comp = (Composite) e.widget;
+ Rectangle rect = comp.getClientArea();
+ e.gc.setForeground(ColorResources.DIALOG_SUNKEN_1);
+ e.gc.drawLine(rect.x, rect.y, rect.x + rect.width, rect.y);
+ e.gc.setForeground(ColorResources.DIALOG_SUNKEN_2);
+ e.gc.drawLine(rect.x, rect.y + 1, rect.x + rect.width,
+ rect.y + 1);
+ }
+ });
+
+ FormData compData = new FormData();
+ compData.top = new FormAttachment(explorer, 20);
+ compData.left = new FormAttachment(0, 0);
+ compData.right = new FormAttachment(100, 0);
+ compData.bottom = new FormAttachment(100, 0);
+ buttonComp.setLayoutData(compData);
+
+ okButton = new DAButton(buttonComp, SWT.NONE);
+ data = new FormData();
+ data.top = new FormAttachment(0, 11);
+ data.left = new FormAttachment(50, -DesignConstants.DA_BUTTON_WIDTH - 4);
+ data.height = DesignConstants.DA_BUTTON_HEIGHT;
+ data.width = DesignConstants.DA_BUTTON_WIDTH;
+ okButton.setLayoutData(data);
+ okButton.setText(WidgetLabels.OK);
+ okButton.addClickListener(new DACustomButtonClickEventListener() {
+
+ @Override
+ public void handleClickEvent(DACustomButton button) {
+ result = explorer.getSelectedProcess();
+ if (null != result) {
+ shell.dispose();
+ }
+ }
+ });
+
+ cancelButton = new DAButton(buttonComp, SWT.NONE);
+ data = new FormData();
+ data.top = new FormAttachment(0, 11);
+ data.left = new FormAttachment(50, 4);
+ data.height = DesignConstants.DA_BUTTON_HEIGHT;
+ data.width = DesignConstants.DA_BUTTON_WIDTH;
+ cancelButton.setLayoutData(data);
+ cancelButton.setText(WidgetLabels.CANCEL);
+ cancelButton.addClickListener(new DACustomButtonClickEventListener() {
+
+ @Override
+ public void handleClickEvent(DACustomButton button) {
+ shell.dispose();
+ }
+ });
+ }
+
+ public void setProcessList(Map<Integer, String> proc) {
+ explorer.setSelectedProcess(proc);
+ }
+
+ @Override
+ protected boolean run() {
+ super.run();
+ explorer.updateData();
+ return true;
+ }
+}
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FormAttachment;
public void selectionEvent(DACustomCombo combo) {
String appName = combo.getText();
if (null != appName && !appName.isEmpty()) {
- AppInfo selectedApp = DACommunicator.getPkgInfoByName(appName);
+ boolean enablestart = true;
+ AppInfo selectedApp = DACommunicator.getPkgInfoByName(appName);
if (null != selectedApp) {
+ if (appName.equals(AnalyzerConstants.RUNNING_PROCESS)) {
+ Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell();
+ ProcessExplorerDialog pdialog = new ProcessExplorerDialog(
+ shell);
+ pdialog.setProcessList(selectedApp.getRunningProcesses());
+ Object result = pdialog.open();
+ if (result != null) {
+ @SuppressWarnings("unchecked")
+ Map<Integer, String> processes = (Map<Integer, String>) result;
+ selectedApp.setRunningProcesses(processes);
+ }
+
+ if (selectedApp.getRunningProcesses() == null) {
+ enablestart = false;
+ }
+ }
+
GlobalInformation.setCurrentApplication(selectedApp);
GlobalInformation.getCurrentDeviceInfo().getCommunicator()
.onAppSelected(selectedApp);
GlobalInformation.getCurrentDeviceInfo().setSelectedAppName(
selectedApp.getInfo(AppInfo.PROPERTY.LABEL.index));
+ } else {
+ enablestart = false;
}
- if (null != GlobalInformation.getCurrentDeviceInfo()) {
+ if (enablestart && null != GlobalInformation.getCurrentDeviceInfo()) {
// AnalyzerUtil
// .setRecordState(RecordStateSourceProvider.RECORD_READY);
AnalyzerManager.setRunningState(false);
List<AppInfo> apps = addToAppComboFromTarget();
- if (apps.size() > 0) {
+ if (apps != null && apps.size() > 0) {
String appName = GlobalInformation.getCurrentDeviceInfo()
.getSelectedAppName();
if (null == appName) {
private List<AppInfo> addToAppComboFromTarget() {
List<AppInfo> apps = DACommunicator.getAppListFromTarget();
- addToAppCombo(apps);
+
+ List<AppInfo> appcomboList = new ArrayList<AppInfo>();
+ if (apps != null) {
+ // TODO : reconstruct real app list for app combo
+ // relation between package and app?
+ for (AppInfo app : apps) {
+ String appid = app.getInfo(AppInfo.PROPERTY.APPID.index);
+ String pkgid = app.getInfo(AppInfo.PROPERTY.PACKAGE.index);
+ if (appid.startsWith(pkgid)
+ && !appid.contains(AnalyzerConstants.APPCONTROL)) {
+ appcomboList.add(app);
+ }
+ }
+ }
+
+ addToAppCombo(appcomboList);
return apps;
}
int topMargin = 3;
-// int bottomMargin = 3;
+ // int bottomMargin = 3;
int arrowMargin = 6;
-
+
int imageSpacing = 3;
+ int alignment;
+
private SortArrowRenderer arrowRenderer = new SortArrowRenderer();
+ public DATableHeaderRenderer() {
+ alignment = SWT.CENTER;
+ }
+
+ public DATableHeaderRenderer(int align) {
+ this.alignment = align;
+ }
+
public void setDisplay(Display display) {
super.setDisplay(display);
arrowRenderer.setDisplay(display);
gc.setBackground(ColorResources.TABLE_HEADER_BG);
if (flat && isSelected()) {
- gc.setBackground(column.getParent()
- .getCellHeaderSelectionBackground());
+ gc.setBackground(column.getParent().getCellHeaderSelectionBackground());
}
Rectangle r = getBounds();
int x = leftMargin;
if (column.getImage() != null) {
- gc.drawImage(column.getImage(), getBounds().x + x
- + pushedDrawingOffset, getBounds().y + topMargin
- + pushedDrawingOffset);
+ gc.drawImage(column.getImage(), getBounds().x + x + pushedDrawingOffset,
+ getBounds().y + topMargin + pushedDrawingOffset);
x += column.getImage().getBounds().width + imageSpacing;
}
// font color
gc.setForeground(ColorResources.TABLE_HEADER_FONT_COLOR);
gc.setFont(FontResources.TABLE_HEADER_FONT);
- String inputText = TextUtils
- .getShortString(gc, column.getText(), width);
+ String inputText = TextUtils.getShortString(gc, column.getText(), width);
Point textSize = gc.textExtent(inputText, SWT.DRAW_MNEMONIC);
- int textX = r.x + (r.width - textSize.x) / 2;
+ int textX;
+ if (alignment == SWT.CENTER) {
+ textX = r.x + (r.width - textSize.x) / 2;
+ } else if (alignment == SWT.LEFT) {
+ textX = r.x + x;
+ } else {
+ textX = r.x + r.width - textSize.x - rightMargin;
+ }
+
int y = getBounds().y + (getBounds().height - textSize.y) / 2;
- gc.drawString(TextUtils.getShortString(gc, column.getText(), width),
- textX + pushedDrawingOffset, y + pushedDrawingOffset, true);
+ 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);
+ 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.setLocation(getBounds().x + getBounds().width - arrowMargin
+ - arrowRenderer.getBounds().width, getBounds().y
+ + ((getBounds().height - arrowRenderer.getBounds().height) / 2));
}
arrowRenderer.paint(gc, null);
}
--- /dev/null
+package org.tizen.dynamicanalyzer.utils;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.tizen.dynamicanalyzer.common.path.PathManager;
+import org.tizen.dynamicanalyzer.util.DALogger;
+
+public class RpmUtil {
+ private static final DALogger DA_LOG = DALogger.getInstance();
+
+ public static final String RPM_EXT = ".rpm";
+ public static final String DEBUGINFO = "debuginfo";
+ public static final String DEBUGSOURCE = "debugsource";
+
+ // extract rpm file exists
+ public static void extractRpm(String targetpath, String rpmpath) {
+ if (null != rpmpath) {
+ String toolPath = PathManager.DA_TOOL_FOLDER_PATH + File.separator
+ + "debuginfo.sh";
+ String[] command = new String[] { toolPath, "-d", targetpath, rpmpath };
+ try {
+ Runtime rt = Runtime.getRuntime();
+ Process process = rt.exec(command);
+ process.waitFor();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(
+ process.getInputStream()));
+
+ String line = null;
+ int lineCount = 0;
+ while (null != (line = reader.readLine())) {
+ lineCount++;
+ if (lineCount == 1) {
+ DA_LOG.debug("CHANGE DIR : " + line);
+ } else {
+ DA_LOG.debug("EXTRACE RPM : " + line);
+ }
+ }
+
+ if (lineCount == 0) {
+ BufferedReader error = new BufferedReader(new InputStreamReader(
+ process.getErrorStream()));
+ String errorStr = error.readLine();
+ DA_LOG.debug("debug info file extract failed... : " + errorStr);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public static List<String> getFileListInRpm(String rpmpath) {
+ List<String> ret = null;
+
+ if (null != rpmpath) {
+ String toolPath = PathManager.DA_TOOL_FOLDER_PATH + File.separator
+ + "debuginfo.sh";
+ String[] command = new String[] { toolPath, "-l", rpmpath };
+ try {
+ Runtime rt = Runtime.getRuntime();
+ Process process = rt.exec(command);
+ process.waitFor();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(
+ process.getInputStream()));
+
+ ret = new ArrayList<String>();
+ String line = null;
+ while (null != (line = reader.readLine())) {
+ if (line.startsWith("./")) {
+ line = line.substring(1);
+ ret.add(line);
+ }
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ return ret;
+ }
+}