From: Philippe Waroquiers <philippe.waroquiers@skynet.be>
To: gdb-patches@sourceware.org
Cc: Philippe Waroquiers <philippe.waroquiers@skynet.be>
Subject: [RFA 3/5] Add a test to verify info [functions|variables|types]|rbreak respect language_mode.
Date: Sun, 28 Oct 2018 14:46:00 -0000 [thread overview]
Message-ID: <20181028144614.14149-4-philippe.waroquiers@skynet.be> (raw)
In-Reply-To: <20181028144614.14149-1-philippe.waroquiers@skynet.be>
2018-10-27 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 | 153 ++++++++++++++++++
.../gdb.ada/info_auto_lang/global_pack.ads | 10 ++
.../gdb.ada/info_auto_lang/proc_in_ada.adb | 11 ++
gdb/testsuite/gdb.ada/info_auto_lang/some_c.c | 15 ++
4 files changed, 189 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
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..60a8b5a17c
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/info_auto_lang.exp
@@ -0,0 +1,153 @@
+# 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]
+# are respecting the 'set language auto|ada|c' setup, 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]
+
+gdb_compile "${csrcfile}" "${cobject}" object [list debug]
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" } {
+ return -1
+}
+
+clean_restart ${testfile}
+
+set bp_location [gdb_get_line_number "STOP" ${testdir}/some_c.c]
+runto "some_c.c:$bp_location"
+
+set number "\[0-9]\+"
+
+set func_in_c(c_syntax) "${number}: void proc_in_c\\\(void\\\);"
+set func_in_c(ada_syntax) "${number}: procedure proc_in_c;"
+set func_in_ada(c_syntax) "${number}: void proc_in_ada\\\(void\\\);"
+set func_in_ada(ada_syntax) "${number}: procedure proc_in_ada;"
+
+set type_in_c(c_syntax) [multi_line \
+ "${number}: typedef struct {" \
+ " int some_component_in_c;" \
+ "} some_type_in_c;" ]
+set type_in_c(ada_syntax) [multi_line \
+ "${number}: record" \
+ " some_component_in_c: int;" \
+ "end record" ]
+set type_in_ada(c_syntax) "${number}: struct global_pack__some_type_in_ada;"
+set type_in_ada(ada_syntax) "${number}: global_pack.some_type_in_ada;"
+
+set var_in_c(c_syntax) "${number}: some_type_in_c some_struct_in_c;"
+set var_in_c(ada_syntax) "${number}: some_struct_in_c: some_type_in_c;"
+set var_in_ada(c_syntax) "${number}: struct global_pack__some_type_in_ada global_pack.some_struct_in_ada;"
+set var_in_ada(ada_syntax) "${number}: 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" } {
+
+ # Switch to the desired language_choice in a frame giving no warning,
+ # and then, 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 {
+ fail "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"
+ }
+ gdb_test "frame $frame" "#$frame .*" "select frame $frame with lang $frame_lang"
+ set selected_frame_msg [concat " in selected frame " $frame " with lang $frame_lang"]
+
+ set cmd "info functions proc_in_"
+ set check [concat $cmd $selected_frame_msg]
+ gdb_test $cmd \
+ [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)
+ ] $check
+
+ set cmd "info types some_type"
+ set check [concat $cmd $selected_frame_msg]
+ gdb_test $cmd \
+ [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)
+ ] $check
+
+ set cmd "info variables some_struct"
+ set check [concat $cmd $selected_frame_msg]
+ gdb_test $cmd \
+ [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)
+ ] $check
+
+ set cmd "rbreak proc_in_"
+ set check [concat $cmd $selected_frame_msg]
+ gdb_test $cmd \
+ [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)
+ ] $check
+ 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..5feeacd1fb
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/info_auto_lang/global_pack.ads
@@ -0,0 +1,10 @@
+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..d244db43e7
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/info_auto_lang/proc_in_ada.adb
@@ -0,0 +1,11 @@
+with Text_Io; use Text_Io;
+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;
+ Put_Line ("hello world from Ada");
+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..79ca1627e2
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/info_auto_lang/some_c.c
@@ -0,0 +1,15 @@
+#include <stdio.h>
+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++;
+ printf ("Hello world from C %d %d\n", /* STOP */
+ some_number_in_c,
+ some_struct_in_c.some_component_in_c);
+}
--
2.19.1
next prev parent reply other threads:[~2018-10-28 14:46 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-28 14:46 [RFA 0/5] Use language mode in 'info [functions|variables|types]|rbreak' Philippe Waroquiers
2018-10-28 14:46 ` [RFA 5/5] NEWS: Document the language choice by 'info [types|functions|variables]|rbreak' Philippe Waroquiers
2018-10-28 15:31 ` Eli Zaretskii
2018-10-28 14:46 ` [RFA 2/5] Use scoped_switch_auto_to_sym_language in symtab.c to switch language Philippe Waroquiers
2018-11-16 18:28 ` Pedro Alves
2018-11-17 12:24 ` Philippe Waroquiers
2018-10-28 14:46 ` [RFA 1/5] Add class scoped_switch_auto_to_sym_language Philippe Waroquiers
2018-11-16 18:27 ` Pedro Alves
2018-10-28 14:46 ` [RFA 4/5] Document language choice in 'info [functions|variables|types]|rbreak' commands Philippe Waroquiers
2018-10-28 15:33 ` Eli Zaretskii
2018-10-28 14:46 ` Philippe Waroquiers [this message]
2018-11-16 18:30 ` [RFA 3/5] Add a test to verify info [functions|variables|types]|rbreak respect language_mode Pedro Alves
2018-11-13 19:15 ` PING Re: [RFA 0/5] Use language mode in 'info [functions|variables|types]|rbreak' Philippe Waroquiers
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=20181028144614.14149-4-philippe.waroquiers@skynet.be \
--to=philippe.waroquiers@skynet.be \
--cc=gdb-patches@sourceware.org \
/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