aboutsummaryrefslogtreecommitdiff
path: root/gdb/language.h
diff options
context:
space:
mode:
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>2018-10-28 13:51:32 +0100
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>2018-11-20 22:39:08 +0100
commit9e6a1ab6652e8461f786d5c308f632a7c0acc53f (patch)
treee35ab39d22879abe826b4253a9f7c3b28b8e30cb /gdb/language.h
parentbeddd67132d5f8240613fd89b21ae0d2a1c7bd0f (diff)
downloadfsf-binutils-gdb-9e6a1ab6652e8461f786d5c308f632a7c0acc53f.zip
fsf-binutils-gdb-9e6a1ab6652e8461f786d5c308f632a7c0acc53f.tar.gz
fsf-binutils-gdb-9e6a1ab6652e8461f786d5c308f632a7c0acc53f.tar.bz2
Add class scoped_switch_to_sym_language_if_auto.
The class scoped_switch_to_sym_language_if_auto allows to switch in a scope the current language to the language of a symbol when language mode is set to auto. 2018-11-20 Philippe Waroquiers <philippe.waroquiers@skynet.be> * language.h (scoped_switch_to_sym_language_if_auto): New class.
Diffstat (limited to 'gdb/language.h')
-rw-r--r--gdb/language.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/gdb/language.h b/gdb/language.h
index 02a84ff..9577065 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -707,4 +707,39 @@ private:
enum language m_lang;
};
+/* If language_mode is language_mode_auto,
+ then switch current language to the language of SYM
+ and restore current language upon destruction.
+
+ Else do nothing. */
+
+class scoped_switch_to_sym_language_if_auto
+{
+public:
+
+ explicit scoped_switch_to_sym_language_if_auto (const struct symbol *sym)
+ {
+ if (language_mode == language_mode_auto)
+ {
+ m_lang = current_language->la_language;
+ m_switched = true;
+ set_language (SYMBOL_LANGUAGE (sym));
+ }
+ else
+ m_switched = false;
+ }
+
+ ~scoped_switch_to_sym_language_if_auto ()
+ {
+ if (m_switched)
+ set_language (m_lang);
+ }
+
+ DISABLE_COPY_AND_ASSIGN (scoped_switch_to_sym_language_if_auto);
+
+private:
+ bool m_switched;
+ enum language m_lang;
+};
+
#endif /* defined (LANGUAGE_H) */