This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[commit/Ada] Reserved word "all" should not need to be spelled in lowercase.


Consider the following code:

   type Ptr is access all Integer;
   IP : Ptr := new Integer'(123);

IP is the Ada exception of a pointer to an integer. To dereference
the pointer and get its value, the user uses the reserved word "all"
as follow:

    (gdb) p ip.all
    $1 = 123

Ada being a case-insensitive language, the casing should not matter.
Unfortunately, for the reserved word "all", things don't work. For
instance:

    (gdb) p ip.ALL
    Type integer is not a structure or union type

This patch fixes the problem.

gdb/ChangeLog:

	* ada-lex.l (find_dot_all): Use strncasecmp instead of strncmp.

gdb/testsuite/ChangeLog:

        * gdb.ada/dot_all: New testcase.

Tested on x86_64-linux, and checked in.

Thanks,
-- 
Joel

---
 gdb/ChangeLog                         |  4 ++++
 gdb/ada-lex.l                         |  2 +-
 gdb/testsuite/ChangeLog               |  4 ++++
 gdb/testsuite/gdb.ada/dot_all.exp     | 34 ++++++++++++++++++++++++++++++++++
 gdb/testsuite/gdb.ada/dot_all/foo.adb | 23 +++++++++++++++++++++++
 gdb/testsuite/gdb.ada/dot_all/pck.adb | 25 +++++++++++++++++++++++++
 gdb/testsuite/gdb.ada/dot_all/pck.ads | 22 ++++++++++++++++++++++
 7 files changed, 113 insertions(+), 1 deletion(-)
 create mode 100644 gdb/testsuite/gdb.ada/dot_all.exp
 create mode 100644 gdb/testsuite/gdb.ada/dot_all/foo.adb
 create mode 100644 gdb/testsuite/gdb.ada/dot_all/pck.adb
 create mode 100644 gdb/testsuite/gdb.ada/dot_all/pck.ads

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6e4b9a5..cbf4039 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
 2013-12-03  Joel Brobecker  <brobecker@adacore.com>
 
+	* ada-lex.l (find_dot_all): Use strncasecmp instead of strncmp.
+
+2013-12-03  Joel Brobecker  <brobecker@adacore.com>
+
 	* ada-lang.c (create_excep_cond_exprs): Force EXP to NULL
 	when parse_exp_1 threw an error.  Add comment.
 
diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l
index 3c30043..8ad825b 100644
--- a/gdb/ada-lex.l
+++ b/gdb/ada-lex.l
@@ -545,7 +545,7 @@ find_dot_all (const char *str)
 	  do
 	    i += 1;
 	  while (isspace (str[i]));
-	  if (strncmp (str+i, "all", 3) == 0
+	  if (strncasecmp (str+i, "all", 3) == 0
 	      && ! isalnum (str[i+3]) && str[i+3] != '_')
 	    return i0;
 	}
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index bc4bcbb..5725b3d 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,9 @@
 2013-12-03  Joel Brobecker  <brobecker@adacore.com>
 
+	* gdb.ada/dot_all: New testcase.
+
+2013-12-03  Joel Brobecker  <brobecker@adacore.com>
+
 	* gdb.mi/mi-undefined-cmd.exp: New testcase.
 
 2013-12-03  Joel Brobecker  <brobecker@adacore.com>
diff --git a/gdb/testsuite/gdb.ada/dot_all.exp b/gdb/testsuite/gdb.ada/dot_all.exp
new file mode 100644
index 0000000..87a248f
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/dot_all.exp
@@ -0,0 +1,34 @@
+# Copyright 2013 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+load_lib "ada.exp"
+
+standard_ada_testfile foo
+
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug ]] != "" } {
+  return -1
+}
+
+clean_restart ${testfile}
+
+set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.adb]
+if ![runto "foo.adb:$bp_location" ] then {
+  perror "Couldn't run ${testfile}"
+  return
+}
+
+gdb_test "print addr.all" " = 123"
+gdb_test "print addr.ALL" " = 123"
+gdb_test "print addr.AlL" " = 123"
diff --git a/gdb/testsuite/gdb.ada/dot_all/foo.adb b/gdb/testsuite/gdb.ada/dot_all/foo.adb
new file mode 100644
index 0000000..1bf0797
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/dot_all/foo.adb
@@ -0,0 +1,23 @@
+--  Copyright 2013 Free Software Foundation, Inc.
+--
+--  This program is free software; you can redistribute it and/or modify
+--  it under the terms of the GNU General Public License as published by
+--  the Free Software Foundation; either version 3 of the License, or
+--  (at your option) any later version.
+--
+--  This program is distributed in the hope that it will be useful,
+--  but WITHOUT ANY WARRANTY; without even the implied warranty of
+--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+--  GNU General Public License for more details.
+--
+--  You should have received a copy of the GNU General Public License
+--  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+with Pck; use Pck;
+
+procedure Foo is
+   type Integer_Access is access all Integer;
+   Addr : Integer_Access := new Integer'(123);
+begin
+   Do_Nothing (Addr'Address);  -- STOP
+end Foo;
diff --git a/gdb/testsuite/gdb.ada/dot_all/pck.adb b/gdb/testsuite/gdb.ada/dot_all/pck.adb
new file mode 100644
index 0000000..39ce769
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/dot_all/pck.adb
@@ -0,0 +1,25 @@
+--  Copyright 2008-2013 Free Software Foundation, Inc.
+--
+--  This program is free software; you can redistribute it and/or modify
+--  it under the terms of the GNU General Public License as published by
+--  the Free Software Foundation; either version 3 of the License, or
+--  (at your option) any later version.
+--
+--  This program is distributed in the hope that it will be useful,
+--  but WITHOUT ANY WARRANTY; without even the implied warranty of
+--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+--  GNU General Public License for more details.
+--
+--  You should have received a copy of the GNU General Public License
+--  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+package body Pck is
+
+   procedure Do_Nothing (A : System.Address) is
+   begin
+      null;
+   end Do_Nothing;
+
+end Pck;
+
+
diff --git a/gdb/testsuite/gdb.ada/dot_all/pck.ads b/gdb/testsuite/gdb.ada/dot_all/pck.ads
new file mode 100644
index 0000000..771b5c1
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/dot_all/pck.ads
@@ -0,0 +1,22 @@
+--  Copyright 2008-2013 Free Software Foundation, Inc.
+--
+--  This program is free software; you can redistribute it and/or modify
+--  it under the terms of the GNU General Public License as published by
+--  the Free Software Foundation; either version 3 of the License, or
+--  (at your option) any later version.
+--
+--  This program is distributed in the hope that it will be useful,
+--  but WITHOUT ANY WARRANTY; without even the implied warranty of
+--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+--  GNU General Public License for more details.
+--
+--  You should have received a copy of the GNU General Public License
+--  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+with System;
+
+package Pck is
+   procedure Do_Nothing (A : System.Address);
+end Pck;
+
+
-- 
1.8.1.2


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]