Correct errors 02/18702/1
authorseokgil.kang <seokgil.kang@samsung.com>
Fri, 28 Mar 2014 08:37:10 +0000 (17:37 +0900)
committerseokgil.kang <seokgil.kang@samsung.com>
Fri, 28 Mar 2014 08:37:10 +0000 (17:37 +0900)
Comment the meaningless codes.
Add the logic of null check to a variable.
Resolve the unboxing case of Boolean object.
Resolve the issue to start a thread in the constructor.

Change-Id: I880016783307240fac0ed7d8cf1195125d4ba18b
Signed-off-by: seokgil.kang <seokgil.kang@samsung.com>
org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/Oprofile.java
org.eclipse.linuxtools.oprofile.launch.exe/src/org/tizen/oprofile/launch/TizenOprofileLaunchDelegate.java
org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/oprofile/launch/configuration/EventConfigCache.java
org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchShortcut.java
org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/ValgrindDebugPlugin.java
org.eclipse.linuxtools.valgrind.launch.exe/src/org/eclipse/linuxtools/valgrind/launch/ValgrindRuntimeProcess.java

index d140eac..757fe29 100644 (file)
@@ -254,7 +254,14 @@ public abstract class Oprofile
         * @param um    the unit mask
         * @return whether the requested event is valid
         */
-       public static Boolean checkEvent(int ctr, int event, int um) {
+       // seokgil.kang modified at 20140326
+       // occurred NPE(NullPointException) for Boolean object unboxing  
+       // return value
+       //      1 : true 
+       //      0 : false 
+       //      -1 : error
+//     public static Boolean checkEvent(int ctr, int event, int um) {
+       public static int checkEvent(int ctr, int event, int um) {
                int[] validResult = new int[1];
                try {
                        IRunnableWithProgress opxml = OprofileCorePlugin.getDefault().getOpxmlProvider().checkEvents(ctr, event, um, validResult);
@@ -301,10 +308,16 @@ public abstract class Oprofile
                        e.printStackTrace();
                } catch (OpxmlException e) {
                        OprofileCorePlugin.showErrorDialog("opxmlProvider", e); //$NON-NLS-1$
-                       return (Boolean)null;
+//                     return (Boolean)null;
+                       return -1;
                }
                
-               return (validResult[0] == CheckEventsProcessor.EVENT_OK);
+//             return (validResult[0] == CheckEventsProcessor.EVENT_OK);
+               if (validResult[0] == CheckEventsProcessor.EVENT_OK) {
+                       return 1;
+               } else {
+                       return 0;
+               }
        }
        
        
index 6b347de..417a7b9 100644 (file)
@@ -276,21 +276,25 @@ public class TizenOprofileLaunchDelegate extends TizenLaunchDelegate {
                        exeFile = CDebugUtils.verifyProgramPath(config);
                        DebugPlugin.newProcess(launch, oprofileProc, exeFile
                                        .toFile().getName());
-                       BufferedReader br = new BufferedReader(new InputStreamReader(
-                                       oprofileProc.getInputStream(), Charset.forName("UTF-8")));
-                       if (null != br) {
-                               while (null != br.readLine()) {
-                                       ;
-                               }
-                               br.close();                             
-                       }
+                       // seokgil.kang modified at 20140328
+                       // meaningful process ??
+//                     BufferedReader br = new BufferedReader(new InputStreamReader(
+//                                     oprofileProc.getInputStream(), Charset.forName("UTF-8")));
+//                     if (null != br) {
+//                             while (null != br.readLine()) {
+//                                     ;
+//                             }
+//                             br.close();                             
+//                     }
                } catch (CoreException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
-               } catch (IOException e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
-               }
+               } 
+               // seokgil.kang modified at 20140328
+//             catch (IOException e) {
+//                     // TODO Auto-generated catch block
+//                     e.printStackTrace();
+//             }
 
        }
 
