LookupSymbol() public method

public LookupSymbol ( string name ) : TargetAddress
name string
return Mono.Debugger.TargetAddress
示例#1
0
        void check_for_mono_runtime(Inferior inferior, Bfd bfd)
        {
            TargetAddress info = bfd.LookupSymbol("MONO_DEBUGGER__debugger_info_ptr");

            if (info.IsNull)
            {
                return;
            }

            TargetAddress data = inferior.ReadAddress(info);

            if (data.IsNull)
            {
                //
                // See CheckForPendingMonoInit() below - this should only happen when
                // the Mono runtime is embedded - for instance Moonlight inside Firefox.
                //
                // Note that we have to do a symbol lookup for it because we do not know
                // whether the mono runtime is recent enough to have this variable.
                //
                data = bfd.LookupSymbol("MONO_DEBUGGER__using_debugger");
                if (data.IsNull)
                {
                    Report.Error("Failed to initialize the Mono runtime!");
                    return;
                }

                inferior.WriteInteger(data, 1);
                pending_mono_init = info;

                // Add a breakpoint in mini_debugger_init, to make sure that InitializeMono()
                // gets called in time to set the breakpoint at debugger_initialize, needed to
                // initialize the notifications.
                TargetAddress mini_debugger_init = bfd.LookupSymbol("mini_debugger_init");
                if (!mini_debugger_init.IsNull)
                {
                    Instruction insn = inferior.Architecture.ReadInstruction(inferior, mini_debugger_init);
                    if ((insn == null) || !insn.CanInterpretInstruction)
                    {
                        throw new InternalError("Unknown dynlink breakpoint: {0}", mini_debugger_init);
                    }

                    DynlinkBreakpoint init_breakpoint = new DynlinkBreakpoint(this, insn);
                    init_breakpoint.Insert(inferior);
                }
                return;
            }

            Process.InitializeMono(inferior, data);
        }
        void check_for_mono_runtime(Inferior inferior, Bfd bfd)
        {
            TargetAddress info = bfd.GetSectionAddress(".mdb_debug_info");

            if (info.IsNull)
            {
                return;
            }

            TargetAddress data = inferior.ReadAddress(info);

            if (data.IsNull)
            {
                //
                // See CheckForPendingMonoInit() below - this should only happen when
                // the Mono runtime is embedded - for instance Moonlight inside Firefox.
                //
                // Note that we have to do a symbol lookup for it because we do not know
                // whether the mono runtime is recent enough to have this variable.
                //
                data = bfd.LookupSymbol("MONO_DEBUGGER__using_debugger");
                if (data.IsNull)
                {
                    Report.Error("Failed to initialize the Mono runtime!");
                    return;
                }

                inferior.WriteInteger(data, 1);
                pending_mono_init = info;
                return;
            }

            Process.InitializeMono(inferior, data);
        }
        void check_nptl_setxid(Inferior inferior, Bfd bfd)
        {
            if (setxid_breakpoint != null)
            {
                return;
            }

            TargetAddress vtable = bfd.LookupSymbol("__libc_pthread_functions");

            if (vtable.IsNull)
            {
                return;
            }

            /*
             * Big big hack to allow debugging gnome-vfs:
             * We intercept any calls to __nptl_setxid() and make it
             * return 0.  This is safe to do since we do not allow
             * debugging setuid programs or running as root, so setxid()
             * will always be a no-op anyways.
             */

            TargetAddress nptl_setxid = inferior.ReadAddress(vtable + 51 * inferior.TargetAddressSize);

            if (!nptl_setxid.IsNull)
            {
                setxid_breakpoint = new SetXidBreakpoint(this, nptl_setxid);
                setxid_breakpoint.Insert(inferior);
            }
        }
示例#4
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);
        }
示例#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 check_for_mono_runtime(Inferior inferior, Bfd bfd)
        {
            TargetAddress info = bfd.LookupSymbol ("MONO_DEBUGGER__debugger_info_ptr");
            if (info.IsNull)
                return;

            TargetAddress data = inferior.ReadAddress (info);
            if (data.IsNull) {
                //
                // See CheckForPendingMonoInit() below - this should only happen when
                // the Mono runtime is embedded - for instance Moonlight inside Firefox.
                //
                // Note that we have to do a symbol lookup for it because we do not know
                // whether the mono runtime is recent enough to have this variable.
                //
                data = bfd.LookupSymbol ("MONO_DEBUGGER__using_debugger");
                if (data.IsNull) {
                    Report.Error ("Failed to initialize the Mono runtime!");
                    return;
                }

                inferior.WriteInteger (data, 1);
                pending_mono_init = info;

                // Add a breakpoint in mini_debugger_init, to make sure that InitializeMono()
                // gets called in time to set the breakpoint at debugger_initialize, needed to
                // initialize the notifications.
                TargetAddress mini_debugger_init = bfd.LookupSymbol ("mini_debugger_init");
                if (!mini_debugger_init.IsNull)
                {
                    Instruction insn = inferior.Architecture.ReadInstruction (inferior, mini_debugger_init);
                    if ((insn == null) || !insn.CanInterpretInstruction)
                        throw new InternalError ("Unknown dynlink breakpoint: {0}", mini_debugger_init);

                    DynlinkBreakpoint init_breakpoint = new DynlinkBreakpoint (this, insn);
                    init_breakpoint.Insert (inferior);
                }
                return;
            }

            Process.InitializeMono (inferior, data);
        }
示例#7
0
        void check_nptl_setxid(Inferior inferior, Bfd bfd)
        {
            if (setxid_breakpoint != null)
                return;

            TargetAddress vtable = bfd.LookupSymbol ("__libc_pthread_functions");
            if (vtable.IsNull)
                return;

            /*
             * Big big hack to allow debugging gnome-vfs:
             * We intercept any calls to __nptl_setxid() and make it
             * return 0.  This is safe to do since we do not allow
             * debugging setuid programs or running as root, so setxid()
             * will always be a no-op anyways.
             */

            TargetAddress nptl_setxid = inferior.ReadAddress (vtable + 51 * inferior.TargetAddressSize);

            if (!nptl_setxid.IsNull) {
                setxid_breakpoint = new SetXidBreakpoint (this, nptl_setxid);
                setxid_breakpoint.Insert (inferior);
            }
        }
示例#8
0
        void check_for_mono_runtime(Inferior inferior, Bfd bfd)
        {
            TargetAddress info = bfd.GetSectionAddress (".mdb_debug_info");
            if (info.IsNull)
                return;

            TargetAddress data = inferior.ReadAddress (info);
            if (data.IsNull) {
                //
                // See CheckForPendingMonoInit() below - this should only happen when
                // the Mono runtime is embedded - for instance Moonlight inside Firefox.
                //
                // Note that we have to do a symbol lookup for it because we do not know
                // whether the mono runtime is recent enough to have this variable.
                //
                data = bfd.LookupSymbol ("MONO_DEBUGGER__using_debugger");
                if (data.IsNull) {
                    Report.Error ("Failed to initialize the Mono runtime!");
                    return;
                }

                inferior.WriteInteger (data, 1);
                pending_mono_init = info;
                return;
            }

            Process.InitializeMono (inferior, data);
        }