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
This commit is contained in:
Greg Clayton 2015-01-28 22:08:17 +00:00
parent 4379d10273
commit d26a1e5060
3 changed files with 85 additions and 72 deletions

View File

@ -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)
{
// I have a remote file.. two possible cases
if (file_spec && file_spec.Exists())
{
// 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())
{
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;
}
}
}
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,
arch_cstr,
get_dependent_files,
platform_sp,
NULL,
target_sp));
if (target_sp)
{
// 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 (platform_sp)
{
// I have a remote file.. two possible cases
if (file_spec && file_spec.Exists())
{
// 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())
{
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
{
result.AppendError("no platform found for target");
result.SetStatus (eReturnStatusFailed);
return false;
}
}
if (symfile || remote_file)
{
ModuleSP module_sp (target_sp->GetExecutableModule());

View File

@ -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__,

View File

@ -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: