+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
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;
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)
{
}
}
- discard_cleanups (old_chain);
-
reallocate_expout ();
/* Convert expression from postfix form as generated by yacc
if (expressiondebug)
dump_prefix_expression (expout, gdb_stdlog);
+ do_cleanups (inner_chain);
+ discard_cleanups (old_chain);
+
*stringptr = lexptr;
return expout;
}
+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.
--- /dev/null
+/* 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 ();
+}
--- /dev/null
+# 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"
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
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 *);