2019-10-18 08:48:08 +08:00
|
|
|
/* Target dependent code for ARC architecture, for GDB.
|
2016-08-13 01:02:20 +08:00
|
|
|
|
2024-01-12 23:30:44 +08:00
|
|
|
Copyright 2005-2024 Free Software Foundation, Inc.
|
2016-08-13 01:02:20 +08:00
|
|
|
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/>. */
|
|
|
|
|
|
|
|
/* GDB header files. */
|
|
|
|
#include "arch-utils.h"
|
2020-07-09 23:43:13 +08:00
|
|
|
#include "elf-bfd.h"
|
2016-08-13 01:02:20 +08:00
|
|
|
#include "disasm.h"
|
Move DWARF code to dwarf2/ subdirectory
This moves all the remaining DWARF code to the new dwarf2
subdirectory. This is just a simple renaming, with updates to
includes as needed.
gdb/ChangeLog
2020-02-08 Tom Tromey <tom@tromey.com>
* dwarf2/expr.c: Rename from dwarf2expr.c.
* dwarf2/expr.h: Rename from dwarf2expr.h.
* dwarf2/frame-tailcall.c: Rename from dwarf2-frame-tailcall.c.
* dwarf2/frame-tailcall.h: Rename from dwarf2-frame-tailcall.h.
* dwarf2/frame.c: Rename from dwarf2-frame.c.
* dwarf2/frame.h: Rename from dwarf2-frame.h.
* dwarf2/index-cache.c: Rename from dwarf-index-cache.c.
* dwarf2/index-cache.h: Rename from dwarf-index-cache.h.
* dwarf2/index-common.c: Rename from dwarf-index-common.c.
* dwarf2/index-common.h: Rename from dwarf-index-common.h.
* dwarf2/index-write.c: Rename from dwarf-index-write.c.
* dwarf2/index-write.h: Rename from dwarf-index-write.h.
* dwarf2/loc.c: Rename from dwarf2loc.c.
* dwarf2/loc.h: Rename from dwarf2loc.h.
* dwarf2/read.c: Rename from dwarf2read.c.
* dwarf2/read.h: Rename from dwarf2read.h.
* dwarf2/abbrev.c, aarch64-tdep.c, alpha-tdep.c,
amd64-darwin-tdep.c, arc-tdep.c, arm-tdep.c, bfin-tdep.c,
compile/compile-c-symbols.c, compile/compile-cplus-symbols.c,
compile/compile-loc2c.c, cris-tdep.c, csky-tdep.c, findvar.c,
gdbtypes.c, guile/scm-type.c, h8300-tdep.c, hppa-bsd-tdep.c,
hppa-linux-tdep.c, i386-darwin-tdep.c, i386-linux-tdep.c,
i386-tdep.c, iq2000-tdep.c, m32c-tdep.c, m68hc11-tdep.c,
m68k-tdep.c, microblaze-tdep.c, mips-tdep.c, mn10300-tdep.c,
msp430-tdep.c, nds32-tdep.c, nios2-tdep.c, or1k-tdep.c,
riscv-tdep.c, rl78-tdep.c, rs6000-tdep.c, rx-tdep.c, s12z-tdep.c,
s390-tdep.c, score-tdep.c, sh-tdep.c, sparc-linux-tdep.c,
sparc-tdep.c, sparc64-linux-tdep.c, sparc64-tdep.c, tic6x-tdep.c,
tilegx-tdep.c, v850-tdep.c, xstormy16-tdep.c, xtensa-tdep.c:
Update.
* Makefile.in (COMMON_SFILES): Update.
(HFILES_NO_SRCDIR): Update.
Change-Id: Ied9ce1436cd27ac4a4cffef10ec92e396f181928
2020-02-09 04:40:54 +08:00
|
|
|
#include "dwarf2/frame.h"
|
2024-04-23 04:10:14 +08:00
|
|
|
#include "extract-store-integer.h"
|
2016-08-13 01:02:20 +08:00
|
|
|
#include "frame-base.h"
|
|
|
|
#include "frame-unwind.h"
|
2019-04-03 10:04:24 +08:00
|
|
|
#include "gdbcore.h"
|
2023-09-30 02:24:38 +08:00
|
|
|
#include "inferior.h"
|
2020-01-15 07:14:24 +08:00
|
|
|
#include "reggroups.h"
|
2024-04-24 03:22:44 +08:00
|
|
|
#include "cli/cli-cmds.h"
|
2016-08-13 01:02:20 +08:00
|
|
|
#include "objfiles.h"
|
2017-10-26 02:51:54 +08:00
|
|
|
#include "osabi.h"
|
2017-02-10 19:12:09 +08:00
|
|
|
#include "prologue-value.h"
|
2017-10-26 02:51:54 +08:00
|
|
|
#include "target-descriptions.h"
|
2016-08-13 01:02:20 +08:00
|
|
|
#include "trad-frame.h"
|
|
|
|
|
|
|
|
/* ARC header files. */
|
|
|
|
#include "opcode/arc.h"
|
2019-10-06 08:27:29 +08:00
|
|
|
#include "opcodes/arc-dis.h"
|
2016-08-13 01:02:20 +08:00
|
|
|
#include "arc-tdep.h"
|
2017-10-26 02:51:54 +08:00
|
|
|
#include "arch/arc.h"
|
2016-08-13 01:02:20 +08:00
|
|
|
|
|
|
|
/* Standard headers. */
|
|
|
|
#include <algorithm>
|
2020-07-09 23:43:13 +08:00
|
|
|
#include <sstream>
|
2016-08-13 01:02:20 +08:00
|
|
|
|
2017-02-10 19:12:09 +08:00
|
|
|
/* The frame unwind cache for ARC. */
|
2016-08-13 01:02:20 +08:00
|
|
|
|
|
|
|
struct arc_frame_cache
|
|
|
|
{
|
|
|
|
/* The stack pointer at the time this frame was created; i.e. the caller's
|
|
|
|
stack pointer when this function was called. It is used to identify this
|
|
|
|
frame. */
|
|
|
|
CORE_ADDR prev_sp;
|
|
|
|
|
2017-02-10 19:12:09 +08:00
|
|
|
/* Register that is a base for this frame - FP for normal frame, SP for
|
|
|
|
non-FP frames. */
|
|
|
|
int frame_base_reg;
|
|
|
|
|
|
|
|
/* Offset from the previous SP to the current frame base. If GCC uses
|
|
|
|
`SUB SP,SP,offset` to allocate space for local variables, then it will be
|
|
|
|
done after setting up a frame pointer, but it still will be considered
|
|
|
|
part of prologue, therefore SP will be lesser than FP at the end of the
|
|
|
|
prologue analysis. In this case that would be an offset from old SP to a
|
|
|
|
new FP. But in case of non-FP frames, frame base is an SP and thus that
|
|
|
|
would be an offset from old SP to new SP. What is important is that this
|
|
|
|
is an offset from old SP to a known register, so it can be used to find
|
|
|
|
old SP.
|
|
|
|
|
|
|
|
Using FP is preferable, when possible, because SP can change in function
|
|
|
|
body after prologue due to alloca, variadic arguments or other shenanigans.
|
|
|
|
If that is the case in the caller frame, then PREV_SP will point to SP at
|
|
|
|
the moment of function call, but it will be different from SP value at the
|
|
|
|
end of the caller prologue. As a result it will not be possible to
|
|
|
|
reconstruct caller's frame and go past it in the backtrace. Those things
|
|
|
|
are unlikely to happen to FP - FP value at the moment of function call (as
|
|
|
|
stored on stack in callee prologue) is also an FP value at the end of the
|
|
|
|
caller's prologue. */
|
|
|
|
|
|
|
|
LONGEST frame_base_offset;
|
|
|
|
|
|
|
|
/* Store addresses for registers saved in prologue. During prologue analysis
|
|
|
|
GDB stores offsets relatively to "old SP", then after old SP is evaluated,
|
|
|
|
offsets are replaced with absolute addresses. */
|
Refactor struct trad_frame_saved_regs
The following patch drops the overloading going on with the trad_frame_saved_reg
struct and defines a new struct with a KIND enum and a union of different
fields.
The new struct looks like this:
struct trad_frame_saved_reg
{
setters/getters
...
private:
trad_frame_saved_reg_kind m_kind;
union {
LONGEST value;
int realreg;
LONGEST addr;
const gdb_byte *value_bytes;
} m_reg;
};
And the enums look like this:
/* Describes the kind of encoding a stored register has. */
enum class trad_frame_saved_reg_kind
{
/* Register value is unknown. */
UNKNOWN = 0,
/* Register value is a constant. */
VALUE,
/* Register value is in another register. */
REALREG,
/* Register value is at an address. */
ADDR,
/* Register value is a sequence of bytes. */
VALUE_BYTES
};
The patch also adds setters/getters and updates all the users of the old
struct.
It is worth mentioning that due to the previous overloaded nature of the
fields, some tdep files like to store negative offsets and indexes in the ADDR
field, so I kept the ADDR as LONGEST instead of CORE_ADDR. Those cases may
be better supported by a new enum entry.
I have not addressed those cases in this patch to prevent unwanted breakage,
given I have no way to test some of the targets. But it would be nice to
clean those up eventually.
The change to frame-unwind.* is to constify the parameter being passed to the
unwinding functions, given we now accept a "const gdb_byte *" for value bytes.
Tested on aarch64-linux/Ubuntu 20.04/18.04 and by building GDB with
--enable-targets=all.
gdb/ChangeLog:
2021-01-04 Luis Machado <luis.machado@linaro.org>
Update all users of trad_frame_saved_reg to use the new member
functions.
Remote all struct keywords from declarations of trad_frame_saved_reg
types, except on forward declarations.
* aarch64-tdep.c: Update.
* alpha-mdebug-tdep.c: Update.
* alpha-tdep.c: Update.
* arc-tdep.c: Update.
* arm-tdep.c: Update.
* avr-tdep.c: Update.
* cris-tdep.c: Update.
* csky-tdep.c: Update.
* frv-tdep.c: Update.
* hppa-linux-tdep.c: Update.
* hppa-tdep.c: Update.
* hppa-tdep.h: Update.
* lm32-tdep.c: Update.
* m32r-linux-tdep.c: Update.
* m32r-tdep.c: Update.
* m68hc11-tdep.c: Update.
* mips-tdep.c: Update.
* moxie-tdep.c: Update.
* riscv-tdep.c: Update.
* rs6000-tdep.c: Update.
* s390-linux-tdep.c: Update.
* s390-tdep.c: Update.
* score-tdep.c: Update.
* sparc-netbsd-tdep.c: Update.
* sparc-sol2-tdep.c: Update.
* sparc64-fbsd-tdep.c: Update.
* sparc64-netbsd-tdep.c: Update.
* sparc64-obsd-tdep.c: Update.
* sparc64-sol2-tdep.c: Update.
* tilegx-tdep.c: Update.
* v850-tdep.c: Update.
* vax-tdep.c: Update.
* frame-unwind.c (frame_unwind_got_bytes): Make parameter const.
* frame-unwind.h (frame_unwind_got_bytes): Likewise.
* trad-frame.c: Update.
Remove TF_REG_* enum.
(trad_frame_alloc_saved_regs): Add a static assertion to check for
a trivially-constructible struct.
(trad_frame_reset_saved_regs): Adjust to use member function.
(trad_frame_value_p): Likewise.
(trad_frame_addr_p): Likewise.
(trad_frame_realreg_p): Likewise.
(trad_frame_value_bytes_p): Likewise.
(trad_frame_set_value): Likewise.
(trad_frame_set_realreg): Likewise.
(trad_frame_set_addr): Likewise.
(trad_frame_set_unknown): Likewise.
(trad_frame_set_value_bytes): Likewise.
(trad_frame_get_prev_register): Likewise.
* trad-frame.h: Update.
(trad_frame_saved_reg_kind): New enum.
(struct trad_frame_saved_reg) <addr, realreg, data>: Remove.
<m_kind, m_reg>: New member fields.
<set_value, set_realreg, set_addr, set_unknown, set_value_bytes>
<kind, value, realreg, addr, value_bytes, is_value, is_realreg>
<is_addr, is_unknown, is_value_bytes>: New member functions.
2020-12-23 04:45:21 +08:00
|
|
|
trad_frame_saved_reg *saved_regs;
|
2016-08-13 01:02:20 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Global debug flag. */
|
|
|
|
|
2021-01-14 03:32:23 +08:00
|
|
|
bool arc_debug;
|
2016-08-13 01:02:20 +08:00
|
|
|
|
2017-02-10 19:12:01 +08:00
|
|
|
/* List of "maintenance print arc" commands. */
|
|
|
|
|
|
|
|
static struct cmd_list_element *maintenance_print_arc_list = NULL;
|
|
|
|
|
2020-07-09 23:43:13 +08:00
|
|
|
/* A set of registers that we expect to find in a tdesc_feature. These
|
|
|
|
are used in ARC_TDESC_INIT when processing the target description. */
|
|
|
|
|
|
|
|
struct arc_register_feature
|
|
|
|
{
|
|
|
|
/* Information for a single register. */
|
|
|
|
struct register_info
|
|
|
|
{
|
|
|
|
/* The GDB register number for this register. */
|
|
|
|
int regnum;
|
|
|
|
|
|
|
|
/* List of names for this register. The first name in this list is the
|
|
|
|
preferred name, the name GDB will use when describing this register. */
|
|
|
|
std::vector<const char *> names;
|
|
|
|
|
|
|
|
/* When true, this register must be present in this feature set. */
|
|
|
|
bool required_p;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* The name for this feature. This is the name used to find this feature
|
|
|
|
within the target description. */
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
/* List of all the registers that we expect to encounter in this register
|
|
|
|
set. */
|
|
|
|
std::vector<struct register_info> registers;
|
2016-08-13 01:02:20 +08:00
|
|
|
};
|
|
|
|
|
2020-07-09 23:43:13 +08:00
|
|
|
/* Obsolete feature names for backward compatibility. */
|
|
|
|
static const char *ARC_CORE_V1_OBSOLETE_FEATURE_NAME
|
|
|
|
= "org.gnu.gdb.arc.core.arcompact";
|
|
|
|
static const char *ARC_CORE_V2_OBSOLETE_FEATURE_NAME
|
|
|
|
= "org.gnu.gdb.arc.core.v2";
|
|
|
|
static const char *ARC_CORE_V2_REDUCED_OBSOLETE_FEATURE_NAME
|
|
|
|
= "org.gnu.gdb.arc.core-reduced.v2";
|
|
|
|
static const char *ARC_AUX_OBSOLETE_FEATURE_NAME
|
|
|
|
= "org.gnu.gdb.arc.aux-minimal";
|
|
|
|
/* Modern feature names. */
|
|
|
|
static const char *ARC_CORE_FEATURE_NAME = "org.gnu.gdb.arc.core";
|
|
|
|
static const char *ARC_AUX_FEATURE_NAME = "org.gnu.gdb.arc.aux";
|
|
|
|
|
|
|
|
/* ARCv1 (ARC600, ARC601, ARC700) general core registers feature set.
|
|
|
|
See also arc_update_acc_reg_names() for "accl/acch" names. */
|
|
|
|
|
|
|
|
static struct arc_register_feature arc_v1_core_reg_feature =
|
|
|
|
{
|
|
|
|
ARC_CORE_FEATURE_NAME,
|
|
|
|
{
|
|
|
|
{ ARC_R0_REGNUM + 0, { "r0" }, true },
|
|
|
|
{ ARC_R0_REGNUM + 1, { "r1" }, true },
|
|
|
|
{ ARC_R0_REGNUM + 2, { "r2" }, true },
|
|
|
|
{ ARC_R0_REGNUM + 3, { "r3" }, true },
|
|
|
|
{ ARC_R0_REGNUM + 4, { "r4" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 5, { "r5" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 6, { "r6" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 7, { "r7" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 8, { "r8" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 9, { "r9" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 10, { "r10" }, true },
|
|
|
|
{ ARC_R0_REGNUM + 11, { "r11" }, true },
|
|
|
|
{ ARC_R0_REGNUM + 12, { "r12" }, true },
|
|
|
|
{ ARC_R0_REGNUM + 13, { "r13" }, true },
|
|
|
|
{ ARC_R0_REGNUM + 14, { "r14" }, true },
|
|
|
|
{ ARC_R0_REGNUM + 15, { "r15" }, true },
|
|
|
|
{ ARC_R0_REGNUM + 16, { "r16" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 17, { "r17" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 18, { "r18" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 19, { "r19" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 20, { "r20" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 21, { "r21" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 22, { "r22" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 23, { "r23" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 24, { "r24" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 25, { "r25" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 26, { "gp" }, true },
|
|
|
|
{ ARC_R0_REGNUM + 27, { "fp" }, true },
|
|
|
|
{ ARC_R0_REGNUM + 28, { "sp" }, true },
|
|
|
|
{ ARC_R0_REGNUM + 29, { "ilink1" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 30, { "ilink2" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 31, { "blink" }, true },
|
|
|
|
{ ARC_R0_REGNUM + 32, { "r32" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 33, { "r33" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 34, { "r34" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 35, { "r35" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 36, { "r36" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 37, { "r37" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 38, { "r38" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 39, { "r39" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 40, { "r40" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 41, { "r41" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 42, { "r42" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 43, { "r43" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 44, { "r44" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 45, { "r45" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 46, { "r46" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 47, { "r47" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 48, { "r48" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 49, { "r49" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 50, { "r50" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 51, { "r51" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 52, { "r52" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 53, { "r53" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 54, { "r54" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 55, { "r55" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 56, { "r56" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 57, { "r57" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 58, { "r58", "accl" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 59, { "r59", "acch" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 60, { "lp_count" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 61, { "reserved" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 62, { "limm" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 63, { "pcl" }, true }
|
|
|
|
}
|
2016-08-13 01:02:20 +08:00
|
|
|
};
|
|
|
|
|
2020-07-09 23:43:13 +08:00
|
|
|
/* ARCv2 (ARCHS) general core registers feature set. See also
|
|
|
|
arc_update_acc_reg_names() for "accl/acch" names. */
|
|
|
|
|
|
|
|
static struct arc_register_feature arc_v2_core_reg_feature =
|
|
|
|
{
|
|
|
|
ARC_CORE_FEATURE_NAME,
|
|
|
|
{
|
|
|
|
{ ARC_R0_REGNUM + 0, { "r0" }, true },
|
|
|
|
{ ARC_R0_REGNUM + 1, { "r1" }, true },
|
|
|
|
{ ARC_R0_REGNUM + 2, { "r2" }, true },
|
|
|
|
{ ARC_R0_REGNUM + 3, { "r3" }, true },
|
|
|
|
{ ARC_R0_REGNUM + 4, { "r4" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 5, { "r5" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 6, { "r6" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 7, { "r7" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 8, { "r8" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 9, { "r9" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 10, { "r10" }, true },
|
|
|
|
{ ARC_R0_REGNUM + 11, { "r11" }, true },
|
|
|
|
{ ARC_R0_REGNUM + 12, { "r12" }, true },
|
|
|
|
{ ARC_R0_REGNUM + 13, { "r13" }, true },
|
|
|
|
{ ARC_R0_REGNUM + 14, { "r14" }, true },
|
|
|
|
{ ARC_R0_REGNUM + 15, { "r15" }, true },
|
|
|
|
{ ARC_R0_REGNUM + 16, { "r16" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 17, { "r17" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 18, { "r18" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 19, { "r19" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 20, { "r20" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 21, { "r21" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 22, { "r22" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 23, { "r23" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 24, { "r24" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 25, { "r25" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 26, { "gp" }, true },
|
|
|
|
{ ARC_R0_REGNUM + 27, { "fp" }, true },
|
|
|
|
{ ARC_R0_REGNUM + 28, { "sp" }, true },
|
|
|
|
{ ARC_R0_REGNUM + 29, { "ilink" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 30, { "r30" }, true },
|
|
|
|
{ ARC_R0_REGNUM + 31, { "blink" }, true },
|
|
|
|
{ ARC_R0_REGNUM + 32, { "r32" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 33, { "r33" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 34, { "r34" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 35, { "r35" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 36, { "r36" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 37, { "r37" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 38, { "r38" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 39, { "r39" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 40, { "r40" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 41, { "r41" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 42, { "r42" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 43, { "r43" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 44, { "r44" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 45, { "r45" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 46, { "r46" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 47, { "r47" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 48, { "r48" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 49, { "r49" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 50, { "r50" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 51, { "r51" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 52, { "r52" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 53, { "r53" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 54, { "r54" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 55, { "r55" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 56, { "r56" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 57, { "r57" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 58, { "r58", "accl" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 59, { "r59", "acch" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 60, { "lp_count" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 61, { "reserved" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 62, { "limm" }, false },
|
|
|
|
{ ARC_R0_REGNUM + 63, { "pcl" }, true }
|
|
|
|
}
|
2016-08-13 01:02:20 +08:00
|
|
|
};
|
|
|
|
|
2020-07-09 23:43:13 +08:00
|
|
|
/* The common auxiliary registers feature set. The REGNUM field
|
|
|
|
must match the ARC_REGNUM enum in arc-tdep.h. */
|
2017-02-10 19:11:55 +08:00
|
|
|
|
2020-07-09 23:43:13 +08:00
|
|
|
static const struct arc_register_feature arc_common_aux_reg_feature =
|
|
|
|
{
|
|
|
|
ARC_AUX_FEATURE_NAME,
|
|
|
|
{
|
|
|
|
{ ARC_FIRST_AUX_REGNUM + 0, { "pc" }, true },
|
|
|
|
{ ARC_FIRST_AUX_REGNUM + 1, { "status32" }, true },
|
|
|
|
{ ARC_FIRST_AUX_REGNUM + 2, { "lp_start" }, false },
|
|
|
|
{ ARC_FIRST_AUX_REGNUM + 3, { "lp_end" }, false },
|
|
|
|
{ ARC_FIRST_AUX_REGNUM + 4, { "bta" }, false }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2024-03-22 01:15:56 +08:00
|
|
|
static std::string arc_disassembler_options;
|
2017-10-26 02:51:54 +08:00
|
|
|
|
2017-02-10 19:12:09 +08:00
|
|
|
/* Functions are sorted in the order as they are used in the
|
|
|
|
_initialize_arc_tdep (), which uses the same order as gdbarch.h. Static
|
|
|
|
functions are defined before the first invocation. */
|
|
|
|
|
2017-02-10 19:12:06 +08:00
|
|
|
/* Returns an unsigned value of OPERAND_NUM in instruction INSN.
|
|
|
|
For relative branch instructions returned value is an offset, not an actual
|
|
|
|
branch target. */
|
|
|
|
|
|
|
|
static ULONGEST
|
|
|
|
arc_insn_get_operand_value (const struct arc_instruction &insn,
|
|
|
|
unsigned int operand_num)
|
|
|
|
{
|
|
|
|
switch (insn.operands[operand_num].kind)
|
|
|
|
{
|
|
|
|
case ARC_OPERAND_KIND_LIMM:
|
|
|
|
gdb_assert (insn.limm_p);
|
|
|
|
return insn.limm_value;
|
|
|
|
case ARC_OPERAND_KIND_SHIMM:
|
|
|
|
return insn.operands[operand_num].value;
|
|
|
|
default:
|
|
|
|
/* Value in instruction is a register number. */
|
2023-11-05 12:47:26 +08:00
|
|
|
regcache *regcache = get_thread_regcache (inferior_thread ());
|
2017-02-10 19:12:06 +08:00
|
|
|
ULONGEST value;
|
|
|
|
regcache_cooked_read_unsigned (regcache,
|
|
|
|
insn.operands[operand_num].value,
|
|
|
|
&value);
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Like arc_insn_get_operand_value, but returns a signed value. */
|
|
|
|
|
|
|
|
static LONGEST
|
|
|
|
arc_insn_get_operand_value_signed (const struct arc_instruction &insn,
|
|
|
|
unsigned int operand_num)
|
|
|
|
{
|
|
|
|
switch (insn.operands[operand_num].kind)
|
|
|
|
{
|
|
|
|
case ARC_OPERAND_KIND_LIMM:
|
|
|
|
gdb_assert (insn.limm_p);
|
|
|
|
/* Convert unsigned raw value to signed one. This assumes 2's
|
|
|
|
complement arithmetic, but so is the LONG_MIN value from generic
|
|
|
|
defs.h and that assumption is true for ARC. */
|
2023-10-19 10:44:11 +08:00
|
|
|
static_assert (sizeof (insn.limm_value) == sizeof (int));
|
2017-02-10 19:12:06 +08:00
|
|
|
return (((LONGEST) insn.limm_value) ^ INT_MIN) - INT_MIN;
|
|
|
|
case ARC_OPERAND_KIND_SHIMM:
|
|
|
|
/* Sign conversion has been done by binutils. */
|
|
|
|
return insn.operands[operand_num].value;
|
|
|
|
default:
|
|
|
|
/* Value in instruction is a register number. */
|
2023-11-05 12:47:26 +08:00
|
|
|
regcache *regcache = get_thread_regcache (inferior_thread ());
|
2017-02-10 19:12:06 +08:00
|
|
|
LONGEST value;
|
|
|
|
regcache_cooked_read_signed (regcache,
|
|
|
|
insn.operands[operand_num].value,
|
|
|
|
&value);
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get register with base address of memory operation. */
|
|
|
|
|
2019-11-27 01:12:01 +08:00
|
|
|
static int
|
2017-02-10 19:12:06 +08:00
|
|
|
arc_insn_get_memory_base_reg (const struct arc_instruction &insn)
|
|
|
|
{
|
|
|
|
/* POP_S and PUSH_S have SP as an implicit argument in a disassembler. */
|
|
|
|
if (insn.insn_class == PUSH || insn.insn_class == POP)
|
|
|
|
return ARC_SP_REGNUM;
|
|
|
|
|
|
|
|
gdb_assert (insn.insn_class == LOAD || insn.insn_class == STORE);
|
|
|
|
|
|
|
|
/* Other instructions all have at least two operands: operand 0 is data,
|
|
|
|
operand 1 is address. Operand 2 is offset from address. However, see
|
|
|
|
comment to arc_instruction.operands - in some cases, third operand may be
|
|
|
|
missing, namely if it is 0. */
|
|
|
|
gdb_assert (insn.operands_count >= 2);
|
|
|
|
return insn.operands[1].value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get offset of a memory operation INSN. */
|
|
|
|
|
2019-11-27 01:12:01 +08:00
|
|
|
static CORE_ADDR
|
2017-02-10 19:12:06 +08:00
|
|
|
arc_insn_get_memory_offset (const struct arc_instruction &insn)
|
|
|
|
{
|
|
|
|
/* POP_S and PUSH_S have offset as an implicit argument in a
|
|
|
|
disassembler. */
|
|
|
|
if (insn.insn_class == POP)
|
|
|
|
return 4;
|
|
|
|
else if (insn.insn_class == PUSH)
|
|
|
|
return -4;
|
|
|
|
|
|
|
|
gdb_assert (insn.insn_class == LOAD || insn.insn_class == STORE);
|
|
|
|
|
|
|
|
/* Other instructions all have at least two operands: operand 0 is data,
|
|
|
|
operand 1 is address. Operand 2 is offset from address. However, see
|
|
|
|
comment to arc_instruction.operands - in some cases, third operand may be
|
|
|
|
missing, namely if it is 0. */
|
|
|
|
if (insn.operands_count < 3)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
CORE_ADDR value = arc_insn_get_operand_value (insn, 2);
|
|
|
|
/* Handle scaling. */
|
|
|
|
if (insn.writeback_mode == ARC_WRITEBACK_AS)
|
|
|
|
{
|
|
|
|
/* Byte data size is not valid for AS. Halfword means shift by 1 bit.
|
|
|
|
Word and double word means shift by 2 bits. */
|
|
|
|
gdb_assert (insn.data_size_mode != ARC_SCALING_B);
|
|
|
|
if (insn.data_size_mode == ARC_SCALING_H)
|
|
|
|
value <<= 1;
|
|
|
|
else
|
|
|
|
value <<= 2;
|
|
|
|
}
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
CORE_ADDR
|
|
|
|
arc_insn_get_branch_target (const struct arc_instruction &insn)
|
|
|
|
{
|
|
|
|
gdb_assert (insn.is_control_flow);
|
|
|
|
|
|
|
|
/* BI [c]: PC = nextPC + (c << 2). */
|
|
|
|
if (insn.insn_class == BI)
|
|
|
|
{
|
|
|
|
ULONGEST reg_value = arc_insn_get_operand_value (insn, 0);
|
|
|
|
return arc_insn_get_linear_next_pc (insn) + (reg_value << 2);
|
|
|
|
}
|
|
|
|
/* BIH [c]: PC = nextPC + (c << 1). */
|
|
|
|
else if (insn.insn_class == BIH)
|
|
|
|
{
|
|
|
|
ULONGEST reg_value = arc_insn_get_operand_value (insn, 0);
|
|
|
|
return arc_insn_get_linear_next_pc (insn) + (reg_value << 1);
|
|
|
|
}
|
|
|
|
/* JLI and EI. */
|
|
|
|
/* JLI and EI depend on optional AUX registers. Not supported right now. */
|
|
|
|
else if (insn.insn_class == JLI)
|
|
|
|
{
|
2022-01-03 02:46:15 +08:00
|
|
|
gdb_printf (gdb_stderr,
|
|
|
|
"JLI_S instruction is not supported by the GDB.");
|
2017-02-10 19:12:06 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if (insn.insn_class == EI)
|
|
|
|
{
|
2022-01-03 02:46:15 +08:00
|
|
|
gdb_printf (gdb_stderr,
|
|
|
|
"EI_S instruction is not supported by the GDB.");
|
2017-02-10 19:12:06 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* LEAVE_S: PC = BLINK. */
|
|
|
|
else if (insn.insn_class == LEAVE)
|
|
|
|
{
|
2023-11-05 12:47:26 +08:00
|
|
|
regcache *regcache = get_thread_regcache (inferior_thread ());
|
2017-02-10 19:12:06 +08:00
|
|
|
ULONGEST value;
|
|
|
|
regcache_cooked_read_unsigned (regcache, ARC_BLINK_REGNUM, &value);
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
/* BBIT0/1, BRcc: PC = currentPC + operand. */
|
|
|
|
else if (insn.insn_class == BBIT0 || insn.insn_class == BBIT1
|
|
|
|
|| insn.insn_class == BRCC)
|
|
|
|
{
|
|
|
|
/* Most instructions has branch target as their sole argument. However
|
|
|
|
conditional brcc/bbit has it as a third operand. */
|
|
|
|
CORE_ADDR pcrel_addr = arc_insn_get_operand_value (insn, 2);
|
|
|
|
|
|
|
|
/* Offset is relative to the 4-byte aligned address of the current
|
|
|
|
instruction, hence last two bits should be truncated. */
|
|
|
|
return pcrel_addr + align_down (insn.address, 4);
|
|
|
|
}
|
2024-02-15 02:16:16 +08:00
|
|
|
/* DBNZ is the only branch instruction that keeps a branch address in
|
|
|
|
the second operand. It must be intercepted and treated differently. */
|
|
|
|
else if (insn.insn_class == DBNZ)
|
|
|
|
{
|
|
|
|
CORE_ADDR pcrel_addr = arc_insn_get_operand_value_signed (insn, 1);
|
|
|
|
|
|
|
|
/* Offset is relative to the 4-byte aligned address of the current
|
|
|
|
instruction, hence last two bits should be truncated. */
|
|
|
|
return pcrel_addr + align_down (insn.address, 4);
|
|
|
|
}
|
2017-02-10 19:12:06 +08:00
|
|
|
/* B, Bcc, BL, BLcc, LP, LPcc: PC = currentPC + operand. */
|
|
|
|
else if (insn.insn_class == BRANCH || insn.insn_class == LOOP)
|
|
|
|
{
|
|
|
|
CORE_ADDR pcrel_addr = arc_insn_get_operand_value (insn, 0);
|
|
|
|
|
|
|
|
/* Offset is relative to the 4-byte aligned address of the current
|
|
|
|
instruction, hence last two bits should be truncated. */
|
|
|
|
return pcrel_addr + align_down (insn.address, 4);
|
|
|
|
}
|
|
|
|
/* J, Jcc, JL, JLcc: PC = operand. */
|
|
|
|
else if (insn.insn_class == JUMP)
|
|
|
|
{
|
|
|
|
/* All jumps are single-operand. */
|
|
|
|
return arc_insn_get_operand_value (insn, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is some new and unknown instruction. */
|
|
|
|
gdb_assert_not_reached ("Unknown branch instruction.");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Dump INSN into gdb_stdlog. */
|
|
|
|
|
2019-11-27 01:12:01 +08:00
|
|
|
static void
|
2017-02-10 19:12:06 +08:00
|
|
|
arc_insn_dump (const struct arc_instruction &insn)
|
|
|
|
{
|
2023-09-30 02:24:38 +08:00
|
|
|
struct gdbarch *gdbarch = current_inferior ()->arch ();
|
2017-02-10 19:12:06 +08:00
|
|
|
|
|
|
|
arc_print ("Dumping arc_instruction at %s\n",
|
|
|
|
paddress (gdbarch, insn.address));
|
|
|
|
arc_print ("\tlength = %u\n", insn.length);
|
|
|
|
|
|
|
|
if (!insn.valid)
|
|
|
|
{
|
|
|
|
arc_print ("\tThis is not a valid ARC instruction.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
arc_print ("\tlength_with_limm = %u\n", insn.length + (insn.limm_p ? 4 : 0));
|
|
|
|
arc_print ("\tcc = 0x%x\n", insn.condition_code);
|
|
|
|
arc_print ("\tinsn_class = %u\n", insn.insn_class);
|
|
|
|
arc_print ("\tis_control_flow = %i\n", insn.is_control_flow);
|
|
|
|
arc_print ("\thas_delay_slot = %i\n", insn.has_delay_slot);
|
|
|
|
|
|
|
|
CORE_ADDR next_pc = arc_insn_get_linear_next_pc (insn);
|
|
|
|
arc_print ("\tlinear_next_pc = %s\n", paddress (gdbarch, next_pc));
|
|
|
|
|
|
|
|
if (insn.is_control_flow)
|
|
|
|
{
|
|
|
|
CORE_ADDR t = arc_insn_get_branch_target (insn);
|
|
|
|
arc_print ("\tbranch_target = %s\n", paddress (gdbarch, t));
|
|
|
|
}
|
|
|
|
|
|
|
|
arc_print ("\tlimm_p = %i\n", insn.limm_p);
|
|
|
|
if (insn.limm_p)
|
|
|
|
arc_print ("\tlimm_value = 0x%08x\n", insn.limm_value);
|
|
|
|
|
|
|
|
if (insn.insn_class == STORE || insn.insn_class == LOAD
|
|
|
|
|| insn.insn_class == PUSH || insn.insn_class == POP)
|
|
|
|
{
|
|
|
|
arc_print ("\twriteback_mode = %u\n", insn.writeback_mode);
|
|
|
|
arc_print ("\tdata_size_mode = %u\n", insn.data_size_mode);
|
|
|
|
arc_print ("\tmemory_base_register = %s\n",
|
|
|
|
gdbarch_register_name (gdbarch,
|
|
|
|
arc_insn_get_memory_base_reg (insn)));
|
|
|
|
/* get_memory_offset returns an unsigned CORE_ADDR, but treat it as a
|
|
|
|
LONGEST for a nicer representation. */
|
|
|
|
arc_print ("\taddr_offset = %s\n",
|
|
|
|
plongest (arc_insn_get_memory_offset (insn)));
|
|
|
|
}
|
|
|
|
|
|
|
|
arc_print ("\toperands_count = %u\n", insn.operands_count);
|
|
|
|
for (unsigned int i = 0; i < insn.operands_count; ++i)
|
|
|
|
{
|
|
|
|
int is_reg = (insn.operands[i].kind == ARC_OPERAND_KIND_REG);
|
|
|
|
|
|
|
|
arc_print ("\toperand[%u] = {\n", i);
|
|
|
|
arc_print ("\t\tis_reg = %i\n", is_reg);
|
|
|
|
if (is_reg)
|
|
|
|
arc_print ("\t\tregister = %s\n",
|
|
|
|
gdbarch_register_name (gdbarch, insn.operands[i].value));
|
|
|
|
/* Don't know if this value is signed or not, so print both
|
|
|
|
representations. This tends to look quite ugly, especially for big
|
|
|
|
numbers. */
|
|
|
|
arc_print ("\t\tunsigned value = %s\n",
|
|
|
|
pulongest (arc_insn_get_operand_value (insn, i)));
|
|
|
|
arc_print ("\t\tsigned value = %s\n",
|
|
|
|
plongest (arc_insn_get_operand_value_signed (insn, i)));
|
|
|
|
arc_print ("\t}\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CORE_ADDR
|
|
|
|
arc_insn_get_linear_next_pc (const struct arc_instruction &insn)
|
|
|
|
{
|
|
|
|
/* In ARC long immediate is always 4 bytes. */
|
|
|
|
return (insn.address + insn.length + (insn.limm_p ? 4 : 0));
|
|
|
|
}
|
|
|
|
|
2016-08-13 01:02:20 +08:00
|
|
|
/* Implement the "write_pc" gdbarch method.
|
|
|
|
|
|
|
|
In ARC PC register is a normal register so in most cases setting PC value
|
|
|
|
is a straightforward process: debugger just writes PC value. However it
|
|
|
|
gets trickier in case when current instruction is an instruction in delay
|
|
|
|
slot. In this case CPU will execute instruction at current PC value, then
|
|
|
|
will set PC to the current value of BTA register; also current instruction
|
|
|
|
cannot be branch/jump and some of the other instruction types. Thus if
|
|
|
|
debugger would try to just change PC value in this case, this instruction
|
|
|
|
will get executed, but then core will "jump" to the original branch target.
|
|
|
|
|
|
|
|
Whether current instruction is a delay-slot instruction or not is indicated
|
|
|
|
by DE bit in STATUS32 register indicates if current instruction is a delay
|
|
|
|
slot instruction. This bit is writable by debug host, which allows debug
|
|
|
|
host to prevent core from jumping after the delay slot instruction. It
|
|
|
|
also works in another direction: setting this bit will make core to treat
|
|
|
|
any current instructions as a delay slot instruction and to set PC to the
|
|
|
|
current value of BTA register.
|
|
|
|
|
|
|
|
To workaround issues with changing PC register while in delay slot
|
|
|
|
instruction, debugger should check for the STATUS32.DE bit and reset it if
|
|
|
|
it is set. No other change is required in this function. Most common
|
|
|
|
case, where this function might be required is calling inferior functions
|
|
|
|
from debugger. Generic GDB logic handles this pretty well: current values
|
|
|
|
of registers are stored, value of PC is changed (that is the job of this
|
|
|
|
function), and after inferior function is executed, GDB restores all
|
|
|
|
registers, include BTA and STATUS32, which also means that core is returned
|
|
|
|
to its original state of being halted on delay slot instructions.
|
|
|
|
|
|
|
|
This method is useless for ARC 600, because it doesn't have externally
|
|
|
|
exposed BTA register. In the case of ARC 600 it is impossible to restore
|
|
|
|
core to its state in all occasions thus core should never be halted (from
|
|
|
|
the perspective of debugger host) in the delay slot. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
arc_write_pc (struct regcache *regcache, CORE_ADDR new_pc)
|
|
|
|
{
|
2017-10-25 23:37:03 +08:00
|
|
|
struct gdbarch *gdbarch = regcache->arch ();
|
2016-08-13 01:02:20 +08:00
|
|
|
|
2021-01-14 03:32:39 +08:00
|
|
|
arc_debug_printf ("Writing PC, new value=%s",
|
|
|
|
paddress (gdbarch, new_pc));
|
2016-08-13 01:02:20 +08:00
|
|
|
|
|
|
|
regcache_cooked_write_unsigned (regcache, gdbarch_pc_regnum (gdbarch),
|
|
|
|
new_pc);
|
|
|
|
|
|
|
|
ULONGEST status32;
|
|
|
|
regcache_cooked_read_unsigned (regcache, gdbarch_ps_regnum (gdbarch),
|
|
|
|
&status32);
|
|
|
|
|
2016-07-07 01:36:49 +08:00
|
|
|
if ((status32 & ARC_STATUS32_DE_MASK) != 0)
|
2016-08-13 01:02:20 +08:00
|
|
|
{
|
2021-01-14 03:32:39 +08:00
|
|
|
arc_debug_printf ("Changing PC while in delay slot. Will "
|
2016-08-13 01:02:20 +08:00
|
|
|
"reset STATUS32.DE bit to zero. Value of STATUS32 "
|
2021-01-14 03:32:39 +08:00
|
|
|
"register is 0x%s",
|
2016-08-13 01:02:20 +08:00
|
|
|
phex (status32, ARC_REGISTER_SIZE));
|
|
|
|
|
|
|
|
/* Reset bit and write to the cache. */
|
|
|
|
status32 &= ~0x40;
|
|
|
|
regcache_cooked_write_unsigned (regcache, gdbarch_ps_regnum (gdbarch),
|
|
|
|
status32);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Implement the "virtual_frame_pointer" gdbarch method.
|
|
|
|
|
|
|
|
According to ABI the FP (r27) is used to point to the middle of the current
|
|
|
|
stack frame, just below the saved FP and before local variables, register
|
|
|
|
spill area and outgoing args. However for optimization levels above O2 and
|
|
|
|
in any case in leaf functions, the frame pointer is usually not set at all.
|
|
|
|
The exception being when handling nested functions.
|
|
|
|
|
|
|
|
We use this function to return a "virtual" frame pointer, marking the start
|
|
|
|
of the current stack frame as a register-offset pair. If the FP is not
|
|
|
|
being used, then it should return SP, with an offset of the frame size.
|
|
|
|
|
|
|
|
The current implementation doesn't actually know the frame size, nor
|
|
|
|
whether the FP is actually being used, so for now we just return SP and an
|
|
|
|
offset of zero. This is no worse than other architectures, but is needed
|
|
|
|
to avoid assertion failures.
|
|
|
|
|
|
|
|
TODO: Can we determine the frame size to get a correct offset?
|
|
|
|
|
|
|
|
PC is a program counter where we need the virtual FP. REG_PTR is the base
|
|
|
|
register used for the virtual FP. OFFSET_PTR is the offset used for the
|
|
|
|
virtual FP. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
arc_virtual_frame_pointer (struct gdbarch *gdbarch, CORE_ADDR pc,
|
|
|
|
int *reg_ptr, LONGEST *offset_ptr)
|
|
|
|
{
|
|
|
|
*reg_ptr = gdbarch_sp_regnum (gdbarch);
|
|
|
|
*offset_ptr = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Implement the "push_dummy_call" gdbarch method.
|
|
|
|
|
|
|
|
Stack Frame Layout
|
|
|
|
|
|
|
|
This shows the layout of the stack frame for the general case of a
|
|
|
|
function call; a given function might not have a variable number of
|
|
|
|
arguments or local variables, or might not save any registers, so it would
|
|
|
|
not have the corresponding frame areas. Additionally, a leaf function
|
|
|
|
(i.e. one which calls no other functions) does not need to save the
|
|
|
|
contents of the BLINK register (which holds its return address), and a
|
|
|
|
function might not have a frame pointer.
|
|
|
|
|
|
|
|
The stack grows downward, so SP points below FP in memory; SP always
|
|
|
|
points to the last used word on the stack, not the first one.
|
|
|
|
|
gdb, gdbserver, gdbsupport: fix leading space vs tabs issues
Many spots incorrectly use only spaces for indentation (for example,
there are a lot of spots in ada-lang.c). I've always found it awkward
when I needed to edit one of these spots: do I keep the original wrong
indentation, or do I fix it? What if the lines around it are also
wrong, do I fix them too? I probably don't want to fix them in the same
patch, to avoid adding noise to my patch.
So I propose to fix as much as possible once and for all (hopefully).
One typical counter argument for this is that it makes code archeology
more difficult, because git-blame will show this commit as the last
change for these lines. My counter counter argument is: when
git-blaming, you often need to do "blame the file at the parent commit"
anyway, to go past some other refactor that touched the line you are
interested in, but is not the change you are looking for. So you
already need a somewhat efficient way to do this.
Using some interactive tool, rather than plain git-blame, makes this
trivial. For example, I use "tig blame <file>", where going back past
the commit that changed the currently selected line is one keystroke.
It looks like Magit in Emacs does it too (though I've never used it).
Web viewers of Github and Gitlab do it too. My point is that it won't
really make archeology more difficult.
The other typical counter argument is that it will cause conflicts with
existing patches. That's true... but it's a one time cost, and those
are not conflicts that are difficult to resolve. I have also tried "git
rebase --ignore-whitespace", it seems to work well. Although that will
re-introduce the faulty indentation, so one needs to take care of fixing
the indentation in the patch after that (which is easy).
gdb/ChangeLog:
* aarch64-linux-tdep.c: Fix indentation.
* aarch64-ravenscar-thread.c: Fix indentation.
* aarch64-tdep.c: Fix indentation.
* aarch64-tdep.h: Fix indentation.
* ada-lang.c: Fix indentation.
* ada-lang.h: Fix indentation.
* ada-tasks.c: Fix indentation.
* ada-typeprint.c: Fix indentation.
* ada-valprint.c: Fix indentation.
* ada-varobj.c: Fix indentation.
* addrmap.c: Fix indentation.
* addrmap.h: Fix indentation.
* agent.c: Fix indentation.
* aix-thread.c: Fix indentation.
* alpha-bsd-nat.c: Fix indentation.
* alpha-linux-tdep.c: Fix indentation.
* alpha-mdebug-tdep.c: Fix indentation.
* alpha-nbsd-tdep.c: Fix indentation.
* alpha-obsd-tdep.c: Fix indentation.
* alpha-tdep.c: Fix indentation.
* amd64-bsd-nat.c: Fix indentation.
* amd64-darwin-tdep.c: Fix indentation.
* amd64-linux-nat.c: Fix indentation.
* amd64-linux-tdep.c: Fix indentation.
* amd64-nat.c: Fix indentation.
* amd64-obsd-tdep.c: Fix indentation.
* amd64-tdep.c: Fix indentation.
* amd64-windows-tdep.c: Fix indentation.
* annotate.c: Fix indentation.
* arc-tdep.c: Fix indentation.
* arch-utils.c: Fix indentation.
* arch/arm-get-next-pcs.c: Fix indentation.
* arch/arm.c: Fix indentation.
* arm-linux-nat.c: Fix indentation.
* arm-linux-tdep.c: Fix indentation.
* arm-nbsd-tdep.c: Fix indentation.
* arm-pikeos-tdep.c: Fix indentation.
* arm-tdep.c: Fix indentation.
* arm-tdep.h: Fix indentation.
* arm-wince-tdep.c: Fix indentation.
* auto-load.c: Fix indentation.
* auxv.c: Fix indentation.
* avr-tdep.c: Fix indentation.
* ax-gdb.c: Fix indentation.
* ax-general.c: Fix indentation.
* bfin-linux-tdep.c: Fix indentation.
* block.c: Fix indentation.
* block.h: Fix indentation.
* blockframe.c: Fix indentation.
* bpf-tdep.c: Fix indentation.
* break-catch-sig.c: Fix indentation.
* break-catch-syscall.c: Fix indentation.
* break-catch-throw.c: Fix indentation.
* breakpoint.c: Fix indentation.
* breakpoint.h: Fix indentation.
* bsd-uthread.c: Fix indentation.
* btrace.c: Fix indentation.
* build-id.c: Fix indentation.
* buildsym-legacy.h: Fix indentation.
* buildsym.c: Fix indentation.
* c-typeprint.c: Fix indentation.
* c-valprint.c: Fix indentation.
* c-varobj.c: Fix indentation.
* charset.c: Fix indentation.
* cli/cli-cmds.c: Fix indentation.
* cli/cli-decode.c: Fix indentation.
* cli/cli-decode.h: Fix indentation.
* cli/cli-script.c: Fix indentation.
* cli/cli-setshow.c: Fix indentation.
* coff-pe-read.c: Fix indentation.
* coffread.c: Fix indentation.
* compile/compile-cplus-types.c: Fix indentation.
* compile/compile-object-load.c: Fix indentation.
* compile/compile-object-run.c: Fix indentation.
* completer.c: Fix indentation.
* corefile.c: Fix indentation.
* corelow.c: Fix indentation.
* cp-abi.h: Fix indentation.
* cp-namespace.c: Fix indentation.
* cp-support.c: Fix indentation.
* cp-valprint.c: Fix indentation.
* cris-linux-tdep.c: Fix indentation.
* cris-tdep.c: Fix indentation.
* darwin-nat-info.c: Fix indentation.
* darwin-nat.c: Fix indentation.
* darwin-nat.h: Fix indentation.
* dbxread.c: Fix indentation.
* dcache.c: Fix indentation.
* disasm.c: Fix indentation.
* dtrace-probe.c: Fix indentation.
* dwarf2/abbrev.c: Fix indentation.
* dwarf2/attribute.c: Fix indentation.
* dwarf2/expr.c: Fix indentation.
* dwarf2/frame.c: Fix indentation.
* dwarf2/index-cache.c: Fix indentation.
* dwarf2/index-write.c: Fix indentation.
* dwarf2/line-header.c: Fix indentation.
* dwarf2/loc.c: Fix indentation.
* dwarf2/macro.c: Fix indentation.
* dwarf2/read.c: Fix indentation.
* dwarf2/read.h: Fix indentation.
* elfread.c: Fix indentation.
* eval.c: Fix indentation.
* event-top.c: Fix indentation.
* exec.c: Fix indentation.
* exec.h: Fix indentation.
* expprint.c: Fix indentation.
* f-lang.c: Fix indentation.
* f-typeprint.c: Fix indentation.
* f-valprint.c: Fix indentation.
* fbsd-nat.c: Fix indentation.
* fbsd-tdep.c: Fix indentation.
* findvar.c: Fix indentation.
* fork-child.c: Fix indentation.
* frame-unwind.c: Fix indentation.
* frame-unwind.h: Fix indentation.
* frame.c: Fix indentation.
* frv-linux-tdep.c: Fix indentation.
* frv-tdep.c: Fix indentation.
* frv-tdep.h: Fix indentation.
* ft32-tdep.c: Fix indentation.
* gcore.c: Fix indentation.
* gdb_bfd.c: Fix indentation.
* gdbarch.sh: Fix indentation.
* gdbarch.c: Re-generate
* gdbarch.h: Re-generate.
* gdbcore.h: Fix indentation.
* gdbthread.h: Fix indentation.
* gdbtypes.c: Fix indentation.
* gdbtypes.h: Fix indentation.
* glibc-tdep.c: Fix indentation.
* gnu-nat.c: Fix indentation.
* gnu-nat.h: Fix indentation.
* gnu-v2-abi.c: Fix indentation.
* gnu-v3-abi.c: Fix indentation.
* go32-nat.c: Fix indentation.
* guile/guile-internal.h: Fix indentation.
* guile/scm-cmd.c: Fix indentation.
* guile/scm-frame.c: Fix indentation.
* guile/scm-iterator.c: Fix indentation.
* guile/scm-math.c: Fix indentation.
* guile/scm-ports.c: Fix indentation.
* guile/scm-pretty-print.c: Fix indentation.
* guile/scm-value.c: Fix indentation.
* h8300-tdep.c: Fix indentation.
* hppa-linux-nat.c: Fix indentation.
* hppa-linux-tdep.c: Fix indentation.
* hppa-nbsd-nat.c: Fix indentation.
* hppa-nbsd-tdep.c: Fix indentation.
* hppa-obsd-nat.c: Fix indentation.
* hppa-tdep.c: Fix indentation.
* hppa-tdep.h: Fix indentation.
* i386-bsd-nat.c: Fix indentation.
* i386-darwin-nat.c: Fix indentation.
* i386-darwin-tdep.c: Fix indentation.
* i386-dicos-tdep.c: Fix indentation.
* i386-gnu-nat.c: Fix indentation.
* i386-linux-nat.c: Fix indentation.
* i386-linux-tdep.c: Fix indentation.
* i386-nto-tdep.c: Fix indentation.
* i386-obsd-tdep.c: Fix indentation.
* i386-sol2-nat.c: Fix indentation.
* i386-tdep.c: Fix indentation.
* i386-tdep.h: Fix indentation.
* i386-windows-tdep.c: Fix indentation.
* i387-tdep.c: Fix indentation.
* i387-tdep.h: Fix indentation.
* ia64-libunwind-tdep.c: Fix indentation.
* ia64-libunwind-tdep.h: Fix indentation.
* ia64-linux-nat.c: Fix indentation.
* ia64-linux-tdep.c: Fix indentation.
* ia64-tdep.c: Fix indentation.
* ia64-tdep.h: Fix indentation.
* ia64-vms-tdep.c: Fix indentation.
* infcall.c: Fix indentation.
* infcmd.c: Fix indentation.
* inferior.c: Fix indentation.
* infrun.c: Fix indentation.
* iq2000-tdep.c: Fix indentation.
* language.c: Fix indentation.
* linespec.c: Fix indentation.
* linux-fork.c: Fix indentation.
* linux-nat.c: Fix indentation.
* linux-tdep.c: Fix indentation.
* linux-thread-db.c: Fix indentation.
* lm32-tdep.c: Fix indentation.
* m2-lang.c: Fix indentation.
* m2-typeprint.c: Fix indentation.
* m2-valprint.c: Fix indentation.
* m32c-tdep.c: Fix indentation.
* m32r-linux-tdep.c: Fix indentation.
* m32r-tdep.c: Fix indentation.
* m68hc11-tdep.c: Fix indentation.
* m68k-bsd-nat.c: Fix indentation.
* m68k-linux-nat.c: Fix indentation.
* m68k-linux-tdep.c: Fix indentation.
* m68k-tdep.c: Fix indentation.
* machoread.c: Fix indentation.
* macrocmd.c: Fix indentation.
* macroexp.c: Fix indentation.
* macroscope.c: Fix indentation.
* macrotab.c: Fix indentation.
* macrotab.h: Fix indentation.
* main.c: Fix indentation.
* mdebugread.c: Fix indentation.
* mep-tdep.c: Fix indentation.
* mi/mi-cmd-catch.c: Fix indentation.
* mi/mi-cmd-disas.c: Fix indentation.
* mi/mi-cmd-env.c: Fix indentation.
* mi/mi-cmd-stack.c: Fix indentation.
* mi/mi-cmd-var.c: Fix indentation.
* mi/mi-cmds.c: Fix indentation.
* mi/mi-main.c: Fix indentation.
* mi/mi-parse.c: Fix indentation.
* microblaze-tdep.c: Fix indentation.
* minidebug.c: Fix indentation.
* minsyms.c: Fix indentation.
* mips-linux-nat.c: Fix indentation.
* mips-linux-tdep.c: Fix indentation.
* mips-nbsd-tdep.c: Fix indentation.
* mips-tdep.c: Fix indentation.
* mn10300-linux-tdep.c: Fix indentation.
* mn10300-tdep.c: Fix indentation.
* moxie-tdep.c: Fix indentation.
* msp430-tdep.c: Fix indentation.
* namespace.h: Fix indentation.
* nat/fork-inferior.c: Fix indentation.
* nat/gdb_ptrace.h: Fix indentation.
* nat/linux-namespaces.c: Fix indentation.
* nat/linux-osdata.c: Fix indentation.
* nat/netbsd-nat.c: Fix indentation.
* nat/x86-dregs.c: Fix indentation.
* nbsd-nat.c: Fix indentation.
* nbsd-tdep.c: Fix indentation.
* nios2-linux-tdep.c: Fix indentation.
* nios2-tdep.c: Fix indentation.
* nto-procfs.c: Fix indentation.
* nto-tdep.c: Fix indentation.
* objfiles.c: Fix indentation.
* objfiles.h: Fix indentation.
* opencl-lang.c: Fix indentation.
* or1k-tdep.c: Fix indentation.
* osabi.c: Fix indentation.
* osabi.h: Fix indentation.
* osdata.c: Fix indentation.
* p-lang.c: Fix indentation.
* p-typeprint.c: Fix indentation.
* p-valprint.c: Fix indentation.
* parse.c: Fix indentation.
* ppc-linux-nat.c: Fix indentation.
* ppc-linux-tdep.c: Fix indentation.
* ppc-nbsd-nat.c: Fix indentation.
* ppc-nbsd-tdep.c: Fix indentation.
* ppc-obsd-nat.c: Fix indentation.
* ppc-ravenscar-thread.c: Fix indentation.
* ppc-sysv-tdep.c: Fix indentation.
* ppc64-tdep.c: Fix indentation.
* printcmd.c: Fix indentation.
* proc-api.c: Fix indentation.
* producer.c: Fix indentation.
* producer.h: Fix indentation.
* prologue-value.c: Fix indentation.
* prologue-value.h: Fix indentation.
* psymtab.c: Fix indentation.
* python/py-arch.c: Fix indentation.
* python/py-bpevent.c: Fix indentation.
* python/py-event.c: Fix indentation.
* python/py-event.h: Fix indentation.
* python/py-finishbreakpoint.c: Fix indentation.
* python/py-frame.c: Fix indentation.
* python/py-framefilter.c: Fix indentation.
* python/py-inferior.c: Fix indentation.
* python/py-infthread.c: Fix indentation.
* python/py-objfile.c: Fix indentation.
* python/py-prettyprint.c: Fix indentation.
* python/py-registers.c: Fix indentation.
* python/py-signalevent.c: Fix indentation.
* python/py-stopevent.c: Fix indentation.
* python/py-stopevent.h: Fix indentation.
* python/py-threadevent.c: Fix indentation.
* python/py-tui.c: Fix indentation.
* python/py-unwind.c: Fix indentation.
* python/py-value.c: Fix indentation.
* python/py-xmethods.c: Fix indentation.
* python/python-internal.h: Fix indentation.
* python/python.c: Fix indentation.
* ravenscar-thread.c: Fix indentation.
* record-btrace.c: Fix indentation.
* record-full.c: Fix indentation.
* record.c: Fix indentation.
* reggroups.c: Fix indentation.
* regset.h: Fix indentation.
* remote-fileio.c: Fix indentation.
* remote.c: Fix indentation.
* reverse.c: Fix indentation.
* riscv-linux-tdep.c: Fix indentation.
* riscv-ravenscar-thread.c: Fix indentation.
* riscv-tdep.c: Fix indentation.
* rl78-tdep.c: Fix indentation.
* rs6000-aix-tdep.c: Fix indentation.
* rs6000-lynx178-tdep.c: Fix indentation.
* rs6000-nat.c: Fix indentation.
* rs6000-tdep.c: Fix indentation.
* rust-lang.c: Fix indentation.
* rx-tdep.c: Fix indentation.
* s12z-tdep.c: Fix indentation.
* s390-linux-tdep.c: Fix indentation.
* score-tdep.c: Fix indentation.
* ser-base.c: Fix indentation.
* ser-mingw.c: Fix indentation.
* ser-uds.c: Fix indentation.
* ser-unix.c: Fix indentation.
* serial.c: Fix indentation.
* sh-linux-tdep.c: Fix indentation.
* sh-nbsd-tdep.c: Fix indentation.
* sh-tdep.c: Fix indentation.
* skip.c: Fix indentation.
* sol-thread.c: Fix indentation.
* solib-aix.c: Fix indentation.
* solib-darwin.c: Fix indentation.
* solib-frv.c: Fix indentation.
* solib-svr4.c: Fix indentation.
* solib.c: Fix indentation.
* source.c: Fix indentation.
* sparc-linux-tdep.c: Fix indentation.
* sparc-nbsd-tdep.c: Fix indentation.
* sparc-obsd-tdep.c: Fix indentation.
* sparc-ravenscar-thread.c: Fix indentation.
* sparc-tdep.c: Fix indentation.
* sparc64-linux-tdep.c: Fix indentation.
* sparc64-nbsd-tdep.c: Fix indentation.
* sparc64-obsd-tdep.c: Fix indentation.
* sparc64-tdep.c: Fix indentation.
* stabsread.c: Fix indentation.
* stack.c: Fix indentation.
* stap-probe.c: Fix indentation.
* stubs/ia64vms-stub.c: Fix indentation.
* stubs/m32r-stub.c: Fix indentation.
* stubs/m68k-stub.c: Fix indentation.
* stubs/sh-stub.c: Fix indentation.
* stubs/sparc-stub.c: Fix indentation.
* symfile-mem.c: Fix indentation.
* symfile.c: Fix indentation.
* symfile.h: Fix indentation.
* symmisc.c: Fix indentation.
* symtab.c: Fix indentation.
* symtab.h: Fix indentation.
* target-float.c: Fix indentation.
* target.c: Fix indentation.
* target.h: Fix indentation.
* tic6x-tdep.c: Fix indentation.
* tilegx-linux-tdep.c: Fix indentation.
* tilegx-tdep.c: Fix indentation.
* top.c: Fix indentation.
* tracefile-tfile.c: Fix indentation.
* tracepoint.c: Fix indentation.
* tui/tui-disasm.c: Fix indentation.
* tui/tui-io.c: Fix indentation.
* tui/tui-regs.c: Fix indentation.
* tui/tui-stack.c: Fix indentation.
* tui/tui-win.c: Fix indentation.
* tui/tui-winsource.c: Fix indentation.
* tui/tui.c: Fix indentation.
* typeprint.c: Fix indentation.
* ui-out.h: Fix indentation.
* unittests/copy_bitwise-selftests.c: Fix indentation.
* unittests/memory-map-selftests.c: Fix indentation.
* utils.c: Fix indentation.
* v850-tdep.c: Fix indentation.
* valarith.c: Fix indentation.
* valops.c: Fix indentation.
* valprint.c: Fix indentation.
* valprint.h: Fix indentation.
* value.c: Fix indentation.
* value.h: Fix indentation.
* varobj.c: Fix indentation.
* vax-tdep.c: Fix indentation.
* windows-nat.c: Fix indentation.
* windows-tdep.c: Fix indentation.
* xcoffread.c: Fix indentation.
* xml-syscall.c: Fix indentation.
* xml-tdesc.c: Fix indentation.
* xstormy16-tdep.c: Fix indentation.
* xtensa-config.c: Fix indentation.
* xtensa-linux-nat.c: Fix indentation.
* xtensa-linux-tdep.c: Fix indentation.
* xtensa-tdep.c: Fix indentation.
gdbserver/ChangeLog:
* ax.cc: Fix indentation.
* dll.cc: Fix indentation.
* inferiors.h: Fix indentation.
* linux-low.cc: Fix indentation.
* linux-nios2-low.cc: Fix indentation.
* linux-ppc-ipa.cc: Fix indentation.
* linux-ppc-low.cc: Fix indentation.
* linux-x86-low.cc: Fix indentation.
* linux-xtensa-low.cc: Fix indentation.
* regcache.cc: Fix indentation.
* server.cc: Fix indentation.
* tracepoint.cc: Fix indentation.
gdbsupport/ChangeLog:
* common-exceptions.h: Fix indentation.
* event-loop.cc: Fix indentation.
* fileio.cc: Fix indentation.
* filestuff.cc: Fix indentation.
* gdb-dlfcn.cc: Fix indentation.
* gdb_string_view.h: Fix indentation.
* job-control.cc: Fix indentation.
* signals.cc: Fix indentation.
Change-Id: I4bad7ae6be0fbe14168b8ebafb98ffe14964a695
2020-11-02 23:26:14 +08:00
|
|
|
| | |
|
|
|
|
| arg word N | | caller's
|
|
|
|
| : | | frame
|
|
|
|
| arg word 10 | |
|
|
|
|
| arg word 9 | |
|
|
|
|
old SP ---> +-----------------------+ --+
|
|
|
|
| | |
|
|
|
|
| callee-saved | |
|
|
|
|
| registers | |
|
|
|
|
| including fp, blink | |
|
|
|
|
| | | callee's
|
|
|
|
new FP ---> +-----------------------+ | frame
|
|
|
|
| | |
|
|
|
|
| local | |
|
|
|
|
| variables | |
|
|
|
|
| | |
|
|
|
|
| register | |
|
|
|
|
| spill area | |
|
|
|
|
| | |
|
|
|
|
| outgoing args | |
|
|
|
|
| | |
|
|
|
|
new SP ---> +-----------------------+ --+
|
|
|
|
| |
|
|
|
|
| unused |
|
|
|
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
V
|
|
|
|
downwards
|
2016-08-13 01:02:20 +08:00
|
|
|
|
|
|
|
The list of arguments to be passed to a function is considered to be a
|
|
|
|
sequence of _N_ words (as though all the parameters were stored in order in
|
|
|
|
memory with each parameter occupying an integral number of words). Words
|
|
|
|
1..8 are passed in registers 0..7; if the function has more than 8 words of
|
|
|
|
arguments then words 9..@em N are passed on the stack in the caller's frame.
|
|
|
|
|
|
|
|
If the function has a variable number of arguments, e.g. it has a form such
|
|
|
|
as `function (p1, p2, ...);' and _P_ words are required to hold the values
|
|
|
|
of the named parameters (which are passed in registers 0..@em P -1), then
|
|
|
|
the remaining 8 - _P_ words passed in registers _P_..7 are spilled into the
|
|
|
|
top of the frame so that the anonymous parameter words occupy a continuous
|
|
|
|
region.
|
|
|
|
|
|
|
|
Any arguments are already in target byte order. We just need to store
|
|
|
|
them!
|
|
|
|
|
|
|
|
BP_ADDR is the return address where breakpoint must be placed. NARGS is
|
|
|
|
the number of arguments to the function. ARGS is the arguments values (in
|
|
|
|
target byte order). SP is the Current value of SP register. STRUCT_RETURN
|
|
|
|
is TRUE if structures are returned by the function. STRUCT_ADDR is the
|
|
|
|
hidden address for returning a struct. Returns SP of a new frame. */
|
|
|
|
|
|
|
|
static CORE_ADDR
|
|
|
|
arc_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
|
|
|
|
struct regcache *regcache, CORE_ADDR bp_addr, int nargs,
|
2018-11-16 19:21:04 +08:00
|
|
|
struct value **args, CORE_ADDR sp,
|
|
|
|
function_call_return_method return_method,
|
2016-08-13 01:02:20 +08:00
|
|
|
CORE_ADDR struct_addr)
|
|
|
|
{
|
2021-01-14 03:32:39 +08:00
|
|
|
arc_debug_printf ("nargs = %d", nargs);
|
2016-08-13 01:02:20 +08:00
|
|
|
|
|
|
|
int arg_reg = ARC_FIRST_ARG_REGNUM;
|
|
|
|
|
|
|
|
/* Push the return address. */
|
|
|
|
regcache_cooked_write_unsigned (regcache, ARC_BLINK_REGNUM, bp_addr);
|
|
|
|
|
|
|
|
/* Are we returning a value using a structure return instead of a normal
|
|
|
|
value return? If so, struct_addr is the address of the reserved space for
|
|
|
|
the return structure to be written on the stack, and that address is
|
|
|
|
passed to that function as a hidden first argument. */
|
2018-11-16 19:21:04 +08:00
|
|
|
if (return_method == return_method_struct)
|
2016-08-13 01:02:20 +08:00
|
|
|
{
|
|
|
|
/* Pass the return address in the first argument register. */
|
|
|
|
regcache_cooked_write_unsigned (regcache, arg_reg, struct_addr);
|
|
|
|
|
2021-01-14 03:32:39 +08:00
|
|
|
arc_debug_printf ("struct return address %s passed in R%d",
|
|
|
|
print_core_address (gdbarch, struct_addr), arg_reg);
|
2016-08-13 01:02:20 +08:00
|
|
|
|
|
|
|
arg_reg++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nargs > 0)
|
|
|
|
{
|
|
|
|
unsigned int total_space = 0;
|
|
|
|
|
|
|
|
/* How much space do the arguments occupy in total? Must round each
|
|
|
|
argument's size up to an integral number of words. */
|
|
|
|
for (int i = 0; i < nargs; i++)
|
|
|
|
{
|
2023-01-31 22:52:09 +08:00
|
|
|
unsigned int len = args[i]->type ()->length ();
|
2016-08-13 01:02:20 +08:00
|
|
|
unsigned int space = align_up (len, 4);
|
|
|
|
|
|
|
|
total_space += space;
|
|
|
|
|
2021-01-14 03:32:39 +08:00
|
|
|
arc_debug_printf ("arg %d: %u bytes -> %u", i, len, space);
|
2016-08-13 01:02:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate a buffer to hold a memory image of the arguments. */
|
|
|
|
gdb_byte *memory_image = XCNEWVEC (gdb_byte, total_space);
|
|
|
|
|
|
|
|
/* Now copy all of the arguments into the buffer, correctly aligned. */
|
|
|
|
gdb_byte *data = memory_image;
|
|
|
|
for (int i = 0; i < nargs; i++)
|
|
|
|
{
|
2023-01-31 22:52:09 +08:00
|
|
|
unsigned int len = args[i]->type ()->length ();
|
2016-08-13 01:02:20 +08:00
|
|
|
unsigned int space = align_up (len, 4);
|
|
|
|
|
2023-02-01 05:38:30 +08:00
|
|
|
memcpy (data, args[i]->contents ().data (), (size_t) len);
|
2021-01-14 03:32:39 +08:00
|
|
|
arc_debug_printf ("copying arg %d, val 0x%08x, len %d to mem",
|
2023-02-01 05:38:30 +08:00
|
|
|
i, *((int *) args[i]->contents ().data ()),
|
2021-10-05 08:47:06 +08:00
|
|
|
len);
|
2016-08-13 01:02:20 +08:00
|
|
|
|
|
|
|
data += space;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now load as much as possible of the memory image into registers. */
|
|
|
|
data = memory_image;
|
|
|
|
while (arg_reg <= ARC_LAST_ARG_REGNUM)
|
|
|
|
{
|
2021-01-14 03:32:39 +08:00
|
|
|
arc_debug_printf ("passing 0x%02x%02x%02x%02x in register R%d",
|
|
|
|
data[0], data[1], data[2], data[3], arg_reg);
|
2016-08-13 01:02:20 +08:00
|
|
|
|
|
|
|
/* Note we don't use write_unsigned here, since that would convert
|
|
|
|
the byte order, but we are already in the correct byte order. */
|
2018-05-31 02:54:42 +08:00
|
|
|
regcache->cooked_write (arg_reg, data);
|
2016-08-13 01:02:20 +08:00
|
|
|
|
|
|
|
data += ARC_REGISTER_SIZE;
|
|
|
|
total_space -= ARC_REGISTER_SIZE;
|
|
|
|
|
|
|
|
/* All the data is now in registers. */
|
|
|
|
if (total_space == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
arg_reg++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If there is any data left, push it onto the stack (in a single write
|
|
|
|
operation). */
|
|
|
|
if (total_space > 0)
|
|
|
|
{
|
2021-01-14 03:32:39 +08:00
|
|
|
arc_debug_printf ("passing %d bytes on stack\n", total_space);
|
2016-08-13 01:02:20 +08:00
|
|
|
|
|
|
|
sp -= total_space;
|
|
|
|
write_memory (sp, data, (int) total_space);
|
|
|
|
}
|
|
|
|
|
|
|
|
xfree (memory_image);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Finally, update the SP register. */
|
|
|
|
regcache_cooked_write_unsigned (regcache, gdbarch_sp_regnum (gdbarch), sp);
|
|
|
|
|
|
|
|
return sp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Implement the "push_dummy_code" gdbarch method.
|
|
|
|
|
|
|
|
We don't actually push any code. We just identify where a breakpoint can
|
|
|
|
be inserted to which we are can return and the resume address where we
|
|
|
|
should be called.
|
|
|
|
|
|
|
|
ARC does not necessarily have an executable stack, so we can't put the
|
|
|
|
return breakpoint there. Instead we put it at the entry point of the
|
|
|
|
function. This means the SP is unchanged.
|
|
|
|
|
|
|
|
SP is a current stack pointer FUNADDR is an address of the function to be
|
|
|
|
called. ARGS is arguments to pass. NARGS is a number of args to pass.
|
|
|
|
VALUE_TYPE is a type of value returned. REAL_PC is a resume address when
|
|
|
|
the function is called. BP_ADDR is an address where breakpoint should be
|
|
|
|
set. Returns the updated stack pointer. */
|
|
|
|
|
|
|
|
static CORE_ADDR
|
|
|
|
arc_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funaddr,
|
|
|
|
struct value **args, int nargs, struct type *value_type,
|
|
|
|
CORE_ADDR *real_pc, CORE_ADDR *bp_addr,
|
|
|
|
struct regcache *regcache)
|
|
|
|
{
|
|
|
|
*real_pc = funaddr;
|
2024-05-17 05:04:13 +08:00
|
|
|
*bp_addr = entry_point_address (current_program_space);
|
2016-08-13 01:02:20 +08:00
|
|
|
return sp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Implement the "cannot_fetch_register" gdbarch method. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
arc_cannot_fetch_register (struct gdbarch *gdbarch, int regnum)
|
|
|
|
{
|
2017-02-10 19:11:46 +08:00
|
|
|
/* Assume that register is readable if it is unknown. LIMM and RESERVED are
|
|
|
|
not real registers, but specific register numbers. They are available as
|
|
|
|
regnums to align architectural register numbers with GDB internal regnums,
|
|
|
|
but they shouldn't appear in target descriptions generated by
|
|
|
|
GDB-servers. */
|
|
|
|
switch (regnum)
|
|
|
|
{
|
|
|
|
case ARC_RESERVED_REGNUM:
|
|
|
|
case ARC_LIMM_REGNUM:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
2016-08-13 01:02:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Implement the "cannot_store_register" gdbarch method. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
arc_cannot_store_register (struct gdbarch *gdbarch, int regnum)
|
|
|
|
{
|
2017-02-10 19:11:46 +08:00
|
|
|
/* Assume that register is writable if it is unknown. See comment in
|
|
|
|
arc_cannot_fetch_register about LIMM and RESERVED. */
|
2016-08-13 01:02:20 +08:00
|
|
|
switch (regnum)
|
|
|
|
{
|
2017-02-10 19:11:46 +08:00
|
|
|
case ARC_RESERVED_REGNUM:
|
|
|
|
case ARC_LIMM_REGNUM:
|
2016-08-13 01:02:20 +08:00
|
|
|
case ARC_PCL_REGNUM:
|
2017-02-10 19:11:46 +08:00
|
|
|
return true;
|
2016-08-13 01:02:20 +08:00
|
|
|
default:
|
2017-02-10 19:11:46 +08:00
|
|
|
return false;
|
2016-08-13 01:02:20 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the return value of a function from the registers/memory used to
|
|
|
|
return it, according to the convention used by the ABI - 4-bytes values are
|
|
|
|
in the R0, while 8-byte values are in the R0-R1.
|
|
|
|
|
|
|
|
TODO: This implementation ignores the case of "complex double", where
|
|
|
|
according to ABI, value is returned in the R0-R3 registers.
|
|
|
|
|
|
|
|
TYPE is a returned value's type. VALBUF is a buffer for the returned
|
|
|
|
value. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
arc_extract_return_value (struct gdbarch *gdbarch, struct type *type,
|
|
|
|
struct regcache *regcache, gdb_byte *valbuf)
|
|
|
|
{
|
2022-09-21 23:05:21 +08:00
|
|
|
unsigned int len = type->length ();
|
2016-08-13 01:02:20 +08:00
|
|
|
|
2021-01-14 03:32:39 +08:00
|
|
|
arc_debug_printf ("called");
|
2016-08-13 01:02:20 +08:00
|
|
|
|
|
|
|
if (len <= ARC_REGISTER_SIZE)
|
|
|
|
{
|
|
|
|
ULONGEST val;
|
|
|
|
|
|
|
|
/* Get the return value from one register. */
|
|
|
|
regcache_cooked_read_unsigned (regcache, ARC_R0_REGNUM, &val);
|
|
|
|
store_unsigned_integer (valbuf, (int) len,
|
|
|
|
gdbarch_byte_order (gdbarch), val);
|
|
|
|
|
2021-01-14 03:32:39 +08:00
|
|
|
arc_debug_printf ("returning 0x%s", phex (val, ARC_REGISTER_SIZE));
|
2016-08-13 01:02:20 +08:00
|
|
|
}
|
|
|
|
else if (len <= ARC_REGISTER_SIZE * 2)
|
|
|
|
{
|
|
|
|
ULONGEST low, high;
|
|
|
|
|
|
|
|
/* Get the return value from two registers. */
|
|
|
|
regcache_cooked_read_unsigned (regcache, ARC_R0_REGNUM, &low);
|
|
|
|
regcache_cooked_read_unsigned (regcache, ARC_R1_REGNUM, &high);
|
|
|
|
|
|
|
|
store_unsigned_integer (valbuf, ARC_REGISTER_SIZE,
|
|
|
|
gdbarch_byte_order (gdbarch), low);
|
|
|
|
store_unsigned_integer (valbuf + ARC_REGISTER_SIZE,
|
|
|
|
(int) len - ARC_REGISTER_SIZE,
|
|
|
|
gdbarch_byte_order (gdbarch), high);
|
|
|
|
|
2021-01-14 03:32:39 +08:00
|
|
|
arc_debug_printf ("returning 0x%s%s",
|
|
|
|
phex (high, ARC_REGISTER_SIZE),
|
|
|
|
phex (low, ARC_REGISTER_SIZE));
|
2016-08-13 01:02:20 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
error (_("arc: extract_return_value: type length %u too large"), len);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Store the return value of a function into the registers/memory used to
|
|
|
|
return it, according to the convention used by the ABI.
|
|
|
|
|
|
|
|
TODO: This implementation ignores the case of "complex double", where
|
|
|
|
according to ABI, value is returned in the R0-R3 registers.
|
|
|
|
|
|
|
|
TYPE is a returned value's type. VALBUF is a buffer with the value to
|
|
|
|
return. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
arc_store_return_value (struct gdbarch *gdbarch, struct type *type,
|
|
|
|
struct regcache *regcache, const gdb_byte *valbuf)
|
|
|
|
{
|
2022-09-21 23:05:21 +08:00
|
|
|
unsigned int len = type->length ();
|
2016-08-13 01:02:20 +08:00
|
|
|
|
2021-01-14 03:32:39 +08:00
|
|
|
arc_debug_printf ("called");
|
2016-08-13 01:02:20 +08:00
|
|
|
|
|
|
|
if (len <= ARC_REGISTER_SIZE)
|
|
|
|
{
|
|
|
|
ULONGEST val;
|
|
|
|
|
|
|
|
/* Put the return value into one register. */
|
|
|
|
val = extract_unsigned_integer (valbuf, (int) len,
|
|
|
|
gdbarch_byte_order (gdbarch));
|
|
|
|
regcache_cooked_write_unsigned (regcache, ARC_R0_REGNUM, val);
|
|
|
|
|
2021-01-14 03:32:39 +08:00
|
|
|
arc_debug_printf ("storing 0x%s", phex (val, ARC_REGISTER_SIZE));
|
2016-08-13 01:02:20 +08:00
|
|
|
}
|
|
|
|
else if (len <= ARC_REGISTER_SIZE * 2)
|
|
|
|
{
|
|
|
|
ULONGEST low, high;
|
|
|
|
|
|
|
|
/* Put the return value into two registers. */
|
|
|
|
low = extract_unsigned_integer (valbuf, ARC_REGISTER_SIZE,
|
|
|
|
gdbarch_byte_order (gdbarch));
|
|
|
|
high = extract_unsigned_integer (valbuf + ARC_REGISTER_SIZE,
|
|
|
|
(int) len - ARC_REGISTER_SIZE,
|
|
|
|
gdbarch_byte_order (gdbarch));
|
|
|
|
|
|
|
|
regcache_cooked_write_unsigned (regcache, ARC_R0_REGNUM, low);
|
|
|
|
regcache_cooked_write_unsigned (regcache, ARC_R1_REGNUM, high);
|
|
|
|
|
2021-01-14 03:32:39 +08:00
|
|
|
arc_debug_printf ("storing 0x%s%s",
|
|
|
|
phex (high, ARC_REGISTER_SIZE),
|
|
|
|
phex (low, ARC_REGISTER_SIZE));
|
2016-08-13 01:02:20 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
error (_("arc_store_return_value: type length too large."));
|
|
|
|
}
|
|
|
|
|
2016-10-12 19:36:44 +08:00
|
|
|
/* Implement the "get_longjmp_target" gdbarch method. */
|
|
|
|
|
|
|
|
static int
|
gdb: pass frames as `const frame_info_ptr &`
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>
2024-02-20 02:07:47 +08:00
|
|
|
arc_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc)
|
2016-10-12 19:36:44 +08:00
|
|
|
{
|
2021-01-14 03:32:39 +08:00
|
|
|
arc_debug_printf ("called");
|
2016-10-12 19:36:44 +08:00
|
|
|
|
|
|
|
struct gdbarch *gdbarch = get_frame_arch (frame);
|
gdb: move the type cast into gdbarch_tdep
I built GDB for all targets on a x86-64/GNU-Linux system, and
then (accidentally) passed GDB a RISC-V binary, and asked GDB to "run"
the binary on the native target. I got this error:
(gdb) show architecture
The target architecture is set to "auto" (currently "i386").
(gdb) file /tmp/hello.rv32.exe
Reading symbols from /tmp/hello.rv32.exe...
(gdb) show architecture
The target architecture is set to "auto" (currently "riscv:rv32").
(gdb) run
Starting program: /tmp/hello.rv32.exe
../../src/gdb/i387-tdep.c:596: internal-error: i387_supply_fxsave: Assertion `tdep->st0_regnum >= I386_ST0_REGNUM' failed.
What's going on here is this; initially the architecture is i386, this
is based on the default architecture, which is set based on the native
target. After loading the RISC-V executable the architecture of the
current inferior is updated based on the architecture of the
executable.
When we "run", GDB does a fork & exec, with the inferior being
controlled through ptrace. GDB sees an initial stop from the inferior
as soon as the inferior comes to life. In response to this stop GDB
ends up calling save_stop_reason (linux-nat.c), which ends up trying
to read register from the inferior, to do this we end up calling
target_ops::fetch_registers, which, for the x86-64 native target,
calls amd64_linux_nat_target::fetch_registers.
After this I eventually end up in i387_supply_fxsave, different x86
based targets will end in different functions to fetch registers, but
it doesn't really matter which function we end up in, the problem is
this line, which is repeated in many places:
i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (arch);
The problem here is that the ARCH in this line comes from the current
inferior, which, as we discussed above, will be a RISC-V gdbarch, the
tdep field will actually be of type riscv_gdbarch_tdep, not
i386_gdbarch_tdep. After this cast we are relying on undefined
behaviour, in my case I happen to trigger an assert, but this might
not always be the case.
The thing I tried that exposed this problem was of course, trying to
start an executable of the wrong architecture on a native target. I
don't think that the correct solution for this problem is to detect,
at the point of cast, that the gdbarch_tdep object is of the wrong
type, but, I did wonder, is there a way that we could protect
ourselves from incorrectly casting the gdbarch_tdep object?
I think that there is something we can do here, and this commit is the
first step in that direction, though no actual check is added by this
commit.
This commit can be split into two parts:
(1) In gdbarch.h and arch-utils.c. In these files I have modified
gdbarch_tdep (the function) so that it now takes a template argument,
like this:
template<typename TDepType>
static inline TDepType *
gdbarch_tdep (struct gdbarch *gdbarch)
{
struct gdbarch_tdep *tdep = gdbarch_tdep_1 (gdbarch);
return static_cast<TDepType *> (tdep);
}
After this change we are no better protected, but the cast is now
done within the gdbarch_tdep function rather than at the call sites,
this leads to the second, much larger change in this commit,
(2) Everywhere gdbarch_tdep is called, we make changes like this:
- i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (arch);
+ i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (arch);
There should be no functional change after this commit.
In the next commit I will build on this change to add an assertion in
gdbarch_tdep that checks we are casting to the correct type.
2022-05-19 20:20:17 +08:00
|
|
|
arc_gdbarch_tdep *tdep = gdbarch_tdep<arc_gdbarch_tdep> (gdbarch);
|
2016-10-12 19:36:44 +08:00
|
|
|
int pc_offset = tdep->jb_pc * ARC_REGISTER_SIZE;
|
|
|
|
gdb_byte buf[ARC_REGISTER_SIZE];
|
|
|
|
CORE_ADDR jb_addr = get_frame_register_unsigned (frame, ARC_FIRST_ARG_REGNUM);
|
|
|
|
|
|
|
|
if (target_read_memory (jb_addr + pc_offset, buf, ARC_REGISTER_SIZE))
|
|
|
|
return 0; /* Failed to read from memory. */
|
|
|
|
|
|
|
|
*pc = extract_unsigned_integer (buf, ARC_REGISTER_SIZE,
|
|
|
|
gdbarch_byte_order (gdbarch));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2016-08-13 01:02:20 +08:00
|
|
|
/* Implement the "return_value" gdbarch method. */
|
|
|
|
|
|
|
|
static enum return_value_convention
|
|
|
|
arc_return_value (struct gdbarch *gdbarch, struct value *function,
|
|
|
|
struct type *valtype, struct regcache *regcache,
|
|
|
|
gdb_byte *readbuf, const gdb_byte *writebuf)
|
|
|
|
{
|
|
|
|
/* If the return type is a struct, or a union, or would occupy more than two
|
|
|
|
registers, the ABI uses the "struct return convention": the calling
|
|
|
|
function passes a hidden first parameter to the callee (in R0). That
|
|
|
|
parameter is the address at which the value being returned should be
|
|
|
|
stored. Otherwise, the result is returned in registers. */
|
2020-05-15 01:46:38 +08:00
|
|
|
int is_struct_return = (valtype->code () == TYPE_CODE_STRUCT
|
|
|
|
|| valtype->code () == TYPE_CODE_UNION
|
2022-09-21 23:05:21 +08:00
|
|
|
|| valtype->length () > 2 * ARC_REGISTER_SIZE);
|
2016-08-13 01:02:20 +08:00
|
|
|
|
2021-01-14 03:32:39 +08:00
|
|
|
arc_debug_printf ("readbuf = %s, writebuf = %s",
|
|
|
|
host_address_to_string (readbuf),
|
|
|
|
host_address_to_string (writebuf));
|
2016-08-13 01:02:20 +08:00
|
|
|
|
|
|
|
if (writebuf != NULL)
|
|
|
|
{
|
|
|
|
/* Case 1. GDB should not ask us to set a struct return value: it
|
|
|
|
should know the struct return location and write the value there
|
|
|
|
itself. */
|
|
|
|
gdb_assert (!is_struct_return);
|
|
|
|
arc_store_return_value (gdbarch, valtype, regcache, writebuf);
|
|
|
|
}
|
|
|
|
else if (readbuf != NULL)
|
|
|
|
{
|
|
|
|
/* Case 2. GDB should not ask us to get a struct return value: it
|
|
|
|
should know the struct return location and read the value from there
|
|
|
|
itself. */
|
|
|
|
gdb_assert (!is_struct_return);
|
|
|
|
arc_extract_return_value (gdbarch, valtype, regcache, readbuf);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (is_struct_return
|
|
|
|
? RETURN_VALUE_STRUCT_CONVENTION
|
|
|
|
: RETURN_VALUE_REGISTER_CONVENTION);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return the base address of the frame. For ARC, the base address is the
|
|
|
|
frame pointer. */
|
|
|
|
|
|
|
|
static CORE_ADDR
|
gdb: pass frames as `const frame_info_ptr &`
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>
2024-02-20 02:07:47 +08:00
|
|
|
arc_frame_base_address (const frame_info_ptr &this_frame, void **prologue_cache)
|
2016-08-13 01:02:20 +08:00
|
|
|
{
|
|
|
|
return (CORE_ADDR) get_frame_register_unsigned (this_frame, ARC_FP_REGNUM);
|
|
|
|
}
|
|
|
|
|
2017-02-10 19:12:09 +08:00
|
|
|
/* Helper function that returns valid pv_t for an instruction operand:
|
|
|
|
either a register or a constant. */
|
|
|
|
|
|
|
|
static pv_t
|
|
|
|
arc_pv_get_operand (pv_t *regs, const struct arc_instruction &insn, int operand)
|
|
|
|
{
|
|
|
|
if (insn.operands[operand].kind == ARC_OPERAND_KIND_REG)
|
|
|
|
return regs[insn.operands[operand].value];
|
|
|
|
else
|
|
|
|
return pv_constant (arc_insn_get_operand_value (insn, operand));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Determine whether the given disassembled instruction may be part of a
|
|
|
|
function prologue. If it is, the information in the frame unwind cache will
|
|
|
|
be updated. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
arc_is_in_prologue (struct gdbarch *gdbarch, const struct arc_instruction &insn,
|
|
|
|
pv_t *regs, struct pv_area *stack)
|
|
|
|
{
|
|
|
|
/* It might be that currently analyzed address doesn't contain an
|
|
|
|
instruction, hence INSN is not valid. It likely means that address points
|
|
|
|
to a data, non-initialized memory, or middle of a 32-bit instruction. In
|
|
|
|
practice this may happen if GDB connects to a remote target that has
|
|
|
|
non-zeroed memory. GDB would read PC value and would try to analyze
|
|
|
|
prologue, but there is no guarantee that memory contents at the address
|
|
|
|
specified in PC is address is a valid instruction. There is not much that
|
|
|
|
that can be done about that. */
|
|
|
|
if (!insn.valid)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* Branch/jump or a predicated instruction. */
|
|
|
|
if (insn.is_control_flow || insn.condition_code != ARC_CC_AL)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* Store of some register. May or may not update base address register. */
|
|
|
|
if (insn.insn_class == STORE || insn.insn_class == PUSH)
|
|
|
|
{
|
2019-10-26 15:55:32 +08:00
|
|
|
/* There is definitely at least one operand - register/value being
|
2017-02-10 19:12:09 +08:00
|
|
|
stored. */
|
|
|
|
gdb_assert (insn.operands_count > 0);
|
|
|
|
|
|
|
|
/* Store at some constant address. */
|
|
|
|
if (insn.operands_count > 1
|
|
|
|
&& insn.operands[1].kind != ARC_OPERAND_KIND_REG)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* Writeback modes:
|
|
|
|
Mode Address used Writeback value
|
|
|
|
--------------------------------------------------
|
|
|
|
No reg + offset no
|
|
|
|
A/AW reg + offset reg + offset
|
|
|
|
AB reg reg + offset
|
|
|
|
AS reg + (offset << scaling) no
|
|
|
|
|
|
|
|
"PUSH reg" is an alias to "ST.AW reg, [SP, -4]" encoding. However
|
|
|
|
16-bit PUSH_S is a distinct instruction encoding, where offset and
|
|
|
|
base register are implied through opcode. */
|
|
|
|
|
|
|
|
/* Register with base memory address. */
|
|
|
|
int base_reg = arc_insn_get_memory_base_reg (insn);
|
|
|
|
|
|
|
|
/* Address where to write. arc_insn_get_memory_offset returns scaled
|
|
|
|
value for ARC_WRITEBACK_AS. */
|
|
|
|
pv_t addr;
|
|
|
|
if (insn.writeback_mode == ARC_WRITEBACK_AB)
|
|
|
|
addr = regs[base_reg];
|
|
|
|
else
|
|
|
|
addr = pv_add_constant (regs[base_reg],
|
|
|
|
arc_insn_get_memory_offset (insn));
|
|
|
|
|
C++-ify prologue-value's pv_area
This patch is an initial C++-ification of pv_area, from
prologue-value. It turns pv_area into a class with a constructor and
destructor; renames the data members; and changes various functions to
be member functions. This allows the removal of
make_cleanup_free_pv_area.
gdb/ChangeLog
2017-10-12 Tom Tromey <tom@tromey.com>
* s390-linux-tdep.c (s390_store, s390_load)
(s390_check_for_saved, s390_analyze_prologue): Update.
* rx-tdep.c (check_for_saved, rx_analyze_prologue): Update.
* rl78-tdep.c (rl78_analyze_prologue, check_for_saved): Update.
* prologue-value.h (class pv_area): Move from prologue-value.c.
Change names of members. Add constructor, destructor, member
functions.
(make_pv_area, free_pv_area, make_cleanup_free_pv_area)
(pv_area_store, pv_area_fetch, pv_area_store_would_trash)
(pv_area_fetch, pv_area_scan): Don't declare.
* prologue-value.c (struct pv_area::area_entry): Now member of
pv_area.
(struct pv_area): Move to prologue-value.h.
(pv_area::pv_area): Rename from make_pv_area.
(pv_area::~pv_area): Rename from free_pv_area.
(do_free_pv_area_cleanup, make_cleanup_free_pv_area): Remove.
(clear_entries, find_entry, overlaps, store_would_trash, store)
(fetch, find_reg, scan): Now member of pv_area.
Remove "area" argument. Update.
* msp430-tdep.c (check_for_saved, msp430_analyze_prologue):
Update.
* mn10300-tdep.c (push_reg, check_for_saved)
(mn10300_analyze_prologue): Update.
* mep-tdep.c (is_arg_spill, check_for_saved)
(mep_analyze_prologue): Update.
* m32c-tdep.c (m32c_pv_push, m32c_srcdest_fetch)
(m32c_srcdest_store, m32c_pv_enter, m32c_is_arg_spill)
(m32c_is_struct_return, m32c_analyze_prologue): Update.
* arm-tdep.c (thumb_analyze_prologue, arm_analyze_prologue):
Update.
* arc-tdep.c (arc_is_in_prologue, arc_analyze_prologue): Update.
* aarch64-tdep.c (aarch64_analyze_prologue): Update.
2017-10-08 08:23:36 +08:00
|
|
|
if (stack->store_would_trash (addr))
|
2017-02-10 19:12:09 +08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if (insn.data_size_mode != ARC_SCALING_D)
|
|
|
|
{
|
|
|
|
/* Find the value being stored. */
|
|
|
|
pv_t store_value = arc_pv_get_operand (regs, insn, 0);
|
|
|
|
|
|
|
|
/* What is the size of a the stored value? */
|
|
|
|
CORE_ADDR size;
|
|
|
|
if (insn.data_size_mode == ARC_SCALING_B)
|
|
|
|
size = 1;
|
|
|
|
else if (insn.data_size_mode == ARC_SCALING_H)
|
|
|
|
size = 2;
|
|
|
|
else
|
|
|
|
size = ARC_REGISTER_SIZE;
|
|
|
|
|
C++-ify prologue-value's pv_area
This patch is an initial C++-ification of pv_area, from
prologue-value. It turns pv_area into a class with a constructor and
destructor; renames the data members; and changes various functions to
be member functions. This allows the removal of
make_cleanup_free_pv_area.
gdb/ChangeLog
2017-10-12 Tom Tromey <tom@tromey.com>
* s390-linux-tdep.c (s390_store, s390_load)
(s390_check_for_saved, s390_analyze_prologue): Update.
* rx-tdep.c (check_for_saved, rx_analyze_prologue): Update.
* rl78-tdep.c (rl78_analyze_prologue, check_for_saved): Update.
* prologue-value.h (class pv_area): Move from prologue-value.c.
Change names of members. Add constructor, destructor, member
functions.
(make_pv_area, free_pv_area, make_cleanup_free_pv_area)
(pv_area_store, pv_area_fetch, pv_area_store_would_trash)
(pv_area_fetch, pv_area_scan): Don't declare.
* prologue-value.c (struct pv_area::area_entry): Now member of
pv_area.
(struct pv_area): Move to prologue-value.h.
(pv_area::pv_area): Rename from make_pv_area.
(pv_area::~pv_area): Rename from free_pv_area.
(do_free_pv_area_cleanup, make_cleanup_free_pv_area): Remove.
(clear_entries, find_entry, overlaps, store_would_trash, store)
(fetch, find_reg, scan): Now member of pv_area.
Remove "area" argument. Update.
* msp430-tdep.c (check_for_saved, msp430_analyze_prologue):
Update.
* mn10300-tdep.c (push_reg, check_for_saved)
(mn10300_analyze_prologue): Update.
* mep-tdep.c (is_arg_spill, check_for_saved)
(mep_analyze_prologue): Update.
* m32c-tdep.c (m32c_pv_push, m32c_srcdest_fetch)
(m32c_srcdest_store, m32c_pv_enter, m32c_is_arg_spill)
(m32c_is_struct_return, m32c_analyze_prologue): Update.
* arm-tdep.c (thumb_analyze_prologue, arm_analyze_prologue):
Update.
* arc-tdep.c (arc_is_in_prologue, arc_analyze_prologue): Update.
* aarch64-tdep.c (aarch64_analyze_prologue): Update.
2017-10-08 08:23:36 +08:00
|
|
|
stack->store (addr, size, store_value);
|
2017-02-10 19:12:09 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (insn.operands[0].kind == ARC_OPERAND_KIND_REG)
|
|
|
|
{
|
|
|
|
/* If this is a double store, than write N+1 register as well. */
|
|
|
|
pv_t store_value1 = regs[insn.operands[0].value];
|
|
|
|
pv_t store_value2 = regs[insn.operands[0].value + 1];
|
C++-ify prologue-value's pv_area
This patch is an initial C++-ification of pv_area, from
prologue-value. It turns pv_area into a class with a constructor and
destructor; renames the data members; and changes various functions to
be member functions. This allows the removal of
make_cleanup_free_pv_area.
gdb/ChangeLog
2017-10-12 Tom Tromey <tom@tromey.com>
* s390-linux-tdep.c (s390_store, s390_load)
(s390_check_for_saved, s390_analyze_prologue): Update.
* rx-tdep.c (check_for_saved, rx_analyze_prologue): Update.
* rl78-tdep.c (rl78_analyze_prologue, check_for_saved): Update.
* prologue-value.h (class pv_area): Move from prologue-value.c.
Change names of members. Add constructor, destructor, member
functions.
(make_pv_area, free_pv_area, make_cleanup_free_pv_area)
(pv_area_store, pv_area_fetch, pv_area_store_would_trash)
(pv_area_fetch, pv_area_scan): Don't declare.
* prologue-value.c (struct pv_area::area_entry): Now member of
pv_area.
(struct pv_area): Move to prologue-value.h.
(pv_area::pv_area): Rename from make_pv_area.
(pv_area::~pv_area): Rename from free_pv_area.
(do_free_pv_area_cleanup, make_cleanup_free_pv_area): Remove.
(clear_entries, find_entry, overlaps, store_would_trash, store)
(fetch, find_reg, scan): Now member of pv_area.
Remove "area" argument. Update.
* msp430-tdep.c (check_for_saved, msp430_analyze_prologue):
Update.
* mn10300-tdep.c (push_reg, check_for_saved)
(mn10300_analyze_prologue): Update.
* mep-tdep.c (is_arg_spill, check_for_saved)
(mep_analyze_prologue): Update.
* m32c-tdep.c (m32c_pv_push, m32c_srcdest_fetch)
(m32c_srcdest_store, m32c_pv_enter, m32c_is_arg_spill)
(m32c_is_struct_return, m32c_analyze_prologue): Update.
* arm-tdep.c (thumb_analyze_prologue, arm_analyze_prologue):
Update.
* arc-tdep.c (arc_is_in_prologue, arc_analyze_prologue): Update.
* aarch64-tdep.c (aarch64_analyze_prologue): Update.
2017-10-08 08:23:36 +08:00
|
|
|
stack->store (addr, ARC_REGISTER_SIZE, store_value1);
|
|
|
|
stack->store (pv_add_constant (addr, ARC_REGISTER_SIZE),
|
|
|
|
ARC_REGISTER_SIZE, store_value2);
|
2017-02-10 19:12:09 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pv_t store_value
|
|
|
|
= pv_constant (arc_insn_get_operand_value (insn, 0));
|
C++-ify prologue-value's pv_area
This patch is an initial C++-ification of pv_area, from
prologue-value. It turns pv_area into a class with a constructor and
destructor; renames the data members; and changes various functions to
be member functions. This allows the removal of
make_cleanup_free_pv_area.
gdb/ChangeLog
2017-10-12 Tom Tromey <tom@tromey.com>
* s390-linux-tdep.c (s390_store, s390_load)
(s390_check_for_saved, s390_analyze_prologue): Update.
* rx-tdep.c (check_for_saved, rx_analyze_prologue): Update.
* rl78-tdep.c (rl78_analyze_prologue, check_for_saved): Update.
* prologue-value.h (class pv_area): Move from prologue-value.c.
Change names of members. Add constructor, destructor, member
functions.
(make_pv_area, free_pv_area, make_cleanup_free_pv_area)
(pv_area_store, pv_area_fetch, pv_area_store_would_trash)
(pv_area_fetch, pv_area_scan): Don't declare.
* prologue-value.c (struct pv_area::area_entry): Now member of
pv_area.
(struct pv_area): Move to prologue-value.h.
(pv_area::pv_area): Rename from make_pv_area.
(pv_area::~pv_area): Rename from free_pv_area.
(do_free_pv_area_cleanup, make_cleanup_free_pv_area): Remove.
(clear_entries, find_entry, overlaps, store_would_trash, store)
(fetch, find_reg, scan): Now member of pv_area.
Remove "area" argument. Update.
* msp430-tdep.c (check_for_saved, msp430_analyze_prologue):
Update.
* mn10300-tdep.c (push_reg, check_for_saved)
(mn10300_analyze_prologue): Update.
* mep-tdep.c (is_arg_spill, check_for_saved)
(mep_analyze_prologue): Update.
* m32c-tdep.c (m32c_pv_push, m32c_srcdest_fetch)
(m32c_srcdest_store, m32c_pv_enter, m32c_is_arg_spill)
(m32c_is_struct_return, m32c_analyze_prologue): Update.
* arm-tdep.c (thumb_analyze_prologue, arm_analyze_prologue):
Update.
* arc-tdep.c (arc_is_in_prologue, arc_analyze_prologue): Update.
* aarch64-tdep.c (aarch64_analyze_prologue): Update.
2017-10-08 08:23:36 +08:00
|
|
|
stack->store (addr, ARC_REGISTER_SIZE * 2, store_value);
|
2017-02-10 19:12:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Is base register updated? */
|
|
|
|
if (insn.writeback_mode == ARC_WRITEBACK_A
|
|
|
|
|| insn.writeback_mode == ARC_WRITEBACK_AB)
|
|
|
|
regs[base_reg] = pv_add_constant (regs[base_reg],
|
|
|
|
arc_insn_get_memory_offset (insn));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (insn.insn_class == MOVE)
|
|
|
|
{
|
|
|
|
gdb_assert (insn.operands_count == 2);
|
|
|
|
|
|
|
|
/* Destination argument can be "0", so nothing will happen. */
|
|
|
|
if (insn.operands[0].kind == ARC_OPERAND_KIND_REG)
|
|
|
|
{
|
|
|
|
int dst_regnum = insn.operands[0].value;
|
|
|
|
regs[dst_regnum] = arc_pv_get_operand (regs, insn, 1);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (insn.insn_class == SUB)
|
|
|
|
{
|
|
|
|
gdb_assert (insn.operands_count == 3);
|
|
|
|
|
|
|
|
/* SUB 0,b,c. */
|
|
|
|
if (insn.operands[0].kind != ARC_OPERAND_KIND_REG)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
int dst_regnum = insn.operands[0].value;
|
|
|
|
regs[dst_regnum] = pv_subtract (arc_pv_get_operand (regs, insn, 1),
|
|
|
|
arc_pv_get_operand (regs, insn, 2));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (insn.insn_class == ENTER)
|
|
|
|
{
|
|
|
|
/* ENTER_S is a prologue-in-instruction - it saves all callee-saved
|
|
|
|
registers according to given arguments thus greatly reducing code
|
|
|
|
size. Which registers will be actually saved depends on arguments.
|
|
|
|
|
|
|
|
ENTER_S {R13-...,FP,BLINK} stores registers in following order:
|
|
|
|
|
|
|
|
new SP ->
|
|
|
|
BLINK
|
|
|
|
R13
|
|
|
|
R14
|
|
|
|
R15
|
|
|
|
...
|
|
|
|
FP
|
|
|
|
old SP ->
|
|
|
|
|
|
|
|
There are up to three arguments for this opcode, as presented by ARC
|
|
|
|
disassembler:
|
|
|
|
1) amount of general-purpose registers to be saved - this argument is
|
|
|
|
always present even when it is 0;
|
|
|
|
2) FP register number (27) if FP has to be stored, otherwise argument
|
|
|
|
is not present;
|
|
|
|
3) BLINK register number (31) if BLINK has to be stored, otherwise
|
|
|
|
argument is not present. If both FP and BLINK are stored, then FP
|
|
|
|
is present before BLINK in argument list. */
|
|
|
|
gdb_assert (insn.operands_count > 0);
|
|
|
|
|
|
|
|
int regs_saved = arc_insn_get_operand_value (insn, 0);
|
|
|
|
|
|
|
|
bool is_fp_saved;
|
|
|
|
if (insn.operands_count > 1)
|
|
|
|
is_fp_saved = (insn.operands[1].value == ARC_FP_REGNUM);
|
|
|
|
else
|
|
|
|
is_fp_saved = false;
|
|
|
|
|
|
|
|
bool is_blink_saved;
|
|
|
|
if (insn.operands_count > 1)
|
|
|
|
is_blink_saved = (insn.operands[insn.operands_count - 1].value
|
|
|
|
== ARC_BLINK_REGNUM);
|
|
|
|
else
|
|
|
|
is_blink_saved = false;
|
|
|
|
|
|
|
|
/* Amount of bytes to be allocated to store specified registers. */
|
|
|
|
CORE_ADDR st_size = ((regs_saved + is_fp_saved + is_blink_saved)
|
|
|
|
* ARC_REGISTER_SIZE);
|
|
|
|
pv_t new_sp = pv_add_constant (regs[ARC_SP_REGNUM], -st_size);
|
|
|
|
|
|
|
|
/* Assume that if the last register (closest to new SP) can be written,
|
|
|
|
then it is possible to write all of them. */
|
C++-ify prologue-value's pv_area
This patch is an initial C++-ification of pv_area, from
prologue-value. It turns pv_area into a class with a constructor and
destructor; renames the data members; and changes various functions to
be member functions. This allows the removal of
make_cleanup_free_pv_area.
gdb/ChangeLog
2017-10-12 Tom Tromey <tom@tromey.com>
* s390-linux-tdep.c (s390_store, s390_load)
(s390_check_for_saved, s390_analyze_prologue): Update.
* rx-tdep.c (check_for_saved, rx_analyze_prologue): Update.
* rl78-tdep.c (rl78_analyze_prologue, check_for_saved): Update.
* prologue-value.h (class pv_area): Move from prologue-value.c.
Change names of members. Add constructor, destructor, member
functions.
(make_pv_area, free_pv_area, make_cleanup_free_pv_area)
(pv_area_store, pv_area_fetch, pv_area_store_would_trash)
(pv_area_fetch, pv_area_scan): Don't declare.
* prologue-value.c (struct pv_area::area_entry): Now member of
pv_area.
(struct pv_area): Move to prologue-value.h.
(pv_area::pv_area): Rename from make_pv_area.
(pv_area::~pv_area): Rename from free_pv_area.
(do_free_pv_area_cleanup, make_cleanup_free_pv_area): Remove.
(clear_entries, find_entry, overlaps, store_would_trash, store)
(fetch, find_reg, scan): Now member of pv_area.
Remove "area" argument. Update.
* msp430-tdep.c (check_for_saved, msp430_analyze_prologue):
Update.
* mn10300-tdep.c (push_reg, check_for_saved)
(mn10300_analyze_prologue): Update.
* mep-tdep.c (is_arg_spill, check_for_saved)
(mep_analyze_prologue): Update.
* m32c-tdep.c (m32c_pv_push, m32c_srcdest_fetch)
(m32c_srcdest_store, m32c_pv_enter, m32c_is_arg_spill)
(m32c_is_struct_return, m32c_analyze_prologue): Update.
* arm-tdep.c (thumb_analyze_prologue, arm_analyze_prologue):
Update.
* arc-tdep.c (arc_is_in_prologue, arc_analyze_prologue): Update.
* aarch64-tdep.c (aarch64_analyze_prologue): Update.
2017-10-08 08:23:36 +08:00
|
|
|
if (stack->store_would_trash (new_sp))
|
2017-02-10 19:12:09 +08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
/* Current store address. */
|
|
|
|
pv_t addr = regs[ARC_SP_REGNUM];
|
|
|
|
|
|
|
|
if (is_fp_saved)
|
|
|
|
{
|
|
|
|
addr = pv_add_constant (addr, -ARC_REGISTER_SIZE);
|
C++-ify prologue-value's pv_area
This patch is an initial C++-ification of pv_area, from
prologue-value. It turns pv_area into a class with a constructor and
destructor; renames the data members; and changes various functions to
be member functions. This allows the removal of
make_cleanup_free_pv_area.
gdb/ChangeLog
2017-10-12 Tom Tromey <tom@tromey.com>
* s390-linux-tdep.c (s390_store, s390_load)
(s390_check_for_saved, s390_analyze_prologue): Update.
* rx-tdep.c (check_for_saved, rx_analyze_prologue): Update.
* rl78-tdep.c (rl78_analyze_prologue, check_for_saved): Update.
* prologue-value.h (class pv_area): Move from prologue-value.c.
Change names of members. Add constructor, destructor, member
functions.
(make_pv_area, free_pv_area, make_cleanup_free_pv_area)
(pv_area_store, pv_area_fetch, pv_area_store_would_trash)
(pv_area_fetch, pv_area_scan): Don't declare.
* prologue-value.c (struct pv_area::area_entry): Now member of
pv_area.
(struct pv_area): Move to prologue-value.h.
(pv_area::pv_area): Rename from make_pv_area.
(pv_area::~pv_area): Rename from free_pv_area.
(do_free_pv_area_cleanup, make_cleanup_free_pv_area): Remove.
(clear_entries, find_entry, overlaps, store_would_trash, store)
(fetch, find_reg, scan): Now member of pv_area.
Remove "area" argument. Update.
* msp430-tdep.c (check_for_saved, msp430_analyze_prologue):
Update.
* mn10300-tdep.c (push_reg, check_for_saved)
(mn10300_analyze_prologue): Update.
* mep-tdep.c (is_arg_spill, check_for_saved)
(mep_analyze_prologue): Update.
* m32c-tdep.c (m32c_pv_push, m32c_srcdest_fetch)
(m32c_srcdest_store, m32c_pv_enter, m32c_is_arg_spill)
(m32c_is_struct_return, m32c_analyze_prologue): Update.
* arm-tdep.c (thumb_analyze_prologue, arm_analyze_prologue):
Update.
* arc-tdep.c (arc_is_in_prologue, arc_analyze_prologue): Update.
* aarch64-tdep.c (aarch64_analyze_prologue): Update.
2017-10-08 08:23:36 +08:00
|
|
|
stack->store (addr, ARC_REGISTER_SIZE, regs[ARC_FP_REGNUM]);
|
2017-02-10 19:12:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Registers are stored in backward order: from GP (R26) to R13. */
|
|
|
|
for (int i = ARC_R13_REGNUM + regs_saved - 1; i >= ARC_R13_REGNUM; i--)
|
|
|
|
{
|
|
|
|
addr = pv_add_constant (addr, -ARC_REGISTER_SIZE);
|
C++-ify prologue-value's pv_area
This patch is an initial C++-ification of pv_area, from
prologue-value. It turns pv_area into a class with a constructor and
destructor; renames the data members; and changes various functions to
be member functions. This allows the removal of
make_cleanup_free_pv_area.
gdb/ChangeLog
2017-10-12 Tom Tromey <tom@tromey.com>
* s390-linux-tdep.c (s390_store, s390_load)
(s390_check_for_saved, s390_analyze_prologue): Update.
* rx-tdep.c (check_for_saved, rx_analyze_prologue): Update.
* rl78-tdep.c (rl78_analyze_prologue, check_for_saved): Update.
* prologue-value.h (class pv_area): Move from prologue-value.c.
Change names of members. Add constructor, destructor, member
functions.
(make_pv_area, free_pv_area, make_cleanup_free_pv_area)
(pv_area_store, pv_area_fetch, pv_area_store_would_trash)
(pv_area_fetch, pv_area_scan): Don't declare.
* prologue-value.c (struct pv_area::area_entry): Now member of
pv_area.
(struct pv_area): Move to prologue-value.h.
(pv_area::pv_area): Rename from make_pv_area.
(pv_area::~pv_area): Rename from free_pv_area.
(do_free_pv_area_cleanup, make_cleanup_free_pv_area): Remove.
(clear_entries, find_entry, overlaps, store_would_trash, store)
(fetch, find_reg, scan): Now member of pv_area.
Remove "area" argument. Update.
* msp430-tdep.c (check_for_saved, msp430_analyze_prologue):
Update.
* mn10300-tdep.c (push_reg, check_for_saved)
(mn10300_analyze_prologue): Update.
* mep-tdep.c (is_arg_spill, check_for_saved)
(mep_analyze_prologue): Update.
* m32c-tdep.c (m32c_pv_push, m32c_srcdest_fetch)
(m32c_srcdest_store, m32c_pv_enter, m32c_is_arg_spill)
(m32c_is_struct_return, m32c_analyze_prologue): Update.
* arm-tdep.c (thumb_analyze_prologue, arm_analyze_prologue):
Update.
* arc-tdep.c (arc_is_in_prologue, arc_analyze_prologue): Update.
* aarch64-tdep.c (aarch64_analyze_prologue): Update.
2017-10-08 08:23:36 +08:00
|
|
|
stack->store (addr, ARC_REGISTER_SIZE, regs[i]);
|
2017-02-10 19:12:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (is_blink_saved)
|
|
|
|
{
|
|
|
|
addr = pv_add_constant (addr, -ARC_REGISTER_SIZE);
|
C++-ify prologue-value's pv_area
This patch is an initial C++-ification of pv_area, from
prologue-value. It turns pv_area into a class with a constructor and
destructor; renames the data members; and changes various functions to
be member functions. This allows the removal of
make_cleanup_free_pv_area.
gdb/ChangeLog
2017-10-12 Tom Tromey <tom@tromey.com>
* s390-linux-tdep.c (s390_store, s390_load)
(s390_check_for_saved, s390_analyze_prologue): Update.
* rx-tdep.c (check_for_saved, rx_analyze_prologue): Update.
* rl78-tdep.c (rl78_analyze_prologue, check_for_saved): Update.
* prologue-value.h (class pv_area): Move from prologue-value.c.
Change names of members. Add constructor, destructor, member
functions.
(make_pv_area, free_pv_area, make_cleanup_free_pv_area)
(pv_area_store, pv_area_fetch, pv_area_store_would_trash)
(pv_area_fetch, pv_area_scan): Don't declare.
* prologue-value.c (struct pv_area::area_entry): Now member of
pv_area.
(struct pv_area): Move to prologue-value.h.
(pv_area::pv_area): Rename from make_pv_area.
(pv_area::~pv_area): Rename from free_pv_area.
(do_free_pv_area_cleanup, make_cleanup_free_pv_area): Remove.
(clear_entries, find_entry, overlaps, store_would_trash, store)
(fetch, find_reg, scan): Now member of pv_area.
Remove "area" argument. Update.
* msp430-tdep.c (check_for_saved, msp430_analyze_prologue):
Update.
* mn10300-tdep.c (push_reg, check_for_saved)
(mn10300_analyze_prologue): Update.
* mep-tdep.c (is_arg_spill, check_for_saved)
(mep_analyze_prologue): Update.
* m32c-tdep.c (m32c_pv_push, m32c_srcdest_fetch)
(m32c_srcdest_store, m32c_pv_enter, m32c_is_arg_spill)
(m32c_is_struct_return, m32c_analyze_prologue): Update.
* arm-tdep.c (thumb_analyze_prologue, arm_analyze_prologue):
Update.
* arc-tdep.c (arc_is_in_prologue, arc_analyze_prologue): Update.
* aarch64-tdep.c (aarch64_analyze_prologue): Update.
2017-10-08 08:23:36 +08:00
|
|
|
stack->store (addr, ARC_REGISTER_SIZE,
|
|
|
|
regs[ARC_BLINK_REGNUM]);
|
2017-02-10 19:12:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gdb_assert (pv_is_identical (addr, new_sp));
|
|
|
|
|
|
|
|
regs[ARC_SP_REGNUM] = new_sp;
|
|
|
|
|
|
|
|
if (is_fp_saved)
|
|
|
|
regs[ARC_FP_REGNUM] = regs[ARC_SP_REGNUM];
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Some other architectures, like nds32 or arm, try to continue as far as
|
|
|
|
possible when building a prologue cache (as opposed to when skipping
|
|
|
|
prologue), so that cache will be as full as possible. However current
|
|
|
|
code for ARC doesn't recognize some instructions that may modify SP, like
|
|
|
|
ADD, AND, OR, etc, hence there is no way to guarantee that SP wasn't
|
|
|
|
clobbered by the skipped instruction. Potential existence of extension
|
|
|
|
instruction, which may do anything they want makes this even more complex,
|
|
|
|
so it is just better to halt on a first unrecognized instruction. */
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Analyze the prologue and update the corresponding frame cache for the frame
|
|
|
|
unwinder for unwinding frames that doesn't have debug info. In such
|
|
|
|
situation GDB attempts to parse instructions in the prologue to understand
|
|
|
|
where each register is saved.
|
|
|
|
|
|
|
|
If CACHE is not NULL, then it will be filled with information about saved
|
|
|
|
registers.
|
|
|
|
|
2019-10-18 08:48:08 +08:00
|
|
|
There are several variations of prologue which GDB may encounter. "Full"
|
2017-02-10 19:12:09 +08:00
|
|
|
prologue looks like this:
|
|
|
|
|
|
|
|
sub sp,sp,<imm> ; Space for variadic arguments.
|
|
|
|
push blink ; Store return address.
|
|
|
|
push r13 ; Store callee saved registers (up to R26/GP).
|
|
|
|
push r14
|
|
|
|
push fp ; Store frame pointer.
|
|
|
|
mov fp,sp ; Update frame pointer.
|
|
|
|
sub sp,sp,<imm> ; Create space for local vars on the stack.
|
|
|
|
|
|
|
|
Depending on compiler options lots of things may change:
|
|
|
|
|
|
|
|
1) BLINK is not saved in leaf functions.
|
|
|
|
2) Frame pointer is not saved and updated if -fomit-frame-pointer is used.
|
|
|
|
3) 16-bit versions of those instructions may be used.
|
|
|
|
4) Instead of a sequence of several push'es, compiler may instead prefer to
|
|
|
|
do one subtract on stack pointer and then store registers using normal
|
|
|
|
store, that doesn't update SP. Like this:
|
|
|
|
|
|
|
|
|
2019-10-18 08:48:08 +08:00
|
|
|
sub sp,sp,8 ; Create space for callee-saved registers.
|
2017-02-10 19:12:09 +08:00
|
|
|
st r13,[sp,4] ; Store callee saved registers (up to R26/GP).
|
|
|
|
st r14,[sp,0]
|
|
|
|
|
|
|
|
5) ENTER_S instruction can encode most of prologue sequence in one
|
|
|
|
instruction (except for those subtracts for variadic arguments and local
|
|
|
|
variables).
|
|
|
|
6) GCC may use "millicode" functions from libgcc to store callee-saved
|
|
|
|
registers with minimal code-size requirements. This function currently
|
|
|
|
doesn't support this.
|
|
|
|
|
|
|
|
ENTRYPOINT is a function entry point where prologue starts.
|
|
|
|
|
|
|
|
LIMIT_PC is a maximum possible end address of prologue (meaning address
|
|
|
|
of first instruction after the prologue). It might also point to the middle
|
|
|
|
of prologue if execution has been stopped by the breakpoint at this address
|
|
|
|
- in this case debugger should analyze prologue only up to this address,
|
|
|
|
because further instructions haven't been executed yet.
|
|
|
|
|
|
|
|
Returns address of the first instruction after the prologue. */
|
|
|
|
|
|
|
|
static CORE_ADDR
|
|
|
|
arc_analyze_prologue (struct gdbarch *gdbarch, const CORE_ADDR entrypoint,
|
|
|
|
const CORE_ADDR limit_pc, struct arc_frame_cache *cache)
|
|
|
|
{
|
2021-01-14 03:32:39 +08:00
|
|
|
arc_debug_printf ("entrypoint=%s, limit_pc=%s",
|
|
|
|
paddress (gdbarch, entrypoint),
|
|
|
|
paddress (gdbarch, limit_pc));
|
2017-02-10 19:12:09 +08:00
|
|
|
|
|
|
|
/* Prologue values. Only core registers can be stored. */
|
|
|
|
pv_t regs[ARC_LAST_CORE_REGNUM + 1];
|
|
|
|
for (int i = 0; i <= ARC_LAST_CORE_REGNUM; i++)
|
|
|
|
regs[i] = pv_register (i, 0);
|
C++-ify prologue-value's pv_area
This patch is an initial C++-ification of pv_area, from
prologue-value. It turns pv_area into a class with a constructor and
destructor; renames the data members; and changes various functions to
be member functions. This allows the removal of
make_cleanup_free_pv_area.
gdb/ChangeLog
2017-10-12 Tom Tromey <tom@tromey.com>
* s390-linux-tdep.c (s390_store, s390_load)
(s390_check_for_saved, s390_analyze_prologue): Update.
* rx-tdep.c (check_for_saved, rx_analyze_prologue): Update.
* rl78-tdep.c (rl78_analyze_prologue, check_for_saved): Update.
* prologue-value.h (class pv_area): Move from prologue-value.c.
Change names of members. Add constructor, destructor, member
functions.
(make_pv_area, free_pv_area, make_cleanup_free_pv_area)
(pv_area_store, pv_area_fetch, pv_area_store_would_trash)
(pv_area_fetch, pv_area_scan): Don't declare.
* prologue-value.c (struct pv_area::area_entry): Now member of
pv_area.
(struct pv_area): Move to prologue-value.h.
(pv_area::pv_area): Rename from make_pv_area.
(pv_area::~pv_area): Rename from free_pv_area.
(do_free_pv_area_cleanup, make_cleanup_free_pv_area): Remove.
(clear_entries, find_entry, overlaps, store_would_trash, store)
(fetch, find_reg, scan): Now member of pv_area.
Remove "area" argument. Update.
* msp430-tdep.c (check_for_saved, msp430_analyze_prologue):
Update.
* mn10300-tdep.c (push_reg, check_for_saved)
(mn10300_analyze_prologue): Update.
* mep-tdep.c (is_arg_spill, check_for_saved)
(mep_analyze_prologue): Update.
* m32c-tdep.c (m32c_pv_push, m32c_srcdest_fetch)
(m32c_srcdest_store, m32c_pv_enter, m32c_is_arg_spill)
(m32c_is_struct_return, m32c_analyze_prologue): Update.
* arm-tdep.c (thumb_analyze_prologue, arm_analyze_prologue):
Update.
* arc-tdep.c (arc_is_in_prologue, arc_analyze_prologue): Update.
* aarch64-tdep.c (aarch64_analyze_prologue): Update.
2017-10-08 08:23:36 +08:00
|
|
|
pv_area stack (ARC_SP_REGNUM, gdbarch_addr_bit (gdbarch));
|
2017-02-10 19:12:09 +08:00
|
|
|
|
|
|
|
CORE_ADDR current_prologue_end = entrypoint;
|
|
|
|
|
|
|
|
/* Look at each instruction in the prologue. */
|
|
|
|
while (current_prologue_end < limit_pc)
|
|
|
|
{
|
|
|
|
struct arc_instruction insn;
|
gdb: refactor the non-printing disassemblers
This commit started from an observation I made while working on some
other disassembler patches, that is, that the function
gdb_buffered_insn_length, is broken ... sort of.
I noticed that the gdb_buffered_insn_length function doesn't set up
the application data field if the disassemble_info structure.
Further, I noticed that some architectures, for example, ARM, require
that the application_data field be set, see gdb_print_insn_arm in
arm-tdep.c.
And so, if we ever use gdb_buffered_insn_length for ARM, then GDB will
likely crash. Which is why I said only "sort of" broken. Right now
we don't use gdb_buffered_insn_length with ARM, so maybe it isn't
broken yet?
Anyway to prove to myself that there was a problem here I extended the
disassembler self tests in disasm-selftests.c to include a test of
gdb_buffered_insn_length. As I run the test for all architectures, I
do indeed see GDB crash for ARM.
To fix this we need gdb_buffered_insn_length to create a disassembler
that inherits from gdb_disassemble_info, but we also need this new
disassembler to not print anything.
And so, I introduce a new gdb_non_printing_disassembler class, this is
a disassembler that doesn't print anything to the output stream.
I then observed that both ARC and S12Z also create non-printing
disassemblers, but these are slightly different. While the
disassembler in gdb_non_printing_disassembler reads the instruction
from a buffer, the ARC and S12Z disassemblers read from target memory
using target_read_code.
And so, I further split gdb_non_printing_disassembler into two
sub-classes, gdb_non_printing_memory_disassembler and
gdb_non_printing_buffer_disassembler.
The new selftests now pass, but otherwise, there should be no user
visible changes after this commit.
2022-04-04 22:48:19 +08:00
|
|
|
|
|
|
|
struct gdb_non_printing_memory_disassembler dis (gdbarch);
|
|
|
|
arc_insn_decode (current_prologue_end, dis.disasm_info (),
|
|
|
|
arc_delayed_print_insn, &insn);
|
2017-02-10 19:12:09 +08:00
|
|
|
|
2021-01-14 03:32:23 +08:00
|
|
|
if (arc_debug)
|
2017-02-10 19:12:09 +08:00
|
|
|
arc_insn_dump (insn);
|
|
|
|
|
|
|
|
/* If this instruction is in the prologue, fields in the cache will be
|
|
|
|
updated, and the saved registers mask may be updated. */
|
C++-ify prologue-value's pv_area
This patch is an initial C++-ification of pv_area, from
prologue-value. It turns pv_area into a class with a constructor and
destructor; renames the data members; and changes various functions to
be member functions. This allows the removal of
make_cleanup_free_pv_area.
gdb/ChangeLog
2017-10-12 Tom Tromey <tom@tromey.com>
* s390-linux-tdep.c (s390_store, s390_load)
(s390_check_for_saved, s390_analyze_prologue): Update.
* rx-tdep.c (check_for_saved, rx_analyze_prologue): Update.
* rl78-tdep.c (rl78_analyze_prologue, check_for_saved): Update.
* prologue-value.h (class pv_area): Move from prologue-value.c.
Change names of members. Add constructor, destructor, member
functions.
(make_pv_area, free_pv_area, make_cleanup_free_pv_area)
(pv_area_store, pv_area_fetch, pv_area_store_would_trash)
(pv_area_fetch, pv_area_scan): Don't declare.
* prologue-value.c (struct pv_area::area_entry): Now member of
pv_area.
(struct pv_area): Move to prologue-value.h.
(pv_area::pv_area): Rename from make_pv_area.
(pv_area::~pv_area): Rename from free_pv_area.
(do_free_pv_area_cleanup, make_cleanup_free_pv_area): Remove.
(clear_entries, find_entry, overlaps, store_would_trash, store)
(fetch, find_reg, scan): Now member of pv_area.
Remove "area" argument. Update.
* msp430-tdep.c (check_for_saved, msp430_analyze_prologue):
Update.
* mn10300-tdep.c (push_reg, check_for_saved)
(mn10300_analyze_prologue): Update.
* mep-tdep.c (is_arg_spill, check_for_saved)
(mep_analyze_prologue): Update.
* m32c-tdep.c (m32c_pv_push, m32c_srcdest_fetch)
(m32c_srcdest_store, m32c_pv_enter, m32c_is_arg_spill)
(m32c_is_struct_return, m32c_analyze_prologue): Update.
* arm-tdep.c (thumb_analyze_prologue, arm_analyze_prologue):
Update.
* arc-tdep.c (arc_is_in_prologue, arc_analyze_prologue): Update.
* aarch64-tdep.c (aarch64_analyze_prologue): Update.
2017-10-08 08:23:36 +08:00
|
|
|
if (!arc_is_in_prologue (gdbarch, insn, regs, &stack))
|
2017-02-10 19:12:09 +08:00
|
|
|
{
|
|
|
|
/* Found an instruction that is not in the prologue. */
|
2021-01-14 03:32:39 +08:00
|
|
|
arc_debug_printf ("End of prologue reached at address %s",
|
|
|
|
paddress (gdbarch, insn.address));
|
2017-02-10 19:12:09 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
current_prologue_end = arc_insn_get_linear_next_pc (insn);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cache != NULL)
|
|
|
|
{
|
|
|
|
/* Figure out if it is a frame pointer or just a stack pointer. */
|
|
|
|
if (pv_is_register (regs[ARC_FP_REGNUM], ARC_SP_REGNUM))
|
|
|
|
{
|
|
|
|
cache->frame_base_reg = ARC_FP_REGNUM;
|
|
|
|
cache->frame_base_offset = -regs[ARC_FP_REGNUM].k;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cache->frame_base_reg = ARC_SP_REGNUM;
|
|
|
|
cache->frame_base_offset = -regs[ARC_SP_REGNUM].k;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Assign offset from old SP to all saved registers. */
|
|
|
|
for (int i = 0; i <= ARC_LAST_CORE_REGNUM; i++)
|
|
|
|
{
|
|
|
|
CORE_ADDR offset;
|
C++-ify prologue-value's pv_area
This patch is an initial C++-ification of pv_area, from
prologue-value. It turns pv_area into a class with a constructor and
destructor; renames the data members; and changes various functions to
be member functions. This allows the removal of
make_cleanup_free_pv_area.
gdb/ChangeLog
2017-10-12 Tom Tromey <tom@tromey.com>
* s390-linux-tdep.c (s390_store, s390_load)
(s390_check_for_saved, s390_analyze_prologue): Update.
* rx-tdep.c (check_for_saved, rx_analyze_prologue): Update.
* rl78-tdep.c (rl78_analyze_prologue, check_for_saved): Update.
* prologue-value.h (class pv_area): Move from prologue-value.c.
Change names of members. Add constructor, destructor, member
functions.
(make_pv_area, free_pv_area, make_cleanup_free_pv_area)
(pv_area_store, pv_area_fetch, pv_area_store_would_trash)
(pv_area_fetch, pv_area_scan): Don't declare.
* prologue-value.c (struct pv_area::area_entry): Now member of
pv_area.
(struct pv_area): Move to prologue-value.h.
(pv_area::pv_area): Rename from make_pv_area.
(pv_area::~pv_area): Rename from free_pv_area.
(do_free_pv_area_cleanup, make_cleanup_free_pv_area): Remove.
(clear_entries, find_entry, overlaps, store_would_trash, store)
(fetch, find_reg, scan): Now member of pv_area.
Remove "area" argument. Update.
* msp430-tdep.c (check_for_saved, msp430_analyze_prologue):
Update.
* mn10300-tdep.c (push_reg, check_for_saved)
(mn10300_analyze_prologue): Update.
* mep-tdep.c (is_arg_spill, check_for_saved)
(mep_analyze_prologue): Update.
* m32c-tdep.c (m32c_pv_push, m32c_srcdest_fetch)
(m32c_srcdest_store, m32c_pv_enter, m32c_is_arg_spill)
(m32c_is_struct_return, m32c_analyze_prologue): Update.
* arm-tdep.c (thumb_analyze_prologue, arm_analyze_prologue):
Update.
* arc-tdep.c (arc_is_in_prologue, arc_analyze_prologue): Update.
* aarch64-tdep.c (aarch64_analyze_prologue): Update.
2017-10-08 08:23:36 +08:00
|
|
|
if (stack.find_reg (gdbarch, i, &offset))
|
Refactor struct trad_frame_saved_regs
The following patch drops the overloading going on with the trad_frame_saved_reg
struct and defines a new struct with a KIND enum and a union of different
fields.
The new struct looks like this:
struct trad_frame_saved_reg
{
setters/getters
...
private:
trad_frame_saved_reg_kind m_kind;
union {
LONGEST value;
int realreg;
LONGEST addr;
const gdb_byte *value_bytes;
} m_reg;
};
And the enums look like this:
/* Describes the kind of encoding a stored register has. */
enum class trad_frame_saved_reg_kind
{
/* Register value is unknown. */
UNKNOWN = 0,
/* Register value is a constant. */
VALUE,
/* Register value is in another register. */
REALREG,
/* Register value is at an address. */
ADDR,
/* Register value is a sequence of bytes. */
VALUE_BYTES
};
The patch also adds setters/getters and updates all the users of the old
struct.
It is worth mentioning that due to the previous overloaded nature of the
fields, some tdep files like to store negative offsets and indexes in the ADDR
field, so I kept the ADDR as LONGEST instead of CORE_ADDR. Those cases may
be better supported by a new enum entry.
I have not addressed those cases in this patch to prevent unwanted breakage,
given I have no way to test some of the targets. But it would be nice to
clean those up eventually.
The change to frame-unwind.* is to constify the parameter being passed to the
unwinding functions, given we now accept a "const gdb_byte *" for value bytes.
Tested on aarch64-linux/Ubuntu 20.04/18.04 and by building GDB with
--enable-targets=all.
gdb/ChangeLog:
2021-01-04 Luis Machado <luis.machado@linaro.org>
Update all users of trad_frame_saved_reg to use the new member
functions.
Remote all struct keywords from declarations of trad_frame_saved_reg
types, except on forward declarations.
* aarch64-tdep.c: Update.
* alpha-mdebug-tdep.c: Update.
* alpha-tdep.c: Update.
* arc-tdep.c: Update.
* arm-tdep.c: Update.
* avr-tdep.c: Update.
* cris-tdep.c: Update.
* csky-tdep.c: Update.
* frv-tdep.c: Update.
* hppa-linux-tdep.c: Update.
* hppa-tdep.c: Update.
* hppa-tdep.h: Update.
* lm32-tdep.c: Update.
* m32r-linux-tdep.c: Update.
* m32r-tdep.c: Update.
* m68hc11-tdep.c: Update.
* mips-tdep.c: Update.
* moxie-tdep.c: Update.
* riscv-tdep.c: Update.
* rs6000-tdep.c: Update.
* s390-linux-tdep.c: Update.
* s390-tdep.c: Update.
* score-tdep.c: Update.
* sparc-netbsd-tdep.c: Update.
* sparc-sol2-tdep.c: Update.
* sparc64-fbsd-tdep.c: Update.
* sparc64-netbsd-tdep.c: Update.
* sparc64-obsd-tdep.c: Update.
* sparc64-sol2-tdep.c: Update.
* tilegx-tdep.c: Update.
* v850-tdep.c: Update.
* vax-tdep.c: Update.
* frame-unwind.c (frame_unwind_got_bytes): Make parameter const.
* frame-unwind.h (frame_unwind_got_bytes): Likewise.
* trad-frame.c: Update.
Remove TF_REG_* enum.
(trad_frame_alloc_saved_regs): Add a static assertion to check for
a trivially-constructible struct.
(trad_frame_reset_saved_regs): Adjust to use member function.
(trad_frame_value_p): Likewise.
(trad_frame_addr_p): Likewise.
(trad_frame_realreg_p): Likewise.
(trad_frame_value_bytes_p): Likewise.
(trad_frame_set_value): Likewise.
(trad_frame_set_realreg): Likewise.
(trad_frame_set_addr): Likewise.
(trad_frame_set_unknown): Likewise.
(trad_frame_set_value_bytes): Likewise.
(trad_frame_get_prev_register): Likewise.
* trad-frame.h: Update.
(trad_frame_saved_reg_kind): New enum.
(struct trad_frame_saved_reg) <addr, realreg, data>: Remove.
<m_kind, m_reg>: New member fields.
<set_value, set_realreg, set_addr, set_unknown, set_value_bytes>
<kind, value, realreg, addr, value_bytes, is_value, is_realreg>
<is_addr, is_unknown, is_value_bytes>: New member functions.
2020-12-23 04:45:21 +08:00
|
|
|
cache->saved_regs[i].set_addr (offset);
|
2017-02-10 19:12:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return current_prologue_end;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Estimated maximum prologue length in bytes. This should include:
|
|
|
|
1) Store instruction for each callee-saved register (R25 - R13 + 1)
|
|
|
|
2) Two instructions for FP
|
|
|
|
3) One for BLINK
|
2024-10-06 13:59:48 +08:00
|
|
|
4) Three subtract instructions for SP (for variadic args, for
|
2017-02-10 19:12:09 +08:00
|
|
|
callee saved regs and for local vars) and assuming that those SUB use
|
|
|
|
long-immediate (hence double length).
|
|
|
|
5) Stores of arguments registers are considered part of prologue too
|
|
|
|
(R7 - R1 + 1).
|
|
|
|
This is quite an extreme case, because even with -O0 GCC will collapse first
|
|
|
|
two SUBs into one and long immediate values are quite unlikely to appear in
|
|
|
|
this case, but still better to overshoot a bit - prologue analysis will
|
|
|
|
anyway stop at the first instruction that doesn't fit prologue, so this
|
|
|
|
limit will be rarely reached. */
|
|
|
|
|
|
|
|
const static int MAX_PROLOGUE_LENGTH
|
|
|
|
= 4 * (ARC_R25_REGNUM - ARC_R13_REGNUM + 1 + 2 + 1 + 6
|
|
|
|
+ ARC_LAST_ARG_REGNUM - ARC_FIRST_ARG_REGNUM + 1);
|
|
|
|
|
2016-08-13 01:02:20 +08:00
|
|
|
/* Implement the "skip_prologue" gdbarch method.
|
|
|
|
|
|
|
|
Skip the prologue for the function at PC. This is done by checking from
|
|
|
|
the line information read from the DWARF, if possible; otherwise, we scan
|
|
|
|
the function prologue to find its end. */
|
|
|
|
|
|
|
|
static CORE_ADDR
|
|
|
|
arc_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
|
|
|
|
{
|
2017-06-28 18:15:46 +08:00
|
|
|
arc_debug_printf ("pc = %s", paddress (gdbarch, pc));
|
2016-08-13 01:02:20 +08:00
|
|
|
|
|
|
|
CORE_ADDR func_addr;
|
|
|
|
const char *func_name;
|
|
|
|
|
|
|
|
/* See what the symbol table says. */
|
|
|
|
if (find_pc_partial_function (pc, &func_name, &func_addr, NULL))
|
|
|
|
{
|
|
|
|
/* Found a function. */
|
|
|
|
CORE_ADDR postprologue_pc
|
|
|
|
= skip_prologue_using_sal (gdbarch, func_addr);
|
|
|
|
|
|
|
|
if (postprologue_pc != 0)
|
|
|
|
return std::max (pc, postprologue_pc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* No prologue info in symbol table, have to analyze prologue. */
|
|
|
|
|
|
|
|
/* Find an upper limit on the function prologue using the debug
|
2017-02-10 19:12:09 +08:00
|
|
|
information. If there is no debug information about prologue end, then
|
|
|
|
skip_prologue_using_sal will return 0. */
|
2016-08-13 01:02:20 +08:00
|
|
|
CORE_ADDR limit_pc = skip_prologue_using_sal (gdbarch, pc);
|
2017-02-10 19:12:09 +08:00
|
|
|
|
|
|
|
/* If there is no debug information at all, it is required to give some
|
|
|
|
semi-arbitrary hard limit on amount of bytes to scan during prologue
|
|
|
|
analysis. */
|
|
|
|
if (limit_pc == 0)
|
|
|
|
limit_pc = pc + MAX_PROLOGUE_LENGTH;
|
|
|
|
|
|
|
|
/* Find the address of the first instruction after the prologue by scanning
|
|
|
|
through it - no other information is needed, so pass NULL as a cache. */
|
|
|
|
return arc_analyze_prologue (gdbarch, pc, limit_pc, NULL);
|
2016-08-13 01:02:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Implement the "print_insn" gdbarch method.
|
|
|
|
|
|
|
|
arc_get_disassembler () may return different functions depending on bfd
|
|
|
|
type, so it is not possible to pass print_insn directly to
|
|
|
|
set_gdbarch_print_insn (). Instead this wrapper function is used. It also
|
|
|
|
may be used by other functions to get disassemble_info for address. It is
|
|
|
|
important to note, that those print_insn from opcodes always print
|
|
|
|
instruction to the stream specified in the INFO. If this is not desired,
|
|
|
|
then either `print_insn` function in INFO should be set to some function
|
|
|
|
that will not print, or `stream` should be different from standard
|
|
|
|
gdb_stdlog. */
|
|
|
|
|
2017-02-10 19:12:06 +08:00
|
|
|
int
|
2016-08-13 01:02:20 +08:00
|
|
|
arc_delayed_print_insn (bfd_vma addr, struct disassemble_info *info)
|
|
|
|
{
|
2019-10-18 08:48:08 +08:00
|
|
|
/* Standard BFD "machine number" field allows libopcodes disassembler to
|
2017-02-10 19:11:55 +08:00
|
|
|
distinguish ARC 600, 700 and v2 cores, however v2 encompasses both ARC EM
|
|
|
|
and HS, which have some difference between. There are two ways to specify
|
|
|
|
what is the target core:
|
|
|
|
1) via the disassemble_info->disassembler_options;
|
|
|
|
2) otherwise libopcodes will use private (architecture-specific) ELF
|
|
|
|
header.
|
|
|
|
|
|
|
|
Using disassembler_options is preferable, because it comes directly from
|
|
|
|
GDBserver which scanned an actual ARC core identification info. However,
|
|
|
|
not all GDBservers report core architecture, so as a fallback GDB still
|
|
|
|
should support analysis of ELF header. The libopcodes disassembly code
|
|
|
|
uses the section to find the BFD and the BFD to find the ELF header,
|
|
|
|
therefore this function should set disassemble_info->section properly.
|
|
|
|
|
|
|
|
disassembler_options was already set by non-target specific code with
|
|
|
|
proper options obtained via gdbarch_disassembler_options ().
|
|
|
|
|
|
|
|
This function might be called multiple times in a sequence, reusing same
|
|
|
|
disassemble_info. */
|
|
|
|
if ((info->disassembler_options == NULL) && (info->section == NULL))
|
|
|
|
{
|
|
|
|
struct obj_section *s = find_pc_section (addr);
|
|
|
|
if (s != NULL)
|
|
|
|
info->section = s->the_bfd_section;
|
|
|
|
}
|
|
|
|
|
|
|
|
return default_print_insn (addr, info);
|
2016-08-13 01:02:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Baremetal breakpoint instructions.
|
|
|
|
|
|
|
|
ARC supports both big- and little-endian. However, instructions for
|
|
|
|
little-endian processors are encoded in the middle-endian: half-words are
|
|
|
|
in big-endian, while bytes inside the half-words are in little-endian; data
|
|
|
|
is represented in the "normal" little-endian. Big-endian processors treat
|
|
|
|
data and code identically.
|
|
|
|
|
|
|
|
Assuming the number 0x01020304, it will be presented this way:
|
|
|
|
|
|
|
|
Address : N N+1 N+2 N+3
|
|
|
|
little-endian : 0x04 0x03 0x02 0x01
|
|
|
|
big-endian : 0x01 0x02 0x03 0x04
|
|
|
|
ARC middle-endian : 0x02 0x01 0x04 0x03
|
|
|
|
*/
|
|
|
|
|
|
|
|
static const gdb_byte arc_brk_s_be[] = { 0x7f, 0xff };
|
|
|
|
static const gdb_byte arc_brk_s_le[] = { 0xff, 0x7f };
|
|
|
|
static const gdb_byte arc_brk_be[] = { 0x25, 0x6f, 0x00, 0x3f };
|
|
|
|
static const gdb_byte arc_brk_le[] = { 0x6f, 0x25, 0x3f, 0x00 };
|
|
|
|
|
2016-11-03 22:35:13 +08:00
|
|
|
/* For ARC ELF, breakpoint uses the 16-bit BRK_S instruction, which is 0x7fff
|
2016-08-13 01:02:20 +08:00
|
|
|
(little endian) or 0xff7f (big endian). We used to insert BRK_S even
|
|
|
|
instead of 32-bit instructions, which works mostly ok, unless breakpoint is
|
|
|
|
inserted into delay slot instruction. In this case if branch is taken
|
|
|
|
BLINK value will be set to address of instruction after delay slot, however
|
|
|
|
if we replaced 32-bit instruction in delay slot with 16-bit long BRK_S,
|
|
|
|
then BLINK value will have an invalid value - it will point to the address
|
|
|
|
after the BRK_S (which was there at the moment of branch execution) while
|
|
|
|
it should point to the address after the 32-bit long instruction. To avoid
|
|
|
|
such issues this function disassembles instruction at target location and
|
|
|
|
evaluates it value.
|
|
|
|
|
|
|
|
ARC 600 supports only 16-bit BRK_S.
|
|
|
|
|
|
|
|
NB: Baremetal GDB uses BRK[_S], while user-space GDB uses TRAP_S. BRK[_S]
|
|
|
|
is much better because it doesn't commit unlike TRAP_S, so it can be set in
|
|
|
|
delay slots; however it cannot be used in user-mode, hence usage of TRAP_S
|
2016-11-03 22:35:13 +08:00
|
|
|
in GDB for user-space. */
|
2016-08-13 01:02:20 +08:00
|
|
|
|
2016-11-03 22:35:13 +08:00
|
|
|
/* Implement the "breakpoint_kind_from_pc" gdbarch method. */
|
2016-08-13 01:02:20 +08:00
|
|
|
|
2016-11-03 22:35:13 +08:00
|
|
|
static int
|
|
|
|
arc_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
|
2016-08-13 01:02:20 +08:00
|
|
|
{
|
|
|
|
size_t length_with_limm = gdb_insn_length (gdbarch, *pcptr);
|
|
|
|
|
|
|
|
/* Replace 16-bit instruction with BRK_S, replace 32-bit instructions with
|
|
|
|
BRK. LIMM is part of instruction length, so it can be either 4 or 8
|
|
|
|
bytes for 32-bit instructions. */
|
|
|
|
if ((length_with_limm == 4 || length_with_limm == 8)
|
|
|
|
&& !arc_mach_is_arc600 (gdbarch))
|
2016-11-03 22:35:13 +08:00
|
|
|
return sizeof (arc_brk_le);
|
|
|
|
else
|
|
|
|
return sizeof (arc_brk_s_le);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Implement the "sw_breakpoint_from_kind" gdbarch method. */
|
|
|
|
|
|
|
|
static const gdb_byte *
|
|
|
|
arc_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
|
|
|
|
{
|
gdb/arc: fix print_one_insn selftest
I noticed that the ARC print_one_insn selftest was failing. The
problem is that in print_one_insn_test the arc case falls through into
the special case that handles nios2, score, and riscv.
The special case for these targets hard codes the breakpoint kind to
'4'. This is find for bare metal arc (see arc-tdep.c,
arc_sw_breakpoint_from_kind), however, for arc/linux only breakpoint
kind '2' is supported (see arc-linux-tdep.c,
arc_linux_sw_breakpoint_from_kind).
So the code in print_one_insn_test as it is currently written passed
in an invalid breakpoint kind, this leads to GDB trying to disassemble
unexpected memory.
The fix is to reorder the code in print_one_insn_test so that the arc
case falls through into the default case. In the default we no longer
hard code the breakpoint kind, and everything should be good.
Additionally, given the arc code only expects specific breakpoint kind
values, I thought it would be nice to add some gdb_assert to validate
things. This assert would have triggered in this case and made it
easier to find the error.
After this commit, configure GDB with --enable-targets=all, then run
gdb.gdb/unittest.exp, there should no longer be any failures.
gdb/ChangeLog:
* arc-linux-tdep.c (arc_linux_sw_breakpoint_from_kind): Add an
assert.
* arc-tdep.c (arc_breakpoint_kind_from_pc): Likewise.
* disasm-selftests.c (print_one_insn_test): Fall throough from ARC
case to the default.
2020-11-16 23:31:16 +08:00
|
|
|
gdb_assert (kind == 2 || kind == 4);
|
2016-11-03 22:35:13 +08:00
|
|
|
*size = kind;
|
|
|
|
|
|
|
|
if (kind == sizeof (arc_brk_le))
|
2016-08-13 01:02:20 +08:00
|
|
|
{
|
|
|
|
return ((gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
|
|
|
|
? arc_brk_be
|
|
|
|
: arc_brk_le);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ((gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
|
|
|
|
? arc_brk_s_be
|
|
|
|
: arc_brk_s_le);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Implement the "frame_align" gdbarch method. */
|
|
|
|
|
|
|
|
static CORE_ADDR
|
|
|
|
arc_frame_align (struct gdbarch *gdbarch, CORE_ADDR sp)
|
|
|
|
{
|
|
|
|
return align_down (sp, 4);
|
|
|
|
}
|
|
|
|
|
2017-02-10 19:12:09 +08:00
|
|
|
/* Dump the frame info. Used for internal debugging only. */
|
|
|
|
|
|
|
|
static void
|
-Wwrite-strings: The Rest
This is the remainder boring constification that all looks more of less
borderline obvious IMO.
gdb/ChangeLog:
2017-04-05 Pedro Alves <palves@redhat.com>
* ada-exp.y (yyerror): Constify.
* ada-lang.c (bound_name, get_selections)
(ada_variant_discrim_type)
(ada_variant_discrim_name, ada_value_struct_elt)
(ada_lookup_struct_elt_type, is_unchecked_variant)
(ada_which_variant_applies, standard_exc, ada_get_next_arg)
(catch_ada_exception_command_split)
(catch_ada_assert_command_split, catch_assert_command)
(ada_op_name): Constify.
* ada-lang.h (ada_yyerror, get_selections)
(ada_variant_discrim_name, ada_value_struct_elt): Constify.
* arc-tdep.c (arc_print_frame_cache): Constify.
* arm-tdep.c (arm_skip_stub): Constify.
* ax-gdb.c (gen_binop, gen_struct_ref_recursive, gen_struct_ref)
(gen_aggregate_elt_ref): Constify.
* bcache.c (print_bcache_statistics): Constify.
* bcache.h (print_bcache_statistics): Constify.
* break-catch-throw.c (catch_exception_command_1):
* breakpoint.c (struct ep_type_description::description):
Constify.
(add_solib_catchpoint): Constify.
(catch_fork_command_1): Add cast.
(add_catch_command): Constify.
* breakpoint.h (add_catch_command, add_solib_catchpoint):
Constify.
* bsd-uthread.c (bsd_uthread_state): Constify.
* buildsym.c (patch_subfile_names): Constify.
* buildsym.h (next_symbol_text_func, patch_subfile_names):
Constify.
* c-exp.y (yyerror): Constify.
(token::oper): Constify.
* c-lang.h (c_yyerror, cp_print_class_member): Constify.
* c-varobj.c (cplus_describe_child): Constify.
* charset.c (find_charset_names): Add cast.
(find_charset_names): Constify array and add const_cast.
* cli/cli-cmds.c (complete_command, cd_command): Constify.
(edit_command): Constify.
* cli/cli-decode.c (lookup_cmd): Constify.
* cli/cli-dump.c (dump_memory_command, dump_value_command):
Constify.
(struct dump_context): Constify.
(add_dump_command, restore_command): Constify.
* cli/cli-script.c (get_command_line): Constify.
* cli/cli-script.h (get_command_line): Constify.
* cli/cli-utils.c (check_for_argument): Constify.
* cli/cli-utils.h (check_for_argument): Constify.
* coff-pe-read.c (struct read_pe_section_data): Constify.
* command.h (lookup_cmd): Constify.
* common/print-utils.c (decimal2str): Constify.
* completer.c (gdb_print_filename): Constify.
* corefile.c (set_gnutarget): Constify.
* cp-name-parser.y (yyerror): Constify.
* cp-valprint.c (cp_print_class_member): Constify.
* cris-tdep.c (cris_register_name, crisv32_register_name):
Constify.
* d-exp.y (yyerror): Constify.
(struct token::oper): Constify.
* d-lang.h (d_yyerror): Constify.
* dbxread.c (struct header_file_location::name): Constify.
(add_old_header_file, add_new_header_file, last_function_name)
(dbx_next_symbol_text, add_bincl_to_list)
(find_corresponding_bincl_psymtab, set_namestring)
(find_stab_function_addr, read_dbx_symtab, start_psymtab)
(dbx_end_psymtab, read_ofile_symtab, process_one_symbol):
* defs.h (command_line_input, print_address_symbolic)
(deprecated_readline_begin_hook): Constify.
* dwarf2read.c (anonymous_struct_prefix, dwarf_bool_name):
Constify.
* event-top.c (handle_line_of_input): Constify and add cast.
* exceptions.c (catch_errors): Constify.
* exceptions.h (catch_errors): Constify.
* expprint.c (print_subexp_standard, op_string, op_name)
(op_name_standard, dump_raw_expression, dump_raw_expression):
* expression.h (op_name, op_string, dump_raw_expression):
Constify.
* f-exp.y (yyerror): Constify.
(struct token::oper): Constify.
(struct f77_boolean_val::name): Constify.
* f-lang.c (f_word_break_characters): Constify.
* f-lang.h (f_yyerror): Constify.
* fork-child.c (fork_inferior): Add cast.
* frv-tdep.c (struct gdbarch_tdep::register_names): Constify.
(new_variant): Constify.
* gdbarch.sh (pstring_ptr, pstring_list): Constify.
* gdbarch.c: Regenerate.
* gdbcore.h (set_gnutarget): Constify.
* go-exp.y (yyerror): Constify.
(token::oper): Constify.
* go-lang.h (go_yyerror): Constify.
* go32-nat.c (go32_sysinfo): Constify.
* guile/scm-breakpoint.c (gdbscm_breakpoint_expression): Constify.
* guile/scm-cmd.c (cmdscm_function): Constify.
* guile/scm-param.c (pascm_param_value): Constify.
* h8300-tdep.c (h8300_register_name, h8300s_register_name)
(h8300sx_register_name): Constify.
* hppa-tdep.c (hppa32_register_name, hppa64_register_name):
Constify.
* ia64-tdep.c (ia64_register_names): Constify.
* infcmd.c (construct_inferior_arguments): Constify.
(path_command, attach_post_wait): Constify.
* language.c (show_range_command, show_case_command)
(unk_lang_error): Constify.
* language.h (language_defn::la_error)
(language_defn::la_name_of_this): Constify.
* linespec.c (decode_line_2): Constify.
* linux-thread-db.c (thread_db_err_str): Constify.
* lm32-tdep.c (lm32_register_name): Constify.
* m2-exp.y (yyerror): Constify.
* m2-lang.h (m2_yyerror): Constify.
* m32r-tdep.c (m32r_register_names): Constify and make static.
* m68hc11-tdep.c (m68hc11_register_names): Constify.
* m88k-tdep.c (m88k_register_name): Constify.
* macroexp.c (appendmem): Constify.
* mdebugread.c (fdr_name, add_data_symbol, parse_type)
(upgrade_type, parse_external, parse_partial_symbols)
(mdebug_next_symbol_text, cross_ref, mylookup_symbol, new_psymtab)
(new_symbol): Constify.
* memattr.c (mem_info_command): Constify.
* mep-tdep.c (register_name_from_keyword): Constify.
* mi/mi-cmd-env.c (mi_cmd_env_path, _initialize_mi_cmd_env):
Constify.
* mi/mi-cmd-stack.c (list_args_or_locals): Constify.
* mi/mi-cmd-var.c (mi_cmd_var_show_attributes): Constify.
* mi/mi-main.c (captured_mi_execute_command): Constify and add
cast.
(mi_execute_async_cli_command): Constify.
* mips-tdep.c (mips_register_name): Constify.
* mn10300-tdep.c (register_name, mn10300_generic_register_name)
(am33_register_name, am33_2_register_name)
* moxie-tdep.c (moxie_register_names): Constify.
* nat/linux-osdata.c (osdata_type): Constify fields.
* nto-tdep.c (nto_parse_redirection): Constify.
* objc-lang.c (lookup_struct_typedef, lookup_objc_class)
(lookup_child_selector): Constify.
(objc_methcall::name): Constify.
* objc-lang.h (lookup_objc_class, lookup_child_selector)
(lookup_struct_typedef): Constify.
* objfiles.c (pc_in_section): Constify.
* objfiles.h (pc_in_section): Constify.
* p-exp.y (struct token::oper): Constify.
(yyerror): Constify.
* p-lang.h (pascal_yyerror): Constify.
* parser-defs.h (op_name_standard): Constify.
(op_print::string): Constify.
(exp_descriptor::op_name): Constify.
* printcmd.c (print_address_symbolic): Constify.
* psymtab.c (print_partial_symbols): Constify.
* python/py-breakpoint.c (stop_func): Constify.
(bppy_get_expression): Constify.
* python/py-cmd.c (cmdpy_completer::name): Constify.
(cmdpy_function): Constify.
* python/py-event.c (evpy_add_attribute)
(gdbpy_initialize_event_generic): Constify.
* python/py-event.h (evpy_add_attribute)
(gdbpy_initialize_event_generic): Constify.
* python/py-evts.c (add_new_registry): Constify.
* python/py-finishbreakpoint.c (outofscope_func): Constify.
* python/py-framefilter.c (get_py_iter_from_func): Constify.
* python/py-inferior.c (get_buffer): Add cast.
* python/py-param.c (parm_constant::name): Constify.
* python/py-unwind.c (fprint_frame_id): Constify.
* python/python.c (gdbpy_parameter_value): Constify.
* remote-fileio.c (remote_fio_func_map): Make 'name' const.
* remote.c (memory_packet_config::name): Constify.
(show_packet_config_cmd, remote_write_bytes)
(remote_buffer_add_string):
* reverse.c (exec_reverse_once): Constify.
* rs6000-tdep.c (variant::name, variant::description): Constify.
* rust-exp.y (rustyyerror): Constify.
* rust-lang.c (rust_op_name): Constify.
* rust-lang.h (rustyyerror): Constify.
* serial.h (serial_ops::name): Constify.
* sh-tdep.c (sh_sh_register_name, sh_sh3_register_name)
(sh_sh3e_register_name, sh_sh2e_register_name)
(sh_sh2a_register_name, sh_sh2a_nofpu_register_name)
(sh_sh_dsp_register_name, sh_sh3_dsp_register_name)
(sh_sh4_register_name, sh_sh4_nofpu_register_name)
(sh_sh4al_dsp_register_name): Constify.
* sh64-tdep.c (sh64_register_name): Constify.
* solib-darwin.c (lookup_symbol_from_bfd): Constify.
* spu-tdep.c (spu_register_name, info_spu_dma_cmdlist): Constify.
* stabsread.c (patch_block_stabs, read_type_number)
(ref_map::stabs, ref_add, process_reference)
(symbol_reference_defined, define_symbol, define_symbol)
(error_type, read_type, read_member_functions, read_cpp_abbrev)
(read_one_struct_field, read_struct_fields, read_baseclasses)
(read_tilde_fields, read_struct_type, read_array_type)
(read_enum_type, read_sun_builtin_type, read_sun_floating_type)
(read_huge_number, read_range_type, read_args, common_block_start)
(find_name_end): Constify.
* stabsread.h (common_block_start, define_symbol)
(process_one_symbol, symbol_reference_defined, ref_add):
* symfile.c (get_section_index, add_symbol_file_command):
* symfile.h (get_section_index): Constify.
* target-descriptions.c (tdesc_type::name): Constify.
(tdesc_free_type): Add cast.
* target.c (find_default_run_target):
(add_deprecated_target_alias, find_default_run_target)
(target_announce_detach): Constify.
(do_option): Constify.
* target.h (add_deprecated_target_alias): Constify.
* thread.c (print_thread_info_1): Constify.
* top.c (deprecated_readline_begin_hook, command_line_input):
Constify.
(init_main): Add casts.
* top.h (handle_line_of_input): Constify.
* tracefile-tfile.c (tfile_write_uploaded_tsv): Constify.
* tracepoint.c (tvariables_info_1, trace_status_mi): Constify.
(tfind_command): Rename to ...
(tfind_command_1): ... this and constify.
(tfind_command): New function.
(tfind_end_command, tfind_start_command): Adjust.
(encode_source_string): Constify.
* tracepoint.h (encode_source_string): Constify.
* tui/tui-data.c (tui_partial_win_by_name): Constify.
* tui/tui-data.h (tui_partial_win_by_name): Constify.
* tui/tui-source.c (tui_set_source_content_nil): Constify.
* tui/tui-source.h (tui_set_source_content_nil): Constify.
* tui/tui-win.c (parse_scrolling_args): Constify.
* tui/tui-windata.c (tui_erase_data_content): Constify.
* tui/tui-windata.h (tui_erase_data_content): Constify.
* tui/tui-winsource.c (tui_erase_source_content): Constify.
* tui/tui.c (tui_enable): Add cast.
* utils.c (defaulted_query): Constify.
(init_page_info): Add cast.
(puts_debug, subset_compare): Constify.
* utils.h (subset_compare): Constify.
* varobj.c (varobj_format_string): Constify.
* varobj.h (varobj_format_string): Constify.
* vax-tdep.c (vax_register_name): Constify.
* windows-nat.c (windows_detach): Constify.
* xcoffread.c (process_linenos, xcoff_next_symbol_text): Constify.
* xml-support.c (gdb_xml_end_element): Constify.
* xml-tdesc.c (tdesc_start_reg): Constify.
* xstormy16-tdep.c (xstormy16_register_name): Constify.
* xtensa-tdep.c (xtensa_find_register_by_name): Constify.
* xtensa-tdep.h (xtensa_register_t::name): Constify.
gdb/gdbserver/ChangeLog:
2017-04-05 Pedro Alves <palves@redhat.com>
* gdbreplay.c (sync_error): Constify.
* linux-x86-low.c (push_opcode): Constify.
2017-04-06 02:21:37 +08:00
|
|
|
arc_print_frame_cache (struct gdbarch *gdbarch, const char *message,
|
2017-02-10 19:12:09 +08:00
|
|
|
struct arc_frame_cache *cache, int addresses_known)
|
|
|
|
{
|
2021-01-14 03:32:39 +08:00
|
|
|
arc_debug_printf ("frame_info %s", message);
|
|
|
|
arc_debug_printf ("prev_sp = %s", paddress (gdbarch, cache->prev_sp));
|
|
|
|
arc_debug_printf ("frame_base_reg = %i", cache->frame_base_reg);
|
|
|
|
arc_debug_printf ("frame_base_offset = %s",
|
|
|
|
plongest (cache->frame_base_offset));
|
2017-02-10 19:12:09 +08:00
|
|
|
|
|
|
|
for (int i = 0; i <= ARC_BLINK_REGNUM; i++)
|
|
|
|
{
|
trad-frame cleanups
With the new member functions for struct trad_frame_saved_reg, there is no
need to invoke some of the set/get functions anymore. This patch removes
those and adjusts all callers.
Even though the most natural initial state of a saved register value is
UNKNOWN, there are target backends relying on the previous initial state
of REALREG set to a register's own number. I noticed this in at least a
couple targets: aarch64 and riscv.
Because of that, I decided to keep the reset function that sets the set of
register values to REALREG. I can't exercise all the targets to make sure
the initial state change won't break things, hence why it is risky to change
the default.
Validated with --enable-targets=all on aarch64-linux Ubuntu 18.04/20.04.
gdb/ChangeLog
2021-01-19 Luis Machado <luis.machado@linaro.org>
* trad-frame.h (trad_frame_saved_reg) <set_value_bytes>: Allocate
memory and save data.
(trad_frame_set_value, trad_frame_set_realreg, trad_frame_set_addr)
(trad_frame_set_unknown, trad_frame_set_value_bytes)
(trad_frame_value_p, trad_frame_addr_p, trad_frame_realreg_p)
(trad_frame_value_bytes_p): Remove.
(trad_frame_reset_saved_regs): Adjust documentation.
* trad-frame.c (trad_frame_alloc_saved_regs): Initialize via a
constructor and reset the state of the registers.
(trad_frame_value_p, trad_frame_addr_p, trad_frame_realreg_p)
(trad_frame_value_bytes_p, trad_frame_set_value)
(trad_frame_set_realreg, trad_frame_set_addr)
(trad_frame_set_unknown, trad_frame_set_value_bytes): Remove.
(trad_frame_set_reg_realreg): Update to call member function.
(trad_frame_set_reg_addr, trad_frame_set_reg_value_bytes): Likewise.
(trad_frame_get_prev_register): Likewise.
* aarch64-tdep.c (aarch64_analyze_prologue)
(aarch64_analyze_prologue_test, aarch64_make_prologue_cache_1)
(aarch64_prologue_prev_register): Update to use member functions.
* alpha-mdebug-tdep.c (alpha_mdebug_frame_unwind_cache): Likewise.
* alpha-tdep.c (alpha_heuristic_frame_unwind_cache): Likewise.
* arc-tdep.c (arc_print_frame_cache, arc_make_frame_cache): Likewise.
* arm-tdep.c (arm_make_prologue_cache, arm_exidx_fill_cache)
(arm_make_epilogue_frame_cache): Likewise.
* avr-tdep.c (avr_frame_unwind_cache)
(avr_frame_prev_register): Likewise.
* cris-tdep.c (cris_scan_prologue): Likewise.
* csky-tdep.c (csky_frame_unwind_cache): Likewise.
* frv-tdep.c (frv_analyze_prologue): Likewise.
* hppa-tdep.c (hppa_frame_cache, hppa_fallback_frame_cache): Likewise.
* lm32-tdep.c (lm32_frame_cache): Likewise.
* m32r-tdep.c (m32r_frame_unwind_cache): Likewise.
* m68hc11-tdep.c (m68hc11_frame_unwind_cache): Likewise.
* mips-tdep.c (set_reg_offset, mips_insn16_frame_cache)
(mips_micro_frame_cache, mips_insn32_frame_cache): Likewise.
(reset_saved_regs): Adjust to set realreg.
* riscv-tdep.c (riscv_scan_prologue, riscv_frame_cache): Adjust to
call member functions.
* rs6000-tdep.c (rs6000_frame_cache, rs6000_epilogue_frame_cache)
* s390-tdep.c (s390_prologue_frame_unwind_cache)
(s390_backchain_frame_unwind_cache): Likewise.
* score-tdep.c (score7_analyze_prologue)
(score3_analyze_prologue, score_make_prologue_cache): Likewise.
* sparc-netbsd-tdep.c (sparc32nbsd_sigcontext_saved_regs): Likewise.
* sparc-sol2-tdep.c (sparc32_sol2_sigtramp_frame_cache): Likewise.
* sparc64-netbsd-tdep.c (sparc64nbsd_sigcontext_saved_regs): Likewise.
* sparc64-sol2-tdep.c (sparc64_sol2_sigtramp_frame_cache): Likewise.
* tilegx-tdep.c (tilegx_analyze_prologue)
(tilegx_frame_cache): Likewise.
* v850-tdep.c (v850_frame_cache): Likewise.
* vax-tdep.c (vax_frame_cache): Likewise.
2021-01-15 02:43:28 +08:00
|
|
|
if (cache->saved_regs[i].is_addr ())
|
2021-01-14 03:32:39 +08:00
|
|
|
arc_debug_printf ("saved register %s at %s %s",
|
|
|
|
gdbarch_register_name (gdbarch, i),
|
|
|
|
(addresses_known) ? "address" : "offset",
|
|
|
|
paddress (gdbarch, cache->saved_regs[i].addr ()));
|
2017-02-10 19:12:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-13 01:02:20 +08:00
|
|
|
/* Frame unwinder for normal frames. */
|
|
|
|
|
|
|
|
static struct arc_frame_cache *
|
gdb: pass frames as `const frame_info_ptr &`
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>
2024-02-20 02:07:47 +08:00
|
|
|
arc_make_frame_cache (const frame_info_ptr &this_frame)
|
2016-08-13 01:02:20 +08:00
|
|
|
{
|
2021-01-14 03:32:39 +08:00
|
|
|
arc_debug_printf ("called");
|
2016-08-13 01:02:20 +08:00
|
|
|
|
|
|
|
struct gdbarch *gdbarch = get_frame_arch (this_frame);
|
|
|
|
|
|
|
|
CORE_ADDR block_addr = get_frame_address_in_block (this_frame);
|
|
|
|
CORE_ADDR entrypoint, prologue_end;
|
|
|
|
if (find_pc_partial_function (block_addr, NULL, &entrypoint, &prologue_end))
|
|
|
|
{
|
|
|
|
struct symtab_and_line sal = find_pc_line (entrypoint, 0);
|
2017-02-10 19:12:09 +08:00
|
|
|
CORE_ADDR prev_pc = get_frame_pc (this_frame);
|
2016-08-13 01:02:20 +08:00
|
|
|
if (sal.line == 0)
|
|
|
|
/* No line info so use current PC. */
|
|
|
|
prologue_end = prev_pc;
|
|
|
|
else if (sal.end < prologue_end)
|
|
|
|
/* The next line begins after the function end. */
|
|
|
|
prologue_end = sal.end;
|
|
|
|
|
|
|
|
prologue_end = std::min (prologue_end, prev_pc);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-02-10 19:12:09 +08:00
|
|
|
/* If find_pc_partial_function returned nothing then there is no symbol
|
|
|
|
information at all for this PC. Currently it is assumed in this case
|
|
|
|
that current PC is entrypoint to function and try to construct the
|
|
|
|
frame from that. This is, probably, suboptimal, for example ARM
|
|
|
|
assumes in this case that program is inside the normal frame (with
|
|
|
|
frame pointer). ARC, perhaps, should try to do the same. */
|
2016-08-13 01:02:20 +08:00
|
|
|
entrypoint = get_frame_register_unsigned (this_frame,
|
|
|
|
gdbarch_pc_regnum (gdbarch));
|
2017-02-10 19:12:09 +08:00
|
|
|
prologue_end = entrypoint + MAX_PROLOGUE_LENGTH;
|
2016-08-13 01:02:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate new frame cache instance and space for saved register info.
|
2017-02-10 19:12:09 +08:00
|
|
|
FRAME_OBSTACK_ZALLOC will initialize fields to zeroes. */
|
2016-08-13 01:02:20 +08:00
|
|
|
struct arc_frame_cache *cache
|
|
|
|
= FRAME_OBSTACK_ZALLOC (struct arc_frame_cache);
|
|
|
|
cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
|
|
|
|
|
2017-02-10 19:12:09 +08:00
|
|
|
arc_analyze_prologue (gdbarch, entrypoint, prologue_end, cache);
|
|
|
|
|
|
|
|
if (arc_debug)
|
|
|
|
arc_print_frame_cache (gdbarch, "after prologue", cache, false);
|
|
|
|
|
|
|
|
CORE_ADDR unwound_fb = get_frame_register_unsigned (this_frame,
|
|
|
|
cache->frame_base_reg);
|
|
|
|
if (unwound_fb == 0)
|
|
|
|
return cache;
|
|
|
|
cache->prev_sp = unwound_fb + cache->frame_base_offset;
|
|
|
|
|
|
|
|
for (int i = 0; i <= ARC_LAST_CORE_REGNUM; i++)
|
|
|
|
{
|
trad-frame cleanups
With the new member functions for struct trad_frame_saved_reg, there is no
need to invoke some of the set/get functions anymore. This patch removes
those and adjusts all callers.
Even though the most natural initial state of a saved register value is
UNKNOWN, there are target backends relying on the previous initial state
of REALREG set to a register's own number. I noticed this in at least a
couple targets: aarch64 and riscv.
Because of that, I decided to keep the reset function that sets the set of
register values to REALREG. I can't exercise all the targets to make sure
the initial state change won't break things, hence why it is risky to change
the default.
Validated with --enable-targets=all on aarch64-linux Ubuntu 18.04/20.04.
gdb/ChangeLog
2021-01-19 Luis Machado <luis.machado@linaro.org>
* trad-frame.h (trad_frame_saved_reg) <set_value_bytes>: Allocate
memory and save data.
(trad_frame_set_value, trad_frame_set_realreg, trad_frame_set_addr)
(trad_frame_set_unknown, trad_frame_set_value_bytes)
(trad_frame_value_p, trad_frame_addr_p, trad_frame_realreg_p)
(trad_frame_value_bytes_p): Remove.
(trad_frame_reset_saved_regs): Adjust documentation.
* trad-frame.c (trad_frame_alloc_saved_regs): Initialize via a
constructor and reset the state of the registers.
(trad_frame_value_p, trad_frame_addr_p, trad_frame_realreg_p)
(trad_frame_value_bytes_p, trad_frame_set_value)
(trad_frame_set_realreg, trad_frame_set_addr)
(trad_frame_set_unknown, trad_frame_set_value_bytes): Remove.
(trad_frame_set_reg_realreg): Update to call member function.
(trad_frame_set_reg_addr, trad_frame_set_reg_value_bytes): Likewise.
(trad_frame_get_prev_register): Likewise.
* aarch64-tdep.c (aarch64_analyze_prologue)
(aarch64_analyze_prologue_test, aarch64_make_prologue_cache_1)
(aarch64_prologue_prev_register): Update to use member functions.
* alpha-mdebug-tdep.c (alpha_mdebug_frame_unwind_cache): Likewise.
* alpha-tdep.c (alpha_heuristic_frame_unwind_cache): Likewise.
* arc-tdep.c (arc_print_frame_cache, arc_make_frame_cache): Likewise.
* arm-tdep.c (arm_make_prologue_cache, arm_exidx_fill_cache)
(arm_make_epilogue_frame_cache): Likewise.
* avr-tdep.c (avr_frame_unwind_cache)
(avr_frame_prev_register): Likewise.
* cris-tdep.c (cris_scan_prologue): Likewise.
* csky-tdep.c (csky_frame_unwind_cache): Likewise.
* frv-tdep.c (frv_analyze_prologue): Likewise.
* hppa-tdep.c (hppa_frame_cache, hppa_fallback_frame_cache): Likewise.
* lm32-tdep.c (lm32_frame_cache): Likewise.
* m32r-tdep.c (m32r_frame_unwind_cache): Likewise.
* m68hc11-tdep.c (m68hc11_frame_unwind_cache): Likewise.
* mips-tdep.c (set_reg_offset, mips_insn16_frame_cache)
(mips_micro_frame_cache, mips_insn32_frame_cache): Likewise.
(reset_saved_regs): Adjust to set realreg.
* riscv-tdep.c (riscv_scan_prologue, riscv_frame_cache): Adjust to
call member functions.
* rs6000-tdep.c (rs6000_frame_cache, rs6000_epilogue_frame_cache)
* s390-tdep.c (s390_prologue_frame_unwind_cache)
(s390_backchain_frame_unwind_cache): Likewise.
* score-tdep.c (score7_analyze_prologue)
(score3_analyze_prologue, score_make_prologue_cache): Likewise.
* sparc-netbsd-tdep.c (sparc32nbsd_sigcontext_saved_regs): Likewise.
* sparc-sol2-tdep.c (sparc32_sol2_sigtramp_frame_cache): Likewise.
* sparc64-netbsd-tdep.c (sparc64nbsd_sigcontext_saved_regs): Likewise.
* sparc64-sol2-tdep.c (sparc64_sol2_sigtramp_frame_cache): Likewise.
* tilegx-tdep.c (tilegx_analyze_prologue)
(tilegx_frame_cache): Likewise.
* v850-tdep.c (v850_frame_cache): Likewise.
* vax-tdep.c (vax_frame_cache): Likewise.
2021-01-15 02:43:28 +08:00
|
|
|
if (cache->saved_regs[i].is_addr ())
|
Refactor struct trad_frame_saved_regs
The following patch drops the overloading going on with the trad_frame_saved_reg
struct and defines a new struct with a KIND enum and a union of different
fields.
The new struct looks like this:
struct trad_frame_saved_reg
{
setters/getters
...
private:
trad_frame_saved_reg_kind m_kind;
union {
LONGEST value;
int realreg;
LONGEST addr;
const gdb_byte *value_bytes;
} m_reg;
};
And the enums look like this:
/* Describes the kind of encoding a stored register has. */
enum class trad_frame_saved_reg_kind
{
/* Register value is unknown. */
UNKNOWN = 0,
/* Register value is a constant. */
VALUE,
/* Register value is in another register. */
REALREG,
/* Register value is at an address. */
ADDR,
/* Register value is a sequence of bytes. */
VALUE_BYTES
};
The patch also adds setters/getters and updates all the users of the old
struct.
It is worth mentioning that due to the previous overloaded nature of the
fields, some tdep files like to store negative offsets and indexes in the ADDR
field, so I kept the ADDR as LONGEST instead of CORE_ADDR. Those cases may
be better supported by a new enum entry.
I have not addressed those cases in this patch to prevent unwanted breakage,
given I have no way to test some of the targets. But it would be nice to
clean those up eventually.
The change to frame-unwind.* is to constify the parameter being passed to the
unwinding functions, given we now accept a "const gdb_byte *" for value bytes.
Tested on aarch64-linux/Ubuntu 20.04/18.04 and by building GDB with
--enable-targets=all.
gdb/ChangeLog:
2021-01-04 Luis Machado <luis.machado@linaro.org>
Update all users of trad_frame_saved_reg to use the new member
functions.
Remote all struct keywords from declarations of trad_frame_saved_reg
types, except on forward declarations.
* aarch64-tdep.c: Update.
* alpha-mdebug-tdep.c: Update.
* alpha-tdep.c: Update.
* arc-tdep.c: Update.
* arm-tdep.c: Update.
* avr-tdep.c: Update.
* cris-tdep.c: Update.
* csky-tdep.c: Update.
* frv-tdep.c: Update.
* hppa-linux-tdep.c: Update.
* hppa-tdep.c: Update.
* hppa-tdep.h: Update.
* lm32-tdep.c: Update.
* m32r-linux-tdep.c: Update.
* m32r-tdep.c: Update.
* m68hc11-tdep.c: Update.
* mips-tdep.c: Update.
* moxie-tdep.c: Update.
* riscv-tdep.c: Update.
* rs6000-tdep.c: Update.
* s390-linux-tdep.c: Update.
* s390-tdep.c: Update.
* score-tdep.c: Update.
* sparc-netbsd-tdep.c: Update.
* sparc-sol2-tdep.c: Update.
* sparc64-fbsd-tdep.c: Update.
* sparc64-netbsd-tdep.c: Update.
* sparc64-obsd-tdep.c: Update.
* sparc64-sol2-tdep.c: Update.
* tilegx-tdep.c: Update.
* v850-tdep.c: Update.
* vax-tdep.c: Update.
* frame-unwind.c (frame_unwind_got_bytes): Make parameter const.
* frame-unwind.h (frame_unwind_got_bytes): Likewise.
* trad-frame.c: Update.
Remove TF_REG_* enum.
(trad_frame_alloc_saved_regs): Add a static assertion to check for
a trivially-constructible struct.
(trad_frame_reset_saved_regs): Adjust to use member function.
(trad_frame_value_p): Likewise.
(trad_frame_addr_p): Likewise.
(trad_frame_realreg_p): Likewise.
(trad_frame_value_bytes_p): Likewise.
(trad_frame_set_value): Likewise.
(trad_frame_set_realreg): Likewise.
(trad_frame_set_addr): Likewise.
(trad_frame_set_unknown): Likewise.
(trad_frame_set_value_bytes): Likewise.
(trad_frame_get_prev_register): Likewise.
* trad-frame.h: Update.
(trad_frame_saved_reg_kind): New enum.
(struct trad_frame_saved_reg) <addr, realreg, data>: Remove.
<m_kind, m_reg>: New member fields.
<set_value, set_realreg, set_addr, set_unknown, set_value_bytes>
<kind, value, realreg, addr, value_bytes, is_value, is_realreg>
<is_addr, is_unknown, is_value_bytes>: New member functions.
2020-12-23 04:45:21 +08:00
|
|
|
cache->saved_regs[i].set_addr (cache->saved_regs[i].addr ()
|
|
|
|
+ cache->prev_sp);
|
2017-02-10 19:12:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (arc_debug)
|
|
|
|
arc_print_frame_cache (gdbarch, "after previous SP found", cache, true);
|
2016-08-13 01:02:20 +08:00
|
|
|
|
|
|
|
return cache;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Implement the "this_id" frame_unwind method. */
|
|
|
|
|
|
|
|
static void
|
gdb: pass frames as `const frame_info_ptr &`
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>
2024-02-20 02:07:47 +08:00
|
|
|
arc_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
|
2016-08-13 01:02:20 +08:00
|
|
|
struct frame_id *this_id)
|
|
|
|
{
|
2021-01-14 03:32:39 +08:00
|
|
|
arc_debug_printf ("called");
|
2016-08-13 01:02:20 +08:00
|
|
|
|
|
|
|
struct gdbarch *gdbarch = get_frame_arch (this_frame);
|
|
|
|
|
|
|
|
if (*this_cache == NULL)
|
|
|
|
*this_cache = arc_make_frame_cache (this_frame);
|
|
|
|
struct arc_frame_cache *cache = (struct arc_frame_cache *) (*this_cache);
|
|
|
|
|
|
|
|
CORE_ADDR stack_addr = cache->prev_sp;
|
|
|
|
|
|
|
|
/* There are 4 possible situation which decide how frame_id->code_addr is
|
|
|
|
evaluated:
|
|
|
|
|
|
|
|
1) Function is compiled with option -g. Then frame_id will be created
|
|
|
|
in dwarf_* function and not in this function. NB: even if target
|
|
|
|
binary is compiled with -g, some std functions like __start and _init
|
|
|
|
are not, so they still will follow one of the following choices.
|
|
|
|
|
|
|
|
2) Function is compiled without -g and binary hasn't been stripped in
|
|
|
|
any way. In this case GDB still has enough information to evaluate
|
|
|
|
frame code_addr properly. This case is covered by call to
|
|
|
|
get_frame_func ().
|
|
|
|
|
|
|
|
3) Binary has been striped with option -g (strip debug symbols). In
|
|
|
|
this case there is still enough symbols for get_frame_func () to work
|
|
|
|
properly, so this case is also covered by it.
|
|
|
|
|
|
|
|
4) Binary has been striped with option -s (strip all symbols). In this
|
|
|
|
case GDB cannot get function start address properly, so we return current
|
|
|
|
PC value instead.
|
|
|
|
*/
|
|
|
|
CORE_ADDR code_addr = get_frame_func (this_frame);
|
|
|
|
if (code_addr == 0)
|
|
|
|
code_addr = get_frame_register_unsigned (this_frame,
|
|
|
|
gdbarch_pc_regnum (gdbarch));
|
|
|
|
|
|
|
|
*this_id = frame_id_build (stack_addr, code_addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Implement the "prev_register" frame_unwind method. */
|
|
|
|
|
|
|
|
static struct value *
|
gdb: pass frames as `const frame_info_ptr &`
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>
2024-02-20 02:07:47 +08:00
|
|
|
arc_frame_prev_register (const frame_info_ptr &this_frame,
|
2016-08-13 01:02:20 +08:00
|
|
|
void **this_cache, int regnum)
|
|
|
|
{
|
|
|
|
if (*this_cache == NULL)
|
|
|
|
*this_cache = arc_make_frame_cache (this_frame);
|
|
|
|
struct arc_frame_cache *cache = (struct arc_frame_cache *) (*this_cache);
|
|
|
|
|
|
|
|
struct gdbarch *gdbarch = get_frame_arch (this_frame);
|
|
|
|
|
|
|
|
/* If we are asked to unwind the PC, then we need to return BLINK instead:
|
|
|
|
the saved value of PC points into this frame's function's prologue, not
|
|
|
|
the next frame's function's resume location. */
|
|
|
|
if (regnum == gdbarch_pc_regnum (gdbarch))
|
|
|
|
regnum = ARC_BLINK_REGNUM;
|
|
|
|
|
|
|
|
/* SP is a special case - we should return prev_sp, because
|
|
|
|
trad_frame_get_prev_register will return _current_ SP value.
|
|
|
|
Alternatively we could have stored cache->prev_sp in the cache->saved
|
|
|
|
regs, but here we follow the lead of AArch64, ARM and Xtensa and will
|
|
|
|
leave that logic in this function, instead of prologue analyzers. That I
|
|
|
|
think is a bit more clear as `saved_regs` should contain saved regs, not
|
|
|
|
computable.
|
|
|
|
|
|
|
|
Because value has been computed, "got_constant" should be used, so that
|
|
|
|
returned value will be a "not_lval" - immutable. */
|
|
|
|
|
|
|
|
if (regnum == gdbarch_sp_regnum (gdbarch))
|
|
|
|
return frame_unwind_got_constant (this_frame, regnum, cache->prev_sp);
|
|
|
|
|
|
|
|
return trad_frame_get_prev_register (this_frame, cache->saved_regs, regnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Implement the "init_reg" dwarf2_frame method. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
arc_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
|
|
|
|
struct dwarf2_frame_state_reg *reg,
|
gdb: pass frames as `const frame_info_ptr &`
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>
2024-02-20 02:07:47 +08:00
|
|
|
const frame_info_ptr &info)
|
2016-08-13 01:02:20 +08:00
|
|
|
{
|
|
|
|
if (regnum == gdbarch_pc_regnum (gdbarch))
|
|
|
|
/* The return address column. */
|
|
|
|
reg->how = DWARF2_FRAME_REG_RA;
|
|
|
|
else if (regnum == gdbarch_sp_regnum (gdbarch))
|
|
|
|
/* The call frame address. */
|
|
|
|
reg->how = DWARF2_FRAME_REG_CFA;
|
|
|
|
}
|
|
|
|
|
2016-08-23 00:39:46 +08:00
|
|
|
/* Signal trampoline frame unwinder. Allows frame unwinding to happen
|
|
|
|
from within signal handlers. */
|
|
|
|
|
|
|
|
static struct arc_frame_cache *
|
gdb: pass frames as `const frame_info_ptr &`
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>
2024-02-20 02:07:47 +08:00
|
|
|
arc_make_sigtramp_frame_cache (const frame_info_ptr &this_frame)
|
2016-08-23 00:39:46 +08:00
|
|
|
{
|
2021-01-14 03:32:39 +08:00
|
|
|
arc_debug_printf ("called");
|
2016-08-23 00:39:46 +08:00
|
|
|
|
gdb: fix gdbarch_tdep ODR violation
I would like to be able to use non-trivial types in gdbarch_tdep types.
This is not possible at the moment (in theory), because of the one
definition rule.
To allow it, rename all gdbarch_tdep types to <arch>_gdbarch_tdep, and
make them inherit from a gdbarch_tdep base class. The inheritance is
necessary to be able to pass pointers to all these <arch>_gdbarch_tdep
objects to gdbarch_alloc, which takes a pointer to gdbarch_tdep.
These objects are never deleted through a base class pointer, so I
didn't include a virtual destructor. In the future, if gdbarch objects
deletable, I could imagine that the gdbarch_tdep objects could become
owned by the gdbarch objects, and then it would become useful to have a
virtual destructor (so that the gdbarch object can delete the owned
gdbarch_tdep object). But that's not necessary right now.
It turns out that RISC-V already has a gdbarch_tdep that is
non-default-constructible, so that provides a good motivation for this
change.
Most changes are fairly straightforward, mostly needing to add some
casts all over the place. There is however the xtensa architecture,
doing its own little weird thing to define its gdbarch_tdep. I did my
best to adapt it, but I can't test those changes.
Change-Id: Ic001903f91ddd106bd6ca09a79dabe8df2d69f3b
2021-11-16 00:29:39 +08:00
|
|
|
gdbarch *arch = get_frame_arch (this_frame);
|
gdb: move the type cast into gdbarch_tdep
I built GDB for all targets on a x86-64/GNU-Linux system, and
then (accidentally) passed GDB a RISC-V binary, and asked GDB to "run"
the binary on the native target. I got this error:
(gdb) show architecture
The target architecture is set to "auto" (currently "i386").
(gdb) file /tmp/hello.rv32.exe
Reading symbols from /tmp/hello.rv32.exe...
(gdb) show architecture
The target architecture is set to "auto" (currently "riscv:rv32").
(gdb) run
Starting program: /tmp/hello.rv32.exe
../../src/gdb/i387-tdep.c:596: internal-error: i387_supply_fxsave: Assertion `tdep->st0_regnum >= I386_ST0_REGNUM' failed.
What's going on here is this; initially the architecture is i386, this
is based on the default architecture, which is set based on the native
target. After loading the RISC-V executable the architecture of the
current inferior is updated based on the architecture of the
executable.
When we "run", GDB does a fork & exec, with the inferior being
controlled through ptrace. GDB sees an initial stop from the inferior
as soon as the inferior comes to life. In response to this stop GDB
ends up calling save_stop_reason (linux-nat.c), which ends up trying
to read register from the inferior, to do this we end up calling
target_ops::fetch_registers, which, for the x86-64 native target,
calls amd64_linux_nat_target::fetch_registers.
After this I eventually end up in i387_supply_fxsave, different x86
based targets will end in different functions to fetch registers, but
it doesn't really matter which function we end up in, the problem is
this line, which is repeated in many places:
i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (arch);
The problem here is that the ARCH in this line comes from the current
inferior, which, as we discussed above, will be a RISC-V gdbarch, the
tdep field will actually be of type riscv_gdbarch_tdep, not
i386_gdbarch_tdep. After this cast we are relying on undefined
behaviour, in my case I happen to trigger an assert, but this might
not always be the case.
The thing I tried that exposed this problem was of course, trying to
start an executable of the wrong architecture on a native target. I
don't think that the correct solution for this problem is to detect,
at the point of cast, that the gdbarch_tdep object is of the wrong
type, but, I did wonder, is there a way that we could protect
ourselves from incorrectly casting the gdbarch_tdep object?
I think that there is something we can do here, and this commit is the
first step in that direction, though no actual check is added by this
commit.
This commit can be split into two parts:
(1) In gdbarch.h and arch-utils.c. In these files I have modified
gdbarch_tdep (the function) so that it now takes a template argument,
like this:
template<typename TDepType>
static inline TDepType *
gdbarch_tdep (struct gdbarch *gdbarch)
{
struct gdbarch_tdep *tdep = gdbarch_tdep_1 (gdbarch);
return static_cast<TDepType *> (tdep);
}
After this change we are no better protected, but the cast is now
done within the gdbarch_tdep function rather than at the call sites,
this leads to the second, much larger change in this commit,
(2) Everywhere gdbarch_tdep is called, we make changes like this:
- i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (arch);
+ i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (arch);
There should be no functional change after this commit.
In the next commit I will build on this change to add an assertion in
gdbarch_tdep that checks we are casting to the correct type.
2022-05-19 20:20:17 +08:00
|
|
|
arc_gdbarch_tdep *tdep = gdbarch_tdep<arc_gdbarch_tdep> (arch);
|
2016-08-23 00:39:46 +08:00
|
|
|
|
|
|
|
/* Allocate new frame cache instance and space for saved register info. */
|
|
|
|
struct arc_frame_cache *cache = FRAME_OBSTACK_ZALLOC (struct arc_frame_cache);
|
|
|
|
cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
|
|
|
|
|
|
|
|
/* Get the stack pointer and use it as the frame base. */
|
|
|
|
cache->prev_sp = arc_frame_base_address (this_frame, NULL);
|
|
|
|
|
|
|
|
/* If the ARC-private target-dependent info doesn't have a table of
|
|
|
|
offsets of saved register contents within an OS signal context
|
|
|
|
structure, then there is nothing to analyze. */
|
|
|
|
if (tdep->sc_reg_offset == NULL)
|
|
|
|
return cache;
|
|
|
|
|
|
|
|
/* Find the address of the sigcontext structure. */
|
|
|
|
CORE_ADDR addr = tdep->sigcontext_addr (this_frame);
|
|
|
|
|
|
|
|
/* For each register, if its contents have been saved within the
|
|
|
|
sigcontext structure, determine the address of those contents. */
|
|
|
|
gdb_assert (tdep->sc_num_regs <= (ARC_LAST_REGNUM + 1));
|
|
|
|
for (int i = 0; i < tdep->sc_num_regs; i++)
|
|
|
|
{
|
|
|
|
if (tdep->sc_reg_offset[i] != ARC_OFFSET_NO_REGISTER)
|
Refactor struct trad_frame_saved_regs
The following patch drops the overloading going on with the trad_frame_saved_reg
struct and defines a new struct with a KIND enum and a union of different
fields.
The new struct looks like this:
struct trad_frame_saved_reg
{
setters/getters
...
private:
trad_frame_saved_reg_kind m_kind;
union {
LONGEST value;
int realreg;
LONGEST addr;
const gdb_byte *value_bytes;
} m_reg;
};
And the enums look like this:
/* Describes the kind of encoding a stored register has. */
enum class trad_frame_saved_reg_kind
{
/* Register value is unknown. */
UNKNOWN = 0,
/* Register value is a constant. */
VALUE,
/* Register value is in another register. */
REALREG,
/* Register value is at an address. */
ADDR,
/* Register value is a sequence of bytes. */
VALUE_BYTES
};
The patch also adds setters/getters and updates all the users of the old
struct.
It is worth mentioning that due to the previous overloaded nature of the
fields, some tdep files like to store negative offsets and indexes in the ADDR
field, so I kept the ADDR as LONGEST instead of CORE_ADDR. Those cases may
be better supported by a new enum entry.
I have not addressed those cases in this patch to prevent unwanted breakage,
given I have no way to test some of the targets. But it would be nice to
clean those up eventually.
The change to frame-unwind.* is to constify the parameter being passed to the
unwinding functions, given we now accept a "const gdb_byte *" for value bytes.
Tested on aarch64-linux/Ubuntu 20.04/18.04 and by building GDB with
--enable-targets=all.
gdb/ChangeLog:
2021-01-04 Luis Machado <luis.machado@linaro.org>
Update all users of trad_frame_saved_reg to use the new member
functions.
Remote all struct keywords from declarations of trad_frame_saved_reg
types, except on forward declarations.
* aarch64-tdep.c: Update.
* alpha-mdebug-tdep.c: Update.
* alpha-tdep.c: Update.
* arc-tdep.c: Update.
* arm-tdep.c: Update.
* avr-tdep.c: Update.
* cris-tdep.c: Update.
* csky-tdep.c: Update.
* frv-tdep.c: Update.
* hppa-linux-tdep.c: Update.
* hppa-tdep.c: Update.
* hppa-tdep.h: Update.
* lm32-tdep.c: Update.
* m32r-linux-tdep.c: Update.
* m32r-tdep.c: Update.
* m68hc11-tdep.c: Update.
* mips-tdep.c: Update.
* moxie-tdep.c: Update.
* riscv-tdep.c: Update.
* rs6000-tdep.c: Update.
* s390-linux-tdep.c: Update.
* s390-tdep.c: Update.
* score-tdep.c: Update.
* sparc-netbsd-tdep.c: Update.
* sparc-sol2-tdep.c: Update.
* sparc64-fbsd-tdep.c: Update.
* sparc64-netbsd-tdep.c: Update.
* sparc64-obsd-tdep.c: Update.
* sparc64-sol2-tdep.c: Update.
* tilegx-tdep.c: Update.
* v850-tdep.c: Update.
* vax-tdep.c: Update.
* frame-unwind.c (frame_unwind_got_bytes): Make parameter const.
* frame-unwind.h (frame_unwind_got_bytes): Likewise.
* trad-frame.c: Update.
Remove TF_REG_* enum.
(trad_frame_alloc_saved_regs): Add a static assertion to check for
a trivially-constructible struct.
(trad_frame_reset_saved_regs): Adjust to use member function.
(trad_frame_value_p): Likewise.
(trad_frame_addr_p): Likewise.
(trad_frame_realreg_p): Likewise.
(trad_frame_value_bytes_p): Likewise.
(trad_frame_set_value): Likewise.
(trad_frame_set_realreg): Likewise.
(trad_frame_set_addr): Likewise.
(trad_frame_set_unknown): Likewise.
(trad_frame_set_value_bytes): Likewise.
(trad_frame_get_prev_register): Likewise.
* trad-frame.h: Update.
(trad_frame_saved_reg_kind): New enum.
(struct trad_frame_saved_reg) <addr, realreg, data>: Remove.
<m_kind, m_reg>: New member fields.
<set_value, set_realreg, set_addr, set_unknown, set_value_bytes>
<kind, value, realreg, addr, value_bytes, is_value, is_realreg>
<is_addr, is_unknown, is_value_bytes>: New member functions.
2020-12-23 04:45:21 +08:00
|
|
|
cache->saved_regs[i].set_addr (addr + tdep->sc_reg_offset[i]);
|
2016-08-23 00:39:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return cache;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Implement the "this_id" frame_unwind method for signal trampoline
|
|
|
|
frames. */
|
|
|
|
|
|
|
|
static void
|
gdb: pass frames as `const frame_info_ptr &`
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>
2024-02-20 02:07:47 +08:00
|
|
|
arc_sigtramp_frame_this_id (const frame_info_ptr &this_frame,
|
2016-08-23 00:39:46 +08:00
|
|
|
void **this_cache, struct frame_id *this_id)
|
|
|
|
{
|
2021-01-14 03:32:39 +08:00
|
|
|
arc_debug_printf ("called");
|
2016-08-23 00:39:46 +08:00
|
|
|
|
|
|
|
if (*this_cache == NULL)
|
|
|
|
*this_cache = arc_make_sigtramp_frame_cache (this_frame);
|
|
|
|
|
|
|
|
struct gdbarch *gdbarch = get_frame_arch (this_frame);
|
|
|
|
struct arc_frame_cache *cache = (struct arc_frame_cache *) *this_cache;
|
|
|
|
CORE_ADDR stack_addr = cache->prev_sp;
|
|
|
|
CORE_ADDR code_addr
|
|
|
|
= get_frame_register_unsigned (this_frame, gdbarch_pc_regnum (gdbarch));
|
|
|
|
*this_id = frame_id_build (stack_addr, code_addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get a register from a signal handler frame. */
|
|
|
|
|
|
|
|
static struct value *
|
gdb: pass frames as `const frame_info_ptr &`
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>
2024-02-20 02:07:47 +08:00
|
|
|
arc_sigtramp_frame_prev_register (const frame_info_ptr &this_frame,
|
2016-08-23 00:39:46 +08:00
|
|
|
void **this_cache, int regnum)
|
|
|
|
{
|
2021-01-14 03:32:39 +08:00
|
|
|
arc_debug_printf ("regnum = %d", regnum);
|
2016-08-23 00:39:46 +08:00
|
|
|
|
|
|
|
/* Make sure we've initialized the cache. */
|
|
|
|
if (*this_cache == NULL)
|
|
|
|
*this_cache = arc_make_sigtramp_frame_cache (this_frame);
|
|
|
|
|
|
|
|
struct arc_frame_cache *cache = (struct arc_frame_cache *) *this_cache;
|
|
|
|
return trad_frame_get_prev_register (this_frame, cache->saved_regs, regnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Frame sniffer for signal handler frame. Only recognize a frame if we
|
|
|
|
have a sigcontext_addr handler in the target dependency. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
arc_sigtramp_frame_sniffer (const struct frame_unwind *self,
|
gdb: pass frames as `const frame_info_ptr &`
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>
2024-02-20 02:07:47 +08:00
|
|
|
const frame_info_ptr &this_frame,
|
2016-08-23 00:39:46 +08:00
|
|
|
void **this_cache)
|
|
|
|
{
|
2021-01-14 03:32:39 +08:00
|
|
|
arc_debug_printf ("called");
|
2016-08-23 00:39:46 +08:00
|
|
|
|
gdb: fix gdbarch_tdep ODR violation
I would like to be able to use non-trivial types in gdbarch_tdep types.
This is not possible at the moment (in theory), because of the one
definition rule.
To allow it, rename all gdbarch_tdep types to <arch>_gdbarch_tdep, and
make them inherit from a gdbarch_tdep base class. The inheritance is
necessary to be able to pass pointers to all these <arch>_gdbarch_tdep
objects to gdbarch_alloc, which takes a pointer to gdbarch_tdep.
These objects are never deleted through a base class pointer, so I
didn't include a virtual destructor. In the future, if gdbarch objects
deletable, I could imagine that the gdbarch_tdep objects could become
owned by the gdbarch objects, and then it would become useful to have a
virtual destructor (so that the gdbarch object can delete the owned
gdbarch_tdep object). But that's not necessary right now.
It turns out that RISC-V already has a gdbarch_tdep that is
non-default-constructible, so that provides a good motivation for this
change.
Most changes are fairly straightforward, mostly needing to add some
casts all over the place. There is however the xtensa architecture,
doing its own little weird thing to define its gdbarch_tdep. I did my
best to adapt it, but I can't test those changes.
Change-Id: Ic001903f91ddd106bd6ca09a79dabe8df2d69f3b
2021-11-16 00:29:39 +08:00
|
|
|
gdbarch *arch = get_frame_arch (this_frame);
|
gdb: move the type cast into gdbarch_tdep
I built GDB for all targets on a x86-64/GNU-Linux system, and
then (accidentally) passed GDB a RISC-V binary, and asked GDB to "run"
the binary on the native target. I got this error:
(gdb) show architecture
The target architecture is set to "auto" (currently "i386").
(gdb) file /tmp/hello.rv32.exe
Reading symbols from /tmp/hello.rv32.exe...
(gdb) show architecture
The target architecture is set to "auto" (currently "riscv:rv32").
(gdb) run
Starting program: /tmp/hello.rv32.exe
../../src/gdb/i387-tdep.c:596: internal-error: i387_supply_fxsave: Assertion `tdep->st0_regnum >= I386_ST0_REGNUM' failed.
What's going on here is this; initially the architecture is i386, this
is based on the default architecture, which is set based on the native
target. After loading the RISC-V executable the architecture of the
current inferior is updated based on the architecture of the
executable.
When we "run", GDB does a fork & exec, with the inferior being
controlled through ptrace. GDB sees an initial stop from the inferior
as soon as the inferior comes to life. In response to this stop GDB
ends up calling save_stop_reason (linux-nat.c), which ends up trying
to read register from the inferior, to do this we end up calling
target_ops::fetch_registers, which, for the x86-64 native target,
calls amd64_linux_nat_target::fetch_registers.
After this I eventually end up in i387_supply_fxsave, different x86
based targets will end in different functions to fetch registers, but
it doesn't really matter which function we end up in, the problem is
this line, which is repeated in many places:
i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (arch);
The problem here is that the ARCH in this line comes from the current
inferior, which, as we discussed above, will be a RISC-V gdbarch, the
tdep field will actually be of type riscv_gdbarch_tdep, not
i386_gdbarch_tdep. After this cast we are relying on undefined
behaviour, in my case I happen to trigger an assert, but this might
not always be the case.
The thing I tried that exposed this problem was of course, trying to
start an executable of the wrong architecture on a native target. I
don't think that the correct solution for this problem is to detect,
at the point of cast, that the gdbarch_tdep object is of the wrong
type, but, I did wonder, is there a way that we could protect
ourselves from incorrectly casting the gdbarch_tdep object?
I think that there is something we can do here, and this commit is the
first step in that direction, though no actual check is added by this
commit.
This commit can be split into two parts:
(1) In gdbarch.h and arch-utils.c. In these files I have modified
gdbarch_tdep (the function) so that it now takes a template argument,
like this:
template<typename TDepType>
static inline TDepType *
gdbarch_tdep (struct gdbarch *gdbarch)
{
struct gdbarch_tdep *tdep = gdbarch_tdep_1 (gdbarch);
return static_cast<TDepType *> (tdep);
}
After this change we are no better protected, but the cast is now
done within the gdbarch_tdep function rather than at the call sites,
this leads to the second, much larger change in this commit,
(2) Everywhere gdbarch_tdep is called, we make changes like this:
- i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (arch);
+ i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (arch);
There should be no functional change after this commit.
In the next commit I will build on this change to add an assertion in
gdbarch_tdep that checks we are casting to the correct type.
2022-05-19 20:20:17 +08:00
|
|
|
arc_gdbarch_tdep *tdep = gdbarch_tdep<arc_gdbarch_tdep> (arch);
|
2016-08-23 00:39:46 +08:00
|
|
|
|
|
|
|
/* If we have a sigcontext_addr handler, then just return 1 (same as the
|
|
|
|
"default_frame_sniffer ()"). */
|
|
|
|
return (tdep->sigcontext_addr != NULL && tdep->is_sigtramp != NULL
|
|
|
|
&& tdep->is_sigtramp (this_frame));
|
|
|
|
}
|
|
|
|
|
2016-08-13 01:02:20 +08:00
|
|
|
/* Structure defining the ARC ordinary frame unwind functions. Since we are
|
|
|
|
the fallback unwinder, we use the default frame sniffer, which always
|
|
|
|
accepts the frame. */
|
|
|
|
|
|
|
|
static const struct frame_unwind arc_frame_unwind = {
|
2021-06-30 00:05:03 +08:00
|
|
|
"arc prologue",
|
2016-08-13 01:02:20 +08:00
|
|
|
NORMAL_FRAME,
|
|
|
|
default_frame_unwind_stop_reason,
|
|
|
|
arc_frame_this_id,
|
|
|
|
arc_frame_prev_register,
|
|
|
|
NULL,
|
|
|
|
default_frame_sniffer,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2016-08-23 00:39:46 +08:00
|
|
|
/* Structure defining the ARC signal frame unwind functions. Custom
|
|
|
|
sniffer is used, because this frame must be accepted only in the right
|
|
|
|
context. */
|
|
|
|
|
|
|
|
static const struct frame_unwind arc_sigtramp_frame_unwind = {
|
2021-06-30 00:05:03 +08:00
|
|
|
"arc sigtramp",
|
2016-08-23 00:39:46 +08:00
|
|
|
SIGTRAMP_FRAME,
|
|
|
|
default_frame_unwind_stop_reason,
|
|
|
|
arc_sigtramp_frame_this_id,
|
|
|
|
arc_sigtramp_frame_prev_register,
|
|
|
|
NULL,
|
|
|
|
arc_sigtramp_frame_sniffer,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2016-08-13 01:02:20 +08:00
|
|
|
|
|
|
|
static const struct frame_base arc_normal_base = {
|
|
|
|
&arc_frame_unwind,
|
|
|
|
arc_frame_base_address,
|
|
|
|
arc_frame_base_address,
|
|
|
|
arc_frame_base_address
|
|
|
|
};
|
|
|
|
|
2020-07-09 23:43:13 +08:00
|
|
|
static enum arc_isa
|
|
|
|
mach_type_to_arc_isa (const unsigned long mach)
|
2016-08-13 01:02:20 +08:00
|
|
|
{
|
2020-07-09 23:43:13 +08:00
|
|
|
switch (mach)
|
|
|
|
{
|
|
|
|
case bfd_mach_arc_arc600:
|
|
|
|
case bfd_mach_arc_arc601:
|
|
|
|
case bfd_mach_arc_arc700:
|
|
|
|
return ARC_ISA_ARCV1;
|
|
|
|
case bfd_mach_arc_arcv2:
|
|
|
|
return ARC_ISA_ARCV2;
|
|
|
|
default:
|
internal_error: remove need to pass __FILE__/__LINE__
Currently, every internal_error call must be passed __FILE__/__LINE__
explicitly, like:
internal_error (__FILE__, __LINE__, "foo %d", var);
The need to pass in explicit __FILE__/__LINE__ is there probably
because the function predates widespread and portable variadic macros
availability. We can use variadic macros nowadays, and in fact, we
already use them in several places, including the related
gdb_assert_not_reached.
So this patch renames the internal_error function to something else,
and then reimplements internal_error as a variadic macro that expands
__FILE__/__LINE__ itself.
The result is that we now should call internal_error like so:
internal_error ("foo %d", var);
Likewise for internal_warning.
The patch adjusts all calls sites. 99% of the adjustments were done
with a perl/sed script.
The non-mechanical changes are in gdbsupport/errors.h,
gdbsupport/gdb_assert.h, and gdb/gdbarch.py.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Change-Id: Ia6f372c11550ca876829e8fd85048f4502bdcf06
2022-10-18 00:12:20 +08:00
|
|
|
internal_error (_("unknown machine id %lu"), mach);
|
2020-07-09 23:43:13 +08:00
|
|
|
}
|
|
|
|
}
|
2016-08-13 01:02:20 +08:00
|
|
|
|
2017-01-30 23:32:10 +08:00
|
|
|
/* See arc-tdep.h. */
|
2016-08-13 01:02:20 +08:00
|
|
|
|
2017-01-30 23:32:10 +08:00
|
|
|
arc_arch_features
|
2020-10-05 23:10:47 +08:00
|
|
|
arc_arch_features_create (const bfd *abfd, const unsigned long mach)
|
2020-07-09 23:43:13 +08:00
|
|
|
{
|
|
|
|
/* Use 4 as a fallback value. */
|
|
|
|
int reg_size = 4;
|
|
|
|
|
|
|
|
/* Try to guess the features parameters by looking at the binary to be
|
|
|
|
executed. If the user is providing a binary that does not match the
|
|
|
|
target, then tough luck. This is the last effort to makes sense of
|
|
|
|
what's going on. */
|
|
|
|
if (abfd != nullptr && bfd_get_flavour (abfd) == bfd_target_elf_flavour)
|
2016-08-13 01:02:20 +08:00
|
|
|
{
|
2020-07-09 23:43:13 +08:00
|
|
|
unsigned char eclass = elf_elfheader (abfd)->e_ident[EI_CLASS];
|
|
|
|
|
|
|
|
if (eclass == ELFCLASS32)
|
|
|
|
reg_size = 4;
|
|
|
|
else if (eclass == ELFCLASS64)
|
|
|
|
reg_size = 8;
|
2016-08-13 01:02:20 +08:00
|
|
|
else
|
internal_error: remove need to pass __FILE__/__LINE__
Currently, every internal_error call must be passed __FILE__/__LINE__
explicitly, like:
internal_error (__FILE__, __LINE__, "foo %d", var);
The need to pass in explicit __FILE__/__LINE__ is there probably
because the function predates widespread and portable variadic macros
availability. We can use variadic macros nowadays, and in fact, we
already use them in several places, including the related
gdb_assert_not_reached.
So this patch renames the internal_error function to something else,
and then reimplements internal_error as a variadic macro that expands
__FILE__/__LINE__ itself.
The result is that we now should call internal_error like so:
internal_error ("foo %d", var);
Likewise for internal_warning.
The patch adjusts all calls sites. 99% of the adjustments were done
with a perl/sed script.
The non-mechanical changes are in gdbsupport/errors.h,
gdbsupport/gdb_assert.h, and gdb/gdbarch.py.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Change-Id: Ia6f372c11550ca876829e8fd85048f4502bdcf06
2022-10-18 00:12:20 +08:00
|
|
|
internal_error (_("unknown ELF header class %d"), eclass);
|
2016-08-13 01:02:20 +08:00
|
|
|
}
|
2020-07-09 23:43:13 +08:00
|
|
|
|
|
|
|
/* MACH from a bfd_arch_info struct is used here. It should be a safe
|
|
|
|
bet, as it looks like the struct is always initialized even when we
|
|
|
|
don't pass any elf file to GDB at all (it uses default arch in that
|
|
|
|
case). */
|
|
|
|
arc_isa isa = mach_type_to_arc_isa (mach);
|
|
|
|
|
2020-10-05 23:10:47 +08:00
|
|
|
return arc_arch_features (reg_size, isa);
|
2020-07-09 23:43:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Look for obsolete core feature names in TDESC. */
|
|
|
|
|
|
|
|
static const struct tdesc_feature *
|
|
|
|
find_obsolete_core_names (const struct target_desc *tdesc)
|
|
|
|
{
|
|
|
|
const struct tdesc_feature *feat = nullptr;
|
|
|
|
|
|
|
|
feat = tdesc_find_feature (tdesc, ARC_CORE_V1_OBSOLETE_FEATURE_NAME);
|
|
|
|
|
|
|
|
if (feat == nullptr)
|
|
|
|
feat = tdesc_find_feature (tdesc, ARC_CORE_V2_OBSOLETE_FEATURE_NAME);
|
|
|
|
|
|
|
|
if (feat == nullptr)
|
|
|
|
feat = tdesc_find_feature
|
|
|
|
(tdesc, ARC_CORE_V2_REDUCED_OBSOLETE_FEATURE_NAME);
|
|
|
|
|
|
|
|
return feat;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Look for obsolete aux feature names in TDESC. */
|
|
|
|
|
|
|
|
static const struct tdesc_feature *
|
|
|
|
find_obsolete_aux_names (const struct target_desc *tdesc)
|
|
|
|
{
|
|
|
|
return tdesc_find_feature (tdesc, ARC_AUX_OBSOLETE_FEATURE_NAME);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Based on the MACH value, determines which core register features set
|
|
|
|
must be used. */
|
|
|
|
|
|
|
|
static arc_register_feature *
|
|
|
|
determine_core_reg_feature_set (const unsigned long mach)
|
|
|
|
{
|
|
|
|
switch (mach_type_to_arc_isa (mach))
|
2016-08-13 01:02:20 +08:00
|
|
|
{
|
2020-07-09 23:43:13 +08:00
|
|
|
case ARC_ISA_ARCV1:
|
|
|
|
return &arc_v1_core_reg_feature;
|
|
|
|
case ARC_ISA_ARCV2:
|
|
|
|
return &arc_v2_core_reg_feature;
|
|
|
|
default:
|
|
|
|
gdb_assert_not_reached
|
gdb, gdbserver, gdbsupport: fix leading space vs tabs issues
Many spots incorrectly use only spaces for indentation (for example,
there are a lot of spots in ada-lang.c). I've always found it awkward
when I needed to edit one of these spots: do I keep the original wrong
indentation, or do I fix it? What if the lines around it are also
wrong, do I fix them too? I probably don't want to fix them in the same
patch, to avoid adding noise to my patch.
So I propose to fix as much as possible once and for all (hopefully).
One typical counter argument for this is that it makes code archeology
more difficult, because git-blame will show this commit as the last
change for these lines. My counter counter argument is: when
git-blaming, you often need to do "blame the file at the parent commit"
anyway, to go past some other refactor that touched the line you are
interested in, but is not the change you are looking for. So you
already need a somewhat efficient way to do this.
Using some interactive tool, rather than plain git-blame, makes this
trivial. For example, I use "tig blame <file>", where going back past
the commit that changed the currently selected line is one keystroke.
It looks like Magit in Emacs does it too (though I've never used it).
Web viewers of Github and Gitlab do it too. My point is that it won't
really make archeology more difficult.
The other typical counter argument is that it will cause conflicts with
existing patches. That's true... but it's a one time cost, and those
are not conflicts that are difficult to resolve. I have also tried "git
rebase --ignore-whitespace", it seems to work well. Although that will
re-introduce the faulty indentation, so one needs to take care of fixing
the indentation in the patch after that (which is easy).
gdb/ChangeLog:
* aarch64-linux-tdep.c: Fix indentation.
* aarch64-ravenscar-thread.c: Fix indentation.
* aarch64-tdep.c: Fix indentation.
* aarch64-tdep.h: Fix indentation.
* ada-lang.c: Fix indentation.
* ada-lang.h: Fix indentation.
* ada-tasks.c: Fix indentation.
* ada-typeprint.c: Fix indentation.
* ada-valprint.c: Fix indentation.
* ada-varobj.c: Fix indentation.
* addrmap.c: Fix indentation.
* addrmap.h: Fix indentation.
* agent.c: Fix indentation.
* aix-thread.c: Fix indentation.
* alpha-bsd-nat.c: Fix indentation.
* alpha-linux-tdep.c: Fix indentation.
* alpha-mdebug-tdep.c: Fix indentation.
* alpha-nbsd-tdep.c: Fix indentation.
* alpha-obsd-tdep.c: Fix indentation.
* alpha-tdep.c: Fix indentation.
* amd64-bsd-nat.c: Fix indentation.
* amd64-darwin-tdep.c: Fix indentation.
* amd64-linux-nat.c: Fix indentation.
* amd64-linux-tdep.c: Fix indentation.
* amd64-nat.c: Fix indentation.
* amd64-obsd-tdep.c: Fix indentation.
* amd64-tdep.c: Fix indentation.
* amd64-windows-tdep.c: Fix indentation.
* annotate.c: Fix indentation.
* arc-tdep.c: Fix indentation.
* arch-utils.c: Fix indentation.
* arch/arm-get-next-pcs.c: Fix indentation.
* arch/arm.c: Fix indentation.
* arm-linux-nat.c: Fix indentation.
* arm-linux-tdep.c: Fix indentation.
* arm-nbsd-tdep.c: Fix indentation.
* arm-pikeos-tdep.c: Fix indentation.
* arm-tdep.c: Fix indentation.
* arm-tdep.h: Fix indentation.
* arm-wince-tdep.c: Fix indentation.
* auto-load.c: Fix indentation.
* auxv.c: Fix indentation.
* avr-tdep.c: Fix indentation.
* ax-gdb.c: Fix indentation.
* ax-general.c: Fix indentation.
* bfin-linux-tdep.c: Fix indentation.
* block.c: Fix indentation.
* block.h: Fix indentation.
* blockframe.c: Fix indentation.
* bpf-tdep.c: Fix indentation.
* break-catch-sig.c: Fix indentation.
* break-catch-syscall.c: Fix indentation.
* break-catch-throw.c: Fix indentation.
* breakpoint.c: Fix indentation.
* breakpoint.h: Fix indentation.
* bsd-uthread.c: Fix indentation.
* btrace.c: Fix indentation.
* build-id.c: Fix indentation.
* buildsym-legacy.h: Fix indentation.
* buildsym.c: Fix indentation.
* c-typeprint.c: Fix indentation.
* c-valprint.c: Fix indentation.
* c-varobj.c: Fix indentation.
* charset.c: Fix indentation.
* cli/cli-cmds.c: Fix indentation.
* cli/cli-decode.c: Fix indentation.
* cli/cli-decode.h: Fix indentation.
* cli/cli-script.c: Fix indentation.
* cli/cli-setshow.c: Fix indentation.
* coff-pe-read.c: Fix indentation.
* coffread.c: Fix indentation.
* compile/compile-cplus-types.c: Fix indentation.
* compile/compile-object-load.c: Fix indentation.
* compile/compile-object-run.c: Fix indentation.
* completer.c: Fix indentation.
* corefile.c: Fix indentation.
* corelow.c: Fix indentation.
* cp-abi.h: Fix indentation.
* cp-namespace.c: Fix indentation.
* cp-support.c: Fix indentation.
* cp-valprint.c: Fix indentation.
* cris-linux-tdep.c: Fix indentation.
* cris-tdep.c: Fix indentation.
* darwin-nat-info.c: Fix indentation.
* darwin-nat.c: Fix indentation.
* darwin-nat.h: Fix indentation.
* dbxread.c: Fix indentation.
* dcache.c: Fix indentation.
* disasm.c: Fix indentation.
* dtrace-probe.c: Fix indentation.
* dwarf2/abbrev.c: Fix indentation.
* dwarf2/attribute.c: Fix indentation.
* dwarf2/expr.c: Fix indentation.
* dwarf2/frame.c: Fix indentation.
* dwarf2/index-cache.c: Fix indentation.
* dwarf2/index-write.c: Fix indentation.
* dwarf2/line-header.c: Fix indentation.
* dwarf2/loc.c: Fix indentation.
* dwarf2/macro.c: Fix indentation.
* dwarf2/read.c: Fix indentation.
* dwarf2/read.h: Fix indentation.
* elfread.c: Fix indentation.
* eval.c: Fix indentation.
* event-top.c: Fix indentation.
* exec.c: Fix indentation.
* exec.h: Fix indentation.
* expprint.c: Fix indentation.
* f-lang.c: Fix indentation.
* f-typeprint.c: Fix indentation.
* f-valprint.c: Fix indentation.
* fbsd-nat.c: Fix indentation.
* fbsd-tdep.c: Fix indentation.
* findvar.c: Fix indentation.
* fork-child.c: Fix indentation.
* frame-unwind.c: Fix indentation.
* frame-unwind.h: Fix indentation.
* frame.c: Fix indentation.
* frv-linux-tdep.c: Fix indentation.
* frv-tdep.c: Fix indentation.
* frv-tdep.h: Fix indentation.
* ft32-tdep.c: Fix indentation.
* gcore.c: Fix indentation.
* gdb_bfd.c: Fix indentation.
* gdbarch.sh: Fix indentation.
* gdbarch.c: Re-generate
* gdbarch.h: Re-generate.
* gdbcore.h: Fix indentation.
* gdbthread.h: Fix indentation.
* gdbtypes.c: Fix indentation.
* gdbtypes.h: Fix indentation.
* glibc-tdep.c: Fix indentation.
* gnu-nat.c: Fix indentation.
* gnu-nat.h: Fix indentation.
* gnu-v2-abi.c: Fix indentation.
* gnu-v3-abi.c: Fix indentation.
* go32-nat.c: Fix indentation.
* guile/guile-internal.h: Fix indentation.
* guile/scm-cmd.c: Fix indentation.
* guile/scm-frame.c: Fix indentation.
* guile/scm-iterator.c: Fix indentation.
* guile/scm-math.c: Fix indentation.
* guile/scm-ports.c: Fix indentation.
* guile/scm-pretty-print.c: Fix indentation.
* guile/scm-value.c: Fix indentation.
* h8300-tdep.c: Fix indentation.
* hppa-linux-nat.c: Fix indentation.
* hppa-linux-tdep.c: Fix indentation.
* hppa-nbsd-nat.c: Fix indentation.
* hppa-nbsd-tdep.c: Fix indentation.
* hppa-obsd-nat.c: Fix indentation.
* hppa-tdep.c: Fix indentation.
* hppa-tdep.h: Fix indentation.
* i386-bsd-nat.c: Fix indentation.
* i386-darwin-nat.c: Fix indentation.
* i386-darwin-tdep.c: Fix indentation.
* i386-dicos-tdep.c: Fix indentation.
* i386-gnu-nat.c: Fix indentation.
* i386-linux-nat.c: Fix indentation.
* i386-linux-tdep.c: Fix indentation.
* i386-nto-tdep.c: Fix indentation.
* i386-obsd-tdep.c: Fix indentation.
* i386-sol2-nat.c: Fix indentation.
* i386-tdep.c: Fix indentation.
* i386-tdep.h: Fix indentation.
* i386-windows-tdep.c: Fix indentation.
* i387-tdep.c: Fix indentation.
* i387-tdep.h: Fix indentation.
* ia64-libunwind-tdep.c: Fix indentation.
* ia64-libunwind-tdep.h: Fix indentation.
* ia64-linux-nat.c: Fix indentation.
* ia64-linux-tdep.c: Fix indentation.
* ia64-tdep.c: Fix indentation.
* ia64-tdep.h: Fix indentation.
* ia64-vms-tdep.c: Fix indentation.
* infcall.c: Fix indentation.
* infcmd.c: Fix indentation.
* inferior.c: Fix indentation.
* infrun.c: Fix indentation.
* iq2000-tdep.c: Fix indentation.
* language.c: Fix indentation.
* linespec.c: Fix indentation.
* linux-fork.c: Fix indentation.
* linux-nat.c: Fix indentation.
* linux-tdep.c: Fix indentation.
* linux-thread-db.c: Fix indentation.
* lm32-tdep.c: Fix indentation.
* m2-lang.c: Fix indentation.
* m2-typeprint.c: Fix indentation.
* m2-valprint.c: Fix indentation.
* m32c-tdep.c: Fix indentation.
* m32r-linux-tdep.c: Fix indentation.
* m32r-tdep.c: Fix indentation.
* m68hc11-tdep.c: Fix indentation.
* m68k-bsd-nat.c: Fix indentation.
* m68k-linux-nat.c: Fix indentation.
* m68k-linux-tdep.c: Fix indentation.
* m68k-tdep.c: Fix indentation.
* machoread.c: Fix indentation.
* macrocmd.c: Fix indentation.
* macroexp.c: Fix indentation.
* macroscope.c: Fix indentation.
* macrotab.c: Fix indentation.
* macrotab.h: Fix indentation.
* main.c: Fix indentation.
* mdebugread.c: Fix indentation.
* mep-tdep.c: Fix indentation.
* mi/mi-cmd-catch.c: Fix indentation.
* mi/mi-cmd-disas.c: Fix indentation.
* mi/mi-cmd-env.c: Fix indentation.
* mi/mi-cmd-stack.c: Fix indentation.
* mi/mi-cmd-var.c: Fix indentation.
* mi/mi-cmds.c: Fix indentation.
* mi/mi-main.c: Fix indentation.
* mi/mi-parse.c: Fix indentation.
* microblaze-tdep.c: Fix indentation.
* minidebug.c: Fix indentation.
* minsyms.c: Fix indentation.
* mips-linux-nat.c: Fix indentation.
* mips-linux-tdep.c: Fix indentation.
* mips-nbsd-tdep.c: Fix indentation.
* mips-tdep.c: Fix indentation.
* mn10300-linux-tdep.c: Fix indentation.
* mn10300-tdep.c: Fix indentation.
* moxie-tdep.c: Fix indentation.
* msp430-tdep.c: Fix indentation.
* namespace.h: Fix indentation.
* nat/fork-inferior.c: Fix indentation.
* nat/gdb_ptrace.h: Fix indentation.
* nat/linux-namespaces.c: Fix indentation.
* nat/linux-osdata.c: Fix indentation.
* nat/netbsd-nat.c: Fix indentation.
* nat/x86-dregs.c: Fix indentation.
* nbsd-nat.c: Fix indentation.
* nbsd-tdep.c: Fix indentation.
* nios2-linux-tdep.c: Fix indentation.
* nios2-tdep.c: Fix indentation.
* nto-procfs.c: Fix indentation.
* nto-tdep.c: Fix indentation.
* objfiles.c: Fix indentation.
* objfiles.h: Fix indentation.
* opencl-lang.c: Fix indentation.
* or1k-tdep.c: Fix indentation.
* osabi.c: Fix indentation.
* osabi.h: Fix indentation.
* osdata.c: Fix indentation.
* p-lang.c: Fix indentation.
* p-typeprint.c: Fix indentation.
* p-valprint.c: Fix indentation.
* parse.c: Fix indentation.
* ppc-linux-nat.c: Fix indentation.
* ppc-linux-tdep.c: Fix indentation.
* ppc-nbsd-nat.c: Fix indentation.
* ppc-nbsd-tdep.c: Fix indentation.
* ppc-obsd-nat.c: Fix indentation.
* ppc-ravenscar-thread.c: Fix indentation.
* ppc-sysv-tdep.c: Fix indentation.
* ppc64-tdep.c: Fix indentation.
* printcmd.c: Fix indentation.
* proc-api.c: Fix indentation.
* producer.c: Fix indentation.
* producer.h: Fix indentation.
* prologue-value.c: Fix indentation.
* prologue-value.h: Fix indentation.
* psymtab.c: Fix indentation.
* python/py-arch.c: Fix indentation.
* python/py-bpevent.c: Fix indentation.
* python/py-event.c: Fix indentation.
* python/py-event.h: Fix indentation.
* python/py-finishbreakpoint.c: Fix indentation.
* python/py-frame.c: Fix indentation.
* python/py-framefilter.c: Fix indentation.
* python/py-inferior.c: Fix indentation.
* python/py-infthread.c: Fix indentation.
* python/py-objfile.c: Fix indentation.
* python/py-prettyprint.c: Fix indentation.
* python/py-registers.c: Fix indentation.
* python/py-signalevent.c: Fix indentation.
* python/py-stopevent.c: Fix indentation.
* python/py-stopevent.h: Fix indentation.
* python/py-threadevent.c: Fix indentation.
* python/py-tui.c: Fix indentation.
* python/py-unwind.c: Fix indentation.
* python/py-value.c: Fix indentation.
* python/py-xmethods.c: Fix indentation.
* python/python-internal.h: Fix indentation.
* python/python.c: Fix indentation.
* ravenscar-thread.c: Fix indentation.
* record-btrace.c: Fix indentation.
* record-full.c: Fix indentation.
* record.c: Fix indentation.
* reggroups.c: Fix indentation.
* regset.h: Fix indentation.
* remote-fileio.c: Fix indentation.
* remote.c: Fix indentation.
* reverse.c: Fix indentation.
* riscv-linux-tdep.c: Fix indentation.
* riscv-ravenscar-thread.c: Fix indentation.
* riscv-tdep.c: Fix indentation.
* rl78-tdep.c: Fix indentation.
* rs6000-aix-tdep.c: Fix indentation.
* rs6000-lynx178-tdep.c: Fix indentation.
* rs6000-nat.c: Fix indentation.
* rs6000-tdep.c: Fix indentation.
* rust-lang.c: Fix indentation.
* rx-tdep.c: Fix indentation.
* s12z-tdep.c: Fix indentation.
* s390-linux-tdep.c: Fix indentation.
* score-tdep.c: Fix indentation.
* ser-base.c: Fix indentation.
* ser-mingw.c: Fix indentation.
* ser-uds.c: Fix indentation.
* ser-unix.c: Fix indentation.
* serial.c: Fix indentation.
* sh-linux-tdep.c: Fix indentation.
* sh-nbsd-tdep.c: Fix indentation.
* sh-tdep.c: Fix indentation.
* skip.c: Fix indentation.
* sol-thread.c: Fix indentation.
* solib-aix.c: Fix indentation.
* solib-darwin.c: Fix indentation.
* solib-frv.c: Fix indentation.
* solib-svr4.c: Fix indentation.
* solib.c: Fix indentation.
* source.c: Fix indentation.
* sparc-linux-tdep.c: Fix indentation.
* sparc-nbsd-tdep.c: Fix indentation.
* sparc-obsd-tdep.c: Fix indentation.
* sparc-ravenscar-thread.c: Fix indentation.
* sparc-tdep.c: Fix indentation.
* sparc64-linux-tdep.c: Fix indentation.
* sparc64-nbsd-tdep.c: Fix indentation.
* sparc64-obsd-tdep.c: Fix indentation.
* sparc64-tdep.c: Fix indentation.
* stabsread.c: Fix indentation.
* stack.c: Fix indentation.
* stap-probe.c: Fix indentation.
* stubs/ia64vms-stub.c: Fix indentation.
* stubs/m32r-stub.c: Fix indentation.
* stubs/m68k-stub.c: Fix indentation.
* stubs/sh-stub.c: Fix indentation.
* stubs/sparc-stub.c: Fix indentation.
* symfile-mem.c: Fix indentation.
* symfile.c: Fix indentation.
* symfile.h: Fix indentation.
* symmisc.c: Fix indentation.
* symtab.c: Fix indentation.
* symtab.h: Fix indentation.
* target-float.c: Fix indentation.
* target.c: Fix indentation.
* target.h: Fix indentation.
* tic6x-tdep.c: Fix indentation.
* tilegx-linux-tdep.c: Fix indentation.
* tilegx-tdep.c: Fix indentation.
* top.c: Fix indentation.
* tracefile-tfile.c: Fix indentation.
* tracepoint.c: Fix indentation.
* tui/tui-disasm.c: Fix indentation.
* tui/tui-io.c: Fix indentation.
* tui/tui-regs.c: Fix indentation.
* tui/tui-stack.c: Fix indentation.
* tui/tui-win.c: Fix indentation.
* tui/tui-winsource.c: Fix indentation.
* tui/tui.c: Fix indentation.
* typeprint.c: Fix indentation.
* ui-out.h: Fix indentation.
* unittests/copy_bitwise-selftests.c: Fix indentation.
* unittests/memory-map-selftests.c: Fix indentation.
* utils.c: Fix indentation.
* v850-tdep.c: Fix indentation.
* valarith.c: Fix indentation.
* valops.c: Fix indentation.
* valprint.c: Fix indentation.
* valprint.h: Fix indentation.
* value.c: Fix indentation.
* value.h: Fix indentation.
* varobj.c: Fix indentation.
* vax-tdep.c: Fix indentation.
* windows-nat.c: Fix indentation.
* windows-tdep.c: Fix indentation.
* xcoffread.c: Fix indentation.
* xml-syscall.c: Fix indentation.
* xml-tdesc.c: Fix indentation.
* xstormy16-tdep.c: Fix indentation.
* xtensa-config.c: Fix indentation.
* xtensa-linux-nat.c: Fix indentation.
* xtensa-linux-tdep.c: Fix indentation.
* xtensa-tdep.c: Fix indentation.
gdbserver/ChangeLog:
* ax.cc: Fix indentation.
* dll.cc: Fix indentation.
* inferiors.h: Fix indentation.
* linux-low.cc: Fix indentation.
* linux-nios2-low.cc: Fix indentation.
* linux-ppc-ipa.cc: Fix indentation.
* linux-ppc-low.cc: Fix indentation.
* linux-x86-low.cc: Fix indentation.
* linux-xtensa-low.cc: Fix indentation.
* regcache.cc: Fix indentation.
* server.cc: Fix indentation.
* tracepoint.cc: Fix indentation.
gdbsupport/ChangeLog:
* common-exceptions.h: Fix indentation.
* event-loop.cc: Fix indentation.
* fileio.cc: Fix indentation.
* filestuff.cc: Fix indentation.
* gdb-dlfcn.cc: Fix indentation.
* gdb_string_view.h: Fix indentation.
* job-control.cc: Fix indentation.
* signals.cc: Fix indentation.
Change-Id: I4bad7ae6be0fbe14168b8ebafb98ffe14964a695
2020-11-02 23:26:14 +08:00
|
|
|
("Unknown machine type to determine the core feature set.");
|
2016-08-13 01:02:20 +08:00
|
|
|
}
|
2020-07-09 23:43:13 +08:00
|
|
|
}
|
2016-08-13 01:02:20 +08:00
|
|
|
|
2020-07-09 23:43:13 +08:00
|
|
|
/* At the moment, there is only 1 auxiliary register features set.
|
|
|
|
This is a place holder for future extendability. */
|
2016-08-13 01:02:20 +08:00
|
|
|
|
2020-07-09 23:43:13 +08:00
|
|
|
static const arc_register_feature *
|
|
|
|
determine_aux_reg_feature_set ()
|
|
|
|
{
|
|
|
|
return &arc_common_aux_reg_feature;
|
|
|
|
}
|
2016-08-13 01:02:20 +08:00
|
|
|
|
2020-07-09 23:43:13 +08:00
|
|
|
/* Update accumulator register names (ACCH/ACCL) for r58 and r59 in the
|
|
|
|
register sets. The endianness determines the assignment:
|
2016-08-13 01:02:20 +08:00
|
|
|
|
gdb, gdbserver, gdbsupport: fix leading space vs tabs issues
Many spots incorrectly use only spaces for indentation (for example,
there are a lot of spots in ada-lang.c). I've always found it awkward
when I needed to edit one of these spots: do I keep the original wrong
indentation, or do I fix it? What if the lines around it are also
wrong, do I fix them too? I probably don't want to fix them in the same
patch, to avoid adding noise to my patch.
So I propose to fix as much as possible once and for all (hopefully).
One typical counter argument for this is that it makes code archeology
more difficult, because git-blame will show this commit as the last
change for these lines. My counter counter argument is: when
git-blaming, you often need to do "blame the file at the parent commit"
anyway, to go past some other refactor that touched the line you are
interested in, but is not the change you are looking for. So you
already need a somewhat efficient way to do this.
Using some interactive tool, rather than plain git-blame, makes this
trivial. For example, I use "tig blame <file>", where going back past
the commit that changed the currently selected line is one keystroke.
It looks like Magit in Emacs does it too (though I've never used it).
Web viewers of Github and Gitlab do it too. My point is that it won't
really make archeology more difficult.
The other typical counter argument is that it will cause conflicts with
existing patches. That's true... but it's a one time cost, and those
are not conflicts that are difficult to resolve. I have also tried "git
rebase --ignore-whitespace", it seems to work well. Although that will
re-introduce the faulty indentation, so one needs to take care of fixing
the indentation in the patch after that (which is easy).
gdb/ChangeLog:
* aarch64-linux-tdep.c: Fix indentation.
* aarch64-ravenscar-thread.c: Fix indentation.
* aarch64-tdep.c: Fix indentation.
* aarch64-tdep.h: Fix indentation.
* ada-lang.c: Fix indentation.
* ada-lang.h: Fix indentation.
* ada-tasks.c: Fix indentation.
* ada-typeprint.c: Fix indentation.
* ada-valprint.c: Fix indentation.
* ada-varobj.c: Fix indentation.
* addrmap.c: Fix indentation.
* addrmap.h: Fix indentation.
* agent.c: Fix indentation.
* aix-thread.c: Fix indentation.
* alpha-bsd-nat.c: Fix indentation.
* alpha-linux-tdep.c: Fix indentation.
* alpha-mdebug-tdep.c: Fix indentation.
* alpha-nbsd-tdep.c: Fix indentation.
* alpha-obsd-tdep.c: Fix indentation.
* alpha-tdep.c: Fix indentation.
* amd64-bsd-nat.c: Fix indentation.
* amd64-darwin-tdep.c: Fix indentation.
* amd64-linux-nat.c: Fix indentation.
* amd64-linux-tdep.c: Fix indentation.
* amd64-nat.c: Fix indentation.
* amd64-obsd-tdep.c: Fix indentation.
* amd64-tdep.c: Fix indentation.
* amd64-windows-tdep.c: Fix indentation.
* annotate.c: Fix indentation.
* arc-tdep.c: Fix indentation.
* arch-utils.c: Fix indentation.
* arch/arm-get-next-pcs.c: Fix indentation.
* arch/arm.c: Fix indentation.
* arm-linux-nat.c: Fix indentation.
* arm-linux-tdep.c: Fix indentation.
* arm-nbsd-tdep.c: Fix indentation.
* arm-pikeos-tdep.c: Fix indentation.
* arm-tdep.c: Fix indentation.
* arm-tdep.h: Fix indentation.
* arm-wince-tdep.c: Fix indentation.
* auto-load.c: Fix indentation.
* auxv.c: Fix indentation.
* avr-tdep.c: Fix indentation.
* ax-gdb.c: Fix indentation.
* ax-general.c: Fix indentation.
* bfin-linux-tdep.c: Fix indentation.
* block.c: Fix indentation.
* block.h: Fix indentation.
* blockframe.c: Fix indentation.
* bpf-tdep.c: Fix indentation.
* break-catch-sig.c: Fix indentation.
* break-catch-syscall.c: Fix indentation.
* break-catch-throw.c: Fix indentation.
* breakpoint.c: Fix indentation.
* breakpoint.h: Fix indentation.
* bsd-uthread.c: Fix indentation.
* btrace.c: Fix indentation.
* build-id.c: Fix indentation.
* buildsym-legacy.h: Fix indentation.
* buildsym.c: Fix indentation.
* c-typeprint.c: Fix indentation.
* c-valprint.c: Fix indentation.
* c-varobj.c: Fix indentation.
* charset.c: Fix indentation.
* cli/cli-cmds.c: Fix indentation.
* cli/cli-decode.c: Fix indentation.
* cli/cli-decode.h: Fix indentation.
* cli/cli-script.c: Fix indentation.
* cli/cli-setshow.c: Fix indentation.
* coff-pe-read.c: Fix indentation.
* coffread.c: Fix indentation.
* compile/compile-cplus-types.c: Fix indentation.
* compile/compile-object-load.c: Fix indentation.
* compile/compile-object-run.c: Fix indentation.
* completer.c: Fix indentation.
* corefile.c: Fix indentation.
* corelow.c: Fix indentation.
* cp-abi.h: Fix indentation.
* cp-namespace.c: Fix indentation.
* cp-support.c: Fix indentation.
* cp-valprint.c: Fix indentation.
* cris-linux-tdep.c: Fix indentation.
* cris-tdep.c: Fix indentation.
* darwin-nat-info.c: Fix indentation.
* darwin-nat.c: Fix indentation.
* darwin-nat.h: Fix indentation.
* dbxread.c: Fix indentation.
* dcache.c: Fix indentation.
* disasm.c: Fix indentation.
* dtrace-probe.c: Fix indentation.
* dwarf2/abbrev.c: Fix indentation.
* dwarf2/attribute.c: Fix indentation.
* dwarf2/expr.c: Fix indentation.
* dwarf2/frame.c: Fix indentation.
* dwarf2/index-cache.c: Fix indentation.
* dwarf2/index-write.c: Fix indentation.
* dwarf2/line-header.c: Fix indentation.
* dwarf2/loc.c: Fix indentation.
* dwarf2/macro.c: Fix indentation.
* dwarf2/read.c: Fix indentation.
* dwarf2/read.h: Fix indentation.
* elfread.c: Fix indentation.
* eval.c: Fix indentation.
* event-top.c: Fix indentation.
* exec.c: Fix indentation.
* exec.h: Fix indentation.
* expprint.c: Fix indentation.
* f-lang.c: Fix indentation.
* f-typeprint.c: Fix indentation.
* f-valprint.c: Fix indentation.
* fbsd-nat.c: Fix indentation.
* fbsd-tdep.c: Fix indentation.
* findvar.c: Fix indentation.
* fork-child.c: Fix indentation.
* frame-unwind.c: Fix indentation.
* frame-unwind.h: Fix indentation.
* frame.c: Fix indentation.
* frv-linux-tdep.c: Fix indentation.
* frv-tdep.c: Fix indentation.
* frv-tdep.h: Fix indentation.
* ft32-tdep.c: Fix indentation.
* gcore.c: Fix indentation.
* gdb_bfd.c: Fix indentation.
* gdbarch.sh: Fix indentation.
* gdbarch.c: Re-generate
* gdbarch.h: Re-generate.
* gdbcore.h: Fix indentation.
* gdbthread.h: Fix indentation.
* gdbtypes.c: Fix indentation.
* gdbtypes.h: Fix indentation.
* glibc-tdep.c: Fix indentation.
* gnu-nat.c: Fix indentation.
* gnu-nat.h: Fix indentation.
* gnu-v2-abi.c: Fix indentation.
* gnu-v3-abi.c: Fix indentation.
* go32-nat.c: Fix indentation.
* guile/guile-internal.h: Fix indentation.
* guile/scm-cmd.c: Fix indentation.
* guile/scm-frame.c: Fix indentation.
* guile/scm-iterator.c: Fix indentation.
* guile/scm-math.c: Fix indentation.
* guile/scm-ports.c: Fix indentation.
* guile/scm-pretty-print.c: Fix indentation.
* guile/scm-value.c: Fix indentation.
* h8300-tdep.c: Fix indentation.
* hppa-linux-nat.c: Fix indentation.
* hppa-linux-tdep.c: Fix indentation.
* hppa-nbsd-nat.c: Fix indentation.
* hppa-nbsd-tdep.c: Fix indentation.
* hppa-obsd-nat.c: Fix indentation.
* hppa-tdep.c: Fix indentation.
* hppa-tdep.h: Fix indentation.
* i386-bsd-nat.c: Fix indentation.
* i386-darwin-nat.c: Fix indentation.
* i386-darwin-tdep.c: Fix indentation.
* i386-dicos-tdep.c: Fix indentation.
* i386-gnu-nat.c: Fix indentation.
* i386-linux-nat.c: Fix indentation.
* i386-linux-tdep.c: Fix indentation.
* i386-nto-tdep.c: Fix indentation.
* i386-obsd-tdep.c: Fix indentation.
* i386-sol2-nat.c: Fix indentation.
* i386-tdep.c: Fix indentation.
* i386-tdep.h: Fix indentation.
* i386-windows-tdep.c: Fix indentation.
* i387-tdep.c: Fix indentation.
* i387-tdep.h: Fix indentation.
* ia64-libunwind-tdep.c: Fix indentation.
* ia64-libunwind-tdep.h: Fix indentation.
* ia64-linux-nat.c: Fix indentation.
* ia64-linux-tdep.c: Fix indentation.
* ia64-tdep.c: Fix indentation.
* ia64-tdep.h: Fix indentation.
* ia64-vms-tdep.c: Fix indentation.
* infcall.c: Fix indentation.
* infcmd.c: Fix indentation.
* inferior.c: Fix indentation.
* infrun.c: Fix indentation.
* iq2000-tdep.c: Fix indentation.
* language.c: Fix indentation.
* linespec.c: Fix indentation.
* linux-fork.c: Fix indentation.
* linux-nat.c: Fix indentation.
* linux-tdep.c: Fix indentation.
* linux-thread-db.c: Fix indentation.
* lm32-tdep.c: Fix indentation.
* m2-lang.c: Fix indentation.
* m2-typeprint.c: Fix indentation.
* m2-valprint.c: Fix indentation.
* m32c-tdep.c: Fix indentation.
* m32r-linux-tdep.c: Fix indentation.
* m32r-tdep.c: Fix indentation.
* m68hc11-tdep.c: Fix indentation.
* m68k-bsd-nat.c: Fix indentation.
* m68k-linux-nat.c: Fix indentation.
* m68k-linux-tdep.c: Fix indentation.
* m68k-tdep.c: Fix indentation.
* machoread.c: Fix indentation.
* macrocmd.c: Fix indentation.
* macroexp.c: Fix indentation.
* macroscope.c: Fix indentation.
* macrotab.c: Fix indentation.
* macrotab.h: Fix indentation.
* main.c: Fix indentation.
* mdebugread.c: Fix indentation.
* mep-tdep.c: Fix indentation.
* mi/mi-cmd-catch.c: Fix indentation.
* mi/mi-cmd-disas.c: Fix indentation.
* mi/mi-cmd-env.c: Fix indentation.
* mi/mi-cmd-stack.c: Fix indentation.
* mi/mi-cmd-var.c: Fix indentation.
* mi/mi-cmds.c: Fix indentation.
* mi/mi-main.c: Fix indentation.
* mi/mi-parse.c: Fix indentation.
* microblaze-tdep.c: Fix indentation.
* minidebug.c: Fix indentation.
* minsyms.c: Fix indentation.
* mips-linux-nat.c: Fix indentation.
* mips-linux-tdep.c: Fix indentation.
* mips-nbsd-tdep.c: Fix indentation.
* mips-tdep.c: Fix indentation.
* mn10300-linux-tdep.c: Fix indentation.
* mn10300-tdep.c: Fix indentation.
* moxie-tdep.c: Fix indentation.
* msp430-tdep.c: Fix indentation.
* namespace.h: Fix indentation.
* nat/fork-inferior.c: Fix indentation.
* nat/gdb_ptrace.h: Fix indentation.
* nat/linux-namespaces.c: Fix indentation.
* nat/linux-osdata.c: Fix indentation.
* nat/netbsd-nat.c: Fix indentation.
* nat/x86-dregs.c: Fix indentation.
* nbsd-nat.c: Fix indentation.
* nbsd-tdep.c: Fix indentation.
* nios2-linux-tdep.c: Fix indentation.
* nios2-tdep.c: Fix indentation.
* nto-procfs.c: Fix indentation.
* nto-tdep.c: Fix indentation.
* objfiles.c: Fix indentation.
* objfiles.h: Fix indentation.
* opencl-lang.c: Fix indentation.
* or1k-tdep.c: Fix indentation.
* osabi.c: Fix indentation.
* osabi.h: Fix indentation.
* osdata.c: Fix indentation.
* p-lang.c: Fix indentation.
* p-typeprint.c: Fix indentation.
* p-valprint.c: Fix indentation.
* parse.c: Fix indentation.
* ppc-linux-nat.c: Fix indentation.
* ppc-linux-tdep.c: Fix indentation.
* ppc-nbsd-nat.c: Fix indentation.
* ppc-nbsd-tdep.c: Fix indentation.
* ppc-obsd-nat.c: Fix indentation.
* ppc-ravenscar-thread.c: Fix indentation.
* ppc-sysv-tdep.c: Fix indentation.
* ppc64-tdep.c: Fix indentation.
* printcmd.c: Fix indentation.
* proc-api.c: Fix indentation.
* producer.c: Fix indentation.
* producer.h: Fix indentation.
* prologue-value.c: Fix indentation.
* prologue-value.h: Fix indentation.
* psymtab.c: Fix indentation.
* python/py-arch.c: Fix indentation.
* python/py-bpevent.c: Fix indentation.
* python/py-event.c: Fix indentation.
* python/py-event.h: Fix indentation.
* python/py-finishbreakpoint.c: Fix indentation.
* python/py-frame.c: Fix indentation.
* python/py-framefilter.c: Fix indentation.
* python/py-inferior.c: Fix indentation.
* python/py-infthread.c: Fix indentation.
* python/py-objfile.c: Fix indentation.
* python/py-prettyprint.c: Fix indentation.
* python/py-registers.c: Fix indentation.
* python/py-signalevent.c: Fix indentation.
* python/py-stopevent.c: Fix indentation.
* python/py-stopevent.h: Fix indentation.
* python/py-threadevent.c: Fix indentation.
* python/py-tui.c: Fix indentation.
* python/py-unwind.c: Fix indentation.
* python/py-value.c: Fix indentation.
* python/py-xmethods.c: Fix indentation.
* python/python-internal.h: Fix indentation.
* python/python.c: Fix indentation.
* ravenscar-thread.c: Fix indentation.
* record-btrace.c: Fix indentation.
* record-full.c: Fix indentation.
* record.c: Fix indentation.
* reggroups.c: Fix indentation.
* regset.h: Fix indentation.
* remote-fileio.c: Fix indentation.
* remote.c: Fix indentation.
* reverse.c: Fix indentation.
* riscv-linux-tdep.c: Fix indentation.
* riscv-ravenscar-thread.c: Fix indentation.
* riscv-tdep.c: Fix indentation.
* rl78-tdep.c: Fix indentation.
* rs6000-aix-tdep.c: Fix indentation.
* rs6000-lynx178-tdep.c: Fix indentation.
* rs6000-nat.c: Fix indentation.
* rs6000-tdep.c: Fix indentation.
* rust-lang.c: Fix indentation.
* rx-tdep.c: Fix indentation.
* s12z-tdep.c: Fix indentation.
* s390-linux-tdep.c: Fix indentation.
* score-tdep.c: Fix indentation.
* ser-base.c: Fix indentation.
* ser-mingw.c: Fix indentation.
* ser-uds.c: Fix indentation.
* ser-unix.c: Fix indentation.
* serial.c: Fix indentation.
* sh-linux-tdep.c: Fix indentation.
* sh-nbsd-tdep.c: Fix indentation.
* sh-tdep.c: Fix indentation.
* skip.c: Fix indentation.
* sol-thread.c: Fix indentation.
* solib-aix.c: Fix indentation.
* solib-darwin.c: Fix indentation.
* solib-frv.c: Fix indentation.
* solib-svr4.c: Fix indentation.
* solib.c: Fix indentation.
* source.c: Fix indentation.
* sparc-linux-tdep.c: Fix indentation.
* sparc-nbsd-tdep.c: Fix indentation.
* sparc-obsd-tdep.c: Fix indentation.
* sparc-ravenscar-thread.c: Fix indentation.
* sparc-tdep.c: Fix indentation.
* sparc64-linux-tdep.c: Fix indentation.
* sparc64-nbsd-tdep.c: Fix indentation.
* sparc64-obsd-tdep.c: Fix indentation.
* sparc64-tdep.c: Fix indentation.
* stabsread.c: Fix indentation.
* stack.c: Fix indentation.
* stap-probe.c: Fix indentation.
* stubs/ia64vms-stub.c: Fix indentation.
* stubs/m32r-stub.c: Fix indentation.
* stubs/m68k-stub.c: Fix indentation.
* stubs/sh-stub.c: Fix indentation.
* stubs/sparc-stub.c: Fix indentation.
* symfile-mem.c: Fix indentation.
* symfile.c: Fix indentation.
* symfile.h: Fix indentation.
* symmisc.c: Fix indentation.
* symtab.c: Fix indentation.
* symtab.h: Fix indentation.
* target-float.c: Fix indentation.
* target.c: Fix indentation.
* target.h: Fix indentation.
* tic6x-tdep.c: Fix indentation.
* tilegx-linux-tdep.c: Fix indentation.
* tilegx-tdep.c: Fix indentation.
* top.c: Fix indentation.
* tracefile-tfile.c: Fix indentation.
* tracepoint.c: Fix indentation.
* tui/tui-disasm.c: Fix indentation.
* tui/tui-io.c: Fix indentation.
* tui/tui-regs.c: Fix indentation.
* tui/tui-stack.c: Fix indentation.
* tui/tui-win.c: Fix indentation.
* tui/tui-winsource.c: Fix indentation.
* tui/tui.c: Fix indentation.
* typeprint.c: Fix indentation.
* ui-out.h: Fix indentation.
* unittests/copy_bitwise-selftests.c: Fix indentation.
* unittests/memory-map-selftests.c: Fix indentation.
* utils.c: Fix indentation.
* v850-tdep.c: Fix indentation.
* valarith.c: Fix indentation.
* valops.c: Fix indentation.
* valprint.c: Fix indentation.
* valprint.h: Fix indentation.
* value.c: Fix indentation.
* value.h: Fix indentation.
* varobj.c: Fix indentation.
* vax-tdep.c: Fix indentation.
* windows-nat.c: Fix indentation.
* windows-tdep.c: Fix indentation.
* xcoffread.c: Fix indentation.
* xml-syscall.c: Fix indentation.
* xml-tdesc.c: Fix indentation.
* xstormy16-tdep.c: Fix indentation.
* xtensa-config.c: Fix indentation.
* xtensa-linux-nat.c: Fix indentation.
* xtensa-linux-tdep.c: Fix indentation.
* xtensa-tdep.c: Fix indentation.
gdbserver/ChangeLog:
* ax.cc: Fix indentation.
* dll.cc: Fix indentation.
* inferiors.h: Fix indentation.
* linux-low.cc: Fix indentation.
* linux-nios2-low.cc: Fix indentation.
* linux-ppc-ipa.cc: Fix indentation.
* linux-ppc-low.cc: Fix indentation.
* linux-x86-low.cc: Fix indentation.
* linux-xtensa-low.cc: Fix indentation.
* regcache.cc: Fix indentation.
* server.cc: Fix indentation.
* tracepoint.cc: Fix indentation.
gdbsupport/ChangeLog:
* common-exceptions.h: Fix indentation.
* event-loop.cc: Fix indentation.
* fileio.cc: Fix indentation.
* filestuff.cc: Fix indentation.
* gdb-dlfcn.cc: Fix indentation.
* gdb_string_view.h: Fix indentation.
* job-control.cc: Fix indentation.
* signals.cc: Fix indentation.
Change-Id: I4bad7ae6be0fbe14168b8ebafb98ffe14964a695
2020-11-02 23:26:14 +08:00
|
|
|
,------.------.
|
|
|
|
| acch | accl |
|
2020-07-09 23:43:13 +08:00
|
|
|
,----|------+------|
|
|
|
|
| LE | r59 | r58 |
|
|
|
|
| BE | r58 | r59 |
|
|
|
|
`----^------^------' */
|
|
|
|
|
|
|
|
static void
|
|
|
|
arc_update_acc_reg_names (const int byte_order)
|
|
|
|
{
|
|
|
|
const char *r58_alias
|
|
|
|
= byte_order == BFD_ENDIAN_LITTLE ? "accl" : "acch";
|
|
|
|
const char *r59_alias
|
|
|
|
= byte_order == BFD_ENDIAN_LITTLE ? "acch" : "accl";
|
|
|
|
|
|
|
|
/* Subscript 1 must be OK because those registers have 2 names. */
|
|
|
|
arc_v1_core_reg_feature.registers[ARC_R58_REGNUM].names[1] = r58_alias;
|
|
|
|
arc_v1_core_reg_feature.registers[ARC_R59_REGNUM].names[1] = r59_alias;
|
|
|
|
arc_v2_core_reg_feature.registers[ARC_R58_REGNUM].names[1] = r58_alias;
|
|
|
|
arc_v2_core_reg_feature.registers[ARC_R59_REGNUM].names[1] = r59_alias;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Go through all the registers in REG_SET and check if they exist
|
|
|
|
in FEATURE. The TDESC_DATA is updated with the register number
|
|
|
|
in REG_SET if it is found in the feature. If a required register
|
|
|
|
is not found, this function returns false. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
arc_check_tdesc_feature (struct tdesc_arch_data *tdesc_data,
|
|
|
|
const struct tdesc_feature *feature,
|
|
|
|
const struct arc_register_feature *reg_set)
|
|
|
|
{
|
|
|
|
for (const auto ® : reg_set->registers)
|
2016-08-13 01:02:20 +08:00
|
|
|
{
|
2020-07-09 23:43:13 +08:00
|
|
|
bool found = false;
|
|
|
|
|
|
|
|
for (const char *name : reg.names)
|
2016-08-13 01:02:20 +08:00
|
|
|
{
|
2020-07-09 23:43:13 +08:00
|
|
|
found
|
|
|
|
= tdesc_numbered_register (feature, tdesc_data, reg.regnum, name);
|
2016-08-13 01:02:20 +08:00
|
|
|
|
2020-07-09 23:43:13 +08:00
|
|
|
if (found)
|
|
|
|
break;
|
2016-08-13 01:02:20 +08:00
|
|
|
}
|
2020-07-09 23:43:13 +08:00
|
|
|
|
|
|
|
if (!found && reg.required_p)
|
2016-08-13 01:02:20 +08:00
|
|
|
{
|
2020-07-09 23:43:13 +08:00
|
|
|
std::ostringstream reg_names;
|
|
|
|
for (std::size_t i = 0; i < reg.names.size(); ++i)
|
2016-08-13 01:02:20 +08:00
|
|
|
{
|
2020-07-09 23:43:13 +08:00
|
|
|
if (i == 0)
|
|
|
|
reg_names << "'" << reg.names[0] << "'";
|
|
|
|
else
|
|
|
|
reg_names << " or '" << reg.names[0] << "'";
|
2016-08-13 01:02:20 +08:00
|
|
|
}
|
2020-07-09 23:43:13 +08:00
|
|
|
arc_print (_("Error: Cannot find required register(s) %s "
|
|
|
|
"in feature '%s'.\n"), reg_names.str ().c_str (),
|
|
|
|
feature->name.c_str ());
|
|
|
|
return false;
|
2016-08-13 01:02:20 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-09 23:43:13 +08:00
|
|
|
return true;
|
|
|
|
}
|
2016-08-13 01:02:20 +08:00
|
|
|
|
2024-10-06 13:59:48 +08:00
|
|
|
/* Check for the existence of "lp_start" and "lp_end" in target description.
|
2020-07-09 23:44:01 +08:00
|
|
|
If both are present, assume there is hardware loop support in the target.
|
|
|
|
This can be improved by looking into "lpc_size" field of "isa_config"
|
|
|
|
auxiliary register. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
arc_check_for_hw_loops (const struct target_desc *tdesc,
|
|
|
|
struct tdesc_arch_data *data)
|
|
|
|
{
|
|
|
|
const auto feature_aux = tdesc_find_feature (tdesc, ARC_AUX_FEATURE_NAME);
|
|
|
|
const auto aux_regset = determine_aux_reg_feature_set ();
|
|
|
|
|
|
|
|
if (feature_aux == nullptr)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
bool hw_loop_p = false;
|
|
|
|
const auto lp_start_name =
|
|
|
|
aux_regset->registers[ARC_LP_START_REGNUM - ARC_FIRST_AUX_REGNUM].names[0];
|
|
|
|
const auto lp_end_name =
|
|
|
|
aux_regset->registers[ARC_LP_END_REGNUM - ARC_FIRST_AUX_REGNUM].names[0];
|
|
|
|
|
|
|
|
hw_loop_p = tdesc_numbered_register (feature_aux, data,
|
|
|
|
ARC_LP_START_REGNUM, lp_start_name);
|
|
|
|
hw_loop_p &= tdesc_numbered_register (feature_aux, data,
|
|
|
|
ARC_LP_END_REGNUM, lp_end_name);
|
|
|
|
|
|
|
|
return hw_loop_p;
|
|
|
|
}
|
|
|
|
|
2020-07-09 23:43:13 +08:00
|
|
|
/* Initialize target description for the ARC.
|
2016-08-13 01:02:20 +08:00
|
|
|
|
2020-07-09 23:43:13 +08:00
|
|
|
Returns true if input TDESC was valid and in this case it will assign TDESC
|
|
|
|
and TDESC_DATA output parameters. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
arc_tdesc_init (struct gdbarch_info info, const struct target_desc **tdesc,
|
2020-09-18 04:11:38 +08:00
|
|
|
tdesc_arch_data_up *tdesc_data)
|
2020-07-09 23:43:13 +08:00
|
|
|
{
|
|
|
|
const struct target_desc *tdesc_loc = info.target_desc;
|
2021-01-14 03:32:39 +08:00
|
|
|
arc_debug_printf ("Target description initialization.");
|
2020-07-09 23:43:13 +08:00
|
|
|
|
|
|
|
/* If target doesn't provide a description, use the default ones. */
|
|
|
|
if (!tdesc_has_registers (tdesc_loc))
|
2016-08-13 01:02:20 +08:00
|
|
|
{
|
2020-10-05 23:10:47 +08:00
|
|
|
arc_arch_features features
|
|
|
|
= arc_arch_features_create (info.abfd,
|
|
|
|
info.bfd_arch_info->mach);
|
2020-07-09 23:43:13 +08:00
|
|
|
tdesc_loc = arc_lookup_target_description (features);
|
|
|
|
}
|
|
|
|
gdb_assert (tdesc_loc != nullptr);
|
|
|
|
|
2021-01-14 03:32:39 +08:00
|
|
|
arc_debug_printf ("Have got a target description");
|
2020-07-09 23:43:13 +08:00
|
|
|
|
|
|
|
const struct tdesc_feature *feature_core
|
|
|
|
= tdesc_find_feature (tdesc_loc, ARC_CORE_FEATURE_NAME);
|
|
|
|
const struct tdesc_feature *feature_aux
|
|
|
|
= tdesc_find_feature (tdesc_loc, ARC_AUX_FEATURE_NAME);
|
|
|
|
|
|
|
|
/* Maybe there still is a chance to salvage the input. */
|
|
|
|
if (feature_core == nullptr)
|
|
|
|
feature_core = find_obsolete_core_names (tdesc_loc);
|
|
|
|
if (feature_aux == nullptr)
|
|
|
|
feature_aux = find_obsolete_aux_names (tdesc_loc);
|
|
|
|
|
|
|
|
if (feature_core == nullptr)
|
|
|
|
{
|
|
|
|
arc_print (_("Error: Cannot find required feature '%s' in supplied "
|
|
|
|
"target description.\n"), ARC_CORE_FEATURE_NAME);
|
|
|
|
return false;
|
2016-08-13 01:02:20 +08:00
|
|
|
}
|
|
|
|
|
2020-07-09 23:43:13 +08:00
|
|
|
if (feature_aux == nullptr)
|
2016-08-13 01:02:20 +08:00
|
|
|
{
|
2020-07-09 23:43:13 +08:00
|
|
|
arc_print (_("Error: Cannot find required feature '%s' in supplied "
|
|
|
|
"target description.\n"), ARC_AUX_FEATURE_NAME);
|
2019-04-25 06:24:05 +08:00
|
|
|
return false;
|
2016-08-13 01:02:20 +08:00
|
|
|
}
|
|
|
|
|
2020-07-09 23:43:13 +08:00
|
|
|
const arc_register_feature *arc_core_reg_feature
|
|
|
|
= determine_core_reg_feature_set (info.bfd_arch_info->mach);
|
|
|
|
const arc_register_feature *arc_aux_reg_feature
|
|
|
|
= determine_aux_reg_feature_set ();
|
|
|
|
|
2020-09-18 04:11:38 +08:00
|
|
|
tdesc_arch_data_up tdesc_data_loc = tdesc_data_alloc ();
|
2020-07-09 23:43:13 +08:00
|
|
|
|
|
|
|
arc_update_acc_reg_names (info.byte_order);
|
|
|
|
|
2020-09-18 04:11:38 +08:00
|
|
|
bool valid_p = arc_check_tdesc_feature (tdesc_data_loc.get (),
|
2020-07-09 23:43:13 +08:00
|
|
|
feature_core,
|
|
|
|
arc_core_reg_feature);
|
|
|
|
|
2020-09-18 04:11:38 +08:00
|
|
|
valid_p &= arc_check_tdesc_feature (tdesc_data_loc.get (),
|
2020-07-09 23:43:13 +08:00
|
|
|
feature_aux,
|
|
|
|
arc_aux_reg_feature);
|
|
|
|
|
|
|
|
if (!valid_p)
|
2016-08-13 01:02:20 +08:00
|
|
|
{
|
2021-01-14 03:32:39 +08:00
|
|
|
arc_debug_printf ("Target description is not valid");
|
2020-07-09 23:43:13 +08:00
|
|
|
return false;
|
2016-08-13 01:02:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
*tdesc = tdesc_loc;
|
2020-09-18 04:11:38 +08:00
|
|
|
*tdesc_data = std::move (tdesc_data_loc);
|
2016-08-13 01:02:20 +08:00
|
|
|
|
2019-04-25 06:24:05 +08:00
|
|
|
return true;
|
2016-08-13 01:02:20 +08:00
|
|
|
}
|
|
|
|
|
2018-04-24 03:41:27 +08:00
|
|
|
/* Implement the type_align gdbarch function. */
|
|
|
|
|
|
|
|
static ULONGEST
|
|
|
|
arc_type_align (struct gdbarch *gdbarch, struct type *type)
|
|
|
|
{
|
2020-05-15 01:46:38 +08:00
|
|
|
switch (type->code ())
|
gdb: Restructure type_align and gdbarch_type_align
This commit restructures the relationship between the type_align
function and the gdbarch_type_align method.
The problem being addressed with this commit is this; previously the
type_align function was structured so that for "basic" types (int,
float, etc) the gdbarch_type_align hook was called, which for
"compound" types (arrays, structs, etc) the common type_align code has
a fixed method for how to extract a "basic" type and would then call
itself on that "basic" type.
The problem is that if an architecture wants to modify the alignment
rules for a "compound" type then this is not currently possible.
In the revised structure, all types pass through the
gdbarch_type_align method. If this method returns 0 then this
indicates that the architecture has no special rules for this type,
and GDB should apply the default rules for alignment. However, the
architecture is free to provide an alignment for any type, both
"basic" and "compound".
After this commit the default alignment rules now all live in the
type_align function, the default_type_align only ever returns 0,
meaning apply the default rules.
I've updated the 3 targets (arc, i386, and nios2) that already
override the gdbarch_type_align method to fit the new scheme.
Tested on X86-64/GNU Linux with no regressions.
gdb/ChangeLog:
* arc-tdep.c (arc_type_align): Provide alignment for basic types,
return 0 for other types.
* arch-utils.c (default_type_align): Always return 0.
* gdbarch.h: Regenerate.
* gdbarch.sh (type_align): Extend comment.
* gdbtypes.c (type_align): Add additional comments, always call
gdbarch_type_align before applying the default rules.
* i386-tdep.c (i386_type_align): Return 0 as the default rule,
generic code will then apply a suitable default.
* nios2-tdep.c (nios2_type_align): Provide alignment for basic
types, return 0 for other types.
2019-02-23 04:49:04 +08:00
|
|
|
{
|
|
|
|
case TYPE_CODE_PTR:
|
|
|
|
case TYPE_CODE_FUNC:
|
|
|
|
case TYPE_CODE_FLAGS:
|
|
|
|
case TYPE_CODE_INT:
|
|
|
|
case TYPE_CODE_RANGE:
|
|
|
|
case TYPE_CODE_FLT:
|
|
|
|
case TYPE_CODE_ENUM:
|
|
|
|
case TYPE_CODE_REF:
|
|
|
|
case TYPE_CODE_RVALUE_REF:
|
|
|
|
case TYPE_CODE_CHAR:
|
|
|
|
case TYPE_CODE_BOOL:
|
|
|
|
case TYPE_CODE_DECFLOAT:
|
|
|
|
case TYPE_CODE_METHODPTR:
|
|
|
|
case TYPE_CODE_MEMBERPTR:
|
|
|
|
type = check_typedef (type);
|
2022-09-21 23:05:21 +08:00
|
|
|
return std::min<ULONGEST> (4, type->length ());
|
gdb: Restructure type_align and gdbarch_type_align
This commit restructures the relationship between the type_align
function and the gdbarch_type_align method.
The problem being addressed with this commit is this; previously the
type_align function was structured so that for "basic" types (int,
float, etc) the gdbarch_type_align hook was called, which for
"compound" types (arrays, structs, etc) the common type_align code has
a fixed method for how to extract a "basic" type and would then call
itself on that "basic" type.
The problem is that if an architecture wants to modify the alignment
rules for a "compound" type then this is not currently possible.
In the revised structure, all types pass through the
gdbarch_type_align method. If this method returns 0 then this
indicates that the architecture has no special rules for this type,
and GDB should apply the default rules for alignment. However, the
architecture is free to provide an alignment for any type, both
"basic" and "compound".
After this commit the default alignment rules now all live in the
type_align function, the default_type_align only ever returns 0,
meaning apply the default rules.
I've updated the 3 targets (arc, i386, and nios2) that already
override the gdbarch_type_align method to fit the new scheme.
Tested on X86-64/GNU Linux with no regressions.
gdb/ChangeLog:
* arc-tdep.c (arc_type_align): Provide alignment for basic types,
return 0 for other types.
* arch-utils.c (default_type_align): Always return 0.
* gdbarch.h: Regenerate.
* gdbarch.sh (type_align): Extend comment.
* gdbtypes.c (type_align): Add additional comments, always call
gdbarch_type_align before applying the default rules.
* i386-tdep.c (i386_type_align): Return 0 as the default rule,
generic code will then apply a suitable default.
* nios2-tdep.c (nios2_type_align): Provide alignment for basic
types, return 0 for other types.
2019-02-23 04:49:04 +08:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
2018-04-24 03:41:27 +08:00
|
|
|
}
|
|
|
|
|
2016-08-13 01:02:20 +08:00
|
|
|
/* Implement the "init" gdbarch method. */
|
|
|
|
|
|
|
|
static struct gdbarch *
|
|
|
|
arc_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
|
|
|
|
{
|
|
|
|
const struct target_desc *tdesc;
|
2020-09-18 04:11:38 +08:00
|
|
|
tdesc_arch_data_up tdesc_data;
|
2016-08-13 01:02:20 +08:00
|
|
|
|
2021-01-14 03:32:39 +08:00
|
|
|
arc_debug_printf ("Architecture initialization.");
|
2016-08-13 01:02:20 +08:00
|
|
|
|
|
|
|
if (!arc_tdesc_init (info, &tdesc, &tdesc_data))
|
2020-07-09 23:44:01 +08:00
|
|
|
return nullptr;
|
2016-08-13 01:02:20 +08:00
|
|
|
|
2016-10-12 19:36:44 +08:00
|
|
|
/* Allocate the ARC-private target-dependent information structure, and the
|
|
|
|
GDB target-independent information structure. */
|
gdb: make gdbarch_alloc take ownership of the tdep
It's currently not clear how the ownership of gdbarch_tdep objects
works. In fact, nothing ever takes ownership of it. This is mostly
fine because we never free gdbarch objects, and thus we never free
gdbarch_tdep objects. There is an exception to that however: when
initialization fails, we do free the gdbarch object that is not going to
be used, and we free the tdep too. Currently, i386 and s390 do it.
To make things clearer, change gdbarch_alloc so that it takes ownership
of the tdep. The tdep is thus automatically freed if the gdbarch is
freed.
Change all gdbarch initialization functions to pass a new gdbarch_tdep
object to gdbarch_alloc and then retrieve a non-owning reference from
the gdbarch object.
Before this patch, the xtensa architecture had a single global instance
of xtensa_gdbarch_tdep. Since we need to pass a dynamically allocated
gdbarch_tdep_base instance to gdbarch_alloc, remove this global
instance, and dynamically allocate one as needed, like we do for all
other architectures. Make the `rmap` array externally visible and
rename it to the less collision-prone `xtensa_rmap` name.
Change-Id: Id3d70493ef80ce4bdff701c57636f4c79ed8aea2
Approved-By: Andrew Burgess <aburgess@redhat.com>
2022-10-03 23:15:14 +08:00
|
|
|
gdbarch *gdbarch
|
|
|
|
= gdbarch_alloc (&info, gdbarch_tdep_up (new arc_gdbarch_tdep));
|
|
|
|
arc_gdbarch_tdep *tdep = gdbarch_tdep<arc_gdbarch_tdep> (gdbarch);
|
2016-10-12 19:36:44 +08:00
|
|
|
tdep->jb_pc = -1; /* No longjmp support by default. */
|
2020-09-18 04:11:38 +08:00
|
|
|
tdep->has_hw_loops = arc_check_for_hw_loops (tdesc, tdesc_data.get ());
|
2016-08-13 01:02:20 +08:00
|
|
|
|
|
|
|
/* Data types. */
|
|
|
|
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);
|
2018-04-24 03:41:27 +08:00
|
|
|
set_gdbarch_type_align (gdbarch, arc_type_align);
|
2016-08-13 01:02:20 +08:00
|
|
|
set_gdbarch_float_bit (gdbarch, 32);
|
|
|
|
set_gdbarch_float_format (gdbarch, floatformats_ieee_single);
|
|
|
|
set_gdbarch_double_bit (gdbarch, 64);
|
|
|
|
set_gdbarch_double_format (gdbarch, floatformats_ieee_double);
|
|
|
|
set_gdbarch_ptr_bit (gdbarch, 32);
|
|
|
|
set_gdbarch_addr_bit (gdbarch, 32);
|
|
|
|
set_gdbarch_char_signed (gdbarch, 0);
|
|
|
|
|
|
|
|
set_gdbarch_write_pc (gdbarch, arc_write_pc);
|
|
|
|
|
|
|
|
set_gdbarch_virtual_frame_pointer (gdbarch, arc_virtual_frame_pointer);
|
|
|
|
|
|
|
|
/* tdesc_use_registers expects gdbarch_num_regs to return number of registers
|
|
|
|
parsed by gdbarch_init, and then it will add all of the remaining
|
|
|
|
registers and will increase number of registers. */
|
|
|
|
set_gdbarch_num_regs (gdbarch, ARC_LAST_REGNUM + 1);
|
|
|
|
set_gdbarch_num_pseudo_regs (gdbarch, 0);
|
|
|
|
set_gdbarch_sp_regnum (gdbarch, ARC_SP_REGNUM);
|
|
|
|
set_gdbarch_pc_regnum (gdbarch, ARC_PC_REGNUM);
|
|
|
|
set_gdbarch_ps_regnum (gdbarch, ARC_STATUS32_REGNUM);
|
|
|
|
set_gdbarch_fp0_regnum (gdbarch, -1); /* No FPU registers. */
|
|
|
|
|
|
|
|
set_gdbarch_push_dummy_call (gdbarch, arc_push_dummy_call);
|
|
|
|
set_gdbarch_push_dummy_code (gdbarch, arc_push_dummy_code);
|
|
|
|
|
|
|
|
set_gdbarch_cannot_fetch_register (gdbarch, arc_cannot_fetch_register);
|
|
|
|
set_gdbarch_cannot_store_register (gdbarch, arc_cannot_store_register);
|
|
|
|
|
|
|
|
set_gdbarch_believe_pcc_promotion (gdbarch, 1);
|
|
|
|
|
|
|
|
set_gdbarch_return_value (gdbarch, arc_return_value);
|
|
|
|
|
|
|
|
set_gdbarch_skip_prologue (gdbarch, arc_skip_prologue);
|
|
|
|
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
|
|
|
|
|
2016-11-03 22:35:14 +08:00
|
|
|
set_gdbarch_breakpoint_kind_from_pc (gdbarch, arc_breakpoint_kind_from_pc);
|
|
|
|
set_gdbarch_sw_breakpoint_from_kind (gdbarch, arc_sw_breakpoint_from_kind);
|
2016-08-13 01:02:20 +08:00
|
|
|
|
|
|
|
/* On ARC 600 BRK_S instruction advances PC, unlike other ARC cores. */
|
|
|
|
if (!arc_mach_is_arc600 (gdbarch))
|
|
|
|
set_gdbarch_decr_pc_after_break (gdbarch, 0);
|
|
|
|
else
|
|
|
|
set_gdbarch_decr_pc_after_break (gdbarch, 2);
|
|
|
|
|
|
|
|
set_gdbarch_frame_align (gdbarch, arc_frame_align);
|
|
|
|
|
2017-02-10 19:11:55 +08:00
|
|
|
set_gdbarch_print_insn (gdbarch, arc_delayed_print_insn);
|
|
|
|
|
2016-08-13 01:02:20 +08:00
|
|
|
set_gdbarch_cannot_step_breakpoint (gdbarch, 1);
|
|
|
|
|
|
|
|
/* "nonsteppable" watchpoint means that watchpoint triggers before
|
|
|
|
instruction is committed, therefore it is required to remove watchpoint
|
|
|
|
to step though instruction that triggers it. ARC watchpoints trigger
|
|
|
|
only after instruction is committed, thus there is no need to remove
|
|
|
|
them. In fact on ARC watchpoint for memory writes may trigger with more
|
|
|
|
significant delay, like one or two instructions, depending on type of
|
|
|
|
memory where write is performed (CCM or external) and next instruction
|
|
|
|
after the memory write. */
|
|
|
|
set_gdbarch_have_nonsteppable_watchpoint (gdbarch, 0);
|
|
|
|
|
|
|
|
/* This doesn't include possible long-immediate value. */
|
|
|
|
set_gdbarch_max_insn_length (gdbarch, 4);
|
|
|
|
|
|
|
|
/* Frame unwinders and sniffers. */
|
|
|
|
dwarf2_frame_set_init_reg (gdbarch, arc_dwarf2_frame_init_reg);
|
|
|
|
dwarf2_append_unwinders (gdbarch);
|
2016-08-23 00:39:46 +08:00
|
|
|
frame_unwind_append_unwinder (gdbarch, &arc_sigtramp_frame_unwind);
|
2016-08-13 01:02:20 +08:00
|
|
|
frame_unwind_append_unwinder (gdbarch, &arc_frame_unwind);
|
|
|
|
frame_base_set_default (gdbarch, &arc_normal_base);
|
|
|
|
|
|
|
|
/* Setup stuff specific to a particular environment (baremetal or Linux).
|
|
|
|
It can override functions set earlier. */
|
|
|
|
gdbarch_init_osabi (info, gdbarch);
|
|
|
|
|
gdb: fix gdbarch_tdep ODR violation
I would like to be able to use non-trivial types in gdbarch_tdep types.
This is not possible at the moment (in theory), because of the one
definition rule.
To allow it, rename all gdbarch_tdep types to <arch>_gdbarch_tdep, and
make them inherit from a gdbarch_tdep base class. The inheritance is
necessary to be able to pass pointers to all these <arch>_gdbarch_tdep
objects to gdbarch_alloc, which takes a pointer to gdbarch_tdep.
These objects are never deleted through a base class pointer, so I
didn't include a virtual destructor. In the future, if gdbarch objects
deletable, I could imagine that the gdbarch_tdep objects could become
owned by the gdbarch objects, and then it would become useful to have a
virtual destructor (so that the gdbarch object can delete the owned
gdbarch_tdep object). But that's not necessary right now.
It turns out that RISC-V already has a gdbarch_tdep that is
non-default-constructible, so that provides a good motivation for this
change.
Most changes are fairly straightforward, mostly needing to add some
casts all over the place. There is however the xtensa architecture,
doing its own little weird thing to define its gdbarch_tdep. I did my
best to adapt it, but I can't test those changes.
Change-Id: Ic001903f91ddd106bd6ca09a79dabe8df2d69f3b
2021-11-16 00:29:39 +08:00
|
|
|
if (tdep->jb_pc >= 0)
|
2016-10-12 19:36:44 +08:00
|
|
|
set_gdbarch_get_longjmp_target (gdbarch, arc_get_longjmp_target);
|
|
|
|
|
2017-02-10 19:11:55 +08:00
|
|
|
/* Disassembler options. Enforce CPU if it was specified in XML target
|
|
|
|
description, otherwise use default method of determining CPU (ELF private
|
|
|
|
header). */
|
|
|
|
if (info.target_desc != NULL)
|
|
|
|
{
|
|
|
|
const struct bfd_arch_info *tdesc_arch
|
|
|
|
= tdesc_architecture (info.target_desc);
|
|
|
|
if (tdesc_arch != NULL)
|
|
|
|
{
|
|
|
|
/* FIXME: It is not really good to change disassembler options
|
|
|
|
behind the scene, because that might override options
|
|
|
|
specified by the user. However as of now ARC doesn't support
|
|
|
|
`set disassembler-options' hence this code is the only place
|
|
|
|
where options are changed. It also changes options for all
|
|
|
|
existing gdbarches, which also can be problematic, if
|
|
|
|
arc_gdbarch_init will start reusing existing gdbarch
|
|
|
|
instances. */
|
2017-06-28 00:12:14 +08:00
|
|
|
/* Target description specifies a BFD architecture, which is
|
|
|
|
different from ARC cpu, as accepted by disassembler (and most
|
|
|
|
other ARC tools), because cpu values are much more fine grained -
|
|
|
|
there can be multiple cpu values per single BFD architecture. As
|
|
|
|
a result this code should translate architecture to some cpu
|
|
|
|
value. Since there is no info on exact cpu configuration, it is
|
|
|
|
best to use the most feature-rich CPU, so that disassembler will
|
|
|
|
recognize all instructions available to the specified
|
|
|
|
architecture. */
|
|
|
|
switch (tdesc_arch->mach)
|
|
|
|
{
|
|
|
|
case bfd_mach_arc_arc601:
|
2024-03-22 01:15:56 +08:00
|
|
|
arc_disassembler_options = "cpu=arc601";
|
2017-06-28 00:12:14 +08:00
|
|
|
break;
|
|
|
|
case bfd_mach_arc_arc600:
|
2024-03-22 01:15:56 +08:00
|
|
|
arc_disassembler_options = "cpu=arc600";
|
2017-06-28 00:12:14 +08:00
|
|
|
break;
|
|
|
|
case bfd_mach_arc_arc700:
|
2024-03-22 01:15:56 +08:00
|
|
|
arc_disassembler_options = "cpu=arc700";
|
2017-06-28 00:12:14 +08:00
|
|
|
break;
|
|
|
|
case bfd_mach_arc_arcv2:
|
|
|
|
/* Machine arcv2 has three arches: ARCv2, EM and HS; where ARCv2
|
|
|
|
is treated as EM. */
|
|
|
|
if (arc_arch_is_hs (tdesc_arch))
|
2024-03-22 01:15:56 +08:00
|
|
|
arc_disassembler_options = "cpu=hs38_linux";
|
2017-06-28 00:12:14 +08:00
|
|
|
else
|
2024-03-22 01:15:56 +08:00
|
|
|
arc_disassembler_options = "cpu=em4_fpuda";
|
2017-06-28 00:12:14 +08:00
|
|
|
break;
|
|
|
|
default:
|
2024-03-22 01:15:56 +08:00
|
|
|
arc_disassembler_options = "";
|
2017-06-28 00:12:14 +08:00
|
|
|
break;
|
|
|
|
}
|
2017-02-10 19:11:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-06 05:07:38 +08:00
|
|
|
set_gdbarch_disassembler_options (gdbarch, &arc_disassembler_options);
|
|
|
|
set_gdbarch_valid_disassembler_options (gdbarch,
|
|
|
|
disassembler_options_arc ());
|
|
|
|
|
2020-09-18 04:11:38 +08:00
|
|
|
tdesc_use_registers (gdbarch, tdesc, std::move (tdesc_data));
|
2016-08-13 01:02:20 +08:00
|
|
|
|
|
|
|
return gdbarch;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Implement the "dump_tdep" gdbarch method. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
arc_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
|
|
|
|
{
|
gdb: move the type cast into gdbarch_tdep
I built GDB for all targets on a x86-64/GNU-Linux system, and
then (accidentally) passed GDB a RISC-V binary, and asked GDB to "run"
the binary on the native target. I got this error:
(gdb) show architecture
The target architecture is set to "auto" (currently "i386").
(gdb) file /tmp/hello.rv32.exe
Reading symbols from /tmp/hello.rv32.exe...
(gdb) show architecture
The target architecture is set to "auto" (currently "riscv:rv32").
(gdb) run
Starting program: /tmp/hello.rv32.exe
../../src/gdb/i387-tdep.c:596: internal-error: i387_supply_fxsave: Assertion `tdep->st0_regnum >= I386_ST0_REGNUM' failed.
What's going on here is this; initially the architecture is i386, this
is based on the default architecture, which is set based on the native
target. After loading the RISC-V executable the architecture of the
current inferior is updated based on the architecture of the
executable.
When we "run", GDB does a fork & exec, with the inferior being
controlled through ptrace. GDB sees an initial stop from the inferior
as soon as the inferior comes to life. In response to this stop GDB
ends up calling save_stop_reason (linux-nat.c), which ends up trying
to read register from the inferior, to do this we end up calling
target_ops::fetch_registers, which, for the x86-64 native target,
calls amd64_linux_nat_target::fetch_registers.
After this I eventually end up in i387_supply_fxsave, different x86
based targets will end in different functions to fetch registers, but
it doesn't really matter which function we end up in, the problem is
this line, which is repeated in many places:
i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (arch);
The problem here is that the ARCH in this line comes from the current
inferior, which, as we discussed above, will be a RISC-V gdbarch, the
tdep field will actually be of type riscv_gdbarch_tdep, not
i386_gdbarch_tdep. After this cast we are relying on undefined
behaviour, in my case I happen to trigger an assert, but this might
not always be the case.
The thing I tried that exposed this problem was of course, trying to
start an executable of the wrong architecture on a native target. I
don't think that the correct solution for this problem is to detect,
at the point of cast, that the gdbarch_tdep object is of the wrong
type, but, I did wonder, is there a way that we could protect
ourselves from incorrectly casting the gdbarch_tdep object?
I think that there is something we can do here, and this commit is the
first step in that direction, though no actual check is added by this
commit.
This commit can be split into two parts:
(1) In gdbarch.h and arch-utils.c. In these files I have modified
gdbarch_tdep (the function) so that it now takes a template argument,
like this:
template<typename TDepType>
static inline TDepType *
gdbarch_tdep (struct gdbarch *gdbarch)
{
struct gdbarch_tdep *tdep = gdbarch_tdep_1 (gdbarch);
return static_cast<TDepType *> (tdep);
}
After this change we are no better protected, but the cast is now
done within the gdbarch_tdep function rather than at the call sites,
this leads to the second, much larger change in this commit,
(2) Everywhere gdbarch_tdep is called, we make changes like this:
- i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (arch);
+ i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (arch);
There should be no functional change after this commit.
In the next commit I will build on this change to add an assertion in
gdbarch_tdep that checks we are casting to the correct type.
2022-05-19 20:20:17 +08:00
|
|
|
arc_gdbarch_tdep *tdep = gdbarch_tdep<arc_gdbarch_tdep> (gdbarch);
|
2016-10-12 19:36:44 +08:00
|
|
|
|
2022-01-03 02:46:15 +08:00
|
|
|
gdb_printf (file, "arc_dump_tdep: jb_pc = %i\n", tdep->jb_pc);
|
2021-12-27 04:26:58 +08:00
|
|
|
|
2022-01-03 02:46:15 +08:00
|
|
|
gdb_printf (file, "arc_dump_tdep: is_sigtramp = <%s>\n",
|
|
|
|
host_address_to_string (tdep->is_sigtramp));
|
|
|
|
gdb_printf (file, "arc_dump_tdep: sigcontext_addr = <%s>\n",
|
|
|
|
host_address_to_string (tdep->sigcontext_addr));
|
|
|
|
gdb_printf (file, "arc_dump_tdep: sc_reg_offset = <%s>\n",
|
|
|
|
host_address_to_string (tdep->sc_reg_offset));
|
|
|
|
gdb_printf (file, "arc_dump_tdep: sc_num_regs = %d\n",
|
|
|
|
tdep->sc_num_regs);
|
2016-08-13 01:02:20 +08:00
|
|
|
}
|
|
|
|
|
2017-02-10 19:12:06 +08:00
|
|
|
/* This command accepts single argument - address of instruction to
|
|
|
|
disassemble. */
|
|
|
|
|
|
|
|
static void
|
2017-09-10 10:59:14 +08:00
|
|
|
dump_arc_instruction_command (const char *args, int from_tty)
|
2017-02-10 19:12:06 +08:00
|
|
|
{
|
|
|
|
struct value *val;
|
|
|
|
if (args != NULL && strlen (args) > 0)
|
2023-04-28 21:24:59 +08:00
|
|
|
val = parse_expression (args)->evaluate ();
|
2017-02-10 19:12:06 +08:00
|
|
|
else
|
|
|
|
val = access_value_history (0);
|
2023-02-12 23:04:07 +08:00
|
|
|
val->record_latest ();
|
2017-02-10 19:12:06 +08:00
|
|
|
|
|
|
|
CORE_ADDR address = value_as_address (val);
|
|
|
|
struct arc_instruction insn;
|
2023-09-30 02:24:38 +08:00
|
|
|
gdb_non_printing_memory_disassembler dis (current_inferior ()->arch ());
|
gdb: refactor the non-printing disassemblers
This commit started from an observation I made while working on some
other disassembler patches, that is, that the function
gdb_buffered_insn_length, is broken ... sort of.
I noticed that the gdb_buffered_insn_length function doesn't set up
the application data field if the disassemble_info structure.
Further, I noticed that some architectures, for example, ARM, require
that the application_data field be set, see gdb_print_insn_arm in
arm-tdep.c.
And so, if we ever use gdb_buffered_insn_length for ARM, then GDB will
likely crash. Which is why I said only "sort of" broken. Right now
we don't use gdb_buffered_insn_length with ARM, so maybe it isn't
broken yet?
Anyway to prove to myself that there was a problem here I extended the
disassembler self tests in disasm-selftests.c to include a test of
gdb_buffered_insn_length. As I run the test for all architectures, I
do indeed see GDB crash for ARM.
To fix this we need gdb_buffered_insn_length to create a disassembler
that inherits from gdb_disassemble_info, but we also need this new
disassembler to not print anything.
And so, I introduce a new gdb_non_printing_disassembler class, this is
a disassembler that doesn't print anything to the output stream.
I then observed that both ARC and S12Z also create non-printing
disassemblers, but these are slightly different. While the
disassembler in gdb_non_printing_disassembler reads the instruction
from a buffer, the ARC and S12Z disassemblers read from target memory
using target_read_code.
And so, I further split gdb_non_printing_disassembler into two
sub-classes, gdb_non_printing_memory_disassembler and
gdb_non_printing_buffer_disassembler.
The new selftests now pass, but otherwise, there should be no user
visible changes after this commit.
2022-04-04 22:48:19 +08:00
|
|
|
arc_insn_decode (address, dis.disasm_info (), arc_delayed_print_insn, &insn);
|
2017-02-10 19:12:06 +08:00
|
|
|
arc_insn_dump (insn);
|
|
|
|
}
|
|
|
|
|
2020-01-14 03:01:38 +08:00
|
|
|
void _initialize_arc_tdep ();
|
2016-08-13 01:02:20 +08:00
|
|
|
void
|
2020-01-14 03:01:38 +08:00
|
|
|
_initialize_arc_tdep ()
|
2016-08-13 01:02:20 +08:00
|
|
|
{
|
|
|
|
gdbarch_register (bfd_arch_arc, arc_gdbarch_init, arc_dump_tdep);
|
|
|
|
|
|
|
|
/* Register ARC-specific commands with gdb. */
|
|
|
|
|
2017-02-10 19:12:01 +08:00
|
|
|
/* Add root prefix command for "maintenance print arc" commands. */
|
2022-05-27 21:52:16 +08:00
|
|
|
add_basic_prefix_cmd ("arc", class_maintenance,
|
|
|
|
_("ARC-specific maintenance commands for printing GDB "
|
|
|
|
"internal state."),
|
|
|
|
&maintenance_print_arc_list,
|
|
|
|
0, &maintenanceprintlist);
|
2017-02-10 19:12:01 +08:00
|
|
|
|
2017-02-10 19:12:06 +08:00
|
|
|
add_cmd ("arc-instruction", class_maintenance,
|
|
|
|
dump_arc_instruction_command,
|
|
|
|
_("Dump arc_instruction structure for specified address."),
|
|
|
|
&maintenance_print_arc_list);
|
|
|
|
|
2016-08-13 01:02:20 +08:00
|
|
|
/* Debug internals for ARC GDB. */
|
2021-01-14 03:32:23 +08:00
|
|
|
add_setshow_boolean_cmd ("arc", class_maintenance,
|
|
|
|
&arc_debug,
|
|
|
|
_("Set ARC specific debugging."),
|
|
|
|
_("Show ARC specific debugging."),
|
|
|
|
_("When set, ARC specific debugging is enabled."),
|
|
|
|
NULL, NULL, &setdebuglist, &showdebuglist);
|
2016-08-13 01:02:20 +08:00
|
|
|
}
|