Architecture-dependent interface.
Inheritance: DebuggerMarshalByRefObject, IDisposable
        public MethodAddress(TargetBinaryReader reader,
				      AddressDomain domain, Architecture arch)
        {
            // here we read the MonoDebugMethodAddress structure
            // as written out in mono_debug_add_method.
            reader.Position = 16;
            ReadAddress (reader, domain); // wrapper_data
            MonoMethod = ReadAddress (reader, domain);
            ReadAddress (reader, domain); // address_list
            StartAddress = ReadAddress (reader, domain);
            WrapperAddress = ReadAddress (reader, domain);
            int code_size = reader.ReadInt32 ();

            EndAddress = StartAddress + code_size;

            int prologue_end = reader.ReadLeb128 ();
            int epilogue_begin = reader.ReadLeb128 ();

            MethodStartAddress = prologue_end > 0 ?
                StartAddress + prologue_end : StartAddress;
            MethodEndAddress = epilogue_begin > 0 ?
                StartAddress + epilogue_begin : EndAddress;

            int num_line_numbers = reader.ReadLeb128 ();
            LineNumbers = new List<JitLineNumberEntry> ();

            for (int i = 0; i < num_line_numbers; i++) {
                int il_offset = reader.ReadSLeb128 ();
                int native_offset = reader.ReadSLeb128 ();

                if (il_offset < 0)
                    continue;

                LineNumbers.Add (new JitLineNumberEntry (il_offset, native_offset));
            }

            HasThis = reader.ReadByte () != 0;
            if (HasThis)
                ThisVariableInfo = new VariableInfo (arch, reader);

            int num_params = reader.ReadLeb128 ();
            ParamVariableInfo = new VariableInfo [num_params];
            for (int i = 0; i < num_params; i++)
                ParamVariableInfo [i] = new VariableInfo (arch, reader);

            int num_locals = reader.ReadLeb128 ();
            LocalVariableInfo = new VariableInfo [num_locals];
            for (int i = 0; i < num_locals; i++)
                LocalVariableInfo [i] = new VariableInfo (arch, reader);
        }
Exemple #2
0
        private Process(ThreadManager manager, DebuggerSession session)
        {
            this.manager = manager;
            this.session = session;

            operation_host = new MyOperationHost (this);

            thread_lock_mutex = new DebuggerMutex ("thread_lock_mutex");

            stopped_event = new ST.ManualResetEvent (false);

            thread_hash = Hashtable.Synchronized (new Hashtable ());

            target_info = Inferior.GetTargetInfo ();
            if (target_info.TargetAddressSize == 8)
                architecture = new Architecture_X86_64 (this, target_info);
            else
                architecture = new Architecture_I386 (this, target_info);
        }
Exemple #3
0
        void DoDispose()
        {
            if (!is_forked) {
                if (architecture != null) {
                    architecture.Dispose ();
                    architecture = null;
                }

                if (mono_language != null) {
                    mono_language.Dispose();
                    mono_language = null;
                }

                if (native_language != null) {
                    native_language.Dispose ();
                    native_language = null;
                }

                if (os != null) {
                    os.Dispose ();
                    os = null;
                }

                if (symtab_manager != null) {
                    symtab_manager.Dispose ();
                    symtab_manager = null;
                }
            }

            if (breakpoint_manager != null) {
                breakpoint_manager.Dispose ();
                breakpoint_manager = null;
            }

            if (thread_db != null) {
                thread_db.Dispose ();
                thread_db = null;
            }

            if (thread_lock_mutex != null) {
                thread_lock_mutex.Dispose ();
                thread_lock_mutex = null;
            }

            exception_handlers = null;

            manager.RemoveProcess (this);
        }
Exemple #4
0
            void SetRegisters(Registers regs, TargetMemoryAccess target,
					   Architecture arch, Column[] columns)
            {
                long cfa_addr = GetRegisterValue (regs, 1, columns [0]);
                TargetAddress cfa = new TargetAddress (
                    target.AddressDomain, cfa_addr);

                for (int i = 1; i < columns.Length; i++) {
                    GetValue (target, regs, cfa, i+2, columns [i]);
                }
            }
Exemple #5
0
            public StackFrame Unwind(StackFrame frame, TargetMemoryAccess target,
						  Architecture arch)
            {
                Registers old_regs = frame.Registers;

                Registers regs = arch.CopyRegisters (old_regs);

                SetRegisters (regs, target, arch, columns);

                Register eip = GetRegister (regs, 0);
                Register esp = GetRegister (regs, 1);
                Register ebp = GetRegister (regs, 2);

                if (!eip.Valid || !esp.Valid)
                    return null;

                TargetAddress address = new TargetAddress (
                    target.AddressDomain, eip.Value);
                TargetAddress stack = new TargetAddress (
                    target.AddressDomain, esp.Value);

                TargetAddress frame_addr = TargetAddress.Null;
                if (ebp.Valid)
                    frame_addr = new TargetAddress (
                        target.AddressDomain, ebp.Value);

                return arch.CreateFrame (
                    frame.Thread, FrameType.Normal, target, address, stack, frame_addr, regs);
            }
