FEATURE: add running process profiling feature 20/24720/1
authorgreatim <jaewon81.lim@samsung.com>
Fri, 18 Jul 2014 14:34:00 +0000 (23:34 +0900)
committergreatim <jaewon81.lim@samsung.com>
Fri, 18 Jul 2014 14:34:00 +0000 (23:34 +0900)
Now DA can trace the running process on target
Add process selection dialog fot that

Change-Id: I2ede33163571f067cd5e96766b2dd27b3d2bd3ff
Signed-off-by: greatim <jaewon81.lim@samsung.com>
16 files changed:
org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/combo/DACustomCombo.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerConstants.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerShellCommands.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/DACommunicator.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/IDECommunicator.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/AppInfo.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/callstack/BaseCallstackManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/callstack/SWAPCallStackManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/communicator/Communicator30.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/SWAPLogParser.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/info/callstack/CallStackManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ProcessExplorer.java [new file with mode: 0644]
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ProcessExplorerDialog.java [new file with mode: 0644]
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ToolbarArea.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/table/DATableHeaderRenderer.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/utils/RpmUtil.java [new file with mode: 0644]

index 59c94c4..9d5201a 100644 (file)
@@ -61,7 +61,7 @@ import org.tizen.dynamicanalyzer.widgets.helper.ColorResources;
 
 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;
@@ -96,16 +96,16 @@ public class DACustomCombo extends Canvas {
        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;
@@ -138,7 +138,7 @@ public class DACustomCombo extends Canvas {
        public void setFontPoint(Point fontPoint) {
                attr.setFontPoint(fontPoint);
        }
-       
+
        public String getText() {
                if (selection < 0) {
                        return attr.getText();
@@ -327,8 +327,7 @@ public class DACustomCombo extends Canvas {
                        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);
@@ -359,8 +358,8 @@ public class DACustomCombo extends Canvas {
                        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);
@@ -369,8 +368,7 @@ public class DACustomCombo extends Canvas {
                        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);
@@ -392,11 +390,9 @@ public class DACustomCombo extends Canvas {
                }
 
                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();
@@ -412,8 +408,8 @@ public class DACustomCombo extends Canvas {
                        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);
                }
        };
 
@@ -438,7 +434,7 @@ public class DACustomCombo extends Canvas {
                if (index < 0) {
                        return false;
                }
-               
+
                itemIndex = 0;
                int size = items.size();
                if (size < MAX_SIZE) {
@@ -458,7 +454,7 @@ public class DACustomCombo extends Canvas {
                                DA_LOG.debug("Combo indexing bug!");
                                return false;
                        }
-                       
+
                        selection = index;
                        select(selection);
                }
@@ -471,7 +467,9 @@ public class DACustomCombo extends Canvas {
                } else {
                        setText(DAWidgetConstants.EMPTY_STRING);
                }
-               childShell.close();
+               if (childShell != null) {
+                       childShell.close();
+               }
                childShell = null;
        }
 
@@ -585,10 +583,10 @@ public class DACustomCombo extends Canvas {
                        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);
                }
        };
@@ -624,7 +622,7 @@ public class DACustomCombo extends Canvas {
                }
                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);
@@ -632,10 +630,10 @@ public class DACustomCombo extends Canvas {
                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);
@@ -643,10 +641,10 @@ public class DACustomCombo extends Canvas {
                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");
@@ -659,8 +657,7 @@ public class DACustomCombo extends Canvas {
                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);
@@ -673,11 +670,11 @@ public class DACustomCombo extends Canvas {
                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) {
@@ -685,8 +682,7 @@ public class DACustomCombo extends Canvas {
                        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);
                                }
                        }
@@ -712,8 +708,7 @@ public class DACustomCombo extends Canvas {
                                        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;
                                        }
                                }
@@ -741,8 +736,7 @@ public class DACustomCombo extends Canvas {
                        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);
                                }
                        }
@@ -768,8 +762,7 @@ public class DACustomCombo extends Canvas {
                                        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;
                                        }
                                }
@@ -803,8 +796,7 @@ public class DACustomCombo extends Canvas {
                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);
