ReadAddress() public method

public ReadAddress ( ) : TargetAddress
return TargetAddress
コード例 #1
0
        void read_dynamic_info(Inferior inferior)
        {
            if (has_dynlink_info)
            {
                if (!first_link_map.IsNull)
                {
                    do_update_shlib_info(inferior);
                }
                return;
            }

            TargetAddress debug_base = main_bfd.ReadDynamicInfo(inferior);

            if (debug_base.IsNull)
            {
                return;
            }

            int size = 2 * inferior.TargetLongIntegerSize + 3 * inferior.TargetAddressSize;

            TargetReader reader = new TargetReader(inferior.ReadMemory(debug_base, size));

            if (reader.ReadLongInteger() != 1)
            {
                return;
            }

            first_link_map          = reader.ReadAddress();
            dynlink_breakpoint_addr = reader.ReadAddress();

            rdebug_state_addr = debug_base + reader.Offset;

            if (reader.ReadLongInteger() != 0)
            {
                return;
            }

            has_dynlink_info = true;

            Instruction insn = inferior.Architecture.ReadInstruction(inferior, dynlink_breakpoint_addr);

            if ((insn == null) || !insn.CanInterpretInstruction)
            {
                throw new InternalError("Unknown dynlink breakpoint: {0}", dynlink_breakpoint_addr);
            }

            dynlink_breakpoint = new DynlinkBreakpoint(this, insn);
            dynlink_breakpoint.Insert(inferior);

            do_update_shlib_info(inferior);

            check_loaded_library(inferior, main_bfd);
        }
コード例 #2
0
        void do_update_shlib_info(Inferior inferior)
        {
            bool          first = true;
            TargetAddress map   = first_link_map;

            while (!map.IsNull)
            {
                int          the_size   = 4 * inferior.TargetAddressSize;
                TargetReader map_reader = new TargetReader(inferior.ReadMemory(map, the_size));

                TargetAddress l_addr = map_reader.ReadAddress();
                TargetAddress l_name = map_reader.ReadAddress();
                map_reader.ReadAddress();

                string name;
                try {
                    name = inferior.ReadString(l_name);
                    // glibc 2.3.x uses the empty string for the virtual
                    // "linux-gate.so.1".
                    if ((name != null) && (name == ""))
                    {
                        name = null;
                    }
                } catch {
                    name = null;
                }

                map = map_reader.ReadAddress();

                if (first)
                {
                    first = false;
                    continue;
                }

                if (name == null)
                {
                    continue;
                }

                if (bfd_hash.Contains(name))
                {
                    continue;
                }

                bool step_into = Process.ProcessStart.LoadNativeSymbolTable;
                AddExecutableFile(inferior, name, l_addr, step_into, true);
            }
        }
