diff options
author | Joel Brobecker <brobecker@gnat.com> | 2010-05-17 17:23:33 +0000 |
---|---|---|
committer | Joel Brobecker <brobecker@gnat.com> | 2010-05-17 17:23:33 +0000 |
commit | 0cce5bd9dd8b740485b4ce847a0bd09a23097076 (patch) | |
tree | b8961b145e807ba2980eb8928b852a0d420414da /gdb/testsuite/gdb.ada | |
parent | 5f19d646befbb9597a7dc4c44eccacb8ef5ab80c (diff) | |
download | gdb-0cce5bd9dd8b740485b4ce847a0bd09a23097076.zip gdb-0cce5bd9dd8b740485b4ce847a0bd09a23097076.tar.gz gdb-0cce5bd9dd8b740485b4ce847a0bd09a23097076.tar.bz2 |
Use breakpoint location to parse condition over current language.
gdb/ChangeLog:
* parse.c (parse_exp_in_context): When block is not NULL, use
its associated language to parse the expression instead of
the current_language.
gdb/testsuite/ChangeLog:
* gdb.ada/cond_lang: New testcase.
Diffstat (limited to 'gdb/testsuite/gdb.ada')
-rw-r--r-- | gdb/testsuite/gdb.ada/cond_lang.exp | 58 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/cond_lang/a.adb | 21 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/cond_lang/foo.c | 25 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/cond_lang/mixed.adb | 49 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/cond_lang/mixed.ads | 20 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/cond_lang/pck.adb | 21 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/cond_lang/pck.ads | 20 |
7 files changed, 214 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.ada/cond_lang.exp b/gdb/testsuite/gdb.ada/cond_lang.exp new file mode 100644 index 0000000..dcd46da --- /dev/null +++ b/gdb/testsuite/gdb.ada/cond_lang.exp @@ -0,0 +1,58 @@ +# Copyright 2010 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/>. + +if $tracelevel then { + strace $tracelevel +} + +load_lib "ada.exp" + +set testdir "cond_lang" +set testfile "${testdir}/a" +set cfile "${testdir}/foo" +set adasrcfile ${srcdir}/${subdir}/${testfile}.adb +set csrcfile ${srcdir}/${subdir}/${cfile}.c +set cobject ${objdir}/${subdir}/${cfile}.o +set binfile ${objdir}/${subdir}/${testfile} + +file mkdir ${objdir}/${subdir}/${testdir} +gdb_compile "${csrcfile}" "${cobject}" object [list debug] +if {[gdb_compile_ada "${adasrcfile}" "${binfile}" executable [list debug]] != "" } { + return -1 +} + +clean_restart ${testfile} + +# Run to c_function an verify that the language automatically gets set to C. +runto c_function +gdb_test "show lang" \ + "The current source language is \"auto; currently c\"\\." + +# Now, insert a breakpoint inside an Ada unit, using a condition written +# in Ada. Even though the current language is "auto; currently c", we +# expect the debugger to parse the expression using Ada, because the +# current language mode is auto, and the breakpoint is inside Ada code. +set bp_location [gdb_get_line_number "STOP" ${testdir}/mixed.adb] +gdb_test "break mixed.adb:${bp_location} if light = green" \ + "Breakpoint \[0-9\]* at .*: file .*/mixed.adb, line \[0-9\]*\\." + +# Now, continue until we hit the breakpoint. If the condition is +# evaluated correctly, the first hit will be ignored, and the debugger +# will stop at the second hit only, when the "light" argument is equal +# to green. +gdb_test "continue" \ + "Breakpoint \[0-9\]*, mixed\\.break_me \\(light=green\\) at .*" + + diff --git a/gdb/testsuite/gdb.ada/cond_lang/a.adb b/gdb/testsuite/gdb.ada/cond_lang/a.adb new file mode 100644 index 0000000..e1cda16 --- /dev/null +++ b/gdb/testsuite/gdb.ada/cond_lang/a.adb @@ -0,0 +1,21 @@ +-- Copyright 2010 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 Mixed; + +procedure A is +begin + Mixed.Start_Test; +end A; diff --git a/gdb/testsuite/gdb.ada/cond_lang/foo.c b/gdb/testsuite/gdb.ada/cond_lang/foo.c new file mode 100644 index 0000000..fe27fc9 --- /dev/null +++ b/gdb/testsuite/gdb.ada/cond_lang/foo.c @@ -0,0 +1,25 @@ +/* Copyright 2010 Free Software Foundation, Inc. + + This file is part of GDB. + + 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/>. */ + +extern callme (void); + +void +c_function (void) +{ + callme (); +} + diff --git a/gdb/testsuite/gdb.ada/cond_lang/mixed.adb b/gdb/testsuite/gdb.ada/cond_lang/mixed.adb new file mode 100644 index 0000000..1d5fd31 --- /dev/null +++ b/gdb/testsuite/gdb.ada/cond_lang/mixed.adb @@ -0,0 +1,49 @@ +-- Copyright 2010 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; + +package body Mixed is + -- We are importing symbols from foo.o, so make sure this object file + -- gets linked in. + Pragma Linker_Options ("foo.o"); + + type Color is (Red, Green, Blue); + + procedure C_Function; + pragma Import (C, C_Function, "c_function"); + + procedure Callme; + pragma Export (C, Callme, "callme"); + + procedure Break_Me (Light : Color) is + begin + Put_Line ("Light: " & Color'Image (Light)); -- STOP + end Break_Me; + + procedure Callme is + begin + Break_Me (Red); + Break_Me (Green); + Break_Me (Blue); + end Callme; + + procedure Start_Test is + begin + -- Call C_Function, which will call Callme. + C_Function; + end Start_Test; + +end Mixed; diff --git a/gdb/testsuite/gdb.ada/cond_lang/mixed.ads b/gdb/testsuite/gdb.ada/cond_lang/mixed.ads new file mode 100644 index 0000000..b3a712a --- /dev/null +++ b/gdb/testsuite/gdb.ada/cond_lang/mixed.ads @@ -0,0 +1,20 @@ +-- Copyright 2010 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 Mixed is + + procedure Start_Test; + +end Mixed; diff --git a/gdb/testsuite/gdb.ada/cond_lang/pck.adb b/gdb/testsuite/gdb.ada/cond_lang/pck.adb new file mode 100644 index 0000000..d412fec --- /dev/null +++ b/gdb/testsuite/gdb.ada/cond_lang/pck.adb @@ -0,0 +1,21 @@ +-- Copyright 2010 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 Put_Line (S : String) is + begin + null; + end Put_Line; +end Pck; diff --git a/gdb/testsuite/gdb.ada/cond_lang/pck.ads b/gdb/testsuite/gdb.ada/cond_lang/pck.ads new file mode 100644 index 0000000..4fbc2a2 --- /dev/null +++ b/gdb/testsuite/gdb.ada/cond_lang/pck.ads @@ -0,0 +1,20 @@ +-- Copyright 2010 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 Pck is + procedure Put_Line (S : String); + -- Stub implementation of Put_Line to avoid a dependency on Text_IO. + -- Does actually nothing. +end Pck; |