LAUNCH: Supported RDS (debug as) and insert user logger for checking
authordonghyuk.yang <donghyuk.yang@samsung.com>
Mon, 28 Apr 2014 07:35:40 +0000 (16:35 +0900)
committerdonghyuk.yang <donghyuk.yang@samsung.com>
Mon, 28 Apr 2014 07:35:40 +0000 (16:35 +0900)
performance

RDS is not fully supported. RDS supports only change resource (except
remove/add resource).

Change-Id: Ie9b6603f3bf38c8f9a2a16f2d9a5e2621fe0ff9c
Signed-off-by: donghyuk.yang <donghyuk.yang@samsung.com>
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/PlatformLaunchDelegate.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenPlatformDebugger.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformLaunchSettingPage.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmPackageLauncher.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/PkgMgrInitializer.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/rds/RemoteRpmRapidDeployer.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/PlatformUserInteraction.java

index 0928efb..cf7ccdd 100644 (file)
@@ -658,6 +658,7 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
             }
 
             // Run gdbserver as blocking mode!
+            UserLogger.start(UserInteraction.CATE_PLATFORM_LAUNCH, PlatformUserInteraction.START_GDBSERVER);
             tizenCommand.run(gdbserverRunCommand, null, true);
         } catch (Exception e) {
             logger.error(TizenLaunchMessages.CANNOT_LAUNCH_APPLICATION_WITH_GDBSERVER, e);
@@ -670,6 +671,7 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
 
     protected ICDISession getDebugSession(ILaunch launch, ILaunchConfiguration config,
             IBinaryObject exeFile, IProgressMonitor monitor) throws CoreException {
+        UserLogger.start(UserInteraction.CATE_PLATFORM_LAUNCH, PlatformUserInteraction.START_GDB_SESSION);
         TizenPlatformDebugger debugger = new TizenPlatformDebugger();
         if (OSChecker.isWindows()) {
             String appPath = config.getAttribute(
index 41227a1..cee4bb5 100644 (file)
@@ -3,6 +3,7 @@ package org.tizen.nativeplatform.launch;
 import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
 import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
 import org.eclipse.cdt.debug.mi.core.GDBServerCDIDebugger2;
+import org.eclipse.cdt.debug.mi.core.IGDBServerMILaunchConfigurationConstants;
 import org.eclipse.cdt.debug.mi.core.IMILaunchConfigurationConstants;
 import org.eclipse.cdt.debug.mi.core.MIException;
 import org.eclipse.cdt.debug.mi.core.MIPlugin;
@@ -11,6 +12,8 @@ import org.eclipse.cdt.debug.mi.core.cdi.Session;
 import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
 import org.eclipse.cdt.debug.mi.core.command.Command;
 import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
+import org.eclipse.cdt.debug.mi.core.command.MIGDBSet;
+import org.eclipse.cdt.debug.mi.core.command.MITargetSelect;
 import org.eclipse.cdt.debug.mi.core.output.MIInfo;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IProgressMonitor;
@@ -18,6 +21,9 @@ import org.eclipse.core.runtime.OperationCanceledException;
 import org.eclipse.debug.core.DebugPlugin;
 import org.eclipse.debug.core.ILaunch;
 import org.eclipse.debug.core.ILaunchConfiguration;
+import org.tizen.common.util.log.UserInteraction;
+import org.tizen.common.util.log.UserLogger;
+import org.tizen.nativeplatform.util.PlatformUserInteraction;
 
 public class TizenPlatformDebugger extends GDBServerCDIDebugger2 {
     @Override
@@ -120,4 +126,68 @@ public class TizenPlatformDebugger extends GDBServerCDIDebugger2 {
                 IMILaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT);
         return (gdbinit != null && gdbinit.length() > 0) ? "--command=" + gdbinit : "--nx"; //$NON-NLS-1$ //$NON-NLS-2$
     }
+    
+    protected void startGDBServerSession( ILaunchConfiguration config, Session session, IProgressMonitor monitor ) throws CoreException {
+        if ( monitor.isCanceled() ) {
+            throw new OperationCanceledException();
+        }
+        ICDITarget[] targets = session.getTargets();
+        int launchTimeout = MIPlugin.getLaunchTimeout();
+        boolean tcpConnection = config.getAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_REMOTE_TCP, false );
+        // Set serial line parameters
+        if ( !tcpConnection ) {
+            String remoteBaud = config.getAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_DEV_SPEED, "invalid" ); //$NON-NLS-1$
+            for( int i = 0; i < targets.length; ++i ) {
+                if ( monitor.isCanceled() ) {
+                    throw new OperationCanceledException();
+                }
+                Target target = (Target)targets[i];
+                MISession miSession = target.getMISession();
+                CommandFactory factory = miSession.getCommandFactory();
+                MIGDBSet setRemoteBaud = factory.createMIGDBSet( new String[]{ "remotebaud", remoteBaud } ); //$NON-NLS-1$
+                // Set serial line parameters
+                MIInfo info = null;
+                MIException ex = null;
+                try {
+                    // shouldn't we use the command timeout instead?
+                    miSession.postCommand( setRemoteBaud, launchTimeout );
+                    info = setRemoteBaud.getMIInfo();
+                }
+                catch( MIException e ) {
+                    ex = e;
+                }
+                if ( info == null ) {
+                    throw newCoreException( MIPlugin.getResourceString( "src.GDBServerDebugger.Can_not_set_Baud" ), ex ); //$NON-NLS-1$
+                }
+            }       
+        }
+        for( int i = 0; i < targets.length; ++i ) {
+            if ( monitor.isCanceled() ) {
+                throw new OperationCanceledException();
+            }
+            Target target = (Target)targets[i];
+            MISession miSession = target.getMISession();
+            CommandFactory factory = miSession.getCommandFactory();
+            String[] targetParams = getTargetParams( config, tcpConnection );
+            MITargetSelect select = factory.createMITargetSelect( targetParams );
+            MIInfo info = null;
+            MIException ex = null;
+            try {
+                UserLogger.start(UserInteraction.CATE_PLATFORM_LAUNCH, PlatformUserInteraction.CONNECT_GDBSERVER);
+                miSession.postCommand( select, launchTimeout );
+                UserLogger.end(UserInteraction.CATE_PLATFORM_LAUNCH, PlatformUserInteraction.CONNECT_GDBSERVER);
+                info = select.getMIInfo();
+            }
+            catch( MIException e ) {
+                ex = e;
+            }
+            if ( info == null ) {
+                throw newCoreException( MIPlugin.getResourceString( "src.GDBServerCDIDebugger.target_selection_failed" ), ex ); //$NON-NLS-1$
+            }
+            // @@@ We have to set the suspended state manually
+            miSession.getMIInferior().setSuspended();
+            miSession.getMIInferior().update();
+            miSession.getMIInferior().setIsRemoteInferior(true);
+        }
+    }
 }
index 68821a0..8628c5f 100644 (file)
@@ -53,6 +53,7 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Text;
+import org.tizen.common.util.log.UserLogger;
 import org.tizen.nativeplatform.launch.wizards.PlatformLaunchWizard;
 import org.tizen.nativeplatform.pkg.commander.ICommandStatus;
 import org.tizen.nativeplatform.pkg.commander.IPkgCommander;
@@ -61,6 +62,7 @@ import org.tizen.nativeplatform.pkg.commander.rpm.RpmDebugPackagesResolver;
 import org.tizen.nativeplatform.pkgmgr.PkgMgrInitializer;
 import org.tizen.nativeplatform.pkgmgr.ui.RPMPackageDialog;
 import org.tizen.nativeplatform.util.PlatformLaunchUtil;
+import org.tizen.nativeplatform.util.PlatformUserInteraction;
 import org.tizen.sdblib.service.FileEntry;
 
 public class PlatformLaunchSettingPage extends PlatformLaunchCommonPage {
@@ -166,11 +168,11 @@ public class PlatformLaunchSettingPage extends PlatformLaunchCommonPage {
         spanData.horizontalSpan = 2;
         Label binaryLabel = new Label(composite, SWT.NONE);
         binaryLabel.setText(COMMAND_LABEL_TEXT);        
-        commandText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+        commandText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
         GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
         commandText.setLayoutData(data);
         if (useGuideString) {
-            commandText.setForeground(wizard.getShell().getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));            
+            commandText.setForeground(wizard.getShell().getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
             commandText.addFocusListener(new FocusListener() {
                 @Override
                 public void focusGained(FocusEvent e) {
@@ -190,8 +192,8 @@ public class PlatformLaunchSettingPage extends PlatformLaunchCommonPage {
         commandText.setText(commandInitText);
         commandText.addModifyListener(new ModifyListener() {
             @Override
-            public void modifyText(ModifyEvent e) {                
-                validate();
+            public void modifyText(ModifyEvent e) {
+                validateDebugPackage();
             }
         });
         
@@ -243,6 +245,12 @@ public class PlatformLaunchSettingPage extends PlatformLaunchCommonPage {
             pageNotCompleted(msg);
             return;
         }
+        
+        pageCompleted();
+    }
+    
+    protected void validateDebugPackage() {
+        final String command = commandText.getText().trim();
         if (mode.equals(ILaunchManager.DEBUG_MODE)) {
             final IPkgCommander rootstrapCommander = cmdTarget.getRootstrapCommander();
             if (rootstrapCommander == null) {
@@ -280,7 +288,6 @@ public class PlatformLaunchSettingPage extends PlatformLaunchCommonPage {
                 return;
             }
         }
-        
         pageCompleted();
     }
     
index 78782de..2e5f075 100644 (file)
@@ -256,7 +256,7 @@ public class RpmPackageLauncher implements IPkgLauncher {
         } else {
             UserLogger.start(UserInteraction.CATE_PLATFORM_LAUNCH, PlatformUserInteraction.INIT_ROOTSTRAP_REPO);
             PkgMgrInitializer initializer = new PkgMgrInitializer(target, CmdTargetTypes.ROOTSTRAP);
-            initializer.initRootstrapRepoInfo();
+            initializer.faskInitRootstrapData();            
             UserLogger.end(UserInteraction.CATE_PLATFORM_LAUNCH, PlatformUserInteraction.INIT_ROOTSTRAP_REPO);
         }
         IPkgCommander commander = target.getCommander(CmdTargetTypes.ROOTSTRAP);
@@ -281,10 +281,13 @@ public class RpmPackageLauncher implements IPkgLauncher {
         } else if (!PlatformLaunchUtil.checkDeviceRootOn(target.getDevice())) {
             newInterruptedException(PlatformLaunchMessages.DEVICE_IS_NOT_ROOT_ON);
         } else {
+            // Refreshing repository is needed?
+            /*
             UserLogger.start(UserInteraction.CATE_PLATFORM_LAUNCH, PlatformUserInteraction.INIT_DEVICE_REPO);
             PkgMgrInitializer initializer = new PkgMgrInitializer(target, CmdTargetTypes.DEVICE);
             initializer.initDeviceRepoInfo();
             UserLogger.end(UserInteraction.CATE_PLATFORM_LAUNCH, PlatformUserInteraction.INIT_DEVICE_REPO);
+            */
         }
         IPkgCommander commander = target.getCommander(CmdTargetTypes.DEVICE);
         boolean installResult = false;
@@ -345,14 +348,18 @@ public class RpmPackageLauncher implements IPkgLauncher {
     }
 
     private boolean internalProcessRDS(final IPkgCommander commander, List<IPackage> packages,
-            boolean worksSmack, IProgressMonitor monitor) {    
+            boolean worksSmack, IProgressMonitor monitor) {
+        boolean result = false;
+        UserLogger.start(UserInteraction.CATE_PLATFORM_LAUNCH, PlatformUserInteraction.LAUNCH_RDS);
        if (OSChecker.isWindows()) {
                RemoteRpmRapidDeployer rpmRds = new RemoteRpmRapidDeployer(project, commander, packages);
-               return rpmRds.process();
+               result = rpmRds.process();
        } else {
                RpmRapidDeployer rpmRds = new RpmRapidDeployer(project, commander, packages);
-               return rpmRds.process();
+               result = rpmRds.process();              
        }
+       UserLogger.end(UserInteraction.CATE_PLATFORM_LAUNCH, PlatformUserInteraction.LAUNCH_RDS);
+       return result;
     }
 
     private String newline() {
index e26a36b..6feaca3 100644 (file)
@@ -167,6 +167,26 @@ public class PkgMgrInitializer {
     private boolean isSetDevice() {
         return (device != null) ? true : false;
     }
+    
+    public void faskInitRootstrapData() {
+        List<Repository> sourceList = rootstrap.getRepoList();
+        List<Repository> targetList = target.getCommander(CmdTargetTypes.ROOTSTRAP)
+                .getRepoList();
+        boolean needReset = true;
+        if (sourceList.size() == targetList.size()) {
+            for (Repository repo : targetList) {
+                String url = repo.getUri();
+                if (!rootstrap.containRepository(url)) {
+                    needReset = true;
+                    break;
+                } else {
+                    needReset = false;
+                }
+            }
+        }
+        initRootstrapRepoInfo(needReset);
+        initRootstrapPkgInfo();
+    }
 
     public void fastInitData(IProgressMonitor monitor) throws InterruptedException {
         if (isSetRootstrap()) {
index b17eb9a..f307975 100644 (file)
@@ -8,8 +8,10 @@ import java.util.Map.Entry;
 
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.ptp.remotetools.core.IRemoteCopyTools;
+import org.eclipse.ptp.remotetools.core.IRemoteFileTools;
 import org.eclipse.ptp.remotetools.exception.CancelException;
 import org.eclipse.ptp.remotetools.exception.RemoteConnectionException;
 import org.eclipse.ptp.remotetools.exception.RemoteOperationException;
@@ -23,7 +25,9 @@ import org.tizen.nativeplatform.command.launcher.RemoteCommandUtil;
 import org.tizen.nativeplatform.launch.PlatformLaunchMessages;
 import org.tizen.nativeplatform.pkg.commander.ICommandStatus;
 import org.tizen.nativeplatform.pkg.commander.IPkgCommander;
+import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
 import org.tizen.nativeplatform.pkg.model.IPackage;
+import org.tizen.nativeplatform.pkg.model.Package;
 import org.tizen.nativeplatform.remote.connection.RemoteConnectionManager;
 import org.tizen.nativeplatform.types.CmdTargetTypes;
 import org.tizen.nativeplatform.util.RootstrapUtil;
@@ -31,23 +35,24 @@ import org.tizen.nativeplatform.util.RootstrapUtil;
 public class RemoteRpmRapidDeployer {
     private IProject project;
     private IPkgCommander commander;
-    private List<IPackage> packages;
+    private List<IPackage> packages = new ArrayList<IPackage>();
     private CmdTargetTypes cmdType;
     private final Logger logger = LoggerFactory.getLogger(RemoteRpmRapidDeployer.class);
 
-    public RemoteRpmRapidDeployer(IProject project, IPkgCommander commander, List<IPackage> packages) {
+    public RemoteRpmRapidDeployer(IProject project, IPkgCommander commander, List<IPackage> pkgs) {
         this.project = project;
         this.commander = commander;
-        for (IPackage pkg : packages) {
+        for (IPackage pkg : pkgs) {
                String path = pkg.getPath();
                String[] segments = new Path(path).segments();
                String configNamae = segments[segments.length - 2];
                String fileNamae = segments[segments.length - 1];
                String remoteWorkspacePath = RootstrapUtil.getUserSyncWorkspacePath(project.getName());
-               String remotePkgPath = new Path(remoteWorkspacePath).append(configNamae).append(fileNamae).toString();
-               pkg.setPath(remotePkgPath);
+               String remotePkgPath = new Path(remoteWorkspacePath).append(configNamae).append(fileNamae).toString();          
+               IPackage newPkg = pkg.clonePkg();
+               newPkg.setPath(remotePkgPath);
+               packages.add(newPkg);
         }
-        this.packages = packages;
         this.cmdType = commander.getCommandType();
     }
 
@@ -86,6 +91,7 @@ public class RemoteRpmRapidDeployer {
         List<String> addList = new ArrayList<String>();
         List<String> remainList = new ArrayList<String>();
         List<String> removeList = new ArrayList<String>();
+        System.out.print(true);
         String copyFileList = groupFiles(sourceChecksums, targetChecksums, copyList, addList,
                 remainList, removeList);
         if (isDeviceCommander()) {
@@ -124,56 +130,67 @@ public class RemoteRpmRapidDeployer {
             }
         }
         return true;
-    }  
+    }
 
     private boolean processCopiedFiles(List<String> fileList) {
-       String cachingDir = LocalCommandUtil.getCachingDir(project);
-       IRemoteCopyTools copytool = RemoteConnectionManager.getRemoteTools().getCopyTool();
-        for (final String file : fileList) {
-               String remoteFilepath = new Path(RemoteCommandUtil.getCachingDir(project)).append(file).toString();
-               String filename = FilenameUtil.getFilename(file);
-               String srcPath = new Path(cachingDir).append(filename).toOSString();
-               try {
-                               copytool.downloadFileToFile(remoteFilepath, srcPath);
-                       } catch (Exception e) {
-                               e.printStackTrace();
-                       }
-            String targetFilePath = new Path(file).removeFirstSegments(1).toString();
-            ICommandStatus status = commander.copyFile(srcPath, targetFilePath);
-            if (status == null || !status.isOk()) {
-                logger.error(String.format("Failed to copy files [%s]", srcPath));
-                return false;
+        if (isDeviceCommander()) {
+               String cachingDir = LocalCommandUtil.getCachingDir(project);
+               IRemoteCopyTools copytool = RemoteConnectionManager.getRemoteTools().getCopyTool(); 
+            for (final String file : fileList) {
+               String remoteFilepath = new Path(RemoteCommandUtil.getCachingDir(project)).append(file).toString();
+               String filename = FilenameUtil.getFilename(file);
+               String srcPath = new Path(cachingDir).append(filename).toOSString();
+               try {
+                   copytool.downloadFileToFile(remoteFilepath, srcPath);
+                       } catch (Exception e) {
+                               e.printStackTrace();
+                       }
+                String targetFilePath = new Path(file).removeFirstSegments(1).toString();
+                ICommandStatus status = commander.copyFile(srcPath, targetFilePath);
+                if (status == null || !status.isOk()) {
+                    logger.error(String.format("Failed to copy files [%s]", srcPath));
+                    return false;
+                }
+            }
+        } else if (isRootstrapCommander()) {
+            for (final String file : fileList) {
+                String remoteFilePath = new Path(RemoteCommandUtil.getCachingDir(project)).append(file).toString();
+                String filePath = new Path(file).removeFirstSegments(1).toString();                
+                commander.copyFile(remoteFilePath, filePath);
             }
         }
         return true;
     }
 
     private boolean processAddedFiles(List<String> fileList, Map<String, String[]> smackInfo) {
-        for (String file : fileList) {
-            IPath filePath = new Path(file);
-            String targetFilePath = filePath.removeFirstSegments(1).toOSString();
-            String targetPath = filePath.removeFirstSegments(1).removeLastSegments(1).toOSString();
-            String srcFilePath = new Path(CommandUtil.getCachingDir(project)).append(file)
-                    .toOSString();
-            ICommandStatus status = commander.makeDir(targetPath);
-            if (status == null || !status.isOk()) {
-                logger.error(String.format("Failed to make directory [%s]", targetPath));
-                return false;
-            }
-            status = commander.copyFile(srcFilePath, targetFilePath);
-            if (status == null || !status.isOk()) {
-                logger.error(String.format("Failed to copy files [%s]", srcFilePath));
-                return false;
-            }
-            if (smackInfo != null && isDeviceCommander()) {
-                String[] labels = { "_", "_" };
-                smackInfo.put(targetFilePath, labels);
+        if (isDeviceCommander()) {
+                // RDS can not add files to device because of setting smack information.
+                // How set smack information for a new file ?
+        } else if (isRootstrapCommander()) {
+            for (String file : fileList) {
+                IPath filePath = new Path(file);
+                String targetFilePath = filePath.removeFirstSegments(1).toString();
+                String targetPath = filePath.removeFirstSegments(1).removeLastSegments(1).toString();
+                String srcFilePath = new Path(RemoteCommandUtil.getCachingDir(project)).append(file).toString();
+                ICommandStatus status = commander.makeDir(targetPath);
+                if (status == null || !status.isOk()) {
+                    logger.error(String.format("Failed to make directory [%s]", targetPath));
+                    return false;
+                }
+                status = commander.copyFile(srcFilePath, targetFilePath);
+                if (status == null || !status.isOk()) {
+                    logger.error(String.format("Failed to copy files [%s]", srcFilePath));
+                    return false;
+                }
             }
         }
         return true;
     }
 
     private boolean processRemovedFiles(List<String> fileList) {
+        // Nothing will be removed because source files should be in target
+        // FIXME:
+        /*
         for (String file : fileList) {
             ICommandStatus status = commander.removeFile(file);
             if (status == null || !status.isOk()) {
@@ -181,12 +198,17 @@ public class RemoteRpmRapidDeployer {
                 return false;
             }
         }
+        */
         return true;
     }
 
     private boolean isDeviceCommander() {
         return (cmdType == CmdTargetTypes.DEVICE);
     }
+    
+    private boolean isRootstrapCommander() {
+        return (cmdType == CmdTargetTypes.ROOTSTRAP);
+    }
 
     // Maintain smack information of copied file same as before.
     private boolean applySmack(Map<String, String[]> smackInfo) {
@@ -194,7 +216,7 @@ public class RemoteRpmRapidDeployer {
             try {
                 // Sleep guarantee changing of smack information.
                 // "chsmack" command after pushing file is not completed.
-                Thread.sleep(100);
+                Thread.sleep(1000);
             } catch (InterruptedException e) {
                 e.printStackTrace();
                 return false;
index e3d22ad..38fce16 100644 (file)
@@ -15,4 +15,9 @@ public class PlatformUserInteraction {
     public static final String INSTALL_DEVICE = "install.device";\r
     public static final String INIT_DEVICE_REPO = "init.device.repo";\r
     public static final String INIT_ROOTSTRAP_REPO = "init.rootstrap.repo";\r
+    public static final String LAUNCH_RDS = "launch.rds";\r
+    public static final String START_GDBSERVER = "start.gdbserver";\r
+    public static final String START_GDB = "start.gdb";\r
+    public static final String START_GDB_SESSION = "start.gdb.session";\r
+    public static final String CONNECT_GDBSERVER = "connect.gdb";\r
 }\r