コード例 #3
0
        void read_thread_table()
        {
            TargetAddress ptr = main_thread.ReadAddress(debugger_info.ThreadTable);

            while (!ptr.IsNull)
            {
                int          size   = 56 + main_thread.TargetMemoryInfo.TargetAddressSize;
                TargetReader reader = new TargetReader(main_thread.ReadMemory(ptr, size));

                long          tid      = reader.ReadLongInteger();
                TargetAddress lmf_addr = reader.ReadAddress();
                reader.ReadAddress();                  // end stack

                ptr = reader.ReadAddress();

                TargetAddress stack_start        = reader.ReadAddress();
                TargetAddress signal_stack_start = reader.ReadAddress();
                int           stack_size         = reader.ReadInteger();
                int           signal_stack_size  = reader.ReadInteger();

                bool found = false;
                foreach (CoreFileThread thread in threads)
                {
                    TargetAddress sp = thread.CurrentFrame.StackPointer;

                    if ((sp >= stack_start) && (sp < stack_start + stack_size))
                    {
                        thread.SetLMFAddress(tid, lmf_addr);
                        found = true;
                        break;
                    }
                    else if (!signal_stack_start.IsNull &&
                             (sp >= signal_stack_start) &&
                             (sp < signal_stack_start + signal_stack_size))
                    {
                        thread.SetLMFAddress(tid, lmf_addr);
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    Console.WriteLine("InternalError: did not find the address for the thread");
                }
            }
        }
コード例 #4
0
        void do_update_shlib_info(Inferior inferior)
        {
//			if (Process.MonoRuntimeFound)
//				return;
            if (!dyld_all_image_infos.IsNull)
            {
                int          size   = 2 * inferior.TargetLongIntegerSize + 2 * inferior.TargetAddressSize;
                TargetReader reader = new TargetReader(inferior.ReadMemory(dyld_all_image_infos, size));

                reader.ReadLongInteger();                  // version
                int           infoArrayCount = (int)reader.ReadLongInteger();
                TargetAddress infoArray      = reader.ReadAddress();

                size   = infoArrayCount * (inferior.TargetLongIntegerSize + 2 * inferior.TargetAddressSize);
                reader = new TargetReader(inferior.ReadMemory(infoArray, size));
                Console.Write("Loading symbols for shared libraries:");
                for (int i = 0; i < infoArrayCount; i++)
                {
                    TargetAddress imageLoadAddress = reader.ReadAddress();
                    TargetAddress imageFilePath    = reader.ReadAddress();
                    reader.ReadLongInteger();                     //imageFileModDate
                    string name = inferior.ReadString(imageFilePath);

                    if (name == null)
                    {
                        continue;
                    }

                    if (bfd_hash.Contains(name))
                    {
                        continue;
                    }

                    try {
                        Console.Write(".");
                        AddExecutableFile(inferior, name, imageLoadAddress /*TargetAddress.Null*/, false, true);
                    }
                    catch (SymbolTableException e)
                    {
                        Console.WriteLine("Unable to load binary for " + name);
                        bfd_hash.Add(name, null);
                    }
                }
                Console.WriteLine("");
            }
        }
コード例 #5
0
        void read_dynamic_info(Inferior inferior)
        {
            if (has_dynlink_info)
            {
                if (!dyld_all_image_infos.IsNull)
                {
                    do_update_shlib_info(inferior);
                }
                return;
            }

            TargetMemoryInfo info = Inferior.GetTargetMemoryInfo(AddressDomain.Global);
            Bfd dyld_image        = new Bfd(this, info, "/usr/lib/dyld", TargetAddress.Null, true);

            dyld_all_image_infos = dyld_image.LookupSymbol("dyld_all_image_infos");
            if (dyld_all_image_infos.IsNull)
            {
                return;
            }


            int          size   = 2 * inferior.TargetLongIntegerSize + 2 * inferior.TargetAddressSize;
            TargetReader reader = new TargetReader(inferior.ReadMemory(dyld_all_image_infos, size));

            reader.ReadLongInteger();          // version
            reader.ReadLongInteger();          // infoArrayCount
            reader.ReadAddress();              // infoArray
            TargetAddress dyld_image_notifier = reader.ReadAddress();

            has_dynlink_info = true;

            Instruction insn = inferior.Architecture.ReadInstruction(inferior, dyld_image_notifier);

            if ((insn == null) || !insn.CanInterpretInstruction)
            {
                throw new InternalError("Unknown dynlink breakpoint: {0}", dyld_image_notifier);
            }

            dynlink_breakpoint = new DynlinkBreakpoint(this, insn);
            dynlink_breakpoint.Insert(inferior);

            do_update_shlib_info(inferior);

            check_loaded_library(inferior, main_bfd);
        }
コード例 #6
0
        void method_from_jit_info(TargetAccess target, TargetAddress data,
					   MethodLoadedHandler handler)
        {
            int size = target.ReadInteger (data);
            TargetReader reader = new TargetReader (target.ReadMemory (data, size));

            reader.BinaryReader.ReadInt32 ();
            int count = reader.BinaryReader.ReadInt32 ();

            for (int i = 0; i < count; i++) {
                TargetAddress address = reader.ReadAddress ();
                Method method = read_range_entry (target, address);

                handler (target, method);
            }
        }
コード例 #7
0
            protected override void ReadDataItem(TargetMemoryAccess memory,
							      DataItemType type, TargetReader reader)
            {
                if (type != DataItemType.DelegateInvoke)
                    throw new InternalError (
                        "Got unknown data item: {0}", type);

                TargetAddress code = reader.ReadAddress ();
                int size = reader.BinaryReader.ReadInt32 ();
                Report.Debug (DebugFlags.JitSymtab, "READ DELEGATE IMPL: {0} {1}",
                          code, size);
                delegate_impl_list.Add (new DelegateInvokeEntry (code, size));
            }
コード例 #8
0
        void create_appdomain(TargetMemoryAccess memory, TargetAddress address)
        {
            int addr_size = memory.TargetMemoryInfo.TargetAddressSize;
            TargetReader reader = new TargetReader (
                memory.ReadMemory (address, 8 + 3 * addr_size));

            int id = reader.BinaryReader.ReadInt32 ();
            int shadow_path_len = reader.BinaryReader.ReadInt32 ();
            TargetAddress shadow_path_addr = reader.ReadAddress ();

            string shadow_path = null;
            if (!shadow_path_addr.IsNull) {
                byte[] buffer = memory.ReadBuffer (shadow_path_addr, shadow_path_len);
                char[] cbuffer = new char [buffer.Length];
                for (int i = 0; i < buffer.Length; i++)
                    cbuffer [i] = (char) buffer [i];
                shadow_path = new String (cbuffer);
            }

            TargetAddress domain = reader.ReadAddress ();
            TargetAddress setup = reader.ReadAddress ();

            MetadataHelper.AppDomainInfo info = MetadataHelper.GetAppDomainInfo (this, memory, setup);
            info.ShadowCopyPath = shadow_path;

            appdomain_info.Add (id, info);
        }
コード例 #9
0
        // This method reads the MonoDebuggerSymbolTable structure
        // (struct definition is in mono-debug-debugger.h)
        void do_read_symbol_table(TargetMemoryAccess memory)
        {
            TargetAddress symtab_address = memory.ReadAddress (info.SymbolTable);
            if (symtab_address.IsNull)
                throw new SymbolTableException ("Symbol table is null.");

            TargetReader header = new TargetReader (
                memory.ReadMemory (symtab_address, info.SymbolTableSize));

            long magic = header.BinaryReader.ReadInt64 ();
            if (magic != MonoDebuggerInfo.DynamicMagic)
                throw new SymbolTableException (
                    "Debugger symbol table has unknown magic {0:x}.", magic);

            int version = header.ReadInteger ();
            if (version < MonoDebuggerInfo.MinDynamicVersion)
                throw new SymbolTableException (
                    "Debugger symbol table has version {0}, but " +
                    "expected at least {1}.", version,
                    MonoDebuggerInfo.MinDynamicVersion);
            if (version > MonoDebuggerInfo.MaxDynamicVersion)
                throw new SymbolTableException (
                    "Debugger symbol table has version {0}, but " +
                    "expected at most {1}.", version,
                    MonoDebuggerInfo.MaxDynamicVersion);

            int total_size = header.ReadInteger ();
            if (total_size != info.SymbolTableSize)
                throw new SymbolTableException (
                    "Debugger symbol table has size {0}, but " +
                    "expected {1}.", total_size, info.SymbolTableSize);

            TargetAddress corlib_address = header.ReadAddress ();
            TargetAddress global_data_table_ptr = header.ReadAddress ();
            TargetAddress data_table_list = header.ReadAddress ();

            TargetAddress symfile_by_index = header.ReadAddress ();

            if (corlib_address.IsNull)
                throw new SymbolTableException ("Corlib address is null.");
            corlib = load_symfile (memory, corlib_address);
            if (corlib == null)
                throw new SymbolTableException ("Cannot read corlib!");

            TargetAddress ptr = symfile_by_index;
            while (!ptr.IsNull) {
                TargetAddress next_ptr = memory.ReadAddress (ptr);
                TargetAddress address = memory.ReadAddress (
                    ptr + memory.TargetMemoryInfo.TargetAddressSize);

                ptr = next_ptr;
                load_symfile (memory, address);
            }

            ptr = data_table_list;
            while (!ptr.IsNull) {
                TargetAddress next_ptr = memory.ReadAddress (ptr);
                TargetAddress address = memory.ReadAddress (
                    ptr + memory.TargetMemoryInfo.TargetAddressSize);

                ptr = next_ptr;
                add_data_table (memory, address);
            }

            global_data_table = new GlobalDataTable (this, global_data_table_ptr);
        }
コード例 #10
0
ファイル: X86_Instruction.cs プロジェクト: baulig/debugger
        protected void DecodeGroup5(TargetReader reader)
        {
            if ((ModRM.Reg == 2) || (ModRM.Reg == 3))
                type = Type.IndirectCall;
            else if ((ModRM.Reg == 4) || (ModRM.Reg == 5))
                type = Type.IndirectJump;
            else
                return;

            int displacement = 0;
            bool dereference_addr;

            int register;
            int index_register = -1;

            if ((ModRM.R_M == 5) || (ModRM.R_M == 13)) {
                /* Special meaning in mod == 00 */
                if (ModRM.Mod == 0) {
                    if (Is64BitMode) {
                        displacement = reader.BinaryReader.ReadInt32 ();
                        register = -1;
                        is_ip_relative = true;
                    } else {
                        CallTarget = reader.ReadAddress ();
                        return;
                    }
                } else {
                    register = DecodeRegister (ModRM.R_M);
                }
            } else if ((ModRM.R_M == 4) || (ModRM.R_M == 12)) {
                /* Activate SIB byte if mod != 11 */
                if (ModRM.Mod != 3) {
                    SIB = new X86_SIB (this, reader.ReadByte ());

                    if ((ModRM.Mod == 0) &&
                        ((SIB.Base == 5) || (SIB.Base == 13))) {
                        displacement = reader.BinaryReader.ReadInt32 ();
                        CallTarget = new TargetAddress (
                            reader.AddressDomain, displacement);
                        return;
                    }

                    if (SIB.Index != 4) {
                        index_register = DecodeRegister (SIB.Index);
                    }

                    register = DecodeRegister (SIB.Base);
                } else {
                    register = DecodeRegister (ModRM.R_M);
                }
            } else {
                register = DecodeRegister (ModRM.R_M);
            }

            if (ModRM.Mod == 0) {
                dereference_addr = true;
            } else if (ModRM.Mod == 1) {
                displacement = reader.BinaryReader.ReadSByte ();
                dereference_addr = true;
            } else if (ModRM.Mod == 2) {
                displacement = reader.BinaryReader.ReadInt32 ();
                dereference_addr = true;
            } else if (ModRM.Mod == 3) {
                displacement = 0;
                dereference_addr = false;
            } else {
                // Can never happen
                throw new InvalidOperationException ();
            }

            Register = register;
            IndexRegister = index_register;
            Displacement = displacement;
            DereferenceAddress = dereference_addr;
        }
コード例 #11
0
        void add_data_table(TargetMemoryAccess memory, TargetAddress ptr)
        {
            int table_size = 8 + 2 * memory.TargetMemoryInfo.TargetAddressSize;

            TargetReader reader = new TargetReader (memory.ReadMemory (ptr, table_size));

            int domain = reader.ReadInteger ();
            reader.Offset += 4;

            DomainDataTable table = (DomainDataTable) data_tables [domain];
            if (table == null) {
                TargetAddress first_chunk = reader.ReadAddress ();
                table = new DomainDataTable (this, domain, ptr, first_chunk);
                data_tables.Add (domain, table);
            }
        }
コード例 #12
0
ファイル: MetadataHelper.cs プロジェクト: baulig/debugger
        public GenericParamInfo GetGenericParameter(TargetMemoryAccess memory,
							     TargetAddress address)
        {
            int addr_size = memory.TargetMemoryInfo.TargetAddressSize;

            TargetReader reader = new TargetReader (
                memory.ReadMemory (address, 4 * addr_size + 4));
            TargetAddress container = reader.ReadAddress ();
            TargetAddress klass = reader.ReadAddress ();
            TargetAddress name_addr = reader.ReadAddress ();
            reader.BinaryReader.ReadInt16 (); /* flags */
            int pos = reader.BinaryReader.ReadInt16 ();

            string name;
            if (!name_addr.IsNull)
                name = memory.ReadString (name_addr);
            else
                name = String.Format ("!{0}", pos);

            return new GenericParamInfo (container, klass, name, pos);
        }
コード例 #13
0
ファイル: CoreFile.cs プロジェクト: baulig/debugger
        void read_thread_table()
        {
            TargetAddress ptr = main_thread.ReadAddress (debugger_info.ThreadTable);
            while (!ptr.IsNull) {
                int size = 56 + main_thread.TargetMemoryInfo.TargetAddressSize;
                TargetReader reader = new TargetReader (main_thread.ReadMemory (ptr, size));

                long tid = reader.ReadLongInteger ();
                TargetAddress lmf_addr = reader.ReadAddress ();
                reader.ReadAddress (); // end stack

                ptr = reader.ReadAddress ();

                TargetAddress stack_start = reader.ReadAddress ();
                TargetAddress signal_stack_start = reader.ReadAddress ();
                int stack_size = reader.ReadInteger ();
                int signal_stack_size = reader.ReadInteger ();

                bool found = false;
                foreach (CoreFileThread thread in threads) {
                    TargetAddress sp = thread.CurrentFrame.StackPointer;

                    if ((sp >= stack_start) && (sp < stack_start + stack_size)) {
                        thread.SetLMFAddress (tid, lmf_addr);
                        found = true;
                        break;
                    } else if (!signal_stack_start.IsNull &&
                           (sp >= signal_stack_start) &&
                           (sp < signal_stack_start + signal_stack_size)) {
                        thread.SetLMFAddress (tid, lmf_addr);
                        found = true;
                        break;
                    }
                }

                if (!found)
                    Console.WriteLine ("InternalError: did not find the address for the thread");
            }
        }
コード例 #14
0
        void read_dynamic_info(Inferior inferior)
        {
            if (has_dynlink_info) {
                if (!dyld_all_image_infos.IsNull)
                    do_update_shlib_info (inferior);
                return;
            }

            TargetMemoryInfo info = Inferior.GetTargetMemoryInfo (AddressDomain.Global);
			Bfd dyld_image = new Bfd (this, info, "/usr/lib/dyld", TargetAddress.Null, true);

            dyld_all_image_infos = dyld_image.LookupSymbol("dyld_all_image_infos");
            if (dyld_all_image_infos.IsNull)
                return;

            int size = 2 * inferior.TargetLongIntegerSize + 2 * inferior.TargetAddressSize;
            TargetReader reader = new TargetReader (inferior.ReadMemory (dyld_all_image_infos, size));

            reader.ReadLongInteger (); // version
            reader.ReadLongInteger (); // infoArrayCount
            reader.ReadAddress (); // infoArray
            TargetAddress dyld_image_notifier = reader.ReadAddress ();

            has_dynlink_info = true;

            Instruction insn = inferior.Architecture.ReadInstruction (inferior, dyld_image_notifier);
            if ((insn == null) || !insn.CanInterpretInstruction)
                throw new InternalError ("Unknown dynlink breakpoint: {0}", dyld_image_notifier);

            dynlink_breakpoint = new DynlinkBreakpoint (this, insn);
            dynlink_breakpoint.Insert (inferior);

            do_update_shlib_info (inferior);

            check_loaded_library (inferior, main_bfd);
コード例 #15
0
ファイル: MetadataHelper.cs プロジェクト: baulig/debugger
        public MonoMethodSignature GetMethodSignature(MonoLanguageBackend mono,
							       TargetMemoryAccess memory,
							       TargetAddress signature)
        {
            int count = memory.ReadInteger (signature + 4) & 0x0000ffff;

            int offset = memory.TargetAddressSize == 8 ? 16 : 12;
            TargetAddress ret = memory.ReadAddress (signature + offset);

            TargetType ret_type = mono.ReadType (memory, ret);
            if (count == 0)
                return new MonoMethodSignature (ret_type, new TargetType [0]);

            offset += memory.TargetAddressSize;
            TargetReader reader = new TargetReader (
                memory.ReadMemory (signature + offset, count * memory.TargetAddressSize));

            TargetType[] param_types = new TargetType [count];
            for (int i = 0; i < count; i++)
                param_types [i] = mono.ReadType (memory, reader.ReadAddress ());

            return new MonoMethodSignature (ret_type, param_types);
        }
コード例 #16
0
        void do_update_shlib_info(Inferior inferior)
        {
            //			if (Process.MonoRuntimeFound)
            //				return;
            if (!dyld_all_image_infos.IsNull) {
                int size = 2 * inferior.TargetLongIntegerSize + 2 * inferior.TargetAddressSize;
                TargetReader reader = new TargetReader (inferior.ReadMemory (dyld_all_image_infos, size));

                reader.ReadLongInteger (); // version
                int infoArrayCount = (int)reader.ReadLongInteger ();
                TargetAddress infoArray = reader.ReadAddress ();

                size = infoArrayCount * (inferior.TargetLongIntegerSize + 2 * inferior.TargetAddressSize);
                reader = new TargetReader (inferior.ReadMemory (infoArray, size));
                Console.Write("Loading symbols for shared libraries:");
                for (int i=0; i<infoArrayCount; i++)
                {
                    TargetAddress imageLoadAddress = reader.ReadAddress();
                    TargetAddress imageFilePath = reader.ReadAddress();
                    reader.ReadLongInteger(); //imageFileModDate
                    string name = inferior.ReadString (imageFilePath);

                    if (name == null)
                        continue;

                    if (bfd_hash.Contains (name))
                        continue;

                    try {
                        Console.Write(".");
                        AddExecutableFile (inferior, name, imageLoadAddress/*TargetAddress.Null*/, false, true);
                    }
                    catch (SymbolTableException e)
                    {
                        Console.WriteLine("Unable to load binary for "+name);
                        bfd_hash.Add (name, null);
                    }
                }
                Console.WriteLine("");
            }
        }
コード例 #17
0
ファイル: MetadataHelper.cs プロジェクト: baulig/debugger
            public AppDomainInfo(MonoLanguageBackend mono, TargetMemoryAccess memory, TargetReader reader)
            {
                int addr_size = memory.TargetMemoryInfo.TargetAddressSize;

                reader.Offset = 2 * addr_size;
                ApplicationBase = MonoStringObject.ReadString (mono, memory, reader.ReadAddress ());
                ApplicationName = MonoStringObject.ReadString (mono, memory, reader.ReadAddress ());
                CachePath = MonoStringObject.ReadString (mono, memory, reader.ReadAddress ());
                ConfigFile = MonoStringObject.ReadString (mono, memory, reader.ReadAddress ());
                DynamicBase = MonoStringObject.ReadString (mono, memory, reader.ReadAddress ());
                reader.Offset += 3 * addr_size;
                ShadowCopyDirectories = MonoStringObject.ReadString (mono, memory, reader.ReadAddress ());
                ShadowCopyFiles = MonoStringObject.ReadString (mono, memory, reader.ReadAddress ()) == "true";
            }
コード例 #18
0
        void do_update_shlib_info(Inferior inferior)
        {
            bool first = true;
            TargetAddress map = first_link_map;
            while (!map.IsNull) {
                int the_size = 4 * inferior.TargetAddressSize;
                TargetReader map_reader = new TargetReader (inferior.ReadMemory (map, the_size));

                TargetAddress l_addr = map_reader.ReadAddress ();
                TargetAddress l_name = map_reader.ReadAddress ();
                map_reader.ReadAddress ();

                string name;
                try {
                    name = inferior.ReadString (l_name);
                    // glibc 2.3.x uses the empty string for the virtual
                    // "linux-gate.so.1".
                    if ((name != null) && (name == ""))
                        name = null;
                } catch {
                    name = null;
                }

                map = map_reader.ReadAddress ();

                if (first) {
                    first = false;
                    continue;
                }

                if (name == null)
                    continue;

                if (bfd_hash.Contains (name))
                    continue;

                bool step_into = Process.ProcessStart.LoadNativeSymbolTable;
                AddExecutableFile (inferior, name, l_addr, step_into, true);
            }
        }
コード例 #19
0
        public void Read(TargetMemoryAccess memory)
        {
            int address_size = memory.TargetMemoryInfo.TargetAddressSize;
            int header_size = 16 + address_size;

            if (first_chunk.IsNull) {
                first_chunk = memory.ReadAddress (TableAddress + 8);
                current_chunk = first_chunk;
            }

            if (current_chunk.IsNull)
                return;

            again:
            TargetReader reader = new TargetReader (
                memory.ReadMemory (current_chunk, header_size));

            reader.ReadInteger (); /* size */
            int allocated_size = reader.ReadInteger ();
            int current_offset = reader.ReadInteger ();
            reader.ReadInteger (); /* dummy */
            TargetAddress next = reader.ReadAddress ();

            read_data_items (memory, current_chunk + header_size,
                     last_offset, current_offset);

            last_offset = current_offset;

            if (!next.IsNull && (current_offset == allocated_size)) {
                current_chunk = next;
                last_offset = 0;
                goto again;
            }
        }
コード例 #20
0
            protected override EventResult DoProcessEvent(Inferior.ChildEvent cevent,
							       out TargetEventArgs args)
            {
                if ((cevent.Type == Inferior.ChildEventType.CHILD_NOTIFICATION) &&
                ((NotificationType) cevent.Argument == NotificationType.Trampoline)) {
                TargetAddress info = new TargetAddress (
                    inferior.AddressDomain, cevent.Data1);

                TargetReader reader = new TargetReader (inferior.ReadMemory (info, 3 * inferior.TargetAddressSize));
                TargetAddress trampoline = reader.ReadAddress ();
                TargetAddress method = reader.ReadAddress ();
                TargetAddress code = reader.ReadAddress ();

                if ((trampoline.IsNull) || (trampoline != CallSite.Address + CallSite.InstructionSize)) {
                    args = null;
                    sse.do_continue ();
                    return EventResult.Running;
                }

                args = null;
                compiled = true;
                TrampolineCompiled (method, code);
                return EventResult.Running;
                } else if ((cevent.Type == Inferior.ChildEventType.CHILD_NOTIFICATION) &&
                   ((NotificationType) cevent.Argument == NotificationType.OldTrampoline)) {
                TargetAddress method = new TargetAddress (
                    inferior.AddressDomain, cevent.Data1);
                TargetAddress code = new TargetAddress (
                    inferior.AddressDomain, cevent.Data2);

                args = null;
                compiled = true;
                TrampolineCompiled (method, code);
                return EventResult.Running;
                }

                args = null;
                if (!compiled) {
                sse.disable_extended_notification (NotificationType.Trampoline);
                return EventResult.Completed;
                } else
                return EventResult.ResumeOperation;
            }
コード例 #21
0
            protected override void ReadDataItem(TargetMemoryAccess memory,
							      DataItemType type, TargetReader reader)
            {
                if (type != DataItemType.Class)
                    throw new InternalError (
                        "Got unknown data item: {0}", type);

                reader.BinaryReader.ReadInt32 ();

                int token = reader.BinaryReader.ReadLeb128 ();
                reader.BinaryReader.ReadLeb128 (); /* instance_size */
                TargetAddress klass_address = reader.ReadAddress ();

                SymbolFile.AddClassEntry (token, klass_address);
            }
コード例 #22
0
        void read_dynamic_info(Inferior inferior)
        {
            if (has_dynlink_info) {
                if (!first_link_map.IsNull)
                    do_update_shlib_info (inferior);
                return;
            }

            TargetAddress debug_base = main_bfd.ReadDynamicInfo (inferior);
            if (debug_base.IsNull)
                return;

            int size = 2 * inferior.TargetLongIntegerSize + 3 * inferior.TargetAddressSize;

            TargetReader reader = new TargetReader (inferior.ReadMemory (debug_base, size));
            if (reader.ReadLongInteger () != 1)
                return;

            first_link_map = reader.ReadAddress ();
            dynlink_breakpoint_addr = reader.ReadAddress ();

            rdebug_state_addr = debug_base + reader.Offset;

            if (reader.ReadLongInteger () != 0)
                return;

            has_dynlink_info = true;

            Instruction insn = inferior.Architecture.ReadInstruction (inferior, dynlink_breakpoint_addr);
            if ((insn == null) || !insn.CanInterpretInstruction)
                throw new InternalError ("Unknown dynlink breakpoint: {0}", dynlink_breakpoint_addr);

            dynlink_breakpoint = new DynlinkBreakpoint (this, insn);
            dynlink_breakpoint.Insert (inferior);

            do_update_shlib_info (inferior);

            check_loaded_library (inferior, main_bfd);
        }
コード例 #23
0
            public static RangeEntry Create(MonoSymbolFile file, TargetMemoryAccess memory,
							 TargetReader reader, byte[] contents)
            {
                int domain = reader.BinaryReader.ReadInt32 ();
                int index = reader.BinaryReader.ReadInt32 ();

                TargetAddress wrapper_data = reader.ReadAddress ();
                TargetAddress method = reader.ReadAddress ();
                reader.ReadAddress (); /* address_list */
                TargetAddress code_start = reader.ReadAddress ();
                TargetAddress wrapper_addr = reader.ReadAddress ();
                int code_size = reader.BinaryReader.ReadInt32 ();

                WrapperEntry wrapper = null;

                if (!wrapper_data.IsNull) {
                    int wrapper_size = 4 + 3 * memory.TargetMemoryInfo.TargetAddressSize;

                    TargetReader wrapper_reader = new TargetReader (
                        memory.ReadMemory (wrapper_data, wrapper_size));

                    TargetAddress name_address = wrapper_reader.ReadAddress ();
                    TargetAddress cil_address = wrapper_reader.ReadAddress ();
                    int wrapper_type = wrapper_reader.BinaryReader.ReadInt32 ();

                    string name = "<" + memory.ReadString (name_address) + ">";
                    string cil_code = memory.ReadString (cil_address);

                    wrapper = new WrapperEntry (
                        wrapper_addr, (WrapperType) wrapper_type, name, cil_code);
                }

                return new RangeEntry (
                    file, domain, index, wrapper, method,
                    code_start, code_start + code_size, contents);
            }
コード例 #24
0
ファイル: MetadataHelper.cs プロジェクト: baulig/debugger
        //
        // The following API is new in `terrania'.
        //
        public GenericClassInfo GetGenericClass(TargetMemoryAccess memory,
							 TargetAddress address)
        {
            int addr_size = memory.TargetMemoryInfo.TargetAddressSize;

            TargetReader reader = new TargetReader (memory.ReadMemory (address, 5 * addr_size));
            TargetAddress container = reader.ReadAddress ();
            TargetAddress class_inst = reader.ReadAddress ();
            reader.ReadAddress (); /* method_inst */
            reader.ReadAddress ();
            TargetAddress cached_class = reader.ReadAddress ();

            int inst_id = memory.ReadInteger (class_inst);
            int inst_data = memory.ReadInteger (class_inst + 4);

            TargetAddress inst_argv;
            if (MonoDebuggerInfo.MajorVersion == 80)
                inst_argv = memory.ReadAddress (class_inst + 8);
            else
                inst_argv = class_inst + 8;

            int type_argc = inst_data & 0x3fffff;

            TargetReader argv_reader = new TargetReader (
                memory.ReadMemory (inst_argv, type_argc * addr_size));

            TargetAddress[] type_args = new TargetAddress [type_argc];
            for (int i = 0; i < type_argc; i++)
                type_args [i] = argv_reader.ReadAddress ();

            TargetAddress cached_class_ptr = address + 4 * addr_size;

            return new GenericClassInfo (container, type_args, cached_class_ptr,
                             cached_class);
        }