import org.eclipse.swt.widgets.Shell;
import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
import org.tizen.dynamicanalyzer.common.AnalyzerManager;
+import org.tizen.dynamicanalyzer.common.GlobalInformation;
import org.tizen.dynamicanalyzer.common.SymbolManager;
import org.tizen.dynamicanalyzer.common.SymbolManager.SourceLine;
import org.tizen.dynamicanalyzer.communicator.IDECommunicator;
import org.tizen.dynamicanalyzer.constant.CommonConstants;
import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
+import org.tizen.dynamicanalyzer.project.AppInfo;
import org.tizen.dynamicanalyzer.resources.ColorResources;
import org.tizen.dynamicanalyzer.resources.FontResources;
import org.tizen.dynamicanalyzer.resources.ImageResources;
BinarySettingData binData = BinarySettingManager.getInstance()
.getRealBinarySetting(libName);
- if (null != binData && null != binData.getUserSourcePath()
+ if (null != binData) {
+ if (null != binData.getUserSourcePath()
&& !binData.getUserSourcePath().isEmpty()) {
- String fileName = getSourceFilePath(sourceLine.getFilePath());
- filePath = binData.getUserSourcePath() + File.separator + fileName;
- } else {
- if (!isLibrary(libName)) {
- filePath = sourceLine.getFilePath();
+ String fileName = getSourceFilePath(sourceLine.getFilePath());
+ filePath = binData.getUserSourcePath() + File.separator + fileName;
} else {
filePath = binData.getDebugSourcePath()
- + sourceLine.getFilePath();
+ + sourceLine.getFilePath();
+ }
+ } else {
+ AppInfo appInfo = GlobalInformation.getCurrentApplication();
+ if (appInfo.getMainBinaryInfo().getTargetBinaryPath().equals(libName)
+ && appInfo.getAppType().contains(AppInfo.APPTYPE_CAPP)) {
+ filePath = appInfo.getSourcePath() + sourceLine.getFilePath();
+ } else {
+ filePath = sourceLine.getFilePath();
}
}
return filePath;
path = binInfo.getTempBinaryPath();
}
} else {
- path = binInfo.getTempBinaryPath();
+ AppInfo appInfo = GlobalInformation.getCurrentApplication();
+ if (binInfo.equals(appInfo.getMainBinaryInfo())
+ && appInfo.getAppType().contains(AppInfo.APPTYPE_CAPP)) {
+ path = appInfo.getDebugFilePath();
+ } else {
+ path = binInfo.getTempBinaryPath();
+ }
}
SourceLine sl = SymbolManager.addr2line(path, addr, isPieBuild,
baseAddr);
import java.util.HashMap;
import java.util.List;
-import org.tizen.dynamicanalyzer.common.ElfSymbolExtracter;
+import org.tizen.dynamicanalyzer.common.ElfSymbolExtractor;
import org.tizen.dynamicanalyzer.common.GlobalInformation;
import org.tizen.dynamicanalyzer.common.path.PathManager;
import org.tizen.dynamicanalyzer.constant.CommonConstants;
public static final String APPTYPE_WEB = "webapp";//$NON-NLS-1$
public static final String FLAG_ZERO = "0";//$NON-NLS-1$
public static final String FLAG_ONE = "1";//$NON-NLS-1$
+
+ public static final String DEBUGPKGTYPE_DEBUG = "debug-";//$NON-NLS-1$
+ public static final String DEBUGPKGTYPE_DEBUGINFO = "debuginfo";//$NON-NLS-1$
+ public static final String DEBUGPKGTYPE_DEBUGSOURCE = "debugsource";//$NON-NLS-1$
private static final DALogger DA_LOG = DALogger.getInstance();
private String installTime = null;
private String execFileName = null;
+ private String debugFilePath = null;
+ private String sourcePath = null;
- private ElfSymbolExtracter symbolExtractor = new ElfSymbolExtracter();
+ private ElfSymbolExtractor symbolExtractor = new ElfSymbolExtractor();
public String getInstallTime() {
return installTime;
public void setInstallTime(String installTime) {
this.installTime = installTime;
}
+
+ public String getDebugFilePath() {
+ return debugFilePath;
+ }
+
+ public void setDebugFilePath(String debugFilePath) {
+ this.debugFilePath = debugFilePath;
+ }
+
+ public String getSourcePath() {
+ return sourcePath;
+ }
+
+ public void setSourcePath(String sourcePath) {
+ this.sourcePath = sourcePath;
+ }
private List<String> appInfo = new ArrayList<String>();
return appInfo.get(index);
}
- // public BinaryInfo getBinInfo() {
- // return binInfo;
- // }
-
- // public void setBinInfo(BinaryInfo binInfo) {
- // this.binInfo = binInfo;
- // }
-
public List<AddrSymbolPair> getSymbols(String sourceBinaryPath) {
- List<AddrSymbolPair> fromDebug = null;
+ List<AddrSymbolPair> symbols = null;
if (localPackagePath != null) {
int psize = localPackagePath.size();
for (int i = 0; i < psize; i++) {
- if (localPackagePath.get(i).contains("debuginfo")) {
- fromDebug = getSymbolsFromDebugRpm(localPackagePath.get(i));
- break;
+ if (localPackagePath.get(i)
+ .contains(DEBUGPKGTYPE_DEBUGINFO)) {
+ getDebugFilePathFromDebugRpm(localPackagePath.get(i));
+ } else if (localPackagePath.get(i)
+ .contains(DEBUGPKGTYPE_DEBUGSOURCE)) {
+ getSourcePathFromSourceRpm(localPackagePath.get(i));
}
}
}
- if (fromDebug == null) {
- List<AddrSymbolPair> fromExec = getSymbolsFromBinary(sourceBinaryPath);
- return fromExec;
- } else {
- return fromDebug;
- }
+ symbols = getSymbolsFromBinary(sourceBinaryPath);
+ return symbols;
}
public List<AddrSymbolPair> getSymbolsFromBinary(String sourceBinaryPath) {
return symbolExtractor.getAddrSymbolPairs();
}
- public List<AddrSymbolPair> getSymbolsFromDebugRpm(String debugRpmPath) {
+ //TODO: refactoring - make rpm copy/extraction code to utility function
+
+ public void getDebugFilePathFromDebugRpm(String debugRpmPath) {
String debugFilePath = null;
if (null == debugRpmPath || debugRpmPath.isEmpty()) {
- return null;
+ return;
}
// check rpm file exists
File debugInfoRpmFile = new File(debugRpmPath);
if (!debugInfoRpmFile.exists() || debugInfoRpmFile.isDirectory()) {
- return null;
+ return;
}
// copy rpm file
String rpmPath = PathManager.DA_RPM_PATH + File.separator
if (!rpms.exists()) {
if (!rpms.mkdirs()) {
DA_LOG.debug("rpm directory create failed...");
- return null;
+ return;
}
}
String copiedRpmPath = null;
if (AnalyzerUtil.copyFile(debugRpmPath, destPath)) {
copiedRpmPath = destPath;
} else {
- return null;
+ return;
}
// extract rpm file
String toolPath = PathManager.DA_TOOL_FOLDER_PATH + File.separator
+ "debuginfo.sh";
String[] command = null;
- // TODO: handle source rpm package
- // if (null != debugRpmSourcePath) {
- // command = new String[] { toolPath, "-r", rpmPath,
- // debugRpmPath, debugRpmSourcePath };
- // } else {
command = new String[] { toolPath, "-d", rpmPath, debugRpmPath };
- // }
try {
Runtime rt = Runtime.getRuntime();
Process process = rt.exec(command);
String errorStr = error.readLine();
DA_LOG.debug("debug info file extract failed... : "
+ errorStr);
- return null;
+ return;
}
} catch (IOException e) {
e.printStackTrace();
- return null;
+ return;
} catch (InterruptedException e) {
e.printStackTrace();
- return null;
+ return;
}
}
// check debuginfo file path
- if (debugInfoRpmFile.getName().contains("debuginfo")) {
+ if (debugInfoRpmFile.getName().contains(DEBUGPKGTYPE_DEBUGINFO)) {
String debugCmd = PathManager.DA_TOOL_FOLDER_PATH + File.separator
+ "debuginfo.sh -f " + rpmPath + CommonConstants.SPACE
- + appInfo.get(LABEL_INDEX) + ".debug";
+ + getExecFileName() + ".debug";
try {
Runtime rt = Runtime.getRuntime();
Process process = rt.exec(debugCmd);
new InputStreamReader(process.getErrorStream()));
String errorStr = error.readLine();
DA_LOG.debug("debug info file find failed... : " + errorStr);
- return null;
+ return;
}
debugFilePath = rpmPath + line.substring(1, line.length());
DA_LOG.debug("DEBUG PATH : " + debugFilePath);
} catch (IOException e) {
e.printStackTrace();
- return null;
+ return;
} catch (InterruptedException e) {
e.printStackTrace();
- return null;
+ return;
}
- // TODO: handle source rpm package
- // future extension for normal executable
- } else if (debugInfoRpmFile.getName().contains("debug-")) {
+ // future extension for applications with normal debug package
+ } else if (debugInfoRpmFile.getName()
+ .contains(DEBUGPKGTYPE_DEBUG)) {
String debugCmd = PathManager.DA_TOOL_FOLDER_PATH + File.separator
+ "debuginfo.sh -f " + rpmPath + CommonConstants.SPACE
- + appInfo.get(LABEL_INDEX);
+ + getExecFileName();
try {
Runtime rt = Runtime.getRuntime();
Process process = rt.exec(debugCmd);
new InputStreamReader(process.getErrorStream()));
String errorStr = error.readLine();
DA_LOG.debug("debug info file find failed... : " + errorStr);
- return null;
+ return;
}
debugFilePath = rpmPath + line.substring(1, line.length());
DA_LOG.debug("DEBUG PATH : " + debugFilePath);
} catch (IOException e) {
e.printStackTrace();
- return null;
+ return;
} catch (InterruptedException e) {
e.printStackTrace();
- return null;
+ return;
}
} else {
- return null;
+ return;
}
- if (null == debugFilePath || debugFilePath.isEmpty()) {
- return null;
+ if (null != debugFilePath && !debugFilePath.isEmpty()) {
+ setDebugFilePath(debugFilePath);
+ }
+ return;
+ }
+
+ public void getSourcePathFromSourceRpm(String sourceRpmPath) {
+ if (null == sourceRpmPath || sourceRpmPath.isEmpty()) {
+ return;
+ }
+
+ // check rpm file exists
+ File debugsourceRpmFile = new File(sourceRpmPath);
+ if (!debugsourceRpmFile.exists() || debugsourceRpmFile.isDirectory()) {
+ return;
+ }
+
+ // get source project name
+ // (ex. pr-debugsource-0.0.0-1.1.i586.rpm -> pr-0.0.0)
+ String debugsourceRpmFileName = debugsourceRpmFile.getName();
+ int index = debugsourceRpmFileName.indexOf(DEBUGPKGTYPE_DEBUGSOURCE);
+ String project = debugsourceRpmFileName.substring(0, index);
+ String[] splitSrcRpmFileName = debugsourceRpmFileName
+ .split(CommonConstants.DASH);
+ String version = splitSrcRpmFileName[splitSrcRpmFileName.length - 2];
+ String projectName = project + version;
+
+ // copy rpm file
+ String rpmPath = PathManager.DA_RPM_PATH + File.separator
+ + appInfo.get(LABEL_INDEX);
+ File rpms = new File(rpmPath);
+ if (!rpms.exists()) {
+ if (!rpms.mkdirs()) {
+ DA_LOG.debug("rpm directory create failed...");
+ return;
+ }
+ }
+ String copiedRpmPath = null;
+ String destPath = rpmPath + File.separator + debugsourceRpmFileName;
+ if (AnalyzerUtil.copyFile(sourceRpmPath, destPath)) {
+ copiedRpmPath = destPath;
} else {
- return getSymbolsFromBinary(debugFilePath);
+ return;
}
- }
- public String getExecFileName(int type) {
+ // extract rpm file
+ if (null != copiedRpmPath) {
+ String toolPath = PathManager.DA_TOOL_FOLDER_PATH + File.separator
+ + "debuginfo.sh";
+ String[] command = null;
+ command = new String[] { toolPath, "-d", rpmPath, sourceRpmPath };
+
+ 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("EXTRACT RPM : " + line);
+ }
+ }
+ if (lineCount == 0) {
+ BufferedReader error = new BufferedReader(
+ new InputStreamReader(process.getErrorStream()));
+ String errorStr = error.readLine();
+ DA_LOG.debug("debug source file extract failed... : "
+ + errorStr);
+ return;
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ return;
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ return;
+ }
+ }
+
+ // check debugsource file path
+ String sourceCmd = PathManager.DA_TOOL_FOLDER_PATH + File.separator
+ + "debuginfo.sh -f " + rpmPath + CommonConstants.SPACE
+ + projectName + CommonConstants.ASTERISK;
+ try {
+ Runtime rt = Runtime.getRuntime();
+ Process process = rt.exec(sourceCmd);
+ process.waitFor();
+ BufferedReader reader = new BufferedReader(
+ new InputStreamReader(process.getInputStream()));
+ String line = reader.readLine();
+ if (null == line) {
+ BufferedReader error = new BufferedReader(
+ new InputStreamReader(process.getErrorStream()));
+ String errorStr = error.readLine();
+ DA_LOG.debug("source file path get failed... : " + errorStr);
+ return;
+ }
+ setSourcePath(rpmPath);
+ DA_LOG.debug("SOURCE PATH : " + sourcePath);
+ } catch (IOException e) {
+ e.printStackTrace();
+ return;
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ return;
+ }
+ }
+
+ public String getExecFileName() {
if (null == execFileName) {
- String execPath = appInfo.get(EXEC_INDEX);
- String[] splitPath = execPath.split(CommonConstants.SLASH);
- if (type == ApplicationInst.APPTYPE_TIZEN) {
+ String[] splitPath = appInfo.get(EXEC_INDEX)
+ .split(CommonConstants.SLASH);
+ if (getAppType().contains(APPTYPE_CPP)) {
execFileName = splitPath[splitPath.length - 1]
+ CommonConstants.EXTENSION_EXEC_FILE;
} else {
public String getExecPath() {
String exec = appInfo.get(EXEC_INDEX);
- // exec = exec.replaceFirst("/opt/apps", "/opt/usr/apps");
if (getAppType().contains(APPTYPE_CPP)) {
- exec += ".exe";
+ exec = exec.replaceFirst("/opt/apps", "/opt/usr/apps");
+ exec += CommonConstants.EXTENSION_EXEC_FILE;
}
return exec;
}