Re: RFC: tracepoints: extend range of ax_trace_quick function

Michael Snyder
2007-10-27T08:11:21Z

On Fri, 2007-10-26 at 15:59 -0700, Jim Blandy wrote:
> In order to get Linux kernel tracepoints working, I needed to make a
> number of fixes in GDB. This is one such patch; the code which uses
> the function's new range comes a bit later.
>
> Okay to commit?

If I understand correctly, a trace_quick was formerly of size up to
8 bits. You've added a trace16 for objects up to 16 bits, and this
just allows trace_quick to handle those objects by forwarding them
to trace16.

In which case, it looks fine.

Michael

>
> gdb/ChangeLog:
> 2007-10-24 Jim Blandy <jimb@codesourcery.com>
>
> * ax-general.c (ax_trace_quick): Generate trace16 instructions for
> sizes from 256 to 65535.
>
> diff -r 7625042dd5a0 -r eb635294a14e gdb/ax-general.c
> --- a/gdb/ax-general.c Wed Oct 24 10:17:42 2007 -0700
> +++ b/gdb/ax-general.c Wed Oct 24 18:02:15 2007 -0700
> @@ -166,17 +166,29 @@ ax_zero_ext (struct agent_expr *x, int n
> }
>
>
> -/* Append a trace_quick instruction to EXPR, to record N bytes. */
> +/* Append a trace_quick or trace16 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;
> + if (n < 0)
> + internal_error (__FILE__, __LINE__,
> + _("ax_trace_quick: negative size"));
> + else if (n < (1 << 8))
> + {
> + grow_expr (x, 2);
> + x->buf[x->len++] = aop_trace_quick;
> + x->buf[x->len++] = n;
> + }
> + else if (n < (1 << 16))
> + {
> + grow_expr (x, 3);
> + x->buf[x->len++] = aop_trace16;
> + x->buf[x->len++] = n >> 8;
> + x->buf[x->len++] = n;
> + }
> + else
> + internal_error (__FILE__, __LINE__,
> + _("ax_trace_quick: size out of range"));
> }
>
>
> diff -r 7625042dd5a0 -r eb635294a14e gdb/ax.h
> --- a/gdb/ax.h Wed Oct 24 10:17:42 2007 -0700
> +++ b/gdb/ax.h Wed Oct 24 18:02:15 2007 -0700
> @@ -157,7 +157,8 @@ extern void ax_ext (struct agent_expr *E
> /* Append a zero-extension instruction to EXPR, to extend an N-bit value. */
> extern void ax_zero_ext (struct agent_expr *EXPR, int N);
>
> -/* Append a trace_quick instruction to EXPR, to record N bytes. */
> +/* Append a trace_quick or trace16 instruction to EXPR, to record N bytes.
> + N must be less than 65536. */
> extern void ax_trace_quick (struct agent_expr *EXPR, int N);
>
> /* Append a goto op to EXPR. OP is the actual op (must be aop_goto or