/* Target-dependent code for Atmel AVR, for GDB.
- Copyright (C) 1996-2015 Free Software Foundation, Inc.
+ Copyright (C) 1996-2016 Free Software Foundation, Inc.
This file is part of GDB.
#include "regcache.h"
#include "dis-asm.h"
#include "objfiles.h"
+#include <algorithm>
/* AVR Background:
AVR_ARG1_REGNUM = 24, /* Single byte argument */
AVR_ARGN_REGNUM = 25, /* Multi byte argments */
+ AVR_LAST_ARG_REGNUM = 8, /* Last argument register */
AVR_RET1_REGNUM = 24, /* Single byte return value */
AVR_RETN_REGNUM = 25, /* Multi byte return value */
post_prologue_pc = skip_prologue_using_sal (gdbarch, func_addr);
if (post_prologue_pc != 0)
- return max (pc, post_prologue_pc);
+ return std::max (pc, post_prologue_pc);
{
CORE_ADDR prologue_end = pc;
int i;
if (*this_prologue_cache)
- return *this_prologue_cache;
+ return (struct avr_unwind_cache *) *this_prologue_cache;
info = FRAME_OBSTACK_ZALLOC (struct avr_unwind_cache);
*this_prologue_cache = info;
avr_frame_prev_register (struct frame_info *this_frame,
void **this_prologue_cache, int regnum)
{
- struct gdbarch *gdbarch = get_frame_arch (this_frame);
- enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct avr_unwind_cache *info
= avr_frame_unwind_cache (this_frame, this_prologue_cache);
{
int len;
struct stack_item *prev;
- void *data;
+ gdb_byte *data;
};
static struct stack_item *
push_stack_item (struct stack_item *prev, const bfd_byte *contents, int len)
{
struct stack_item *si;
- si = xmalloc (sizeof (struct stack_item));
- si->data = xmalloc (len);
+ si = XNEW (struct stack_item);
+ si->data = (gdb_byte *) xmalloc (len);
si->len = len;
si->prev = prev;
memcpy (si->data, contents, len);
int nargs, struct value **args, CORE_ADDR sp,
int struct_return, CORE_ADDR struct_addr)
{
- enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int i;
gdb_byte buf[3];
int call_length = gdbarch_tdep (gdbarch)->call_length;
const bfd_byte *contents = value_contents (arg);
int len = TYPE_LENGTH (type);
- /* Calculate the potential last register needed. */
- last_regnum = regnum - (len + (len & 1));
+ /* Calculate the potential last register needed.
+ E.g. For length 2, registers regnum and regnum-1 (say 25 and 24)
+ shall be used. So, last needed register will be regnum-1(24). */
+ last_regnum = regnum - (len + (len & 1)) + 1;
/* If there are registers available, use them. Once we start putting
stuff on the stack, all subsequent args go on stack. */
- if ((si == NULL) && (last_regnum >= 8))
+ if ((si == NULL) && (last_regnum >= AVR_LAST_ARG_REGNUM))
{
- ULONGEST val;
-
/* Skip a register for odd length args. */
if (len & 1)
regnum--;
- val = extract_unsigned_integer (contents, len, byte_order);
+ /* Write MSB of argument into register and subsequent bytes in
+ decreasing register numbers. */
for (j = 0; j < len; j++)
regcache_cooked_write_unsigned
- (regcache, regnum--, val >> (8 * (len - j - 1)));
+ (regcache, regnum--, contents[len - j - 1]);
}
/* No registers available, push the args onto the stack. */
else
return reg;
if (reg == 32)
return AVR_SP_REGNUM;
-
- warning (_("Unmapped DWARF Register #%d encountered."), reg);
-
return -1;
}
be defined. */
tdep->void_type = arch_type (gdbarch, TYPE_CODE_VOID, 1, "void");
tdep->func_void_type = make_function_type (tdep->void_type, NULL);
- tdep->pc_type = arch_type (gdbarch, TYPE_CODE_PTR, 4, NULL);
- TYPE_TARGET_TYPE (tdep->pc_type) = tdep->func_void_type;
- TYPE_UNSIGNED (tdep->pc_type) = 1;
+ tdep->pc_type = arch_pointer_type (gdbarch, 4 * TARGET_CHAR_BIT, NULL,
+ tdep->func_void_type);
set_gdbarch_short_bit (gdbarch, 2 * TARGET_CHAR_BIT);
set_gdbarch_int_bit (gdbarch, 2 * TARGET_CHAR_BIT);
/* FIXME: TRoth/2002-02-18: This should probably be changed to 'info avr
io_registers' to signify it is not available on other platforms. */
- add_cmd ("io_registers", class_info, avr_io_reg_read_command,
- _("query remote avr target for io space register values"),
- &infolist);
+ add_info ("io_registers", avr_io_reg_read_command,
+ _("query remote avr target for io space register values"));
}