ReadInteger() public method

public ReadInteger ( ) : int
return int
Ejemplo n.º 1
0
        void read_note_section()
        {
            threads = new ArrayList();
            foreach (Bfd.Section section in core_bfd.Sections)
            {
                if (!section.name.StartsWith(".reg/"))
                {
                    continue;
                }

                int            pid    = Int32.Parse(section.name.Substring(5));
                CoreFileThread thread = new CoreFileThread(this, pid);
                OnThreadCreatedEvent(thread);
                threads.Add(thread);
            }

#if FIXME
            TargetReader reader = core_bfd.GetSectionReader("note0");
            while (reader.Offset < reader.Size)
            {
                long offset = reader.Offset;
                int  namesz = reader.ReadInteger();
                int  descsz = reader.ReadInteger();
                int  type   = reader.ReadInteger();

                string name = null;
                if (namesz != 0)
                {
                    char[] namebuf = new char [namesz];
                    for (int i = 0; i < namesz; i++)
                    {
                        namebuf [i] = (char)reader.ReadByte();
                    }

                    name = new String(namebuf);
                }

                byte[] desc = null;
                if (descsz != 0)
                {
                    desc = reader.BinaryReader.ReadBuffer(descsz);
                }

                // Console.WriteLine ("NOTE: {0} {1:x} {2}", offset, type, name);
                // Console.WriteLine (TargetBinaryReader.HexDump (desc));

                reader.Offset += 4 - (reader.Offset % 4);
            }
#endif
        }
Ejemplo n.º 2
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");
                }
            }
        }
Ejemplo n.º 3
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;
            }
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
            }
        }
Ejemplo n.º 6
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");
            }
        }