[c++,01/12] Introduce ax_raw_byte and use it
Commit Message
This patch was taken directly from Pedro's branch.
ax_simple is used to append an agent expression operator to an agent
expression string. Therefore, it takes an enum agent_op as input.
There is an instance where it's called to append a raw byte, unrelated
to the enum. It makes the build fail in C++ mode.
This patch introduces ax_raw_byte for that purpose and uses it.
gdb/ChangeLog:
* ax.h (ax_raw_byte): New declaration.
* ax-general.c (ax_raw_byte): New function.
(ax_simple): Use ax_raw_byte.
* ax-gdb.c (gen_printf): Likewise.
---
gdb/ax-gdb.c | 2 +-
gdb/ax-general.c | 11 +++++++++--
gdb/ax.h | 3 +++
3 files changed, 13 insertions(+), 3 deletions(-)
Comments
On 10/26/2015 03:46 AM, Simon Marchi wrote:
> This patch was taken directly from Pedro's branch.
>
Thanks.
> ax_simple is used to append an agent expression operator to an agent
> expression string. Therefore, it takes an enum agent_op as input.
> There is an instance where it's called to append a raw byte, unrelated
> to the enum. It makes the build fail in C++ mode.
>
> This patch introduces ax_raw_byte for that purpose and uses it.
>
> gdb/ChangeLog:
>
> * ax.h (ax_raw_byte): New declaration.
> * ax-general.c (ax_raw_byte): New function.
> (ax_simple): Use ax_raw_byte.
> * ax-gdb.c (gen_printf): Likewise.
OK.
Thanks,
Pedro Alves
On 27/10/15 08:16 AM, Pedro Alves wrote:
> On 10/26/2015 03:46 AM, Simon Marchi wrote:
>> This patch was taken directly from Pedro's branch.
>>
>
> Thanks.
>
>> ax_simple is used to append an agent expression operator to an agent
>> expression string. Therefore, it takes an enum agent_op as input.
>> There is an instance where it's called to append a raw byte, unrelated
>> to the enum. It makes the build fail in C++ mode.
>>
>> This patch introduces ax_raw_byte for that purpose and uses it.
>>
>> gdb/ChangeLog:
>>
>> * ax.h (ax_raw_byte): New declaration.
>> * ax-general.c (ax_raw_byte): New function.
>> (ax_simple): Use ax_raw_byte.
>> * ax-gdb.c (gen_printf): Likewise.
>
> OK.
>
> Thanks,
> Pedro Alves
>
Pushed thanks.
@@ -2564,7 +2564,7 @@ gen_printf (CORE_ADDR scope, struct gdbarch *gdbarch,
/* Issue the printf bytecode proper. */
ax_simple (ax, aop_printf);
- ax_simple (ax, nargs);
+ ax_raw_byte (ax, nargs);
ax_string (ax, format, fmtlen);
/* And terminate. */
@@ -133,13 +133,20 @@ read_const (struct agent_expr *x, int o, int n)
return accum;
}
+/* See ax.h. */
+
+void
+ax_raw_byte (struct agent_expr *x, gdb_byte byte)
+{
+ grow_expr (x, 1);
+ x->buf[x->len++] = byte;
+}
/* 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;
+ ax_raw_byte (x, op);
}
/* Append a pick operator to EXPR. DEPTH is the stack item to pick,
@@ -190,6 +190,9 @@ extern struct agent_expr *new_agent_expr (struct gdbarch *, CORE_ADDR);
extern void free_agent_expr (struct agent_expr *);
extern struct cleanup *make_cleanup_free_agent_expr (struct agent_expr *);
+/* Append a raw byte to EXPR. */
+extern void ax_raw_byte (struct agent_expr *expr, gdb_byte byte);
+
/* Append a simple operator OP to EXPR. */
extern void ax_simple (struct agent_expr *EXPR, enum agent_op OP);