Add a comment for the ARM_F{0..7}_REGNUM registers
[binutils-gdb.git] / gdbsupport / environ.h
blob8794a2aadc8d83e87d81aec2436f82202e78b41f
1 /* Header for environment manipulation library.
2 Copyright (C) 1989-2020 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17 #ifndef COMMON_ENVIRON_H
18 #define COMMON_ENVIRON_H
20 #include <vector>
21 #include <set>
23 /* Class that represents the environment variables as seen by the
24 inferior. */
26 class gdb_environ
28 public:
29 /* Regular constructor and destructor. */
30 gdb_environ ()
32 /* Make sure that the vector contains at least a NULL element.
33 If/when we add more variables to it, NULL will always be the
34 last element. */
35 m_environ_vector.push_back (NULL);
38 ~gdb_environ ()
40 clear ();
43 /* Move constructor. */
44 gdb_environ (gdb_environ &&e)
45 : m_environ_vector (std::move (e.m_environ_vector)),
46 m_user_set_env (std::move (e.m_user_set_env)),
47 m_user_unset_env (std::move (e.m_user_unset_env))
49 /* Make sure that the moved-from vector is left at a valid
50 state (only one NULL element). */
51 e.m_environ_vector.clear ();
52 e.m_environ_vector.push_back (NULL);
53 e.m_user_set_env.clear ();
54 e.m_user_unset_env.clear ();
57 /* Move assignment. */
58 gdb_environ &operator= (gdb_environ &&e);
60 /* Create a gdb_environ object using the host's environment
61 variables. */
62 static gdb_environ from_host_environ ();
64 /* Clear the environment variables stored in the object. */
65 void clear ();
67 /* Return the value in the environment for the variable VAR. The
68 returned pointer is only valid as long as the gdb_environ object
69 is not modified. */
70 const char *get (const char *var) const;
72 /* Store VAR=VALUE in the environment. */
73 void set (const char *var, const char *value);
75 /* Unset VAR in environment. */
76 void unset (const char *var);
78 /* Return the environment vector represented as a 'char **'. */
79 char **envp () const;
81 /* Return the user-set environment vector. */
82 const std::set<std::string> &user_set_env () const;
84 /* Return the user-unset environment vector. */
85 const std::set<std::string> &user_unset_env () const;
87 private:
88 /* Unset VAR in environment. If UPDATE_UNSET_LIST is true, then
89 also update M_USER_UNSET_ENV to reflect the unsetting of the
90 environment variable. */
91 void unset (const char *var, bool update_unset_list);
93 /* A vector containing the environment variables. */
94 std::vector<char *> m_environ_vector;
96 /* The environment variables explicitly set by the user. */
97 std::set<std::string> m_user_set_env;
99 /* The environment variables explicitly unset by the user. */
100 std::set<std::string> m_user_unset_env;
103 #endif /* COMMON_ENVIRON_H */