[Title] add web app support for B2 project
authorgreatim <jaewon81.lim@samsung.com>
Tue, 28 Jan 2014 12:15:53 +0000 (21:15 +0900)
committergreatim <jaewon81.lim@samsung.com>
Tue, 28 Jan 2014 12:15:53 +0000 (21:15 +0900)
[Desc.]
[Issue]

org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerPaths.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/Project.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/channel/control/ApplicationInfo.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/communicator/Communicator30.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/MessageParser.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/SWAPLogParser.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/summary/profiling/ProfileDataMaker.java

index af70157..9243f10 100644 (file)
@@ -45,6 +45,10 @@ public class AnalyzerPaths {
                        + "test"
                        + File.separator
                        + AnalyzerConstants.DYNAMIC_ANALYZER_FOLDER_NAME;
+       public static final String DA_DEBUG_DATA_CHANNEL_LOG_PATH = TIZEN_SDK_DATA_PATH
+                       + File.separator + "data.log";
+       public static final String DA_DEBUG_CONTROL_CHANNEL_LOG_PATH = TIZEN_SDK_DATA_PATH
+                       + File.separator + "control.log";
        public static final String TOOL_FOLDER_PATH = DYNAMIC_ANALYZER_INSTALL_PATH
                        + File.separator + AnalyzerConstants.TOOL_FOLDER_NAME;
        public static final String TEMP_FOLDER_PATH = DYNAMIC_ANALYZER_SAVE_PATH
index b6e3f45..907765a 100755 (executable)
@@ -176,6 +176,7 @@ public class Project {
        }
 
        public void setProfileStartTime(DATime time) {
+               System.out.printf("profile starttime : %d\n", time.getSec());
                this.profilingStartTime = time;
        }
 
index 03f56c4..4265581 100755 (executable)
@@ -32,6 +32,7 @@ public class ApplicationInfo implements SWAPModel {
        public static final int APPTYPE_TIZEN = 0x01;
        public static final int APPTYPE_PROCESS = 0x02;
        public static final int APPTYPE_COMMON_EXEC = 0x03;
+       public static final int APPTYPE_WEB = 0x04;
        /***
         * target application type 
         * 01: tizen native application
index f6cbc05..155f10a 100755 (executable)
@@ -36,9 +36,12 @@ import static org.tizen.dynamicanalyzer.common.CommonConstants.INT_SIZE;
 import static org.tizen.dynamicanalyzer.common.CommonConstants.LONG_SIZE;
 
 import java.io.BufferedReader;
+import java.io.BufferedWriter;
 import java.io.File;
+import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.io.PrintWriter;
 import java.net.Socket;
 import java.net.SocketException;
 import java.net.SocketTimeoutException;
@@ -99,6 +102,9 @@ import org.tizen.sdblib.service.SyncResult;
 
 public class Communicator30 extends BaseCommunicator {
 
+       static final boolean PRINT_CONTROL_LOG_TOFILE = true;
+       private PrintWriter printWriter = null;
+
        @Override
        public HostResult init(DeviceInfo devInfo) {
                // connect ecs server
@@ -182,6 +188,20 @@ public class Communicator30 extends BaseCommunicator {
 
                System.out.println("print start message");
                ByteUtils.printByteArrayForStart(ret);
+               
+               if(PRINT_CONTROL_LOG_TOFILE) {
+                       File logPath = new File(
+                                       AnalyzerPaths.DA_DEBUG_CONTROL_CHANNEL_LOG_PATH);
+                       if (logPath.exists()) {
+                               logPath.delete();
+                       }
+
+                       try {
+                               printWriter = new PrintWriter(new BufferedWriter(new FileWriter(logPath)), true);
+                       } catch (IOException e) {
+                               e.printStackTrace();
+                       }
+               }
 
                // data receive thread create and start
                Thread dataThread = new Thread(null, new DataChannelThread(),
@@ -252,9 +272,10 @@ public class Communicator30 extends BaseCommunicator {
                        ApplicationInst appInst = new ApplicationInst();
 
                        String appType = app.getInfo(AppInfo.APPTYPE_INDEX);
-                       if (appType.contains(AppInfo.APPTYPE_CPP)
-                                       || appType.contains(AppInfo.APPTYPE_WEB)) {
+                       if (appType.contains(AppInfo.APPTYPE_CPP)) {
                                appInst.setApplicationType(ApplicationInfo.APPTYPE_TIZEN);
+                       } else if(appType.contains(AppInfo.APPTYPE_WEB)) {
+                               appInst.setApplicationType(ApplicationInfo.APPTYPE_WEB);
                        } else {
                                appInst.setApplicationType(ApplicationInfo.APPTYPE_COMMON_EXEC);
                        }
@@ -554,6 +575,12 @@ public class Communicator30 extends BaseCommunicator {
 
                try {
                        if (null != controlSock && !controlSock.isClosed()) {
+                               if(PRINT_CONTROL_LOG_TOFILE && printWriter != null) {
+                                       printWriter.printf("send :");
+                                       for(int k = 0; k < message.length; k++)
+                                               printWriter.printf("%02x ", message[k]);
+                                       printWriter.printf("\n");
+                               }
                                controlSock.getOutputStream().write(message);
                        }
 
@@ -568,6 +595,13 @@ public class Communicator30 extends BaseCommunicator {
                        System.out.println("blocked");
                        readsize = controlSock.getInputStream().read(cbuf);
                        blocked = false;
+                       if(PRINT_CONTROL_LOG_TOFILE && printWriter != null) {
+                               printWriter.printf("recv :");
+                               for(int k = 0; k < readsize; k++)
+                                       printWriter.printf("%02x ", cbuf[k]);
+                               printWriter.printf("\n");
+                       }
+
                        System.out.println("unblocked");
                        if (readsize > 0) {
                                byte[] buf = new byte[readsize];
index bd3eea9..999eb2d 100755 (executable)
@@ -28,10 +28,15 @@ package org.tizen.dynamicanalyzer.swap.logparser;
 import static org.tizen.dynamicanalyzer.common.CommonConstants.INT_SIZE;
 import static org.tizen.dynamicanalyzer.common.CommonConstants.LONG_SIZE;
 
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.PrintWriter;
 import java.net.Socket;
 import java.util.ArrayList;
+import java.util.Formatter;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Timer;
@@ -67,6 +72,7 @@ import org.tizen.dynamicanalyzer.ui.widgets.DADialog;
 import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
 
 public class MessageParser {
+       static final boolean PRINT_DATA_LOG_TOFILE = false;
 
        static final int MSG_ID_INDEX = 0;
        static final int MSG_LENGTH_INDEX = 1;
@@ -224,11 +230,9 @@ public class MessageParser {
                                .getNano();
 
                if (0 == startSec && 0 == startNano) {
-                       startTime.setSec(sec);
-                       startTime.setNano(nano);
+                       startTime.setSec(ByteUtils.toInt(data, 8));
+                       startTime.setNano(ByteUtils.toInt(data, 12));
                        AnalyzerManager.getProject().setProfileStartTime(startTime);
-                       startSec = sec;
-                       startNano = nano;
                }
 
                pInfo.setPid(pid);
@@ -386,12 +390,27 @@ public class MessageParser {
 
        public void startMessageParsing(Socket dataSocket) {
                InputStream inputStream = null;
+               PrintWriter printWriter = null;
 
                try {
                        inputStream = dataSocket.getInputStream();
                } catch (IOException e1) {
                        e1.printStackTrace();
                }
+               
+               if(PRINT_DATA_LOG_TOFILE) {
+                       File logPath = new File(
+                                       AnalyzerPaths.DA_DEBUG_DATA_CHANNEL_LOG_PATH);
+                       if (logPath.exists()) {
+                               logPath.delete();
+                       }
+
+                       try {
+                               printWriter = new PrintWriter(new BufferedWriter(new FileWriter(logPath)), true);
+                       } catch (IOException e) {
+                               e.printStackTrace();
+                       }
+               }
 
                startTimer();
 
@@ -458,6 +477,13 @@ public class MessageParser {
                                System.arraycopy(header, 0, buffer, 0, MSG_HEADER_SIZE);
                                System.arraycopy(payload, 0, buffer, MSG_HEADER_SIZE,
                                                payloadSize);
+                               
+                               if(PRINT_DATA_LOG_TOFILE && printWriter != null) {
+                                       printWriter.printf("%d %d %d %d %d :", id, ByteUtils.toInt(header, 4), ByteUtils.toInt(header, 8), ByteUtils.toInt(header, 12), payloadSize);
+                                       for(int k = 0; k < payloadSize; k++)
+                                               printWriter.printf("%02x ", payload[k]);
+                                       printWriter.printf("\n");
+                               }
 
                                processMessage(buffer);
                                if (id == DataChannelConstants.MSG_DATA_TERMINATE) {
index 50e4fab..276e1ae 100755 (executable)
@@ -141,6 +141,7 @@ public class SWAPLogParser implements Runnable {
                        int id = log.getId();
                        int seqNum = log.getSeq();
                        if (log instanceof SystemData) {
+                               System.out.println("=========systemData is slicing===========\n");
                                pushLog(log, logPack);
                        } else if (log instanceof ProfileData) {
                                if (!AnalyzerManager.isProcessInfoArrived()) {
index f2c118e..7df0083 100644 (file)
@@ -284,13 +284,15 @@ public class ProfileDataMaker {
                        String baseAddr = Long.toString(processInfo.getLowestAddress());
                        String pcStr = Long.toString(pcAddr);
                        BinaryInfo binInfo = processInfo.getTargetBinary(pcAddr);
-                       String localPath = binInfo.getTempBinaryPath();
-                       boolean isPieBuild = true;
-                       if (binInfo.getType() != 1) {
-                               isPieBuild = false;
+                       if(binInfo != null) {
+                               String localPath = binInfo.getTempBinaryPath();
+                               boolean isPieBuild = true;
+                               if (binInfo.getType() != 1) {
+                                       isPieBuild = false;
+                               }
+                               functionName = SymbolManager.addr2func(localPath, pcStr, isPieBuild,
+                                               baseAddr);
                        }
-                       functionName = SymbolManager.addr2func(localPath, pcStr, isPieBuild,
-                                       baseAddr);
                        if (null == functionName || functionName.isEmpty()
                                        || functionName.equals("_end")) { //$NON-NLS-1$
                                functionName = InformationViewLabels.CALLSTACK_TABLE_UNKNOWN_FUNCTION;