2011-08-14 22:03:45 +08:00
|
|
|
/* Target dependent code for GDB on TI C6x systems.
|
|
|
|
|
2024-01-12 23:30:44 +08:00
|
|
|
Copyright (C) 2010-2024 Free Software Foundation, Inc.
|
2011-08-14 22:03:45 +08:00
|
|
|
Contributed by Andrew Jenner <andrew@codesourcery.com>
|
|
|
|
Contributed by Yao Qi <yao@codesourcery.com>
|
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
|
2024-04-23 04:10:14 +08:00
|
|
|
#include "extract-store-integer.h"
|
2011-08-14 22:03:45 +08:00
|
|
|
#include "frame.h"
|
|
|
|
#include "frame-unwind.h"
|
|
|
|
#include "frame-base.h"
|
|
|
|
#include "trad-frame.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"
|
2011-08-14 22:03:45 +08:00
|
|
|
#include "symtab.h"
|
|
|
|
#include "inferior.h"
|
|
|
|
#include "gdbtypes.h"
|
|
|
|
#include "gdbcore.h"
|
2024-04-24 03:22:44 +08:00
|
|
|
#include "cli/cli-cmds.h"
|
2011-08-14 22:03:45 +08:00
|
|
|
#include "target.h"
|
|
|
|
#include "dis-asm.h"
|
|
|
|
#include "regcache.h"
|
|
|
|
#include "value.h"
|
|
|
|
#include "symfile.h"
|
|
|
|
#include "arch-utils.h"
|
|
|
|
#include "glibc-tdep.h"
|
|
|
|
#include "infcall.h"
|
|
|
|
#include "regset.h"
|
|
|
|
#include "tramp-frame.h"
|
|
|
|
#include "linux-tdep.h"
|
|
|
|
#include "solib.h"
|
|
|
|
#include "objfiles.h"
|
|
|
|
#include "osabi.h"
|
|
|
|
#include "tic6x-tdep.h"
|
|
|
|
#include "language.h"
|
|
|
|
#include "target-descriptions.h"
|
gdb: Use std::min and std::max throughout
Otherwise including <string> or some other C++ header is broken.
E.g.:
In file included from /opt/gcc/include/c++/7.0.0/bits/char_traits.h:39:0,
from /opt/gcc/include/c++/7.0.0/string:40,
from /home/pedro/gdb/mygit/cxx-convertion/src/gdb/infrun.c:68:
/opt/gcc/include/c++/7.0.0/bits/stl_algobase.h:243:56: error: macro "min" passed 3 arguments, but takes just 2
min(const _Tp& __a, const _Tp& __b, _Compare __comp)
^
/opt/gcc/include/c++/7.0.0/bits/stl_algobase.h:265:56: error: macro "max" passed 3 arguments, but takes just 2
max(const _Tp& __a, const _Tp& __b, _Compare __comp)
^
In file included from .../src/gdb/infrun.c:21:0:
To the best of my grepping abilities, I believe I adjusted all min/max
calls.
gdb/ChangeLog:
2016-09-16 Pedro Alves <palves@redhat.com>
* defs.h (min, max): Delete.
* aarch64-tdep.c: Include <algorithm> and use std::min and
std::max throughout.
* aarch64-tdep.c: Likewise.
* alpha-tdep.c: Likewise.
* amd64-tdep.c: Likewise.
* amd64-windows-tdep.c: Likewise.
* arm-tdep.c: Likewise.
* avr-tdep.c: Likewise.
* breakpoint.c: Likewise.
* btrace.c: Likewise.
* ctf.c: Likewise.
* disasm.c: Likewise.
* doublest.c: Likewise.
* dwarf2loc.c: Likewise.
* dwarf2read.c: Likewise.
* environ.c: Likewise.
* exec.c: Likewise.
* f-exp.y: Likewise.
* findcmd.c: Likewise.
* ft32-tdep.c: Likewise.
* gcore.c: Likewise.
* hppa-tdep.c: Likewise.
* i386-darwin-tdep.c: Likewise.
* i386-tdep.c: Likewise.
* linux-thread-db.c: Likewise.
* lm32-tdep.c: Likewise.
* m32r-tdep.c: Likewise.
* m88k-tdep.c: Likewise.
* memrange.c: Likewise.
* minidebug.c: Likewise.
* mips-tdep.c: Likewise.
* moxie-tdep.c: Likewise.
* nds32-tdep.c: Likewise.
* nios2-tdep.c: Likewise.
* nto-procfs.c: Likewise.
* parse.c: Likewise.
* ppc-sysv-tdep.c: Likewise.
* probe.c: Likewise.
* record-btrace.c: Likewise.
* remote.c: Likewise.
* rs6000-tdep.c: Likewise.
* rx-tdep.c: Likewise.
* s390-linux-nat.c: Likewise.
* s390-linux-tdep.c: Likewise.
* ser-tcp.c: Likewise.
* sh-tdep.c: Likewise.
* sh64-tdep.c: Likewise.
* source.c: Likewise.
* sparc-tdep.c: Likewise.
* symfile.c: Likewise.
* target-memory.c: Likewise.
* target.c: Likewise.
* tic6x-tdep.c: Likewise.
* tilegx-tdep.c: Likewise.
* tracefile-tfile.c: Likewise.
* tracepoint.c: Likewise.
* valprint.c: Likewise.
* value.c: Likewise.
* xtensa-tdep.c: Likewise.
* cli/cli-cmds.c: Likewise.
* compile/compile-object-load.c: Likewise.
2016-09-17 02:55:17 +08:00
|
|
|
#include <algorithm>
|
2011-08-14 22:03:45 +08:00
|
|
|
|
|
|
|
#define TIC6X_OPCODE_SIZE 4
|
|
|
|
#define TIC6X_FETCH_PACKET_SIZE 32
|
|
|
|
|
|
|
|
#define INST_S_BIT(INST) ((INST >> 1) & 1)
|
|
|
|
#define INST_X_BIT(INST) ((INST >> 12) & 1)
|
|
|
|
|
2011-08-16 12:15:23 +08:00
|
|
|
const gdb_byte tic6x_bkpt_illegal_opcode_be[] = { 0x56, 0x45, 0x43, 0x14 };
|
|
|
|
const gdb_byte tic6x_bkpt_illegal_opcode_le[] = { 0x14, 0x43, 0x45, 0x56 };
|
|
|
|
|
2011-08-14 22:03:45 +08:00
|
|
|
struct tic6x_unwind_cache
|
|
|
|
{
|
|
|
|
/* The frame's base, optionally used by the high-level debug info. */
|
|
|
|
CORE_ADDR base;
|
|
|
|
|
|
|
|
/* The previous frame's inner most stack address. Used as this
|
|
|
|
frame ID's stack_addr. */
|
|
|
|
CORE_ADDR cfa;
|
|
|
|
|
|
|
|
/* The address of the first instruction in this function */
|
|
|
|
CORE_ADDR pc;
|
|
|
|
|
|
|
|
/* Which register holds the return address for the frame. */
|
|
|
|
int return_regnum;
|
|
|
|
|
|
|
|
/* The offset of register saved on stack. If register is not saved, the
|
|
|
|
corresponding element is -1. */
|
|
|
|
CORE_ADDR reg_saved[TIC6X_NUM_CORE_REGS];
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Name of TI C6x core registers. */
|
|
|
|
static const char *const tic6x_register_names[] =
|
|
|
|
{
|
|
|
|
"A0", "A1", "A2", "A3", /* 0 1 2 3 */
|
|
|
|
"A4", "A5", "A6", "A7", /* 4 5 6 7 */
|
|
|
|
"A8", "A9", "A10", "A11", /* 8 9 10 11 */
|
|
|
|
"A12", "A13", "A14", "A15", /* 12 13 14 15 */
|
|
|
|
"B0", "B1", "B2", "B3", /* 16 17 18 19 */
|
|
|
|
"B4", "B5", "B6", "B7", /* 20 21 22 23 */
|
|
|
|
"B8", "B9", "B10", "B11", /* 24 25 26 27 */
|
|
|
|
"B12", "B13", "B14", "B15", /* 28 29 30 31 */
|
|
|
|
"CSR", "PC", /* 32 33 */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* This array maps the arguments to the register number which passes argument
|
|
|
|
in function call according to C6000 ELF ABI. */
|
|
|
|
static const int arg_regs[] = { 4, 20, 6, 22, 8, 24, 10, 26, 12, 28 };
|
|
|
|
|
|
|
|
/* This is the implementation of gdbarch method register_name. */
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
tic6x_register_name (struct gdbarch *gdbarch, int regno)
|
|
|
|
{
|
|
|
|
if (tdesc_has_registers (gdbarch_target_desc (gdbarch)))
|
|
|
|
return tdesc_register_name (gdbarch, regno);
|
|
|
|
else if (regno >= ARRAY_SIZE (tic6x_register_names))
|
|
|
|
return "";
|
|
|
|
else
|
|
|
|
return tic6x_register_names[regno];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is the implementation of gdbarch method register_type. */
|
|
|
|
|
|
|
|
static struct type *
|
|
|
|
tic6x_register_type (struct gdbarch *gdbarch, int regno)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (regno == TIC6X_PC_REGNUM)
|
|
|
|
return builtin_type (gdbarch)->builtin_func_ptr;
|
|
|
|
else
|
|
|
|
return builtin_type (gdbarch)->builtin_uint32;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tic6x_setup_default (struct tic6x_unwind_cache *cache)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < TIC6X_NUM_CORE_REGS; i++)
|
|
|
|
cache->reg_saved[i] = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned long tic6x_fetch_instruction (struct gdbarch *, CORE_ADDR);
|
|
|
|
static int tic6x_register_number (int reg, int side, int crosspath);
|
|
|
|
|
|
|
|
/* Do a full analysis of the prologue at START_PC and update CACHE accordingly.
|
|
|
|
Bail out early if CURRENT_PC is reached. Returns the address of the first
|
|
|
|
instruction after the prologue. */
|
|
|
|
|
2012-03-02 08:06:13 +08:00
|
|
|
static CORE_ADDR
|
2011-08-14 22:03:45 +08:00
|
|
|
tic6x_analyze_prologue (struct gdbarch *gdbarch, const CORE_ADDR start_pc,
|
|
|
|
const CORE_ADDR current_pc,
|
|
|
|
struct tic6x_unwind_cache *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
|
|
|
const frame_info_ptr &this_frame)
|
2011-08-14 22:03:45 +08:00
|
|
|
{
|
|
|
|
unsigned int src_reg, base_reg, dst_reg;
|
|
|
|
int i;
|
|
|
|
CORE_ADDR pc = start_pc;
|
|
|
|
CORE_ADDR return_pc = start_pc;
|
|
|
|
int frame_base_offset_to_sp = 0;
|
|
|
|
/* Counter of non-stw instructions after first insn ` sub sp, xxx, sp'. */
|
|
|
|
int non_stw_insn_counter = 0;
|
|
|
|
|
|
|
|
if (start_pc >= current_pc)
|
|
|
|
return_pc = current_pc;
|
|
|
|
|
|
|
|
cache->base = 0;
|
|
|
|
|
|
|
|
/* The landmarks in prologue is one or two SUB instructions to SP.
|
|
|
|
Instructions on setting up dsbt are in the last part of prologue, if
|
|
|
|
needed. In maxim, prologue can be divided to three parts by two
|
|
|
|
`sub sp, xx, sp' insns. */
|
|
|
|
|
|
|
|
/* Step 1: Look for the 1st and 2nd insn `sub sp, xx, sp', in which, the
|
|
|
|
2nd one is optional. */
|
|
|
|
while (pc < current_pc)
|
|
|
|
{
|
|
|
|
unsigned long inst = tic6x_fetch_instruction (gdbarch, pc);
|
|
|
|
|
|
|
|
if ((inst & 0x1ffc) == 0x1dc0 || (inst & 0x1ffc) == 0x1bc0
|
|
|
|
|| (inst & 0x0ffc) == 0x9c0)
|
|
|
|
{
|
|
|
|
/* SUBAW/SUBAH/SUB, and src1 is ucst 5. */
|
|
|
|
unsigned int src2 = tic6x_register_number ((inst >> 18) & 0x1f,
|
|
|
|
INST_S_BIT (inst), 0);
|
|
|
|
unsigned int dst = tic6x_register_number ((inst >> 23) & 0x1f,
|
|
|
|
INST_S_BIT (inst), 0);
|
|
|
|
|
|
|
|
if (src2 == TIC6X_SP_REGNUM && dst == TIC6X_SP_REGNUM)
|
|
|
|
{
|
|
|
|
/* Extract const from insn SUBAW/SUBAH/SUB, and translate it to
|
|
|
|
offset. The constant offset is decoded in bit 13-17 in all
|
|
|
|
these three kinds of instructions. */
|
|
|
|
unsigned int ucst5 = (inst >> 13) & 0x1f;
|
|
|
|
|
|
|
|
if ((inst & 0x1ffc) == 0x1dc0) /* SUBAW */
|
|
|
|
frame_base_offset_to_sp += ucst5 << 2;
|
|
|
|
else if ((inst & 0x1ffc) == 0x1bc0) /* SUBAH */
|
|
|
|
frame_base_offset_to_sp += ucst5 << 1;
|
|
|
|
else if ((inst & 0x0ffc) == 0x9c0) /* SUB */
|
|
|
|
frame_base_offset_to_sp += ucst5;
|
|
|
|
else
|
|
|
|
gdb_assert_not_reached ("unexpected instruction");
|
|
|
|
|
|
|
|
return_pc = pc + 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((inst & 0x174) == 0x74) /* stw SRC, *+b15(uconst) */
|
|
|
|
{
|
|
|
|
/* The y bit determines which file base is read from. */
|
|
|
|
base_reg = tic6x_register_number ((inst >> 18) & 0x1f,
|
|
|
|
(inst >> 7) & 1, 0);
|
|
|
|
|
|
|
|
if (base_reg == TIC6X_SP_REGNUM)
|
|
|
|
{
|
|
|
|
src_reg = tic6x_register_number ((inst >> 23) & 0x1f,
|
|
|
|
INST_S_BIT (inst), 0);
|
|
|
|
|
|
|
|
cache->reg_saved[src_reg] = ((inst >> 13) & 0x1f) << 2;
|
|
|
|
|
|
|
|
return_pc = pc + 4;
|
|
|
|
}
|
|
|
|
non_stw_insn_counter = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
non_stw_insn_counter++;
|
|
|
|
/* Following instruction sequence may be emitted in prologue:
|
|
|
|
|
|
|
|
<+0>: subah .D2 b15,28,b15
|
|
|
|
<+4>: or .L2X 0,a4,b0
|
|
|
|
<+8>: || stw .D2T2 b14,*+b15(56)
|
|
|
|
<+12>:[!b0] b .S1 0xe50e4c1c <sleep+220>
|
|
|
|
<+16>:|| stw .D2T1 a10,*+b15(48)
|
|
|
|
<+20>:stw .D2T2 b3,*+b15(52)
|
|
|
|
<+24>:stw .D2T1 a4,*+b15(40)
|
|
|
|
|
|
|
|
we should look forward for next instruction instead of breaking loop
|
|
|
|
here. So far, we allow almost two sequential non-stw instructions
|
|
|
|
in prologue. */
|
|
|
|
if (non_stw_insn_counter >= 2)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pc += 4;
|
|
|
|
}
|
|
|
|
/* Step 2: Skip insn on setting up dsbt if it is. Usually, it looks like,
|
|
|
|
ldw .D2T2 *+b14(0),b14 */
|
2018-04-22 06:16:27 +08:00
|
|
|
unsigned long inst = tic6x_fetch_instruction (gdbarch, pc);
|
2011-08-14 22:03:45 +08:00
|
|
|
/* The s bit determines which file dst will be loaded into, same effect as
|
|
|
|
other places. */
|
|
|
|
dst_reg = tic6x_register_number ((inst >> 23) & 0x1f, (inst >> 1) & 1, 0);
|
|
|
|
/* The y bit (bit 7), instead of s bit, determines which file base be
|
|
|
|
used. */
|
|
|
|
base_reg = tic6x_register_number ((inst >> 18) & 0x1f, (inst >> 7) & 1, 0);
|
|
|
|
|
|
|
|
if ((inst & 0x164) == 0x64 /* ldw */
|
|
|
|
&& dst_reg == TIC6X_DP_REGNUM /* dst is B14 */
|
|
|
|
&& base_reg == TIC6X_DP_REGNUM) /* baseR is B14 */
|
|
|
|
{
|
|
|
|
return_pc = pc + 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this_frame)
|
|
|
|
{
|
|
|
|
cache->base = get_frame_register_unsigned (this_frame, TIC6X_SP_REGNUM);
|
|
|
|
|
|
|
|
if (cache->reg_saved[TIC6X_FP_REGNUM] != -1)
|
|
|
|
{
|
|
|
|
/* If the FP now holds an offset from the CFA then this is a frame
|
|
|
|
which uses the frame pointer. */
|
|
|
|
|
|
|
|
cache->cfa = get_frame_register_unsigned (this_frame,
|
|
|
|
TIC6X_FP_REGNUM);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* FP doesn't hold an offset from the CFA. If SP still holds an
|
|
|
|
offset from the CFA then we might be in a function which omits
|
|
|
|
the frame pointer. */
|
|
|
|
|
|
|
|
cache->cfa = cache->base + frame_base_offset_to_sp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Adjust all the saved registers such that they contain addresses
|
|
|
|
instead of offsets. */
|
|
|
|
for (i = 0; i < TIC6X_NUM_CORE_REGS; i++)
|
|
|
|
if (cache->reg_saved[i] != -1)
|
|
|
|
cache->reg_saved[i] = cache->base + cache->reg_saved[i];
|
|
|
|
|
|
|
|
return return_pc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is the implementation of gdbarch method skip_prologue. */
|
|
|
|
|
2012-03-02 08:06:13 +08:00
|
|
|
static CORE_ADDR
|
2011-08-14 22:03:45 +08:00
|
|
|
tic6x_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
|
|
|
|
{
|
|
|
|
CORE_ADDR func_addr;
|
|
|
|
struct tic6x_unwind_cache cache;
|
|
|
|
|
|
|
|
/* See if we can determine the end of the prologue via the symbol table.
|
|
|
|
If so, then return either PC, or the PC after the prologue, whichever is
|
|
|
|
greater. */
|
|
|
|
if (find_pc_partial_function (start_pc, NULL, &func_addr, NULL))
|
|
|
|
{
|
|
|
|
CORE_ADDR post_prologue_pc
|
|
|
|
= skip_prologue_using_sal (gdbarch, func_addr);
|
|
|
|
if (post_prologue_pc != 0)
|
gdb: Use std::min and std::max throughout
Otherwise including <string> or some other C++ header is broken.
E.g.:
In file included from /opt/gcc/include/c++/7.0.0/bits/char_traits.h:39:0,
from /opt/gcc/include/c++/7.0.0/string:40,
from /home/pedro/gdb/mygit/cxx-convertion/src/gdb/infrun.c:68:
/opt/gcc/include/c++/7.0.0/bits/stl_algobase.h:243:56: error: macro "min" passed 3 arguments, but takes just 2
min(const _Tp& __a, const _Tp& __b, _Compare __comp)
^
/opt/gcc/include/c++/7.0.0/bits/stl_algobase.h:265:56: error: macro "max" passed 3 arguments, but takes just 2
max(const _Tp& __a, const _Tp& __b, _Compare __comp)
^
In file included from .../src/gdb/infrun.c:21:0:
To the best of my grepping abilities, I believe I adjusted all min/max
calls.
gdb/ChangeLog:
2016-09-16 Pedro Alves <palves@redhat.com>
* defs.h (min, max): Delete.
* aarch64-tdep.c: Include <algorithm> and use std::min and
std::max throughout.
* aarch64-tdep.c: Likewise.
* alpha-tdep.c: Likewise.
* amd64-tdep.c: Likewise.
* amd64-windows-tdep.c: Likewise.
* arm-tdep.c: Likewise.
* avr-tdep.c: Likewise.
* breakpoint.c: Likewise.
* btrace.c: Likewise.
* ctf.c: Likewise.
* disasm.c: Likewise.
* doublest.c: Likewise.
* dwarf2loc.c: Likewise.
* dwarf2read.c: Likewise.
* environ.c: Likewise.
* exec.c: Likewise.
* f-exp.y: Likewise.
* findcmd.c: Likewise.
* ft32-tdep.c: Likewise.
* gcore.c: Likewise.
* hppa-tdep.c: Likewise.
* i386-darwin-tdep.c: Likewise.
* i386-tdep.c: Likewise.
* linux-thread-db.c: Likewise.
* lm32-tdep.c: Likewise.
* m32r-tdep.c: Likewise.
* m88k-tdep.c: Likewise.
* memrange.c: Likewise.
* minidebug.c: Likewise.
* mips-tdep.c: Likewise.
* moxie-tdep.c: Likewise.
* nds32-tdep.c: Likewise.
* nios2-tdep.c: Likewise.
* nto-procfs.c: Likewise.
* parse.c: Likewise.
* ppc-sysv-tdep.c: Likewise.
* probe.c: Likewise.
* record-btrace.c: Likewise.
* remote.c: Likewise.
* rs6000-tdep.c: Likewise.
* rx-tdep.c: Likewise.
* s390-linux-nat.c: Likewise.
* s390-linux-tdep.c: Likewise.
* ser-tcp.c: Likewise.
* sh-tdep.c: Likewise.
* sh64-tdep.c: Likewise.
* source.c: Likewise.
* sparc-tdep.c: Likewise.
* symfile.c: Likewise.
* target-memory.c: Likewise.
* target.c: Likewise.
* tic6x-tdep.c: Likewise.
* tilegx-tdep.c: Likewise.
* tracefile-tfile.c: Likewise.
* tracepoint.c: Likewise.
* valprint.c: Likewise.
* value.c: Likewise.
* xtensa-tdep.c: Likewise.
* cli/cli-cmds.c: Likewise.
* compile/compile-object-load.c: Likewise.
2016-09-17 02:55:17 +08:00
|
|
|
return std::max (start_pc, post_prologue_pc);
|
2011-08-14 22:03:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Can't determine prologue from the symbol table, need to examine
|
|
|
|
instructions. */
|
|
|
|
return tic6x_analyze_prologue (gdbarch, start_pc, (CORE_ADDR) -1, &cache,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
New gdbarch methods breakpoint_kind_from_pc and sw_breakpoint_from_kind
This patch adds two gdbarch methods breakpoint_kind_from_pc and
sw_breakpoint_from_kind, and uses target_info.placed_size as "kind"
of the breakpoint. This patch updates the usages of
target_info.placed_size.
The "kind" of a breakpoint is determined by gdbarch rather than
target, so we have gdbarch method breakpoint_kind_from_pc, and we
should set target_info.placed_size out of each implementation of
target to_insert_breakpoint. In this way, each target doesn't have
to set target_info.placed_size any more.
This patch also sets target_info.placed_address before
target_insert_breakpoint too, so that target to_insert_breakpoint
can use it, see record_full_insert_breakpoint.
Before we call target_insert_breakpoint, we set
target_info.placed_address and target_info.placed_size like this,
CORE_ADDR addr = bl->target_info.reqstd_address;
bl->target_info.placed_size = gdbarch_breakpoint_kind_from_pc (bl->gdbarch, &addr);
bl->target_info.placed_address = addr;
return target_insert_breakpoint (bl->gdbarch, &bl->target_info);
target_insert_breakpoint may fail, but it doesn't matter to the "kind"
and "placed_address" of a breakpoint. They should be determined by
gdbarch.
gdb:
2016-11-03 Yao Qi <yao.qi@linaro.org>
* arch-utils.h (GDBARCH_BREAKPOINT_MANIPULATION): Define
breakpoint_kind_from_pc and sw_breakpoint_from_kind.
(GDBARCH_BREAKPOINT_MANIPULATION_ENDIAN): Likewise.
(SET_GDBARCH_BREAKPOINT_MANIPULATION): Call
set_gdbarch_breakpoint_kind_from_pc and
set_gdbarch_sw_breakpoint_from_kind.
* arm-tdep.c: Add comments.
* bfin-tdep.c: Likewise.
* breakpoint.c (breakpoint_kind): New function.
(insert_bp_location): Set target_info.placed_size and
target_info.placed_address.
(bkpt_insert_location): Likewise.
* cris-tdep.c: Add comments.
* gdbarch.sh (breakpoint_kind_from_pc): New.
(sw_breakpoint_from_kind): New.
* gdbarch.c, gdbarch.h: Regenerated.
* ia64-tdep.c (ia64_memory_insert_breakpoint): Don't set
bp_tgt->placed_size.
(ia64_memory_remove_breakpoint): Don't assert
bp_tgt->placed_size.
(ia64_breakpoint_kind_from_pc): New function.
(ia64_gdbarch_init): Install ia64_breakpoint_kind_from_pc.
* m32r-tdep.c (m32r_memory_insert_breakpoint): Don't set
bp_tgt->placed_size.
* mem-break.c (default_memory_insert_breakpoint): Don't set
bp_tgt->placed_size. Call gdbarch_sw_breakpoint_from_kind.
(default_memory_remove_breakpoint): Call
gdbarch_sw_breakpoint_from_kind.
(memory_validate_breakpoint): Don't check bp_tgt->placed_size.
* mips-tdep.c: Add comments.
* mt-tdep.c: Likewise.
* nios2-tdep.c: Likewise.
* record-full.c (record_full_insert_breakpoint): Don't call
gdbarch_breakpoint_from_pc. Don't set bp_tgt->placed_address
and bp_tgt->placed_size.
* remote.c (remote_insert_breakpoint): Don't call
gdbarch_remote_breakpoint_from_pc. Use bp_tgt->placed_size.
Don't set bp_tgt->placed_address and bp_tgt->placed_size.
(remote_insert_hw_breakpoint): Likewise.
* score-tdep.c: Likewise.
* sh-tdep.c: Likewise.
* tic6x-tdep.c: Likewise.
* v850-tdep.c: Likewise.
* xtensa-tdep.c: Likewise.
2016-11-03 22:35:13 +08:00
|
|
|
/* Implement the breakpoint_kind_from_pc gdbarch method. */
|
|
|
|
|
2016-11-03 22:35:13 +08:00
|
|
|
static int
|
|
|
|
tic6x_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
|
|
|
|
{
|
|
|
|
return 4;
|
|
|
|
}
|
2011-08-14 22:03:45 +08:00
|
|
|
|
New gdbarch methods breakpoint_kind_from_pc and sw_breakpoint_from_kind
This patch adds two gdbarch methods breakpoint_kind_from_pc and
sw_breakpoint_from_kind, and uses target_info.placed_size as "kind"
of the breakpoint. This patch updates the usages of
target_info.placed_size.
The "kind" of a breakpoint is determined by gdbarch rather than
target, so we have gdbarch method breakpoint_kind_from_pc, and we
should set target_info.placed_size out of each implementation of
target to_insert_breakpoint. In this way, each target doesn't have
to set target_info.placed_size any more.
This patch also sets target_info.placed_address before
target_insert_breakpoint too, so that target to_insert_breakpoint
can use it, see record_full_insert_breakpoint.
Before we call target_insert_breakpoint, we set
target_info.placed_address and target_info.placed_size like this,
CORE_ADDR addr = bl->target_info.reqstd_address;
bl->target_info.placed_size = gdbarch_breakpoint_kind_from_pc (bl->gdbarch, &addr);
bl->target_info.placed_address = addr;
return target_insert_breakpoint (bl->gdbarch, &bl->target_info);
target_insert_breakpoint may fail, but it doesn't matter to the "kind"
and "placed_address" of a breakpoint. They should be determined by
gdbarch.
gdb:
2016-11-03 Yao Qi <yao.qi@linaro.org>
* arch-utils.h (GDBARCH_BREAKPOINT_MANIPULATION): Define
breakpoint_kind_from_pc and sw_breakpoint_from_kind.
(GDBARCH_BREAKPOINT_MANIPULATION_ENDIAN): Likewise.
(SET_GDBARCH_BREAKPOINT_MANIPULATION): Call
set_gdbarch_breakpoint_kind_from_pc and
set_gdbarch_sw_breakpoint_from_kind.
* arm-tdep.c: Add comments.
* bfin-tdep.c: Likewise.
* breakpoint.c (breakpoint_kind): New function.
(insert_bp_location): Set target_info.placed_size and
target_info.placed_address.
(bkpt_insert_location): Likewise.
* cris-tdep.c: Add comments.
* gdbarch.sh (breakpoint_kind_from_pc): New.
(sw_breakpoint_from_kind): New.
* gdbarch.c, gdbarch.h: Regenerated.
* ia64-tdep.c (ia64_memory_insert_breakpoint): Don't set
bp_tgt->placed_size.
(ia64_memory_remove_breakpoint): Don't assert
bp_tgt->placed_size.
(ia64_breakpoint_kind_from_pc): New function.
(ia64_gdbarch_init): Install ia64_breakpoint_kind_from_pc.
* m32r-tdep.c (m32r_memory_insert_breakpoint): Don't set
bp_tgt->placed_size.
* mem-break.c (default_memory_insert_breakpoint): Don't set
bp_tgt->placed_size. Call gdbarch_sw_breakpoint_from_kind.
(default_memory_remove_breakpoint): Call
gdbarch_sw_breakpoint_from_kind.
(memory_validate_breakpoint): Don't check bp_tgt->placed_size.
* mips-tdep.c: Add comments.
* mt-tdep.c: Likewise.
* nios2-tdep.c: Likewise.
* record-full.c (record_full_insert_breakpoint): Don't call
gdbarch_breakpoint_from_pc. Don't set bp_tgt->placed_address
and bp_tgt->placed_size.
* remote.c (remote_insert_breakpoint): Don't call
gdbarch_remote_breakpoint_from_pc. Use bp_tgt->placed_size.
Don't set bp_tgt->placed_address and bp_tgt->placed_size.
(remote_insert_hw_breakpoint): Likewise.
* score-tdep.c: Likewise.
* sh-tdep.c: Likewise.
* tic6x-tdep.c: Likewise.
* v850-tdep.c: Likewise.
* xtensa-tdep.c: Likewise.
2016-11-03 22:35:13 +08:00
|
|
|
/* Implement the sw_breakpoint_from_kind gdbarch method. */
|
|
|
|
|
-Wpointer-sign: char -> gdb_byte.
-Wpointer-sign catches all these cases across the codebase that should
be using gdb_byte for raw target bytes. I think these are all
obvious, hence I've collapsed into a single patch.
gdb/
2013-04-19 Pedro Alves <palves@redhat.com>
* aarch64-tdep.c (aarch64_default_breakpoint): Change type to
gdb_byte[].
(aarch64_breakpoint_from_pc): Change return type to gdb_byte *.
* ada-lang.c (ada_value_assign): Use gdb_byte.
* alphanbsd-tdep.c (sigtramp_retcode): Change type to gdb_byte[].
(alphanbsd_sigtramp_offset): Use gdb_byte.
* arm-linux-tdep.c (arm_linux_arm_le_breakpoint)
(arm_linux_arm_be_breakpoint, eabi_linux_arm_le_breakpoint)
(eabi_linux_arm_be_breakpoint, arm_linux_thumb_be_breakpoint)
(arm_linux_thumb_le_breakpoint, arm_linux_thumb2_be_breakpoint)
(arm_linux_thumb2_le_breakpoint): Change type to gdb_byte[].
* arm-tdep.c (arm_stub_unwind_sniffer)
(arm_displaced_init_closure): Use gdb_byte.
(arm_default_arm_le_breakpoint, arm_default_arm_be_breakpoint)
(arm_default_thumb_le_breakpoint)
(arm_default_thumb_be_breakpoint): Change type to gdb_byte[].
* arm-tdep.h (struct gdbarch_tdep) <arm_breakpoint,
thumb_breakpoint, thumb2_breakpoint>: Change type to gdb_byte *.
* arm-wince-tdep.c (arm_wince_le_breakpoint)
(arm_wince_thumb_le_breakpoint): Change type to gdb_byte[].
* armnbsd-tdep.c (arm_nbsd_arm_le_breakpoint)
(arm_nbsd_arm_be_breakpoint, arm_nbsd_thumb_le_breakpoint)
(arm_nbsd_thumb_be_breakpoint): Change type to gdb_byte[].
* armobsd-tdep.c (arm_obsd_thumb_le_breakpoint)
(arm_obsd_thumb_be_breakpoint): Change type to gdb_byte[].
* cris-tdep.c (push_stack_item, cris_push_dummy_call)
(cris_store_return_value, cris_extract_return_value): Use
gdb_byte.
(constraint): Change type of parameter to char * from signed
char*. Use gdb_byte.
* dwarf2loc.c (read_pieced_value, write_pieced_value): Change type
of local buffer to gdb_byte *.
* dwarf2read.c (read_index_from_section): Use gdb_byte.
(create_dwp_hash_table): Change type of locals to gdb_byte *.
(add_address_entry): Change type of local buffer to gdb_byte[].
* frv-tdep.c (frv_adjust_breakpoint_address, find_func_descr)
(frv_push_dummy_call): Use gdb_byte.
* hppa-hpux-tdep.c (hppa_hpux_push_dummy_code)
(hppa_hpux_supply_ss_fpblock, hppa_hpux_supply_ss_wide)
(hppa_hpux_supply_save_state): Use gdb_byte.
* hppa-tdep.c (hppa32_push_dummy_call)
(hppa64_convert_code_addr_to_fptr): Use gdb_byte.
* ia64-tdep.c (extract_bit_field, replace_bit_field)
(slotN_contents, replace_slotN_contents): Change type of parameter
to gdb_byte *.
(fetch_instruction, ia64_pseudo_register_write)
(ia64_register_to_value, ia64_value_to_register)
(ia64_extract_return_value, ia64_store_return_value)
(ia64_push_dummy_call): Use gdb_byte.
* m32c-tdep.c (m32c_return_value): Remove cast.
* m68hc11-tdep.c (m68hc11_pseudo_register_write)
(m68hc11_push_dummy_call, m68hc11_store_return_value): Use
gdb_byte.
* mipsnbsd-tdep.c (mipsnbsd_get_longjmp_target): Use gdb_byte.
* mn10300-tdep.c (mn10300_store_return_value)
(mn10300_breakpoint_from_pc, mn10300_push_dummy_call): Use
gdb_byte.
* moxie-tdep.c (moxie_process_readu): Use gdb_byte.
(moxie_process_record): Remove casts.
* ppc-ravenscar-thread.c (supply_register_at_address)
(ppc_ravenscar_generic_store_registers): Use gdb_byte.
* ravenscar-thread.c (get_running_thread_id): Use gdb_byte.
* remote-m32r-sdi.c (m32r_fetch_register): Use gdb_byte.
* remote-mips.c (mips_xfer_memory): Use gdb_byte.
* remote.c (compare_sections_command): Use gdb_byte.
* score-tdep.c (score7_free_memblock): Change type of parameter to
gdb_byte *.
* sh-tdep.c (sh_justify_value_in_reg): Change return type to
gdb_byte *. Use gdb_byte.
(sh_push_dummy_call_fpu): Use gdb_byte.
(sh_extract_return_value_nofpu, sh_extract_return_value_fpu)
(sh_store_return_value_nofpu, sh_store_return_value_fpu)
(sh_register_convert_to_virtual, sh_register_convert_to_raw):
Change parameter type to 'gdb_byte *'. Use gdb_byte.
(sh_pseudo_register_read, sh_pseudo_register_write): Use gdb_byte.
* sh64-tdep.c (sh64_push_dummy_call): Use gdb_byte.
(sh64_store_return_value, sh64_register_convert_to_virtual):
Change parameter type to 'gdb_byte *'. Use gdb_byte.
(sh64_pseudo_register_write): Use gdb_byte.
* solib-darwin.c (darwin_current_sos): Add casts to 'gdb_byte *'.
* solib-irix.c (fetch_lm_info): Likewise. Use gdb_byte for byte
buffer.
(irix_current_sos): Use gdb_byte.
* solib-som.c (som_current_sos): Use gdb_byte.
* sparc-ravenscar-thread.c (supply_register_at_address)
(sparc_ravenscar_generic_store_registers): Use gdb_byte.
* spu-multiarch.c (spu_xfer_partial): Add cast to 'char *'.
* spu-tdep.c (spu_get_overlay_table): Use gdb_byte.
* tic6x-tdep.c (tic6x_breakpoint_from_pc): Change return type to
'gdb_byte *'.
* tic6x-tdep.h (struct gdbarch_tdep) <breakpoint>: Change type to
'gdb_byte *'.
* tracepoint.c (tfile_fetch_registers): Use gdb_byte.
* xstormy16-tdep.c (xstormy16_extract_return_value)
(xstormy16_store_return_value): Change parameter type to
'gdb_byte *'. Adjust.
(xstormy16_push_dummy_call): Use gdb_byte.
* xtensa-tdep.c (xtensa_scan_prologue, call0_ret)
(call0_analyze_prologue, execute_code): Use gdb_byte.
2013-04-19 23:09:46 +08:00
|
|
|
static const gdb_byte *
|
2016-11-03 22:35:13 +08:00
|
|
|
tic6x_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
|
2011-08-14 22:03:45 +08:00
|
|
|
{
|
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
|
|
|
tic6x_gdbarch_tdep *tdep = gdbarch_tdep<tic6x_gdbarch_tdep> (gdbarch);
|
2011-08-14 22:03:45 +08:00
|
|
|
|
2016-11-03 22:35:13 +08:00
|
|
|
*size = kind;
|
2011-08-14 22:03:45 +08:00
|
|
|
|
|
|
|
if (tdep == NULL || tdep->breakpoint == NULL)
|
|
|
|
{
|
|
|
|
if (BFD_ENDIAN_BIG == gdbarch_byte_order_for_code (gdbarch))
|
|
|
|
return tic6x_bkpt_illegal_opcode_be;
|
|
|
|
else
|
|
|
|
return tic6x_bkpt_illegal_opcode_le;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return tdep->breakpoint;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tic6x_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 &this_frame)
|
2011-08-14 22:03:45 +08:00
|
|
|
{
|
|
|
|
/* Mark the PC as the destination for the return address. */
|
|
|
|
if (regnum == gdbarch_pc_regnum (gdbarch))
|
|
|
|
reg->how = DWARF2_FRAME_REG_RA;
|
|
|
|
|
|
|
|
/* Mark the stack pointer as the call frame address. */
|
|
|
|
else if (regnum == gdbarch_sp_regnum (gdbarch))
|
|
|
|
reg->how = DWARF2_FRAME_REG_CFA;
|
|
|
|
|
|
|
|
/* The above was taken from the default init_reg in dwarf2-frame.c
|
|
|
|
while the below is c6x specific. */
|
|
|
|
|
|
|
|
/* Callee save registers. The ABI designates A10-A15 and B10-B15 as
|
|
|
|
callee-save. */
|
|
|
|
else if ((regnum >= 10 && regnum <= 15) || (regnum >= 26 && regnum <= 31))
|
|
|
|
reg->how = DWARF2_FRAME_REG_SAME_VALUE;
|
|
|
|
else
|
|
|
|
/* All other registers are caller-save. */
|
|
|
|
reg->how = DWARF2_FRAME_REG_UNDEFINED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is the implementation of gdbarch method unwind_pc. */
|
|
|
|
|
|
|
|
static CORE_ADDR
|
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
|
|
|
tic6x_unwind_pc (struct gdbarch *gdbarch, const frame_info_ptr &next_frame)
|
2011-08-14 22:03:45 +08:00
|
|
|
{
|
|
|
|
gdb_byte buf[8];
|
|
|
|
|
|
|
|
frame_unwind_register (next_frame, TIC6X_PC_REGNUM, buf);
|
|
|
|
return extract_typed_address (buf, builtin_type (gdbarch)->builtin_func_ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Frame base handling. */
|
|
|
|
|
2012-03-02 08:06:13 +08:00
|
|
|
static struct tic6x_unwind_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
|
|
|
tic6x_frame_unwind_cache (const frame_info_ptr &this_frame,
|
2011-08-14 22:03:45 +08:00
|
|
|
void **this_prologue_cache)
|
|
|
|
{
|
|
|
|
struct gdbarch *gdbarch = get_frame_arch (this_frame);
|
|
|
|
CORE_ADDR current_pc;
|
|
|
|
struct tic6x_unwind_cache *cache;
|
|
|
|
|
|
|
|
if (*this_prologue_cache)
|
2015-09-26 02:08:07 +08:00
|
|
|
return (struct tic6x_unwind_cache *) *this_prologue_cache;
|
2011-08-14 22:03:45 +08:00
|
|
|
|
|
|
|
cache = FRAME_OBSTACK_ZALLOC (struct tic6x_unwind_cache);
|
|
|
|
(*this_prologue_cache) = cache;
|
|
|
|
|
|
|
|
cache->return_regnum = TIC6X_RA_REGNUM;
|
|
|
|
|
|
|
|
tic6x_setup_default (cache);
|
|
|
|
|
|
|
|
cache->pc = get_frame_func (this_frame);
|
|
|
|
current_pc = get_frame_pc (this_frame);
|
|
|
|
|
|
|
|
/* Prologue analysis does the rest... */
|
|
|
|
if (cache->pc != 0)
|
|
|
|
tic6x_analyze_prologue (gdbarch, cache->pc, current_pc, cache, this_frame);
|
|
|
|
|
|
|
|
return cache;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
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
|
|
|
tic6x_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
|
2011-08-14 22:03:45 +08:00
|
|
|
struct frame_id *this_id)
|
|
|
|
{
|
|
|
|
struct tic6x_unwind_cache *cache =
|
|
|
|
tic6x_frame_unwind_cache (this_frame, this_cache);
|
|
|
|
|
|
|
|
/* This marks the outermost frame. */
|
|
|
|
if (cache->base == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
(*this_id) = frame_id_build (cache->cfa, cache->pc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct value *
|
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
|
|
|
tic6x_frame_prev_register (const frame_info_ptr &this_frame, void **this_cache,
|
2011-08-14 22:03:45 +08:00
|
|
|
int regnum)
|
|
|
|
{
|
|
|
|
struct tic6x_unwind_cache *cache =
|
|
|
|
tic6x_frame_unwind_cache (this_frame, this_cache);
|
|
|
|
|
|
|
|
gdb_assert (regnum >= 0);
|
|
|
|
|
|
|
|
/* The PC of the previous frame is stored in the RA register of
|
|
|
|
the current frame. Frob regnum so that we pull the value from
|
|
|
|
the correct place. */
|
|
|
|
if (regnum == TIC6X_PC_REGNUM)
|
|
|
|
regnum = cache->return_regnum;
|
|
|
|
|
|
|
|
if (regnum == TIC6X_SP_REGNUM && cache->cfa)
|
|
|
|
return frame_unwind_got_constant (this_frame, regnum, cache->cfa);
|
|
|
|
|
|
|
|
/* If we've worked out where a register is stored then load it from
|
|
|
|
there. */
|
|
|
|
if (regnum < TIC6X_NUM_CORE_REGS && cache->reg_saved[regnum] != -1)
|
|
|
|
return frame_unwind_got_memory (this_frame, regnum,
|
|
|
|
cache->reg_saved[regnum]);
|
|
|
|
|
|
|
|
return frame_unwind_got_register (this_frame, regnum, regnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
static CORE_ADDR
|
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
|
|
|
tic6x_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
|
2011-08-14 22:03:45 +08:00
|
|
|
{
|
|
|
|
struct tic6x_unwind_cache *info
|
|
|
|
= tic6x_frame_unwind_cache (this_frame, this_cache);
|
|
|
|
return info->base;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct frame_unwind tic6x_frame_unwind =
|
|
|
|
{
|
2021-06-30 00:05:03 +08:00
|
|
|
"tic6x prologue",
|
2011-08-14 22:03:45 +08:00
|
|
|
NORMAL_FRAME,
|
|
|
|
default_frame_unwind_stop_reason,
|
|
|
|
tic6x_frame_this_id,
|
|
|
|
tic6x_frame_prev_register,
|
|
|
|
NULL,
|
|
|
|
default_frame_sniffer
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct frame_base tic6x_frame_base =
|
|
|
|
{
|
|
|
|
&tic6x_frame_unwind,
|
|
|
|
tic6x_frame_base_address,
|
|
|
|
tic6x_frame_base_address,
|
|
|
|
tic6x_frame_base_address
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static struct tic6x_unwind_cache *
|
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
|
|
|
tic6x_make_stub_cache (const frame_info_ptr &this_frame)
|
2011-08-14 22:03:45 +08:00
|
|
|
{
|
|
|
|
struct tic6x_unwind_cache *cache;
|
|
|
|
|
|
|
|
cache = FRAME_OBSTACK_ZALLOC (struct tic6x_unwind_cache);
|
|
|
|
|
|
|
|
cache->return_regnum = TIC6X_RA_REGNUM;
|
|
|
|
|
|
|
|
tic6x_setup_default (cache);
|
|
|
|
|
|
|
|
cache->cfa = get_frame_register_unsigned (this_frame, TIC6X_SP_REGNUM);
|
|
|
|
|
|
|
|
return cache;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
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
|
|
|
tic6x_stub_this_id (const frame_info_ptr &this_frame, void **this_cache,
|
2011-08-14 22:03:45 +08:00
|
|
|
struct frame_id *this_id)
|
|
|
|
{
|
|
|
|
struct tic6x_unwind_cache *cache;
|
|
|
|
|
|
|
|
if (*this_cache == NULL)
|
|
|
|
*this_cache = tic6x_make_stub_cache (this_frame);
|
2015-09-26 02:08:07 +08:00
|
|
|
cache = (struct tic6x_unwind_cache *) *this_cache;
|
2011-08-14 22:03:45 +08:00
|
|
|
|
|
|
|
*this_id = frame_id_build (cache->cfa, get_frame_pc (this_frame));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tic6x_stub_unwind_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,
|
2011-08-14 22:03:45 +08:00
|
|
|
void **this_prologue_cache)
|
|
|
|
{
|
|
|
|
CORE_ADDR addr_in_block;
|
|
|
|
|
|
|
|
addr_in_block = get_frame_address_in_block (this_frame);
|
2013-06-25 06:18:32 +08:00
|
|
|
if (in_plt_section (addr_in_block))
|
2011-08-14 22:03:45 +08:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct frame_unwind tic6x_stub_unwind =
|
|
|
|
{
|
2021-06-30 00:05:03 +08:00
|
|
|
"tic6x stub",
|
2011-08-14 22:03:45 +08:00
|
|
|
NORMAL_FRAME,
|
|
|
|
default_frame_unwind_stop_reason,
|
|
|
|
tic6x_stub_this_id,
|
|
|
|
tic6x_frame_prev_register,
|
|
|
|
NULL,
|
|
|
|
tic6x_stub_unwind_sniffer
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Return the instruction on address PC. */
|
|
|
|
|
|
|
|
static unsigned long
|
|
|
|
tic6x_fetch_instruction (struct gdbarch *gdbarch, CORE_ADDR pc)
|
|
|
|
{
|
|
|
|
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
|
|
|
|
return read_memory_unsigned_integer (pc, TIC6X_OPCODE_SIZE, byte_order);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Compute the condition of INST if it is a conditional instruction. Always
|
|
|
|
return 1 if INST is not a conditional instruction. */
|
|
|
|
|
|
|
|
static int
|
2016-11-22 22:05:05 +08:00
|
|
|
tic6x_condition_true (struct regcache *regcache, unsigned long inst)
|
2011-08-14 22:03:45 +08:00
|
|
|
{
|
|
|
|
int register_number;
|
|
|
|
int register_value;
|
|
|
|
static const int register_numbers[8] = { -1, 16, 17, 18, 1, 2, 0, -1 };
|
|
|
|
|
|
|
|
register_number = register_numbers[(inst >> 29) & 7];
|
|
|
|
if (register_number == -1)
|
|
|
|
return 1;
|
|
|
|
|
2016-11-22 22:05:05 +08:00
|
|
|
register_value = regcache_raw_get_signed (regcache, register_number);
|
2011-08-14 22:03:45 +08:00
|
|
|
if ((inst & 0x10000000) != 0)
|
|
|
|
return register_value == 0;
|
|
|
|
return register_value != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the register number by decoding raw bits REG, SIDE, and CROSSPATH in
|
|
|
|
instruction. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
tic6x_register_number (int reg, int side, int crosspath)
|
|
|
|
{
|
|
|
|
int r = (reg & 15) | ((crosspath ^ side) << 4);
|
|
|
|
if ((reg & 16) != 0) /* A16 - A31, B16 - B31 */
|
|
|
|
r += 37;
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tic6x_extract_signed_field (int value, int low_bit, int bits)
|
|
|
|
{
|
|
|
|
int mask = (1 << bits) - 1;
|
|
|
|
int r = (value >> low_bit) & mask;
|
|
|
|
if ((r & (1 << (bits - 1))) != 0)
|
|
|
|
r -= mask + 1;
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Determine where to set a single step breakpoint. */
|
|
|
|
|
|
|
|
static CORE_ADDR
|
2016-11-22 22:05:05 +08:00
|
|
|
tic6x_get_next_pc (struct regcache *regcache, CORE_ADDR pc)
|
2011-08-14 22:03:45 +08:00
|
|
|
{
|
2017-10-25 23:37:03 +08:00
|
|
|
struct gdbarch *gdbarch = regcache->arch ();
|
2011-08-14 22:03:45 +08:00
|
|
|
unsigned long inst;
|
|
|
|
int register_number;
|
|
|
|
int last = 0;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
inst = tic6x_fetch_instruction (gdbarch, pc);
|
|
|
|
|
|
|
|
last = !(inst & 1);
|
|
|
|
|
|
|
|
if (inst == TIC6X_INST_SWE)
|
|
|
|
{
|
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
|
|
|
tic6x_gdbarch_tdep *tdep
|
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
|
|
|
= gdbarch_tdep<tic6x_gdbarch_tdep> (gdbarch);
|
2011-08-14 22:03:45 +08:00
|
|
|
|
|
|
|
if (tdep->syscall_next_pc != NULL)
|
2016-11-22 22:05:05 +08:00
|
|
|
return tdep->syscall_next_pc (get_current_frame ());
|
2011-08-14 22:03:45 +08:00
|
|
|
}
|
|
|
|
|
2016-11-22 22:05:05 +08:00
|
|
|
if (tic6x_condition_true (regcache, inst))
|
2011-08-14 22:03:45 +08:00
|
|
|
{
|
|
|
|
if ((inst & 0x0000007c) == 0x00000010)
|
|
|
|
{
|
|
|
|
/* B with displacement */
|
|
|
|
pc &= ~(TIC6X_FETCH_PACKET_SIZE - 1);
|
|
|
|
pc += tic6x_extract_signed_field (inst, 7, 21) << 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ((inst & 0x0f83effc) == 0x00000360)
|
|
|
|
{
|
|
|
|
/* B with register */
|
|
|
|
|
|
|
|
register_number = tic6x_register_number ((inst >> 18) & 0x1f,
|
|
|
|
INST_S_BIT (inst),
|
|
|
|
INST_X_BIT (inst));
|
2016-11-22 22:05:05 +08:00
|
|
|
pc = regcache_raw_get_unsigned (regcache, register_number);
|
2011-08-14 22:03:45 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ((inst & 0x00001ffc) == 0x00001020)
|
|
|
|
{
|
|
|
|
/* BDEC */
|
|
|
|
register_number = tic6x_register_number ((inst >> 23) & 0x1f,
|
|
|
|
INST_S_BIT (inst), 0);
|
2016-11-22 22:05:05 +08:00
|
|
|
if (regcache_raw_get_signed (regcache, register_number) >= 0)
|
2011-08-14 22:03:45 +08:00
|
|
|
{
|
|
|
|
pc &= ~(TIC6X_FETCH_PACKET_SIZE - 1);
|
|
|
|
pc += tic6x_extract_signed_field (inst, 7, 10) << 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ((inst & 0x00001ffc) == 0x00000120)
|
|
|
|
{
|
|
|
|
/* BNOP with displacement */
|
|
|
|
pc &= ~(TIC6X_FETCH_PACKET_SIZE - 1);
|
|
|
|
pc += tic6x_extract_signed_field (inst, 16, 12) << 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ((inst & 0x0f830ffe) == 0x00800362)
|
|
|
|
{
|
|
|
|
/* BNOP with register */
|
|
|
|
register_number = tic6x_register_number ((inst >> 18) & 0x1f,
|
|
|
|
1, INST_X_BIT (inst));
|
2016-11-22 22:05:05 +08:00
|
|
|
pc = regcache_raw_get_unsigned (regcache, register_number);
|
2011-08-14 22:03:45 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ((inst & 0x00001ffc) == 0x00000020)
|
|
|
|
{
|
|
|
|
/* BPOS */
|
|
|
|
register_number = tic6x_register_number ((inst >> 23) & 0x1f,
|
|
|
|
INST_S_BIT (inst), 0);
|
2016-11-22 22:05:05 +08:00
|
|
|
if (regcache_raw_get_signed (regcache, register_number) >= 0)
|
2011-08-14 22:03:45 +08:00
|
|
|
{
|
|
|
|
pc &= ~(TIC6X_FETCH_PACKET_SIZE - 1);
|
|
|
|
pc += tic6x_extract_signed_field (inst, 13, 10) << 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ((inst & 0xf000007c) == 0x10000010)
|
|
|
|
{
|
|
|
|
/* CALLP */
|
|
|
|
pc &= ~(TIC6X_FETCH_PACKET_SIZE - 1);
|
|
|
|
pc += tic6x_extract_signed_field (inst, 7, 21) << 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pc += TIC6X_OPCODE_SIZE;
|
|
|
|
}
|
|
|
|
while (!last);
|
|
|
|
return pc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is the implementation of gdbarch method software_single_step. */
|
|
|
|
|
2017-05-03 01:30:07 +08:00
|
|
|
static std::vector<CORE_ADDR>
|
2016-11-22 22:05:06 +08:00
|
|
|
tic6x_software_single_step (struct regcache *regcache)
|
2011-08-14 22:03:45 +08:00
|
|
|
{
|
2016-11-22 22:05:05 +08:00
|
|
|
CORE_ADDR next_pc = tic6x_get_next_pc (regcache, regcache_read_pc (regcache));
|
2011-08-14 22:03:45 +08:00
|
|
|
|
2017-05-03 01:30:07 +08:00
|
|
|
return {next_pc};
|
2011-08-14 22:03:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* This is the implementation of gdbarch method frame_align. */
|
|
|
|
|
|
|
|
static CORE_ADDR
|
|
|
|
tic6x_frame_align (struct gdbarch *gdbarch, CORE_ADDR addr)
|
|
|
|
{
|
|
|
|
return align_down (addr, 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Given a return value in REGCACHE with a type VALTYPE, extract and copy its
|
|
|
|
value into VALBUF. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
tic6x_extract_return_value (struct type *valtype, struct regcache *regcache,
|
|
|
|
enum bfd_endian byte_order, gdb_byte *valbuf)
|
|
|
|
{
|
2022-09-21 23:05:21 +08:00
|
|
|
int len = valtype->length ();
|
2011-08-14 22:03:45 +08:00
|
|
|
|
|
|
|
/* pointer types are returned in register A4,
|
|
|
|
up to 32-bit types in A4
|
|
|
|
up to 64-bit types in A5:A4 */
|
|
|
|
if (len <= 4)
|
|
|
|
{
|
|
|
|
/* In big-endian,
|
|
|
|
- one-byte structure or union occupies the LSB of single even register.
|
|
|
|
- for two-byte structure or union, the first byte occupies byte 1 of
|
|
|
|
register and the second byte occupies byte 0.
|
|
|
|
so, we read the contents in VAL from the LSBs of register. */
|
|
|
|
if (len < 3 && byte_order == BFD_ENDIAN_BIG)
|
2018-05-31 02:54:43 +08:00
|
|
|
regcache->cooked_read_part (TIC6X_A4_REGNUM, 4 - len, len, valbuf);
|
2011-08-14 22:03:45 +08:00
|
|
|
else
|
2018-05-31 02:54:38 +08:00
|
|
|
regcache->cooked_read (TIC6X_A4_REGNUM, valbuf);
|
2011-08-14 22:03:45 +08:00
|
|
|
}
|
|
|
|
else if (len <= 8)
|
|
|
|
{
|
|
|
|
/* For a 5-8 byte structure or union in big-endian, the first byte
|
|
|
|
occupies byte 3 (the MSB) of the upper (odd) register and the
|
|
|
|
remaining bytes fill the decreasingly significant bytes. 5-7
|
|
|
|
byte structures or unions have padding in the LSBs of the
|
|
|
|
lower (even) register. */
|
|
|
|
if (byte_order == BFD_ENDIAN_BIG)
|
|
|
|
{
|
2018-05-31 02:54:38 +08:00
|
|
|
regcache->cooked_read (TIC6X_A4_REGNUM, valbuf + 4);
|
|
|
|
regcache->cooked_read (TIC6X_A5_REGNUM, valbuf);
|
2011-08-14 22:03:45 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-05-31 02:54:38 +08:00
|
|
|
regcache->cooked_read (TIC6X_A4_REGNUM, valbuf);
|
|
|
|
regcache->cooked_read (TIC6X_A5_REGNUM, valbuf + 4);
|
2011-08-14 22:03:45 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Write into appropriate registers a function return value
|
|
|
|
of type TYPE, given in virtual format. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
tic6x_store_return_value (struct type *valtype, struct regcache *regcache,
|
|
|
|
enum bfd_endian byte_order, const gdb_byte *valbuf)
|
|
|
|
{
|
2022-09-21 23:05:21 +08:00
|
|
|
int len = valtype->length ();
|
2011-08-14 22:03:45 +08:00
|
|
|
|
|
|
|
/* return values of up to 8 bytes are returned in A5:A4 */
|
|
|
|
|
|
|
|
if (len <= 4)
|
|
|
|
{
|
|
|
|
if (len < 3 && byte_order == BFD_ENDIAN_BIG)
|
2018-05-31 02:54:44 +08:00
|
|
|
regcache->cooked_write_part (TIC6X_A4_REGNUM, 4 - len, len, valbuf);
|
2011-08-14 22:03:45 +08:00
|
|
|
else
|
2018-05-31 02:54:42 +08:00
|
|
|
regcache->cooked_write (TIC6X_A4_REGNUM, valbuf);
|
2011-08-14 22:03:45 +08:00
|
|
|
}
|
|
|
|
else if (len <= 8)
|
|
|
|
{
|
|
|
|
if (byte_order == BFD_ENDIAN_BIG)
|
|
|
|
{
|
2018-05-31 02:54:42 +08:00
|
|
|
regcache->cooked_write (TIC6X_A4_REGNUM, valbuf + 4);
|
|
|
|
regcache->cooked_write (TIC6X_A5_REGNUM, valbuf);
|
2011-08-14 22:03:45 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-05-31 02:54:42 +08:00
|
|
|
regcache->cooked_write (TIC6X_A4_REGNUM, valbuf);
|
|
|
|
regcache->cooked_write (TIC6X_A5_REGNUM, valbuf + 4);
|
2011-08-14 22:03:45 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is the implementation of gdbarch method return_value. */
|
|
|
|
|
|
|
|
static enum return_value_convention
|
2012-05-16 22:35:09 +08:00
|
|
|
tic6x_return_value (struct gdbarch *gdbarch, struct value *function,
|
2011-08-14 22:03:45 +08:00
|
|
|
struct type *type, struct regcache *regcache,
|
|
|
|
gdb_byte *readbuf, const gdb_byte *writebuf)
|
|
|
|
{
|
2012-06-08 22:24:57 +08:00
|
|
|
/* In C++, when function returns an object, even its size is small
|
|
|
|
enough, it stii has to be passed via reference, pointed by register
|
|
|
|
A3. */
|
|
|
|
if (current_language->la_language == language_cplus)
|
|
|
|
{
|
|
|
|
if (type != NULL)
|
|
|
|
{
|
2015-07-07 04:05:06 +08:00
|
|
|
type = check_typedef (type);
|
2019-12-21 00:43:06 +08:00
|
|
|
if (!(language_pass_by_reference (type).trivially_copyable))
|
2012-06-08 22:24:57 +08:00
|
|
|
return RETURN_VALUE_STRUCT_CONVENTION;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-21 23:05:21 +08:00
|
|
|
if (type->length () > 8)
|
2011-08-14 22:03:45 +08:00
|
|
|
return RETURN_VALUE_STRUCT_CONVENTION;
|
|
|
|
|
|
|
|
if (readbuf)
|
|
|
|
tic6x_extract_return_value (type, regcache,
|
|
|
|
gdbarch_byte_order (gdbarch), readbuf);
|
|
|
|
if (writebuf)
|
|
|
|
tic6x_store_return_value (type, regcache,
|
|
|
|
gdbarch_byte_order (gdbarch), writebuf);
|
|
|
|
|
|
|
|
return RETURN_VALUE_REGISTER_CONVENTION;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the alignment requirement of TYPE. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
tic6x_arg_type_alignment (struct type *type)
|
|
|
|
{
|
2022-09-21 23:05:21 +08:00
|
|
|
int len = check_typedef (type)->length ();
|
2020-05-15 01:46:38 +08:00
|
|
|
enum type_code typecode = check_typedef (type)->code ();
|
2011-08-14 22:03:45 +08:00
|
|
|
|
|
|
|
if (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION)
|
|
|
|
{
|
|
|
|
/* The stack alignment of a structure (and union) passed by value is the
|
|
|
|
smallest power of two greater than or equal to its size.
|
|
|
|
This cannot exceed 8 bytes, which is the largest allowable size for
|
|
|
|
a structure passed by value. */
|
|
|
|
|
|
|
|
if (len <= 2)
|
|
|
|
return len;
|
|
|
|
else if (len <= 4)
|
|
|
|
return 4;
|
|
|
|
else if (len <= 8)
|
|
|
|
return 8;
|
|
|
|
else
|
|
|
|
gdb_assert_not_reached ("unexpected length of data");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (len <= 4)
|
|
|
|
return 4;
|
|
|
|
else if (len == 8)
|
|
|
|
{
|
|
|
|
if (typecode == TYPE_CODE_COMPLEX)
|
|
|
|
return 4;
|
|
|
|
else
|
|
|
|
return 8;
|
|
|
|
}
|
|
|
|
else if (len == 16)
|
|
|
|
{
|
|
|
|
if (typecode == TYPE_CODE_COMPLEX)
|
|
|
|
return 8;
|
|
|
|
else
|
|
|
|
return 16;
|
|
|
|
}
|
|
|
|
else
|
internal_error: 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 (_("unexpected length %d of type"),
|
2011-08-14 22:03:45 +08:00
|
|
|
len);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is the implementation of gdbarch method push_dummy_call. */
|
|
|
|
|
|
|
|
static CORE_ADDR
|
|
|
|
tic6x_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
|
|
|
|
struct regcache *regcache, CORE_ADDR bp_addr,
|
|
|
|
int nargs, struct value **args, CORE_ADDR sp,
|
2018-11-16 19:21:04 +08:00
|
|
|
function_call_return_method return_method,
|
|
|
|
CORE_ADDR struct_addr)
|
2011-08-14 22:03:45 +08:00
|
|
|
{
|
|
|
|
int argreg = 0;
|
|
|
|
int argnum;
|
|
|
|
int stack_offset = 4;
|
|
|
|
int references_offset = 4;
|
|
|
|
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
|
2023-01-31 22:52:09 +08:00
|
|
|
struct type *func_type = function->type ();
|
2011-08-14 22:03:45 +08:00
|
|
|
/* The first arg passed on stack. Mostly the first 10 args are passed by
|
|
|
|
registers. */
|
|
|
|
int first_arg_on_stack = 10;
|
|
|
|
|
|
|
|
/* Set the return address register to point to the entry point of
|
|
|
|
the program, where a breakpoint lies in wait. */
|
|
|
|
regcache_cooked_write_unsigned (regcache, TIC6X_RA_REGNUM, bp_addr);
|
|
|
|
|
|
|
|
/* The caller must pass an argument in A3 containing a destination address
|
|
|
|
for the returned value. The callee returns the object by copying it to
|
|
|
|
the address in A3. */
|
2018-11-16 19:21:04 +08:00
|
|
|
if (return_method == return_method_struct)
|
2011-08-14 22:03:45 +08:00
|
|
|
regcache_cooked_write_unsigned (regcache, 3, struct_addr);
|
|
|
|
|
|
|
|
/* Determine the type of this function. */
|
|
|
|
func_type = check_typedef (func_type);
|
2020-05-15 01:46:38 +08:00
|
|
|
if (func_type->code () == TYPE_CODE_PTR)
|
2022-07-31 10:43:54 +08:00
|
|
|
func_type = check_typedef (func_type->target_type ());
|
2011-08-14 22:03:45 +08:00
|
|
|
|
2020-05-15 01:46:38 +08:00
|
|
|
gdb_assert (func_type->code () == TYPE_CODE_FUNC
|
|
|
|
|| func_type->code () == TYPE_CODE_METHOD);
|
2011-08-14 22:03:45 +08:00
|
|
|
|
|
|
|
/* For a variadic C function, the last explicitly declared argument and all
|
|
|
|
remaining arguments are passed on the stack. */
|
2020-09-14 23:08:02 +08:00
|
|
|
if (func_type->has_varargs ())
|
2020-05-23 04:55:15 +08:00
|
|
|
first_arg_on_stack = func_type->num_fields () - 1;
|
2011-08-14 22:03:45 +08:00
|
|
|
|
2012-06-08 22:24:57 +08:00
|
|
|
/* Now make space on the stack for the args. */
|
|
|
|
for (argnum = 0; argnum < nargs; argnum++)
|
2011-08-14 22:03:45 +08:00
|
|
|
{
|
2023-01-31 22:52:09 +08:00
|
|
|
int len = align_up (args[argnum]->type ()->length (), 4);
|
2011-08-14 22:03:45 +08:00
|
|
|
if (argnum >= 10 - argreg)
|
|
|
|
references_offset += len;
|
|
|
|
stack_offset += len;
|
|
|
|
}
|
|
|
|
sp -= stack_offset;
|
|
|
|
/* SP should be 8-byte aligned, see C6000 ABI section 4.4.1
|
|
|
|
Stack Alignment. */
|
|
|
|
sp = align_down (sp, 8);
|
|
|
|
stack_offset = 4;
|
|
|
|
|
|
|
|
/* Now load as many as possible of the first arguments into
|
|
|
|
registers, and push the rest onto the stack. Loop through args
|
|
|
|
from first to last. */
|
2012-06-08 22:24:57 +08:00
|
|
|
for (argnum = 0; argnum < nargs; argnum++)
|
2011-08-14 22:03:45 +08:00
|
|
|
{
|
|
|
|
const gdb_byte *val;
|
|
|
|
struct value *arg = args[argnum];
|
2023-01-31 22:52:09 +08:00
|
|
|
struct type *arg_type = check_typedef (arg->type ());
|
2022-09-21 23:05:21 +08:00
|
|
|
int len = arg_type->length ();
|
2020-05-15 01:46:38 +08:00
|
|
|
enum type_code typecode = arg_type->code ();
|
2011-08-14 22:03:45 +08:00
|
|
|
|
2023-02-01 05:38:30 +08:00
|
|
|
val = arg->contents ().data ();
|
2011-08-14 22:03:45 +08:00
|
|
|
|
|
|
|
/* Copy the argument to general registers or the stack in
|
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
|
|
|
register-sized pieces. */
|
2011-08-14 22:03:45 +08:00
|
|
|
if (argreg < first_arg_on_stack)
|
|
|
|
{
|
|
|
|
if (len <= 4)
|
|
|
|
{
|
|
|
|
if (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION)
|
|
|
|
{
|
|
|
|
/* In big-endian,
|
|
|
|
- one-byte structure or union occupies the LSB of single
|
|
|
|
even register.
|
|
|
|
- for two-byte structure or union, the first byte
|
|
|
|
occupies byte 1 of register and the second byte occupies
|
|
|
|
byte 0.
|
|
|
|
so, we write the contents in VAL to the lsp of
|
|
|
|
register. */
|
|
|
|
if (len < 3 && byte_order == BFD_ENDIAN_BIG)
|
2018-05-31 02:54:44 +08:00
|
|
|
regcache->cooked_write_part (arg_regs[argreg], 4 - len, len,
|
|
|
|
val);
|
2011-08-14 22:03:45 +08:00
|
|
|
else
|
2018-05-31 02:54:42 +08:00
|
|
|
regcache->cooked_write (arg_regs[argreg], val);
|
2011-08-14 22:03:45 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* The argument is being passed by value in a single
|
|
|
|
register. */
|
|
|
|
CORE_ADDR regval = extract_unsigned_integer (val, len,
|
|
|
|
byte_order);
|
|
|
|
|
|
|
|
regcache_cooked_write_unsigned (regcache, arg_regs[argreg],
|
|
|
|
regval);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (len <= 8)
|
|
|
|
{
|
|
|
|
if (typecode == TYPE_CODE_STRUCT
|
|
|
|
|| typecode == TYPE_CODE_UNION)
|
|
|
|
{
|
|
|
|
/* For a 5-8 byte structure or union in big-endian, the
|
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
|
|
|
first byte occupies byte 3 (the MSB) of the upper (odd)
|
|
|
|
register and the remaining bytes fill the decreasingly
|
|
|
|
significant bytes. 5-7 byte structures or unions have
|
|
|
|
padding in the LSBs of the lower (even) register. */
|
2011-08-14 22:03:45 +08:00
|
|
|
if (byte_order == BFD_ENDIAN_BIG)
|
|
|
|
{
|
2018-05-31 02:54:42 +08:00
|
|
|
regcache->cooked_write (arg_regs[argreg] + 1, val);
|
2018-05-31 02:54:44 +08:00
|
|
|
regcache->cooked_write_part (arg_regs[argreg], 0,
|
|
|
|
len - 4, val + 4);
|
2011-08-14 22:03:45 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-05-31 02:54:42 +08:00
|
|
|
regcache->cooked_write (arg_regs[argreg], val);
|
2018-05-31 02:54:44 +08:00
|
|
|
regcache->cooked_write_part (arg_regs[argreg] + 1, 0,
|
|
|
|
len - 4, val + 4);
|
2011-08-14 22:03:45 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* The argument is being passed by value in a pair of
|
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
|
|
|
registers. */
|
2011-08-14 22:03:45 +08:00
|
|
|
ULONGEST regval = extract_unsigned_integer (val, len,
|
|
|
|
byte_order);
|
|
|
|
|
|
|
|
regcache_cooked_write_unsigned (regcache,
|
|
|
|
arg_regs[argreg],
|
|
|
|
regval);
|
|
|
|
regcache_cooked_write_unsigned (regcache,
|
|
|
|
arg_regs[argreg] + 1,
|
|
|
|
regval >> 32);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* The argument is being passed by reference in a single
|
|
|
|
register. */
|
|
|
|
CORE_ADDR addr;
|
|
|
|
|
|
|
|
/* It is not necessary to adjust REFERENCES_OFFSET to
|
|
|
|
8-byte aligned in some cases, in which 4-byte alignment
|
|
|
|
is sufficient. For simplicity, we adjust
|
|
|
|
REFERENCES_OFFSET to 8-byte aligned. */
|
|
|
|
references_offset = align_up (references_offset, 8);
|
|
|
|
|
|
|
|
addr = sp + references_offset;
|
|
|
|
write_memory (addr, val, len);
|
|
|
|
references_offset += align_up (len, 4);
|
|
|
|
regcache_cooked_write_unsigned (regcache, arg_regs[argreg],
|
|
|
|
addr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
argreg++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* The argument is being passed on the stack. */
|
|
|
|
CORE_ADDR addr;
|
|
|
|
|
|
|
|
/* There are six different cases of alignment, and these rules can
|
|
|
|
be found in tic6x_arg_type_alignment:
|
|
|
|
|
|
|
|
1) 4-byte aligned if size is less than or equal to 4 byte, such
|
|
|
|
as short, int, struct, union etc.
|
|
|
|
2) 8-byte aligned if size is less than or equal to 8-byte, such
|
|
|
|
as double, long long,
|
|
|
|
3) 4-byte aligned if it is of type _Complex float, even its size
|
|
|
|
is 8-byte.
|
|
|
|
4) 8-byte aligned if it is of type _Complex double or _Complex
|
|
|
|
long double, even its size is 16-byte. Because, the address of
|
|
|
|
variable is passed as reference.
|
|
|
|
5) struct and union larger than 8-byte are passed by reference, so
|
|
|
|
it is 4-byte aligned.
|
|
|
|
6) struct and union of size between 4 byte and 8 byte varies.
|
|
|
|
alignment of struct variable is the alignment of its first field,
|
|
|
|
while alignment of union variable is the max of all its fields'
|
|
|
|
alignment. */
|
|
|
|
|
|
|
|
if (len <= 4)
|
|
|
|
; /* Default is 4-byte aligned. Nothing to be done. */
|
|
|
|
else if (len <= 8)
|
|
|
|
stack_offset = align_up (stack_offset,
|
|
|
|
tic6x_arg_type_alignment (arg_type));
|
|
|
|
else if (len == 16)
|
|
|
|
{
|
|
|
|
/* _Complex double or _Complex long double */
|
|
|
|
if (typecode == TYPE_CODE_COMPLEX)
|
|
|
|
{
|
|
|
|
/* The argument is being passed by reference on stack. */
|
|
|
|
references_offset = align_up (references_offset, 8);
|
|
|
|
|
|
|
|
addr = sp + references_offset;
|
|
|
|
/* Store variable on stack. */
|
|
|
|
write_memory (addr, val, len);
|
|
|
|
|
|
|
|
references_offset += align_up (len, 4);
|
|
|
|
|
|
|
|
/* Pass the address of variable on stack as reference. */
|
|
|
|
store_unsigned_integer ((gdb_byte *) val, 4, byte_order,
|
|
|
|
addr);
|
|
|
|
len = 4;
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
internal_error: 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 (_("unexpected type %d of arg %d"),
|
2011-08-14 22:03:45 +08:00
|
|
|
typecode, argnum);
|
|
|
|
}
|
|
|
|
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 (_("unexpected length %d of arg %d"), len, argnum);
|
2011-08-14 22:03:45 +08:00
|
|
|
|
|
|
|
addr = sp + stack_offset;
|
|
|
|
write_memory (addr, val, len);
|
|
|
|
stack_offset += align_up (len, 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
regcache_cooked_write_signed (regcache, TIC6X_SP_REGNUM, sp);
|
|
|
|
|
|
|
|
/* Return adjusted stack pointer. */
|
|
|
|
return sp;
|
|
|
|
}
|
|
|
|
|
2015-05-26 18:59:17 +08:00
|
|
|
/* This is the implementation of gdbarch method stack_frame_destroyed_p. */
|
2011-08-14 22:03:45 +08:00
|
|
|
|
|
|
|
static int
|
2015-05-26 18:59:17 +08:00
|
|
|
tic6x_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
|
2011-08-14 22:03:45 +08:00
|
|
|
{
|
|
|
|
unsigned long inst = tic6x_fetch_instruction (gdbarch, pc);
|
|
|
|
/* Normally, the epilogue is composed by instruction `b .S2 b3'. */
|
|
|
|
if ((inst & 0x0f83effc) == 0x360)
|
|
|
|
{
|
|
|
|
unsigned int src2 = tic6x_register_number ((inst >> 18) & 0x1f,
|
|
|
|
INST_S_BIT (inst),
|
|
|
|
INST_X_BIT (inst));
|
|
|
|
if (src2 == TIC6X_RA_REGNUM)
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is the implementation of gdbarch method get_longjmp_target. */
|
|
|
|
|
|
|
|
static int
|
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
|
|
|
tic6x_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc)
|
2011-08-14 22:03:45 +08:00
|
|
|
{
|
|
|
|
struct gdbarch *gdbarch = get_frame_arch (frame);
|
|
|
|
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
|
|
|
|
CORE_ADDR jb_addr;
|
Use gdb_byte for bytes from the program being debugged.
gdb_byte should be used for bytes from the program being debugged. We
have many places using char or unsigned char instead all over the
existing ports, and more ends up added over time due to copy/paste as
new code is based on old code.
I've greped the tree for "char buf[", and fixed all I found.
Tested by building with --enable-targets=all.
2013-03-01 Pedro Alves <palves@redhat.com>
Use gdb_byte for bytes from the program being debugged.
* arm-tdep.c (arm_store_return_value, arm_get_longjmp_target):
Change type of local 'buf' to gdb_byte.
* avr-tdep.c (avr_frame_prev_register, avr_push_dummy_call): Likewise.
* bfin-tdep.c (bfin_push_dummy_call): Likewise.
* cris-tdep.c (cris_sigcontext_addr)
(cris_sigtramp_frame_unwind_cache): Likewise.
* frv-linux-tdep.c (frv_linux_pc_in_sigtramp)
(frv_linux_sigcontext_reg_addr, frv_linux_sigtramp_frame_cache):
Likewise.
* frv-tdep.c (frv_pseudo_register_write, frv_analyze_prologue): Likewise.
* hppa-hpux-tdep.c (hppa32_hpux_find_global_pointer)
(hppa32_hpux_search_dummy_call_sequence)
(hppa_hpux_supply_save_state): Likewise.
* hppa-linux-tdep.c (insns_match_pattern)
(hppa_linux_find_global_pointer): Likewise.
* hppa-tdep.c (hppa_in_function_epilogue_p)
(skip_prologue_hard_way, hppa_frame_cache): Likewise.
* i386-nto-tdep.c (i386nto_sigcontext_addr): Likewise.
* i386fbsd-tdep.c (i386fbsd_supply_uthread)
(i386fbsd_collect_uthread): Likewise.
* ia64-hpux-tdep.c (ia64_hpux_push_dummy_code): Likewise.
* ia64-linux-tdep.c (ia64_linux_sigcontext_register_address): Likewise.
* ia64-tdep.c (examine_prologue, ia64_frame_cache)
(ia64_frame_prev_register, ia64_sigtramp_frame_cache)
(ia64_sigtramp_frame_prev_register, ia64_access_reg)
(ia64_access_rse_reg, ia64_libunwind_frame_this_id)
(ia64_libunwind_frame_prev_register)
(ia64_libunwind_sigtramp_frame_this_id)
(ia64_find_global_pointer_from_dynamic_section)
(find_extant_func_descr, find_func_descr, ia64_dummy_id)
(ia64_unwind_pc): Likewise.
* iq2000-tdep.c (iq2000_store_return_value): Likewise.
* m68hc11-tdep.c (m68hc11_push_dummy_call)
(m68hc11_extract_return_value): Likewise.
* m68klinux-nat.c (fetch_register, store_register): Likewise.
* mep-tdep.c (mep_pseudo_cr32_read, mep_pseudo_cr32_write)
(mep_get_insn, mep_push_dummy_call): Likewise.
* mips-linux-tdep.c (mips_linux_get_longjmp_target)
(mips_linux_in_dynsym_stub): Likewise.
* mn10300-tdep.c (mep_pseudo_cr32_write): Likewise.
* ppc-linux-nat.c (fetch_register, store_register): Likewise.
* regcache.c (dump_endian_bytes): Change type of parameter 'buf'
to gdb_byte.
* remote-mips.c (mips_set_register): Likewise.
* remote-sim.c (gdbsim_fetch_register): Likewise.
* score-tdep.c (score7_fetch_inst): Change type of parameter
'memblock' and local 'buf' to gdb_byte.
(score7_malloc_and_get_memblock): Change return type to gdb_byte.
Change type of local 'buf' to gdb_byte. Adjust.
(score7_adjust_memblock_ptr): Change type of parameter 'memblock'
to gdb_byte**.
(score7_analyze_prologue): Change type of 'memblock' and
'memblock_ptr' locals to gdb_byte*.
* sh64-tdep.c (sh64_extract_return_value)
(sh64_store_return_value): Change type of local 'buf' to gdb_byte.
* solib-darwin.c (darwin_current_sos, darwin_read_exec_load_addr):
* solib-pa64.c (pa64_solib_create_inferior_hook)
(pa64_open_symbol_file_object): Remove local 'buf'.
* solib-som.c (som_solib_create_inferior_hook, link_map_start)
(som_open_symbol_file_object): Likewise.
* solib-spu.c (spu_current_sos): Likewise.
* spu-linux-nat.c (spu_fetch_inferior_registers): Likewise.
* spu-multiarch.c (parse_spufs_run, spu_fetch_registers)
(spu_store_registers): Likewise.
* target.c (debug_print_register): Likewise.
* tic6x-tdep.c (tic6x_get_longjmp_target): Likewise.
* xstormy16-tdep.c (xstormy16_store_return_value)
(xstormy16_push_dummy_call, xstormy16_resolve_jmp_table_entry)
(xstormy16_find_jmp_table_entry): Likewise.
2013-03-01 23:38:27 +08:00
|
|
|
gdb_byte buf[4];
|
2011-08-14 22:03:45 +08:00
|
|
|
|
|
|
|
/* JMP_BUF is passed by reference in A4. */
|
|
|
|
jb_addr = get_frame_register_unsigned (frame, 4);
|
|
|
|
|
|
|
|
/* JMP_BUF contains 13 elements of type int, and return address is stored
|
|
|
|
in the last slot. */
|
|
|
|
if (target_read_memory (jb_addr + 12 * 4, buf, 4))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
*pc = extract_unsigned_integer (buf, 4, byte_order);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-06-08 22:24:57 +08:00
|
|
|
/* This is the implementation of gdbarch method
|
|
|
|
return_in_first_hidden_param_p. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
tic6x_return_in_first_hidden_param_p (struct gdbarch *gdbarch,
|
|
|
|
struct type *type)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-08-14 22:03:45 +08:00
|
|
|
static struct gdbarch *
|
|
|
|
tic6x_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
|
|
|
|
{
|
2020-09-18 04:11:38 +08:00
|
|
|
tdesc_arch_data_up tdesc_data;
|
2011-08-14 22:03:45 +08:00
|
|
|
const struct target_desc *tdesc = info.target_desc;
|
|
|
|
int has_gp = 0;
|
|
|
|
|
|
|
|
/* Check any target description for validity. */
|
|
|
|
if (tdesc_has_registers (tdesc))
|
|
|
|
{
|
|
|
|
const struct tdesc_feature *feature;
|
|
|
|
int valid_p, i;
|
|
|
|
|
|
|
|
feature = tdesc_find_feature (tdesc, "org.gnu.gdb.tic6x.core");
|
|
|
|
|
|
|
|
if (feature == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
tdesc_data = tdesc_data_alloc ();
|
|
|
|
|
|
|
|
valid_p = 1;
|
|
|
|
for (i = 0; i < 32; i++) /* A0 - A15, B0 - B15 */
|
2020-09-18 04:11:38 +08:00
|
|
|
valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), i,
|
2011-08-14 22:03:45 +08:00
|
|
|
tic6x_register_names[i]);
|
|
|
|
|
|
|
|
/* CSR */
|
2020-09-18 04:11:38 +08:00
|
|
|
valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), i++,
|
2011-08-14 22:03:45 +08:00
|
|
|
tic6x_register_names[TIC6X_CSR_REGNUM]);
|
2020-09-18 04:11:38 +08:00
|
|
|
valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), i++,
|
2011-08-14 22:03:45 +08:00
|
|
|
tic6x_register_names[TIC6X_PC_REGNUM]);
|
|
|
|
|
|
|
|
if (!valid_p)
|
2020-09-18 04:11:38 +08:00
|
|
|
return NULL;
|
2011-08-14 22:03:45 +08:00
|
|
|
|
|
|
|
feature = tdesc_find_feature (tdesc, "org.gnu.gdb.tic6x.gp");
|
|
|
|
if (feature)
|
|
|
|
{
|
|
|
|
int j = 0;
|
|
|
|
static const char *const gp[] =
|
|
|
|
{
|
|
|
|
"A16", "A17", "A18", "A19", "A20", "A21", "A22", "A23",
|
|
|
|
"A24", "A25", "A26", "A27", "A28", "A29", "A30", "A31",
|
|
|
|
"B16", "B17", "B18", "B19", "B20", "B21", "B22", "B23",
|
|
|
|
"B24", "B25", "B26", "B27", "B28", "B29", "B30", "B31",
|
|
|
|
};
|
|
|
|
|
|
|
|
has_gp = 1;
|
|
|
|
valid_p = 1;
|
|
|
|
for (j = 0; j < 32; j++) /* A16 - A31, B16 - B31 */
|
2020-09-18 04:11:38 +08:00
|
|
|
valid_p &= tdesc_numbered_register (feature, tdesc_data.get (),
|
|
|
|
i++, gp[j]);
|
2011-08-14 22:03:45 +08:00
|
|
|
|
|
|
|
if (!valid_p)
|
2020-09-18 04:11:38 +08:00
|
|
|
return NULL;
|
2011-08-14 22:03:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
feature = tdesc_find_feature (tdesc, "org.gnu.gdb.tic6x.c6xp");
|
|
|
|
if (feature)
|
|
|
|
{
|
2020-09-18 04:11:38 +08:00
|
|
|
valid_p &= tdesc_numbered_register (feature, tdesc_data.get (),
|
|
|
|
i++, "TSR");
|
|
|
|
valid_p &= tdesc_numbered_register (feature, tdesc_data.get (),
|
|
|
|
i++, "ILC");
|
|
|
|
valid_p &= tdesc_numbered_register (feature, tdesc_data.get (),
|
|
|
|
i++, "RILC");
|
2011-08-14 22:03:45 +08:00
|
|
|
|
|
|
|
if (!valid_p)
|
2020-09-18 04:11:38 +08:00
|
|
|
return NULL;
|
2011-08-14 22:03:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Find a candidate among extant architectures. */
|
|
|
|
for (arches = gdbarch_list_lookup_by_info (arches, &info);
|
|
|
|
arches != NULL;
|
|
|
|
arches = gdbarch_list_lookup_by_info (arches->next, &info))
|
|
|
|
{
|
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
|
|
|
tic6x_gdbarch_tdep *tdep
|
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
|
|
|
= gdbarch_tdep<tic6x_gdbarch_tdep> (arches->gdbarch);
|
2011-08-14 22:03:45 +08:00
|
|
|
|
|
|
|
if (has_gp != tdep->has_gp)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (tdep && tdep->breakpoint)
|
|
|
|
return arches->gdbarch;
|
|
|
|
}
|
|
|
|
|
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 tic6x_gdbarch_tdep));
|
|
|
|
tic6x_gdbarch_tdep *tdep = gdbarch_tdep<tic6x_gdbarch_tdep> (gdbarch);
|
2011-08-14 22:03:45 +08:00
|
|
|
|
|
|
|
tdep->has_gp = has_gp;
|
|
|
|
|
|
|
|
/* Data type sizes. */
|
|
|
|
set_gdbarch_ptr_bit (gdbarch, 32);
|
|
|
|
set_gdbarch_addr_bit (gdbarch, 32);
|
|
|
|
set_gdbarch_short_bit (gdbarch, 16);
|
|
|
|
set_gdbarch_int_bit (gdbarch, 32);
|
|
|
|
set_gdbarch_long_bit (gdbarch, 32);
|
|
|
|
set_gdbarch_long_long_bit (gdbarch, 64);
|
|
|
|
set_gdbarch_float_bit (gdbarch, 32);
|
|
|
|
set_gdbarch_double_bit (gdbarch, 64);
|
|
|
|
|
|
|
|
set_gdbarch_float_format (gdbarch, floatformats_ieee_single);
|
|
|
|
set_gdbarch_double_format (gdbarch, floatformats_ieee_double);
|
|
|
|
|
|
|
|
/* The register set. */
|
|
|
|
set_gdbarch_num_regs (gdbarch, TIC6X_NUM_REGS);
|
|
|
|
set_gdbarch_sp_regnum (gdbarch, TIC6X_SP_REGNUM);
|
|
|
|
set_gdbarch_pc_regnum (gdbarch, TIC6X_PC_REGNUM);
|
|
|
|
|
|
|
|
set_gdbarch_register_name (gdbarch, tic6x_register_name);
|
|
|
|
set_gdbarch_register_type (gdbarch, tic6x_register_type);
|
|
|
|
|
|
|
|
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
|
|
|
|
|
|
|
|
set_gdbarch_skip_prologue (gdbarch, tic6x_skip_prologue);
|
2016-11-03 22:35:14 +08:00
|
|
|
set_gdbarch_breakpoint_kind_from_pc (gdbarch,
|
|
|
|
tic6x_breakpoint_kind_from_pc);
|
|
|
|
set_gdbarch_sw_breakpoint_from_kind (gdbarch,
|
|
|
|
tic6x_sw_breakpoint_from_kind);
|
2011-08-14 22:03:45 +08:00
|
|
|
|
|
|
|
set_gdbarch_unwind_pc (gdbarch, tic6x_unwind_pc);
|
|
|
|
|
|
|
|
/* Unwinding. */
|
|
|
|
dwarf2_append_unwinders (gdbarch);
|
|
|
|
|
|
|
|
frame_unwind_append_unwinder (gdbarch, &tic6x_stub_unwind);
|
|
|
|
frame_unwind_append_unwinder (gdbarch, &tic6x_frame_unwind);
|
2014-02-11 02:00:01 +08:00
|
|
|
frame_base_set_default (gdbarch, &tic6x_frame_base);
|
2011-08-14 22:03:45 +08:00
|
|
|
|
|
|
|
dwarf2_frame_set_init_reg (gdbarch, tic6x_dwarf2_frame_init_reg);
|
|
|
|
|
|
|
|
/* Single stepping. */
|
|
|
|
set_gdbarch_software_single_step (gdbarch, tic6x_software_single_step);
|
|
|
|
|
|
|
|
/* Call dummy code. */
|
|
|
|
set_gdbarch_frame_align (gdbarch, tic6x_frame_align);
|
|
|
|
|
|
|
|
set_gdbarch_return_value (gdbarch, tic6x_return_value);
|
|
|
|
|
|
|
|
/* Enable inferior call support. */
|
|
|
|
set_gdbarch_push_dummy_call (gdbarch, tic6x_push_dummy_call);
|
|
|
|
|
|
|
|
set_gdbarch_get_longjmp_target (gdbarch, tic6x_get_longjmp_target);
|
|
|
|
|
2015-05-26 18:59:17 +08:00
|
|
|
set_gdbarch_stack_frame_destroyed_p (gdbarch, tic6x_stack_frame_destroyed_p);
|
2011-08-14 22:03:45 +08:00
|
|
|
|
2012-06-08 22:24:57 +08:00
|
|
|
set_gdbarch_return_in_first_hidden_param_p (gdbarch,
|
|
|
|
tic6x_return_in_first_hidden_param_p);
|
|
|
|
|
2011-08-14 22:03:45 +08:00
|
|
|
/* Hook in ABI-specific overrides, if they have been registered. */
|
|
|
|
gdbarch_init_osabi (info, gdbarch);
|
|
|
|
|
2020-09-18 04:11:38 +08:00
|
|
|
if (tdesc_data != nullptr)
|
|
|
|
tdesc_use_registers (gdbarch, tdesc, std::move (tdesc_data));
|
2011-08-14 22:03:45 +08:00
|
|
|
|
|
|
|
return gdbarch;
|
|
|
|
}
|
|
|
|
|
2020-01-14 03:01:38 +08:00
|
|
|
void _initialize_tic6x_tdep ();
|
2011-08-14 22:03:45 +08:00
|
|
|
void
|
2020-01-14 03:01:38 +08:00
|
|
|
_initialize_tic6x_tdep ()
|
2011-08-14 22:03:45 +08:00
|
|
|
{
|
2022-08-01 00:44:01 +08:00
|
|
|
gdbarch_register (bfd_arch_tic6x, tic6x_gdbarch_init);
|
2011-08-14 22:03:45 +08:00
|
|
|
}
|