[Lldb-commits] [lldb] r227380 - Fixed the failing test:

Greg Clayton gclayton at apple.com
Wed Jan 28 14:08:18 PST 2015


Author: gclayton
Date: Wed Jan 28 16:08:17 2015
New Revision: 227380

URL: http://llvm.org/viewvc/llvm-project?rev=227380&view=rev
Log:
Fixed the failing test:

./dotest.py -A x86_64 -C clang -v -t  -f TestImageListMultiArchitecture.test_image_list_shows_multiple_architectures

The problem was that if the platform wasn't compatible with the current file in the "target create" command, it wasn't finding a platform that was like it used to.

Also, the currently selected platform was being used upload the file _before_ the target was created which was incorrect as "target create a.out" might switch platforms if its architecture doesn't match, so I moved the uploading to happen after the target was created so we use the right platform (the one in the target, not the selected one).


Modified:
    lldb/trunk/source/Commands/CommandObjectTarget.cpp
    lldb/trunk/source/Target/TargetList.cpp
    lldb/trunk/test/functionalities/object-file/TestImageListMultiArchitecture.py

Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=227380&r1=227379&r2=227380&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Wed Jan 28 16:08:17 2015
@@ -281,70 +281,83 @@ protected:
             bool must_set_platform_path = false;
 
             Debugger &debugger = m_interpreter.GetDebugger();
-            PlatformSP platform_sp(debugger.GetPlatformList().GetSelectedPlatform ());
 
-            if (remote_file)
+            TargetSP target_sp;
+            const char *arch_cstr = m_arch_option.GetArchitectureName();
+            const bool get_dependent_files = m_add_dependents.GetOptionValue().GetCurrentValue();
+            Error error (debugger.GetTargetList().CreateTarget (debugger,
+                                                                file_path,
+                                                                arch_cstr,
+                                                                get_dependent_files,
+                                                                NULL,
+                                                                target_sp));
+
+            if (target_sp)
             {
-                // I have a remote file.. two possible cases
-                if (file_spec && file_spec.Exists())
+                // Only get the platform after we create the target because we might have
+                // switched platforms depending on what the arguments were to CreateTarget()
+                // we can't rely on the selected platform.
+
+                PlatformSP platform_sp = target_sp->GetPlatform();
+
+                if (remote_file)
                 {
-                    // if the remote file does not exist, push it there
-                    if (!platform_sp->GetFileExists (remote_file))
+                    if (platform_sp)
                     {
-                        Error err = platform_sp->PutFile(file_spec, remote_file);
-                        if (err.Fail())
+                        // I have a remote file.. two possible cases
+                        if (file_spec && file_spec.Exists())
                         {
-                            result.AppendError(err.AsCString());
-                            result.SetStatus (eReturnStatusFailed);
-                            return false;
+                            // if the remote file does not exist, push it there
+                            if (!platform_sp->GetFileExists (remote_file))
+                            {
+                                Error err = platform_sp->PutFile(file_spec, remote_file);
+                                if (err.Fail())
+                                {
+                                    result.AppendError(err.AsCString());
+                                    result.SetStatus (eReturnStatusFailed);
+                                    return false;
+                                }
+                            }
                         }
-                    }
-                }
-                else
-                {
-                    // there is no local file and we need one
-                    // in order to make the remote ---> local transfer we need a platform
-                    // TODO: if the user has passed in a --platform argument, use it to fetch the right platform
-                    if (!platform_sp)
-                    {
-                        result.AppendError("unable to perform remote debugging without a platform");
-                        result.SetStatus (eReturnStatusFailed);
-                        return false;
-                    }
-                    if (file_path)
-                    {
-                        // copy the remote file to the local file
-                        Error err = platform_sp->GetFile(remote_file, file_spec);
-                        if (err.Fail())
+                        else
                         {
-                            result.AppendError(err.AsCString());
-                            result.SetStatus (eReturnStatusFailed);
-                            return false;
+                            // there is no local file and we need one
+                            // in order to make the remote ---> local transfer we need a platform
+                            // TODO: if the user has passed in a --platform argument, use it to fetch the right platform
+                            if (!platform_sp)
+                            {
+                                result.AppendError("unable to perform remote debugging without a platform");
+                                result.SetStatus (eReturnStatusFailed);
+                                return false;
+                            }
+                            if (file_path)
+                            {
+                                // copy the remote file to the local file
+                                Error err = platform_sp->GetFile(remote_file, file_spec);
+                                if (err.Fail())
+                                {
+                                    result.AppendError(err.AsCString());
+                                    result.SetStatus (eReturnStatusFailed);
+                                    return false;
+                                }
+                            }
+                            else
+                            {
+                                // make up a local file
+                                result.AppendError("remote --> local transfer without local path is not implemented yet");
+                                result.SetStatus (eReturnStatusFailed);
+                                return false;
+                            }
                         }
                     }
                     else
                     {
-                        // make up a local file
-                        result.AppendError("remote --> local transfer without local path is not implemented yet");
+                        result.AppendError("no platform found for target");
                         result.SetStatus (eReturnStatusFailed);
                         return false;
                     }
                 }
-            }
-
-            TargetSP target_sp;
-            const char *arch_cstr = m_arch_option.GetArchitectureName();
-            ArchSpec arch_spec(arch_cstr);
-            const bool get_dependent_files = m_add_dependents.GetOptionValue().GetCurrentValue();
-            Error error (debugger.GetTargetList().CreateTarget (debugger,
-                                                                file_path,
-                                                                arch_spec,
-                                                                get_dependent_files,
-                                                                platform_sp,
-                                                                target_sp));
 
