From patchwork Mon Oct 26 03:46:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 9362 Received: (qmail 12414 invoked by alias); 26 Oct 2015 03:46:54 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 12404 invoked by uid 89); 26 Oct 2015 03:46:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, BAYES_00, SPF_SOFTFAIL autolearn=no version=3.3.2 X-HELO: smtp.electronicbox.net Received: from smtp.electronicbox.net (HELO smtp.electronicbox.net) (96.127.255.83) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 26 Oct 2015 03:46:52 +0000 Received: from simark.lan. (cable-192.222.137.139.electronicbox.net [192.222.137.139]) by smtp.electronicbox.net (Postfix) with ESMTP id 6CA9A440E78; Sun, 25 Oct 2015 23:46:50 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH c++ 01/12] Introduce ax_raw_byte and use it Date: Sun, 25 Oct 2015 23:46:33 -0400 Message-Id: <1445831204-16588-1-git-send-email-simon.marchi@polymtl.ca> 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(-) diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index 817fa53..7091a4a 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -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. */ diff --git a/gdb/ax-general.c b/gdb/ax-general.c index e5dc240..5c8a25b 100644 --- a/gdb/ax-general.c +++ b/gdb/ax-general.c @@ -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, diff --git a/gdb/ax.h b/gdb/ax.h index eaa72dd..1714bb4 100644 --- a/gdb/ax.h +++ b/gdb/ax.h @@ -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);