gdb: allow enumeration constants as second operand of BINOP_REPEAT
authorArtemiy Volkov <artemiyv@acm.org>
Fri, 1 Apr 2016 15:00:59 +0000 (16:00 +0100)
committerYao Qi <yao.qi@linaro.org>
Fri, 1 Apr 2016 15:00:59 +0000 (16:00 +0100)
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-04-01  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-04-01  Artemiy Volkov  <artemiyv@acm.org>

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

gdb/ChangeLog
gdb/eval.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/printcmds.exp

index e8bed141c296a87839e5be2922805bbb33ec8d39..3f40c3133cea079012f63196f253268dc3af1fe3 100644 (file)
@@ -1,3 +1,9 @@
+2016-04-01  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.
+
 2016-03-31  Yichao Yu  <yyc1992@gmail.com>
 
        PR gdb/19858
index 78ad946391ce20941fc4c9b1cbacb0536cc07ff6..5d32a3cd4bc2f7f6ada7185f5cd9caf188db03be 100644 (file)
@@ -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)
        {
index 083e6141e795cedb17dcea3bc1e7f8a4f3729a10..c4338ff49e391b1effa6b60419dfbc73088a462b 100644 (file)
@@ -1,3 +1,8 @@
+2016-04-01  Artemiy Volkov  <artemiyv@acm.org>
+
+       PR gdb/19820
+       * gdb.base/printcmds.exp: Add artificial arrays tests.
+
 2016-03-31  Pedro Alves  <palves@redhat.com>
 
        PR gdb/19858
index 3c78a53e456249bdd38a1c4febab36a30c159620..d599a70e10c920f9eee2b9a3d4ce4d764e69e10d 100644 (file)
@@ -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})"
 }
This page took 0.036768 seconds and 4 git commands to generate.