A module is either a shared library (containing unmanaged code) or a dll (containing managed code). A module maintains all the breakpoints and controls whether to enter methods while single-stepping.
Inheritance: ModuleBase
Beispiel #1
0
        public SourceFile(DebuggerSession session, Module module, string name)
        {
            this.id = ++next_id;
            this.module = module;

            if ((name == "") || (name == null)) {
                this.path = this.filename = "";
            } else if (session.Config.OpaqueFileNames) {
                this.path = this.filename = name;
            } else {
                if ((name.Length > 1) && (name [1] == ':'))
                    name = session.MapFileName (name);

                if ((name.Length > 1) && (name [1] == ':'))
                    this.path = this.filename = name;
                else {
                    name = session.MapFileName (name);
                    this.path = Path.GetFullPath (name);
                    this.filename = Path.GetFileName (name);
                }
            }
        }
Beispiel #2
0
 protected Method(string name, string image_file, Module module)
 {
     this.name = name;
     this.image_file = image_file;
     this.module = module;
 }
Beispiel #3
0
        protected Method(string name, string image_file, Module module,
				  TargetAddress start, TargetAddress end)
            : this(name, image_file, module)
        {
            this.start = start;
            this.end = end;
            this.method_start = start;
            this.method_end = end;
            this.is_loaded = true;
        }
Beispiel #4
0
        public DynamicSourceLocation(TargetFunctionType function, int line, int column)
        {
            this.function = function;
            this.file = null;
            this.module = function.Module;

            this.line = line;
            this.column = column;
        }
Beispiel #5
0
 public DynamicSourceLocation(SourceFile file, int line, int column)
 {
     this.module = file.Module;
     this.file = file;
     this.line = line;
     this.column = column;
 }
Beispiel #6
0
        public DynamicSourceLocation(MethodSource source, SourceFile file, int line, int column)
        {
            if (source.IsManaged) {
                this.function = source.Function;
                this.module = function.Module;
            } else {
                this.module = source.Module;
                this.source = source;
            }

            this.file = file;
            this.line = line;
            this.column = column;
        }
Beispiel #7
0
            public MonoSourceFile(DebuggerSession session, Module module,
					       C.SourceFileEntry file, string path)
                : base(session, module, path)
            {
                this.file = file;
            }
Beispiel #8
0
        internal MonoSymbolFile(MonoLanguageBackend language, Process process,
					 TargetMemoryAccess memory, TargetAddress address)
        {
            this.MonoLanguage = language;
            this.TargetMemoryInfo = memory.TargetMemoryInfo;
            this.Architecture = process.Architecture;
            this.process = process;

            ThreadManager = process.ThreadManager;

            int address_size = TargetMemoryInfo.TargetAddressSize;
            int int_size = TargetMemoryInfo.TargetIntegerSize;

            ranges = ArrayList.Synchronized (new ArrayList ());
            range_hash = Hashtable.Synchronized (new Hashtable ());
            type_hash = Hashtable.Synchronized (new Hashtable ());
            class_entry_by_token = Hashtable.Synchronized (new Hashtable ());

            Index = memory.ReadInteger (address);
            address += int_size;
            TargetAddress image_file_addr = memory.ReadAddress (address);
            address += address_size;
            ImageFile = memory.ReadString (image_file_addr);
            MonoImage = memory.ReadAddress (address);
            address += address_size;
            TargetAddress type_table_ptr = memory.ReadAddress (address);
            address += address_size;

            TypeTable = MonoTypeTable.CreateTypeTable (this, memory, type_table_ptr);

            string shadow_location = language.GetShadowCopyLocation (ImageFile);
            if (shadow_location != null)
                ImageFile = shadow_location;

            try {
                Assembly = Cecil.AssemblyDefinition.ReadAssembly (ImageFile);
            } catch (Exception ex) {
                throw new SymbolTableException (
                    "Cannot load symbol file `{0}': {1}", ImageFile, ex);
            }

            ModuleDefinition = Assembly.MainModule;

            Report.Debug (DebugFlags.JitSymtab, "SYMBOL TABLE READER: {0}", ImageFile);

            string mdb_file = ImageFile + ".mdb";

            try {
                File = C.MonoSymbolFile.ReadSymbolFile (ModuleDefinition, mdb_file);
                if (File == null)
                    Report.Error ("Cannot load symbol file `{0}'", mdb_file);
                else if (ModuleDefinition.Mvid != File.Guid) {
                    Report.Error ("Symbol file `{0}' does not match assembly `{1}'",
                              mdb_file, ImageFile);
                    File = null;
                }
            } catch (C.MonoSymbolFileException ex) {
                Report.Error (ex.Message);
            } catch (Exception ex) {
                Report.Error ("Cannot load symbol file `{0}': {1}", mdb_file, ex);
            }

            symtab = new MonoSymbolTable (this);

            name = Assembly.Name.FullName;

            module = process.Session.GetModule (name);
            if (module == null) {
                module = process.Session.CreateModule (name, this);
            } else {
                module.LoadModule (this);
            }

            #if FIXME
            if ((File != null) && (File.OffsetTable.IsAspxSource)) {
                Console.WriteLine ("ASPX SOURCE: {0} {1}", this, File);
            }
            #endif

            process.SymbolTableManager.AddSymbolFile (this);
        }
