--- /dev/null
+/*
+ * org.tizen.nativecpp.csviewer
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Zoomin Cha <zoomin.cha@samsung.com>
+ * JaeGyu Jung <pang@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * - Samsung Electronics, Co. Ltd.
+ *
+ */
+
+package org.tizen.nativeplatform.coredump;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.tizen.common.core.application.InstallPathConfig;
+import org.tizen.nativeplatform.coredump.model.CSVO;
+import org.tizen.nativeplatform.coredump.model.CallStackVO;
+import org.tizen.nativeplatform.coredump.model.DebugMessageVO;
+import org.tizen.nativeplatform.coredump.model.HeaderVO;
+import org.tizen.nativeplatform.coredump.model.MemoryMapVO;
+import org.tizen.nativeplatform.coredump.model.RegisterVO;
+
+public class CSFileReader {
+
+ private File csFile;
+
+ public CSFileReader(String csFilePath) {
+ csFile = new File(csFilePath);
+ }
+
+ public void demanglingFile() {
+
+ try {
+ String sdkRoot = InstallPathConfig.getSDKPath();
+
+ if (sdkRoot != null && !sdkRoot.isEmpty()) {
+
+ StringBuffer sb = new StringBuffer();
+ StringBuffer sbFile = new StringBuffer();
+
+ // 1. If windows, making cat.exe File object.
+ if (isWindows()) {
+ sb.append("tools");//$NON-NLS-1$
+ sb.append(File.separator);
+ sb.append("mingw");//$NON-NLS-1$
+ sb.append(File.separator);
+ sb.append("msys");//$NON-NLS-1$
+ sb.append(File.separator);
+ sb.append("1.0");//$NON-NLS-1$
+ sb.append(File.separator);
+ sb.append("bin");//$NON-NLS-1$
+ sb.append(File.separator);
+ sb.append("cat.exe");
+ sb.append(" ");//$NON-NLS-1$
+ } else if (isLinux() || isMacOS()) {
+ sb.append("cat ");//$NON-NLS-1$
+ } else {
+ return;
+ }
+
+ // $INPUT_FILE
+ sbFile.append("\"");//$NON-NLS-1$
+ sbFile.append(csFile.getCanonicalFile().getCanonicalPath());
+ sbFile.append("\"");//$NON-NLS-1$
+ String strInputFile = sbFile.toString();
+
+ sb.append(strInputFile);
+ String strCommandCat = sb.toString();
+
+ // 2. Making i386-linux-gnueabi-c++filt File object.
+ sb.delete(0, sb.length());
+ sb.append("tools");//$NON-NLS-1$
+ sb.append(File.separator);
+ sb.append("i386-linux-gnueabi-gcc-4.5");//$NON-NLS-1$
+ sb.append(File.separator);
+ sb.append("bin");//$NON-NLS-1$
+ sb.append(File.separator);
+ if (isWindows()) {
+ sb.append("i386-linux-gnueabi-c++filt.exe");//$NON-NLS-1$
+ } else if (isLinux() || isMacOS()) {
+ sb.append("i386-linux-gnueabi-c++filt");//$NON-NLS-1$
+ } else {
+ return;
+ }
+ sb.append(" > ");//$NON-NLS-1$
+
+ // $OUTPUT_FILE
+ sbFile.delete(0, sbFile.length());
+ sbFile.append("\"");//$NON-NLS-1$
+ sbFile.append(csFile.getParentFile().getCanonicalPath());
+ sbFile.append(File.separator);
+ sbFile.append("copy_");//$NON-NLS-1$
+ sbFile.append(csFile.getName());
+ sbFile.append("\"");//$NON-NLS-1$
+ String strOutputFile = sbFile.toString();
+
+ sb.append(strOutputFile);
+ String strCommandFilt = sb.toString();
+
+ // 3. Making complete command.
+ sb.delete(0, sb.length());
+ sb.append(strCommandCat);
+ sb.append(" | ");//$NON-NLS-1$
+ sb.append(strCommandFilt);
+
+ // 4. Run command.
+ ProcessBuilder processBuilder = new ProcessBuilder();
+ processBuilder.command(getCommand(sb.toString()));
+ processBuilder.directory(new File(sdkRoot));
+ Process process = processBuilder.start();
+ if (process.waitFor() == 0)
+ process.destroy();
+
+ // Final. Change file
+ strInputFile = strInputFile.substring(1, strInputFile.length() - 1);
+ File fileInput = new File(strInputFile);
+ fileInput.setWritable(true);
+ fileInput.delete();
+
+ strOutputFile = strOutputFile.substring(1, strOutputFile.length() - 1);
+ File fileOutput = new File(strOutputFile);
+ fileOutput.setWritable(true);
+ fileOutput.renameTo(new File(strInputFile));
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private String[] getCommand(String strCmd) {
+ if (isWindows()) {
+ return new String[] { "cmd", "/c", strCmd }; //$NON-NLS-1$
+ } else if (isLinux() || isMacOS()) {
+ return new String[] { "/bin/sh", "-c", strCmd }; //$NON-NLS-1$
+ }
+ return null;
+ }
+
+ private static final int MODE_DEFAULT = 0;
+
+ private static final int MODE_HEADER = 1;
+ private static final int MODE_HEADER_CRASH = 2;
+ private static final int MODE_HEADER_SIGNAL = 3;
+ private static final int MODE_HEADER_REGISTER_INFO = 4;
+ private static final int MODE_HEADER_MEMORY = 5;
+ private static final int MODE_HEADER_PACKAGE = 6;
+
+ private static final int MODE_CALL_STACK_INFO = 12;
+ private static final int MODE_MEMORY_MAP = 13;
+ private static final int MODE_DEBUG_MESSAGE = 14;
+
+ private String strSignalNumber = null;
+ private int mode = MODE_DEFAULT;
+
+ public CSVO parse() {
+ CSVO result = null;
+
+ if (csFile != null) {
+ String strLine = null;
+ FileReader fr = null;
+ BufferedReader br = null;
+
+ mode = MODE_DEFAULT;
+ result = new CSVO();
+
+ try {
+ fr = new FileReader(csFile);
+ br = new BufferedReader(fr);
+
+ while ((strLine = br.readLine()) != null) {
+
+ strLine = strLine.trim();
+
+ switch (mode) {
+ case MODE_DEFAULT:
+ if (strLine.equals("S/W Version Information"))//$NON-NLS-1$
+ mode = MODE_HEADER;
+ else if (strLine.equals("Crash Information"))//$NON-NLS-1$
+ mode = MODE_HEADER_CRASH;
+ else if (strLine.equals("Package Information"))//$NON-NLS-1$
+ mode = MODE_HEADER_PACKAGE;
+ else if (strLine.startsWith("Register Information"))//$NON-NLS-1$
+ mode = MODE_HEADER_REGISTER_INFO;
+ else if (strLine.startsWith("Memory Information"))//$NON-NLS-1$
+ mode = MODE_HEADER_MEMORY;
+ else if (strLine.startsWith("Callstack Information"))//$NON-NLS-1$
+ mode = MODE_CALL_STACK_INFO;
+ else if (strLine.startsWith("Maps Information"))//$NON-NLS-1$
+ mode = MODE_MEMORY_MAP;
+ else if (strLine.startsWith("Latest Debug Message Information"))//$NON-NLS-1$
+ mode = MODE_DEBUG_MESSAGE;
+ break;
+
+ case MODE_HEADER:
+ if (parseHeader(result, strLine))
+ mode = MODE_DEFAULT;
+ break;
+
+ case MODE_HEADER_CRASH:
+ if (parseHeaderCrash(result, strLine))
+ mode = MODE_DEFAULT;
+ break;
+
+ case MODE_HEADER_SIGNAL:
+ if (parseHeaderSignal(result, strLine))
+ mode = MODE_DEFAULT;
+ break;
+
+ case MODE_HEADER_REGISTER_INFO:
+ if (parseHeaderRegisterInfo(result, strLine))
+ mode = MODE_DEFAULT;
+ break;
+
+ case MODE_HEADER_PACKAGE:
+ if (parseHeaderPackage(result, strLine))
+ mode = MODE_DEFAULT;
+ break;
+
+ case MODE_HEADER_MEMORY:
+ if (parseHeaderMemory(result, strLine))
+ mode = MODE_DEFAULT;
+ break;
+
+ case MODE_CALL_STACK_INFO:
+ if (parseCallStackInfo(result, strLine))
+ mode = MODE_DEFAULT;
+ break;
+
+ case MODE_MEMORY_MAP:
+ if (parseMemoryMap(result, strLine))
+ mode = MODE_DEFAULT;
+ break;
+
+ case MODE_DEBUG_MESSAGE:
+ if (parseDebugMessage(result, strLine))
+ mode = MODE_DEFAULT;
+ break;
+ }
+ }
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ if (fr != null)
+ fr.close();
+ if (br != null)
+ br.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * @param result
+ * @param strLine
+ * @return
+ */
+ /**
+ * @param result
+ * @param strLine
+ * @return
+ */
+ private boolean parseHeader(CSVO result, String strLine) throws Exception {
+
+ boolean isEnd = false;
+
+ int idxSub = -1;
+ String strSub = null;
+
+ if (strLine.isEmpty()) {
+ isEnd = true;
+ } else {
+ HeaderVO header = result.getHeader();
+
+ if (strLine.startsWith("Build-Number:")) {//$NON-NLS-1$
+ idxSub = strLine.indexOf(':');
+ if (idxSub > -1) {
+ strSub = strLine.substring(idxSub + 1, strLine.length());
+ header.setBuildNumber(strSub);
+ }
+ } else if (strLine.startsWith("Build-Date:")) {//$NON-NLS-1$
+ idxSub = strLine.indexOf(':');
+ if (idxSub > -1) {
+ strSub = strLine.substring(idxSub + 1, strLine.length());
+ header.setBuildDate(strSub);
+ }
+ } else if (strLine.startsWith("Model:")) {//$NON-NLS-1$
+ idxSub = strLine.indexOf(':');
+ if (idxSub > -1) {
+ strSub = strLine.substring(idxSub + 1, strLine.length());
+ header.setModel(strSub);
+ }
+ } else if (strLine.startsWith("Tizen-Version:")) {//$NON-NLS-1$
+ idxSub = strLine.indexOf(':');
+ if (idxSub > -1) {
+ strSub = strLine.substring(idxSub + 1, strLine.length());
+ header.setVersion(strSub);
+ }
+ }
+ result.setHeader(header);
+ }
+
+ return isEnd;
+ }
+
+ private boolean parseHeaderCrash(CSVO result, String strLine) throws Exception {
+ boolean isEnd = false;
+
+ int idxSub = -1;
+ String strSub = null;
+
+ if (strLine.isEmpty()) {
+ isEnd = true;
+ } else {
+ HeaderVO header = result.getHeader();
+
+ if (strLine.startsWith("Date:")) {//$NON-NLS-1$
+ idxSub = strLine.indexOf(':');
+ if (idxSub > -1) {
+ strSub = strLine.substring(idxSub + 1, strLine.length()).trim();
+ header.setCrashDate(strSub);
+ }
+ } else if (strLine.startsWith("Executable File Path:")) {//$NON-NLS-1$
+ idxSub = strLine.indexOf(':');
+ if (idxSub > -1) {
+ strSub = strLine.substring(idxSub + 1, strLine.length()).trim();
+ header.setCrashExePath(strSub);
+ }
+ } else if (strLine.startsWith("Process Name:")) {//$NON-NLS-1$
+ idxSub = strLine.indexOf(':');
+ if (idxSub > -1) {
+ strSub = strLine.substring(idxSub + 1, strLine.length()).trim();
+ header.setProcessName(strSub);
+ }
+ } else if (strLine.startsWith("PID:")) {//$NON-NLS-1$
+ idxSub = strLine.indexOf(':');
+ if (idxSub > -1) {
+ strSub = strLine.substring(idxSub + 1, strLine.length()).trim();
+ header.setPID(strSub);
+ }
+ } else if (strLine.startsWith("Signal:")) {//$NON-NLS-1$
+ idxSub = strLine.indexOf(':');
+ if (idxSub > -1) {
+ strSub = strLine.substring(idxSub + 1, strLine.length()).trim();
+ header.appendSignalLine(strSub);
+ mode = MODE_HEADER_SIGNAL;
+ }
+ }
+ result.setHeader(header);
+ }
+
+ return isEnd;
+ }
+
+ private boolean parseHeaderSignal(CSVO result, String strLine) throws Exception {
+ boolean isEnd = false;
+
+ if (strLine.isEmpty()) {
+ isEnd = true;
+ } else {
+ HeaderVO header = result.getHeader();
+
+ if (strSignalNumber != null && !strSignalNumber.isEmpty()) {
+ header.appendSignalLine(strSignalNumber);
+ strSignalNumber = null;
+ }
+
+ header.appendSignalLine(strLine);
+ result.setHeader(header);
+ }
+
+ return isEnd;
+ }
+
+ private boolean parseHeaderPackage(CSVO result, String strLine) throws Exception {
+ boolean isEnd = false;
+
+ int idxSub = -1;
+ String strSub = null;
+
+ if (strLine.isEmpty()) {
+ isEnd = true;
+ } else {
+ HeaderVO header = result.getHeader();
+
+ if (strLine.startsWith("Package Name:")) {//$NON-NLS-1$
+ idxSub = strLine.indexOf(':');
+ if (idxSub > -1) {
+ strSub = strLine.substring(idxSub + 1, strLine.length()).trim();
+ header.setPackageName(strSub);
+ }
+ } else if (strLine.startsWith("Package Type:")) {//$NON-NLS-1$
+ idxSub = strLine.indexOf(':');
+ if (idxSub > -1) {
+ strSub = strLine.substring(idxSub + 1, strLine.length()).trim();
+ header.setPackageType(strSub);
+ }
+ } else if (strLine.startsWith("Version:")) {//$NON-NLS-1$
+ idxSub = strLine.indexOf(':');
+ if (idxSub > -1) {
+ strSub = strLine.substring(idxSub + 1, strLine.length()).trim();
+ header.setPackageVersion(strSub);
+ }
+ } else if (strLine.startsWith("App Name:")) {//$NON-NLS-1$
+ idxSub = strLine.indexOf(':');
+ if (idxSub > -1) {
+ strSub = strLine.substring(idxSub + 1, strLine.length()).trim();
+ header.setAppName(strSub);
+ }
+ } else if (strLine.startsWith("App ID")) {//$NON-NLS-1$
+ idxSub = strLine.indexOf(':');
+ if (idxSub > -1) {
+ strSub = strLine.substring(idxSub + 1, strLine.length()).trim();
+ header.setAppID(strSub);
+ }
+ } else if (strLine.startsWith("Type:")) {//$NON-NLS-1$
+ idxSub = strLine.indexOf(':');
+ if (idxSub > -1) {
+ strSub = strLine.substring(idxSub + 1, strLine.length()).trim();
+ header.setAppType(strSub);
+ }
+ } else if (strLine.startsWith("Categories:")) {//$NON-NLS-1$
+ idxSub = strLine.indexOf(':');
+ if (idxSub > -1) {
+ strSub = strLine.substring(idxSub + 1, strLine.length()).trim();
+ header.setCategories(strSub);
+ }
+ }
+ }
+
+ return isEnd;
+ }
+
+ private boolean parseHeaderRegisterInfo(CSVO result, String strLine) throws Exception {
+ boolean isEnd = false;
+
+ if (strLine.isEmpty()) {
+ isEnd = true;
+ } else {
+ HeaderVO header = result.getHeader();
+
+ ArrayList<RegisterVO> registerList = header.getRegisterList();
+ String[] strsLine = strLine.split(",");//$NON-NLS-1$
+ for (String str : strsLine) {
+ int idxSub = str.indexOf('=');//$NON-NLS-1$
+ if (idxSub > -1) {
+ RegisterVO registerVO = new RegisterVO(str.substring(0, idxSub).trim(), str.substring(idxSub + 1,
+ str.length()).trim());
+ registerList.add(registerVO);
+ }
+ }
+
+ header.setRegisters(registerList);
+ result.setHeader(header);
+ }
+
+ return isEnd;
+ }
+
+ private boolean parseHeaderMemory(CSVO result, String strLine) throws Exception {
+ boolean isEnd = false;
+
+ if (strLine.isEmpty()) {
+ isEnd = true;
+ } else {
+ HeaderVO header = result.getHeader();
+
+ int idxSub = -1;
+ String strSub = null;
+
+ idxSub = strLine.indexOf(":");//$NON-NLS-1$
+ if (idxSub > -1) {
+ strSub = strLine.substring(0, idxSub).trim();
+ if (strSub.equals("MemTotal")) {//$NON-NLS-1$
+ header.setMemTotal(Integer.parseInt(strLine.substring(idxSub + 1, strLine.length())
+ .replace(" KB", "").trim()));//$NON-NLS-1$
+ } else if (strSub.equals("MemFree")) {//$NON-NLS-1$
+ header.setMemFree(Integer.parseInt(strLine.substring(idxSub + 1, strLine.length())
+ .replace(" KB", "").trim()));//$NON-NLS-1$
+ } else if (strSub.equals("Buffers")) {//$NON-NLS-1$
+ header.setBuffers(Integer.parseInt(strLine.substring(idxSub + 1, strLine.length())
+ .replace(" KB", "").trim()));//$NON-NLS-1$
+ } else if (strSub.equals("Cached")) {//$NON-NLS-1$
+ header.setCached(Integer.parseInt(strLine.substring(idxSub + 1, strLine.length())
+ .replace(" KB", "").trim()));//$NON-NLS-1$
+ } else if (strSub.equals("VmPeak")) {//$NON-NLS-1$
+ header.setVmPeak(Integer.parseInt(strLine.substring(idxSub + 1, strLine.length())
+ .replace(" KB", "").trim()));//$NON-NLS-1$
+ } else if (strSub.equals("VmSize")) {//$NON-NLS-1$
+ header.setVmSize(Integer.parseInt(strLine.substring(idxSub + 1, strLine.length())
+ .replace(" KB", "").trim()));//$NON-NLS-1$
+ } else if (strSub.equals("VmLck")) {//$NON-NLS-1$
+ header.setVmLck(Integer.parseInt(strLine.substring(idxSub + 1, strLine.length())
+ .replace(" KB", "").trim()));//$NON-NLS-1$
+ } else if (strSub.equals("VmPin")) {//$NON-NLS-1$
+ header.setVmPin(Integer.parseInt(strLine.substring(idxSub + 1, strLine.length())
+ .replace(" KB", "").trim()));//$NON-NLS-1$
+ } else if (strSub.equals("VmHWM")) {//$NON-NLS-1$
+ header.setVmHWM(Integer.parseInt(strLine.substring(idxSub + 1, strLine.length())
+ .replace(" KB", "").trim()));//$NON-NLS-1$
+ } else if (strSub.equals("VmRSS")) {//$NON-NLS-1$
+ header.setVmRSS(Integer.parseInt(strLine.substring(idxSub + 1, strLine.length())
+ .replace(" KB", "").trim()));//$NON-NLS-1$
+ } else if (strSub.equals("VmData")) {//$NON-NLS-1$
+ header.setVmData(Integer.parseInt(strLine.substring(idxSub + 1, strLine.length())
+ .replace(" KB", "").trim()));//$NON-NLS-1$
+ } else if (strSub.equals("VmStk")) {//$NON-NLS-1$
+ header.setVmStk(Integer.parseInt(strLine.substring(idxSub + 1, strLine.length())
+ .replace(" KB", "").trim()));//$NON-NLS-1$
+ } else if (strSub.equals("VmExe")) {//$NON-NLS-1$
+ header.setVmExe(Integer.parseInt(strLine.substring(idxSub + 1, strLine.length())
+ .replace(" KB", "").trim()));//$NON-NLS-1$
+ } else if (strSub.equals("VmLib")) {//$NON-NLS-1$
+ header.setVmLib(Integer.parseInt(strLine.substring(idxSub + 1, strLine.length())
+ .replace(" KB", "").trim()));//$NON-NLS-1$
+ } else if (strSub.equals("VmPTE")) {//$NON-NLS-1$
+ header.setVmPTE(Integer.parseInt(strLine.substring(idxSub + 1, strLine.length())
+ .replace(" KB", "").trim()));//$NON-NLS-1$
+ } else if (strSub.equals("VmSwap")) {//$NON-NLS-1$
+ header.setVmSwap(Integer.parseInt(strLine.substring(idxSub + 1, strLine.length())
+ .replace(" KB", "").trim()));//$NON-NLS-1$
+ }
+ }
+
+ result.setHeader(header);
+ }
+
+ return isEnd;
+ }
+
+ private boolean parseCallStackInfo(CSVO result, String strLine) throws Exception {
+ boolean isEnd = false;
+
+ if (strLine.equals("End of Call Stack")) {//$NON-NLS-1$
+ isEnd = true;
+ } else if (strLine.startsWith("Call Stack Count:")) {//$NON-NLS-1$
+ // Ignore
+ } else {
+ ArrayList<CallStackVO> csList = result.getCallStackList();
+
+ int idxSub = -1;
+ int idxL = -1, idxR = -1;
+ int countP = 0;
+
+ CallStackVO csVO = new CallStackVO();
+
+ idxSub = strLine.indexOf(":");
+ if (idxSub > -1)
+ csVO.setSerialNumber(Integer.parseInt(strLine.substring(0, idxSub).trim()));
+
+ // emluator vs. target
+ boolean isAbnormalAddressFormat = false;
+ String strAddressTemp = null;
+ long addressTemp = 0l;
+ idxL = strLine.indexOf('[');
+ idxR = strLine.indexOf(']');
+ if (idxL > -1 && idxR > -1) {
+ strAddressTemp = strLine.substring(idxL + 1, idxR).trim();
+ if (strAddressTemp != null) {
+ try {
+ if (strAddressTemp.startsWith("0x"))//$NON-NLS-1$
+ strAddressTemp = strAddressTemp.substring(2, strAddressTemp.length());
+ addressTemp = Long.parseLong(strAddressTemp, 16);
+ } catch (NumberFormatException e) {
+ isAbnormalAddressFormat = true;
+ }
+ }
+ }
+
+ if (isAbnormalAddressFormat) {
+ // Target
+
+ idxL = 0;
+ idxR = 0;
+ countP = countParentheses(strLine);
+ if (countP > 0) {
+ for (int i = 0; i < countP; i++) {
+ idxL = strLine.indexOf("(", idxL);//$NON-NLS-1$
+ if (idxL > -1) {
+ idxR = strLine.indexOf(")", idxL);//$NON-NLS-1$
+ if (idxR > -1) {
+ if (idxL + 3 < idxR) {
+ long longTemp = getAddress(strLine.substring(idxL + 1, idxR).trim());
+ if (longTemp != 0) {
+ csVO.setAddressS(strLine.substring(idxL + 1, idxR).trim());
+ csVO.setAddressL(longTemp);
+ csVO.setPayload(strLine);
+
+ csList.add(csVO);
+ result.setCallStackList(csList);
+ break;
+ } else {
+ idxL = idxR;
+ }
+ } else {
+ idxL = idxR;
+ }
+ }
+ }
+ }
+ }
+ } else {
+ // Emulator
+ csVO.setAddressS(strAddressTemp);
+ csVO.setAddressL(addressTemp);
+
+ if (idxSub > 0 && idxL > 0)
+ csVO.setPayload(strLine.substring(idxSub, idxL).trim());
+ csList.add(csVO);
+ result.setCallStackList(csList);
+ }
+ }
+
+ return isEnd;
+ }
+
+ private boolean parseMemoryMap(CSVO result, String strLine) throws Exception {
+ boolean isEnd = false;
+
+ if (strLine.equals("End of Maps Information")) {//$NON-NLS-1$
+ isEnd = true;
+ } else if (!strLine.isEmpty()) {
+ ArrayList<MemoryMapVO> memoryMapList = result.getMemoryMapList();
+
+ int idxStart = 0, idxEnd = -1;
+ String strSub = null;
+ MemoryMapVO memoryMapVO = new MemoryMapVO();
+
+ idxEnd = strLine.indexOf(" ");//$NON-NLS-1$
+ if (idxEnd > -1) {
+ strSub = strLine.substring(idxStart, idxEnd).trim();
+ memoryMapVO.setStartAddressS(strSub);
+ memoryMapVO.setStartAddressL(Long.parseLong(strSub, 16));
+ }
+ idxStart = idxEnd + 1;
+ idxEnd = strLine.indexOf(" ", idxStart);//$NON-NLS-1$
+ if (idxEnd > -1) {
+ strSub = strLine.substring(idxStart, idxEnd).trim();
+ memoryMapVO.setEndAddressS(strSub);
+ memoryMapVO.setEndAddressL(Long.parseLong(strSub, 16));
+ }
+ idxStart = idxEnd + 1;
+ idxEnd = strLine.indexOf(" ", idxStart);//$NON-NLS-1$
+ if (idxEnd > -1) {
+ strSub = strLine.substring(idxStart, idxEnd).trim();
+ memoryMapVO.setMod(strSub);
+ }
+ idxStart = idxEnd + 1;
+ idxEnd = strLine.length();
+ if (idxEnd > -1) {
+ strSub = strLine.substring(idxStart, idxEnd).trim();
+ memoryMapVO.setSoInfo(strSub);
+ }
+
+ memoryMapList.add(memoryMapVO);
+ result.setMemoryMapList(memoryMapList);
+ }
+
+ return isEnd;
+ }
+
+ private boolean parseDebugMessage(CSVO result, String strLine) throws Exception {
+ boolean isEnd = false;
+
+ if (strLine.startsWith("end of latest dmf")) {//$NON-NLS-1$
+ isEnd = true;
+ } else {
+ boolean isAbnormalLine = false;
+ ArrayList<DebugMessageVO> debugMessageList = result.getDebugMessageList();
+
+ int idxStart = -1, idxEnd = -1;
+ String strSub = null;
+ DebugMessageVO debugMessageVO = new DebugMessageVO();
+
+ idxEnd = strLine.indexOf(" ");//$NON-NLS-1$
+ if (idxEnd > -1) {
+ strSub = strLine.substring(0, idxEnd);
+ idxStart = idxEnd + 1;
+ idxEnd = strLine.indexOf(" ", idxStart);//$NON-NLS-1$
+ if (idxEnd > -1) {
+ strSub = strLine.substring(0, idxEnd).trim();
+ debugMessageVO.setDate(strSub);
+ } else {
+ isAbnormalLine = true;
+ }
+ }
+ idxStart = idxEnd + 1;
+ idxEnd = strLine.indexOf("(", idxStart);//$NON-NLS-1$
+ if (idxEnd > -1) {
+ strSub = strLine.substring(idxStart, idxEnd).trim();
+ debugMessageVO.setTag(strSub);
+ } else {
+ isAbnormalLine = true;
+ }
+ idxStart = idxEnd + 1;
+ idxEnd = strLine.indexOf(")", idxStart);//$NON-NLS-1$
+ if (idxEnd > -1) {
+ strSub = strLine.substring(idxStart, idxEnd).trim();
+ debugMessageVO.setPID(strSub);
+ } else {
+ isAbnormalLine = true;
+ }
+ idxStart = strLine.indexOf(":", idxEnd);//$NON-NLS-1$
+ if (idxStart > -1) {
+ strSub = strLine.substring(idxStart + 1, strLine.length()).trim();
+ debugMessageVO.setMessage(strSub);
+ } else {
+ isAbnormalLine = true;
+ }
+
+ if (!isAbnormalLine)
+ debugMessageList.add(debugMessageVO);
+ result.setDebugMessageList(debugMessageList);
+ }
+
+ return isEnd;
+ }
+
+ private int countParentheses(String strLine) {
+ int result = 0;
+ int i, len = 0;
+ boolean isLeft = false;
+
+ if (strLine != null)
+ len = strLine.length();
+
+ for (i = 0; i < len; i++) {
+ if (strLine.charAt(i) == '(')
+ isLeft = true;
+
+ if (isLeft && strLine.charAt(i) == ')') {
+ result++;
+ isLeft = false;
+ }
+ }
+
+ return result;
+ }
+
+ private long getAddress(String strLine) {
+ long result = 0;
+
+ if (strLine != null && strLine.startsWith("0x")) {//$NON-NLS-1$
+ strLine = strLine.substring(3, strLine.length()).trim();
+ result = Long.parseLong(strLine, 16);
+ }
+
+ return result;
+ }
+
+ /*
+ * From OSChecker.java
+ */
+ public String PROPERTY_OS_NAME = (System.getProperty("os.name") != null) //$NON-NLS-1$
+ ? System.getProperty("os.name").toLowerCase() : ""; //$NON-NLS-1$
+
+ public boolean isWindows() {
+ if (PROPERTY_OS_NAME.contains("windows")) { //$NON-NLS-1$
+ return true;
+ }
+ return false;
+ }
+
+ public boolean isLinux() {
+ if (PROPERTY_OS_NAME.contains("linux")) { //$NON-NLS-1$
+ return true;
+ }
+ return false;
+ }
+
+ public boolean isMacOS() {
+ if (PROPERTY_OS_NAME.contains("mac")) { //$NON-NLS-1$
+ return true;
+ }
+ return false;
+ }
+}
--- /dev/null
+/*
+ * org.tizen.nativecpp.csviewer
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Zoomin Cha <zoomin.cha@samsung.com>
+ * JaeGyu Jung <pang@samsung.com>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * - Samsung Electronics, Co. Ltd.
+ *
+ */
+
+package org.tizen.nativeplatform.coredump.model;
+
+import java.util.ArrayList;
+
+public class HeaderVO {
+
+ // Binary info. start
+ private int major;
+ private int minor;
+ private String buildNumber;
+ private String buildDate;
+ private String buildTime;
+
+ // Application info. start
+ private String fileName;
+ private String pID;
+
+ // Extra(crash) info. start
+ private String crashDate;
+ private String crashExePath;
+ private String signal;
+ private ArrayList<RegisterVO> registers;
+
+ // Memory Information
+ private int memTotal;
+ private int memFree;
+ private int buffers;
+ private int cached;
+ private int vmPeak;
+ private int vmSize;
+ private int vmLck;
+ private int vmPin;
+ private int vmHWM;
+ private int vmRSS;
+ private int vmData;
+ private int vmStk;
+ private int vmExe;
+ private int vmLib;
+ private int vmPTE;
+ private int vmSwap;
+
+ // New Format
+ private String model;
+ private String version;
+ private String processName;
+
+ // Package Information
+ private String packageName;
+ private String packageType;
+ private String packageVersion;
+ private String appName;
+ private String appID;
+ private String appType;
+ private String category;
+
+ public HeaderVO() {
+ super();
+ registers = new ArrayList<RegisterVO>();
+ }
+
+ public String[][] getSWVersionItems() {
+ String[][] result = { new String[] { "Model", this.model },
+ new String[] { "Tizen-Version", this.version },
+ new String[] { "Build-Number", buildNumber },
+ new String[] { "Build-Date", buildDate } };
+
+ return result;
+ }
+
+ public String[][] getCrashInformationItems() {
+ String[][] result = { new String[] { "Process Name", processName },
+ new String[] { "PID", pID },
+ new String[] { "Date", crashDate },
+ new String[] { "Executable File Path", crashExePath } };
+
+ return result;
+ }
+
+ public String[][] getSignalInformationItems() {
+ String[][] result = { new String[] { "Signal", signal } };
+ return result;
+ }
+
+ public String[][] getMemoryInformationItems() {
+ String[][] result = {
+ new String[] { "Total Memory", memTotal + " KB" },
+ new String[] { "Free Memory", memFree + " KB" },
+ new String[] { "Buffer Memory", buffers + " KB" },
+ new String[] { "Cached Memory", cached + " KB" },
+
+ new String[] { "VmPeak", vmPeak + " KB" },
+ new String[] { "VmSize", vmSize + " KB" },
+ new String[] { "VmLck", vmLck + " KB" },
+ new String[] { "VmPin", vmPin + " KB" },
+ new String[] { "VmHWM", vmHWM + " KB" },
+ new String[] { "VmRSS", vmRSS + " KB" },
+ new String[] { "VmData", vmData + " KB" },
+ new String[] { "VmStk", vmStk + " KB" },
+ new String[] { "VmExe", vmExe + " KB" },
+ new String[] { "VmLib", vmLib + " KB" },
+ new String[] { "VmPTE", vmPTE + " KB" },
+ new String[] { "VmSwap", vmSwap + " KB" }
+ };
+ return result;
+ }
+
+ public String[][] getPackageInformationItems() {
+ String[][] result = { new String[] { "Package Name", packageName },
+ new String[] { "Package Type", packageType },
+ new String[] { "Application Name", appName },
+ new String[] { "Application ID", appID },
+ new String[] { "Application Version", packageVersion },
+ new String[] { "Application Type", appType },
+ new String[] { "Category", category } };
+ return result;
+ }
+
+ public ArrayList<RegisterVO> getRegisterInformationItems() {
+ return registers;
+ }
+
+ public int getMajor() {
+ return major;
+ }
+
+ public void setMajor(int major) {
+ this.major = major;
+ }
+
+ public int getMinor() {
+ return minor;
+ }
+
+ public void setMinor(int minor) {
+ this.minor = minor;
+ }
+
+ public String getBuildNumber() {
+ return buildNumber;
+ }
+
+ public void setBuildNumber(String buildNumber) {
+ this.buildNumber = buildNumber;
+ }
+
+ public String getBuildDate() {
+ return buildDate;
+ }
+
+ public void setBuildDate(String buildDate) {
+ this.buildDate = buildDate;
+ }
+
+ public String getBuildTime() {
+ return buildTime;
+ }
+
+ public void setBuildTime(String buildTime) {
+ this.buildTime = buildTime;
+ }
+
+ public String getAppName() {
+ return appName;
+ }
+
+ public void setAppName(String appName) {
+ this.appName = appName;
+ }
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+
+ public String getpID() {
+ return pID;
+ }
+
+ public void setPID(String pID) {
+ this.pID = pID;
+ }
+
+ public String getCrashDate() {
+ return crashDate;
+ }
+
+ public void setCrashDate(String crashDate) {
+ this.crashDate = crashDate;
+ }
+
+ public String getCrashExePath() {
+ return crashExePath;
+ }
+
+ public void setCrashExePath(String crashExePath) {
+ this.crashExePath = crashExePath;
+ }
+
+ public String getSignal() {
+ return signal;
+ }
+
+ public void setSignal(String signal) {
+ this.signal = signal;
+ }
+
+ public void appendSignalLine(String signal) {
+ if (this.signal == null || this.signal.isEmpty()) {
+ this.signal = signal;
+ } else {
+ StringBuffer sb = new StringBuffer(this.signal);
+ sb.append("\n");
+ sb.append(signal);
+ this.signal = sb.toString();
+ }
+ }
+
+ public ArrayList<RegisterVO> getRegisterList() {
+ return registers;
+ }
+
+ public void setRegisters(ArrayList<RegisterVO> registers) {
+ this.registers = registers;
+ }
+
+ public int getMemTotal() {
+ return memTotal;
+ }
+
+ public void setMemTotal(int memTotal) {
+ this.memTotal = memTotal;
+ }
+
+ public int getMemFree() {
+ return memFree;
+ }
+
+ public void setMemFree(int memFree) {
+ this.memFree = memFree;
+ }
+
+ public int getBuffers() {
+ return buffers;
+ }
+
+ public void setBuffers(int buffers) {
+ this.buffers = buffers;
+ }
+
+ public int getCached() {
+ return cached;
+ }
+
+ public void setCached(int cached) {
+ this.cached = cached;
+ }
+
+ public String getModel() {
+ return model;
+ }
+
+ public void setModel(String model) {
+ this.model = model;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getProcessName() {
+ return processName;
+ }
+
+ public void setProcessName(String processName) {
+ this.processName = processName;
+ }
+
+ public String getPackageName() {
+ return packageName;
+ }
+
+ public void setPackageName(String packageName) {
+ this.packageName = packageName;
+ }
+
+ public String getPackageType() {
+ return packageType;
+ }
+
+ public void setPackageType(String packageType) {
+ this.packageType = packageType;
+ }
+
+ public String getPackageVersion() {
+ return packageVersion;
+ }
+
+ public void setPackageVersion(String packageVersion) {
+ this.packageVersion = packageVersion;
+ }
+
+ public String getAppID() {
+ return appID;
+ }
+
+ public void setAppID(String appID) {
+ this.appID = appID;
+ }
+
+ public String getAppType() {
+ return appType;
+ }
+
+ public void setAppType(String appType) {
+ this.appType = appType;
+ }
+
+ public String getCategory() {
+ return category;
+ }
+
+ public void setCategories(String category) {
+ this.category = category;
+ }
+
+ public int getVmPeak() {
+ return vmPeak;
+ }
+
+ public void setVmPeak(int vmPeak) {
+ this.vmPeak = vmPeak;
+ }
+
+ public int getVmSize() {
+ return vmSize;
+ }
+
+ public void setVmSize(int vmSize) {
+ this.vmSize = vmSize;
+ }
+
+ public int getVmLck() {
+ return vmLck;
+ }
+
+ public void setVmLck(int vmLck) {
+ this.vmLck = vmLck;
+ }
+
+ public int getVmPin() {
+ return vmPin;
+ }
+
+ public void setVmPin(int vmPin) {
+ this.vmPin = vmPin;
+ }
+
+ public int getVmHWM() {
+ return vmHWM;
+ }
+
+ public void setVmHWM(int vmHWM) {
+ this.vmHWM = vmHWM;
+ }
+
+ public int getVmRSS() {
+ return vmRSS;
+ }
+
+ public void setVmRSS(int vmRSS) {
+ this.vmRSS = vmRSS;
+ }
+
+ public int getVmData() {
+ return vmData;
+ }
+
+ public void setVmData(int vmData) {
+ this.vmData = vmData;
+ }
+
+ public int getVmStk() {
+ return vmStk;
+ }
+
+ public void setVmStk(int vmStk) {
+ this.vmStk = vmStk;
+ }
+
+ public int getVmExe() {
+ return vmExe;
+ }
+
+ public void setVmExe(int vmExe) {
+ this.vmExe = vmExe;
+ }
+
+ public int getVmLib() {
+ return vmLib;
+ }
+
+ public void setVmLib(int vmLib) {
+ this.vmLib = vmLib;
+ }
+
+ public int getVmPTE() {
+ return vmPTE;
+ }
+
+ public void setVmPTE(int vmPTE) {
+ this.vmPTE = vmPTE;
+ }
+
+ public int getVmSwap() {
+ return vmSwap;
+ }
+
+ public void setVmSwap(int vmSwap) {
+ this.vmSwap = vmSwap;
+ }
+
+}