mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-25 21:41:47 +08:00
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.
This commit is contained in:
@ -4,6 +4,12 @@
|
|||||||
* c-lang.c (c_printstr): Compute real length of NUL terminated
|
* c-lang.c (c_printstr): Compute real length of NUL terminated
|
||||||
string at first.
|
string at first.
|
||||||
|
|
||||||
|
2010-05-17 Joel Brobecker <brobecker@adacore.com>
|
||||||
|
|
||||||
|
* parse.c (parse_exp_in_context): When block is not NULL, use
|
||||||
|
its associated language to parse the expression instead of
|
||||||
|
the current_language.
|
||||||
|
|
||||||
2010-05-17 Joel Brobecker <brobecker@adacore.com>
|
2010-05-17 Joel Brobecker <brobecker@adacore.com>
|
||||||
|
|
||||||
* jv-lang.c (java_lookup_class): Remove commented out code.
|
* jv-lang.c (java_lookup_class): Remove commented out code.
|
||||||
|
35
gdb/parse.c
35
gdb/parse.c
@ -1068,6 +1068,7 @@ parse_exp_in_context (char **stringptr, struct block *block, int comma,
|
|||||||
{
|
{
|
||||||
volatile struct gdb_exception except;
|
volatile struct gdb_exception except;
|
||||||
struct cleanup *old_chain;
|
struct cleanup *old_chain;
|
||||||
|
const struct language_defn *lang = NULL;
|
||||||
int subexp;
|
int subexp;
|
||||||
|
|
||||||
lexptr = *stringptr;
|
lexptr = *stringptr;
|
||||||
@ -1105,17 +1106,43 @@ parse_exp_in_context (char **stringptr, struct block *block, int comma,
|
|||||||
expression_context_pc = BLOCK_START (expression_context_block);
|
expression_context_pc = BLOCK_START (expression_context_block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (language_mode == language_mode_auto && block != NULL)
|
||||||
|
{
|
||||||
|
/* Find the language associated to the given context block.
|
||||||
|
Default to the current language if it can not be determined.
|
||||||
|
|
||||||
|
Note that using the language corresponding to the current frame
|
||||||
|
can sometimes give unexpected results. For instance, this
|
||||||
|
routine is often called several times during the inferior
|
||||||
|
startup phase to re-parse breakpoint expressions after
|
||||||
|
a new shared library has been loaded. The language associated
|
||||||
|
to the current frame at this moment is not relevant for
|
||||||
|
the breakpoint. Using it would therefore be silly, so it seems
|
||||||
|
better to rely on the current language rather than relying on
|
||||||
|
the current frame language to parse the expression. That's why
|
||||||
|
we do the following language detection only if the context block
|
||||||
|
has been specifically provided. */
|
||||||
|
struct symbol *func = block_linkage_function (block);
|
||||||
|
|
||||||
|
if (func != NULL)
|
||||||
|
lang = language_def (SYMBOL_LANGUAGE (func));
|
||||||
|
if (lang == NULL || lang->la_language == language_unknown)
|
||||||
|
lang = current_language;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
lang = current_language;
|
||||||
|
|
||||||
expout_size = 10;
|
expout_size = 10;
|
||||||
expout_ptr = 0;
|
expout_ptr = 0;
|
||||||
expout = (struct expression *)
|
expout = (struct expression *)
|
||||||
xmalloc (sizeof (struct expression) + EXP_ELEM_TO_BYTES (expout_size));
|
xmalloc (sizeof (struct expression) + EXP_ELEM_TO_BYTES (expout_size));
|
||||||
expout->language_defn = current_language;
|
expout->language_defn = lang;
|
||||||
expout->gdbarch = get_current_arch ();
|
expout->gdbarch = get_current_arch ();
|
||||||
|
|
||||||
TRY_CATCH (except, RETURN_MASK_ALL)
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
||||||
{
|
{
|
||||||
if (current_language->la_parser ())
|
if (lang->la_parser ())
|
||||||
current_language->la_error (NULL);
|
lang->la_error (NULL);
|
||||||
}
|
}
|
||||||
if (except.reason < 0)
|
if (except.reason < 0)
|
||||||
{
|
{
|
||||||
@ -1148,7 +1175,7 @@ parse_exp_in_context (char **stringptr, struct block *block, int comma,
|
|||||||
if (out_subexp)
|
if (out_subexp)
|
||||||
*out_subexp = subexp;
|
*out_subexp = subexp;
|
||||||
|
|
||||||
current_language->la_post_parser (&expout, void_context_p);
|
lang->la_post_parser (&expout, void_context_p);
|
||||||
|
|
||||||
if (expressiondebug)
|
if (expressiondebug)
|
||||||
dump_prefix_expression (expout, gdb_stdlog);
|
dump_prefix_expression (expout, gdb_stdlog);
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
2010-05-17 Joel Brobecker <brobecker@adacore.com>
|
||||||
|
|
||||||
|
* gdb.ada/cond_lang: New testcase.
|
||||||
|
|
||||||
2010-05-17 Joel Brobecker <brobecker@adacore.com>
|
2010-05-17 Joel Brobecker <brobecker@adacore.com>
|
||||||
|
|
||||||
* lib/gdb.exp (banned_variables): New variable/constant.
|
* lib/gdb.exp (banned_variables): New variable/constant.
|
||||||
|
58
gdb/testsuite/gdb.ada/cond_lang.exp
Normal file
58
gdb/testsuite/gdb.ada/cond_lang.exp
Normal file
@ -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 .*"
|
||||||
|
|
||||||
|
|
21
gdb/testsuite/gdb.ada/cond_lang/a.adb
Normal file
21
gdb/testsuite/gdb.ada/cond_lang/a.adb
Normal file
@ -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;
|
25
gdb/testsuite/gdb.ada/cond_lang/foo.c
Normal file
25
gdb/testsuite/gdb.ada/cond_lang/foo.c
Normal file
@ -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 ();
|
||||||
|
}
|
||||||
|
|
49
gdb/testsuite/gdb.ada/cond_lang/mixed.adb
Normal file
49
gdb/testsuite/gdb.ada/cond_lang/mixed.adb
Normal file
@ -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;
|
20
gdb/testsuite/gdb.ada/cond_lang/mixed.ads
Normal file
20
gdb/testsuite/gdb.ada/cond_lang/mixed.ads
Normal file
@ -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;
|
21
gdb/testsuite/gdb.ada/cond_lang/pck.adb
Normal file
21
gdb/testsuite/gdb.ada/cond_lang/pck.adb
Normal file
@ -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;
|
20
gdb/testsuite/gdb.ada/cond_lang/pck.ads
Normal file
20
gdb/testsuite/gdb.ada/cond_lang/pck.ads
Normal file
@ -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;
|
Reference in New Issue
Block a user