Beispiel #9
0
        public Bfd(OperatingSystemBackend os, TargetMemoryInfo info, string filename,
			    TargetAddress base_address, bool is_loaded)
        {
            this.os = os;
            this.info = info;
            this.filename = filename;
            this.base_address = base_address;
            this.is_loaded = is_loaded;

            this.symfile = new BfdSymbolFile (this);

            bfd = bfd_glue_openr (filename, null);
            if (bfd == IntPtr.Zero)
                throw new SymbolTableException ("Can't read symbol file: {0}", filename);

            if (bfd_glue_check_format_archive (bfd))
            {
                IntPtr archive = bfd;
                bfd = IntPtr.Zero;

                while (true) {
                    bfd = bfd_glue_openr_next_archived_file (archive, bfd);
                    if(bfd == IntPtr.Zero)
                        throw new SymbolTableException ("Can't read symbol file: {0}", filename);

                    if (bfd_glue_check_format_object(bfd))
                    {
                        /*
                         * At this point, just check for mach-o-le (OS X X86 binary).
                         * When we want to support other architctures in fat binarys,
                         * we need to somehow get the correct target string for the
                         * process, and chech against that.
                         */
                        if (bfd_glue_get_target_name(bfd) == "mach-o-le")
                            break;
                    }
                }
            }

            if (bfd_glue_check_format_object (bfd))
                is_coredump = false;
            else if (bfd_glue_check_format_core (bfd))
                is_coredump = true;
            else
                throw new SymbolTableException ("Not an object file: {0}", filename);

            target = bfd_glue_get_target_name (bfd);
            if ((target == "elf32-i386") || (target == "elf64-x86-64")) {
                if (!is_coredump) {
                    Section text = GetSectionByName (".text", false);
                    Section bss = GetSectionByName (".bss", false);

                    if ((text != null) && (bss != null)) {
                        if (!base_address.IsNull)
                            start_address = new TargetAddress (
                                info.AddressDomain,
                                base_address.Address + text.vma);
                        else
                            start_address = new TargetAddress (
                                info.AddressDomain, text.vma);

                        if (!base_address.IsNull)
                            end_address = new TargetAddress (
                                info.AddressDomain,
                                base_address.Address + bss.vma + bss.size);
                        else
                            end_address = new TargetAddress (
                                info.AddressDomain, bss.vma + bss.size);
                    }
                }

                read_bfd_symbols ();

                if (DwarfReader.IsSupported (this))
                    has_debugging_info = true;

                Section plt_section = GetSectionByName (".plt", false);
                Section got_section = GetSectionByName (".got", false);
                if ((plt_section != null) && (got_section != null)) {
                    plt_start = new TargetAddress (
                        info.AddressDomain,
                        base_address.Address + plt_section.vma);
                    plt_end = plt_start + plt_section.size;

                    got_start = new TargetAddress (
                        info.AddressDomain,
                        base_address.Address + got_section.vma);
                    has_got = true;
                }
            } else if (target == "mach-o-le") {
                if (!is_coredump) {
                    read_sections ();
                    long start = 0xffffffff;
                    long end = 0;
                    foreach (Section section in sections) {
                        long relocated = base_address.Address + section.vma;

                        if (relocated < start)
                            start = relocated;
                        if (relocated + section.size > end)
                            end = relocated + section.size;
                    }

                    start_address = new TargetAddress (info.AddressDomain, start);
                    end_address = new TargetAddress (info.AddressDomain, end);
                }

                read_bfd_symbols ();

                if (DwarfReader.IsSupported (this))
                    has_debugging_info = true;

                has_got = false;
            } else
                throw new SymbolTableException (
                    "Symbol file {0} has unknown target architecture {1}",
                    filename, target);

            long entry_point_addr = bfd_glue_get_start_address (bfd);
            entry_point = entry_point_addr != 0 ? new TargetAddress (info.AddressDomain, entry_point_addr) : TargetAddress.Null;

            module = os.Process.Session.GetModule (filename);
            if (module == null) {
                module = os.Process.Session.CreateModule (filename, symfile);
                OnModuleChanged ();
            } else {
                module.LoadModule (symfile);
            }

            os.Process.SymbolTableManager.AddSymbolFile (symfile);
        }
		private void OnModuleUnLoadedEvent (Module module)
		{
			SourceFile[] sfiles = module.Sources;
			string[] files = new string [sfiles.Length];
			for (int n=0; n<files.Length; n++)
				files [n] = sfiles [n].FileName;
			controller.NotifySourceFileUnloaded (files);
			WriteDebuggerOutput (string.Format ("Module unloaded: {0}.\n", module.Name));
		}
		private void OnModuleLoadedEvent (Module module)
		{
			SourceFile[] sfiles = module.Sources;
			string[] files = new string [sfiles.Length];
			for (int n=0; n<files.Length; n++)
				files [n] = sfiles [n].FileName;
			controller.NotifySourceFileLoaded (files);
			WriteDebuggerOutput (string.Format ("Module loaded: {0}.\n", module.Name));

			if (process == null)
				return;
			
			lock (pendingCatchpoints) {
				foreach (Catchpoint cp in pendingCatchpoints.ToArray ()) {
					ML.TargetType exc = module.Language.LookupType (cp.ExceptionName);
					if (exc != null) {
						session.InsertExceptionCatchPoint (process.MainThread, ThreadGroup.Global, exc);
						pendingCatchpoints.Remove (cp);
					}
				}
			}
		}