Exemplo n.º 1
0
/* Assemble code to push the value of register number REG on the
   stack.  */
void
ax_reg (struct agent_expr *x, int reg)
{
  if (reg >= gdbarch_num_regs (x->gdbarch))
    {
      /* This is a pseudo-register.  */
      if (!gdbarch_ax_pseudo_register_push_stack_p (x->gdbarch))
	error (_("'%s' is a pseudo-register; "
		 "GDB cannot yet trace its contents."),
	       user_reg_map_regnum_to_name (x->gdbarch, reg));
      if (gdbarch_ax_pseudo_register_push_stack (x->gdbarch, x, reg))
	error (_("Trace '%s' failed."),
	       user_reg_map_regnum_to_name (x->gdbarch, reg));
    }
  else
    {
      /* Make sure the register number is in range.  */
      if (reg < 0 || reg > 0xffff)
        error (_("GDB bug: ax-general.c (ax_reg): "
		 "register number out of range"));
      grow_expr (x, 3);
      x->buf[x->len] = aop_reg;
      x->buf[x->len + 1] = (reg >> 8) & 0xff;
      x->buf[x->len + 2] = (reg) & 0xff;
      x->len += 3;
    }
}
Exemplo n.º 2
0
/* Append a goto op to EXPR.  OP is the actual op (must be aop_goto or
   aop_if_goto).  We assume we don't know the target offset yet,
   because it's probably a forward branch, so we leave space in EXPR
   for the target, and return the offset in EXPR of that space, so we
   can backpatch it once we do know the target offset.  Use ax_label
   to do the backpatching.  */
int
ax_goto(struct agent_expr *x, enum agent_op op)
{
  grow_expr(x, 3);
  x->buf[x->len + 0] = (unsigned char)op;
  x->buf[x->len + 1] = 0xff;
  x->buf[x->len + 2] = 0xff;
  x->len += 3;
  return (int)(x->len - 2UL);
}
Exemplo n.º 3
0
/* Append a goto op to EXPR.  OP is the actual op (must be aop_goto or
   aop_if_goto).  We assume we don't know the target offset yet,
   because it's probably a forward branch, so we leave space in EXPR
   for the target, and return the offset in EXPR of that space, so we
   can backpatch it once we do know the target offset.  Use ax_label
   to do the backpatching.  */
int
ax_goto (struct agent_expr *x, enum agent_op op)
{
  grow_expr (x, 3);
  x->buf[x->len + 0] = op;
  x->buf[x->len + 1] = 0xff;
  x->buf[x->len + 2] = 0xff;
  x->len += 3;
  return x->len - 2;
}
Exemplo n.º 4
0
/* Append a trace_quick instruction to EXPR, to record N bytes.  */
void
ax_trace_quick (struct agent_expr *x, int n)
{
  /* N must fit in a byte.  */
  if (n < 0 || n > 255)
    error (_("GDB bug: ax-general.c (ax_trace_quick): size out of range for trace_quick"));

  grow_expr (x, 2);
  x->buf[x->len++] = aop_trace_quick;
  x->buf[x->len++] = n;
}
Exemplo n.º 5
0
/* Assemble code to push the value of register number REG on the
   stack.  */
void
ax_reg (struct agent_expr *x, int reg)
{
  /* Make sure the register number is in range.  */
  if (reg < 0 || reg > 0xffff)
    error (_("GDB bug: ax-general.c (ax_reg): register number out of range"));
  grow_expr (x, 3);
  x->buf[x->len] = aop_reg;
  x->buf[x->len + 1] = (reg >> 8) & 0xff;
  x->buf[x->len + 2] = (reg) & 0xff;
  x->len += 3;
}
Exemplo n.º 6
0
/* Append the low N bytes of VAL as an N-byte integer to the
   expression X, in big-endian order.  */
static void
append_const (struct agent_expr *x, LONGEST val, int n)
{
  int i;

  grow_expr (x, n);
  for (i = n - 1; i >= 0; i--)
    {
      x->buf[x->len + i] = val & 0xff;
      val >>= 8;
    }
  x->len += n;
}
Exemplo n.º 7
0
/* Append the low N bytes of VAL as an N-byte integer to the
   expression X, in big-endian order.  */
static void
append_const(struct agent_expr *x, LONGEST val, int n)
{
  int i;

  grow_expr(x, n);
  for (i = (n - 1); i >= 0; i--)
    {
      x->buf[x->len + (size_t)i] = (val & 0xff);
      val >>= 8;
    }
  x->len += (size_t)n;
}
Exemplo n.º 8
0
/* Append a sign-extension or zero-extension instruction to EXPR, to
   extend an N-bit value.  */
static void
generic_ext (struct agent_expr *x, enum agent_op op, int n)
{
  /* N must fit in a byte.  */
  if (n < 0 || n > 255)
    error (_("GDB bug: ax-general.c (generic_ext): bit count out of range"));
  /* That had better be enough range.  */
  if (sizeof (LONGEST) * 8 > 255)
    error (_("GDB bug: ax-general.c (generic_ext): opcode has inadequate range"));

  grow_expr (x, 2);
  x->buf[x->len++] = op;
  x->buf[x->len++] = n;
}
Exemplo n.º 9
0
/* Append a sign-extension or zero-extension instruction to EXPR, to
   extend an N-bit value.  */
static void
generic_ext(struct agent_expr *x, enum agent_op op, int n)
{
  /* N must fit in a byte: */
  if ((n < 0) || (n > 255))
    error(_("GDB bug: ax-general.c (generic_ext): bit count out of range"));
  /* That had better be enough range: */
  if ((sizeof(LONGEST) * 8UL) > 255UL)
    error(_("GDB bug: ax-general.c (generic_ext): opcode has inadequate range"));

  grow_expr(x, 2);
  x->buf[x->len++] = (unsigned char)op;
  x->buf[x->len++] = (char)n;
}
Exemplo n.º 10
0
void
ax_tsv (struct agent_expr *x, enum agent_op op, int num)
{
  /* Make sure the tsv number is in range.  */
  if (num < 0 || num > 0xffff)
    internal_error (__FILE__, __LINE__, 
		    _("ax-general.c (ax_tsv): variable "
		      "number is %d, out of range"), num);

  grow_expr (x, 3);
  x->buf[x->len] = op;
  x->buf[x->len + 1] = (num >> 8) & 0xff;
  x->buf[x->len + 2] = (num) & 0xff;
  x->len += 3;
}
Exemplo n.º 11
0
void
ax_string (struct agent_expr *x, char *str, int slen)
{
  int i;

  /* Make sure the string length is reasonable.  */
  if (slen < 0 || slen > 0xffff)
    internal_error (__FILE__, __LINE__, 
		    _("ax-general.c (ax_string): string "
		      "length is %d, out of allowed range"), slen);

  grow_expr (x, 2 + slen + 1);
  x->buf[x->len++] = ((slen + 1) >> 8) & 0xff;
  x->buf[x->len++] = (slen + 1) & 0xff;
  for (i = 0; i < slen; ++i)
    x->buf[x->len++] = str[i];
  x->buf[x->len++] = '\0';
}
Exemplo n.º 12
0
/* Append a simple operator OP to EXPR.  */
void
ax_simple (struct agent_expr *x, enum agent_op op)
{
  grow_expr (x, 1);
  x->buf[x->len++] = op;
}