gdb: Don't skip prologue for explicit line breakpoints in assembler
[deliverable/binutils-gdb.git] / gdb / common / environ.h
index 3ace69e30a3aaef73deca741c4b1b342d31f7568..8a6b907c9b4e19daa621e6d316cfb4ecd02b3084 100644 (file)
@@ -1,5 +1,5 @@
 /* Header for environment manipulation library.
-   Copyright (C) 1989-2017 Free Software Foundation, Inc.
+   Copyright (C) 1989-2019 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
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#if !defined (ENVIRON_H)
-#define ENVIRON_H 1
+#ifndef COMMON_ENVIRON_H
+#define COMMON_ENVIRON_H
 
-/* We manipulate environments represented as these structures.  */
+#include <vector>
+#include <set>
 
-struct gdb_environ
+/* Class that represents the environment variables as seen by the
+   inferior.  */
+
+class gdb_environ
+{
+public:
+  /* Regular constructor and destructor.  */
+  gdb_environ ()
+  {
+    /* Make sure that the vector contains at least a NULL element.
+       If/when we add more variables to it, NULL will always be the
+       last element.  */
+    m_environ_vector.push_back (NULL);
+  }
+
+  ~gdb_environ ()
   {
-    /* Number of usable slots allocated in VECTOR.
-       VECTOR always has one slot not counted here,
-       to hold the terminating zero.  */
-    int allocated;
-    /* A vector of slots, ALLOCATED + 1 of them.
-       The first few slots contain strings "VAR=VALUE"
-       and the next one contains zero.
-       Then come some unused slots.  */
-    char **vector;
-  };
+    clear ();
+  }
+
+  /* Move constructor.  */
+  gdb_environ (gdb_environ &&e)
+    : m_environ_vector (std::move (e.m_environ_vector)),
+      m_user_set_env (std::move (e.m_user_set_env)),
+      m_user_unset_env (std::move (e.m_user_unset_env))
+  {
+    /* Make sure that the moved-from vector is left at a valid
+       state (only one NULL element).  */
+    e.m_environ_vector.clear ();
+    e.m_environ_vector.push_back (NULL);
+    e.m_user_set_env.clear ();
+    e.m_user_unset_env.clear ();
+  }
+
+  /* Move assignment.  */
+  gdb_environ &operator= (gdb_environ &&e);
+
+  /* Create a gdb_environ object using the host's environment
+     variables.  */
+  static gdb_environ from_host_environ ();
+
+  /* Clear the environment variables stored in the object.  */
+  void clear ();
+
+  /* Return the value in the environment for the variable VAR.  The
+     returned pointer is only valid as long as the gdb_environ object
+     is not modified.  */
+  const char *get (const char *var) const;
+
+  /* Store VAR=VALUE in the environment.  */
+  void set (const char *var, const char *value);
+
+  /* Unset VAR in environment.  */
+  void unset (const char *var);
 
-extern struct gdb_environ *make_environ (void);
+  /* Return the environment vector represented as a 'char **'.  */
+  char **envp () const;
 
-extern void free_environ (struct gdb_environ *);
+  /* Return the user-set environment vector.  */
+  const std::set<std::string> &user_set_env () const;
 
-extern void init_environ (struct gdb_environ *);
+  /* Return the user-unset environment vector.  */
+  const std::set<std::string> &user_unset_env () const;
 
-extern char *get_in_environ (const struct gdb_environ *, const char *);
+private:
+  /* Unset VAR in environment.  If UPDATE_UNSET_LIST is true, then
+     also update M_USER_UNSET_ENV to reflect the unsetting of the
+     environment variable.  */
+  void unset (const char *var, bool update_unset_list);
 
-extern void set_in_environ (struct gdb_environ *, const char *, const char *);
+  /* A vector containing the environment variables.  */
+  std::vector<char *> m_environ_vector;
 
-extern void unset_in_environ (struct gdb_environ *, const char *);
+  /* The environment variables explicitly set by the user.  */
+  std::set<std::string> m_user_set_env;
 
-extern char **environ_vector (struct gdb_environ *);
+  /* The environment variables explicitly unset by the user.  */
+  std::set<std::string> m_user_unset_env;
+};
 
-#endif /* defined (ENVIRON_H) */
+#endif /* COMMON_ENVIRON_H */
This page took 0.030556 seconds and 4 git commands to generate.