Exemple #6
0
        public StackFrame UnwindStack(StackFrame frame, TargetMemoryAccess target,
					       Architecture arch)
        {
            if (frame.TargetAddress.IsNull)
                return null;

            TargetAddress address = frame.TargetAddress;

            DwarfBinaryReader reader = new DwarfBinaryReader (bfd, blob, false);

            while (reader.Position < reader.Size) {
                long length = reader.ReadInitialLength ();
                if (length == 0)
                    break;
                long end_pos = reader.Position + length;

                long cie_pointer = reader.ReadOffset ();
                bool is_cie;
                if (is_ehframe)
                    is_cie = cie_pointer == 0;
                else
                    is_cie = cie_pointer == -1;

                if (is_cie) {
                    reader.Position = end_pos;
                    continue;
                }

                if (is_ehframe)
                    cie_pointer = reader.Position - cie_pointer -
                        target.TargetMemoryInfo.TargetAddressSize;

                CIE cie = find_cie (cie_pointer);

                long initial, range;
                if (is_ehframe) {
                    initial = ReadEncodedValue (reader, cie.Encoding);
                    range = ReadEncodedValue (reader, cie.Encoding & 0x0f);
                } else {
                    initial = reader.ReadAddress ();
                    range = reader.ReadAddress ();
                }

                TargetAddress start = new TargetAddress (target.AddressDomain, initial);

                if ((address < start) || (address > start + range)) {
                    reader.Position = end_pos;
                    continue;
                }

                Entry fde = new Entry (cie, start, address);
                fde.Read (reader, end_pos);
                return fde.Unwind (frame, target, arch);
            }

            return null;
        }
Exemple #7
0
        internal Registers(Architecture arch, long[] values)
        {
            important_indices = arch.RegisterIndices;

            regs = new Register [arch.CountRegisters];
            if (regs.Length != values.Length)
                throw new ArgumentException ();
            for (int i = 0; i < regs.Length; i++) {
                if (arch.RegisterSizes [i] < 0)
                    continue;
                regs [i] = new Register (
                    this, arch.RegisterNames [i], i,
                    arch.RegisterSizes [i], true, values [i]);
            }
            from_current_frame = true;
        }
Exemple #8
0
        internal Registers(Architecture arch)
        {
            important_indices = arch.RegisterIndices;

            regs = new Register [arch.CountRegisters];
            for (int i = 0; i < regs.Length; i++) {
                if (arch.RegisterSizes [i] < 0)
                    continue;
                regs [i] = new Register (
                    this, arch.RegisterNames [i], i,
                    arch.RegisterSizes [i], false, 0);
            }
        }
        public VariableInfo(Architecture arch, TargetBinaryReader reader)
        {
            Index = reader.ReadLeb128 ();
            Offset = reader.ReadSLeb128 ();
            Size = reader.ReadLeb128 ();
            BeginLiveness = reader.ReadLeb128 ();
            EndLiveness = reader.ReadLeb128 ();

            MonoType = new TargetAddress (
                reader.TargetMemoryInfo.AddressDomain, reader.ReadAddress ());

            Mode = (AddressMode) (Index & AddressModeFlags);
            Index = (int) ((long) Index & ~AddressModeFlags);

            Report.Debug (DebugFlags.JitSymtab, "VARIABLE INFO: {0} {1} {2} {3} {4}",
                      Mode, Index, Offset, Size, arch);

            if ((Mode == AddressMode.Register) || (Mode == AddressMode.RegOffset))
                Index = arch.RegisterMap [Index];

            Report.Debug (DebugFlags.JitSymtab, "VARIABLE INFO #1: {0}", Index);

            HasLivenessInfo = (BeginLiveness != 0) && (EndLiveness != 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);
        }
Exemple #11
0
        protected void SetupInferior()
        {
            IntPtr data = IntPtr.Zero;
            try {
                check_error (mono_debugger_server_get_signal_info (
                             server_handle, out data));

                signal_info = (SignalInfo) Marshal.PtrToStructure (
                    data, typeof (SignalInfo));
                has_signals = true;
            } finally {
                g_free (data);
            }

            target_info = GetTargetMemoryInfo (address_domain);

            try {
                string cwd;
                string[] cmdline_args;

                string application = GetApplication (out cwd, out cmdline_args);

                exe = process.OperatingSystem.LoadExecutable (
                    target_info, application, start.LoadNativeSymbolTable);
            } catch (Exception e) {
                if (error_handler != null)
                    error_handler (this, String.Format (
                                   "Can't read symbol file {0}", start.TargetApplication), e);
                else
                    Console.WriteLine ("Can't read symbol file {0}: {1}",
                               start.TargetApplication, e);
                return;
            }

            arch = process.Architecture;
        }