]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/
authorJan Kratochvil <jan.kratochvil@redhat.com>
Sun, 13 Jan 2013 18:57:01 +0000 (18:57 +0000)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Sun, 13 Jan 2013 18:57:01 +0000 (18:57 +0000)
* parse.c (parse_exp_in_context): New variable inner_chain.  Call
make_cleanup_restore_current_language.  Call set_language.  Move
OLD_CHAIN and INNER_CHAIN cleanups.
* utils.c (do_restore_current_language)
(make_cleanup_restore_current_language): New functions.
* utils.h (make_cleanup_restore_current_language): New declaration.

gdb/testsuite/
* gdb.cp/parse-lang.cc: New file.
* gdb.cp/parse-lang.exp: New file.

gdb/ChangeLog
gdb/parse.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.cp/parse-lang.cc [new file with mode: 0644]
gdb/testsuite/gdb.cp/parse-lang.exp [new file with mode: 0644]
gdb/utils.c
gdb/utils.h

index e4c51325716cec764365fb2eacca21e836052b7d..d9a2e456f5bc5b994218f4acf7171afbac24677d 100644 (file)
@@ -1,3 +1,12 @@
+2013-01-13  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * parse.c (parse_exp_in_context): New variable inner_chain.  Call
+       make_cleanup_restore_current_language.  Call set_language.  Move
+       OLD_CHAIN and INNER_CHAIN cleanups.
+       * utils.c (do_restore_current_language)
+       (make_cleanup_restore_current_language): New functions.
+       * utils.h (make_cleanup_restore_current_language): New declaration.
+
 2013-01-13  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        * source.c (symtab_to_fullname): Apply rewrite_source_path also for
index 2d530dfa7e8c201fe461417982d50c5f32277bbf..09c378b98bbf76a8cecae0becacc5b9c799b8876 100644 (file)
@@ -1143,7 +1143,7 @@ parse_exp_in_context (char **stringptr, CORE_ADDR pc, const struct block *block,
                      int comma, int void_context_p, int *out_subexp)
 {
   volatile struct gdb_exception except;
-  struct cleanup *old_chain;
+  struct cleanup *old_chain, *inner_chain;
   const struct language_defn *lang = NULL;
   int subexp;
 
@@ -1213,7 +1213,13 @@ parse_exp_in_context (char **stringptr, CORE_ADDR pc, const struct block *block,
   else
     lang = current_language;
 
+  /* get_current_arch may reset CURRENT_LANGUAGE via select_frame.
+     While we need CURRENT_LANGUAGE to be set to LANG (for lookup_symbol
+     and others called from *.y) ensure CURRENT_LANGUAGE gets restored
+     to the value matching SELECTED_FRAME as set by get_current_arch.  */
   initialize_expout (10, lang, get_current_arch ());
+  inner_chain = make_cleanup_restore_current_language ();
+  set_language (lang->la_language);
 
   TRY_CATCH (except, RETURN_MASK_ALL)
     {
@@ -1229,8 +1235,6 @@ parse_exp_in_context (char **stringptr, CORE_ADDR pc, const struct block *block,
        }
     }
 
-  discard_cleanups (old_chain);
-
   reallocate_expout ();
 
   /* Convert expression from postfix form as generated by yacc
@@ -1249,6 +1253,9 @@ parse_exp_in_context (char **stringptr, CORE_ADDR pc, const struct block *block,
   if (expressiondebug)
     dump_prefix_expression (expout, gdb_stdlog);
 
+  do_cleanups (inner_chain);
+  discard_cleanups (old_chain);
+
   *stringptr = lexptr;
   return expout;
 }
index 3e366d98e6cce80ef5710dd25abc434bb1bd2c4e..717ea18297e8c187181394eccb8351b291885bf9 100644 (file)
@@ -1,3 +1,8 @@
+2013-01-13  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * gdb.cp/parse-lang.cc: New file.
+       * gdb.cp/parse-lang.exp: New file.
+
 2013-01-13  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        * gdb.mi/mi-fullname-deleted.exp: Set srcfileabssubst and initdir.
diff --git a/gdb/testsuite/gdb.cp/parse-lang.cc b/gdb/testsuite/gdb.cp/parse-lang.cc
new file mode 100644 (file)
index 0000000..46af670
--- /dev/null
@@ -0,0 +1,40 @@
+/* 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 <http://www.gnu.org/licenses/>.  */
+
+class C
+{
+public:
+  int v;
+  void m ();
+};
+
+void
+C::m ()
+{
+}
+
+void
+marker ()
+{
+}
+
+int
+main ()
+{
+  C c = { 42 };
+
+  c.m ();
+  marker ();
+}
diff --git a/gdb/testsuite/gdb.cp/parse-lang.exp b/gdb/testsuite/gdb.cp/parse-lang.exp
new file mode 100644 (file)
index 0000000..c0051e9
--- /dev/null
@@ -0,0 +1,31 @@
+# Copyright 2012-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 <http://www.gnu.org/licenses/>.
+
+standard_testfile .cc
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
+}
+
+# Place the breakpoint before inferior gets started.  Then the breakpoint
+# condition will be re-evaluated in non-C++ startup code.
+gdb_breakpoint "C::m if v == 42"
+
+gdb_breakpoint "marker"
+
+# runto_main would delete the breakpoint.
+gdb_run_cmd
+
+gdb_test "" {Breakpoint [0-9]+, C::m .*} "breakpoint hit"
index e12888fa856ffc6506f4f58ed5124a13c01efc52..8bae4ebaa0950a462d64ee003826ce3754e71b92 100644 (file)
@@ -503,6 +503,28 @@ make_cleanup_free_so (struct so_list *so)
   return make_cleanup (do_free_so, so);
 }
 
+/* Helper for make_cleanup_restore_current_language.  */
+
+static void
+do_restore_current_language (void *p)
+{
+  enum language saved_lang = (uintptr_t) p;
+
+  set_language (saved_lang);
+}
+
+/* Remember the current value of CURRENT_LANGUAGE and make it restored when
+   the cleanup is run.  */
+
+struct cleanup *
+make_cleanup_restore_current_language (void)
+{
+  enum language saved_lang = current_language->la_language;
+
+  return make_cleanup (do_restore_current_language,
+                      (void *) (uintptr_t) saved_lang);
+}
+
 /* This function is useful for cleanups.
    Do
 
index 14235a9b3564751c301ae90615d8ff609d1756c3..6983a53c6f946fe94c5c99617b6e28406bb615a2 100644 (file)
@@ -104,6 +104,8 @@ extern struct cleanup *make_cleanup_value_free (struct value *);
 struct so_list;
 extern struct cleanup *make_cleanup_free_so (struct so_list *so);
 
+extern struct cleanup *make_cleanup_restore_current_language (void);
+
 extern struct cleanup *make_cleanup_htab_delete (htab_t htab);
 
 extern void free_current_contents (void *);