Exemplo n.º 1
0
 public AssemblerLine(string label, TargetAddress address, byte size, string text)
 {
     this.Label = label;
     this.Address = address;
     this.InstructionSize = size;
     this.Text = text;
 }
Exemplo n.º 2
0
        public TargetMemoryArea(TargetAddress start, TargetAddress end,
					 TargetMemoryFlags flags, string name)
        {
            this.start = start;
            this.end = end;
            this.flags = flags;
            this.name = name;
        }
Exemplo n.º 3
0
        public StepFrame(Language language, StepMode mode, StackFrame stack,
				  TargetAddress start, TargetAddress end)
        {
            this.start = start;
            this.end = end;
            this.stack = stack;
            this.language = language;
            this.mode = mode;
        }
Exemplo n.º 4
0
        public LineEntry(TargetAddress address, int file, int line, bool is_hidden,
				  SourceRange? source_range)
        {
            this.Address = address;;
            this.File = file;
            this.Line = line;
            this.IsHidden = is_hidden;
            this.SourceRange = source_range;
        }
Exemplo n.º 5
0
        public Register(Registers registers, string name, int index, int size,
				 bool valid, long value)
        {
            this.registers = registers;
            this.Name = name;
            this.Index = index;
            this.Size = size;
            this.valid = valid;
            this.value = value;
            this.addr_on_stack = TargetAddress.Null;
        }
