[RFAv2,3/5] Add a test to verify info [functions|variables|types]|rbreak respect language_mode.

Message ID 20181117120445.10805-4-philippe.waroquiers@skynet.be
State New, archived
Headers

Commit Message

Philippe Waroquiers Nov. 17, 2018, 12:04 p.m. UTC
  2018-11-17  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* gdb.ada/info_auto_lang.exp: New testcase.
	* gdb.ada/info_auto_lang/global_pack.ads: New file.
	* gdb.ada/info_auto_lang/proc_in_ada.adb: New file.
	* gdb.ada/info_auto_lang/some_c.c: New file.
---
 gdb/testsuite/gdb.ada/info_auto_lang.exp      | 154 ++++++++++++++++++
 .../gdb.ada/info_auto_lang/global_pack.ads    |  25 +++
 .../gdb.ada/info_auto_lang/proc_in_ada.adb    |  24 +++
 gdb/testsuite/gdb.ada/info_auto_lang/some_c.c |  28 ++++
 4 files changed, 231 insertions(+)
 create mode 100644 gdb/testsuite/gdb.ada/info_auto_lang.exp
 create mode 100644 gdb/testsuite/gdb.ada/info_auto_lang/global_pack.ads
 create mode 100644 gdb/testsuite/gdb.ada/info_auto_lang/proc_in_ada.adb
 create mode 100644 gdb/testsuite/gdb.ada/info_auto_lang/some_c.c
  

Comments

Sergio Durigan Junior Nov. 30, 2018, 8:46 p.m. UTC | #1
On Saturday, November 17 2018, Philippe Waroquiers wrote:

> 2018-11-17  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
>
> 	* gdb.ada/info_auto_lang.exp: New testcase.
> 	* gdb.ada/info_auto_lang/global_pack.ads: New file.
> 	* gdb.ada/info_auto_lang/proc_in_ada.adb: New file.
> 	* gdb.ada/info_auto_lang/some_c.c: New file.

Hey Philippe,

I've just noticed that this commit introduced a bunch of new FAILs in
our testsuite.  This is what I'm seeing here:

  FAIL: gdb.ada/info_auto_lang.exp: language_choice=auto: frame=0, frame_lang=c: info functions proc_in_
  FAIL: gdb.ada/info_auto_lang.exp: language_choice=auto: frame=0, frame_lang=c: info types some_type
  FAIL: gdb.ada/info_auto_lang.exp: language_choice=auto: frame=0, frame_lang=c: info variables some_struct
  FAIL: gdb.ada/info_auto_lang.exp: language_choice=auto: frame=0, frame_lang=c: rbreak proc_in_
  FAIL: gdb.ada/info_auto_lang.exp: language_choice=auto: frame=1, frame_lang=ada: info functions proc_in_
  FAIL: gdb.ada/info_auto_lang.exp: language_choice=auto: frame=1, frame_lang=ada: info types some_type
  FAIL: gdb.ada/info_auto_lang.exp: language_choice=auto: frame=1, frame_lang=ada: info variables some_struct
  FAIL: gdb.ada/info_auto_lang.exp: language_choice=auto: frame=1, frame_lang=ada: rbreak proc_in_
  FAIL: gdb.ada/info_auto_lang.exp: language_choice=ada: frame=0, frame_lang=c: info functions proc_in_
  FAIL: gdb.ada/info_auto_lang.exp: language_choice=ada: frame=0, frame_lang=c: info types some_type
  FAIL: gdb.ada/info_auto_lang.exp: language_choice=ada: frame=0, frame_lang=c: info variables some_struct
  FAIL: gdb.ada/info_auto_lang.exp: language_choice=ada: frame=0, frame_lang=c: rbreak proc_in_
  FAIL: gdb.ada/info_auto_lang.exp: language_choice=ada: frame=1, frame_lang=ada: info functions proc_in_
  FAIL: gdb.ada/info_auto_lang.exp: language_choice=ada: frame=1, frame_lang=ada: info types some_type
  FAIL: gdb.ada/info_auto_lang.exp: language_choice=ada: frame=1, frame_lang=ada: info variables some_struct
  FAIL: gdb.ada/info_auto_lang.exp: language_choice=ada: frame=1, frame_lang=ada: rbreak proc_in_
  FAIL: gdb.ada/info_auto_lang.exp: language_choice=c: frame=0, frame_lang=c: info functions proc_in_
  FAIL: gdb.ada/info_auto_lang.exp: language_choice=c: frame=0, frame_lang=c: info types some_type
  FAIL: gdb.ada/info_auto_lang.exp: language_choice=c: frame=0, frame_lang=c: info variables some_struct
  FAIL: gdb.ada/info_auto_lang.exp: language_choice=c: frame=0, frame_lang=c: rbreak proc_in_
  FAIL: gdb.ada/info_auto_lang.exp: language_choice=c: frame=1, frame_lang=ada: info functions proc_in_
  FAIL: gdb.ada/info_auto_lang.exp: language_choice=c: frame=1, frame_lang=ada: info types some_type
  FAIL: gdb.ada/info_auto_lang.exp: language_choice=c: frame=1, frame_lang=ada: info variables some_struct
  FAIL: gdb.ada/info_auto_lang.exp: language_choice=c: frame=1, frame_lang=ada: rbreak proc_in_