@@ -812,8 +804,7 @@ public class DACustomCombo extends Canvas {
                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);
@@ -841,29 +832,26 @@ public class DACustomCombo extends Canvas {
                }
                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),
@@ -875,15 +863,14 @@ public class DACustomCombo extends Canvas {
                                // 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 {
@@ -942,14 +929,13 @@ public class DACustomCombo extends Canvas {
                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;
        }
index 572a17a..0708622 100644 (file)
@@ -45,6 +45,8 @@ public class AnalyzerConstants {
        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$
@@ -340,8 +342,10 @@ public class AnalyzerConstants {
        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;
 }
index f47e60a..770f942 100755 (executable)
@@ -35,6 +35,7 @@ public class AnalyzerShellCommands {
        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;
 
index b675ab9..632ccec 100644 (file)
@@ -37,6 +37,8 @@ import java.net.Socket;
 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;
@@ -70,7 +72,7 @@ public class DACommunicator {
 
        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;
 
@@ -111,7 +113,7 @@ public class DACommunicator {
                setNewBridge();
                isRunning = false;
                devices = null;
-               packageInfoMultiLines.clear();
+               cmdResultMultiLines.clear();
                filterMultiLines.clear();
                uploadDataResult.clear();
                unittestList.clear();
@@ -241,47 +243,83 @@ public class DACommunicator {
                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(
@@ -298,7 +336,6 @@ public class DACommunicator {
                                                backList.remove(appInfoHash.get(appId));
                                        }
                                }
-                               i += ii;
                        }
                }
                if (!backList.isEmpty()) {
@@ -309,18 +346,45 @@ public class DACommunicator {
                        }
                }
 
-               // 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) {
@@ -417,8 +481,15 @@ public class DACommunicator {
                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);
@@ -437,7 +508,8 @@ public class DACommunicator {
                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;
                                }
@@ -450,7 +522,8 @@ public class DACommunicator {
                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;
                                }
@@ -460,8 +533,8 @@ public class DACommunicator {
        }
 
        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() {
@@ -575,7 +648,8 @@ public class DACommunicator {
                                }
                        });
 
-                       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);
@@ -635,7 +709,8 @@ public class DACommunicator {
                Display.getDefault().syncExec(new Runnable() {
                        @Override
                        public void run() {
-                               ToolbarArea.getInstance().setDeviceComboItems(selectedDevice, deviceSerials);
+                               ToolbarArea.getInstance().setDeviceComboItems(selectedDevice,
+                                               deviceSerials);
                        }
                });
        }
@@ -643,7 +718,7 @@ public class DACommunicator {
        private static void clearDeviceAppInfo() {
                GlobalInformation.setCurrentDeviceInfo(null);
                GlobalInformation.setCurrentApplication(null);
-               packageInfoMultiLines.clear();
+               cmdResultMultiLines.clear();
        }
 
        public static DeviceInfo setSelectedDeviceBySerial(String serial) {
@@ -678,7 +753,8 @@ public class DACommunicator {
                        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() {
@@ -714,7 +790,8 @@ public class DACommunicator {
        }
 
        public static BufferedReader getSockBufferedReader() {
-               return GlobalInformation.getCurrentDeviceInfo().getCommunicator().getDataBufferedReader();
+               return GlobalInformation.getCurrentDeviceInfo().getCommunicator()
+                               .getDataBufferedReader();
        }
 
        public static void closeAll() {
@@ -726,29 +803,30 @@ public class DACommunicator {
        }
 
        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;
        }
index d3b2e12..194b9e3 100644 (file)
@@ -59,6 +59,7 @@ import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea;
 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;
 
@@ -88,7 +89,7 @@ public class IDECommunicator implements Runnable {
        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;
@@ -292,12 +293,11 @@ public class IDECommunicator implements Runnable {
                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;
                        }
 
@@ -320,18 +320,59 @@ public class IDECommunicator implements Runnable {
                        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();
index 55052db..267d371 100644 (file)
@@ -33,7 +33,9 @@ import java.io.IOException;
 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;
@@ -66,10 +68,21 @@ public class AppInfo {
                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";
@@ -77,6 +90,10 @@ public class AppInfo {
        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$
 
@@ -90,6 +107,7 @@ public class AppInfo {
 
        private String execFileName = null;
        private List<String> localPackagePath = null;
+       private Map<Integer, String> runningProcesses = null;
 
        private List<String> properties = new ArrayList<String>();
 
@@ -150,6 +168,14 @@ public class AppInfo {
                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) {
index 253b93a..09c2269 100644 (file)
@@ -99,8 +99,6 @@ public abstract class BaseCallstackManager {
 
        abstract public void makeCallstackWithoutBacktrace(LogData inputData);
 
-       abstract public boolean isIrregularUserCall(LogData input);
-
        public void offerCallStackUnit(CallStackUnit csu) {
                if (callstackInserter != null) {
                        callstackInserter.startInserterThread();
index 5866419..55f227c 100644 (file)
@@ -334,83 +334,6 @@ public class SWAPCallStackManager extends BaseCallstackManager {
 
        }
 
-       // 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();
index 6d0219b..a46aa03 100755 (executable)
@@ -50,6 +50,8 @@ import java.net.UnknownHostException;
 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;
@@ -286,103 +288,145 @@ public class Communicator30 extends BaseCommunicator {
                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;
@@ -1026,6 +1070,7 @@ public class Communicator30 extends BaseCommunicator {
 
                        if (binaryType < 0) {
                                // binary does not exist in target
+                               // so do not try to download binary from target
                                return;
                        }
 
index 352424b..658d6f4 100755 (executable)
@@ -168,8 +168,8 @@ public class SWAPLogParser implements Runnable {
                                        // 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
@@ -184,22 +184,16 @@ public class SWAPLogParser implements Runnable {
                                                        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
index 4fcf6b4..442e264 100644 (file)
@@ -304,83 +304,6 @@ public class CallStackManager extends BaseCallstackManager {
 
        }
 
-       // 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();
diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ProcessExplorer.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ProcessExplorer.java
new file mode 100644 (file)
index 0000000..2e995fa
--- /dev/null
@@ -0,0 +1,199 @@
+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;
+       }
+}
diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ProcessExplorerDialog.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ProcessExplorerDialog.java
new file mode 100644 (file)
index 0000000..50aae58
--- /dev/null
@@ -0,0 +1,115 @@
+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;
+       }
+}
index d2148a6..dc22a2a 100755 (executable)
@@ -30,6 +30,7 @@ package org.tizen.dynamicanalyzer.ui.toolbar;
 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;
@@ -242,17 +243,37 @@ public class ToolbarArea {
                        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);
@@ -779,7 +800,7 @@ public class ToolbarArea {
 
                List<AppInfo> apps = addToAppComboFromTarget();
 
-               if (apps.size() > 0) {
+               if (apps != null && apps.size() > 0) {
                        String appName = GlobalInformation.getCurrentDeviceInfo()
                                        .getSelectedAppName();
                        if (null == appName) {
@@ -875,7 +896,22 @@ public class ToolbarArea {
 
        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;
        }
index 5aef2db..3d26049 100644 (file)
@@ -47,14 +47,24 @@ public class DATableHeaderRenderer extends DefaultColumnHeaderRenderer {
 
        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);
@@ -76,8 +86,7 @@ public class DATableHeaderRenderer extends DefaultColumnHeaderRenderer {
                gc.setBackground(ColorResources.TABLE_HEADER_BG);
 
                if (flat && isSelected()) {
-                       gc.setBackground(column.getParent()
-                                       .getCellHeaderSelectionBackground());
+                       gc.setBackground(column.getParent().getCellHeaderSelectionBackground());
                }
 
                Rectangle r = getBounds();
@@ -94,9 +103,8 @@ public class DATableHeaderRenderer extends DefaultColumnHeaderRenderer {
                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;
                }
 
@@ -111,32 +119,34 @@ public class DATableHeaderRenderer extends DefaultColumnHeaderRenderer {
                // 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);
                }
diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/utils/RpmUtil.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/utils/RpmUtil.java
new file mode 100644 (file)
index 0000000..28e5f7d
--- /dev/null
@@ -0,0 +1,89 @@
+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;
+       }
+}