X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gdb%2Fh8300-tdep.c;h=0f58553d955581152c20aff07e6f311b8782f3af;hb=fab39d55fa914ad1cea809848899c76c64eaab9d;hp=4c9ed153dd1ede4e42d43232077d51e4c8fb6f47;hpb=7b6bb8daaceb9ecf3f42dea57ae82733d6a3b2f6;p=platform%2Fupstream%2Fbinutils.git diff --git a/gdb/h8300-tdep.c b/gdb/h8300-tdep.c index 4c9ed15..0f58553 100644 --- a/gdb/h8300-tdep.c +++ b/gdb/h8300-tdep.c @@ -1,8 +1,6 @@ /* Target-machine dependent code for Renesas H8/300, for GDB. - Copyright (C) 1988, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, - 2000, 2001, 2002, 2003, 2005, 2007, 2008, 2009, 2010, 2011 - Free Software Foundation, Inc. + Copyright (C) 1988-2014 Free Software Foundation, Inc. This file is part of GDB. @@ -30,7 +28,6 @@ #include "regcache.h" #include "gdbcore.h" #include "objfiles.h" -#include "gdb_assert.h" #include "dis-asm.h" #include "dwarf2-frame.h" #include "frame-base.h" @@ -71,7 +68,7 @@ struct h8300_frame_cache CORE_ADDR sp_offset; CORE_ADDR pc; - /* Flag showing that a frame has been created in the prologue code. */ + /* Flag showing that a frame has been created in the prologue code. */ int uses_fp; /* Saved registers. */ @@ -147,7 +144,7 @@ h8300_init_frame_cache (struct gdbarch *gdbarch, #define IS_MOVW_Rn16_SP(x) (((x) & 0xfff0) == 0x6fe0) #define IS_MOVW_EXT(x) ((x) == 0x78e0) #define IS_MOVW_Rn24_SP(x) (((x) & 0xfff0) == 0x6ba0) -/* Same instructions as mov.w, just prefixed with 0x0100 */ +/* Same instructions as mov.w, just prefixed with 0x0100. */ #define IS_MOVL_PRE(x) ((x) == 0x0100) #define IS_MOVL_Rn16_SP(x) (((x) & 0xfff0) == 0x6fe0) #define IS_MOVL_EXT(x) ((x) == 0x78e0) @@ -431,7 +428,6 @@ h8300_frame_cache (struct frame_info *this_frame, void **this_cache) { struct gdbarch *gdbarch = get_frame_arch (this_frame); struct h8300_frame_cache *cache; - char buf[4]; int i; CORE_ADDR current_pc; @@ -526,6 +522,7 @@ h8300_frame_prev_register (struct frame_info *this_frame, void **this_cache, static const struct frame_unwind h8300_frame_unwind = { NORMAL_FRAME, + default_frame_unwind_stop_reason, h8300_frame_this_id, h8300_frame_prev_register, NULL, @@ -667,13 +664,15 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (argument = 0; argument < nargs; argument++) { + struct cleanup *back_to; struct type *type = value_type (args[argument]); int len = TYPE_LENGTH (type); char *contents = (char *) value_contents (args[argument]); /* Pad the argument appropriately. */ int padded_len = align_up (len, wordsize); - gdb_byte *padded = alloca (padded_len); + gdb_byte *padded = xmalloc (padded_len); + back_to = make_cleanup (xfree, padded); memset (padded, 0, padded_len); memcpy (len < wordsize ? padded + padded_len - len : padded, @@ -698,9 +697,8 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function, else { /* Heavens to Betsy --- it's really going in registers! - It would be nice if we could use write_register_bytes - here, but on the h8/300s, there are gaps between - the registers in the register file. */ + Note that on the h8/300s, there are gaps between the + registers in the register file. */ int offset; for (offset = 0; offset < padded_len; offset += wordsize) @@ -722,6 +720,8 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function, subsequent arguments go on the stack. */ reg = E_ARGLAST_REGNUM + 1; } + + do_cleanups (back_to); } /* Store return address. */ @@ -771,7 +771,7 @@ h8300_extract_return_value (struct type *type, struct regcache *regcache, } else { - error ("I don't know how this 8 byte value is returned."); + error (_("I don't know how this 8 byte value is returned.")); } break; } @@ -783,16 +783,15 @@ h8300h_extract_return_value (struct type *type, struct regcache *regcache, { struct gdbarch *gdbarch = get_regcache_arch (regcache); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - int len = TYPE_LENGTH (type); - ULONGEST c, addr; + ULONGEST c; - switch (len) + switch (TYPE_LENGTH (type)) { case 1: case 2: case 4: regcache_cooked_read_unsigned (regcache, E_RET0_REGNUM, &c); - store_unsigned_integer (valbuf, len, byte_order, c); + store_unsigned_integer (valbuf, TYPE_LENGTH (type), byte_order, c); break; case 8: /* long long is now 8 bytes. */ if (TYPE_CODE (type) == TYPE_CODE_INT) @@ -805,7 +804,7 @@ h8300h_extract_return_value (struct type *type, struct regcache *regcache, } else { - error ("I don't know how this 8 byte value is returned."); + error (_("I don't know how this 8 byte value is returned.")); } break; } @@ -815,7 +814,7 @@ static int h8300_use_struct_convention (struct type *value_type) { /* Types of 1, 2 or 4 bytes are returned in R0/R1, everything else on the - stack. */ + stack. */ if (TYPE_CODE (value_type) == TYPE_CODE_STRUCT || TYPE_CODE (value_type) == TYPE_CODE_UNION) @@ -829,7 +828,7 @@ static int h8300h_use_struct_convention (struct type *value_type) { /* Types of 1, 2 or 4 bytes are returned in R0, INT types of 8 bytes are - returned in R0/R1, everything else on the stack. */ + returned in R0/R1, everything else on the stack. */ if (TYPE_CODE (value_type) == TYPE_CODE_STRUCT || TYPE_CODE (value_type) == TYPE_CODE_UNION) return 1; @@ -850,25 +849,25 @@ h8300_store_return_value (struct type *type, struct regcache *regcache, { struct gdbarch *gdbarch = get_regcache_arch (regcache); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - int len = TYPE_LENGTH (type); ULONGEST val; - switch (len) + switch (TYPE_LENGTH (type)) { case 1: - case 2: /* short... */ - val = extract_unsigned_integer (valbuf, len, byte_order); + case 2: /* short... */ + val = extract_unsigned_integer (valbuf, TYPE_LENGTH (type), byte_order); regcache_cooked_write_unsigned (regcache, E_RET0_REGNUM, val); break; case 4: /* long, float */ - val = extract_unsigned_integer (valbuf, len, byte_order); + val = extract_unsigned_integer (valbuf, TYPE_LENGTH (type), byte_order); regcache_cooked_write_unsigned (regcache, E_RET0_REGNUM, (val >> 16) & 0xffff); regcache_cooked_write_unsigned (regcache, E_RET1_REGNUM, val & 0xffff); break; - case 8: /* long long, double and long double are all defined - as 4 byte types so far so this shouldn't happen. */ - error ("I don't know how to return an 8 byte value."); + case 8: /* long long, double and long double + are all defined as 4 byte types so + far so this shouldn't happen. */ + error (_("I don't know how to return an 8 byte value.")); break; } } @@ -879,19 +878,18 @@ h8300h_store_return_value (struct type *type, struct regcache *regcache, { struct gdbarch *gdbarch = get_regcache_arch (regcache); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - int len = TYPE_LENGTH (type); ULONGEST val; - switch (len) + switch (TYPE_LENGTH (type)) { case 1: case 2: case 4: /* long, float */ - val = extract_unsigned_integer (valbuf, len, byte_order); + val = extract_unsigned_integer (valbuf, TYPE_LENGTH (type), byte_order); regcache_cooked_write_unsigned (regcache, E_RET0_REGNUM, val); break; case 8: - val = extract_unsigned_integer (valbuf, len, byte_order); + val = extract_unsigned_integer (valbuf, TYPE_LENGTH (type), byte_order); regcache_cooked_write_unsigned (regcache, E_RET0_REGNUM, (val >> 32) & 0xffffffff); regcache_cooked_write_unsigned (regcache, E_RET1_REGNUM, @@ -901,7 +899,7 @@ h8300h_store_return_value (struct type *type, struct regcache *regcache, } static enum return_value_convention -h8300_return_value (struct gdbarch *gdbarch, struct type *func_type, +h8300_return_value (struct gdbarch *gdbarch, struct value *function, struct type *type, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf) { @@ -915,7 +913,7 @@ h8300_return_value (struct gdbarch *gdbarch, struct type *func_type, } static enum return_value_convention -h8300h_return_value (struct gdbarch *gdbarch, struct type *func_type, +h8300h_return_value (struct gdbarch *gdbarch, struct value *function, struct type *type, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf) { @@ -938,13 +936,27 @@ h8300h_return_value (struct gdbarch *gdbarch, struct type *func_type, return RETURN_VALUE_REGISTER_CONVENTION; } -static struct cmd_list_element *setmachinelist; +/* Implementation of 'register_sim_regno' gdbarch method. */ + +static int +h8300_register_sim_regno (struct gdbarch *gdbarch, int regnum) +{ + /* Only makes sense to supply raw registers. */ + gdb_assert (regnum >= 0 && regnum < gdbarch_num_regs (gdbarch)); + + /* We hide the raw ccr from the user by making it nameless. Because + the default register_sim_regno hook returns + LEGACY_SIM_REGNO_IGNORE for unnamed registers, we need to + override it. The sim register numbering is compatible with + gdb's. */ + return regnum; +} static const char * h8300_register_name (struct gdbarch *gdbarch, int regno) { /* The register names change depending on which h8300 processor - type is selected. */ + type is selected. */ static char *register_names[] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "sp", "", "pc", "cycles", "tick", "inst", @@ -953,7 +965,8 @@ h8300_register_name (struct gdbarch *gdbarch, int regno) if (regno < 0 || regno >= (sizeof (register_names) / sizeof (*register_names))) internal_error (__FILE__, __LINE__, - "h8300_register_name: illegal register number %d", regno); + _("h8300_register_name: illegal register number %d"), + regno); else return register_names[regno]; } @@ -970,7 +983,7 @@ h8300s_register_name (struct gdbarch *gdbarch, int regno) if (regno < 0 || regno >= (sizeof (register_names) / sizeof (*register_names))) internal_error (__FILE__, __LINE__, - "h8300s_register_name: illegal register number %d", + _("h8300s_register_name: illegal register number %d"), regno); else return register_names[regno]; @@ -988,7 +1001,7 @@ h8300sx_register_name (struct gdbarch *gdbarch, int regno) if (regno < 0 || regno >= (sizeof (register_names) / sizeof (*register_names))) internal_error (__FILE__, __LINE__, - "h8300sx_register_name: illegal register number %d", + _("h8300sx_register_name: illegal register number %d"), regno); else return register_names[regno]; @@ -1124,7 +1137,8 @@ h8300_register_type (struct gdbarch *gdbarch, int regno) if (regno < 0 || regno >= gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch)) internal_error (__FILE__, __LINE__, - "h8300_register_type: illegal register number %d", regno); + _("h8300_register_type: illegal register number %d"), + regno); else { switch (regno) @@ -1147,17 +1161,57 @@ h8300_register_type (struct gdbarch *gdbarch, int regno) } } +/* Helpers for h8300_pseudo_register_read. We expose ccr/exr as + pseudo-registers to users with smaller sizes than the corresponding + raw registers. These helpers extend/narrow the values. */ + +static enum register_status +pseudo_from_raw_register (struct gdbarch *gdbarch, struct regcache *regcache, + gdb_byte *buf, int pseudo_regno, int raw_regno) +{ + enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); + enum register_status status; + ULONGEST val; + + status = regcache_raw_read_unsigned (regcache, raw_regno, &val); + if (status == REG_VALID) + store_unsigned_integer (buf, + register_size (gdbarch, pseudo_regno), + byte_order, val); + return status; +} + +/* See pseudo_from_raw_register. */ + static void +raw_from_pseudo_register (struct gdbarch *gdbarch, struct regcache *regcache, + const gdb_byte *buf, int raw_regno, int pseudo_regno) +{ + enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); + ULONGEST val; + + val = extract_unsigned_integer (buf, register_size (gdbarch, pseudo_regno), + byte_order); + regcache_raw_write_unsigned (regcache, raw_regno, val); +} + +static enum register_status h8300_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache, int regno, gdb_byte *buf) { if (regno == E_PSEUDO_CCR_REGNUM (gdbarch)) - regcache_raw_read (regcache, E_CCR_REGNUM, buf); + { + return pseudo_from_raw_register (gdbarch, regcache, buf, + regno, E_CCR_REGNUM); + } else if (regno == E_PSEUDO_EXR_REGNUM (gdbarch)) - regcache_raw_read (regcache, E_EXR_REGNUM, buf); + { + return pseudo_from_raw_register (gdbarch, regcache, buf, + regno, E_EXR_REGNUM); + } else - regcache_raw_read (regcache, regno, buf); + return regcache_raw_read (regcache, regno, buf); } static void @@ -1166,9 +1220,9 @@ h8300_pseudo_register_write (struct gdbarch *gdbarch, const gdb_byte *buf) { if (regno == E_PSEUDO_CCR_REGNUM (gdbarch)) - regcache_raw_write (regcache, E_CCR_REGNUM, buf); + raw_from_pseudo_register (gdbarch, regcache, buf, E_CCR_REGNUM, regno); else if (regno == E_PSEUDO_EXR_REGNUM (gdbarch)) - regcache_raw_write (regcache, E_EXR_REGNUM, buf); + raw_from_pseudo_register (gdbarch, regcache, buf, E_EXR_REGNUM, regno); else regcache_raw_write (regcache, regno, buf); } @@ -1191,7 +1245,7 @@ h8300s_dbg_reg_to_regnum (struct gdbarch *gdbarch, int regno) return regno; } -const static unsigned char * +static const unsigned char * h8300_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr) { @@ -1229,6 +1283,8 @@ h8300_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) gdbarch = gdbarch_alloc (&info, 0); + set_gdbarch_register_sim_regno (gdbarch, h8300_register_sim_regno); + switch (info.bfd_arch_info->mach) { case bfd_mach_h8300: @@ -1335,7 +1391,7 @@ h8300_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* * Miscelany */ - /* Stack grows up. */ + /* Stack grows up. */ set_gdbarch_inner_than (gdbarch, core_addr_lessthan); set_gdbarch_breakpoint_from_pc (gdbarch, h8300_breakpoint_from_pc); @@ -1346,7 +1402,9 @@ h8300_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_long_bit (gdbarch, 4 * TARGET_CHAR_BIT); set_gdbarch_long_long_bit (gdbarch, 8 * TARGET_CHAR_BIT); set_gdbarch_double_bit (gdbarch, 4 * TARGET_CHAR_BIT); + set_gdbarch_double_format (gdbarch, floatformats_ieee_single); set_gdbarch_long_double_bit (gdbarch, 4 * TARGET_CHAR_BIT); + set_gdbarch_long_double_format (gdbarch, floatformats_ieee_single); set_gdbarch_believe_pcc_promotion (gdbarch, 1); @@ -1358,7 +1416,7 @@ h8300_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) } -extern initialize_file_ftype _initialize_h8300_tdep; /* -Wmissing-prototypes */ +extern initialize_file_ftype _initialize_h8300_tdep; /* -Wmissing-prototypes */ void _initialize_h8300_tdep (void)