Exemplo n.º 1
0
        public void IsPlaceholderModule()
        {
            var placeholderModule = CreatePlaceholderModule();

            Assert.True(moduleUtil.IsPlaceholderModule(placeholderModule));
            Assert.False(moduleUtil.HasBinaryLoaded(placeholderModule));
        }
Exemplo n.º 2
0
        public void SetUp()
        {
            searchLog = new StringWriter();

            mockTarget            = Substitute.For <RemoteTarget>();
            moduleReplacedHandler = Substitute.For <EventHandler <LldbModuleReplacedEventArgs> >();

            mockModuleFileFinder = Substitute.For <IModuleFileFinder>();
            mockModuleFileFinder.FindFileAsync(BINARY_FILENAME, UUID, false, searchLog)
            .Returns(Task.FromResult(PATH_IN_STORE));

            placeholderModule = Substitute.For <SbModule>();
            placeholderModule.GetPlatformFileSpec().GetFilename().Returns(BINARY_FILENAME);
            placeholderModule.GetUUIDString().Returns(UUID.ToString());

            placeholderProperties =
                new PlaceholderModuleProperties(MODULE_SLIDE, Substitute.For <SbFileSpec>());

            mockModuleUtil = Substitute.For <ILldbModuleUtil>();
            mockModuleUtil.IsPlaceholderModule(placeholderModule).Returns(true);
            mockModuleUtil.GetPlaceholderProperties(Arg.Any <SbModule>(), Arg.Any <RemoteTarget>())
            .ReturnsForAnyArgs(placeholderProperties);
            mockModuleUtil.ApplyPlaceholderProperties(
                Arg.Any <SbModule>(), Arg.Any <PlaceholderModuleProperties>(),
                Arg.Any <RemoteTarget>())
            .ReturnsForAnyArgs(true);


            binaryLoader = new BinaryLoader(mockModuleUtil, mockModuleFileFinder,
                                            mockTarget);
            binaryLoader.LldbModuleReplaced += moduleReplacedHandler;
        }
Exemplo n.º 3
0
        public virtual async Task <(SbModule, bool)> LoadBinaryAsync(
            SbModule lldbModule, TextWriter searchLog)
        {
            if (lldbModule == null)
            {
                throw new ArgumentNullException(nameof(lldbModule));
            }
            searchLog = searchLog ?? TextWriter.Null;

            if (!moduleUtil.IsPlaceholderModule(lldbModule))
            {
                return(lldbModule, true);
            }

            var binaryName = lldbModule.GetPlatformFileSpec()?.GetFilename();

            if (string.IsNullOrEmpty(binaryName))
            {
                await searchLog.WriteLineAsync(ErrorStrings.BinaryFileNameUnknown);

                Trace.WriteLine(ErrorStrings.BinaryFileNameUnknown);
                return(lldbModule, false);
            }

            var binaryPath = await moduleFileFinder.FindFileAsync(
                binaryName, new BuildId(lldbModule.GetUUIDString()), false, searchLog);

            if (binaryPath == null)
            {
                return(lldbModule, false);
            }

            PlaceholderModuleProperties properties =
                moduleUtil.GetPlaceholderProperties(lldbModule, lldbTarget);

            if (properties == null)
            {
                return(lldbModule, false);
            }
            RemoveModule(lldbModule);

            var newModule = AddModule(binaryPath, lldbModule.GetUUIDString(), searchLog);

            if (newModule == null)
            {
                return(lldbModule, false);
            }

            if (!moduleUtil.ApplyPlaceholderProperties(newModule, properties, lldbTarget))
            {
                return(lldbModule, false);
            }

            LldbModuleReplaced?.Invoke(Self,
                                       new LldbModuleReplacedEventArgs(newModule, lldbModule));

            return(newModule, true);
        }
Exemplo n.º 4
0
        public async Task LoadBinary_AlreadyLoadedAsync()
        {
            var loadedModule = Substitute.For <SbModule>();

            mockModuleUtil.IsPlaceholderModule(loadedModule).Returns(false);

            var  module = loadedModule;
            bool ok;

            (module, ok) = await binaryLoader.LoadBinaryAsync(module, searchLog);

            Assert.True(ok);

            Assert.AreSame(loadedModule, module);
        }