/* Target-dependent code for GDB, the GNU debugger.
- Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
- 2011 Free Software Foundation, Inc.
+ Copyright (C) 2001-2013 Free Software Foundation, Inc.
Contributed by D.J. Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
for IBM Deutschland Entwicklung GmbH, IBM Corporation.
#include "linux-tdep.h"
#include "s390-tdep.h"
+#include "stap-probe.h"
+#include "ax.h"
+#include "ax-gdb.h"
+#include "user-regs.h"
+#include "cli/cli-utils.h"
+#include <ctype.h>
+
#include "features/s390-linux32.c"
#include "features/s390-linux32v1.c"
#include "features/s390-linux32v2.c"
#include "features/s390x-linux64v1.c"
#include "features/s390x-linux64v2.c"
-
/* The tdep structure. */
struct gdbarch_tdep
S390_R8_REGNUM, S390_R9_REGNUM, S390_R10_REGNUM, S390_R11_REGNUM,
S390_R12_REGNUM, S390_R13_REGNUM, S390_R14_REGNUM, S390_R15_REGNUM,
- /* Linux-specific registers (not mapped). */
+ /* GNU/Linux-specific registers (not mapped). */
-1, -1, -1,
};
struct frame_info *frame)
{
struct value *value = default_value_from_register (type, regnum, frame);
- int len = TYPE_LENGTH (check_typedef (type));
- if (regnum >= S390_F0_REGNUM && regnum <= S390_F15_REGNUM && len < 8)
+ check_typedef (type);
+
+ if (regnum >= S390_F0_REGNUM && regnum <= S390_F15_REGNUM
+ && TYPE_LENGTH (type) < 8)
set_value_offset (value, 0);
return value;
/* GPR Uppper Halves. */
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
- /* Linux-specific optional "registers". */
+ /* GNU/Linux-specific optional "registers". */
0x88, -1, -1,
};
0x30, 0x38, 0x40, 0x48,
0x50, 0x58, 0x60, 0x68,
0x70, 0x78, 0x80, 0x88,
- /* Linux-specific optional "registers". */
+ /* GNU/Linux-specific optional "registers". */
0xd0, -1, -1,
};
/* GPR Uppper Halves. */
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
- /* Linux-specific optional "registers". */
+ /* GNU/Linux-specific optional "registers". */
-1, -1, -1,
};
0x10, 0x14, 0x18, 0x1c,
0x20, 0x24, 0x28, 0x2c,
0x30, 0x34, 0x38, 0x3c,
- /* Linux-specific optional "registers". */
+ /* GNU/Linux-specific optional "registers". */
-1, -1, -1,
};
/* GPR Uppper Halves. */
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
- /* Linux-specific optional "registers". */
+ /* GNU/Linux-specific optional "registers". */
-1, 4, -1,
};
/* GPR Uppper Halves. */
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
- /* Linux-specific optional "registers". */
+ /* GNU/Linux-specific optional "registers". */
-1, 0, -1,
};
/* GPR Uppper Halves. */
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
- /* Linux-specific optional "registers". */
+ /* GNU/Linux-specific optional "registers". */
-1, -1, 0,
};
static int
is_rs (bfd_byte *insn, int op,
- unsigned int *r1, unsigned int *r3, unsigned int *d2, unsigned int *b2)
+ unsigned int *r1, unsigned int *r3, int *d2, unsigned int *b2)
{
if (insn[0] == op)
{
static int
is_rsy (bfd_byte *insn, int op1, int op2,
- unsigned int *r1, unsigned int *r3, unsigned int *d2, unsigned int *b2)
+ unsigned int *r1, unsigned int *r3, int *d2, unsigned int *b2)
{
if (insn[0] == op1
&& insn[5] == op2)
static int
is_rx (bfd_byte *insn, int op,
- unsigned int *r1, unsigned int *d2, unsigned int *x2, unsigned int *b2)
+ unsigned int *r1, int *d2, unsigned int *x2, unsigned int *b2)
{
if (insn[0] == op)
{
static int
is_rxy (bfd_byte *insn, int op1, int op2,
- unsigned int *r1, unsigned int *d2, unsigned int *x2, unsigned int *b2)
+ unsigned int *r1, int *d2, unsigned int *x2, unsigned int *b2)
{
if (insn[0] == op1
&& insn[5] == op2)
{
pv_t addr = s390_addr (data, d2, x2, b2);
- pv_t offset;
/* If it's a load from an in-line constant pool, then we can
simulate that, under the assumption that the code isn't
struct target_section *secp;
secp = target_section_by_addr (¤t_target, addr.k);
if (secp != NULL
- && (bfd_get_section_flags (secp->bfd, secp->the_bfd_section)
+ && (bfd_get_section_flags (secp->the_bfd_section->owner,
+ secp->the_bfd_section)
& SEC_READONLY))
return pv_constant (read_memory_integer (addr.k, size,
data->byte_order));
break;
else
- /* An instruction we don't know how to simulate. The only
- safe thing to do would be to set every value we're tracking
- to 'unknown'. Instead, we'll be optimistic: we assume that
- we *can* interpret every instruction that the compiler uses
- to manipulate any of the data we're interested in here --
- then we can just ignore anything else. */
- ;
+ {
+ /* An instruction we don't know how to simulate. The only
+ safe thing to do would be to set every value we're tracking
+ to 'unknown'. Instead, we'll be optimistic: we assume that
+ we *can* interpret every instruction that the compiler uses
+ to manipulate any of the data we're interested in here --
+ then we can just ignore anything else. */
+ }
/* Record the address after the last instruction that changed
the FP, SP, or backlink. Ignore instructions that changed
have trapped due to an invalid function pointer call. We handle
the non-existing current function like a PLT stub. */
addr_in_block = get_frame_address_in_block (this_frame);
- if (in_plt_section (addr_in_block, NULL)
+ if (in_plt_section (addr_in_block)
|| s390_readinstruction (insn, get_frame_pc (this_frame)) < 0)
return 1;
return 0;
static int
s390_function_arg_pass_by_reference (struct type *type)
{
- unsigned length = TYPE_LENGTH (type);
- if (length > 8)
+ if (TYPE_LENGTH (type) > 8)
return 1;
return (is_struct_like (type) && !is_power_of_two (TYPE_LENGTH (type)))
static int
s390_function_arg_float (struct type *type)
{
- unsigned length = TYPE_LENGTH (type);
- if (length > 8)
+ if (TYPE_LENGTH (type) > 8)
return 0;
return is_float_like (type);
static int
s390_function_arg_integer (struct type *type)
{
- unsigned length = TYPE_LENGTH (type);
- if (length > 8)
+ if (TYPE_LENGTH (type) > 8)
return 0;
return is_integer_like (type)
|| is_pointer_like (type)
- || (is_struct_like (type) && is_power_of_two (length));
+ || (is_struct_like (type) && is_power_of_two (TYPE_LENGTH (type)));
}
/* Return ARG, a `SIMPLE_ARG', sign-extended or zero-extended to a full
{
struct value *arg = args[i];
struct type *type = check_typedef (value_type (arg));
- unsigned length = TYPE_LENGTH (type);
if (s390_function_arg_pass_by_reference (type))
{
- sp -= length;
+ sp -= TYPE_LENGTH (type);
sp = align_down (sp, alignment_of (type));
copy_addr[i] = sp;
}
}
}
- /* Store return address. */
+ /* Store return PSWA. In 31-bit mode, keep addressing mode bit. */
+ if (word_size == 4)
+ {
+ ULONGEST pswa;
+ regcache_cooked_read_unsigned (regcache, S390_PSWA_REGNUM, &pswa);
+ bp_addr = (bp_addr & 0x7fffffff) | (pswa & 0x80000000);
+ }
regcache_cooked_write_unsigned (regcache, S390_RETADDR_REGNUM, bp_addr);
-
+
/* Store updated stack pointer. */
regcache_cooked_write_unsigned (regcache, S390_SP_REGNUM, sp);
static enum return_value_convention
s390_return_value_convention (struct gdbarch *gdbarch, struct type *type)
{
- int length = TYPE_LENGTH (type);
- if (length > 8)
+ if (TYPE_LENGTH (type) > 8)
return RETURN_VALUE_STRUCT_CONVENTION;
switch (TYPE_CODE (type))
}
static enum return_value_convention
-s390_return_value (struct gdbarch *gdbarch, struct type *func_type,
+s390_return_value (struct gdbarch *gdbarch, struct value *function,
struct type *type, struct regcache *regcache,
gdb_byte *out, const gdb_byte *in)
{
return 0;
}
+/* Implementation of `gdbarch_stap_is_single_operand', as defined in
+ gdbarch.h. */
+
+static int
+s390_stap_is_single_operand (struct gdbarch *gdbarch, const char *s)
+{
+ return ((isdigit (*s) && s[1] == '(' && s[2] == '%') /* Displacement
+ or indirection. */
+ || *s == '%' /* Register access. */
+ || isdigit (*s)); /* Literal number. */
+}
+
/* Set up gdbarch struct. */
static struct gdbarch *
valid_p &= tdesc_numbered_register (feature, tdesc_data,
S390_A0_REGNUM + i, acrs[i]);
- /* Optional Linux-specific "registers". */
+ /* Optional GNU/Linux-specific "registers". */
feature = tdesc_find_feature (tdesc, "org.gnu.gdb.s390.linux");
if (feature)
{
set_gdbarch_get_siginfo_type (gdbarch, linux_get_siginfo_type);
+ /* SystemTap functions. */
+ set_gdbarch_stap_register_prefix (gdbarch, "%");
+ set_gdbarch_stap_register_indirection_prefix (gdbarch, "(");
+ set_gdbarch_stap_register_indirection_suffix (gdbarch, ")");
+ set_gdbarch_stap_is_single_operand (gdbarch, s390_stap_is_single_operand);
+
return gdbarch;
}
/* Hook us into the gdbarch mechanism. */
register_gdbarch_init (bfd_arch_s390, s390_gdbarch_init);
- /* Initialize the Linux target descriptions. */
+ /* Initialize the GNU/Linux target descriptions. */
initialize_tdesc_s390_linux32 ();
initialize_tdesc_s390_linux32v1 ();
initialize_tdesc_s390_linux32v2 ();