2011-08-14 14:03:45 +00:00
|
|
|
/* Target dependent code for GDB on TI C6x systems.
|
|
|
|
|
2015-01-01 09:32:14 +00:00
|
|
|
Copyright (C) 2010-2015 Free Software Foundation, Inc.
|
2011-08-14 14:03:45 +00:00
|
|
|
Contributed by Andrew Jenner <andrew@codesourcery.com>
|
|
|
|
Contributed by Yao Qi <yao@codesourcery.com>
|
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
#include "frame.h"
|
|
|
|
#include "frame-unwind.h"
|
|
|
|
#include "frame-base.h"
|
|
|
|
#include "trad-frame.h"
|
|
|
|
#include "dwarf2-frame.h"
|
|
|
|
#include "symtab.h"
|
|
|
|
#include "inferior.h"
|
|
|
|
#include "gdbtypes.h"
|
|
|
|
#include "gdbcore.h"
|
|
|
|
#include "gdbcmd.h"
|
|
|
|
#include "target.h"
|
|
|
|
#include "dis-asm.h"
|
|
|
|
#include "regcache.h"
|
|
|
|
#include "value.h"
|
|
|
|
#include "symfile.h"
|
|
|
|
#include "arch-utils.h"
|
|
|
|
#include "floatformat.h"
|
|
|
|
#include "glibc-tdep.h"
|
|
|
|
#include "infcall.h"
|
|
|
|
#include "regset.h"
|
|
|
|
#include "tramp-frame.h"
|
|
|
|
#include "linux-tdep.h"
|
|
|
|
#include "solib.h"
|
|
|
|
#include "objfiles.h"
|
|
|
|
#include "osabi.h"
|
|
|
|
#include "tic6x-tdep.h"
|
|
|
|
#include "language.h"
|
|
|
|
#include "target-descriptions.h"
|
|
|
|
|
|
|
|
#include "features/tic6x-c64xp.c"
|
|
|
|
#include "features/tic6x-c64x.c"
|
|
|
|
#include "features/tic6x-c62x.c"
|
|
|
|
|
|
|
|
#define TIC6X_OPCODE_SIZE 4
|
|
|
|
#define TIC6X_FETCH_PACKET_SIZE 32
|
|
|
|
|
|
|
|
#define INST_S_BIT(INST) ((INST >> 1) & 1)
|
|
|
|
#define INST_X_BIT(INST) ((INST >> 12) & 1)
|
|
|
|
|
2011-08-16 04:15:23 +00:00
|
|
|
const gdb_byte tic6x_bkpt_illegal_opcode_be[] = { 0x56, 0x45, 0x43, 0x14 };
|
|
|
|
const gdb_byte tic6x_bkpt_illegal_opcode_le[] = { 0x14, 0x43, 0x45, 0x56 };
|
|
|
|
|
2011-08-14 14:03:45 +00:00
|
|
|
struct tic6x_unwind_cache
|
|
|
|
{
|
|
|
|
/* The frame's base, optionally used by the high-level debug info. */
|
|
|
|
CORE_ADDR base;
|
|
|
|
|
|
|
|
/* The previous frame's inner most stack address. Used as this
|
|
|
|
frame ID's stack_addr. */
|
|
|
|
CORE_ADDR cfa;
|
|
|
|
|
|
|
|
/* The address of the first instruction in this function */
|
|
|
|
CORE_ADDR pc;
|
|
|
|
|
|
|
|
/* Which register holds the return address for the frame. */
|
|
|
|
int return_regnum;
|
|
|
|
|
|
|
|
/* The offset of register saved on stack. If register is not saved, the
|
|
|
|
corresponding element is -1. */
|
|
|
|
CORE_ADDR reg_saved[TIC6X_NUM_CORE_REGS];
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Name of TI C6x core registers. */
|
|
|
|
static const char *const tic6x_register_names[] =
|
|
|
|
{
|
|
|
|
"A0", "A1", "A2", "A3", /* 0 1 2 3 */
|
|
|
|
"A4", "A5", "A6", "A7", /* 4 5 6 7 */
|
|
|
|
"A8", "A9", "A10", "A11", /* 8 9 10 11 */
|
|
|
|
"A12", "A13", "A14", "A15", /* 12 13 14 15 */
|
|
|
|
"B0", "B1", "B2", "B3", /* 16 17 18 19 */
|
|
|
|
"B4", "B5", "B6", "B7", /* 20 21 22 23 */
|
|
|
|
"B8", "B9", "B10", "B11", /* 24 25 26 27 */
|
|
|
|
"B12", "B13", "B14", "B15", /* 28 29 30 31 */
|
|
|
|
"CSR", "PC", /* 32 33 */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* This array maps the arguments to the register number which passes argument
|
|
|
|
in function call according to C6000 ELF ABI. */
|
|
|
|
static const int arg_regs[] = { 4, 20, 6, 22, 8, 24, 10, 26, 12, 28 };
|
|
|
|
|
|
|
|
/* This is the implementation of gdbarch method register_name. */
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
tic6x_register_name (struct gdbarch *gdbarch, int regno)
|
|
|
|
{
|
|
|
|
if (regno < 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (tdesc_has_registers (gdbarch_target_desc (gdbarch)))
|
|
|
|
return tdesc_register_name (gdbarch, regno);
|
|
|
|
else if (regno >= ARRAY_SIZE (tic6x_register_names))
|
|
|
|
return "";
|
|
|
|
else
|
|
|
|
return tic6x_register_names[regno];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is the implementation of gdbarch method register_type. */
|
|
|
|
|
|
|
|
static struct type *
|
|
|
|
tic6x_register_type (struct gdbarch *gdbarch, int regno)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (regno == TIC6X_PC_REGNUM)
|
|
|
|
return builtin_type (gdbarch)->builtin_func_ptr;
|
|
|
|
else
|
|
|
|
return builtin_type (gdbarch)->builtin_uint32;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tic6x_setup_default (struct tic6x_unwind_cache *cache)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < TIC6X_NUM_CORE_REGS; i++)
|
|
|
|
cache->reg_saved[i] = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned long tic6x_fetch_instruction (struct gdbarch *, CORE_ADDR);
|
|
|
|
static int tic6x_register_number (int reg, int side, int crosspath);
|
|
|
|
|
|
|
|
/* Do a full analysis of the prologue at START_PC and update CACHE accordingly.
|
|
|
|
Bail out early if CURRENT_PC is reached. Returns the address of the first
|
|
|
|
instruction after the prologue. */
|
|
|
|
|
2012-03-02 00:06:13 +00:00
|
|
|
static CORE_ADDR
|
2011-08-14 14:03:45 +00:00
|
|
|
tic6x_analyze_prologue (struct gdbarch *gdbarch, const CORE_ADDR start_pc,
|
|
|
|
const CORE_ADDR current_pc,
|
|
|
|
struct tic6x_unwind_cache *cache,
|
|
|
|
struct frame_info *this_frame)
|
|
|
|
{
|
|
|
|
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
|
|
|
|
unsigned long inst;
|
|
|
|
unsigned int src_reg, base_reg, dst_reg;
|
|
|
|
int i;
|
|
|
|
CORE_ADDR pc = start_pc;
|
|
|
|
CORE_ADDR return_pc = start_pc;
|
|
|
|
int frame_base_offset_to_sp = 0;
|
|
|
|
/* Counter of non-stw instructions after first insn ` sub sp, xxx, sp'. */
|
|
|
|
int non_stw_insn_counter = 0;
|
|
|
|
|
|
|
|
if (start_pc >= current_pc)
|
|
|
|
return_pc = current_pc;
|
|
|
|
|
|
|
|
cache->base = 0;
|
|
|
|
|
|
|
|
/* The landmarks in prologue is one or two SUB instructions to SP.
|
|
|
|
Instructions on setting up dsbt are in the last part of prologue, if
|
|
|
|
needed. In maxim, prologue can be divided to three parts by two
|
|
|
|
`sub sp, xx, sp' insns. */
|
|
|
|
|
|
|
|
/* Step 1: Look for the 1st and 2nd insn `sub sp, xx, sp', in which, the
|
|
|
|
2nd one is optional. */
|
|
|
|
while (pc < current_pc)
|
|
|
|
{
|
|
|
|
int offset = 0;
|
|
|
|
|
|
|
|
unsigned long inst = tic6x_fetch_instruction (gdbarch, pc);
|
|
|
|
|
|
|
|
if ((inst & 0x1ffc) == 0x1dc0 || (inst & 0x1ffc) == 0x1bc0
|
|
|
|
|| (inst & 0x0ffc) == 0x9c0)
|
|
|
|
{
|
|
|
|
/* SUBAW/SUBAH/SUB, and src1 is ucst 5. */
|
|
|
|
unsigned int src2 = tic6x_register_number ((inst >> 18) & 0x1f,
|
|
|
|
INST_S_BIT (inst), 0);
|
|
|
|
unsigned int dst = tic6x_register_number ((inst >> 23) & 0x1f,
|
|
|
|
INST_S_BIT (inst), 0);
|
|
|
|
|
|
|
|
if (src2 == TIC6X_SP_REGNUM && dst == TIC6X_SP_REGNUM)
|
|
|
|
{
|
|
|
|
/* Extract const from insn SUBAW/SUBAH/SUB, and translate it to
|
|
|
|
offset. The constant offset is decoded in bit 13-17 in all
|
|
|
|
these three kinds of instructions. */
|
|
|
|
unsigned int ucst5 = (inst >> 13) & 0x1f;
|
|
|
|
|
|
|
|
if ((inst & 0x1ffc) == 0x1dc0) /* SUBAW */
|
|
|
|
frame_base_offset_to_sp += ucst5 << 2;
|
|
|
|
else if ((inst & 0x1ffc) == 0x1bc0) /* SUBAH */
|
|
|
|
frame_base_offset_to_sp += ucst5 << 1;
|
|
|
|
else if ((inst & 0x0ffc) == 0x9c0) /* SUB */
|
|
|
|
frame_base_offset_to_sp += ucst5;
|
|
|
|
else
|
|
|
|
gdb_assert_not_reached ("unexpected instruction");
|
|
|
|
|
|
|
|
return_pc = pc + 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((inst & 0x174) == 0x74) /* stw SRC, *+b15(uconst) */
|
|
|
|
{
|
|
|
|
/* The y bit determines which file base is read from. */
|
|
|
|
base_reg = tic6x_register_number ((inst >> 18) & 0x1f,
|
|
|
|
(inst >> 7) & 1, 0);
|
|
|
|
|
|
|
|
if (base_reg == TIC6X_SP_REGNUM)
|
|
|
|
{
|
|
|
|
src_reg = tic6x_register_number ((inst >> 23) & 0x1f,
|
|
|
|
INST_S_BIT (inst), 0);
|
|
|
|
|
|
|
|
cache->reg_saved[src_reg] = ((inst >> 13) & 0x1f) << 2;
|
|
|
|
|
|
|
|
return_pc = pc + 4;
|
|
|
|
}
|
|
|
|
non_stw_insn_counter = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
non_stw_insn_counter++;
|
|
|
|
/* Following instruction sequence may be emitted in prologue:
|
|
|
|
|
|
|
|
<+0>: subah .D2 b15,28,b15
|
|
|
|
<+4>: or .L2X 0,a4,b0
|
|
|
|
<+8>: || stw .D2T2 b14,*+b15(56)
|
|
|
|
<+12>:[!b0] b .S1 0xe50e4c1c <sleep+220>
|
|
|
|
<+16>:|| stw .D2T1 a10,*+b15(48)
|
|
|
|
<+20>:stw .D2T2 b3,*+b15(52)
|
|
|
|
<+24>:stw .D2T1 a4,*+b15(40)
|
|
|
|
|
|
|
|
we should look forward for next instruction instead of breaking loop
|
|
|
|
here. So far, we allow almost two sequential non-stw instructions
|
|
|
|
in prologue. */
|
|
|
|
if (non_stw_insn_counter >= 2)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pc += 4;
|
|
|
|
}
|
|
|
|
/* Step 2: Skip insn on setting up dsbt if it is. Usually, it looks like,
|
|
|
|
ldw .D2T2 *+b14(0),b14 */
|
|
|
|
inst = tic6x_fetch_instruction (gdbarch, pc);
|
|
|
|
/* The s bit determines which file dst will be loaded into, same effect as
|
|
|
|
other places. */
|
|
|
|
dst_reg = tic6x_register_number ((inst >> 23) & 0x1f, (inst >> 1) & 1, 0);
|
|
|
|
/* The y bit (bit 7), instead of s bit, determines which file base be
|
|
|
|
used. */
|
|
|
|
base_reg = tic6x_register_number ((inst >> 18) & 0x1f, (inst >> 7) & 1, 0);
|
|
|
|
|
|
|
|
if ((inst & 0x164) == 0x64 /* ldw */
|
|
|
|
&& dst_reg == TIC6X_DP_REGNUM /* dst is B14 */
|
|
|
|
&& base_reg == TIC6X_DP_REGNUM) /* baseR is B14 */
|
|
|
|
{
|
|
|
|
return_pc = pc + 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this_frame)
|
|
|
|
{
|
|
|
|
cache->base = get_frame_register_unsigned (this_frame, TIC6X_SP_REGNUM);
|
|
|
|
|
|
|
|
if (cache->reg_saved[TIC6X_FP_REGNUM] != -1)
|
|
|
|
{
|
|
|
|
/* If the FP now holds an offset from the CFA then this is a frame
|
|
|
|
which uses the frame pointer. */
|
|
|
|
|
|
|
|
cache->cfa = get_frame_register_unsigned (this_frame,
|
|
|
|
TIC6X_FP_REGNUM);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* FP doesn't hold an offset from the CFA. If SP still holds an
|
|
|
|
offset from the CFA then we might be in a function which omits
|
|
|
|
the frame pointer. */
|
|
|
|
|
|
|
|
cache->cfa = cache->base + frame_base_offset_to_sp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Adjust all the saved registers such that they contain addresses
|
|
|
|
instead of offsets. */
|
|
|
|
for (i = 0; i < TIC6X_NUM_CORE_REGS; i++)
|
|
|
|
if (cache->reg_saved[i] != -1)
|
|
|
|
cache->reg_saved[i] = cache->base + cache->reg_saved[i];
|
|
|
|
|
|
|
|
return return_pc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is the implementation of gdbarch method skip_prologue. */
|
|
|
|
|
2012-03-02 00:06:13 +00:00
|
|
|
static CORE_ADDR
|
2011-08-14 14:03:45 +00:00
|
|
|
tic6x_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
|
|
|
|
{
|
|
|
|
CORE_ADDR func_addr;
|
|
|
|
struct tic6x_unwind_cache cache;
|
|
|
|
|
|
|
|
/* See if we can determine the end of the prologue via the symbol table.
|
|
|
|
If so, then return either PC, or the PC after the prologue, whichever is
|
|
|
|
greater. */
|
|
|
|
if (find_pc_partial_function (start_pc, NULL, &func_addr, NULL))
|
|
|
|
{
|
|
|
|
CORE_ADDR post_prologue_pc
|
|
|
|
= skip_prologue_using_sal (gdbarch, func_addr);
|
|
|
|
if (post_prologue_pc != 0)
|
|
|
|
return max (start_pc, post_prologue_pc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Can't determine prologue from the symbol table, need to examine
|
|
|
|
instructions. */
|
|
|
|
return tic6x_analyze_prologue (gdbarch, start_pc, (CORE_ADDR) -1, &cache,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is the implementation of gdbarch method breakpiont_from_pc. */
|
|
|
|
|
-Wpointer-sign: char -> gdb_byte.
-Wpointer-sign catches all these cases across the codebase that should
be using gdb_byte for raw target bytes. I think these are all
obvious, hence I've collapsed into a single patch.
gdb/
2013-04-19 Pedro Alves <palves@redhat.com>
* aarch64-tdep.c (aarch64_default_breakpoint): Change type to
gdb_byte[].
(aarch64_breakpoint_from_pc): Change return type to gdb_byte *.
* ada-lang.c (ada_value_assign): Use gdb_byte.
* alphanbsd-tdep.c (sigtramp_retcode): Change type to gdb_byte[].
(alphanbsd_sigtramp_offset): Use gdb_byte.
* arm-linux-tdep.c (arm_linux_arm_le_breakpoint)
(arm_linux_arm_be_breakpoint, eabi_linux_arm_le_breakpoint)
(eabi_linux_arm_be_breakpoint, arm_linux_thumb_be_breakpoint)
(arm_linux_thumb_le_breakpoint, arm_linux_thumb2_be_breakpoint)
(arm_linux_thumb2_le_breakpoint): Change type to gdb_byte[].
* arm-tdep.c (arm_stub_unwind_sniffer)
(arm_displaced_init_closure): Use gdb_byte.
(arm_default_arm_le_breakpoint, arm_default_arm_be_breakpoint)
(arm_default_thumb_le_breakpoint)
(arm_default_thumb_be_breakpoint): Change type to gdb_byte[].
* arm-tdep.h (struct gdbarch_tdep) <arm_breakpoint,
thumb_breakpoint, thumb2_breakpoint>: Change type to gdb_byte *.
* arm-wince-tdep.c (arm_wince_le_breakpoint)
(arm_wince_thumb_le_breakpoint): Change type to gdb_byte[].
* armnbsd-tdep.c (arm_nbsd_arm_le_breakpoint)
(arm_nbsd_arm_be_breakpoint, arm_nbsd_thumb_le_breakpoint)
(arm_nbsd_thumb_be_breakpoint): Change type to gdb_byte[].
* armobsd-tdep.c (arm_obsd_thumb_le_breakpoint)
(arm_obsd_thumb_be_breakpoint): Change type to gdb_byte[].
* cris-tdep.c (push_stack_item, cris_push_dummy_call)
(cris_store_return_value, cris_extract_return_value): Use
gdb_byte.
(constraint): Change type of parameter to char * from signed
char*. Use gdb_byte.
* dwarf2loc.c (read_pieced_value, write_pieced_value): Change type
of local buffer to gdb_byte *.
* dwarf2read.c (read_index_from_section): Use gdb_byte.
(create_dwp_hash_table): Change type of locals to gdb_byte *.
(add_address_entry): Change type of local buffer to gdb_byte[].
* frv-tdep.c (frv_adjust_breakpoint_address, find_func_descr)
(frv_push_dummy_call): Use gdb_byte.
* hppa-hpux-tdep.c (hppa_hpux_push_dummy_code)
(hppa_hpux_supply_ss_fpblock, hppa_hpux_supply_ss_wide)
(hppa_hpux_supply_save_state): Use gdb_byte.
* hppa-tdep.c (hppa32_push_dummy_call)
(hppa64_convert_code_addr_to_fptr): Use gdb_byte.
* ia64-tdep.c (extract_bit_field, replace_bit_field)
(slotN_contents, replace_slotN_contents): Change type of parameter
to gdb_byte *.
(fetch_instruction, ia64_pseudo_register_write)
(ia64_register_to_value, ia64_value_to_register)
(ia64_extract_return_value, ia64_store_return_value)
(ia64_push_dummy_call): Use gdb_byte.
* m32c-tdep.c (m32c_return_value): Remove cast.
* m68hc11-tdep.c (m68hc11_pseudo_register_write)
(m68hc11_push_dummy_call, m68hc11_store_return_value): Use
gdb_byte.
* mipsnbsd-tdep.c (mipsnbsd_get_longjmp_target): Use gdb_byte.
* mn10300-tdep.c (mn10300_store_return_value)
(mn10300_breakpoint_from_pc, mn10300_push_dummy_call): Use
gdb_byte.
* moxie-tdep.c (moxie_process_readu): Use gdb_byte.
(moxie_process_record): Remove casts.
* ppc-ravenscar-thread.c (supply_register_at_address)
(ppc_ravenscar_generic_store_registers): Use gdb_byte.
* ravenscar-thread.c (get_running_thread_id): Use gdb_byte.
* remote-m32r-sdi.c (m32r_fetch_register): Use gdb_byte.
* remote-mips.c (mips_xfer_memory): Use gdb_byte.
* remote.c (compare_sections_command): Use gdb_byte.
* score-tdep.c (score7_free_memblock): Change type of parameter to
gdb_byte *.
* sh-tdep.c (sh_justify_value_in_reg): Change return type to
gdb_byte *. Use gdb_byte.
(sh_push_dummy_call_fpu): Use gdb_byte.
(sh_extract_return_value_nofpu, sh_extract_return_value_fpu)
(sh_store_return_value_nofpu, sh_store_return_value_fpu)
(sh_register_convert_to_virtual, sh_register_convert_to_raw):
Change parameter type to 'gdb_byte *'. Use gdb_byte.
(sh_pseudo_register_read, sh_pseudo_register_write): Use gdb_byte.
* sh64-tdep.c (sh64_push_dummy_call): Use gdb_byte.
(sh64_store_return_value, sh64_register_convert_to_virtual):
Change parameter type to 'gdb_byte *'. Use gdb_byte.
(sh64_pseudo_register_write): Use gdb_byte.
* solib-darwin.c (darwin_current_sos): Add casts to 'gdb_byte *'.
* solib-irix.c (fetch_lm_info): Likewise. Use gdb_byte for byte
buffer.
(irix_current_sos): Use gdb_byte.
* solib-som.c (som_current_sos): Use gdb_byte.
* sparc-ravenscar-thread.c (supply_register_at_address)
(sparc_ravenscar_generic_store_registers): Use gdb_byte.
* spu-multiarch.c (spu_xfer_partial): Add cast to 'char *'.
* spu-tdep.c (spu_get_overlay_table): Use gdb_byte.
* tic6x-tdep.c (tic6x_breakpoint_from_pc): Change return type to
'gdb_byte *'.
* tic6x-tdep.h (struct gdbarch_tdep) <breakpoint>: Change type to
'gdb_byte *'.
* tracepoint.c (tfile_fetch_registers): Use gdb_byte.
* xstormy16-tdep.c (xstormy16_extract_return_value)
(xstormy16_store_return_value): Change parameter type to
'gdb_byte *'. Adjust.
(xstormy16_push_dummy_call): Use gdb_byte.
* xtensa-tdep.c (xtensa_scan_prologue, call0_ret)
(call0_analyze_prologue, execute_code): Use gdb_byte.
2013-04-19 15:09:46 +00:00
|
|
|
static const gdb_byte *
|
2011-08-14 14:03:45 +00:00
|
|
|
tic6x_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *bp_addr,
|
|
|
|
int *bp_size)
|
|
|
|
{
|
|
|
|
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
|
|
|
|
|
|
|
|
*bp_size = 4;
|
|
|
|
|
|
|
|
if (tdep == NULL || tdep->breakpoint == NULL)
|
|
|
|
{
|
|
|
|
if (BFD_ENDIAN_BIG == gdbarch_byte_order_for_code (gdbarch))
|
|
|
|
return tic6x_bkpt_illegal_opcode_be;
|
|
|
|
else
|
|
|
|
return tic6x_bkpt_illegal_opcode_le;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return tdep->breakpoint;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is the implementation of gdbarch method print_insn. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
tic6x_print_insn (bfd_vma memaddr, disassemble_info *info)
|
|
|
|
{
|
|
|
|
return print_insn_tic6x (memaddr, info);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tic6x_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
|
|
|
|
struct dwarf2_frame_state_reg *reg,
|
|
|
|
struct frame_info *this_frame)
|
|
|
|
{
|
|
|
|
/* Mark the PC as the destination for the return address. */
|
|
|
|
if (regnum == gdbarch_pc_regnum (gdbarch))
|
|
|
|
reg->how = DWARF2_FRAME_REG_RA;
|
|
|
|
|
|
|
|
/* Mark the stack pointer as the call frame address. */
|
|
|
|
else if (regnum == gdbarch_sp_regnum (gdbarch))
|
|
|
|
reg->how = DWARF2_FRAME_REG_CFA;
|
|
|
|
|
|
|
|
/* The above was taken from the default init_reg in dwarf2-frame.c
|
|
|
|
while the below is c6x specific. */
|
|
|
|
|
|
|
|
/* Callee save registers. The ABI designates A10-A15 and B10-B15 as
|
|
|
|
callee-save. */
|
|
|
|
else if ((regnum >= 10 && regnum <= 15) || (regnum >= 26 && regnum <= 31))
|
|
|
|
reg->how = DWARF2_FRAME_REG_SAME_VALUE;
|
|
|
|
else
|
|
|
|
/* All other registers are caller-save. */
|
|
|
|
reg->how = DWARF2_FRAME_REG_UNDEFINED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is the implementation of gdbarch method unwind_pc. */
|
|
|
|
|
|
|
|
static CORE_ADDR
|
|
|
|
tic6x_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
|
|
|
|
{
|
|
|
|
gdb_byte buf[8];
|
|
|
|
|
|
|
|
frame_unwind_register (next_frame, TIC6X_PC_REGNUM, buf);
|
|
|
|
return extract_typed_address (buf, builtin_type (gdbarch)->builtin_func_ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is the implementation of gdbarch method unwind_sp. */
|
|
|
|
|
|
|
|
static CORE_ADDR
|
|
|
|
tic6x_unwind_sp (struct gdbarch *gdbarch, struct frame_info *this_frame)
|
|
|
|
{
|
|
|
|
return frame_unwind_register_unsigned (this_frame, TIC6X_SP_REGNUM);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Frame base handling. */
|
|
|
|
|
2012-03-02 00:06:13 +00:00
|
|
|
static struct tic6x_unwind_cache*
|
2011-08-14 14:03:45 +00:00
|
|
|
tic6x_frame_unwind_cache (struct frame_info *this_frame,
|
|
|
|
void **this_prologue_cache)
|
|
|
|
{
|
|
|
|
struct gdbarch *gdbarch = get_frame_arch (this_frame);
|
|
|
|
CORE_ADDR current_pc;
|
|
|
|
struct tic6x_unwind_cache *cache;
|
|
|
|
|
|
|
|
if (*this_prologue_cache)
|
|
|
|
return *this_prologue_cache;
|
|
|
|
|
|
|
|
cache = FRAME_OBSTACK_ZALLOC (struct tic6x_unwind_cache);
|
|
|
|
(*this_prologue_cache) = cache;
|
|
|
|
|
|
|
|
cache->return_regnum = TIC6X_RA_REGNUM;
|
|
|
|
|
|
|
|
tic6x_setup_default (cache);
|
|
|
|
|
|
|
|
cache->pc = get_frame_func (this_frame);
|
|
|
|
current_pc = get_frame_pc (this_frame);
|
|
|
|
|
|
|
|
/* Prologue analysis does the rest... */
|
|
|
|
if (cache->pc != 0)
|
|
|
|
tic6x_analyze_prologue (gdbarch, cache->pc, current_pc, cache, this_frame);
|
|
|
|
|
|
|
|
return cache;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tic6x_frame_this_id (struct frame_info *this_frame, void **this_cache,
|
|
|
|
struct frame_id *this_id)
|
|
|
|
{
|
|
|
|
struct tic6x_unwind_cache *cache =
|
|
|
|
tic6x_frame_unwind_cache (this_frame, this_cache);
|
|
|
|
|
|
|
|
/* This marks the outermost frame. */
|
|
|
|
if (cache->base == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
(*this_id) = frame_id_build (cache->cfa, cache->pc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct value *
|
|
|
|
tic6x_frame_prev_register (struct frame_info *this_frame, void **this_cache,
|
|
|
|
int regnum)
|
|
|
|
{
|
|
|
|
struct tic6x_unwind_cache *cache =
|
|
|
|
tic6x_frame_unwind_cache (this_frame, this_cache);
|
|
|
|
|
|
|
|
gdb_assert (regnum >= 0);
|
|
|
|
|
|
|
|
/* The PC of the previous frame is stored in the RA register of
|
|
|
|
the current frame. Frob regnum so that we pull the value from
|
|
|
|
the correct place. */
|
|
|
|
if (regnum == TIC6X_PC_REGNUM)
|
|
|
|
regnum = cache->return_regnum;
|
|
|
|
|
|
|
|
if (regnum == TIC6X_SP_REGNUM && cache->cfa)
|
|
|
|
return frame_unwind_got_constant (this_frame, regnum, cache->cfa);
|
|
|
|
|
|
|
|
/* If we've worked out where a register is stored then load it from
|
|
|
|
there. */
|
|
|
|
if (regnum < TIC6X_NUM_CORE_REGS && cache->reg_saved[regnum] != -1)
|
|
|
|
return frame_unwind_got_memory (this_frame, regnum,
|
|
|
|
cache->reg_saved[regnum]);
|
|
|
|
|
|
|
|
return frame_unwind_got_register (this_frame, regnum, regnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
static CORE_ADDR
|
|
|
|
tic6x_frame_base_address (struct frame_info *this_frame, void **this_cache)
|
|
|
|
{
|
|
|
|
struct tic6x_unwind_cache *info
|
|
|
|
= tic6x_frame_unwind_cache (this_frame, this_cache);
|
|
|
|
return info->base;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct frame_unwind tic6x_frame_unwind =
|
|
|
|
{
|
|
|
|
NORMAL_FRAME,
|
|
|
|
default_frame_unwind_stop_reason,
|
|
|
|
tic6x_frame_this_id,
|
|
|
|
tic6x_frame_prev_register,
|
|
|
|
NULL,
|
|
|
|
default_frame_sniffer
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct frame_base tic6x_frame_base =
|
|
|
|
{
|
|
|
|
&tic6x_frame_unwind,
|
|
|
|
tic6x_frame_base_address,
|
|
|
|
tic6x_frame_base_address,
|
|
|
|
tic6x_frame_base_address
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static struct tic6x_unwind_cache *
|
|
|
|
tic6x_make_stub_cache (struct frame_info *this_frame)
|
|
|
|
{
|
|
|
|
struct tic6x_unwind_cache *cache;
|
|
|
|
|
|
|
|
cache = FRAME_OBSTACK_ZALLOC (struct tic6x_unwind_cache);
|
|
|
|
|
|
|
|
cache->return_regnum = TIC6X_RA_REGNUM;
|
|
|
|
|
|
|
|
tic6x_setup_default (cache);
|
|
|
|
|
|
|
|
cache->cfa = get_frame_register_unsigned (this_frame, TIC6X_SP_REGNUM);
|
|
|
|
|
|
|
|
return cache;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tic6x_stub_this_id (struct frame_info *this_frame, void **this_cache,
|
|
|
|
struct frame_id *this_id)
|
|
|
|
{
|
|
|
|
struct tic6x_unwind_cache *cache;
|
|
|
|
|
|
|
|
if (*this_cache == NULL)
|
|
|
|
*this_cache = tic6x_make_stub_cache (this_frame);
|
|
|
|
cache = *this_cache;
|
|
|
|
|
|
|
|
*this_id = frame_id_build (cache->cfa, get_frame_pc (this_frame));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tic6x_stub_unwind_sniffer (const struct frame_unwind *self,
|
|
|
|
struct frame_info *this_frame,
|
|
|
|
void **this_prologue_cache)
|
|
|
|
{
|
|
|
|
CORE_ADDR addr_in_block;
|
|
|
|
|
|
|
|
addr_in_block = get_frame_address_in_block (this_frame);
|
2013-06-24 22:18:32 +00:00
|
|
|
if (in_plt_section (addr_in_block))
|
2011-08-14 14:03:45 +00:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct frame_unwind tic6x_stub_unwind =
|
|
|
|
{
|
|
|
|
NORMAL_FRAME,
|
|
|
|
default_frame_unwind_stop_reason,
|
|
|
|
tic6x_stub_this_id,
|
|
|
|
tic6x_frame_prev_register,
|
|
|
|
NULL,
|
|
|
|
tic6x_stub_unwind_sniffer
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Return the instruction on address PC. */
|
|
|
|
|
|
|
|
static unsigned long
|
|
|
|
tic6x_fetch_instruction (struct gdbarch *gdbarch, CORE_ADDR pc)
|
|
|
|
{
|
|
|
|
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
|
|
|
|
return read_memory_unsigned_integer (pc, TIC6X_OPCODE_SIZE, byte_order);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Compute the condition of INST if it is a conditional instruction. Always
|
|
|
|
return 1 if INST is not a conditional instruction. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
tic6x_condition_true (struct frame_info *frame, unsigned long inst)
|
|
|
|
{
|
|
|
|
int register_number;
|
|
|
|
int register_value;
|
|
|
|
static const int register_numbers[8] = { -1, 16, 17, 18, 1, 2, 0, -1 };
|
|
|
|
|
|
|
|
register_number = register_numbers[(inst >> 29) & 7];
|
|
|
|
if (register_number == -1)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
register_value = get_frame_register_signed (frame, register_number);
|
|
|
|
if ((inst & 0x10000000) != 0)
|
|
|
|
return register_value == 0;
|
|
|
|
return register_value != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the register number by decoding raw bits REG, SIDE, and CROSSPATH in
|
|
|
|
instruction. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
tic6x_register_number (int reg, int side, int crosspath)
|
|
|
|
{
|
|
|
|
int r = (reg & 15) | ((crosspath ^ side) << 4);
|
|
|
|
if ((reg & 16) != 0) /* A16 - A31, B16 - B31 */
|
|
|
|
r += 37;
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tic6x_extract_signed_field (int value, int low_bit, int bits)
|
|
|
|
{
|
|
|
|
int mask = (1 << bits) - 1;
|
|
|
|
int r = (value >> low_bit) & mask;
|
|
|
|
if ((r & (1 << (bits - 1))) != 0)
|
|
|
|
r -= mask + 1;
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Determine where to set a single step breakpoint. */
|
|
|
|
|
|
|
|
static CORE_ADDR
|
|
|
|
tic6x_get_next_pc (struct frame_info *frame, CORE_ADDR pc)
|
|
|
|
{
|
|
|
|
struct gdbarch *gdbarch = get_frame_arch (frame);
|
|
|
|
unsigned long inst;
|
|
|
|
int register_number;
|
|
|
|
int last = 0;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
inst = tic6x_fetch_instruction (gdbarch, pc);
|
|
|
|
|
|
|
|
last = !(inst & 1);
|
|
|
|
|
|
|
|
if (inst == TIC6X_INST_SWE)
|
|
|
|
{
|
|
|
|
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
|
|
|
|
|
|
|
|
if (tdep->syscall_next_pc != NULL)
|
|
|
|
return tdep->syscall_next_pc (frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tic6x_condition_true (frame, inst))
|
|
|
|
{
|
|
|
|
if ((inst & 0x0000007c) == 0x00000010)
|
|
|
|
{
|
|
|
|
/* B with displacement */
|
|
|
|
pc &= ~(TIC6X_FETCH_PACKET_SIZE - 1);
|
|
|
|
pc += tic6x_extract_signed_field (inst, 7, 21) << 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ((inst & 0x0f83effc) == 0x00000360)
|
|
|
|
{
|
|
|
|
/* B with register */
|
|
|
|
|
|
|
|
register_number = tic6x_register_number ((inst >> 18) & 0x1f,
|
|
|
|
INST_S_BIT (inst),
|
|
|
|
INST_X_BIT (inst));
|
|
|
|
pc = get_frame_register_unsigned (frame, register_number);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ((inst & 0x00001ffc) == 0x00001020)
|
|
|
|
{
|
|
|
|
/* BDEC */
|
|
|
|
register_number = tic6x_register_number ((inst >> 23) & 0x1f,
|
|
|
|
INST_S_BIT (inst), 0);
|
|
|
|
if (get_frame_register_signed (frame, register_number) >= 0)
|
|
|
|
{
|
|
|
|
pc &= ~(TIC6X_FETCH_PACKET_SIZE - 1);
|
|
|
|
pc += tic6x_extract_signed_field (inst, 7, 10) << 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ((inst & 0x00001ffc) == 0x00000120)
|
|
|
|
{
|
|
|
|
/* BNOP with displacement */
|
|
|
|
pc &= ~(TIC6X_FETCH_PACKET_SIZE - 1);
|
|
|
|
pc += tic6x_extract_signed_field (inst, 16, 12) << 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ((inst & 0x0f830ffe) == 0x00800362)
|
|
|
|
{
|
|
|
|
/* BNOP with register */
|
|
|
|
register_number = tic6x_register_number ((inst >> 18) & 0x1f,
|
|
|
|
1, INST_X_BIT (inst));
|
|
|
|
pc = get_frame_register_unsigned (frame, register_number);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ((inst & 0x00001ffc) == 0x00000020)
|
|
|
|
{
|
|
|
|
/* BPOS */
|
|
|
|
register_number = tic6x_register_number ((inst >> 23) & 0x1f,
|
|
|
|
INST_S_BIT (inst), 0);
|
|
|
|
if (get_frame_register_signed (frame, register_number) >= 0)
|
|
|
|
{
|
|
|
|
pc &= ~(TIC6X_FETCH_PACKET_SIZE - 1);
|
|
|
|
pc += tic6x_extract_signed_field (inst, 13, 10) << 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ((inst & 0xf000007c) == 0x10000010)
|
|
|
|
{
|
|
|
|
/* CALLP */
|
|
|
|
pc &= ~(TIC6X_FETCH_PACKET_SIZE - 1);
|
|
|
|
pc += tic6x_extract_signed_field (inst, 7, 21) << 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pc += TIC6X_OPCODE_SIZE;
|
|
|
|
}
|
|
|
|
while (!last);
|
|
|
|
return pc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is the implementation of gdbarch method software_single_step. */
|
|
|
|
|
2012-03-02 00:06:13 +00:00
|
|
|
static int
|
2011-08-14 14:03:45 +00:00
|
|
|
tic6x_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 next_pc = tic6x_get_next_pc (frame, get_frame_pc (frame));
|
|
|
|
|
|
|
|
insert_single_step_breakpoint (gdbarch, aspace, next_pc);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is the implementation of gdbarch method frame_align. */
|
|
|
|
|
|
|
|
static CORE_ADDR
|
|
|
|
tic6x_frame_align (struct gdbarch *gdbarch, CORE_ADDR addr)
|
|
|
|
{
|
|
|
|
return align_down (addr, 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Given a return value in REGCACHE with a type VALTYPE, extract and copy its
|
|
|
|
value into VALBUF. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
tic6x_extract_return_value (struct type *valtype, struct regcache *regcache,
|
|
|
|
enum bfd_endian byte_order, gdb_byte *valbuf)
|
|
|
|
{
|
|
|
|
int len = TYPE_LENGTH (valtype);
|
|
|
|
|
|
|
|
/* pointer types are returned in register A4,
|
|
|
|
up to 32-bit types in A4
|
|
|
|
up to 64-bit types in A5:A4 */
|
|
|
|
if (len <= 4)
|
|
|
|
{
|
|
|
|
/* In big-endian,
|
|
|
|
- one-byte structure or union occupies the LSB of single even register.
|
|
|
|
- for two-byte structure or union, the first byte occupies byte 1 of
|
|
|
|
register and the second byte occupies byte 0.
|
|
|
|
so, we read the contents in VAL from the LSBs of register. */
|
|
|
|
if (len < 3 && byte_order == BFD_ENDIAN_BIG)
|
|
|
|
regcache_cooked_read_part (regcache, TIC6X_A4_REGNUM, 4 - len, len,
|
|
|
|
valbuf);
|
|
|
|
else
|
|
|
|
regcache_cooked_read (regcache, TIC6X_A4_REGNUM, valbuf);
|
|
|
|
}
|
|
|
|
else if (len <= 8)
|
|
|
|
{
|
|
|
|
/* For a 5-8 byte structure or union in big-endian, the first byte
|
|
|
|
occupies byte 3 (the MSB) of the upper (odd) register and the
|
|
|
|
remaining bytes fill the decreasingly significant bytes. 5-7
|
|
|
|
byte structures or unions have padding in the LSBs of the
|
|
|
|
lower (even) register. */
|
|
|
|
if (byte_order == BFD_ENDIAN_BIG)
|
|
|
|
{
|
|
|
|
regcache_cooked_read (regcache, TIC6X_A4_REGNUM, valbuf + 4);
|
|
|
|
regcache_cooked_read (regcache, TIC6X_A5_REGNUM, valbuf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
regcache_cooked_read (regcache, TIC6X_A4_REGNUM, valbuf);
|
|
|
|
regcache_cooked_read (regcache, TIC6X_A5_REGNUM, valbuf + 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Write into appropriate registers a function return value
|
|
|
|
of type TYPE, given in virtual format. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
tic6x_store_return_value (struct type *valtype, struct regcache *regcache,
|
|
|
|
enum bfd_endian byte_order, const gdb_byte *valbuf)
|
|
|
|
{
|
|
|
|
int len = TYPE_LENGTH (valtype);
|
|
|
|
|
|
|
|
/* return values of up to 8 bytes are returned in A5:A4 */
|
|
|
|
|
|
|
|
if (len <= 4)
|
|
|
|
{
|
|
|
|
if (len < 3 && byte_order == BFD_ENDIAN_BIG)
|
|
|
|
regcache_cooked_write_part (regcache, TIC6X_A4_REGNUM, 4 - len, len,
|
|
|
|
valbuf);
|
|
|
|
else
|
|
|
|
regcache_cooked_write (regcache, TIC6X_A4_REGNUM, valbuf);
|
|
|
|
}
|
|
|
|
else if (len <= 8)
|
|
|
|
{
|
|
|
|
if (byte_order == BFD_ENDIAN_BIG)
|
|
|
|
{
|
|
|
|
regcache_cooked_write (regcache, TIC6X_A4_REGNUM, valbuf + 4);
|
|
|
|
regcache_cooked_write (regcache, TIC6X_A5_REGNUM, valbuf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
regcache_cooked_write (regcache, TIC6X_A4_REGNUM, valbuf);
|
|
|
|
regcache_cooked_write (regcache, TIC6X_A5_REGNUM, valbuf + 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is the implementation of gdbarch method return_value. */
|
|
|
|
|
|
|
|
static enum return_value_convention
|
2012-05-16 14:35:09 +00:00
|
|
|
tic6x_return_value (struct gdbarch *gdbarch, struct value *function,
|
2011-08-14 14:03:45 +00:00
|
|
|
struct type *type, struct regcache *regcache,
|
|
|
|
gdb_byte *readbuf, const gdb_byte *writebuf)
|
|
|
|
{
|
2012-06-08 14:24:57 +00:00
|
|
|
/* In C++, when function returns an object, even its size is small
|
|
|
|
enough, it stii has to be passed via reference, pointed by register
|
|
|
|
A3. */
|
|
|
|
if (current_language->la_language == language_cplus)
|
|
|
|
{
|
|
|
|
if (type != NULL)
|
|
|
|
{
|
2015-07-06 20:05:06 +00:00
|
|
|
type = check_typedef (type);
|
2012-06-08 14:24:57 +00:00
|
|
|
if (language_pass_by_reference (type))
|
|
|
|
return RETURN_VALUE_STRUCT_CONVENTION;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-14 14:03:45 +00:00
|
|
|
if (TYPE_LENGTH (type) > 8)
|
|
|
|
return RETURN_VALUE_STRUCT_CONVENTION;
|
|
|
|
|
|
|
|
if (readbuf)
|
|
|
|
tic6x_extract_return_value (type, regcache,
|
|
|
|
gdbarch_byte_order (gdbarch), readbuf);
|
|
|
|
if (writebuf)
|
|
|
|
tic6x_store_return_value (type, regcache,
|
|
|
|
gdbarch_byte_order (gdbarch), writebuf);
|
|
|
|
|
|
|
|
return RETURN_VALUE_REGISTER_CONVENTION;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is the implementation of gdbarch method dummy_id. */
|
|
|
|
|
|
|
|
static struct frame_id
|
|
|
|
tic6x_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
|
|
|
|
{
|
|
|
|
return frame_id_build
|
|
|
|
(get_frame_register_unsigned (this_frame, TIC6X_SP_REGNUM),
|
|
|
|
get_frame_pc (this_frame));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the alignment requirement of TYPE. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
tic6x_arg_type_alignment (struct type *type)
|
|
|
|
{
|
|
|
|
int len = TYPE_LENGTH (check_typedef (type));
|
|
|
|
enum type_code typecode = TYPE_CODE (check_typedef (type));
|
|
|
|
|
|
|
|
if (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION)
|
|
|
|
{
|
|
|
|
/* The stack alignment of a structure (and union) passed by value is the
|
|
|
|
smallest power of two greater than or equal to its size.
|
|
|
|
This cannot exceed 8 bytes, which is the largest allowable size for
|
|
|
|
a structure passed by value. */
|
|
|
|
|
|
|
|
if (len <= 2)
|
|
|
|
return len;
|
|
|
|
else if (len <= 4)
|
|
|
|
return 4;
|
|
|
|
else if (len <= 8)
|
|
|
|
return 8;
|
|
|
|
else
|
|
|
|
gdb_assert_not_reached ("unexpected length of data");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (len <= 4)
|
|
|
|
return 4;
|
|
|
|
else if (len == 8)
|
|
|
|
{
|
|
|
|
if (typecode == TYPE_CODE_COMPLEX)
|
|
|
|
return 4;
|
|
|
|
else
|
|
|
|
return 8;
|
|
|
|
}
|
|
|
|
else if (len == 16)
|
|
|
|
{
|
|
|
|
if (typecode == TYPE_CODE_COMPLEX)
|
|
|
|
return 8;
|
|
|
|
else
|
|
|
|
return 16;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
internal_error (__FILE__, __LINE__, _("unexpected length %d of type"),
|
|
|
|
len);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is the implementation of gdbarch method push_dummy_call. */
|
|
|
|
|
|
|
|
static CORE_ADDR
|
|
|
|
tic6x_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
|
|
|
|
struct regcache *regcache, CORE_ADDR bp_addr,
|
|
|
|
int nargs, struct value **args, CORE_ADDR sp,
|
|
|
|
int struct_return, CORE_ADDR struct_addr)
|
|
|
|
{
|
|
|
|
int argreg = 0;
|
|
|
|
int argnum;
|
|
|
|
int stack_offset = 4;
|
|
|
|
int references_offset = 4;
|
|
|
|
CORE_ADDR func_addr = find_function_addr (function, NULL);
|
|
|
|
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
|
|
|
|
struct type *func_type = value_type (function);
|
|
|
|
/* The first arg passed on stack. Mostly the first 10 args are passed by
|
|
|
|
registers. */
|
|
|
|
int first_arg_on_stack = 10;
|
|
|
|
|
|
|
|
/* Set the return address register to point to the entry point of
|
|
|
|
the program, where a breakpoint lies in wait. */
|
|
|
|
regcache_cooked_write_unsigned (regcache, TIC6X_RA_REGNUM, bp_addr);
|
|
|
|
|
|
|
|
/* The caller must pass an argument in A3 containing a destination address
|
|
|
|
for the returned value. The callee returns the object by copying it to
|
|
|
|
the address in A3. */
|
|
|
|
if (struct_return)
|
|
|
|
regcache_cooked_write_unsigned (regcache, 3, struct_addr);
|
|
|
|
|
|
|
|
/* Determine the type of this function. */
|
|
|
|
func_type = check_typedef (func_type);
|
|
|
|
if (TYPE_CODE (func_type) == TYPE_CODE_PTR)
|
|
|
|
func_type = check_typedef (TYPE_TARGET_TYPE (func_type));
|
|
|
|
|
|
|
|
gdb_assert (TYPE_CODE (func_type) == TYPE_CODE_FUNC
|
|
|
|
|| TYPE_CODE (func_type) == TYPE_CODE_METHOD);
|
|
|
|
|
|
|
|
/* For a variadic C function, the last explicitly declared argument and all
|
|
|
|
remaining arguments are passed on the stack. */
|
|
|
|
if (TYPE_VARARGS (func_type))
|
|
|
|
first_arg_on_stack = TYPE_NFIELDS (func_type) - 1;
|
|
|
|
|
2012-06-08 14:24:57 +00:00
|
|
|
/* Now make space on the stack for the args. */
|
|
|
|
for (argnum = 0; argnum < nargs; argnum++)
|
2011-08-14 14:03:45 +00:00
|
|
|
{
|
|
|
|
int len = align_up (TYPE_LENGTH (value_type (args[argnum])), 4);
|
|
|
|
if (argnum >= 10 - argreg)
|
|
|
|
references_offset += len;
|
|
|
|
stack_offset += len;
|
|
|
|
}
|
|
|
|
sp -= stack_offset;
|
|
|
|
/* SP should be 8-byte aligned, see C6000 ABI section 4.4.1
|
|
|
|
Stack Alignment. */
|
|
|
|
sp = align_down (sp, 8);
|
|
|
|
stack_offset = 4;
|
|
|
|
|
|
|
|
/* Now load as many as possible of the first arguments into
|
|
|
|
registers, and push the rest onto the stack. Loop through args
|
|
|
|
from first to last. */
|
2012-06-08 14:24:57 +00:00
|
|
|
for (argnum = 0; argnum < nargs; argnum++)
|
2011-08-14 14:03:45 +00:00
|
|
|
{
|
|
|
|
const gdb_byte *val;
|
|
|
|
struct value *arg = args[argnum];
|
|
|
|
struct type *arg_type = check_typedef (value_type (arg));
|
|
|
|
int len = TYPE_LENGTH (arg_type);
|
|
|
|
enum type_code typecode = TYPE_CODE (arg_type);
|
|
|
|
|
|
|
|
val = value_contents (arg);
|
|
|
|
|
|
|
|
/* Copy the argument to general registers or the stack in
|
|
|
|
register-sized pieces. */
|
|
|
|
if (argreg < first_arg_on_stack)
|
|
|
|
{
|
|
|
|
if (len <= 4)
|
|
|
|
{
|
|
|
|
if (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION)
|
|
|
|
{
|
|
|
|
/* In big-endian,
|
|
|
|
- one-byte structure or union occupies the LSB of single
|
|
|
|
even register.
|
|
|
|
- for two-byte structure or union, the first byte
|
|
|
|
occupies byte 1 of register and the second byte occupies
|
|
|
|
byte 0.
|
|
|
|
so, we write the contents in VAL to the lsp of
|
|
|
|
register. */
|
|
|
|
if (len < 3 && byte_order == BFD_ENDIAN_BIG)
|
|
|
|
regcache_cooked_write_part (regcache, arg_regs[argreg],
|
|
|
|
4 - len, len, val);
|
|
|
|
else
|
|
|
|
regcache_cooked_write (regcache, arg_regs[argreg], val);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* The argument is being passed by value in a single
|
|
|
|
register. */
|
|
|
|
CORE_ADDR regval = extract_unsigned_integer (val, len,
|
|
|
|
byte_order);
|
|
|
|
|
|
|
|
regcache_cooked_write_unsigned (regcache, arg_regs[argreg],
|
|
|
|
regval);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (len <= 8)
|
|
|
|
{
|
|
|
|
if (typecode == TYPE_CODE_STRUCT
|
|
|
|
|| typecode == TYPE_CODE_UNION)
|
|
|
|
{
|
|
|
|
/* For a 5-8 byte structure or union in big-endian, the
|
|
|
|
first byte occupies byte 3 (the MSB) of the upper (odd)
|
|
|
|
register and the remaining bytes fill the decreasingly
|
|
|
|
significant bytes. 5-7 byte structures or unions have
|
|
|
|
padding in the LSBs of the lower (even) register. */
|
|
|
|
if (byte_order == BFD_ENDIAN_BIG)
|
|
|
|
{
|
|
|
|
regcache_cooked_write (regcache,
|
|
|
|
arg_regs[argreg] + 1, val);
|
|
|
|
regcache_cooked_write_part (regcache,
|
|
|
|
arg_regs[argreg], 0,
|
|
|
|
len - 4, val + 4);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
regcache_cooked_write (regcache, arg_regs[argreg],
|
|
|
|
val);
|
|
|
|
regcache_cooked_write_part (regcache,
|
|
|
|
arg_regs[argreg] + 1, 0,
|
|
|
|
len - 4, val + 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* The argument is being passed by value in a pair of
|
|
|
|
registers. */
|
|
|
|
ULONGEST regval = extract_unsigned_integer (val, len,
|
|
|
|
byte_order);
|
|
|
|
|
|
|
|
regcache_cooked_write_unsigned (regcache,
|
|
|
|
arg_regs[argreg],
|
|
|
|
regval);
|
|
|
|
regcache_cooked_write_unsigned (regcache,
|
|
|
|
arg_regs[argreg] + 1,
|
|
|
|
regval >> 32);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* The argument is being passed by reference in a single
|
|
|
|
register. */
|
|
|
|
CORE_ADDR addr;
|
|
|
|
|
|
|
|
/* It is not necessary to adjust REFERENCES_OFFSET to
|
|
|
|
8-byte aligned in some cases, in which 4-byte alignment
|
|
|
|
is sufficient. For simplicity, we adjust
|
|
|
|
REFERENCES_OFFSET to 8-byte aligned. */
|
|
|
|
references_offset = align_up (references_offset, 8);
|
|
|
|
|
|
|
|
addr = sp + references_offset;
|
|
|
|
write_memory (addr, val, len);
|
|
|
|
references_offset += align_up (len, 4);
|
|
|
|
regcache_cooked_write_unsigned (regcache, arg_regs[argreg],
|
|
|
|
addr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
argreg++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* The argument is being passed on the stack. */
|
|
|
|
CORE_ADDR addr;
|
|
|
|
|
|
|
|
/* There are six different cases of alignment, and these rules can
|
|
|
|
be found in tic6x_arg_type_alignment:
|
|
|
|
|
|
|
|
1) 4-byte aligned if size is less than or equal to 4 byte, such
|
|
|
|
as short, int, struct, union etc.
|
|
|
|
2) 8-byte aligned if size is less than or equal to 8-byte, such
|
|
|
|
as double, long long,
|
|
|
|
3) 4-byte aligned if it is of type _Complex float, even its size
|
|
|
|
is 8-byte.
|
|
|
|
4) 8-byte aligned if it is of type _Complex double or _Complex
|
|
|
|
long double, even its size is 16-byte. Because, the address of
|
|
|
|
variable is passed as reference.
|
|
|
|
5) struct and union larger than 8-byte are passed by reference, so
|
|
|
|
it is 4-byte aligned.
|
|
|
|
6) struct and union of size between 4 byte and 8 byte varies.
|
|
|
|
alignment of struct variable is the alignment of its first field,
|
|
|
|
while alignment of union variable is the max of all its fields'
|
|
|
|
alignment. */
|
|
|
|
|
|
|
|
if (len <= 4)
|
|
|
|
; /* Default is 4-byte aligned. Nothing to be done. */
|
|
|
|
else if (len <= 8)
|
|
|
|
stack_offset = align_up (stack_offset,
|
|
|
|
tic6x_arg_type_alignment (arg_type));
|
|
|
|
else if (len == 16)
|
|
|
|
{
|
|
|
|
/* _Complex double or _Complex long double */
|
|
|
|
if (typecode == TYPE_CODE_COMPLEX)
|
|
|
|
{
|
|
|
|
/* The argument is being passed by reference on stack. */
|
|
|
|
CORE_ADDR addr;
|
|
|
|
references_offset = align_up (references_offset, 8);
|
|
|
|
|
|
|
|
addr = sp + references_offset;
|
|
|
|
/* Store variable on stack. */
|
|
|
|
write_memory (addr, val, len);
|
|
|
|
|
|
|
|
references_offset += align_up (len, 4);
|
|
|
|
|
|
|
|
/* Pass the address of variable on stack as reference. */
|
|
|
|
store_unsigned_integer ((gdb_byte *) val, 4, byte_order,
|
|
|
|
addr);
|
|
|
|
len = 4;
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
internal_error (__FILE__, __LINE__,
|
|
|
|
_("unexpected type %d of arg %d"),
|
|
|
|
typecode, argnum);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
internal_error (__FILE__, __LINE__,
|
|
|
|
_("unexpected length %d of arg %d"), len, argnum);
|
|
|
|
|
|
|
|
addr = sp + stack_offset;
|
|
|
|
write_memory (addr, val, len);
|
|
|
|
stack_offset += align_up (len, 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
regcache_cooked_write_signed (regcache, TIC6X_SP_REGNUM, sp);
|
|
|
|
|
|
|
|
/* Return adjusted stack pointer. */
|
|
|
|
return sp;
|
|
|
|
}
|
|
|
|
|
2015-05-26 10:59:17 +00:00
|
|
|
/* This is the implementation of gdbarch method stack_frame_destroyed_p. */
|
2011-08-14 14:03:45 +00:00
|
|
|
|
|
|
|
static int
|
2015-05-26 10:59:17 +00:00
|
|
|
tic6x_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
|
2011-08-14 14:03:45 +00:00
|
|
|
{
|
|
|
|
unsigned long inst = tic6x_fetch_instruction (gdbarch, pc);
|
|
|
|
/* Normally, the epilogue is composed by instruction `b .S2 b3'. */
|
|
|
|
if ((inst & 0x0f83effc) == 0x360)
|
|
|
|
{
|
|
|
|
unsigned int src2 = tic6x_register_number ((inst >> 18) & 0x1f,
|
|
|
|
INST_S_BIT (inst),
|
|
|
|
INST_X_BIT (inst));
|
|
|
|
if (src2 == TIC6X_RA_REGNUM)
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is the implementation of gdbarch method get_longjmp_target. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
tic6x_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
|
|
|
|
{
|
|
|
|
struct gdbarch *gdbarch = get_frame_arch (frame);
|
|
|
|
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
|
|
|
|
CORE_ADDR jb_addr;
|
Use gdb_byte for bytes from the program being debugged.
gdb_byte should be used for bytes from the program being debugged. We
have many places using char or unsigned char instead all over the
existing ports, and more ends up added over time due to copy/paste as
new code is based on old code.
I've greped the tree for "char buf[", and fixed all I found.
Tested by building with --enable-targets=all.
2013-03-01 Pedro Alves <palves@redhat.com>
Use gdb_byte for bytes from the program being debugged.
* arm-tdep.c (arm_store_return_value, arm_get_longjmp_target):
Change type of local 'buf' to gdb_byte.
* avr-tdep.c (avr_frame_prev_register, avr_push_dummy_call): Likewise.
* bfin-tdep.c (bfin_push_dummy_call): Likewise.
* cris-tdep.c (cris_sigcontext_addr)
(cris_sigtramp_frame_unwind_cache): Likewise.
* frv-linux-tdep.c (frv_linux_pc_in_sigtramp)
(frv_linux_sigcontext_reg_addr, frv_linux_sigtramp_frame_cache):
Likewise.
* frv-tdep.c (frv_pseudo_register_write, frv_analyze_prologue): Likewise.
* hppa-hpux-tdep.c (hppa32_hpux_find_global_pointer)
(hppa32_hpux_search_dummy_call_sequence)
(hppa_hpux_supply_save_state): Likewise.
* hppa-linux-tdep.c (insns_match_pattern)
(hppa_linux_find_global_pointer): Likewise.
* hppa-tdep.c (hppa_in_function_epilogue_p)
(skip_prologue_hard_way, hppa_frame_cache): Likewise.
* i386-nto-tdep.c (i386nto_sigcontext_addr): Likewise.
* i386fbsd-tdep.c (i386fbsd_supply_uthread)
(i386fbsd_collect_uthread): Likewise.
* ia64-hpux-tdep.c (ia64_hpux_push_dummy_code): Likewise.
* ia64-linux-tdep.c (ia64_linux_sigcontext_register_address): Likewise.
* ia64-tdep.c (examine_prologue, ia64_frame_cache)
(ia64_frame_prev_register, ia64_sigtramp_frame_cache)
(ia64_sigtramp_frame_prev_register, ia64_access_reg)
(ia64_access_rse_reg, ia64_libunwind_frame_this_id)
(ia64_libunwind_frame_prev_register)
(ia64_libunwind_sigtramp_frame_this_id)
(ia64_find_global_pointer_from_dynamic_section)
(find_extant_func_descr, find_func_descr, ia64_dummy_id)
(ia64_unwind_pc): Likewise.
* iq2000-tdep.c (iq2000_store_return_value): Likewise.
* m68hc11-tdep.c (m68hc11_push_dummy_call)
(m68hc11_extract_return_value): Likewise.
* m68klinux-nat.c (fetch_register, store_register): Likewise.
* mep-tdep.c (mep_pseudo_cr32_read, mep_pseudo_cr32_write)
(mep_get_insn, mep_push_dummy_call): Likewise.
* mips-linux-tdep.c (mips_linux_get_longjmp_target)
(mips_linux_in_dynsym_stub): Likewise.
* mn10300-tdep.c (mep_pseudo_cr32_write): Likewise.
* ppc-linux-nat.c (fetch_register, store_register): Likewise.
* regcache.c (dump_endian_bytes): Change type of parameter 'buf'
to gdb_byte.
* remote-mips.c (mips_set_register): Likewise.
* remote-sim.c (gdbsim_fetch_register): Likewise.
* score-tdep.c (score7_fetch_inst): Change type of parameter
'memblock' and local 'buf' to gdb_byte.
(score7_malloc_and_get_memblock): Change return type to gdb_byte.
Change type of local 'buf' to gdb_byte. Adjust.
(score7_adjust_memblock_ptr): Change type of parameter 'memblock'
to gdb_byte**.
(score7_analyze_prologue): Change type of 'memblock' and
'memblock_ptr' locals to gdb_byte*.
* sh64-tdep.c (sh64_extract_return_value)
(sh64_store_return_value): Change type of local 'buf' to gdb_byte.
* solib-darwin.c (darwin_current_sos, darwin_read_exec_load_addr):
* solib-pa64.c (pa64_solib_create_inferior_hook)
(pa64_open_symbol_file_object): Remove local 'buf'.
* solib-som.c (som_solib_create_inferior_hook, link_map_start)
(som_open_symbol_file_object): Likewise.
* solib-spu.c (spu_current_sos): Likewise.
* spu-linux-nat.c (spu_fetch_inferior_registers): Likewise.
* spu-multiarch.c (parse_spufs_run, spu_fetch_registers)
(spu_store_registers): Likewise.
* target.c (debug_print_register): Likewise.
* tic6x-tdep.c (tic6x_get_longjmp_target): Likewise.
* xstormy16-tdep.c (xstormy16_store_return_value)
(xstormy16_push_dummy_call, xstormy16_resolve_jmp_table_entry)
(xstormy16_find_jmp_table_entry): Likewise.
2013-03-01 15:38:27 +00:00
|
|
|
gdb_byte buf[4];
|
2011-08-14 14:03:45 +00:00
|
|
|
|
|
|
|
/* JMP_BUF is passed by reference in A4. */
|
|
|
|
jb_addr = get_frame_register_unsigned (frame, 4);
|
|
|
|
|
|
|
|
/* JMP_BUF contains 13 elements of type int, and return address is stored
|
|
|
|
in the last slot. */
|
|
|
|
if (target_read_memory (jb_addr + 12 * 4, buf, 4))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
*pc = extract_unsigned_integer (buf, 4, byte_order);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-06-08 14:24:57 +00:00
|
|
|
/* This is the implementation of gdbarch method
|
|
|
|
return_in_first_hidden_param_p. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
tic6x_return_in_first_hidden_param_p (struct gdbarch *gdbarch,
|
|
|
|
struct type *type)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-08-14 14:03:45 +00:00
|
|
|
static struct gdbarch *
|
|
|
|
tic6x_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
|
|
|
|
{
|
|
|
|
struct gdbarch *gdbarch;
|
|
|
|
struct gdbarch_tdep *tdep;
|
|
|
|
struct tdesc_arch_data *tdesc_data = NULL;
|
|
|
|
const struct target_desc *tdesc = info.target_desc;
|
|
|
|
int has_gp = 0;
|
|
|
|
|
|
|
|
/* Check any target description for validity. */
|
|
|
|
if (tdesc_has_registers (tdesc))
|
|
|
|
{
|
|
|
|
const struct tdesc_feature *feature;
|
|
|
|
int valid_p, i;
|
|
|
|
|
|
|
|
feature = tdesc_find_feature (tdesc, "org.gnu.gdb.tic6x.core");
|
|
|
|
|
|
|
|
if (feature == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
tdesc_data = tdesc_data_alloc ();
|
|
|
|
|
|
|
|
valid_p = 1;
|
|
|
|
for (i = 0; i < 32; i++) /* A0 - A15, B0 - B15 */
|
|
|
|
valid_p &= tdesc_numbered_register (feature, tdesc_data, i,
|
|
|
|
tic6x_register_names[i]);
|
|
|
|
|
|
|
|
/* CSR */
|
|
|
|
valid_p &= tdesc_numbered_register (feature, tdesc_data, i++,
|
|
|
|
tic6x_register_names[TIC6X_CSR_REGNUM]);
|
|
|
|
valid_p &= tdesc_numbered_register (feature, tdesc_data, i++,
|
|
|
|
tic6x_register_names[TIC6X_PC_REGNUM]);
|
|
|
|
|
|
|
|
if (!valid_p)
|
|
|
|
{
|
|
|
|
tdesc_data_cleanup (tdesc_data);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
feature = tdesc_find_feature (tdesc, "org.gnu.gdb.tic6x.gp");
|
|
|
|
if (feature)
|
|
|
|
{
|
|
|
|
int j = 0;
|
|
|
|
static const char *const gp[] =
|
|
|
|
{
|
|
|
|
"A16", "A17", "A18", "A19", "A20", "A21", "A22", "A23",
|
|
|
|
"A24", "A25", "A26", "A27", "A28", "A29", "A30", "A31",
|
|
|
|
"B16", "B17", "B18", "B19", "B20", "B21", "B22", "B23",
|
|
|
|
"B24", "B25", "B26", "B27", "B28", "B29", "B30", "B31",
|
|
|
|
};
|
|
|
|
|
|
|
|
has_gp = 1;
|
|
|
|
valid_p = 1;
|
|
|
|
for (j = 0; j < 32; j++) /* A16 - A31, B16 - B31 */
|
|
|
|
valid_p &= tdesc_numbered_register (feature, tdesc_data, i++,
|
|
|
|
gp[j]);
|
|
|
|
|
|
|
|
if (!valid_p)
|
|
|
|
{
|
|
|
|
tdesc_data_cleanup (tdesc_data);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
feature = tdesc_find_feature (tdesc, "org.gnu.gdb.tic6x.c6xp");
|
|
|
|
if (feature)
|
|
|
|
{
|
|
|
|
valid_p &= tdesc_numbered_register (feature, tdesc_data, i++, "TSR");
|
|
|
|
valid_p &= tdesc_numbered_register (feature, tdesc_data, i++, "ILC");
|
|
|
|
valid_p &= tdesc_numbered_register (feature, tdesc_data, i++, "RILC");
|
|
|
|
|
|
|
|
if (!valid_p)
|
|
|
|
{
|
|
|
|
tdesc_data_cleanup (tdesc_data);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Find a candidate among extant architectures. */
|
|
|
|
for (arches = gdbarch_list_lookup_by_info (arches, &info);
|
|
|
|
arches != NULL;
|
|
|
|
arches = gdbarch_list_lookup_by_info (arches->next, &info))
|
|
|
|
{
|
|
|
|
tdep = gdbarch_tdep (arches->gdbarch);
|
|
|
|
|
|
|
|
if (has_gp != tdep->has_gp)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (tdep && tdep->breakpoint)
|
|
|
|
return arches->gdbarch;
|
|
|
|
}
|
|
|
|
|
Replace some xmalloc-family functions with XNEW-family ones
This patch is part of the make-gdb-buildable-in-C++ effort. The idea is
to change some calls to the xmalloc family of functions to calls to the
equivalents in the XNEW family. This avoids adding an explicit cast, so
it keeps the code a bit more readable. Some of them also map relatively
well to a C++ equivalent (XNEW (struct foo) -> new foo), so it will be
possible to do scripted replacements if needed.
I only changed calls that were obviously allocating memory for one or
multiple "objects". Allocation of variable sizes (such as strings or
buffer handling) will be for later (and won't use XNEW).
- xmalloc (sizeof (struct foo)) -> XNEW (struct foo)
- xmalloc (num * sizeof (struct foo)) -> XNEWVEC (struct foo, num)
- xcalloc (1, sizeof (struct foo)) -> XCNEW (struct foo)
- xcalloc (num, sizeof (struct foo)) -> XCNEWVEC (struct foo, num)
- xrealloc (p, num * sizeof (struct foo) -> XRESIZEVEC (struct foo, p, num)
- obstack_alloc (ob, sizeof (struct foo)) -> XOBNEW (ob, struct foo)
- obstack_alloc (ob, num * sizeof (struct foo)) -> XOBNEWVEC (ob, struct foo, num)
- alloca (sizeof (struct foo)) -> XALLOCA (struct foo)
- alloca (num * sizeof (struct foo)) -> XALLOCAVEC (struct foo, num)
Some instances of xmalloc followed by memset to zero the buffer were
replaced by XCNEW or XCNEWVEC.
I regtested on x86-64, Ubuntu 14.04, but the patch touches many
architecture-specific files. For those I'll have to rely on the
buildbot or people complaining that I broke their gdb.
gdb/ChangeLog:
* aarch64-linux-nat.c (aarch64_add_process): Likewise.
* aarch64-tdep.c (aarch64_gdbarch_init): Likewise.
* ada-exp.y (write_ambiguous_var): Likewise.
* ada-lang.c (resolve_subexp): Likewise.
(user_select_syms): Likewise.
(assign_aggregate): Likewise.
(ada_evaluate_subexp): Likewise.
(cache_symbol): Likewise.
* addrmap.c (allocate_key): Likewise.
(addrmap_create_mutable): Likewise.
* aix-thread.c (sync_threadlists): Likewise.
* alpha-tdep.c (alpha_push_dummy_call): Likewise.
(alpha_gdbarch_init): Likewise.
* amd64-windows-tdep.c (amd64_windows_push_arguments): Likewise.
* arm-linux-nat.c (arm_linux_add_process): Likewise.
* arm-linux-tdep.c (arm_linux_displaced_step_copy_insn): Likewise.
* arm-tdep.c (push_stack_item): Likewise.
(arm_displaced_step_copy_insn): Likewise.
(arm_gdbarch_init): Likewise.
(_initialize_arm_tdep): Likewise.
* avr-tdep.c (push_stack_item): Likewise.
* ax-general.c (new_agent_expr): Likewise.
* block.c (block_initialize_namespace): Likewise.
* breakpoint.c (alloc_counted_command_line): Likewise.
(update_dprintf_command_list): Likewise.
(parse_breakpoint_sals): Likewise.
(decode_static_tracepoint_spec): Likewise.
(until_break_command): Likewise.
(clear_command): Likewise.
(update_global_location_list): Likewise.
(get_breakpoint_objfile_data) Likewise.
* btrace.c (ftrace_new_function): Likewise.
(btrace_set_insn_history): Likewise.
(btrace_set_call_history): Likewise.
* buildsym.c (add_symbol_to_list): Likewise.
(record_pending_block): Likewise.
(start_subfile): Likewise.
(start_buildsym_compunit): Likewise.
(push_subfile): Likewise.
(end_symtab_get_static_block): Likewise.
(buildsym_init): Likewise.
* cli/cli-cmds.c (source_command): Likewise.
* cli/cli-decode.c (add_cmd): Likewise.
* cli/cli-script.c (build_command_line): Likewise.
(setup_user_args): Likewise.
(realloc_body_list): Likewise.
(process_next_line): Likewise.
(copy_command_lines): Likewise.
* cli/cli-setshow.c (do_set_command): Likewise.
* coff-pe-read.c (read_pe_exported_syms): Likewise.
* coffread.c (coff_locate_sections): Likewise.
(coff_symtab_read): Likewise.
(coff_read_struct_type): Likewise.
* common/cleanups.c (make_my_cleanup2): Likewise.
* common/common-exceptions.c (throw_it): Likewise.
* common/filestuff.c (make_cleanup_close): Likewise.
* common/format.c (parse_format_string): Likewise.
* common/queue.h (DEFINE_QUEUE_P): Likewise.
* compile/compile-object-load.c (munmap_list_add): Likewise.
(compile_object_load): Likewise.
* compile/compile-object-run.c (compile_object_run): Likewise.
* compile/compile.c (append_args): Likewise.
* corefile.c (specify_exec_file_hook): Likewise.
* cp-support.c (make_symbol_overload_list): Likewise.
* cris-tdep.c (push_stack_item): Likewise.
(cris_gdbarch_init): Likewise.
* ctf.c (ctf_trace_file_writer_new): Likewise.
* dbxread.c (init_header_files): Likewise.
(add_new_header_file): Likewise.
(init_bincl_list): Likewise.
(dbx_end_psymtab): Likewise.
(start_psymtab): Likewise.
(dbx_end_psymtab): Likewise.
* dcache.c (dcache_init): Likewise.
* dictionary.c (dict_create_hashed): Likewise.
(dict_create_hashed_expandable): Likewise.
(dict_create_linear): Likewise.
(dict_create_linear_expandable): Likewise.
* dtrace-probe.c (dtrace_process_dof_probe): Likewise.
* dummy-frame.c (register_dummy_frame_dtor): Likewise.
* dwarf2-frame-tailcall.c (cache_new_ref1): Likewise.
* dwarf2-frame.c (dwarf2_build_frame_info): Likewise.
(decode_frame_entry_1): Likewise.
* dwarf2expr.c (new_dwarf_expr_context): Likewise.
* dwarf2loc.c (dwarf2_compile_expr_to_ax): Likewise.
* dwarf2read.c (dwarf2_has_info): Likewise.
(create_signatured_type_table_from_index): Likewise.
(dwarf2_read_index): Likewise.
(dw2_get_file_names_reader): Likewise.
(create_all_type_units): Likewise.
(read_cutu_die_from_dwo): Likewise.
(init_tu_and_read_dwo_dies): Likewise.
(init_cutu_and_read_dies): Likewise.
(create_all_comp_units): Likewise.
(queue_comp_unit): Likewise.
(inherit_abstract_dies): Likewise.
(read_call_site_scope): Likewise.
(dwarf2_add_field): Likewise.
(dwarf2_add_typedef): Likewise.
(dwarf2_add_member_fn): Likewise.
(attr_to_dynamic_prop): Likewise.
(abbrev_table_alloc_abbrev): Likewise.
(abbrev_table_read_table): Likewise.
(add_include_dir): Likewise.
(add_file_name): Likewise.
(dwarf_decode_line_header): Likewise.
(dwarf2_const_value_attr): Likewise.
(dwarf_alloc_block): Likewise.
(parse_macro_definition): Likewise.
(set_die_type): Likewise.
(write_psymtabs_to_index): Likewise.
(create_cus_from_index): Likewise.
(dwarf2_create_include_psymtab): Likewise.
(process_psymtab_comp_unit_reader): Likewise.
(build_type_psymtab_dependencies): Likewise.
(read_comp_units_from_section): Likewise.
(compute_compunit_symtab_includes): Likewise.
(create_dwo_unit_in_dwp_v1): Likewise.
(create_dwo_unit_in_dwp_v2): Likewise.
(read_func_scope): Likewise.
(process_structure_scope): Likewise.
(mark_common_block_symbol_computed): Likewise.
(load_partial_dies): Likewise.
(dwarf2_symbol_mark_computed): Likewise.
* elfread.c (elf_symfile_segments): Likewise.
(elf_read_minimal_symbols): Likewise.
* environ.c (make_environ): Likewise.
* eval.c (evaluate_subexp_standard): Likewise.
* event-loop.c (create_file_handler): Likewise.
(create_async_signal_handler): Likewise.
(create_async_event_handler): Likewise.
(create_timer): Likewise.
* exec.c (build_section_table): Likewise.
* fbsd-nat.c (fbsd_remember_child): Likewise.
* fork-child.c (fork_inferior): Likewise.
* frv-tdep.c (new_variant): Likewise.
* gdbarch.sh (gdbarch_alloc): Likewise.
(append_name): Likewise.
* gdbtypes.c (rank_function): Likewise.
(copy_type_recursive): Likewise.
(add_dyn_prop): Likewise.
* gnu-nat.c (make_proc): Likewise.
(make_inf): Likewise.
(gnu_write_inferior): Likewise.
* gnu-v3-abi.c (build_gdb_vtable_type): Likewise.
(build_std_type_info_type): Likewise.
* guile/scm-param.c (compute_enum_list): Likewise.
* guile/scm-utils.c (gdbscm_parse_function_args): Likewise.
* guile/scm-value.c (gdbscm_value_call): Likewise.
* h8300-tdep.c (h8300_gdbarch_init): Likewise.
* hppa-tdep.c (hppa_init_objfile_priv_data): Likewise.
(read_unwind_info): Likewise.
* ia64-tdep.c (ia64_gdbarch_init): Likewise.
* infcall.c (dummy_frame_context_saver_setup): Likewise.
(call_function_by_hand_dummy): Likewise.
* infcmd.c (step_once): Likewise.
(finish_forward): Likewise.
(attach_command): Likewise.
(notice_new_inferior): Likewise.
* inferior.c (add_inferior_silent): Likewise.
* infrun.c (add_displaced_stepping_state): Likewise.
(save_infcall_control_state): Likewise.
(save_inferior_ptid): Likewise.
(_initialize_infrun): Likewise.
* jit.c (bfd_open_from_target_memory): Likewise.
(jit_gdbarch_data_init): Likewise.
* language.c (add_language): Likewise.
* linespec.c (decode_line_2): Likewise.
* linux-nat.c (add_to_pid_list): Likewise.
(add_initial_lwp): Likewise.
* linux-thread-db.c (add_thread_db_info): Likewise.
(record_thread): Likewise.
(info_auto_load_libthread_db): Likewise.
* m32c-tdep.c (m32c_gdbarch_init): Likewise.
* m68hc11-tdep.c (m68hc11_gdbarch_init): Likewise.
* m68k-tdep.c (m68k_gdbarch_init): Likewise.
* m88k-tdep.c (m88k_analyze_prologue): Likewise.
* macrocmd.c (macro_define_command): Likewise.
* macroexp.c (gather_arguments): Likewise.
* macroscope.c (sal_macro_scope): Likewise.
* macrotab.c (new_macro_table): Likewise.
* mdebugread.c (push_parse_stack): Likewise.
(parse_partial_symbols): Likewise.
(parse_symbol): Likewise.
(psymtab_to_symtab_1): Likewise.
(new_block): Likewise.
(new_psymtab): Likewise.
(mdebug_build_psymtabs): Likewise.
(add_pending): Likewise.
(elfmdebug_build_psymtabs): Likewise.
* mep-tdep.c (mep_gdbarch_init): Likewise.
* mi/mi-main.c (mi_execute_command): Likewise.
* mi/mi-parse.c (mi_parse_argv): Likewise.
* minidebug.c (lzma_open): Likewise.
* minsyms.c (terminate_minimal_symbol_table): Likewise.
* mips-linux-nat.c (mips_linux_insert_watchpoint): Likewise.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* mn10300-tdep.c (mn10300_gdbarch_init): Likewise.
* msp430-tdep.c (msp430_gdbarch_init): Likewise.
* mt-tdep.c (mt_registers_info): Likewise.
* nat/aarch64-linux.c (aarch64_linux_new_thread): Likewise.
* nat/linux-btrace.c (linux_enable_bts): Likewise.
(linux_enable_pt): Likewise.
* nat/linux-osdata.c (linux_xfer_osdata_processes): Likewise.
(linux_xfer_osdata_processgroups): Likewise.
* nios2-tdep.c (nios2_gdbarch_init): Likewise.
* nto-procfs.c (procfs_meminfo): Likewise.
* objc-lang.c (start_msglist): Likewise.
(selectors_info): Likewise.
(classes_info): Likewise.
(find_methods): Likewise.
* objfiles.c (allocate_objfile): Likewise.
(update_section_map): Likewise.
* osabi.c (gdbarch_register_osabi): Likewise.
(gdbarch_register_osabi_sniffer): Likewise.
* parse.c (start_arglist): Likewise.
* ppc-linux-nat.c (hwdebug_find_thread_points_by_tid): Likewise.
(hwdebug_insert_point): Likewise.
* printcmd.c (display_command): Likewise.
(ui_printf): Likewise.
* procfs.c (create_procinfo): Likewise.
(load_syscalls): Likewise.
(proc_get_LDT_entry): Likewise.
(proc_update_threads): Likewise.
* prologue-value.c (make_pv_area): Likewise.
(pv_area_store): Likewise.
* psymtab.c (extend_psymbol_list): Likewise.
(init_psymbol_list): Likewise.
(allocate_psymtab): Likewise.
* python/py-inferior.c (add_thread_object): Likewise.
* python/py-param.c (compute_enum_values): Likewise.
* python/py-value.c (valpy_call): Likewise.
* python/py-varobj.c (py_varobj_iter_next): Likewise.
* python/python.c (ensure_python_env): Likewise.
* record-btrace.c (record_btrace_start_replaying): Likewise.
* record-full.c (record_full_reg_alloc): Likewise.
(record_full_mem_alloc): Likewise.
(record_full_end_alloc): Likewise.
(record_full_core_xfer_partial): Likewise.
* regcache.c (get_thread_arch_aspace_regcache): Likewise.
* remote-fileio.c (remote_fileio_init_fd_map): Likewise.
* remote-notif.c (remote_notif_state_allocate): Likewise.
* remote.c (demand_private_info): Likewise.
(remote_notif_stop_alloc_reply): Likewise.
(remote_enable_btrace): Likewise.
* reverse.c (save_bookmark_command): Likewise.
* rl78-tdep.c (rl78_gdbarch_init): Likewise.
* rx-tdep.c (rx_gdbarch_init): Likewise.
* s390-linux-nat.c (s390_insert_watchpoint): Likewise.
* ser-go32.c (dos_get_tty_state): Likewise.
(dos_copy_tty_state): Likewise.
* ser-mingw.c (ser_windows_open): Likewise.
(ser_console_wait_handle): Likewise.
(ser_console_get_tty_state): Likewise.
(make_pipe_state): Likewise.
(net_windows_open): Likewise.
* ser-unix.c (hardwire_get_tty_state): Likewise.
(hardwire_copy_tty_state): Likewise.
* solib-aix.c (solib_aix_new_lm_info): Likewise.
* solib-dsbt.c (dsbt_current_sos): Likewise.
(dsbt_relocate_main_executable): Likewise.
* solib-frv.c (frv_current_sos): Likewise.
(frv_relocate_main_executable): Likewise.
* solib-spu.c (spu_bfd_fopen): Likewise.
* solib-svr4.c (lm_info_read): Likewise.
(svr4_copy_library_list): Likewise.
(svr4_default_sos): Likewise.
* source.c (find_source_lines): Likewise.
(line_info): Likewise.
(add_substitute_path_rule): Likewise.
* spu-linux-nat.c (spu_bfd_open): Likewise.
* spu-tdep.c (info_spu_dma_cmdlist): Likewise.
* stabsread.c (dbx_lookup_type): Likewise.
(read_type): Likewise.
(read_member_functions): Likewise.
(read_struct_fields): Likewise.
(read_baseclasses): Likewise.
(read_args): Likewise.
(_initialize_stabsread): Likewise.
* stack.c (func_command): Likewise.
* stap-probe.c (handle_stap_probe): Likewise.
* symfile.c (addrs_section_sort): Likewise.
(addr_info_make_relative): Likewise.
(load_section_callback): Likewise.
(add_symbol_file_command): Likewise.
(init_filename_language_table): Likewise.
* symtab.c (create_filename_seen_cache): Likewise.
(sort_search_symbols_remove_dups): Likewise.
(search_symbols): Likewise.
* target.c (make_cleanup_restore_target_terminal): Likewise.
* thread.c (new_thread): Likewise.
(enable_thread_stack_temporaries): Likewise.
(make_cleanup_restore_current_thread): Likewise.
(thread_apply_all_command): Likewise.
* tic6x-tdep.c (tic6x_gdbarch_init): Likewise.
* top.c (gdb_readline_wrapper): Likewise.
* tracefile-tfile.c (tfile_trace_file_writer_new): Likewise.
* tracepoint.c (trace_find_line_command): Likewise.
(all_tracepoint_actions_and_cleanup): Likewise.
(make_cleanup_restore_current_traceframe): Likewise.
(get_uploaded_tp): Likewise.
(get_uploaded_tsv): Likewise.
* tui/tui-data.c (tui_alloc_generic_win_info): Likewise.
(tui_alloc_win_info): Likewise.
(tui_alloc_content): Likewise.
(tui_add_content_elements): Likewise.
* tui/tui-disasm.c (tui_find_disassembly_address): Likewise.
(tui_set_disassem_content): Likewise.
* ui-file.c (ui_file_new): Likewise.
(stdio_file_new): Likewise.
(tee_file_new): Likewise.
* utils.c (make_cleanup_restore_integer): Likewise.
(add_internal_problem_command): Likewise.
* v850-tdep.c (v850_gdbarch_init): Likewise.
* valops.c (find_oload_champ): Likewise.
* value.c (allocate_value_lazy): Likewise.
(record_latest_value): Likewise.
(create_internalvar): Likewise.
* varobj.c (install_variable): Likewise.
(new_variable): Likewise.
(new_root_variable): Likewise.
(cppush): Likewise.
(_initialize_varobj): Likewise.
* windows-nat.c (windows_make_so): Likewise.
* x86-nat.c (x86_add_process): Likewise.
* xcoffread.c (arrange_linetable): Likewise.
(allocate_include_entry): Likewise.
(process_linenos): Likewise.
(SYMBOL_DUP): Likewise.
(xcoff_start_psymtab): Likewise.
(xcoff_end_psymtab): Likewise.
* xml-support.c (gdb_xml_parse_attr_ulongest): Likewise.
* xtensa-tdep.c (xtensa_register_type): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
gdb/gdbserver/ChangeLog:
* ax.c (gdb_parse_agent_expr): Likewise.
(compile_bytecodes): Likewise.
* dll.c (loaded_dll): Likewise.
* event-loop.c (append_callback_event): Likewise.
(create_file_handler): Likewise.
(create_file_event): Likewise.
* hostio.c (handle_open): Likewise.
* inferiors.c (add_thread): Likewise.
(add_process): Likewise.
* linux-aarch64-low.c (aarch64_linux_new_process): Likewise.
* linux-arm-low.c (arm_new_process): Likewise.
(arm_new_thread): Likewise.
* linux-low.c (add_to_pid_list): Likewise.
(linux_add_process): Likewise.
(handle_extended_wait): Likewise.
(add_lwp): Likewise.
(enqueue_one_deferred_signal): Likewise.
(enqueue_pending_signal): Likewise.
(linux_resume_one_lwp_throw): Likewise.
(linux_resume_one_thread): Likewise.
(linux_read_memory): Likewise.
(linux_write_memory): Likewise.
* linux-mips-low.c (mips_linux_new_process): Likewise.
(mips_linux_new_thread): Likewise.
(mips_add_watchpoint): Likewise.
* linux-x86-low.c (initialize_low_arch): Likewise.
* lynx-low.c (lynx_add_process): Likewise.
* mem-break.c (set_raw_breakpoint_at): Likewise.
(set_breakpoint): Likewise.
(add_condition_to_breakpoint): Likewise.
(add_commands_to_breakpoint): Likewise.
(clone_agent_expr): Likewise.
(clone_one_breakpoint): Likewise.
* regcache.c (new_register_cache): Likewise.
* remote-utils.c (look_up_one_symbol): Likewise.
* server.c (queue_stop_reply): Likewise.
(start_inferior): Likewise.
(queue_stop_reply_callback): Likewise.
(handle_target_event): Likewise.
* spu-low.c (fetch_ppc_memory): Likewise.
(store_ppc_memory): Likewise.
* target.c (set_target_ops): Likewise.
* thread-db.c (thread_db_load_search): Likewise.
(try_thread_db_load_1): Likewise.
* tracepoint.c (add_tracepoint): Likewise.
(add_tracepoint_action): Likewise.
(create_trace_state_variable): Likewise.
(cmd_qtdpsrc): Likewise.
(cmd_qtro): Likewise.
(add_while_stepping_state): Likewise.
* win32-low.c (child_add_thread): Likewise.
(get_image_name): Likewise.
2015-08-26 21:16:07 +00:00
|
|
|
tdep = XCNEW (struct gdbarch_tdep);
|
2011-08-14 14:03:45 +00:00
|
|
|
|
|
|
|
tdep->has_gp = has_gp;
|
|
|
|
gdbarch = gdbarch_alloc (&info, tdep);
|
|
|
|
|
|
|
|
/* Data type sizes. */
|
|
|
|
set_gdbarch_ptr_bit (gdbarch, 32);
|
|
|
|
set_gdbarch_addr_bit (gdbarch, 32);
|
|
|
|
set_gdbarch_short_bit (gdbarch, 16);
|
|
|
|
set_gdbarch_int_bit (gdbarch, 32);
|
|
|
|
set_gdbarch_long_bit (gdbarch, 32);
|
|
|
|
set_gdbarch_long_long_bit (gdbarch, 64);
|
|
|
|
set_gdbarch_float_bit (gdbarch, 32);
|
|
|
|
set_gdbarch_double_bit (gdbarch, 64);
|
|
|
|
|
|
|
|
set_gdbarch_float_format (gdbarch, floatformats_ieee_single);
|
|
|
|
set_gdbarch_double_format (gdbarch, floatformats_ieee_double);
|
|
|
|
|
|
|
|
/* The register set. */
|
|
|
|
set_gdbarch_num_regs (gdbarch, TIC6X_NUM_REGS);
|
|
|
|
set_gdbarch_sp_regnum (gdbarch, TIC6X_SP_REGNUM);
|
|
|
|
set_gdbarch_pc_regnum (gdbarch, TIC6X_PC_REGNUM);
|
|
|
|
|
|
|
|
set_gdbarch_register_name (gdbarch, tic6x_register_name);
|
|
|
|
set_gdbarch_register_type (gdbarch, tic6x_register_type);
|
|
|
|
|
|
|
|
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
|
|
|
|
|
|
|
|
set_gdbarch_skip_prologue (gdbarch, tic6x_skip_prologue);
|
|
|
|
set_gdbarch_breakpoint_from_pc (gdbarch, tic6x_breakpoint_from_pc);
|
|
|
|
|
|
|
|
set_gdbarch_unwind_pc (gdbarch, tic6x_unwind_pc);
|
|
|
|
set_gdbarch_unwind_sp (gdbarch, tic6x_unwind_sp);
|
|
|
|
|
|
|
|
/* Unwinding. */
|
|
|
|
dwarf2_append_unwinders (gdbarch);
|
|
|
|
|
|
|
|
frame_unwind_append_unwinder (gdbarch, &tic6x_stub_unwind);
|
|
|
|
frame_unwind_append_unwinder (gdbarch, &tic6x_frame_unwind);
|
2014-02-10 18:00:01 +00:00
|
|
|
frame_base_set_default (gdbarch, &tic6x_frame_base);
|
2011-08-14 14:03:45 +00:00
|
|
|
|
|
|
|
dwarf2_frame_set_init_reg (gdbarch, tic6x_dwarf2_frame_init_reg);
|
|
|
|
|
|
|
|
/* Single stepping. */
|
|
|
|
set_gdbarch_software_single_step (gdbarch, tic6x_software_single_step);
|
|
|
|
|
|
|
|
set_gdbarch_print_insn (gdbarch, tic6x_print_insn);
|
|
|
|
|
|
|
|
/* Call dummy code. */
|
|
|
|
set_gdbarch_frame_align (gdbarch, tic6x_frame_align);
|
|
|
|
|
|
|
|
set_gdbarch_return_value (gdbarch, tic6x_return_value);
|
|
|
|
|
|
|
|
set_gdbarch_dummy_id (gdbarch, tic6x_dummy_id);
|
|
|
|
|
|
|
|
/* Enable inferior call support. */
|
|
|
|
set_gdbarch_push_dummy_call (gdbarch, tic6x_push_dummy_call);
|
|
|
|
|
|
|
|
set_gdbarch_get_longjmp_target (gdbarch, tic6x_get_longjmp_target);
|
|
|
|
|
2015-05-26 10:59:17 +00:00
|
|
|
set_gdbarch_stack_frame_destroyed_p (gdbarch, tic6x_stack_frame_destroyed_p);
|
2011-08-14 14:03:45 +00:00
|
|
|
|
2012-06-08 14:24:57 +00:00
|
|
|
set_gdbarch_return_in_first_hidden_param_p (gdbarch,
|
|
|
|
tic6x_return_in_first_hidden_param_p);
|
|
|
|
|
2011-08-14 14:03:45 +00:00
|
|
|
/* Hook in ABI-specific overrides, if they have been registered. */
|
|
|
|
gdbarch_init_osabi (info, gdbarch);
|
|
|
|
|
|
|
|
if (tdesc_data)
|
|
|
|
tdesc_use_registers (gdbarch, tdesc, tdesc_data);
|
|
|
|
|
|
|
|
return gdbarch;
|
|
|
|
}
|
|
|
|
|
2012-03-02 00:06:13 +00:00
|
|
|
/* -Wmissing-prototypes */
|
|
|
|
extern initialize_file_ftype _initialize_tic6x_tdep;
|
|
|
|
|
2011-08-14 14:03:45 +00:00
|
|
|
void
|
|
|
|
_initialize_tic6x_tdep (void)
|
|
|
|
{
|
|
|
|
register_gdbarch_init (bfd_arch_tic6x, tic6x_gdbarch_init);
|
|
|
|
|
|
|
|
initialize_tdesc_tic6x_c64xp ();
|
|
|
|
initialize_tdesc_tic6x_c64x ();
|
|
|
|
initialize_tdesc_tic6x_c62x ();
|
|
|
|
}
|