mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-09 04:21:49 +08:00
8480a37e14
We currently pass frames to function by value, as `frame_info_ptr`. This is somewhat expensive: - the size of `frame_info_ptr` is 64 bytes, which is a bit big to pass by value - the constructors and destructor link/unlink the object in the global `frame_info_ptr::frame_list` list. This is an `intrusive_list`, so it's not so bad: it's just assigning a few points, there's no memory allocation as if it was `std::list`, but still it's useless to do that over and over. As suggested by Tom Tromey, change many function signatures to accept `const frame_info_ptr &` instead of `frame_info_ptr`. Some functions reassign their `frame_info_ptr` parameter, like: void the_func (frame_info_ptr frame) { for (; frame != nullptr; frame = get_prev_frame (frame)) { ... } } I wondered what to do about them, do I leave them as-is or change them (and need to introduce a separate local variable that can be re-assigned). I opted for the later for consistency. It might not be clear why some functions take `const frame_info_ptr &` while others take `frame_info_ptr`. Also, if a function took a `frame_info_ptr` because it did re-assign its parameter, I doubt that we would think to change it to `const frame_info_ptr &` should the implementation change such that it doesn't need to take `frame_info_ptr` anymore. It seems better to have a simple rule and apply it everywhere. Change-Id: I59d10addef687d157f82ccf4d54f5dde9a963fd0 Approved-By: Andrew Burgess <aburgess@redhat.com>
209 lines
7.0 KiB
C
209 lines
7.0 KiB
C
/* Target dependent code for ARC architecture, for GDB.
|
|
|
|
Copyright 2005-2024 Free Software Foundation, Inc.
|
|
Contributed by Synopsys Inc.
|
|
|
|
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/>. */
|
|
|
|
#ifndef ARC_TDEP_H
|
|
#define ARC_TDEP_H
|
|
|
|
/* Need disassemble_info. */
|
|
#include "dis-asm.h"
|
|
#include "gdbarch.h"
|
|
#include "arch/arc.h"
|
|
|
|
/* To simplify GDB code this enum assumes that internal regnums should be same
|
|
as architectural register numbers, i.e. PCL regnum is 63. This allows to
|
|
use internal GDB regnums as architectural numbers when dealing with
|
|
instruction encodings, for example when analyzing what are the registers
|
|
saved in function prologue. */
|
|
|
|
enum arc_regnum
|
|
{
|
|
/* Core registers. */
|
|
ARC_R0_REGNUM = 0,
|
|
ARC_R1_REGNUM = 1,
|
|
ARC_R4_REGNUM = 4,
|
|
ARC_R7_REGNUM = 7,
|
|
ARC_R9_REGNUM = 9,
|
|
ARC_R13_REGNUM = 13,
|
|
ARC_R16_REGNUM = 16,
|
|
ARC_R25_REGNUM = 25,
|
|
/* Global data pointer. */
|
|
ARC_GP_REGNUM,
|
|
/* Frame pointer. */
|
|
ARC_FP_REGNUM,
|
|
/* Stack pointer. */
|
|
ARC_SP_REGNUM,
|
|
/* Return address from interrupt. */
|
|
ARC_ILINK_REGNUM,
|
|
ARC_R30_REGNUM,
|
|
/* Return address from function. */
|
|
ARC_BLINK_REGNUM,
|
|
/* Accumulator registers. */
|
|
ARC_R58_REGNUM = 58,
|
|
ARC_R59_REGNUM,
|
|
/* Zero-delay loop counter. */
|
|
ARC_LP_COUNT_REGNUM = 60,
|
|
/* Reserved register number. There should never be a register with such
|
|
number, this name is needed only for a sanity check in
|
|
arc_cannot_(fetch|store)_register. */
|
|
ARC_RESERVED_REGNUM,
|
|
/* Long-immediate value. This is not a physical register - if instruction
|
|
has register 62 as an operand, then this operand is a literal value
|
|
stored in the instruction memory right after the instruction itself.
|
|
This value is required in this enumeration as an architectural number
|
|
for instruction analysis. */
|
|
ARC_LIMM_REGNUM,
|
|
/* Program counter, aligned to 4-bytes, read-only. */
|
|
ARC_PCL_REGNUM,
|
|
ARC_LAST_CORE_REGNUM = ARC_PCL_REGNUM,
|
|
|
|
/* AUX registers. */
|
|
/* Actual program counter. */
|
|
ARC_PC_REGNUM,
|
|
ARC_FIRST_AUX_REGNUM = ARC_PC_REGNUM,
|
|
/* Status register. */
|
|
ARC_STATUS32_REGNUM,
|
|
/* Zero-delay loop start instruction. */
|
|
ARC_LP_START_REGNUM,
|
|
/* Zero-delay loop next-after-last instruction. */
|
|
ARC_LP_END_REGNUM,
|
|
/* Branch target address. */
|
|
ARC_BTA_REGNUM,
|
|
/* Exception return address. */
|
|
ARC_ERET_REGNUM,
|
|
ARC_LAST_AUX_REGNUM = ARC_ERET_REGNUM,
|
|
ARC_LAST_REGNUM = ARC_LAST_AUX_REGNUM,
|
|
|
|
/* Additional ABI constants. */
|
|
ARC_FIRST_ARG_REGNUM = ARC_R0_REGNUM,
|
|
ARC_LAST_ARG_REGNUM = ARC_R7_REGNUM,
|
|
ARC_FIRST_CALLEE_SAVED_REGNUM = ARC_R13_REGNUM,
|
|
ARC_LAST_CALLEE_SAVED_REGNUM = ARC_R25_REGNUM,
|
|
};
|
|
|
|
/* Number of bytes in ARC register. All ARC registers are considered 32-bit.
|
|
Those registers, which are actually shorter has zero-on-read for extra bits.
|
|
Longer registers are represented as pairs of 32-bit registers. */
|
|
#define ARC_REGISTER_SIZE 4
|
|
|
|
/* STATUS32 register: hardware loops disabled bit. */
|
|
#define ARC_STATUS32_L_MASK (1 << 12)
|
|
/* STATUS32 register: current instruction is a delay slot. */
|
|
#define ARC_STATUS32_DE_MASK (1 << 6)
|
|
|
|
/* Special value for register offset arrays. */
|
|
#define ARC_OFFSET_NO_REGISTER (-1)
|
|
|
|
#define arc_print(fmt, args...) gdb_printf (gdb_stdlog, fmt, ##args)
|
|
|
|
extern bool arc_debug;
|
|
|
|
/* Print an "arc" debug statement. */
|
|
|
|
#define arc_debug_printf(fmt, ...) \
|
|
debug_prefixed_printf_cond (arc_debug, "arc", fmt, ##__VA_ARGS__)
|
|
|
|
/* Target-dependent information. */
|
|
|
|
struct arc_gdbarch_tdep : gdbarch_tdep_base
|
|
{
|
|
/* Offset to PC value in jump buffer. If this is negative, longjmp
|
|
support will be disabled. */
|
|
int jb_pc = 0;
|
|
|
|
/* Whether target has hardware (aka zero-delay) loops. */
|
|
bool has_hw_loops = false;
|
|
|
|
/* Detect sigtramp. */
|
|
bool (*is_sigtramp) (const frame_info_ptr &) = nullptr;
|
|
|
|
/* Get address of sigcontext for sigtramp. */
|
|
CORE_ADDR (*sigcontext_addr) (const frame_info_ptr &) = nullptr;
|
|
|
|
/* Offset of registers in `struct sigcontext'. */
|
|
const int *sc_reg_offset = nullptr;
|
|
|
|
/* Number of registers in sc_reg_offsets. Most likely a ARC_LAST_REGNUM,
|
|
but in theory it could be less, so it is kept separate. */
|
|
int sc_num_regs = 0;
|
|
};
|
|
|
|
/* Utility functions used by other ARC-specific modules. */
|
|
|
|
static inline int
|
|
arc_mach_is_arc600 (struct gdbarch *gdbarch)
|
|
{
|
|
return (gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_arc_arc600
|
|
|| gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_arc_arc601);
|
|
}
|
|
|
|
static inline int
|
|
arc_mach_is_arc700 (struct gdbarch *gdbarch)
|
|
{
|
|
return gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_arc_arc700;
|
|
}
|
|
|
|
static inline int
|
|
arc_mach_is_arcv2 (struct gdbarch *gdbarch)
|
|
{
|
|
return gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_arc_arcv2;
|
|
}
|
|
|
|
/* ARC EM and ARC HS are unique BFD arches, however they share the same machine
|
|
number as "ARCv2". */
|
|
|
|
static inline bool
|
|
arc_arch_is_hs (const struct bfd_arch_info* arch)
|
|
{
|
|
return startswith (arch->printable_name, "HS");
|
|
}
|
|
|
|
static inline bool
|
|
arc_arch_is_em (const struct bfd_arch_info* arch)
|
|
{
|
|
return startswith (arch->printable_name, "EM");
|
|
}
|
|
|
|
/* Function to access ARC disassembler. Underlying opcodes disassembler will
|
|
print an instruction into stream specified in the INFO, so if it is
|
|
undesired, then this stream should be set to some invisible stream, but it
|
|
can't be set to an actual NULL value - that would cause a crash. */
|
|
int arc_delayed_print_insn (bfd_vma addr, struct disassemble_info *info);
|
|
|
|
/* Get branch/jump target address for the INSN. Note that this function
|
|
returns branch target and doesn't evaluate if this branch is taken or not.
|
|
For the indirect jumps value depends in register state, hence can change.
|
|
It is an error to call this function for a non-branch instruction. */
|
|
|
|
CORE_ADDR arc_insn_get_branch_target (const struct arc_instruction &insn);
|
|
|
|
/* Get address of next instruction after INSN, assuming linear execution (no
|
|
taken branches). If instruction has a delay slot, then returned value will
|
|
point at the instruction in delay slot. That is - "address of instruction +
|
|
instruction length with LIMM". */
|
|
|
|
CORE_ADDR arc_insn_get_linear_next_pc (const struct arc_instruction &insn);
|
|
|
|
/* Create an arc_arch_features instance from the provided data. */
|
|
|
|
arc_arch_features arc_arch_features_create (const bfd *abfd,
|
|
const unsigned long mach);
|
|
|
|
#endif /* ARC_TDEP_H */
|