44 size_t len = x->
buf.size ();
45 x->
buf.resize (len + n);
46 for (
int i = n - 1; i >= 0; i--)
48 x->
buf[len + i] = val & 0xff;
63 if (o + n > x->
buf.size ())
64 error (_(
"GDB bug: ax-general.c (read_const): incomplete constant"));
66 for (i = 0; i < n; i++)
67 accum = (accum << 8) | x->
buf[o + i];
77 x->
buf.push_back (
byte);
93 if (depth < 0 || depth > 255)
94 error (_(
"GDB bug: ax-general.c (ax_pick): stack depth out of range"));
106 if (n < 0 || n > 255)
107 error (_(
"GDB bug: ax-general.c (generic_ext): bit count out of range"));
109 if (
sizeof (LONGEST) * 8 > 255)
110 error (_(
"GDB bug: ax-general.c (generic_ext): "
111 "opcode has inadequate range"));
113 x->
buf.push_back (op);
114 x->
buf.push_back (n);
139 if (n < 0 || n > 255)
140 error (_(
"GDB bug: ax-general.c (ax_trace_quick): "
141 "size out of range for trace_quick"));
143 x->
buf.push_back (aop_trace_quick);
144 x->
buf.push_back (n);
157 x->
buf.push_back (op);
158 x->
buf.push_back (0xff);
159 x->
buf.push_back (0xff);
160 return x->
buf.size () - 2;
172 if (target < 0 || target >= 0xffff)
173 error (_(
"GDB bug: ax-general.c (ax_label): label target out of range"));
175 x->
buf[patch] = (target >> 8) & 0xff;
176 x->
buf[patch + 1] = target & 0xff;
186 {aop_const8, aop_const16, aop_const32, aop_const64};
196 LONGEST lim = ((LONGEST) 1) << (
size - 1);
198 if (-lim <= l && l <= lim - 1)
210 if (l < 0 &&
size < 64)
219 error (_(
"GDB bug: ax-general.c (ax_const_d): "
220 "floating point not supported yet"));
233 error (_(
"'%s' is a pseudo-register; "
234 "GDB cannot yet trace its contents."),
237 error (_(
"Trace '%s' failed."),
246 if (reg < 0 || reg > 0xffff)
247 error (_(
"GDB bug: ax-general.c (ax_reg): "
248 "register number out of range"));
249 x->
buf.push_back (aop_reg);
250 x->
buf.push_back ((reg >> 8) & 0xff);
251 x->
buf.push_back ((reg) & 0xff);
261 if (num < 0 || num > 0xffff)
262 internal_error (_(
"ax-general.c (ax_tsv): variable "
263 "number is %d, out of range"), num);
265 x->
buf.push_back (op);
266 x->
buf.push_back ((num >> 8) & 0xff);
267 x->
buf.push_back ((num) & 0xff);
281 if (slen < 0 || slen > 0xffff)
282 internal_error (_(
"ax-general.c (ax_string): string "
283 "length is %d, out of allowed range"), slen);
285 x->
buf.push_back (((slen + 1) >> 8) & 0xff);
286 x->
buf.push_back ((slen + 1) & 0xff);
287 for (i = 0; i < slen; ++i)
288 x->
buf.push_back (str[i]);
289 x->
buf.push_back (
'\0');
329#define DEFOP(NAME, SIZE, DATA_SIZE, CONSUMED, PRODUCED, VALUE) \
330 , { # NAME, SIZE, DATA_SIZE, CONSUMED, PRODUCED }
331#include "gdbsupport/ax.def"
344 for (i = 0; i < x->
reg_mask.size (); ++i)
352 for (i = 0; i < x->
buf.size ();)
358 gdb_printf (
f, _(
"%3d <bad opcode %02x>\n"), i, op);
378 else if (op == aop_printf)
385 slen = slen * 256 + x->
buf[i++];
387 &(x->
buf[i]), nargs);
403 error (_(
"'%s' is a pseudo-register; "
404 "GDB cannot yet trace its contents."),
407 error (_(
"Trace '%s' failed."),
433 char *targets = (
char *) alloca (ax->
buf.size () *
sizeof (targets[0]));
437 char *boundary = (
char *) alloca (ax->
buf.size () *
sizeof (boundary[0]));
442 int *heights = (
int *) alloca (ax->
buf.size () *
sizeof (heights[0]));
447 memset (targets, 0, ax->
buf.size () * sizeof (targets[0]));
448 memset (boundary, 0, ax->
buf.size () * sizeof (boundary[0]));
454 for (i = 0; i < ax->
buf.size (); i += 1 + op->
op_size)
479 if (targets[i] && (heights[i] != height))
489 if (height < ax->min_height)
502 || aop_if_goto == op -
aop_map)
505 if (target < 0 || target >= ax->
buf.size ())
513 if (targets[target] || boundary[target])
515 if (heights[target] != height)
524 heights[target] = height;
530 && i + 3 < ax->
buf.size ())
538 height = heights[i + 3];
551 for (i = 0; i < ax->
buf.size (); i++)
552 if (targets[i] && !boundary[i])
static void generic_ext(struct agent_expr *x, enum agent_op op, int n)
void ax_reqs(struct agent_expr *ax)
static void append_const(struct agent_expr *x, LONGEST val, int n)
void ax_label(struct agent_expr *x, int patch, int target)
void ax_zero_ext(struct agent_expr *x, int n)
void ax_print(struct ui_file *f, struct agent_expr *x)
void ax_string(struct agent_expr *x, const char *str, int slen)
void ax_reg_mask(struct agent_expr *ax, int reg)
void ax_simple(struct agent_expr *x, enum agent_op op)
void ax_raw_byte(struct agent_expr *x, gdb_byte byte)
void ax_const_d(struct agent_expr *x, LONGEST d)
void ax_pick(struct agent_expr *x, int depth)
void ax_const_l(struct agent_expr *x, LONGEST l)
void ax_ext(struct agent_expr *x, int n)
void ax_tsv(struct agent_expr *x, enum agent_op op, int num)
int ax_goto(struct agent_expr *x, enum agent_op op)
void ax_reg(struct agent_expr *x, int reg)
static LONGEST read_const(struct agent_expr *x, int o, int n)
void ax_trace_quick(struct agent_expr *x, int n)
@ agent_flaw_height_mismatch
@ agent_flaw_bad_instruction
@ agent_flaw_incomplete_instruction
bool gdbarch_ax_pseudo_register_push_stack_p(struct gdbarch *gdbarch)
int gdbarch_ax_pseudo_register_collect(struct gdbarch *gdbarch, struct agent_expr *ax, int reg)
int gdbarch_num_regs(struct gdbarch *gdbarch)
int gdbarch_remote_register_number(struct gdbarch *gdbarch, int regno)
bool gdbarch_ax_pseudo_register_collect_p(struct gdbarch *gdbarch)
int gdbarch_ax_pseudo_register_push_stack(struct gdbarch *gdbarch, struct agent_expr *ax, int reg)
std::vector< bool > reg_mask
const char * user_reg_map_regnum_to_name(struct gdbarch *gdbarch, int regnum)
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
void gdb_printf(struct ui_file *stream, const char *format,...)
void gdb_puts(const char *linebuffer, struct ui_file *stream)
void print_longest(struct ui_file *stream, int format, int use_c_format, LONGEST val_long)