This is just an address, but its lifetime is tied to the lifetime of another location.
Inheritance: TargetLocation
Ejemplo n.º 1
0
            TargetLocation GetLocation(StackFrame frame, TargetMemoryAccess memory,
						    byte[] data)
            {
                TargetBinaryReader locreader = new TargetBinaryReader (
                    data, comp_unit.DwarfReader.TargetMemoryInfo);

                byte opcode = locreader.ReadByte ();
                bool is_regoffset;
                int reg, off;

                if ((opcode >= 0x50) && (opcode <= 0x6f)) { // DW_OP_reg
                    reg = opcode - 0x50 + 3;
                    off = 0;
                    is_regoffset = false;
                } else if ((opcode >= 0x70) && (opcode <= 0x8f)) { // DW_OP_breg
                    reg = opcode - 0x70 + 3;
                    off = locreader.ReadSLeb128 ();
                    is_regoffset = true;
                } else if (opcode == 0x90) { // DW_OP_regx
                    reg = locreader.ReadLeb128 () + 3;
                    off = 0;
                    is_regoffset = false;
                } else if (opcode == 0x91) { // DW_OP_fbreg
                    off = locreader.ReadSLeb128 ();

                    if (frame_base != null) {
                        TargetLocation rloc = new RelativeTargetLocation (
                            frame_base.GetLocation (frame, memory), off);
                        if (is_byref)
                            return new DereferencedTargetLocation (rloc);
                        else
                            return rloc;
                    } else {
                        is_regoffset = true;
                        reg = 2;
                    }
                } else if (opcode == 0x92) { // DW_OP_bregx
                    reg = locreader.ReadLeb128 () + 3;
                    off = locreader.ReadSLeb128 ();
                    is_regoffset = true;
                } else if (opcode == 0x03) { // DW_OP_addr
                    TargetAddress addr = new TargetAddress (
                        memory.AddressDomain, locreader.ReadAddress ());
                    TargetLocation aloc = new AbsoluteTargetLocation (addr);
                    if (is_byref)
                        return new DereferencedTargetLocation (aloc);
                    else
                        return aloc;
                } else {
                    Console.WriteLine ("UNKNOWN OPCODE: {0:x}", opcode);
                    return null;
                }

                reg = comp_unit.DwarfReader.bfd.Architecture.DwarfFrameRegisterMap [reg];

                MonoVariableLocation loc = MonoVariableLocation.Create (
                    memory, is_regoffset, frame.Registers [reg],
                    off, is_byref);

                if (!locreader.IsEof) {
                    Console.WriteLine ("LOCREADER NOT AT EOF!");
                    return null;
                }

                return loc;
            }
Ejemplo n.º 2
0
            public TargetLocation GetLocation(TargetLocation location)
            {
                if (location_block == null)
                    throw new NotImplementedException ();

                TargetBinaryReader locreader = new TargetBinaryReader (
                    location_block, comp_unit.DwarfReader.TargetMemoryInfo);

                byte opcode = locreader.ReadByte ();

                if (opcode == 0x23) // DW_OP_plus_uconst
                    location = new RelativeTargetLocation (location, locreader.ReadLeb128 ());
                else {
                    Console.WriteLine ("UNKNOWN OPCODE: {0:x}", opcode);
                    return null;
                }

                if (!locreader.IsEof) {
                    Console.WriteLine ("LOCREADER NOT AT EOF!");
                    return null;
                }

                return location;
            }