index fa38554..2538fcd 100644 (file)
@@ -70,23 +70,50 @@ public class EventConfigCache {
         * @param mask unit mask value
         * @return true or false, depending if the event config is valid
         */
+       // seokgil.kang modified at 20140328
        public boolean checkEvent(int counter, int event, int mask) {
                CheckEventEntry e = new CheckEventEntry(counter, event, mask);
+//             Boolean result = null;
+//             
+//             result = validEventCache.get(e);
+//             
+//             if (result == null) {
+//                     //not in the map, get its value and add it in
+//                     result = Oprofile.checkEvent(counter, event, mask);
+//                     
+//                     //possible to be null if there is no opxmlProvider
+//                     if (result != null) {
+//                             validEventCache.put(e, result);
+//                     }
+//             }
+//
+//             return (result == null ? false : result);
+               
                Boolean result = null;
+               int res = 0;
                
                result = validEventCache.get(e);
                
                if (result == null) {
                        //not in the map, get its value and add it in
-                       result = Oprofile.checkEvent(counter, event, mask);
+                       res = Oprofile.checkEvent(counter, event, mask);
                        
-                       //possible to be null if there is no opxmlProvider
-                       if (result != null) {
+                       //possible to be -1 if there is no opxmlProvider
+                       if (res != -1) {
                                validEventCache.put(e, result);
                        }
                }
 
-               return (result == null ? false : result);
+               if (result == null) {
+                       if (res == -1) {
+                               return false;
+                       } else if (res == 1) {
+                               return true;
+                       } else {
+                               return false;
+                       }
+               } else {
+                       return result;
+               }
        }
-       
 }
index dfae9bc..73cf891 100644 (file)
@@ -154,12 +154,14 @@ public static void showErrorDialog(final String errorMessage, final String reaso
                                String device_id = LaunchUtils.getDeviceId(device);
                                IPath programPath = AbstractCLaunchDelegate.getProgramPath(config);
                                String projectName = AbstractCLaunchDelegate.getProjectName(config);
-                               IPath binPath = bin.getResource().getProjectRelativePath();
-                               if (programPath != null && programPath.equals(binPath)) {
-                                       if (projectName != null && projectName.equals(bin.getCProject().getProject().getName())
-                                                                       && config_device_id.equals(device_id))
-                                       {
-                                               candidateConfigs.add(config);
+                               if (bin != null) {
+                                       IPath binPath = bin.getResource().getProjectRelativePath();
+                                       if (programPath != null && programPath.equals(binPath)) {
+                                               if (projectName != null && projectName.equals(bin.getCProject().getProject().getName())
+                                                                               && config_device_id.equals(device_id))
+                                               {
+                                                       candidateConfigs.add(config);
+                                               }
                                        }
                                }
                        }
index 32c4785..aeb7621 100644 (file)
@@ -821,7 +821,11 @@ public class ValgrindDebugPlugin extends Plugin {
                        return processFactory
                                        .newProcess(launch, process, label, attributes);
                }
-               return new ValgrindRuntimeProcess(launch, process, label, attributes);
+               // seokgil.kang modified at 20140328
+//             return new ValgrindRuntimeProcess(launch, process, label, attributes);
+               ValgrindRuntimeProcess valgrindRuntimeProc = new ValgrindRuntimeProcess(launch, process, label, attributes);
+               valgrindRuntimeProc.startProcessMonitorThread();
+               return valgrindRuntimeProc;
        }
 
        /**
index f8c1ea2..50fd811 100644 (file)
@@ -136,7 +136,8 @@ public class ValgrindRuntimeProcess extends PlatformObject implements IProcess {
 
                fStreamsProxy = createStreamsProxy();
                fMonitor = new ProcessMonitorThread(this);
-               fMonitor.start();
+               // seokgil.kang modified at 20140328
+//             fMonitor.start();
                launch.addProcess(this);
                fireCreationEvent();
        }
@@ -388,6 +389,15 @@ public class ValgrindRuntimeProcess extends PlatformObject implements IProcess {
                                                DebugCoreMessages.RuntimeProcess_Exit_value_not_available_until_process_terminates__1,
                                                null));
        }
+       
+       // seokgil.kang modified at 20140328
+       /**
+        * Start ProcessMonitorThread
+        */
+       public void startProcessMonitorThread() {
+               if (fMonitor != null)
+                       fMonitor.start();
+       }
 
        /**
         * Monitors a system process, waiting for it to terminate, and then notifies