Exemplo n.º 6
0
        public override bool GetTrampoline(TargetMemoryAccess memory, TargetAddress address,
						    out TargetAddress trampoline, out bool is_start)
        {
            foreach (Bfd bfd in bfd_hash.Values) {
                if (bfd.GetTrampoline (memory, address, out trampoline, out is_start))
                    return true;
            }

            is_start = false;
            trampoline = TargetAddress.Null;
            return false;
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        internal bool CheckException(MonoLanguageBackend mono, TargetMemoryAccess target,
					      TargetAddress address)
        {
            TargetClassObject exc = mono.CreateObject (target, address) as TargetClassObject;
            if (exc == null)
                return false; // OOOPS

            if (exception == null)
                exception = mono.LookupType (Name);
            if (exception == null)
                return false;

            return IsSubclassOf (target, exc.Type, exception);
        }
Exemplo n.º 9
0
        public override NativeExecutableReader AddExecutableFile(Inferior inferior, string filename,
									  TargetAddress base_address, bool step_into,
									  bool is_loaded)
        {
            check_disposed ();
            Bfd bfd = (Bfd) bfd_hash [filename];
            if (bfd != null)
                return bfd;

            bfd = new Bfd (this, inferior.TargetMemoryInfo, filename, base_address, is_loaded);
            bfd_hash.Add (filename, bfd);
            check_loaded_library (inferior, bfd);
            return bfd;
        }
Exemplo n.º 10
0
        public override AssemblyLine[] GetLines(long startAddr, long endAddr)
        {
            List <AssemblyLine> lines = new List <AssemblyLine> ();

            MD.TargetAddress addr = baseAddr + (startAddr - baseAddr.Address);
            while (addr.Address <= endAddr)
            {
                try {
                    MD.AssemblerLine line = thread.DisassembleInstruction(null, addr);
                    lines.Add(new AssemblyLine(addr.Address, line.Text));
                    addr += line.InstructionSize;
                } catch {
                    Console.WriteLine("failed " + addr.Address);
                    lines.Add(new AssemblyLine(addr.Address, "??"));
                    addr++;
                }
            }
            return(lines.ToArray());
        }
Exemplo n.º 11
0
        public override AssemblerLine DisassembleInstruction(TargetMemoryAccess memory,
								      Method method,
								      TargetAddress address)
        {
            lock (this) {
                memory_exception = null;
                sb = new StringBuilder ();

                address = new TargetAddress (memory.AddressDomain, address.Address);

                string insn;
                int insn_size;
                try {
                    this.memory = memory;
                    current_method = method;
                    insn_size = bfd_glue_disassemble_insn (handle, address.Address);
                    if (memory_exception != null)
                        return null;
                    insn = sb.ToString ();
                } finally {
                    sb = null;
                    this.memory = null;
                    memory_exception = null;
                    current_method = null;
                }

                Symbol label = null;
                if (process != null)
                    label = process.SymbolTableManager.SimpleLookup (address, true);

                string label_name = null;
                if (label != null)
                    label_name = label.ToString ();

                return new AssemblerLine (
                    label_name, address, (byte) insn_size, insn);
            }
        }
Exemplo n.º 12
0
        public override int GetInstructionSize(TargetMemoryAccess memory, TargetAddress address)
        {
            memory_exception = null;

            try {
                this.memory = memory;
                int count = bfd_glue_disassemble_insn (handle, address.Address);
                if (memory_exception != null)
                    throw memory_exception;
                return count;
            } finally {
                this.memory = null;
                memory_exception = null;
            }
        }
Exemplo n.º 13
0
 public InitializeBreakpoint(MonoThreadManager manager, TargetAddress address)
     : base("initialize", ThreadGroup.System, address)
 {
     this.manager = manager;
 }
Exemplo n.º 14
0
 public abstract Symbol SimpleLookup(TargetAddress address, bool exact_match);
Exemplo n.º 15
0
 public abstract byte ReadByte(TargetAddress address);
Exemplo n.º 16
0
 public void WriteAddress(TargetAddress address)
 {
     if (AddressSize == 8)
         WriteInt64 (address.Address);
     else
         WriteInt32 ((int) address.Address);
 }
Exemplo n.º 17
0
 internal AddressBreakpoint(HardwareWatchType type, TargetAddress address)
     : base(GetEventType (type), address.ToString (), ThreadGroup.Global)
 {
     this.address = address;
 }
Exemplo n.º 18
0
 public abstract NativeExecutableReader LookupLibrary(TargetAddress address);
Exemplo n.º 19
0
 public abstract void WriteLongInteger(TargetAddress address, long value);
Exemplo n.º 20
0
 public abstract void WriteInteger(TargetAddress address, int value);
Exemplo n.º 21
0
 public abstract void WriteByte(TargetAddress address, byte value);
Exemplo n.º 22
0
 public abstract void WriteBuffer(TargetAddress address, byte[] buffer);
Exemplo n.º 23
0
 public abstract byte[] ReadBuffer(TargetAddress address, int size);
Exemplo n.º 24
0
 public abstract TargetBlob ReadMemory(TargetAddress address, int size);
Exemplo n.º 25
0
 public abstract string ReadString(TargetAddress address);
Exemplo n.º 26
0
 int read_memory_func(long address, IntPtr data, int size)
 {
     try {
         TargetAddress location = new TargetAddress (
             memory.AddressDomain, address);
         byte[] buffer = memory.ReadBuffer (location, size);
         Marshal.Copy (buffer, 0, data, size);
     } catch (Exception e) {
         memory_exception = e;
         return 1;
     }
     return 0;
 }
Exemplo n.º 27
0
        public abstract NativeExecutableReader AddExecutableFile(Inferior inferior, string filename,
									  TargetAddress base_address,
									  bool step_info, bool is_loaded);
Exemplo n.º 28
0
 public abstract void WriteAddress(TargetAddress address, TargetAddress value);
Exemplo n.º 29
0
 public abstract TargetAddress ReadAddress(TargetAddress address);
Exemplo n.º 30
0
 public TargetMemoryException(TargetAddress address)
     : this(String.Format("Cannot read target memory at address {0:x}", address))
 {
 }
Exemplo n.º 31
0
        // <summary>
        //   Get the size of the current instruction.
        // </summary>
        public abstract int GetInstructionSize(TargetMemoryAccess memory,
							TargetAddress address);
Exemplo n.º 32
0
 public TargetMemoryException(TargetAddress address, int size)
     : this(String.Format("Cannot read {1} bytes from target memory at address {0:x}",
                          address, size))
 {
 }
Exemplo n.º 33
0
 public abstract int ReadInteger(TargetAddress address);
Exemplo n.º 34
0
 public TargetMemoryReadOnlyException(TargetAddress address)
     : base(String.Format("Can't write to target memory at address 0x{0:x}: {1}",
                          address, "the current target's memory is read-only"))
 {
 }
Exemplo n.º 35
0
 public Symbol SimpleLookup(TargetAddress address, bool exact_match)
 {
     return(SymbolFile.SimpleLookup(address, exact_match));
 }
Exemplo n.º 36
0
 public void SetValue(TargetAddress address, long value)
 {
     this.valid         = true;
     this.addr_on_stack = address;
     this.value         = value;
 }
Exemplo n.º 37
0
 internal void InitCodeBuffer(Inferior inferior, TargetAddress code_buffer)
 {
     HasCodeBuffer = true;
     mono_debugger_server_initialize_code_buffer (
         mono_runtime_info, code_buffer.Address,
         debugger_info.ExecutableCodeBufferSize);
 }
Exemplo n.º 38
0
 public void SetValue(TargetAddress value)
 {
     this.valid         = true;
     this.addr_on_stack = TargetAddress.Null;
     this.value         = value.Address;
 }
Exemplo n.º 39
0
 public override bool CheckBreakpointHit(Thread target, TargetAddress address)
 {
     return true;
 }
Exemplo n.º 40
0
 // <summary>
 //   Disassemble one instruction.
 //   If @imethod is non-null, it specifies the current method which will
 //   be used to lookup function names from trampoline calls.
 // </summary>
 public abstract AssemblerLine DisassembleInstruction(TargetMemoryAccess memory,
                                                      Method method,
                                                      TargetAddress address);
Exemplo n.º 41
0
        void print_address_func(long address)
        {
            TargetAddress maddress = new TargetAddress (
                memory.AddressDomain, address);

            if (current_method != null) {
                try {
                    MethodSource method = current_method.GetTrampoline (
                        memory, maddress);

                    if (method != null) {
                        output_func (method.Name);
                        return;
                    }
                } catch (TargetException) {
                }
            }

            Symbol name = null;
            if (process != null)
                name = process.SymbolTableManager.SimpleLookup (maddress, false);

            if (name == null)
                output_func (address);
            else
                output_func (String.Format ("0x{0:x}:{1}", address, name.ToString ()));
        }
Exemplo n.º 42
0
 public MdbDissassemblyBuffer(MD.Thread thread, MD.TargetAddress addr) : base(addr.Address)
 {
     this.thread   = thread;
     this.baseAddr = addr;
 }
Exemplo n.º 43
0
 public AssemblerLine(TargetAddress address, byte size, string text)
     : this(null, address, size, text)
 {
 }
Exemplo n.º 44
0
 public AssemblerLine(TargetAddress address, byte size, string text)
     : this(null, address, size, text)
 {
 }
Exemplo n.º 45
0
        public abstract bool GetTrampoline(TargetMemoryAccess memory, TargetAddress address,
						    out TargetAddress trampoline, out bool is_start);
Exemplo n.º 46
0
 public Symbol(string name, TargetAddress address, int offset)
 {
     this.Name = name;
     this.Address = address;
     this.Offset = offset;
 }
Exemplo n.º 47
0
        protected override TargetObject DoEvaluateObject(ScriptingContext context)
        {
            StackFrame frame = context.CurrentFrame;
            Register register = frame.Registers [name];
            if (register == null)
                throw new ScriptingException ("No such register `{0}'.", name);

            try {
                long value = register.Value;
                TargetAddress address = new TargetAddress (
                    context.AddressDomain, value);
                return context.CurrentLanguage.CreatePointer (frame, address);
            } catch {
                throw new ScriptingException (
                    "Can't access register `{0}' selected stack frame.", name);
            }
        }
Exemplo n.º 48
0
 public abstract long ReadLongInteger(TargetAddress address);
Exemplo n.º 49
0
 public SymbolRangeEntry(TargetAddress start, TargetAddress end)
 {
     this.start = start;
     this.end   = end;
 }
Exemplo n.º 50
0
 protected SymbolTable(TargetAddress start_address, TargetAddress end_address)
 {
     this.is_continuous = true;
     this.start_address = start_address;
     this.end_address   = end_address;
 }
Exemplo n.º 51
0
        internal void InitializeMono(Inferior inferior, TargetAddress mdb_debug_info)
        {
            MonoRuntimeFound = true;
            mono_manager = MonoThreadManager.Initialize (this, inferior, mdb_debug_info, is_attached);

            InitializeThreads (inferior, !is_attached);

            if (mono_manager == null)
                return;

            mono_manager.InitializeThreads (inferior);

            if (is_attached)
                mono_manager.InitializeAfterAttach (inferior);
        }
Exemplo n.º 52
0
 internal abstract void InsertBreakpoint(BreakpointHandle breakpoint,
                                         TargetAddress address, int domain);
Exemplo n.º 53
0
 internal AddressBreakpoint(string name, ThreadGroup group, TargetAddress address)
     : base(EventType.Breakpoint, name, group)
 {
     this.address = address;
 }
Exemplo n.º 54
0
 public StepFrame(Language language, StepMode mode, TargetAddress until)
     : this(language, mode, null, TargetAddress.Null, until)
 {
 }
Exemplo n.º 55
0
        // <summary>
        //   Disassemble one instruction.
        //   If @imethod is non-null, it specifies the current method which will
        //   be used to lookup function names from trampoline calls.
        // </summary>
        public abstract AssemblerLine DisassembleInstruction(TargetMemoryAccess memory,
								      Method method,
								      TargetAddress address);
Exemplo n.º 56
0
 public abstract SourceAddress Lookup(TargetAddress address);
Exemplo n.º 57
0
 public void PokeAddress(TargetAddress address)
 {
     PokeAddress (pos, address.Address);
 }
Exemplo n.º 58
0
 public override bool CheckBreakpointHit(Thread target, TargetAddress address)
 {
     return(target.Process.ProcessStart.StopInMain);
 }
Exemplo n.º 59
0
 public int InsertHardwareWatchPoint(Thread target, TargetAddress address)
 {
     Event handle = target.Process.Session.InsertHardwareWatchPoint (
         target, address, HardwareWatchType.WatchWrite);
     return handle.Index;
 }
Exemplo n.º 60
0
 // <summary>
 //   Get the size of the current instruction.
 // </summary>
 public abstract int GetInstructionSize(TargetMemoryAccess memory,
                                        TargetAddress address);