DEBUG: disable to get daemon log whose size is over 1 mega byte 10/29710/1
authorgreatim <jaewon81.lim@samsung.com>
Mon, 3 Nov 2014 04:50:06 +0000 (13:50 +0900)
committergreatim <jaewon81.lim@samsung.com>
Mon, 3 Nov 2014 04:50:06 +0000 (13:50 +0900)
disable to get daemon log whose size is over 1 mega byte

Change-Id: Ia41c736785ce6faf815195da93804484c049da22
Signed-off-by: greatim <jaewon81.lim@samsung.com>
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerShellCommands.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/DALimit.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/DACommunicator.java

index 6e6395f..d8dd410 100755 (executable)
@@ -39,6 +39,7 @@ public class AnalyzerShellCommands {
        public static final String CMD_UPLOAD_FILE_LIST = "du -b " + //$NON-NLS-1$
                        PathConstants.DA_REMOTE_PATH + AnalyzerConstants.READELF_BIN;
        public static final String CMD_PROCESS_NAME = "ps -p %d -o comm=rcu_sched";
+       public static final String CMD_GET_FILE_SIZE = "stat -c %s";
 
        // via da_command
        public static final String DACOMMAND_KILL_MANAGER = "da killmanager";
index 8762aa6..178470c 100644 (file)
@@ -68,6 +68,7 @@ public class DALimit {
        public static final int MAX_BINARY_COUNT = (int) Math.pow(2, 16); // 65535
        public static final int MAX_FUNCTION_COUNT = (int) Math.pow(2, 20);     // 1,048,576
        public static final int MAX_FUNCTION_ARGUMENTS_COUNT = FUNCTION_ARGUMENTS_FORMAT_LENGTH; // Because "MAX_FUNCTION_ARGUMENTS_COUNT < FUNCTION_ARGUMENTS_FORMAT_LENGTH" is always true
+       public static final long MAX_DAEMON_LOG_SIZE = 1024*1024;       // 1 mega byte
        
        // Leak 
        public static final int MAX_LEAK_CHECK_BUFFER_SIZE = (int) Math.pow(2, 20); // 1,048,576
index 3950c77..3213645 100644 (file)
@@ -43,6 +43,7 @@ import org.eclipse.swt.widgets.Display;
 import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
 import org.tizen.dynamicanalyzer.common.AnalyzerManager;
 import org.tizen.dynamicanalyzer.common.AnalyzerShellCommands;
+import org.tizen.dynamicanalyzer.common.DALimit;
 import org.tizen.dynamicanalyzer.common.Global;
 import org.tizen.dynamicanalyzer.common.HostResult;
 import org.tizen.dynamicanalyzer.common.path.PathConstants;
@@ -613,16 +614,37 @@ public class DACommunicator {
 
        public static void pullDaemonLog() {
                final String from = PathConstants.DA_DAEMON_LOG_PATH;
-               final String to = PathManager.DA_LOG_PATH + File.separator + DAEMONLOG_PREFIX
-                               + PathManager.getLogPostFix();//$NON-NLS-1$ 
-               SyncResult res = CommunicatorUtils.pull(from, to);
-               if (null != res && res.isOk()) {
-                       Logger.debug("daemon log copying success!!");//$NON-NLS-1$ 
-               } else {
-                       Logger.debug("Failed to get " + from); //$NON-NLS-1$ 
+               String command = AnalyzerShellCommands.CMD_GET_FILE_SIZE + CommonConstants.SPACE + from;
+
+               cmdResultMultiLines.clear();
+               CommunicatorUtils.execShellCommand(command, new MultiLineReceiver() {
+                       @Override
+                       public void processNewLines(String[] lines) {
+                               for (int i = 0; i < lines.length; i++) {
+                                       cmdResultMultiLines.add(lines[i]);
+                               }
+                       }
+               });
+
+               long filesize = -1;
+               if (cmdResultMultiLines.size() > 0) {
+                       filesize = Long.parseLong(cmdResultMultiLines.get(0));
                }
 
-               AnalyzerUtil.checkLogs(PathManager.DA_LOG_PATH, DAEMONLOG_PREFIX, DAEMONLOG_COUNT);
+               if (filesize > 0 && filesize < DALimit.MAX_DAEMON_LOG_SIZE) {
+                       final String to = PathManager.DA_LOG_PATH + File.separator + DAEMONLOG_PREFIX
+                                       + PathManager.getLogPostFix();//$NON-NLS-1$ 
+                       SyncResult res = CommunicatorUtils.pull(from, to);
+                       if (null != res && res.isOk()) {
+                               Logger.debug("daemon log copying success!!");//$NON-NLS-1$ 
+                       } else {
+                               Logger.debug("Failed to get " + from); //$NON-NLS-1$ 
+                       }
+
+                       AnalyzerUtil.checkLogs(PathManager.DA_LOG_PATH, DAEMONLOG_PREFIX, DAEMONLOG_COUNT);
+               } else {
+                       Logger.debug("daemon log file is too large or does not exist");
+               }
        }
 
        // public static String getLocalhost() {