gdb/moxie-tdep.c - gdb
Global variables defined
Data types defined
Functions defined
Macros defined
Source code
- #include "defs.h"
- #include "frame.h"
- #include "frame-unwind.h"
- #include "frame-base.h"
- #include "symtab.h"
- #include "gdbtypes.h"
- #include "gdbcmd.h"
- #include "gdbcore.h"
- #include "value.h"
- #include "inferior.h"
- #include "symfile.h"
- #include "objfiles.h"
- #include "osabi.h"
- #include "language.h"
- #include "arch-utils.h"
- #include "regcache.h"
- #include "trad-frame.h"
- #include "dis-asm.h"
- #include "record.h"
- #include "record-full.h"
- #include "moxie-tdep.h"
- extern void _initialize_moxie_tdep (void);
- enum { REG_UNAVAIL = (CORE_ADDR) -1 };
- struct moxie_frame_cache
- {
-
- CORE_ADDR base;
- CORE_ADDR pc;
- LONGEST framesize;
- CORE_ADDR saved_regs[MOXIE_NUM_REGS];
- CORE_ADDR saved_sp;
- };
- static CORE_ADDR
- moxie_frame_align (struct gdbarch *gdbarch, CORE_ADDR sp)
- {
-
- return sp & ~1;
- }
- static const unsigned char *
- moxie_breakpoint_from_pc (struct gdbarch *gdbarch,
- CORE_ADDR *pcptr, int *lenptr)
- {
- static unsigned char breakpoint[] = { 0x35, 0x00 };
- *lenptr = sizeof (breakpoint);
- return breakpoint;
- }
- char *moxie_register_names[] = {
- "$fp", "$sp", "$r0", "$r1", "$r2",
- "$r3", "$r4", "$r5", "$r6", "$r7",
- "$r8", "$r9", "$r10", "$r11", "$r12",
- "$r13", "$pc", "$cc" };
- static const char *
- moxie_register_name (struct gdbarch *gdbarch, int reg_nr)
- {
- if (reg_nr < 0)
- return NULL;
- if (reg_nr >= MOXIE_NUM_REGS)
- return NULL;
- return moxie_register_names[reg_nr];
- }
- static struct type *
- moxie_register_type (struct gdbarch *gdbarch, int reg_nr)
- {
- if (reg_nr == MOXIE_PC_REGNUM)
- return builtin_type (gdbarch)->builtin_func_ptr;
- else if (reg_nr == MOXIE_SP_REGNUM || reg_nr == MOXIE_FP_REGNUM)
- return builtin_type (gdbarch)->builtin_data_ptr;
- else
- return builtin_type (gdbarch)->builtin_int32;
- }
- static void
- moxie_store_return_value (struct type *type, struct regcache *regcache,
- const void *valbuf)
- {
- struct gdbarch *gdbarch = get_regcache_arch (regcache);
- enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- CORE_ADDR regval;
- int len = TYPE_LENGTH (type);
-
- regval = extract_unsigned_integer (valbuf, len > 4 ? 4 : len, byte_order);
- regcache_cooked_write_unsigned (regcache, RET1_REGNUM, regval);
- if (len > 4)
- {
- regval = extract_unsigned_integer ((gdb_byte *) valbuf + 4,
- len - 4, byte_order);
- regcache_cooked_write_unsigned (regcache, RET1_REGNUM + 1, regval);
- }
- }
- static CORE_ADDR
- moxie_analyze_prologue (CORE_ADDR start_addr, CORE_ADDR end_addr,
- struct moxie_frame_cache *cache,
- struct gdbarch *gdbarch)
- {
- enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- CORE_ADDR next_addr;
- ULONGEST inst, inst2;
- LONGEST offset;
- int regnum;
-
- cache->saved_regs[MOXIE_PC_REGNUM] = -4;
- cache->saved_regs[MOXIE_FP_REGNUM] = 0;
- cache->framesize = 0;
- if (start_addr >= end_addr)
- return end_addr;
- for (next_addr = start_addr; next_addr < end_addr; )
- {
- inst = read_memory_unsigned_integer (next_addr, 2, byte_order);
-
- if (inst >= 0x0612 && inst <= 0x061f)
- {
- regnum = inst & 0x000f;
- cache->framesize += 4;
- cache->saved_regs[regnum] = cache->framesize;
- next_addr += 2;
- }
- else
- break;
- }
- inst = read_memory_unsigned_integer (next_addr, 2, byte_order);
-
- if (inst == 0x01e0)
- {
- offset = read_memory_integer (next_addr + 2, 4, byte_order);
- inst2 = read_memory_unsigned_integer (next_addr + 6, 2, byte_order);
- if (inst2 == 0x291e)
- {
- cache->framesize += offset;
- }
- return (next_addr + 8);
- }
- else if ((inst & 0xff00) == 0x9100)
- {
- cache->framesize += (inst & 0x00ff);
- next_addr += 2;
- while (next_addr < end_addr)
- {
- inst = read_memory_unsigned_integer (next_addr, 2, byte_order);
- if ((inst & 0xff00) != 0x9100)
- break;
- cache->framesize += (inst & 0x00ff);
- next_addr += 2;
- }
- }
- return next_addr;
- }
- static CORE_ADDR
- moxie_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
- {
- CORE_ADDR func_addr = 0, func_end = 0;
- const char *func_name;
-
- if (find_pc_partial_function (pc, &func_name, &func_addr, &func_end))
- {
- CORE_ADDR post_prologue_pc
- = skip_prologue_using_sal (gdbarch, func_addr);
- if (post_prologue_pc != 0)
- return max (pc, post_prologue_pc);
- else
- {
-
- struct symtab_and_line sal;
- struct symbol *sym;
- struct moxie_frame_cache cache;
- CORE_ADDR plg_end;
- memset (&cache, 0, sizeof cache);
- plg_end = moxie_analyze_prologue (func_addr,
- func_end, &cache, gdbarch);
-
- sym = lookup_symbol (func_name, NULL, VAR_DOMAIN, NULL);
-
- if (sym && SYMBOL_LANGUAGE (sym) != language_asm)
- {
- sal = find_pc_line (func_addr, 0);
- if (sal.end && sal.end < func_end)
- {
-
- return sal.end;
- }
- }
-
- return plg_end;
- }
- }
-
- return (CORE_ADDR) pc;
- }
- struct moxie_unwind_cache
- {
-
- CORE_ADDR prev_sp;
-
- CORE_ADDR base;
- int size;
-
- LONGEST sp_offset;
- LONGEST r13_offset;
- int uses_frame;
-
- struct trad_frame_saved_reg *saved_regs;
- };
- static ULONGEST
- moxie_process_readu (CORE_ADDR addr, gdb_byte *buf,
- int length, enum bfd_endian byte_order)
- {
- if (target_read_memory (addr, buf, length))
- {
- if (record_debug)
- printf_unfiltered (_("Process record: error reading memory at "
- "addr 0x%s len = %d.\n"),
- paddress (target_gdbarch (), addr), length);
- return -1;
- }
- return extract_unsigned_integer (buf, length, byte_order);
- }
- #define INST2OFFSET(o) ((((signed short)((o & ((1<<10)-1))<<6))>>6)<<1)
- static int
- moxie_software_single_step (struct frame_info *frame)
- {
- struct gdbarch *gdbarch = get_frame_arch (frame);
- struct address_space *aspace = get_frame_address_space (frame);
- CORE_ADDR addr;
- gdb_byte buf[4];
- uint16_t inst;
- uint32_t tmpu32;
- ULONGEST fp;
- enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- struct regcache *regcache = get_current_regcache ();
- addr = get_frame_pc (frame);
- inst = (uint16_t) moxie_process_readu (addr, buf, 2, byte_order);
-
- if (inst & (1 << 15))
- {
- if (inst & (1 << 14))
- {
-
- int opcode = (inst >> 10 & 0xf);
- switch (opcode)
- {
- case 0x00:
- case 0x01:
- case 0x02:
- case 0x03:
- case 0x04:
- case 0x05:
- case 0x06:
- case 0x07:
- case 0x08:
- case 0x09:
-
- insert_single_step_breakpoint (gdbarch, aspace, addr + 2);
- insert_single_step_breakpoint (gdbarch, aspace, addr + 2 + INST2OFFSET(inst));
- break;
- default:
- {
-
- break;
- }
- }
- }
- else
- {
-
- insert_single_step_breakpoint (gdbarch, aspace, addr + 2);
- }
- }
- else
- {
-
- int opcode = inst >> 8;
- switch (opcode)
- {
-
- case 0x00:
- case 0x02:
- case 0x05:
- case 0x06:
- case 0x07:
- case 0x0a:
- case 0x0b:
- case 0x0e:
- case 0x0f:
- case 0x10:
- case 0x11:
- case 0x12:
- case 0x13:
- case 0x14:
- case 0x15:
- case 0x16:
- case 0x17:
- case 0x18:
- case 0x1c:
- case 0x1e:
- case 0x21:
- case 0x23:
- case 0x26:
- case 0x27:
- case 0x28:
- case 0x29:
- case 0x2a:
- case 0x2b:
- case 0x2c:
- case 0x2d:
- case 0x2e:
- case 0x2f:
- case 0x31:
- case 0x32:
- case 0x33:
- case 0x34:
- insert_single_step_breakpoint (gdbarch, aspace, addr + 2);
- break;
-
- case 0x0c:
- case 0x0d:
- case 0x36:
- case 0x37:
- case 0x38:
- case 0x39:
- insert_single_step_breakpoint (gdbarch, aspace, addr + 4);
- break;
-
- case 0x01:
- case 0x08:
- case 0x09:
- case 0x1b:
- case 0x1d:
- case 0x1f:
- case 0x20:
- case 0x22:
- case 0x24:
- insert_single_step_breakpoint (gdbarch, aspace, addr + 6);
- break;
-
- case 0x03:
- case 0x1a:
- insert_single_step_breakpoint (gdbarch, aspace,
- moxie_process_readu (addr + 2,
- buf, 4,
- byte_order));
- break;
- case 0x04:
- regcache_cooked_read_unsigned (regcache, MOXIE_FP_REGNUM, &fp);
- insert_single_step_breakpoint (gdbarch, aspace,
- moxie_process_readu (fp + 4,
- buf, 4,
- byte_order));
- break;
- case 0x19:
- case 0x25:
- regcache_raw_read (regcache,
- (inst >> 4) & 0xf, (gdb_byte *) & tmpu32);
- insert_single_step_breakpoint (gdbarch, aspace,
- tmpu32);
- break;
- case 0x30:
- case 0x35:
-
- break;
- }
- }
- return 1;
- }
- static CORE_ADDR
- moxie_read_pc (struct regcache *regcache)
- {
- ULONGEST pc;
- regcache_cooked_read_unsigned (regcache, MOXIE_PC_REGNUM, &pc);
- return pc;
- }
- static void
- moxie_write_pc (struct regcache *regcache, CORE_ADDR val)
- {
- regcache_cooked_write_unsigned (regcache, MOXIE_PC_REGNUM, val);
- }
- static CORE_ADDR
- moxie_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame)
- {
- return frame_unwind_register_unsigned (next_frame, MOXIE_SP_REGNUM);
- }
- static void
- moxie_extract_return_value (struct type *type, struct regcache *regcache,
- void *dst)
- {
- struct gdbarch *gdbarch = get_regcache_arch (regcache);
- enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- bfd_byte *valbuf = dst;
- int len = TYPE_LENGTH (type);
- ULONGEST tmp;
-
- regcache_cooked_read_unsigned (regcache, RET1_REGNUM, &tmp);
- store_unsigned_integer (valbuf, (len > 4 ? len - 4 : len), byte_order, tmp);
-
- if (len > 4)
- {
- regcache_cooked_read_unsigned (regcache, RET1_REGNUM + 1, &tmp);
- store_unsigned_integer (valbuf + len - 4, 4, byte_order, tmp);
- }
- }
- static enum return_value_convention
- moxie_return_value (struct gdbarch *gdbarch, struct value *function,
- struct type *valtype, struct regcache *regcache,
- gdb_byte *readbuf, const gdb_byte *writebuf)
- {
- if (TYPE_LENGTH (valtype) > 8)
- return RETURN_VALUE_STRUCT_CONVENTION;
- else
- {
- if (readbuf != NULL)
- moxie_extract_return_value (valtype, regcache, readbuf);
- if (writebuf != NULL)
- moxie_store_return_value (valtype, regcache, writebuf);
- return RETURN_VALUE_REGISTER_CONVENTION;
- }
- }
- static struct moxie_frame_cache *
- moxie_alloc_frame_cache (void)
- {
- struct moxie_frame_cache *cache;
- int i;
- cache = FRAME_OBSTACK_ZALLOC (struct moxie_frame_cache);
- cache->base = 0;
- cache->saved_sp = 0;
- cache->pc = 0;
- cache->framesize = 0;
- for (i = 0; i < MOXIE_NUM_REGS; ++i)
- cache->saved_regs[i] = REG_UNAVAIL;
- return cache;
- }
- static struct moxie_frame_cache *
- moxie_frame_cache (struct frame_info *this_frame, void **this_cache)
- {
- struct moxie_frame_cache *cache;
- CORE_ADDR current_pc;
- int i;
- if (*this_cache)
- return *this_cache;
- cache = moxie_alloc_frame_cache ();
- *this_cache = cache;
- cache->base = get_frame_register_unsigned (this_frame, MOXIE_FP_REGNUM);
- if (cache->base == 0)
- return cache;
- cache->pc = get_frame_func (this_frame);
- current_pc = get_frame_pc (this_frame);
- if (cache->pc)
- {
- struct gdbarch *gdbarch = get_frame_arch (this_frame);
- moxie_analyze_prologue (cache->pc, current_pc, cache, gdbarch);
- }
- cache->saved_sp = cache->base - cache->framesize;
- for (i = 0; i < MOXIE_NUM_REGS; ++i)
- if (cache->saved_regs[i] != REG_UNAVAIL)
- cache->saved_regs[i] = cache->base - cache->saved_regs[i];
- return cache;
- }
- static CORE_ADDR
- moxie_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
- {
- return frame_unwind_register_unsigned (next_frame, MOXIE_PC_REGNUM);
- }
- static void
- moxie_frame_this_id (struct frame_info *this_frame,
- void **this_prologue_cache, struct frame_id *this_id)
- {
- struct moxie_frame_cache *cache = moxie_frame_cache (this_frame,
- this_prologue_cache);
-
- if (cache->base == 0)
- return;
- *this_id = frame_id_build (cache->saved_sp, cache->pc);
- }
- static struct value *
- moxie_frame_prev_register (struct frame_info *this_frame,
- void **this_prologue_cache, int regnum)
- {
- struct moxie_frame_cache *cache = moxie_frame_cache (this_frame,
- this_prologue_cache);
- gdb_assert (regnum >= 0);
- if (regnum == MOXIE_SP_REGNUM && cache->saved_sp)
- return frame_unwind_got_constant (this_frame, regnum, cache->saved_sp);
- if (regnum < MOXIE_NUM_REGS && cache->saved_regs[regnum] != REG_UNAVAIL)
- return frame_unwind_got_memory (this_frame, regnum,
- cache->saved_regs[regnum]);
- return frame_unwind_got_register (this_frame, regnum, regnum);
- }
- static const struct frame_unwind moxie_frame_unwind = {
- NORMAL_FRAME,
- default_frame_unwind_stop_reason,
- moxie_frame_this_id,
- moxie_frame_prev_register,
- NULL,
- default_frame_sniffer
- };
- static CORE_ADDR
- moxie_frame_base_address (struct frame_info *this_frame, void **this_cache)
- {
- struct moxie_frame_cache *cache = moxie_frame_cache (this_frame,
- this_cache);
- return cache->base;
- }
- static const struct frame_base moxie_frame_base = {
- &moxie_frame_unwind,
- moxie_frame_base_address,
- moxie_frame_base_address,
- moxie_frame_base_address
- };
- static struct frame_id
- moxie_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
- {
- CORE_ADDR sp = get_frame_register_unsigned (this_frame, MOXIE_SP_REGNUM);
- return frame_id_build (sp, get_frame_pc (this_frame));
- }
- static int
- moxie_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
- CORE_ADDR addr)
- {
- gdb_byte buf[4];
- uint16_t inst;
- uint32_t tmpu32;
- enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- if (record_debug > 1)
- fprintf_unfiltered (gdb_stdlog, "Process record: moxie_process_record "
- "addr = 0x%s\n",
- paddress (target_gdbarch (), addr));
- inst = (uint16_t) moxie_process_readu (addr, buf, 2, byte_order);
-
- if (inst & (1 << 15))
- {
- if (inst & (1 << 14))
- {
-
- int opcode = (inst >> 10 & 0xf);
- switch (opcode)
- {
- case 0x00:
- case 0x01:
- case 0x02:
- case 0x03:
- case 0x04:
- case 0x05:
- case 0x06:
- case 0x07:
- case 0x08:
- case 0x09:
-
- break;
- default:
- {
-
- break;
- }
- }
- }
- else
- {
-
- int opcode = (inst >> 12 & 0x3);
- switch (opcode)
- {
- case 0x00:
- case 0x01:
- case 0x02:
- {
- int reg = (inst >> 8) & 0xf;
- if (record_full_arch_list_add_reg (regcache, reg))
- return -1;
- }
- break;
- case 0x03:
- {
-
- }
- break;
- default:
-
- break;
- }
- }
- }
- else
- {
-
- int opcode = inst >> 8;
- switch (opcode)
- {
- case 0x00:
-
- break;
- case 0x01:
- case 0x02:
- {
- int reg = (inst >> 4) & 0xf;
- if (record_full_arch_list_add_reg (regcache, reg))
- return -1;
- }
- break;
- case 0x03:
- {
- regcache_raw_read (regcache,
- MOXIE_SP_REGNUM, (gdb_byte *) & tmpu32);
- tmpu32 = extract_unsigned_integer ((gdb_byte *) & tmpu32,
- 4, byte_order);
- if (record_full_arch_list_add_reg (regcache, MOXIE_FP_REGNUM)
- || (record_full_arch_list_add_reg (regcache,
- MOXIE_SP_REGNUM))
- || record_full_arch_list_add_mem (tmpu32 - 12, 12))
- return -1;
- }
- break;
- case 0x04:
- {
- if (record_full_arch_list_add_reg (regcache, MOXIE_FP_REGNUM)
- || (record_full_arch_list_add_reg (regcache,
- MOXIE_SP_REGNUM)))
- return -1;
- }
- break;
- case 0x05:
- {
- int reg = (inst >> 4) & 0xf;
- if (record_full_arch_list_add_reg (regcache, reg))
- return -1;
- }
- break;
- case 0x06:
- {
- int reg = (inst >> 4) & 0xf;
- regcache_raw_read (regcache, reg, (gdb_byte *) & tmpu32);
- tmpu32 = extract_unsigned_integer ((gdb_byte *) & tmpu32,
- 4, byte_order);
- if (record_full_arch_list_add_reg (regcache, reg)
- || record_full_arch_list_add_mem (tmpu32 - 4, 4))
- return -1;
- }
- break;
- case 0x07:
- {
- int a = (inst >> 4) & 0xf;
- int b = inst & 0xf;
- if (record_full_arch_list_add_reg (regcache, a)
- || record_full_arch_list_add_reg (regcache, b))
- return -1;
- }
- break;
- case 0x08:
- {
- int reg = (inst >> 4) & 0xf;
- if (record_full_arch_list_add_reg (regcache, reg))
- return -1;
- }
- break;
- case 0x09:
- {
- tmpu32 = (uint32_t) moxie_process_readu (addr+2, buf,
- 4, byte_order);
- if (record_full_arch_list_add_mem (tmpu32, 4))
- return -1;
- }
- break;
- case 0x0a:
- {
- int reg = (inst >> 4) & 0xf;
- if (record_full_arch_list_add_reg (regcache, reg))
- return -1;
- }
- break;
- case 0x0b:
- {
- int reg = (inst >> 4) & 0xf;
- regcache_raw_read (regcache, reg, (gdb_byte *) & tmpu32);
- tmpu32 = extract_unsigned_integer ((gdb_byte *) & tmpu32,
- 4, byte_order);
- if (record_full_arch_list_add_mem (tmpu32, 4))
- return -1;
- }
- break;
- case 0x0c:
- {
- int reg = (inst >> 4) & 0xf;
- if (record_full_arch_list_add_reg (regcache, reg))
- return -1;
- }
- break;
- case 0x0d:
- {
- int reg = (inst >> 4) & 0xf;
- uint32_t offset = (((int16_t) moxie_process_readu (addr+2, buf, 2,
- byte_order)) << 16 ) >> 16;
- regcache_raw_read (regcache, reg, (gdb_byte *) & tmpu32);
- tmpu32 = extract_unsigned_integer ((gdb_byte *) & tmpu32,
- 4, byte_order);
- tmpu32 += offset;
- if (record_full_arch_list_add_mem (tmpu32, 4))
- return -1;
- }
- break;
- case 0x0e:
- {
- if (record_full_arch_list_add_reg (regcache, MOXIE_CC_REGNUM))
- return -1;
- }
- break;
- case 0x0f:
- {
-
- break;
- }
- case 0x10:
- case 0x11:
- case 0x12:
- case 0x13:
- case 0x14:
- case 0x15:
- {
- int reg = (inst >> 4) & 0xf;
- if (record_full_arch_list_add_reg (regcache, reg))
- return -1;
- }
- break;
- case 0x16:
- case 0x17:
- case 0x18:
- {
-
- break;
- }
- case 0x19:
- {
- regcache_raw_read (regcache,
- MOXIE_SP_REGNUM, (gdb_byte *) & tmpu32);
- tmpu32 = extract_unsigned_integer ((gdb_byte *) & tmpu32,
- 4, byte_order);
- if (record_full_arch_list_add_reg (regcache, MOXIE_FP_REGNUM)
- || (record_full_arch_list_add_reg (regcache,
- MOXIE_SP_REGNUM))
- || record_full_arch_list_add_mem (tmpu32 - 12, 12))
- return -1;
- }
- break;
- case 0x1a:
- {
-
- }
- break;
- case 0x1b:
- case 0x1c:
- case 0x1d:
- {
- int reg = (inst >> 4) & 0xf;
- if (record_full_arch_list_add_reg (regcache, reg))
- return -1;
- }
- break;
- case 0x1e:
- {
- int reg = (inst >> 4) & 0xf;
- regcache_raw_read (regcache, reg, (gdb_byte *) & tmpu32);
- tmpu32 = extract_unsigned_integer ((gdb_byte *) & tmpu32,
- 4, byte_order);
- if (record_full_arch_list_add_mem (tmpu32, 1))
- return -1;
- }
- break;
- case 0x1f:
- {
- tmpu32 = moxie_process_readu (addr+2, buf, 4, byte_order);
- if (record_full_arch_list_add_mem (tmpu32, 1))
- return -1;
- }
- break;
- case 0x20:
- case 0x21:
- case 0x22:
- {
- int reg = (inst >> 4) & 0xf;
- if (record_full_arch_list_add_reg (regcache, reg))
- return -1;
- }
- break;
- case 0x23:
- {
- int reg = (inst >> 4) & 0xf;
- regcache_raw_read (regcache, reg, (gdb_byte *) & tmpu32);
- tmpu32 = extract_unsigned_integer ((gdb_byte *) & tmpu32,
- 4, byte_order);
- if (record_full_arch_list_add_mem (tmpu32, 2))
- return -1;
- }
- break;
- case 0x24:
- {
- tmpu32 = moxie_process_readu (addr+2, buf, 4, byte_order);
- if (record_full_arch_list_add_mem (tmpu32, 2))
- return -1;
- }
- break;
- case 0x25:
- {
-
- }
- break;
- case 0x26:
- case 0x27:
- case 0x28:
- case 0x29:
- case 0x2a:
- case 0x2b:
- case 0x2c:
- case 0x2d:
- case 0x2e:
- case 0x2f:
- {
- int reg = (inst >> 4) & 0xf;
- if (record_full_arch_list_add_reg (regcache, reg))
- return -1;
- }
- break;
- case 0x30:
- {
-
- int inum = moxie_process_readu (addr+2, buf, 4, byte_order);
- switch (inum)
- {
- case 0x1:
- {
-
- }
- break;
- case 0x2:
- {
- if (record_full_arch_list_add_reg (regcache, RET1_REGNUM))
- return -1;
- }
- break;
- case 0x4:
- {
- uint32_t length, ptr;
-
- regcache_raw_read (regcache, 3, (gdb_byte *) & ptr);
- ptr = extract_unsigned_integer ((gdb_byte *) & ptr,
- 4, byte_order);
-
- regcache_raw_read (regcache,
- MOXIE_FP_REGNUM, (gdb_byte *) & tmpu32);
- tmpu32 = extract_unsigned_integer ((gdb_byte *) & tmpu32,
- 4, byte_order);
- length = moxie_process_readu (tmpu32+20, buf, 4, byte_order);
- if (record_full_arch_list_add_mem (ptr, length))
- return -1;
- }
- break;
- case 0x5:
- {
- if (record_full_arch_list_add_reg (regcache, RET1_REGNUM))
- return -1;
- }
- break;
- default:
- break;
- }
- }
- break;
- case 0x31:
- case 0x32:
- case 0x33:
- case 0x34:
- {
- int reg = (inst >> 4) & 0xf;
- if (record_full_arch_list_add_reg (regcache, reg))
- return -1;
- }
- break;
- case 0x35:
-
- break;
- case 0x36:
- {
- int reg = (inst >> 4) & 0xf;
- if (record_full_arch_list_add_reg (regcache, reg))
- return -1;
- }
- break;
- case 0x37:
- {
- int reg = (inst >> 4) & 0xf;
- uint32_t offset = (((int16_t) moxie_process_readu (addr+2, buf, 2,
- byte_order)) << 16 ) >> 16;
- regcache_raw_read (regcache, reg, (gdb_byte *) & tmpu32);
- tmpu32 = extract_unsigned_integer ((gdb_byte *) & tmpu32,
- 4, byte_order);
- tmpu32 += offset;
- if (record_full_arch_list_add_mem (tmpu32, 1))
- return -1;
- }
- break;
- case 0x38:
- {
- int reg = (inst >> 4) & 0xf;
- if (record_full_arch_list_add_reg (regcache, reg))
- return -1;
- }
- break;
- case 0x39:
- {
- int reg = (inst >> 4) & 0xf;
- uint32_t offset = (((int16_t) moxie_process_readu (addr+2, buf, 2,
- byte_order)) << 16 ) >> 16;
- regcache_raw_read (regcache, reg, (gdb_byte *) & tmpu32);
- tmpu32 = extract_unsigned_integer ((gdb_byte *) & tmpu32,
- 4, byte_order);
- tmpu32 += offset;
- if (record_full_arch_list_add_mem (tmpu32, 2))
- return -1;
- }
- break;
- default:
-
- break;
- }
- }
- if (record_full_arch_list_add_reg (regcache, MOXIE_PC_REGNUM))
- return -1;
- if (record_full_arch_list_add_end ())
- return -1;
- return 0;
- }
- static struct gdbarch *
- moxie_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
- {
- struct gdbarch *gdbarch;
- struct gdbarch_tdep *tdep;
-
- arches = gdbarch_list_lookup_by_info (arches, &info);
- if (arches != NULL)
- return arches->gdbarch;
-
- tdep = XNEW (struct gdbarch_tdep);
- gdbarch = gdbarch_alloc (&info, tdep);
- set_gdbarch_read_pc (gdbarch, moxie_read_pc);
- set_gdbarch_write_pc (gdbarch, moxie_write_pc);
- set_gdbarch_unwind_sp (gdbarch, moxie_unwind_sp);
- set_gdbarch_num_regs (gdbarch, MOXIE_NUM_REGS);
- set_gdbarch_sp_regnum (gdbarch, MOXIE_SP_REGNUM);
- set_gdbarch_pc_regnum (gdbarch, MOXIE_PC_REGNUM);
- set_gdbarch_register_name (gdbarch, moxie_register_name);
- set_gdbarch_register_type (gdbarch, moxie_register_type);
- set_gdbarch_return_value (gdbarch, moxie_return_value);
- set_gdbarch_skip_prologue (gdbarch, moxie_skip_prologue);
- set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
- set_gdbarch_breakpoint_from_pc (gdbarch, moxie_breakpoint_from_pc);
- set_gdbarch_frame_align (gdbarch, moxie_frame_align);
- frame_base_set_default (gdbarch, &moxie_frame_base);
-
- set_gdbarch_dummy_id (gdbarch, moxie_dummy_id);
- set_gdbarch_unwind_pc (gdbarch, moxie_unwind_pc);
- set_gdbarch_print_insn (gdbarch, print_insn_moxie);
-
- gdbarch_init_osabi (info, gdbarch);
-
- frame_unwind_append_unwinder (gdbarch, &moxie_frame_unwind);
-
- set_gdbarch_software_single_step (gdbarch, moxie_software_single_step);
-
- set_gdbarch_overlay_update (gdbarch, simple_overlay_update);
-
- set_gdbarch_process_record (gdbarch, moxie_process_record);
- return gdbarch;
- }
- void
- _initialize_moxie_tdep (void)
- {
- register_gdbarch_init (bfd_arch_moxie, moxie_gdbarch_init);
- }