-            if (target_sp)
-            {
                 if (symfile || remote_file)
                 {
                     ModuleSP module_sp (target_sp->GetExecutableModule());

Modified: lldb/trunk/source/Target/TargetList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/TargetList.cpp?rev=227380&r1=227379&r2=227380&view=diff
==============================================================================
--- lldb/trunk/source/Target/TargetList.cpp (original)
+++ lldb/trunk/source/Target/TargetList.cpp Wed Jan 28 16:08:17 2015
@@ -98,12 +98,12 @@ TargetList::CreateTarget (Debugger &debu
 
 Error
 TargetList::CreateTargetInternal (Debugger &debugger,
-                          const char *user_exe_path,
-                          const char *triple_cstr,
-                          bool get_dependent_files,
-                          const OptionGroupPlatform *platform_options,
-                          TargetSP &target_sp,
-                          bool is_dummy_target)
+                                  const char *user_exe_path,
+                                  const char *triple_cstr,
+                                  bool get_dependent_files,
+                                  const OptionGroupPlatform *platform_options,
+                                  TargetSP &target_sp,
+                                  bool is_dummy_target)
 {
     Error error;
     PlatformSP platform_sp;
@@ -369,12 +369,12 @@ TargetList::CreateDummyTarget (Debugger
 
 Error
 TargetList::CreateTargetInternal (Debugger &debugger,
-                      const char *user_exe_path,
-                      const ArchSpec& specified_arch,
-                      bool get_dependent_files,
-                      lldb::PlatformSP &platform_sp,
-                      lldb::TargetSP &target_sp,
-                      bool is_dummy_target)
+                                  const char *user_exe_path,
+                                  const ArchSpec& specified_arch,
+                                  bool get_dependent_files,
+                                  lldb::PlatformSP &platform_sp,
+                                  lldb::TargetSP &target_sp,
+                                  bool is_dummy_target)
 {
 
     Timer scoped_timer (__PRETTY_FUNCTION__,

Modified: lldb/trunk/test/functionalities/object-file/TestImageListMultiArchitecture.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/object-file/TestImageListMultiArchitecture.py?rev=227380&r1=227379&r2=227380&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/object-file/TestImageListMultiArchitecture.py (original)
+++ lldb/trunk/test/functionalities/object-file/TestImageListMultiArchitecture.py Wed Jan 28 16:08:17 2015
@@ -22,13 +22,13 @@ class TestImageListMultiArchitecture(Tes
     def test_image_list_shows_multiple_architectures(self):
         """Test that image list properly shows the correct architecture for a set of different architecture object files."""
         images = {
-            "hello-freebsd-10.0-x86_64-clang-3.3": re.compile(r"x86_64-(unknown)?-freebsd10.0 x86_64"),
-            "hello-freebsd-10.0-x86_64-gcc-4.7.3": re.compile(r"x86_64-(unknown)?-freebsd10.0 x86_64"),
-            "hello-netbsd-6.1-x86_64-gcc-4.5.3": re.compile(r"x86_64-(unknown)?-netbsd x86_64"),
-            "hello-ubuntu-14.04-x86_64-gcc-4.8.2": re.compile(r"x86_64-(unknown)?-linux x86_64"),
-            "hello-ubuntu-14.04-x86_64-clang-3.5pre": re.compile(r"x86_64-(unknown)?-linux x86_64"),
-            "hello-unknown-kalimba_arch4-kcc-36": re.compile(r"kalimba4-csr-unknown kalimba"),
-            "hello-unknown-kalimba_arch5-kcc-39": re.compile(r"kalimba5-csr-unknown kalimba"),
+            "hello-freebsd-10.0-x86_64-clang-3.3": re.compile(r"x86_64-(unknown)?-freebsd10.0(-unknown)? x86_64"),
+            "hello-freebsd-10.0-x86_64-gcc-4.7.3": re.compile(r"x86_64-(unknown)?-freebsd10.0(-unknown)? x86_64"),
+            "hello-netbsd-6.1-x86_64-gcc-4.5.3": re.compile(r"x86_64-(unknown)?-netbsd(-unknown)? x86_64"),
+            "hello-ubuntu-14.04-x86_64-gcc-4.8.2": re.compile(r"x86_64-(unknown)?-linux(-unknown)? x86_64"),
+            "hello-ubuntu-14.04-x86_64-clang-3.5pre": re.compile(r"x86_64-(unknown)?-linux(-unknown)? x86_64"),
+            "hello-unknown-kalimba_arch4-kcc-36": re.compile(r"kalimba4-csr-unknown(-unknown)? kalimba"),
+            "hello-unknown-kalimba_arch5-kcc-39": re.compile(r"kalimba5-csr-unknown(-unknown)? kalimba"),
         }
 
         for image_name in images:





More information about the lldb-commits mailing list