If you're interested, you can also check the results generated by our
BuildBot here:

  https://sourceware.org/ml/gdb-testers/2018-q4/msg03864.html

I haven't investigated further to see where/what the error is.

Thanks,
  
Philippe Waroquiers Nov. 30, 2018, 11:26 p.m. UTC | #2
On Fri, 2018-11-30 at 15:46 -0500, Sergio Durigan Junior wrote:
> If you're interested, you can also check the results generated by our
> BuildBot here:
> 
>   https://sourceware.org/ml/gdb-testers/2018-q4/msg03864.html
> 
> I haven't investigated further to see where/what the error is.
I will investigate this week-end, thanks for the pointer.

Philippe
  

Patch

diff --git a/gdb/testsuite/gdb.ada/info_auto_lang.exp b/gdb/testsuite/gdb.ada/info_auto_lang.exp
new file mode 100644
index 0000000000..4ba79fff42
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/info_auto_lang.exp
@@ -0,0 +1,154 @@ 
+# Copyright 2018 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"
+
+# This test verifies that the commands
+#   info [functions|variables|types]
+# respect the 'set language auto|ada|c' setting, whatever the language
+# of the current frame.
+# Similarly, checks that rbreak reports its results respecting
+# the language mode.
+
+standard_ada_testfile proc_in_ada
+set cfile "some_c"
+set csrcfile ${srcdir}/${subdir}/${testdir}/${cfile}.c
+set cobject [standard_output_file ${cfile}.o]
+
+if { [gdb_compile "${csrcfile}" "${cobject}" object [list debug]] != "" } {
+    untested "failed to compile"
+    return -1
+}
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" } {
+    untested "failed to compile"
+    return -1
+}
+
+clean_restart ${testfile}
+
+set bp_location [gdb_get_line_number "STOP" ${testdir}/some_c.c]
+if ![runto "some_c.c:$bp_location"] then {
+    fail "can't run to some_c.c STOP location"
+    return
+}
+
+set func_in_c(c_syntax)      "${decimal}:	void proc_in_c\\\(void\\\);"
+set func_in_c(ada_syntax)    "${decimal}:	procedure proc_in_c;"
+set func_in_ada(c_syntax)    "${decimal}:	void proc_in_ada\\\(void\\\);"
+set func_in_ada(ada_syntax)  "${decimal}:	procedure proc_in_ada;"
+
+set type_in_c(c_syntax) [multi_line \
+			    "${decimal}:	typedef struct {" \
+			    "    int some_component_in_c;" \
+			    "} some_type_in_c;" ]
+set type_in_c(ada_syntax) [multi_line \
+			      "${decimal}:	record" \
+			      "    some_component_in_c: int;" \
+			      "end record" ]
+set type_in_ada(c_syntax) "${decimal}:	struct global_pack__some_type_in_ada;"
+set type_in_ada(ada_syntax)  "${decimal}:	global_pack.some_type_in_ada;"
+
+set var_in_c(c_syntax)     "${decimal}:	some_type_in_c some_struct_in_c;"
+set var_in_c(ada_syntax)   "${decimal}:	some_struct_in_c: some_type_in_c;"
+set var_in_ada(c_syntax)   "${decimal}:	struct global_pack__some_type_in_ada global_pack.some_struct_in_ada;"
+set var_in_ada(ada_syntax) "${decimal}:	global_pack.some_struct_in_ada: global_pack.some_type_in_ada;"
+
+set rbreak_func_in_c(c_syntax)      "void proc_in_c\\\(void\\\);"
+set rbreak_func_in_c(ada_syntax)    "procedure proc_in_c;"
+set rbreak_func_in_ada(c_syntax)    "void proc_in_ada\\\(void\\\);"
+set rbreak_func_in_ada(ada_syntax)  "procedure proc_in_ada;"
+
+
+foreach_with_prefix language_choice { "auto" "ada" "c" } {
+
+    # Check that switching to the desired language_choice when the selected
+    # frame has the same language (or the desired language is auto) gives no
+    # warning.  Also set the expected matches for the various commands
+    # tested afterwards.
+    if {$language_choice == "auto"} {
+	gdb_test "frame 0" "#0 .*" "select frame with lang c"
+	set c_match c_syntax
+	set ada_match ada_syntax
+    } elseif {$language_choice == "ada"} {
+	gdb_test "frame 1" "#1 .*" "select frame with lang ada"
+	set c_match ada_syntax
+	set ada_match ada_syntax
+    } elseif {$language_choice == "c"} {
+	gdb_test "frame 0" "#0 .*" "select frame with lang c"
+	set c_match c_syntax
+	set ada_match c_syntax
+    } else {
+	error "unexpected language choice"
+    }
+    gdb_test_no_output "set language $language_choice" "set language language_choice"
+
+    foreach frame {
+	"0"
+	"1" } {
+	if { $frame == 0 } {
+	    set frame_lang "c"
+	} else {
+	    set frame_lang "ada"
+	}
+
+	with_test_prefix "frame=$frame, frame_lang=$frame_lang" {
+
+	    gdb_test "frame $frame" "#$frame .*" "select frame"
+
+	    gdb_test "info functions proc_in_" \
+		[multi_line \
+		     "All functions matching regular expression \"proc_in_\":" \
+		     "" \
+		     "File .*some_c.c:" \
+		     $func_in_c($c_match) \
+		     "" \
+		     "File .*proc_in_ada.adb:" \
+		     $func_in_ada($ada_match)
+		]
+
+	    gdb_test "info types some_type" \
+		[multi_line \
+		     "All types matching regular expression \"some_type\":" \
+		     "" \
+		     "File .*some_c.c:" \
+		     $type_in_c($c_match) \
+		     "" \
+		     "File .*global_pack.ads:" \
+		     $type_in_ada($ada_match)
+		]
+
+	    gdb_test "info variables some_struct" \
+		[multi_line \
+		     "All variables matching regular expression \"some_struct\":" \
+		     "" \
+		     "File .*some_c.c:" \
+		     $var_in_c($c_match) \
+		     "" \
+		     "File .*global_pack.ads:" \
+		     $var_in_ada($ada_match)
+		]
+
+	    gdb_test "rbreak proc_in_" \
+		[multi_line \
+		     "Breakpoint.*file .*some_c.c,.*" \
+		     $rbreak_func_in_c($c_match) \
+		     "Breakpoint.*file .*proc_in_ada.adb,.*" \
+		     $rbreak_func_in_ada($ada_match)
+		]
+	    delete_breakpoints
+	}
+    }
+}
+
diff --git a/gdb/testsuite/gdb.ada/info_auto_lang/global_pack.ads b/gdb/testsuite/gdb.ada/info_auto_lang/global_pack.ads
new file mode 100644
index 0000000000..31e7c3cf91
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/info_auto_lang/global_pack.ads
@@ -0,0 +1,25 @@ 
+--  Copyright 2018 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 Global_Pack is
+  Some_Number_In_Ada : Integer := 0;
+
+  type Some_Type_In_Ada is
+    record
+      Some_Component_In_Ada : Integer;
+    end record;
+
+  Some_Struct_In_Ada : Some_Type_In_Ada;
+end Global_Pack;
diff --git a/gdb/testsuite/gdb.ada/info_auto_lang/proc_in_ada.adb b/gdb/testsuite/gdb.ada/info_auto_lang/proc_in_ada.adb
new file mode 100644
index 0000000000..a82f4a05cd
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/info_auto_lang/proc_in_ada.adb
@@ -0,0 +1,24 @@ 
+--  Copyright 2018 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 Global_Pack; use Global_Pack;
+procedure Proc_In_Ada is
+  procedure Something_In_C
+    with Import, Convention => C, External_Name => "proc_in_c";
+   pragma Linker_Options ("some_c.o");
+begin
+  Something_In_C;
+  Some_Number_In_Ada := Some_Number_In_Ada + 1;
+end Proc_In_Ada;
diff --git a/gdb/testsuite/gdb.ada/info_auto_lang/some_c.c b/gdb/testsuite/gdb.ada/info_auto_lang/some_c.c
new file mode 100644
index 0000000000..bda00cbf34
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/info_auto_lang/some_c.c
@@ -0,0 +1,28 @@ 
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2018 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/>.  */
+
+int some_number_in_c;
+typedef struct {
+   int some_component_in_c;
+} some_type_in_c;
+
+some_type_in_c some_struct_in_c;
+void proc_in_c (void)
+{
+   some_number_in_c++;
+   some_struct_in_c.some_component_in_c++; /* STOP */
+}