Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Artemiy Volkov <artemiyv@acm.org>
To: gdb-patches@sourceware.org
Cc: qiyaoltc@gmail.com,	Artemiy Volkov <artemiyv@acm.org>
Subject: [PATCH v2] [PR gdb/19820] gdb: allow enumeration constants as second operand of BINOP_REPEAT
Date: Wed, 23 Mar 2016 21:04:00 -0000	[thread overview]
Message-ID: <1458766976-14582-1-git-send-email-artemiyv@acm.org> (raw)
In-Reply-To: <1458494257-30862-1-git-send-email-artemiyv@acm.org>

This patch adds support for TYPE_CODE_ENUM values to be supplied
as right-hand side operand of the BINOP_REPEAT (@) operator. The
following should now work:

enum {
  sz = 17
};

int
main ()
{
  int arr[sz + 1] = { 0 };
  return 0; /* line 9 here */
}

(gdb) b 9
(gdb) r
(gdb) p arr@sz
$1 = {0 <repeats 17 times>}
(gdb)

A couple of tests is also included in this patch to demonstrate that it is
working as intended.

gdb/Changelog:

2016-03-23  Artemiy Volkov  <artemiyv@acm.org>

	PR gdb/19820
	* eval.c (evaluate_subexp_standard): Allow TYPE_CODE_ENUM to be
        the type of BINOP_REPEAT's second operand.

gdb/testsuite/Changelog:

2016-03-23  Artemiy Volkov  <artemiyv@acm.org>

	PR gdb/19820
	* gdb.base/printcmds.exp: Add artificial arrays tests.
---

v1 -> v2: Add PR # information to the changelog entries.

 gdb/eval.c                           | 3 ++-
 gdb/testsuite/gdb.base/printcmds.exp | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/gdb/eval.c b/gdb/eval.c
index 78ad946..5d32a3c 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -2427,7 +2427,8 @@ evaluate_subexp_standard (struct type *expect_type,
       if (noside == EVAL_SKIP)
 	goto nosideret;
       type = check_typedef (value_type (arg2));
-      if (TYPE_CODE (type) != TYPE_CODE_INT)
+      if (TYPE_CODE (type) != TYPE_CODE_INT
+          && TYPE_CODE (type) != TYPE_CODE_ENUM)
 	error (_("Non-integral right operand for \"@\" operator."));
       if (noside == EVAL_AVOID_SIDE_EFFECTS)
 	{
diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp
index 3c78a53..d599a70 100644
--- a/gdb/testsuite/gdb.base/printcmds.exp
+++ b/gdb/testsuite/gdb.base/printcmds.exp
@@ -643,6 +643,11 @@ proc test_artificial_arrays {} {
     gdb_test_escape_braces "p int1dim\[0\]${ctrlv}@2${ctrlv}@3" \
 	"({{0, 1}, {2, 3}, {4, 5}}|\[Cc\]annot.*)" \
 	{p int1dim[0]@2@3}
+    gdb_test_escape_braces "p int1dim\[0\]${ctrlv}@TWO" " = {0, 1}" \
+        {p int1dim[0]@TWO}
+    gdb_test_escape_braces "p int1dim\[0\]${ctrlv}@TWO${ctrlv}@three" \
+	"({{0, 1}, {2, 3}, {4, 5}}|\[Cc\]annot.*)" \
+	{p int1dim[0]@TWO@three}
     gdb_test_escape_braces {p/x (short [])0x12345678} \
 	" = ({0x1234, 0x5678}|{0x5678, 0x1234})"
 }
-- 
2.7.3


  parent reply	other threads:[~2016-03-23 21:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-20 19:27 [PATCH] " Artemiy Volkov
2016-03-23 16:21 ` Yao Qi
2016-03-23 19:00   ` Artemiy Volkov
2016-03-23 21:04 ` Artemiy Volkov [this message]
2016-04-01 12:15   ` [PATCH v2] " Artemiy Volkov
2016-04-01 13:09     ` Yao Qi
2016-04-01 13:20       ` Artemiy Volkov
2016-04-01 15:02         ` Yao Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1458766976-14582-1-git-send-email-artemiyv@acm.org \
    --to=artemiyv@acm.org \
    --cc=gdb-patches@sourceware.org \
    --cc=qiyaoltc@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox