示例#1
0
        public PlaceholderModuleProperties GetPlaceholderProperties(SbModule placeholderModule,
                                                                    RemoteTarget lldbTarget)
        {
            SbSection placeholderSection = placeholderModule.FindSection(".module_image");

            if (placeholderSection == null)
            {
                // Could be either an RPC error or a usage error. Hmm...
                throw new ArgumentException(
                          "Placeholder properties can only be copied from placeholder modules.");
            }

            // The load address of the placeholder section represents the base load address of the
            // module as a whole in the original process.
            ulong placeholderBaseLoadAddress = placeholderSection.GetLoadAddress(lldbTarget);

            if (placeholderBaseLoadAddress == DebuggerConstants.INVALID_ADDRESS)
            {
                Trace.WriteLine("Failed to get load address from the placeholder section.");
                return(null);
            }

            // |slide| is how much we need to offset the module's load address by
            long slide = (long)placeholderBaseLoadAddress;

            SbFileSpec fileSpec = placeholderModule.GetPlatformFileSpec();

            if (fileSpec == null)
            {
                Trace.WriteLine("Failed to get file spec from placeholder module.");
                return(null);
            }
            return(new PlaceholderModuleProperties(slide, fileSpec));
        }
示例#2
0
        public void GetPlaceholderProperties_NotPlaceholder()
        {
            mockModule.FindSection(".module_image").Returns((SbSection)null);

            Assert.Throws <ArgumentException>(() =>
                                              moduleUtil.GetPlaceholderProperties(mockModule, mockTarget));
        }
示例#3
0
        public void GetPlaceholderProperties_GetLoadAddressFails()
        {
            SbModule placeholderModule = CreatePlaceholderModule();

            placeholderModule.FindSection(".module_image")
            .GetLoadAddress(mockTarget).Returns(DebuggerConstants.INVALID_ADDRESS);

            Assert.IsNull(moduleUtil.GetPlaceholderProperties(placeholderModule, mockTarget));

            var output = logSpy.GetOutput();

            Assert.That(output, Does.Contain("Failed to get load address"));
        }
示例#4
0
        public void SetUp()
        {
            logSpy = new LogSpy();
            logSpy.Attach();

            var noError = new SbErrorStub(true, null);

            mockTarget = Substitute.For <RemoteTarget>();
            mockTarget.SetModuleLoadAddress(Arg.Any <SbModule>(), Arg.Any <long>()).Returns(noError);
            mockModule = Substitute.For <SbModule>();
            mockModule.HasCompileUnits().Returns(false);
            mockModule.FindSection(Arg.Any <string>()).Returns((SbSection)null);
            mockPlatformFileSpec = Substitute.For <SbFileSpec>();
            moduleUtil           = new LldbModuleUtil();
        }
示例#5
0
 public bool IsPlaceholderModule(SbModule module) => module.GetNumSections() == 1 &&
 module.FindSection(".module_image") != null;