From: Greg Clayton Date: Wed, 28 Jan 2015 22:08:17 +0000 (+0000) Subject: Fixed the failing test: X-Git-Tag: llvmorg-3.7.0-rc1~13797 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d26a1e5060dcf92c8508651526381a7309ab750d;p=platform%2Fupstream%2Fllvm.git 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). llvm-svn: 227380 --- diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 30eecbf..9188283 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -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()); diff --git a/lldb/source/Target/TargetList.cpp b/lldb/source/Target/TargetList.cpp index 1e06341..bbed0fb 100644 --- a/lldb/source/Target/TargetList.cpp +++ b/lldb/source/Target/TargetList.cpp @@ -98,12 +98,12 @@ TargetList::CreateTarget (Debugger &debugger, 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 &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__, diff --git a/lldb/test/functionalities/object-file/TestImageListMultiArchitecture.py b/lldb/test/functionalities/object-file/TestImageListMultiArchitecture.py index 0c4b614..aa1a6f0 100644 --- a/lldb/test/functionalities/object-file/TestImageListMultiArchitecture.py +++ b/lldb/test/functionalities/object-file/TestImageListMultiArchitecture.py @@ -22,13 +22,13 @@ class TestImageListMultiArchitecture(TestBase): 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: