From 7fb1b8b13f1fb3a72f0ab3ce72967549ea040e17 Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Wed, 27 Nov 2013 18:47:40 +0400 Subject: [PATCH] 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. --- 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 6e4b9a5a30..cbf40398b9 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2013-12-03 Joel Brobecker + + * ada-lex.l (find_dot_all): Use strncasecmp instead of strncmp. + 2013-12-03 Joel Brobecker * ada-lang.c (create_excep_cond_exprs): Force EXP to NULL diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l index 3c30043323..8ad825b1bf 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 bc4bcbbaa7..5725b3d1a7 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2013-12-03 Joel Brobecker + + * gdb.ada/dot_all: New testcase. + 2013-12-03 Joel Brobecker * gdb.mi/mi-undefined-cmd.exp: New testcase. diff --git a/gdb/testsuite/gdb.ada/dot_all.exp b/gdb/testsuite/gdb.ada/dot_all.exp new file mode 100644 index 0000000000..87a248fa4a --- /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 . + +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 0000000000..1bf079745f --- /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 . + +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 0000000000..39ce769477 --- /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 . + +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 0000000000..771b5c1a1a --- /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 . + +with System; + +package Pck is + procedure Do_Nothing (A : System.Address); +end Pck; + + -- 2.34.1