gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / gdbsupport / environ.h
CommitLineData
c906108c 1/* Header for environment manipulation library.
b811d2c2 2 Copyright (C) 1989-2020 Free Software Foundation, Inc.
c906108c 3
c5aa993b
JM
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
a9762ec7 6 the Free Software Foundation; either version 3 of the License, or
c5aa993b 7 (at your option) any later version.
c906108c 8
c5aa993b
JM
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.
c906108c 13
c5aa993b 14 You should have received a copy of the GNU General Public License
a9762ec7 15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
c906108c 16
1a5c2598
TT
17#ifndef COMMON_ENVIRON_H
18#define COMMON_ENVIRON_H
c906108c 19
9a6c7d9c 20#include <vector>
0a2dde4a 21#include <set>
c906108c 22
9a6c7d9c
SDJ
23/* Class that represents the environment variables as seen by the
24 inferior. */
25
26class gdb_environ
27{
28public:
29 /* Regular constructor and destructor. */
30 gdb_environ ()
31 {
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);
36 }
37
38 ~gdb_environ ()
c5aa993b 39 {
9a6c7d9c
SDJ
40 clear ();
41 }
42
43 /* Move constructor. */
44 gdb_environ (gdb_environ &&e)
0a2dde4a
SDJ
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))
9a6c7d9c
SDJ
48 {
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);
0a2dde4a
SDJ
53 e.m_user_set_env.clear ();
54 e.m_user_unset_env.clear ();
9a6c7d9c
SDJ
55 }
56
57 /* Move assignment. */
58 gdb_environ &operator= (gdb_environ &&e);
c906108c 59
9a6c7d9c
SDJ
60 /* Create a gdb_environ object using the host's environment
61 variables. */
62 static gdb_environ from_host_environ ();
c906108c 63
9a6c7d9c
SDJ
64 /* Clear the environment variables stored in the object. */
65 void clear ();
c906108c 66
9a6c7d9c
SDJ
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;
c906108c 71
9a6c7d9c
SDJ
72 /* Store VAR=VALUE in the environment. */
73 void set (const char *var, const char *value);
c906108c 74
9a6c7d9c
SDJ
75 /* Unset VAR in environment. */
76 void unset (const char *var);
c906108c 77
9a6c7d9c
SDJ
78 /* Return the environment vector represented as a 'char **'. */
79 char **envp () const;
c906108c 80
0a2dde4a
SDJ
81 /* Return the user-set environment vector. */
82 const std::set<std::string> &user_set_env () const;
83
84 /* Return the user-unset environment vector. */
85 const std::set<std::string> &user_unset_env () const;
86
9a6c7d9c 87private:
0a2dde4a
SDJ
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);
92
9a6c7d9c
SDJ
93 /* A vector containing the environment variables. */
94 std::vector<char *> m_environ_vector;
0a2dde4a
SDJ
95
96 /* The environment variables explicitly set by the user. */
97 std::set<std::string> m_user_set_env;
98
99 /* The environment variables explicitly unset by the user. */
100 std::set<std::string> m_user_unset_env;
9a6c7d9c 101};
c906108c 102
1a5c2598 103#endif /* COMMON_ENVIRON_H */
This page took 1.399534 seconds and 4 git commands to generate.