public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Move some generic code to gdbsupport
@ 2022-01-14 19:57 Tom Tromey
  2022-01-14 19:57 ` [PATCH 1/4] Move gdb_argv " Tom Tromey
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Tom Tromey @ 2022-01-14 19:57 UTC (permalink / raw)
  To: gdb-patches

I think that relatively generic utility code ought to be in
gdbsupport, not gdb proper.  This short series moves a few such
things.  The motivation for this is that I'd like to eliminate
gdb/utils.h -- maybe not achievable entirely, but we can at least
shrink it to be quite small.

Regression tested on x86-64 Fedora 34.

Tom



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/4] Move gdb_argv to gdbsupport
  2022-01-14 19:57 [PATCH 0/4] Move some generic code to gdbsupport Tom Tromey
@ 2022-01-14 19:57 ` Tom Tromey
  2022-01-14 19:57 ` [PATCH 2/4] Move gdb obstack code " Tom Tromey
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2022-01-14 19:57 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This moves the gdb_argv class to a new header in gdbsupport.
---
 gdb/cli/cli-decode.h   |   1 +
 gdb/compile/compile.c  |   1 +
 gdb/exec.c             |   1 +
 gdb/guile/scm-string.c |   1 +
 gdb/inferior.c         |   1 +
 gdb/infrun.c           |   1 +
 gdb/interps.c          |   1 +
 gdb/psymtab.c          |   1 +
 gdb/skip.c             |   1 +
 gdb/source.c           |   1 +
 gdb/stack.c            |   1 +
 gdb/symfile.c          |   1 +
 gdb/symmisc.c          |   1 +
 gdb/tracefile.c        |   1 +
 gdb/tracepoint.c       |   1 +
 gdb/utils.c            |  12 +--
 gdb/utils.h            | 174 -----------------------------------
 gdbsupport/buildargv.h | 204 +++++++++++++++++++++++++++++++++++++++++
 18 files changed, 220 insertions(+), 185 deletions(-)
 create mode 100644 gdbsupport/buildargv.h

diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h
index 8f367bf4634..ed75d3dfc15 100644
--- a/gdb/cli/cli-decode.h
+++ b/gdb/cli/cli-decode.h
@@ -27,6 +27,7 @@
 #include "cli-script.h"
 #include "completer.h"
 #include "gdbsupport/intrusive_list.h"
+#include "gdbsupport/buildargv.h"
 
 /* Not a set/show command.  Note that some commands which begin with
    "set" or "show" might be in this category, if their syntax does
diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c
index 3b76e102257..6794c93d60e 100644
--- a/gdb/compile/compile.c
+++ b/gdb/compile/compile.c
@@ -44,6 +44,7 @@
 #include "gdbsupport/gdb_unlinker.h"
 #include "gdbsupport/pathstuff.h"
 #include "gdbsupport/scoped_ignore_signal.h"
+#include "gdbsupport/buildargv.h"
 
 \f
 
diff --git a/gdb/exec.c b/gdb/exec.c
index f42862b2159..d9854d50f78 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -49,6 +49,7 @@
 #include <algorithm>
 #include "gdbsupport/pathstuff.h"
 #include "cli/cli-style.h"
+#include "gdbsupport/buildargv.h"
 
 void (*deprecated_file_changed_hook) (const char *);
 
diff --git a/gdb/guile/scm-string.c b/gdb/guile/scm-string.c
index 184eaaded07..bf558922db6 100644
--- a/gdb/guile/scm-string.c
+++ b/gdb/guile/scm-string.c
@@ -23,6 +23,7 @@
 #include "defs.h"
 #include "charset.h"
 #include "guile-internal.h"
+#include "gdbsupport/buildargv.h"
 
 /* Convert STRING to an int.
    STRING must be a valid integer.  */
diff --git a/gdb/inferior.c b/gdb/inferior.c
index c7a6ae87cf5..bebddb44173 100644
--- a/gdb/inferior.c
+++ b/gdb/inferior.c
@@ -35,6 +35,7 @@
 #include "target-descriptions.h"
 #include "readline/tilde.h"
 #include "progspace-and-thread.h"
+#include "gdbsupport/buildargv.h"
 
 /* Keep a registry of per-inferior data-pointers required by other GDB
    modules.  */
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 793d83a17a6..0ea5483edc5 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -72,6 +72,7 @@
 #include "scoped-mock-context.h"
 #include "test-target.h"
 #include "gdbsupport/common-debug.h"
+#include "gdbsupport/buildargv.h"
 
 /* Prototypes for local functions */
 
diff --git a/gdb/interps.c b/gdb/interps.c
index d65698f0cb4..a475d8790c9 100644
--- a/gdb/interps.c
+++ b/gdb/interps.c
@@ -38,6 +38,7 @@
 #include "completer.h"
 #include "top.h"		/* For command_loop.  */
 #include "main.h"
+#include "gdbsupport/buildargv.h"
 
 /* Each UI has its own independent set of interpreters.  */
 
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 7e2da485ba5..9db8a7aeba2 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -36,6 +36,7 @@
 #include "gdbcmd.h"
 #include <algorithm>
 #include <set>
+#include "gdbsupport/buildargv.h"
 
 static struct partial_symbol *lookup_partial_symbol (struct objfile *,
 						     struct partial_symtab *,
diff --git a/gdb/skip.c b/gdb/skip.c
index 2525b8b60db..3308252cb47 100644
--- a/gdb/skip.c
+++ b/gdb/skip.c
@@ -37,6 +37,7 @@
 #include "gdbsupport/gdb_optional.h"
 #include <list>
 #include "cli/cli-style.h"
+#include "gdbsupport/buildargv.h"
 
 /* True if we want to print debug printouts related to file/function
    skipping. */
diff --git a/gdb/source.c b/gdb/source.c
index 6bf4a4e881e..ab5cfc5a9d9 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -50,6 +50,7 @@
 #include "observable.h"
 #include "build-id.h"
 #include "debuginfod-support.h"
+#include "gdbsupport/buildargv.h"
 
 #define OPEN_MODE (O_RDONLY | O_BINARY)
 #define FDOPEN_MODE FOPEN_RB
diff --git a/gdb/stack.c b/gdb/stack.c
index 8239c76de20..b81be2962d4 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -55,6 +55,7 @@
 #include "gdbsupport/def-vector.h"
 #include "cli/cli-option.h"
 #include "cli/cli-style.h"
+#include "gdbsupport/buildargv.h"
 
 /* The possible choices of "set print frame-arguments", and the value
    of this setting.  */
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 0449b919974..37ce01bb0e6 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -61,6 +61,7 @@
 #include "gdbsupport/selftest.h"
 #include "cli/cli-style.h"
 #include "gdbsupport/forward-scope-exit.h"
+#include "gdbsupport/buildargv.h"
 
 #include <sys/types.h>
 #include <fcntl.h>
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index ca803fc5342..4cbe338cb84 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -38,6 +38,7 @@
 #include "source.h"
 #include "readline/tilde.h"
 #include <cli/cli-style.h>
+#include "gdbsupport/buildargv.h"
 
 /* Prototypes for local functions */
 
diff --git a/gdb/tracefile.c b/gdb/tracefile.c
index 50510af9805..f7d9331e5b7 100644
--- a/gdb/tracefile.c
+++ b/gdb/tracefile.c
@@ -24,6 +24,7 @@
 #include "regcache.h"
 #include "gdbsupport/byte-vector.h"
 #include "gdbarch.h"
+#include "gdbsupport/buildargv.h"
 
 /* Helper macros.  */
 
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index dc5e7f141cf..33f5c7f59fe 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -58,6 +58,7 @@
 #include <algorithm>
 #include "cli/cli-style.h"
 #include "expop.h"
+#include "gdbsupport/buildargv.h"
 
 #include <unistd.h>
 
diff --git a/gdb/utils.c b/gdb/utils.c
index 3ee2b5444df..da60c1e4144 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -76,6 +76,7 @@
 #include "cli-out.h"
 #include "gdbsupport/gdb-safe-ctype.h"
 #include "bt-utils.h"
+#include "gdbsupport/buildargv.h"
 
 void (*deprecated_error_begin_hook) (void);
 
@@ -2890,17 +2891,6 @@ ldirname (const char *filename)
   return dirname;
 }
 
-/* See utils.h.  */
-
-void
-gdb_argv::reset (const char *s)
-{
-  char **argv = buildargv (s);
-
-  freeargv (m_argv);
-  m_argv = argv;
-}
-
 /* Return ARGS parsed as a valid pid, or throw an error.  */
 
 int
diff --git a/gdb/utils.h b/gdb/utils.h
index ac30fd5f114..5ac34eb41a9 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -120,180 +120,6 @@ extern int parse_pid_to_attach (const char *args);
 
 extern int parse_escape (struct gdbarch *, const char **);
 
-/* A wrapper for an array of char* that was allocated in the way that
-   'buildargv' does, and should be freed with 'freeargv'.  */
-
-class gdb_argv
-{
-public:
-
-  /* A constructor that initializes to NULL.  */
-
-  gdb_argv ()
-    : m_argv (NULL)
-  {
-  }
-
-  /* A constructor that calls buildargv on STR.  STR may be NULL, in
-     which case this object is initialized with a NULL array.  */
-
-  explicit gdb_argv (const char *str)
-    : m_argv (NULL)
-  {
-    reset (str);
-  }
-
-  /* A constructor that takes ownership of an existing array.  */
-
-  explicit gdb_argv (char **array)
-    : m_argv (array)
-  {
-  }
-
-  gdb_argv (const gdb_argv &) = delete;
-  gdb_argv &operator= (const gdb_argv &) = delete;
-
-  gdb_argv &operator= (gdb_argv &&other)
-  {
-    freeargv (m_argv);
-    m_argv = other.m_argv;
-    other.m_argv = nullptr;
-    return *this;
-  }
-
-  gdb_argv (gdb_argv &&other)
-  {
-    m_argv = other.m_argv;
-    other.m_argv = nullptr;
-  }
-
-  ~gdb_argv ()
-  {
-    freeargv (m_argv);
-  }
-
-  /* Call buildargv on STR, storing the result in this object.  Any
-     previous state is freed.  STR may be NULL, in which case this
-     object is reset with a NULL array.  If buildargv fails due to
-     out-of-memory, call malloc_failure.  Therefore, the value is
-     guaranteed to be non-NULL, unless the parameter itself is
-     NULL.  */
-
-  void reset (const char *str);
-
-  /* Return the underlying array.  */
-
-  char **get ()
-  {
-    return m_argv;
-  }
-
-  const char * const * get () const
-  {
-    return m_argv;
-  }
-
-  /* Return the underlying array, transferring ownership to the
-     caller.  */
-
-  ATTRIBUTE_UNUSED_RESULT char **release ()
-  {
-    char **result = m_argv;
-    m_argv = NULL;
-    return result;
-  }
-
-  /* Return the number of items in the array.  */
-
-  int count () const
-  {
-    return countargv (m_argv);
-  }
-
-  /* Index into the array.  */
-
-  char *operator[] (int arg)
-  {
-    gdb_assert (m_argv != NULL);
-    return m_argv[arg];
-  }
-
-  /* Return the arguments array as an array view.  */
-
-  gdb::array_view<char *> as_array_view ()
-  {
-    return gdb::array_view<char *> (this->get (), this->count ());
-  }
-
-  gdb::array_view<const char * const> as_array_view () const
-  {
-    return gdb::array_view<const char * const> (this->get (), this->count ());
-  }
-
-  /* Append arguments to this array.  */
-  void append (gdb_argv &&other)
-  {
-    int size = count ();
-    int argc = other.count ();
-    m_argv = XRESIZEVEC (char *, m_argv, (size + argc + 1));
-
-    for (int argi = 0; argi < argc; argi++)
-      {
-	/* Transfer ownership of the string.  */
-	m_argv[size++] = other.m_argv[argi];
-	/* Ensure that destruction of OTHER works correctly.  */
-	other.m_argv[argi] = nullptr;
-      }
-    m_argv[size] = nullptr;
-  }
-
-  /* Append arguments to this array.  */
-  void append (const gdb_argv &other)
-  {
-    int size = count ();
-    int argc = other.count ();
-    m_argv = XRESIZEVEC (char *, m_argv, (size + argc + 1));
-
-    for (int argi = 0; argi < argc; argi++)
-      m_argv[size++] = xstrdup (other.m_argv[argi]);
-    m_argv[size] = nullptr;
-  }
-
-  /* The iterator type.  */
-
-  typedef char **iterator;
-
-  /* Return an iterator pointing to the start of the array.  */
-
-  iterator begin ()
-  {
-    return m_argv;
-  }
-
-  /* Return an iterator pointing to the end of the array.  */
-
-  iterator end ()
-  {
-    return m_argv + count ();
-  }
-
-  bool operator!= (std::nullptr_t)
-  {
-    return m_argv != NULL;
-  }
-
-  bool operator== (std::nullptr_t)
-  {
-    return m_argv == NULL;
-  }
-
-private:
-
-  /* The wrapped array.  */
-
-  char **m_argv;
-};
-
 \f
 /* Cleanup utilities.  */
 
diff --git a/gdbsupport/buildargv.h b/gdbsupport/buildargv.h
new file mode 100644
index 00000000000..7a34d9b509d
--- /dev/null
+++ b/gdbsupport/buildargv.h
@@ -0,0 +1,204 @@
+/* RAII wrapper for buildargv
+
+   Copyright (C) 2021 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   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/>.  */
+
+#ifndef GDBSUPPORT_BUILDARGV_H
+#define GDBSUPPORT_BUILDARGV_H
+
+#include "libiberty.h"
+
+/* A wrapper for an array of char* that was allocated in the way that
+   'buildargv' does, and should be freed with 'freeargv'.  */
+
+class gdb_argv
+{
+public:
+
+  /* A constructor that initializes to NULL.  */
+
+  gdb_argv ()
+    : m_argv (NULL)
+  {
+  }
+
+  /* A constructor that calls buildargv on STR.  STR may be NULL, in
+     which case this object is initialized with a NULL array.  */
+
+  explicit gdb_argv (const char *str)
+    : m_argv (NULL)
+  {
+    reset (str);
+  }
+
+  /* A constructor that takes ownership of an existing array.  */
+
+  explicit gdb_argv (char **array)
+    : m_argv (array)
+  {
+  }
+
+  gdb_argv (const gdb_argv &) = delete;
+  gdb_argv &operator= (const gdb_argv &) = delete;
+
+  gdb_argv &operator= (gdb_argv &&other)
+  {
+    freeargv (m_argv);
+    m_argv = other.m_argv;
+    other.m_argv = nullptr;
+    return *this;
+  }
+
+  gdb_argv (gdb_argv &&other)
+  {
+    m_argv = other.m_argv;
+    other.m_argv = nullptr;
+  }
+
+  ~gdb_argv ()
+  {
+    freeargv (m_argv);
+  }
+
+  /* Call buildargv on STR, storing the result in this object.  Any
+     previous state is freed.  STR may be NULL, in which case this
+     object is reset with a NULL array.  If buildargv fails due to
+     out-of-memory, call malloc_failure.  Therefore, the value is
+     guaranteed to be non-NULL, unless the parameter itself is
+     NULL.  */
+
+  void reset (const char *str)
+  {
+    char **argv = buildargv (str);
+    freeargv (m_argv);
+    m_argv = argv;
+  }
+
+  /* Return the underlying array.  */
+
+  char **get ()
+  {
+    return m_argv;
+  }
+
+  const char * const * get () const
+  {
+    return m_argv;
+  }
+
+  /* Return the underlying array, transferring ownership to the
+     caller.  */
+
+  ATTRIBUTE_UNUSED_RESULT char **release ()
+  {
+    char **result = m_argv;
+    m_argv = NULL;
+    return result;
+  }
+
+  /* Return the number of items in the array.  */
+
+  int count () const
+  {
+    return countargv (m_argv);
+  }
+
+  /* Index into the array.  */
+
+  char *operator[] (int arg)
+  {
+    gdb_assert (m_argv != NULL);
+    return m_argv[arg];
+  }
+
+  /* Return the arguments array as an array view.  */
+
+  gdb::array_view<char *> as_array_view ()
+  {
+    return gdb::array_view<char *> (this->get (), this->count ());
+  }
+
+  gdb::array_view<const char * const> as_array_view () const
+  {
+    return gdb::array_view<const char * const> (this->get (), this->count ());
+  }
+
+  /* Append arguments to this array.  */
+  void append (gdb_argv &&other)
+  {
+    int size = count ();
+    int argc = other.count ();
+    m_argv = XRESIZEVEC (char *, m_argv, (size + argc + 1));
+
+    for (int argi = 0; argi < argc; argi++)
+      {
+	/* Transfer ownership of the string.  */
+	m_argv[size++] = other.m_argv[argi];
+	/* Ensure that destruction of OTHER works correctly.  */
+	other.m_argv[argi] = nullptr;
+      }
+    m_argv[size] = nullptr;
+  }
+
+  /* Append arguments to this array.  */
+  void append (const gdb_argv &other)
+  {
+    int size = count ();
+    int argc = other.count ();
+    m_argv = XRESIZEVEC (char *, m_argv, (size + argc + 1));
+
+    for (int argi = 0; argi < argc; argi++)
+      m_argv[size++] = xstrdup (other.m_argv[argi]);
+    m_argv[size] = nullptr;
+  }
+
+  /* The iterator type.  */
+
+  typedef char **iterator;
+
+  /* Return an iterator pointing to the start of the array.  */
+
+  iterator begin ()
+  {
+    return m_argv;
+  }
+
+  /* Return an iterator pointing to the end of the array.  */
+
+  iterator end ()
+  {
+    return m_argv + count ();
+  }
+
+  bool operator!= (std::nullptr_t)
+  {
+    return m_argv != NULL;
+  }
+
+  bool operator== (std::nullptr_t)
+  {
+    return m_argv == NULL;
+  }
+
+private:
+
+  /* The wrapped array.  */
+
+  char **m_argv;
+};
+
+#endif /* GDBSUPPORT_BUILDARGV_H */
-- 
2.31.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/4] Move gdb obstack code to gdbsupport
  2022-01-14 19:57 [PATCH 0/4] Move some generic code to gdbsupport Tom Tromey
  2022-01-14 19:57 ` [PATCH 1/4] Move gdb_argv " Tom Tromey
@ 2022-01-14 19:57 ` Tom Tromey
  2022-01-14 19:57 ` [PATCH 3/4] Introduce gdb-hashtab module in gdbsupport Tom Tromey
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2022-01-14 19:57 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This moves the gdb-specific obstack code -- both extensions like
obconcat and obstack_strdup, and things like auto_obstack -- to
gdbsupport.
---
 gdb/Makefile.in                               |  2 --
 gdb/ada-lang.c                                |  2 +-
 gdb/addrmap.c                                 |  2 +-
 gdb/bcache.c                                  |  2 +-
 gdb/block.c                                   |  2 +-
 gdb/break-catch-throw.c                       |  2 +-
 gdb/bsd-uthread.c                             |  2 +-
 gdb/buildsym.c                                |  2 +-
 gdb/buildsym.h                                |  2 +-
 gdb/c-lang.c                                  |  2 +-
 gdb/c-typeprint.c                             |  2 +-
 gdb/charset.c                                 |  2 +-
 gdb/coffread.c                                |  2 +-
 gdb/cp-namespace.c                            |  2 +-
 gdb/cp-support.h                              |  2 +-
 gdb/cp-valprint.c                             |  2 +-
 gdb/d-namespace.c                             |  2 +-
 gdb/dbxread.c                                 |  2 +-
 gdb/dictionary.c                              |  2 +-
 gdb/dwarf2/read.h                             |  2 +-
 gdb/eval.c                                    |  2 +-
 gdb/f-typeprint.c                             |  2 +-
 gdb/frame-base.c                              |  2 +-
 gdb/frame-unwind.c                            |  2 +-
 gdb/frame.c                                   |  2 +-
 gdb/gdbarch.h                                 |  2 +-
 gdb/gdbtypes.h                                |  2 +-
 gdb/gnu-nat.c                                 |  2 +-
 gdb/go-lang.c                                 |  2 +-
 gdb/i386-windows-tdep.c                       |  2 +-
 gdb/linux-tdep.c                              |  2 +-
 gdb/m2-typeprint.c                            |  2 +-
 gdb/macroexp.c                                |  2 +-
 gdb/macrotab.c                                |  2 +-
 gdb/mdebugread.c                              |  2 +-
 gdb/mi/mi-cmd-break.c                         |  2 +-
 gdb/namespace.h                               |  2 +-
 gdb/objfiles.c                                |  2 +-
 gdb/objfiles.h                                |  2 +-
 gdb/p-typeprint.c                             |  2 +-
 gdb/p-valprint.c                              |  2 +-
 gdb/psymtab.h                                 |  2 +-
 gdb/python/py-unwind.c                        |  2 +-
 gdb/reggroups.c                               |  2 +-
 gdb/rust-parse.c                              |  2 +-
 gdb/stabsread.c                               |  2 +-
 gdb/symfile.c                                 |  2 +-
 gdb/symmisc.c                                 |  2 +-
 gdb/symtab.c                                  |  2 +-
 gdb/symtab.h                                  |  2 +-
 gdb/target-descriptions.c                     |  2 +-
 gdb/typeprint.c                               |  2 +-
 gdb/typeprint.h                               |  2 +-
 gdb/ui-file.c                                 |  2 +-
 gdb/utils.c                                   |  2 +-
 gdb/valprint.c                                |  2 +-
 gdb/windows-nat.c                             |  2 +-
 gdb/windows-tdep.c                            |  2 +-
 gdb/xml-support.h                             |  2 +-
 gdbsupport/Makefile.am                        |  1 +
 gdbsupport/Makefile.in                        | 20 +++++++++++--------
 .../gdb_obstack.cc                            |  2 +-
 {gdb => gdbsupport}/gdb_obstack.h             |  0
 63 files changed, 72 insertions(+), 69 deletions(-)
 rename gdb/gdb_obstack.c => gdbsupport/gdb_obstack.cc (98%)
 rename {gdb => gdbsupport}/gdb_obstack.h (100%)

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index d0db5fbdee1..ce9f1ad441c 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1074,7 +1074,6 @@ COMMON_SFILES = \
 	gcore.c \
 	gdb-demangle.c \
 	gdb_bfd.c \
-	gdb_obstack.c \
 	gdb_regex.c \
 	gdbtypes.c \
 	gmp-utils.c \
@@ -1316,7 +1315,6 @@ HFILES_NO_SRCDIR = \
 	gdb_bfd.h \
 	gdb_curses.h \
 	gdb_expat.h \
-	gdb_obstack.h \
 	gdb_proc_service.h \
 	gdb_regex.h \
 	gdb_select.h \
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index f2f8617cc1e..b88b27b55b1 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -35,7 +35,7 @@
 #include "breakpoint.h"
 #include "gdbcore.h"
 #include "hashtab.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "ada-lang.h"
 #include "completer.h"
 #include "ui-out.h"
diff --git a/gdb/addrmap.c b/gdb/addrmap.c
index a35eeed100e..bf30faab66b 100644
--- a/gdb/addrmap.c
+++ b/gdb/addrmap.c
@@ -19,7 +19,7 @@
 
 #include "defs.h"
 #include "splay-tree.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "addrmap.h"
 #include "gdbsupport/selftest.h"
 
diff --git a/gdb/bcache.c b/gdb/bcache.c
index c8a5b011598..6d0741b59d0 100644
--- a/gdb/bcache.c
+++ b/gdb/bcache.c
@@ -20,7 +20,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "bcache.h"
 
 #include <algorithm>
diff --git a/gdb/block.c b/gdb/block.c
index b590697a491..2b6196c09aa 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -21,7 +21,7 @@
 #include "block.h"
 #include "symtab.h"
 #include "symfile.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "cp-support.h"
 #include "addrmap.h"
 #include "gdbtypes.h"
diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
index 15c290b0ad1..5d17854d9af 100644
--- a/gdb/break-catch-throw.c
+++ b/gdb/break-catch-throw.c
@@ -27,7 +27,7 @@
 #include "valprint.h"
 #include "cli/cli-utils.h"
 #include "completer.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "mi/mi-common.h"
 #include "linespec.h"
 #include "probe.h"
diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c
index 5d5978d66ac..d0d9e89e93c 100644
--- a/gdb/bsd-uthread.c
+++ b/gdb/bsd-uthread.c
@@ -29,7 +29,7 @@
 #include "symfile.h"
 #include "target.h"
 
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 
 #include "bsd-uthread.h"
 
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 8827ddf1a11..1754f5ffe6e 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -19,7 +19,7 @@
 #include "defs.h"
 #include "buildsym-legacy.h"
 #include "bfd.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "symtab.h"
 #include "symfile.h"
 #include "objfiles.h"
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index 4ca8e0528f4..003d8a59719 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -19,7 +19,7 @@
 #if !defined (BUILDSYM_H)
 #define BUILDSYM_H 1
 
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 
 struct objfile;
 struct symbol;
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 4c9f8a741df..ed7554fadea 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -32,7 +32,7 @@
 #include "demangle.h"
 #include "cp-abi.h"
 #include "cp-support.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include <ctype.h>
 #include "gdbcore.h"
 #include "gdbarch.h"
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index 71d8797e84c..81fc82ec263 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -17,7 +17,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "bfd.h"		/* Binary File Description.  */
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/charset.c b/gdb/charset.c
index 0b3ef26f1d6..9b1de08a93a 100644
--- a/gdb/charset.c
+++ b/gdb/charset.c
@@ -20,7 +20,7 @@
 #include "defs.h"
 #include "charset.h"
 #include "gdbcmd.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "gdbsupport/gdb_wait.h"
 #include "charset-list.h"
 #include "gdbsupport/environ.h"
diff --git a/gdb/coffread.c b/gdb/coffread.c
index e264918fb3a..921cfce1053 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -24,7 +24,7 @@
 #include "breakpoint.h"
 
 #include "bfd.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include <ctype.h>
 
 #include "coff/internal.h"	/* Internal format of COFF symbols in BFD */
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index e6176719677..6130381fdd6 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -20,7 +20,7 @@
 
 #include "defs.h"
 #include "cp-support.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "symtab.h"
 #include "symfile.h"
 #include "block.h"
diff --git a/gdb/cp-support.h b/gdb/cp-support.h
index 832155bff42..cd473a2c553 100644
--- a/gdb/cp-support.h
+++ b/gdb/cp-support.h
@@ -26,7 +26,7 @@
 
 #include "symtab.h"
 #include "gdbsupport/gdb_vecs.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "gdbsupport/array-view.h"
 #include <vector>
 
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 98ac636a21c..1d98eb58214 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -18,7 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "expression.h"
diff --git a/gdb/d-namespace.c b/gdb/d-namespace.c
index 39097e8055c..eab99cec672 100644
--- a/gdb/d-namespace.c
+++ b/gdb/d-namespace.c
@@ -23,7 +23,7 @@
 #include "language.h"
 #include "namespace.h"
 #include "d-lang.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "gdbarch.h"
 
 /* This returns the length of first component of NAME, which should be
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 849ae0133f7..911d518b7e9 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -32,7 +32,7 @@
 
 #include "defs.h"
 
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include <sys/stat.h>
 #include "symtab.h"
 #include "breakpoint.h"
diff --git a/gdb/dictionary.c b/gdb/dictionary.c
index 7a686281475..849d07469cf 100644
--- a/gdb/dictionary.c
+++ b/gdb/dictionary.c
@@ -22,7 +22,7 @@
 
 #include "defs.h"
 #include <ctype.h>
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "symtab.h"
 #include "buildsym.h"
 #include "dictionary.h"
diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h
index 0071c385bfa..effeaabc4af 100644
--- a/gdb/dwarf2/read.h
+++ b/gdb/dwarf2/read.h
@@ -27,7 +27,7 @@
 #include "dwarf2/index-cache.h"
 #include "dwarf2/section.h"
 #include "filename-seen-cache.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "gdbsupport/hash_enum.h"
 #include "gdbsupport/function-view.h"
 #include "psympriv.h"
diff --git a/gdb/eval.c b/gdb/eval.c
index acac28e5c2d..713f977bc77 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -36,7 +36,7 @@
 #include "regcache.h"
 #include "user-regs.h"
 #include "valprint.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "objfiles.h"
 #include "typeprint.h"
 #include <ctype.h>
diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
index a633e47b2d3..0a338c11cbc 100644
--- a/gdb/f-typeprint.c
+++ b/gdb/f-typeprint.c
@@ -21,7 +21,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "bfd.h"
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/frame-base.c b/gdb/frame-base.c
index 7f018122d37..91af24b4f74 100644
--- a/gdb/frame-base.c
+++ b/gdb/frame-base.c
@@ -20,7 +20,7 @@
 #include "defs.h"
 #include "frame-base.h"
 #include "frame.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "gdbarch.h"
 
 /* A default frame base implementations.  If it wasn't for the old
diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c
index fdfe44cb10a..302ce1efb99 100644
--- a/gdb/frame-unwind.c
+++ b/gdb/frame-unwind.c
@@ -24,7 +24,7 @@
 #include "inline-frame.h"
 #include "value.h"
 #include "regcache.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "target.h"
 #include "gdbarch.h"
 #include "dwarf2/frame-tailcall.h"
diff --git a/gdb/frame.c b/gdb/frame.c
index cee6b08a49a..6e2f6b245a2 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -24,7 +24,7 @@
 #include "inferior.h"	/* for inferior_ptid */
 #include "regcache.h"
 #include "user-regs.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "dummy-frame.h"
 #include "sentinel-frame.h"
 #include "gdbcore.h"
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index fc1582449ed..6404dc1cb43 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -24,7 +24,7 @@
 #include <vector>
 #include "frame.h"
 #include "dis-asm.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "infrun.h"
 #include "osabi.h"
 #include "displaced-stepping.h"
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 42878dba933..467f60975e1 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -52,7 +52,7 @@
 #include "gdbsupport/underlying.h"
 #include "gdbsupport/print-utils.h"
 #include "dwarf2.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "gmp-utils.h"
 
 /* Forward declarations for prototypes.  */
diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
index 9c53e3c0c2f..ea3b8eee293 100644
--- a/gdb/gnu-nat.c
+++ b/gdb/gnu-nat.c
@@ -69,7 +69,7 @@ extern "C"
 #include "gdbcmd.h"
 #include "gdbcore.h"
 #include "gdbthread.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "tid-parse.h"
 #include "nat/fork-inferior.h"
 
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index d0c6188cb0b..74b8b214abb 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -32,7 +32,7 @@
 */
 
 #include "defs.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "block.h"
 #include "symtab.h"
 #include "language.h"
diff --git a/gdb/i386-windows-tdep.c b/gdb/i386-windows-tdep.c
index d50d6edb385..8e1cc17b91c 100644
--- a/gdb/i386-windows-tdep.c
+++ b/gdb/i386-windows-tdep.c
@@ -23,7 +23,7 @@
 #include "i386-tdep.h"
 #include "windows-tdep.h"
 #include "regset.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "xml-support.h"
 #include "gdbcore.h"
 #include "inferior.h"
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index b0056358cf9..4b69121e4d0 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -31,7 +31,7 @@
 #include "inferior.h"
 #include "cli/cli-utils.h"
 #include "arch-utils.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "observable.h"
 #include "objfiles.h"
 #include "infcall.h"
diff --git a/gdb/m2-typeprint.c b/gdb/m2-typeprint.c
index 9fd86f5f0d2..f929ab4df3c 100644
--- a/gdb/m2-typeprint.c
+++ b/gdb/m2-typeprint.c
@@ -17,7 +17,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "bfd.h"		/* Binary File Description */
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/macroexp.c b/gdb/macroexp.c
index 97adb6e31a2..be5723fe600 100644
--- a/gdb/macroexp.c
+++ b/gdb/macroexp.c
@@ -18,7 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "macrotab.h"
 #include "macroexp.h"
 #include "macroscope.h"
diff --git a/gdb/macrotab.c b/gdb/macrotab.c
index 479d08f13c6..92d68e78e71 100644
--- a/gdb/macrotab.c
+++ b/gdb/macrotab.c
@@ -18,7 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "splay-tree.h"
 #include "filenames.h"
 #include "symtab.h"
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index b8c8ccb5e97..1b327ad6115 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -45,7 +45,7 @@
 #include "gdbcore.h"
 #include "filenames.h"
 #include "objfiles.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "buildsym-legacy.h"
 #include "stabsread.h"
 #include "complaints.h"
diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c
index 7be4c3cb3b8..05eac3553ae 100644
--- a/gdb/mi/mi-cmd-break.c
+++ b/gdb/mi/mi-cmd-break.c
@@ -30,7 +30,7 @@
 #include "language.h"
 #include "location.h"
 #include "linespec.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include <ctype.h>
 #include "tracepoint.h"
 
diff --git a/gdb/namespace.h b/gdb/namespace.h
index e3bac97727e..dc052a44e42 100644
--- a/gdb/namespace.h
+++ b/gdb/namespace.h
@@ -20,7 +20,7 @@
 #define NAMESPACE_H
 
 #include "gdbsupport/gdb_vecs.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 
 /* This struct is designed to store data from using directives.  It
    says that names from namespace IMPORT_SRC should be visible within
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 262009eeda3..219dd0175cb 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -36,7 +36,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "hashtab.h"
 
 #include "breakpoint.h"
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 27737dc99ca..8bd76705688 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -21,7 +21,7 @@
 #define OBJFILES_H
 
 #include "hashtab.h"
-#include "gdb_obstack.h"	/* For obstack internals.  */
+#include "gdbsupport/gdb_obstack.h"	/* For obstack internals.  */
 #include "objfile-flags.h"
 #include "symfile.h"
 #include "progspace.h"
diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c
index 468f0fdece1..3450836996d 100644
--- a/gdb/p-typeprint.c
+++ b/gdb/p-typeprint.c
@@ -19,7 +19,7 @@
 /* This file is derived from p-typeprint.c */
 
 #include "defs.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "bfd.h"		/* Binary File Description */
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index d4a3971103c..e0c3868991b 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -20,7 +20,7 @@
 /* This file is derived from c-valprint.c */
 
 #include "defs.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "expression.h"
diff --git a/gdb/psymtab.h b/gdb/psymtab.h
index 7ad9a534af1..70eb3e246ba 100644
--- a/gdb/psymtab.h
+++ b/gdb/psymtab.h
@@ -20,7 +20,7 @@
 #ifndef PSYMTAB_H
 #define PSYMTAB_H
 
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "symfile.h"
 #include "gdbsupport/next-iterator.h"
 #include "bcache.h"
diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c
index a884c83ec26..4fea9068aad 100644
--- a/gdb/python/py-unwind.c
+++ b/gdb/python/py-unwind.c
@@ -20,7 +20,7 @@
 #include "defs.h"
 #include "arch-utils.h"
 #include "frame-unwind.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "gdbcmd.h"
 #include "language.h"
 #include "observable.h"
diff --git a/gdb/reggroups.c b/gdb/reggroups.c
index 2b612fbd040..1ad2a9c40f8 100644
--- a/gdb/reggroups.c
+++ b/gdb/reggroups.c
@@ -26,7 +26,7 @@
 #include "regcache.h"
 #include "command.h"
 #include "gdbcmd.h"		/* For maintenanceprintlist.  */
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 
 /* Individual register groups.  */
 
diff --git a/gdb/rust-parse.c b/gdb/rust-parse.c
index 6628a86f575..a3969fe4fa9 100644
--- a/gdb/rust-parse.c
+++ b/gdb/rust-parse.c
@@ -22,7 +22,7 @@
 #include "block.h"
 #include "charset.h"
 #include "cp-support.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "gdb_regex.h"
 #include "rust-lang.h"
 #include "parser-defs.h"
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index f6b211ec29e..20cba381cc5 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -26,7 +26,7 @@
 
 #include "defs.h"
 #include "bfd.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "expression.h"
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 37ce01bb0e6..a60892b08db 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -40,7 +40,7 @@
 #include "regcache.h"
 #include "filenames.h"		/* for DOSish file names */
 #include "gdb-stabs.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "completer.h"
 #include "bcache.h"
 #include "hashtab.h"
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 4cbe338cb84..3b5c3a07fc7 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -26,7 +26,7 @@
 #include "objfiles.h"
 #include "breakpoint.h"
 #include "command.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "language.h"
 #include "bcache.h"
 #include "block.h"
diff --git a/gdb/symtab.c b/gdb/symtab.c
index ba8e34df651..cf9f6cec34f 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -47,7 +47,7 @@
 #include "hashtab.h"
 #include "typeprint.h"
 
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "block.h"
 #include "dictionary.h"
 
diff --git a/gdb/symtab.h b/gdb/symtab.h
index a17ee02163a..740c7ed8c74 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -26,7 +26,7 @@
 #include <set>
 #include "gdbsupport/gdb_vecs.h"
 #include "gdbtypes.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "gdb_regex.h"
 #include "gdbsupport/enum-flags.h"
 #include "gdbsupport/function-view.h"
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 282729df9e6..7c380cdb60f 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -30,7 +30,7 @@
 #include "xml-tdesc.h"
 #include "osabi.h"
 
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "hashtab.h"
 #include "inferior.h"
 #include <algorithm>
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
index 2428aa2244f..0430df82012 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -18,7 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "bfd.h"		/* Binary File Description */
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/typeprint.h b/gdb/typeprint.h
index 97620a4caf2..29687234c7f 100644
--- a/gdb/typeprint.h
+++ b/gdb/typeprint.h
@@ -19,7 +19,7 @@
 #ifndef TYPEPRINT_H
 #define TYPEPRINT_H
 
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 
 enum language;
 struct ui_file;
diff --git a/gdb/ui-file.c b/gdb/ui-file.c
index c6a4888ed48..d30ec04a68f 100644
--- a/gdb/ui-file.c
+++ b/gdb/ui-file.c
@@ -21,7 +21,7 @@
 
 #include "defs.h"
 #include "ui-file.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "gdbsupport/gdb_select.h"
 #include "gdbsupport/filestuff.h"
 #include "cli/cli-style.h"
diff --git a/gdb/utils.c b/gdb/utils.c
index da60c1e4144..0be49a6d4f8 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -48,7 +48,7 @@
 #include "annotate.h"
 #include "filenames.h"
 #include "symfile.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "gdbcore.h"
 #include "top.h"
 #include "main.h"
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 0bc739cf2e2..f80c1698ad6 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -30,7 +30,7 @@
 #include "target-float.h"
 #include "extension.h"
 #include "ada-lang.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "charset.h"
 #include "typeprint.h"
 #include <ctype.h>
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index bdf6ac93c49..81e26fe4759 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -48,7 +48,7 @@
 #include "symfile.h"
 #include "objfiles.h"
 #include "gdb_bfd.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "gdbthread.h"
 #include "gdbcmd.h"
 #include <unistd.h>
diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c
index 78984d65fd6..13be3e4e461 100644
--- a/gdb/windows-tdep.c
+++ b/gdb/windows-tdep.c
@@ -17,7 +17,7 @@
 
 #include "defs.h"
 #include "windows-tdep.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "xml-support.h"
 #include "gdbarch.h"
 #include "target.h"
diff --git a/gdb/xml-support.h b/gdb/xml-support.h
index 1be77f8eaae..13edeaec910 100644
--- a/gdb/xml-support.h
+++ b/gdb/xml-support.h
@@ -21,7 +21,7 @@
 #ifndef XML_SUPPORT_H
 #define XML_SUPPORT_H
 
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "gdbsupport/xml-utils.h"
 #include "gdbsupport/byte-vector.h"
 #include "gdbsupport/gdb_optional.h"
diff --git a/gdbsupport/Makefile.am b/gdbsupport/Makefile.am
index d8f204b824a..73d4149f294 100644
--- a/gdbsupport/Makefile.am
+++ b/gdbsupport/Makefile.am
@@ -52,6 +52,7 @@ libgdbsupport_a_SOURCES = \
     filestuff.cc \
     format.cc \
     gdb-dlfcn.cc \
+    gdb_obstack.cc \
     gdb_tilde_expand.cc \
     gdb_wait.cc \
     gdb_vecs.cc \
diff --git a/gdbsupport/Makefile.in b/gdbsupport/Makefile.in
index c74e26aacd3..88d3dd153d6 100644
--- a/gdbsupport/Makefile.in
+++ b/gdbsupport/Makefile.in
@@ -151,14 +151,15 @@ am_libgdbsupport_a_OBJECTS = agent.$(OBJEXT) btrace-common.$(OBJEXT) \
 	common-regcache.$(OBJEXT) common-utils.$(OBJEXT) \
 	environ.$(OBJEXT) errors.$(OBJEXT) event-loop.$(OBJEXT) \
 	fileio.$(OBJEXT) filestuff.$(OBJEXT) format.$(OBJEXT) \
-	gdb-dlfcn.$(OBJEXT) gdb_tilde_expand.$(OBJEXT) \
-	gdb_wait.$(OBJEXT) gdb_vecs.$(OBJEXT) job-control.$(OBJEXT) \
-	netstuff.$(OBJEXT) new-op.$(OBJEXT) pathstuff.$(OBJEXT) \
-	print-utils.$(OBJEXT) ptid.$(OBJEXT) rsp-low.$(OBJEXT) \
-	run-time-clock.$(OBJEXT) safe-strerror.$(OBJEXT) \
-	scoped_mmap.$(OBJEXT) search.$(OBJEXT) signals.$(OBJEXT) \
-	signals-state-save-restore.$(OBJEXT) tdesc.$(OBJEXT) \
-	thread-pool.$(OBJEXT) xml-utils.$(OBJEXT) $(am__objects_1)
+	gdb-dlfcn.$(OBJEXT) gdb_obstack.$(OBJEXT) \
+	gdb_tilde_expand.$(OBJEXT) gdb_wait.$(OBJEXT) \
+	gdb_vecs.$(OBJEXT) job-control.$(OBJEXT) netstuff.$(OBJEXT) \
+	new-op.$(OBJEXT) pathstuff.$(OBJEXT) print-utils.$(OBJEXT) \
+	ptid.$(OBJEXT) rsp-low.$(OBJEXT) run-time-clock.$(OBJEXT) \
+	safe-strerror.$(OBJEXT) scoped_mmap.$(OBJEXT) search.$(OBJEXT) \
+	signals.$(OBJEXT) signals-state-save-restore.$(OBJEXT) \
+	tdesc.$(OBJEXT) thread-pool.$(OBJEXT) xml-utils.$(OBJEXT) \
+	$(am__objects_1)
 libgdbsupport_a_OBJECTS = $(am_libgdbsupport_a_OBJECTS)
 AM_V_P = $(am__v_P_@AM_V@)
 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
@@ -336,6 +337,7 @@ pdfdir = @pdfdir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
@@ -375,6 +377,7 @@ libgdbsupport_a_SOURCES = \
     filestuff.cc \
     format.cc \
     gdb-dlfcn.cc \
+    gdb_obstack.cc \
     gdb_tilde_expand.cc \
     gdb_wait.cc \
     gdb_vecs.cc \
@@ -480,6 +483,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filestuff.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/format.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdb-dlfcn.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdb_obstack.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdb_tilde_expand.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdb_vecs.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdb_wait.Po@am__quote@
diff --git a/gdb/gdb_obstack.c b/gdbsupport/gdb_obstack.cc
similarity index 98%
rename from gdb/gdb_obstack.c
rename to gdbsupport/gdb_obstack.cc
index 3f8d82a245e..571f34a7add 100644
--- a/gdb/gdb_obstack.c
+++ b/gdbsupport/gdb_obstack.cc
@@ -17,7 +17,7 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
+#include "common-defs.h"
 #include "gdb_obstack.h"
 
 /* Concatenate NULL terminated variable argument list of `const char *'
diff --git a/gdb/gdb_obstack.h b/gdbsupport/gdb_obstack.h
similarity index 100%
rename from gdb/gdb_obstack.h
rename to gdbsupport/gdb_obstack.h
-- 
2.31.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 3/4] Introduce gdb-hashtab module in gdbsupport
  2022-01-14 19:57 [PATCH 0/4] Move some generic code to gdbsupport Tom Tromey
  2022-01-14 19:57 ` [PATCH 1/4] Move gdb_argv " Tom Tromey
  2022-01-14 19:57 ` [PATCH 2/4] Move gdb obstack code " Tom Tromey
@ 2022-01-14 19:57 ` Tom Tromey
  2022-01-14 19:57 ` [PATCH 4/4] Move gdb_regex to gdbsupport Tom Tromey
  2022-01-18 11:52 ` [PATCH 0/4] Move some generic code " Andrew Burgess
  4 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2022-01-14 19:57 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

gdb has some extensions and helpers for working with the libiberty
hash table.  This patch consolidates these and moves them to
gdbsupport.
---
 gdb/compile/compile-internal.h |  1 +
 gdb/completer.h                |  1 +
 gdb/filename-seen-cache.h      |  1 +
 gdb/gdbtypes.h                 |  1 +
 gdb/utils.c                    | 24 ----------------
 gdb/utils.h                    | 26 ------------------
 gdbsupport/Makefile.am         |  1 +
 gdbsupport/Makefile.in         | 20 ++++++++------
 gdbsupport/gdb-hashtab.cc      | 44 ++++++++++++++++++++++++++++++
 gdbsupport/gdb-hashtab.h       | 50 ++++++++++++++++++++++++++++++++++
 10 files changed, 110 insertions(+), 59 deletions(-)
 create mode 100644 gdbsupport/gdb-hashtab.cc
 create mode 100644 gdbsupport/gdb-hashtab.h

diff --git a/gdb/compile/compile-internal.h b/gdb/compile/compile-internal.h
index 92efd511075..042ddf9c5f9 100644
--- a/gdb/compile/compile-internal.h
+++ b/gdb/compile/compile-internal.h
@@ -18,6 +18,7 @@
 #define COMPILE_COMPILE_INTERNAL_H
 
 #include "gcc-c-interface.h"
+#include "gdbsupport/gdb-hashtab.h"
 
 /* Debugging flag for the "compile" family of commands.  */
 
diff --git a/gdb/completer.h b/gdb/completer.h
index 93125e4c54c..78e5240a95e 100644
--- a/gdb/completer.h
+++ b/gdb/completer.h
@@ -17,6 +17,7 @@
 #if !defined (COMPLETER_H)
 #define COMPLETER_H 1
 
+#include "gdbsupport/gdb-hashtab.h"
 #include "gdbsupport/gdb_vecs.h"
 #include "command.h"
 
diff --git a/gdb/filename-seen-cache.h b/gdb/filename-seen-cache.h
index 09529031973..83a6e8a6258 100644
--- a/gdb/filename-seen-cache.h
+++ b/gdb/filename-seen-cache.h
@@ -22,6 +22,7 @@
 
 #include "defs.h"
 #include "gdbsupport/function-view.h"
+#include "gdbsupport/gdb-hashtab.h"
 
 /* Cache to watch for file names already seen.  */
 
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 467f60975e1..7238873e4db 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -46,6 +46,7 @@
 
 #include "hashtab.h"
 #include "gdbsupport/array-view.h"
+#include "gdbsupport/gdb-hashtab.h"
 #include "gdbsupport/gdb_optional.h"
 #include "gdbsupport/offset-type.h"
 #include "gdbsupport/enum-flags.h"
diff --git a/gdb/utils.c b/gdb/utils.c
index 0be49a6d4f8..bda3b7b5f0d 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -2841,30 +2841,6 @@ gdb_argv_as_array_view_test ()
 
 #endif /* GDB_SELF_TEST */
 
-/* Allocation function for the libiberty hash table which uses an
-   obstack.  The obstack is passed as DATA.  */
-
-void *
-hashtab_obstack_allocate (void *data, size_t size, size_t count)
-{
-  size_t total = size * count;
-  void *ptr = obstack_alloc ((struct obstack *) data, total);
-
-  memset (ptr, 0, total);
-  return ptr;
-}
-
-/* Trivial deallocation function for the libiberty splay tree and hash
-   table - don't deallocate anything.  Rely on later deletion of the
-   obstack.  DATA will be the obstack, although it is not needed
-   here.  */
-
-void
-dummy_obstack_deallocate (void *object, void *data)
-{
-  return;
-}
-
 /* Simple, portable version of dirname that does not modify its
    argument.  */
 
diff --git a/gdb/utils.h b/gdb/utils.h
index 5ac34eb41a9..8e9c2049915 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -123,27 +123,6 @@ extern int parse_escape (struct gdbarch *, const char **);
 \f
 /* Cleanup utilities.  */
 
-/* A deleter for a hash table.  */
-struct htab_deleter
-{
-  void operator() (htab *ptr) const
-  {
-    htab_delete (ptr);
-  }
-};
-
-/* A unique_ptr wrapper for htab_t.  */
-typedef std::unique_ptr<htab, htab_deleter> htab_up;
-
-/* A wrapper for 'delete' that can used as a hash table entry deletion
-   function.  */
-template<typename T>
-void
-htab_delete_entry (void *ptr)
-{
-  delete (T *) ptr;
-}
-
 extern void init_page_info (void);
 
 /* Temporarily set BATCH_FLAG and the associated unlimited terminal size.
@@ -384,11 +363,6 @@ extern void demangler_warning (const char *file, int line,
 \f
 /* Misc. utilities.  */
 
-/* Allocation and deallocation functions for the libiberty hash table
-   which use obstacks.  */
-void *hashtab_obstack_allocate (void *data, size_t size, size_t count);
-void dummy_obstack_deallocate (void *object, void *data);
-
 #ifdef HAVE_WAITPID
 extern pid_t wait_to_die_with_timeout (pid_t pid, int *status, int timeout);
 #endif
diff --git a/gdbsupport/Makefile.am b/gdbsupport/Makefile.am
index 73d4149f294..9e4334891b5 100644
--- a/gdbsupport/Makefile.am
+++ b/gdbsupport/Makefile.am
@@ -52,6 +52,7 @@ libgdbsupport_a_SOURCES = \
     filestuff.cc \
     format.cc \
     gdb-dlfcn.cc \
+    gdb-hashtab.cc \
     gdb_obstack.cc \
     gdb_tilde_expand.cc \
     gdb_wait.cc \
diff --git a/gdbsupport/Makefile.in b/gdbsupport/Makefile.in
index 88d3dd153d6..59e1dfedd8b 100644
--- a/gdbsupport/Makefile.in
+++ b/gdbsupport/Makefile.in
@@ -151,15 +151,15 @@ am_libgdbsupport_a_OBJECTS = agent.$(OBJEXT) btrace-common.$(OBJEXT) \
 	common-regcache.$(OBJEXT) common-utils.$(OBJEXT) \
 	environ.$(OBJEXT) errors.$(OBJEXT) event-loop.$(OBJEXT) \
 	fileio.$(OBJEXT) filestuff.$(OBJEXT) format.$(OBJEXT) \
-	gdb-dlfcn.$(OBJEXT) gdb_obstack.$(OBJEXT) \
-	gdb_tilde_expand.$(OBJEXT) gdb_wait.$(OBJEXT) \
-	gdb_vecs.$(OBJEXT) job-control.$(OBJEXT) netstuff.$(OBJEXT) \
-	new-op.$(OBJEXT) pathstuff.$(OBJEXT) print-utils.$(OBJEXT) \
-	ptid.$(OBJEXT) rsp-low.$(OBJEXT) run-time-clock.$(OBJEXT) \
-	safe-strerror.$(OBJEXT) scoped_mmap.$(OBJEXT) search.$(OBJEXT) \
-	signals.$(OBJEXT) signals-state-save-restore.$(OBJEXT) \
-	tdesc.$(OBJEXT) thread-pool.$(OBJEXT) xml-utils.$(OBJEXT) \
-	$(am__objects_1)
+	gdb-dlfcn.$(OBJEXT) gdb-hashtab.$(OBJEXT) \
+	gdb_obstack.$(OBJEXT) gdb_tilde_expand.$(OBJEXT) \
+	gdb_wait.$(OBJEXT) gdb_vecs.$(OBJEXT) job-control.$(OBJEXT) \
+	netstuff.$(OBJEXT) new-op.$(OBJEXT) pathstuff.$(OBJEXT) \
+	print-utils.$(OBJEXT) ptid.$(OBJEXT) rsp-low.$(OBJEXT) \
+	run-time-clock.$(OBJEXT) safe-strerror.$(OBJEXT) \
+	scoped_mmap.$(OBJEXT) search.$(OBJEXT) signals.$(OBJEXT) \
+	signals-state-save-restore.$(OBJEXT) tdesc.$(OBJEXT) \
+	thread-pool.$(OBJEXT) xml-utils.$(OBJEXT) $(am__objects_1)
 libgdbsupport_a_OBJECTS = $(am_libgdbsupport_a_OBJECTS)
 AM_V_P = $(am__v_P_@AM_V@)
 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
@@ -377,6 +377,7 @@ libgdbsupport_a_SOURCES = \
     filestuff.cc \
     format.cc \
     gdb-dlfcn.cc \
+    gdb-hashtab.cc \
     gdb_obstack.cc \
     gdb_tilde_expand.cc \
     gdb_wait.cc \
@@ -483,6 +484,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filestuff.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/format.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdb-dlfcn.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdb-hashtab.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdb_obstack.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdb_tilde_expand.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdb_vecs.Po@am__quote@
diff --git a/gdbsupport/gdb-hashtab.cc b/gdbsupport/gdb-hashtab.cc
new file mode 100644
index 00000000000..c42e8fec7b7
--- /dev/null
+++ b/gdbsupport/gdb-hashtab.cc
@@ -0,0 +1,44 @@
+/* Hash table wrappers for gdb.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   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/>.  */
+
+#include "common-defs.h"
+#include "gdb-hashtab.h"
+
+/* Allocation function for the libiberty hash table which uses an
+   obstack.  The obstack is passed as DATA.  */
+
+void *
+hashtab_obstack_allocate (void *data, size_t size, size_t count)
+{
+  size_t total = size * count;
+  void *ptr = obstack_alloc ((struct obstack *) data, total);
+
+  memset (ptr, 0, total);
+  return ptr;
+}
+
+/* Trivial deallocation function for the libiberty splay tree and hash
+   table - don't deallocate anything.  Rely on later deletion of the
+   obstack.  DATA will be the obstack, although it is not needed
+   here.  */
+
+void
+dummy_obstack_deallocate (void *object, void *data)
+{
+  return;
+}
diff --git a/gdbsupport/gdb-hashtab.h b/gdbsupport/gdb-hashtab.h
new file mode 100644
index 00000000000..65c2dc59a79
--- /dev/null
+++ b/gdbsupport/gdb-hashtab.h
@@ -0,0 +1,50 @@
+/* Hash table wrappers for gdb.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   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/>.  */
+
+#ifndef GDBSUPPORT_GDB_HASHTAB_H
+#define GDBSUPPORT_GDB_HASHTAB_H
+
+#include "hashtab.h"
+
+/* A deleter for a hash table.  */
+struct htab_deleter
+{
+  void operator() (htab *ptr) const
+  {
+    htab_delete (ptr);
+  }
+};
+
+/* A unique_ptr wrapper for htab_t.  */
+typedef std::unique_ptr<htab, htab_deleter> htab_up;
+
+/* A wrapper for 'delete' that can used as a hash table entry deletion
+   function.  */
+template<typename T>
+void
+htab_delete_entry (void *ptr)
+{
+  delete (T *) ptr;
+}
+
+/* Allocation and deallocation functions for the libiberty hash table
+   which use obstacks.  */
+void *hashtab_obstack_allocate (void *data, size_t size, size_t count);
+void dummy_obstack_deallocate (void *object, void *data);
+
+#endif /* GDBSUPPORT_GDB_HASHTAB_H */
-- 
2.31.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 4/4] Move gdb_regex to gdbsupport
  2022-01-14 19:57 [PATCH 0/4] Move some generic code to gdbsupport Tom Tromey
                   ` (2 preceding siblings ...)
  2022-01-14 19:57 ` [PATCH 3/4] Introduce gdb-hashtab module in gdbsupport Tom Tromey
@ 2022-01-14 19:57 ` Tom Tromey
  2022-01-18 11:52 ` [PATCH 0/4] Move some generic code " Andrew Burgess
  4 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2022-01-14 19:57 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This moves the gdb_regex convenience class to gdbsupport.
---
 gdb/Makefile.in                            |  2 --
 gdb/ada-lang.c                             |  2 +-
 gdb/auto-load.c                            |  2 +-
 gdb/break-catch-throw.c                    |  2 +-
 gdb/breakpoint.c                           |  2 +-
 gdb/cli/cli-cmds.c                         |  2 +-
 gdb/cli/cli-decode.c                       |  2 +-
 gdb/cli/cli-decode.h                       |  2 +-
 gdb/linux-tdep.c                           |  2 +-
 gdb/mi/mi-cmd-file.c                       |  2 +-
 gdb/objc-lang.c                            |  2 +-
 gdb/probe.c                                |  2 +-
 gdb/producer.c                             |  2 +-
 gdb/psymtab.c                              |  2 +-
 gdb/rust-parse.c                           |  2 +-
 gdb/skip.c                                 |  2 +-
 gdb/solib.c                                |  2 +-
 gdb/source.c                               |  2 +-
 gdb/symmisc.c                              |  2 +-
 gdb/symtab.c                               |  2 +-
 gdb/symtab.h                               |  2 +-
 gdb/thread.c                               |  2 +-
 gdb/ui-style.c                             |  2 +-
 gdb/utils.c                                |  2 +-
 gdb/varobj.c                               |  2 +-
 gdbsupport/Makefile.am                     |  1 +
 gdbsupport/Makefile.in                     | 19 +++++++++++--------
 gdb/gdb_regex.c => gdbsupport/gdb_regex.cc |  0
 {gdb => gdbsupport}/gdb_regex.h            |  0
 29 files changed, 36 insertions(+), 34 deletions(-)
 rename gdb/gdb_regex.c => gdbsupport/gdb_regex.cc (100%)
 rename {gdb => gdbsupport}/gdb_regex.h (100%)

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index ce9f1ad441c..2d9b2a76491 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1074,7 +1074,6 @@ COMMON_SFILES = \
 	gcore.c \
 	gdb-demangle.c \
 	gdb_bfd.c \
-	gdb_regex.c \
 	gdbtypes.c \
 	gmp-utils.c \
 	gnu-v2-abi.c \
@@ -1316,7 +1315,6 @@ HFILES_NO_SRCDIR = \
 	gdb_curses.h \
 	gdb_expat.h \
 	gdb_proc_service.h \
-	gdb_regex.h \
 	gdb_select.h \
 	gdb-stabs.h \
 	gdb_vfork.h \
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index b88b27b55b1..a39c1fdee64 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -20,7 +20,7 @@
 
 #include "defs.h"
 #include <ctype.h>
-#include "gdb_regex.h"
+#include "gdbsupport/gdb_regex.h"
 #include "frame.h"
 #include "symtab.h"
 #include "gdbtypes.h"
diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index 98b1373d57f..680b87936b1 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -21,7 +21,7 @@
 #include <ctype.h>
 #include "auto-load.h"
 #include "progspace.h"
-#include "gdb_regex.h"
+#include "gdbsupport/gdb_regex.h"
 #include "ui-out.h"
 #include "filenames.h"
 #include "command.h"
diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
index 5d17854d9af..d34e5f9ee53 100644
--- a/gdb/break-catch-throw.c
+++ b/gdb/break-catch-throw.c
@@ -33,7 +33,7 @@
 #include "probe.h"
 #include "objfiles.h"
 #include "cp-abi.h"
-#include "gdb_regex.h"
+#include "gdbsupport/gdb_regex.h"
 #include "cp-support.h"
 #include "location.h"
 #include "cli/cli-decode.h"
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index c7d75731621..e969ef367bc 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -56,7 +56,7 @@
 #include "valprint.h"
 #include "jit.h"
 #include "parser-defs.h"
-#include "gdb_regex.h"
+#include "gdbsupport/gdb_regex.h"
 #include "probe.h"
 #include "cli/cli-utils.h"
 #include "stack.h"
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index e62e7a9331f..563f29067c3 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -24,7 +24,7 @@
 #include "target.h"	/* For baud_rate, remote_debug and remote_timeout.  */
 #include "gdbsupport/gdb_wait.h"	/* For shell escape implementation.  */
 #include "gdbcmd.h"
-#include "gdb_regex.h"	/* Used by apropos_command.  */
+#include "gdbsupport/gdb_regex.h"	/* Used by apropos_command.  */
 #include "gdb_vfork.h"
 #include "linespec.h"
 #include "expression.h"
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index 7266fb36d0d..c8cd95620a5 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -18,7 +18,7 @@
 #include "defs.h"
 #include "symtab.h"
 #include <ctype.h>
-#include "gdb_regex.h"
+#include "gdbsupport/gdb_regex.h"
 #include "completer.h"
 #include "ui-out.h"
 #include "cli/cli-cmds.h"
diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h
index ed75d3dfc15..658142d338d 100644
--- a/gdb/cli/cli-decode.h
+++ b/gdb/cli/cli-decode.h
@@ -23,7 +23,7 @@
 
 /* Include the public interfaces.  */
 #include "command.h"
-#include "gdb_regex.h"
+#include "gdbsupport/gdb_regex.h"
 #include "cli-script.h"
 #include "completer.h"
 #include "gdbsupport/intrusive_list.h"
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index 4b69121e4d0..1b48b7fef25 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -36,7 +36,7 @@
 #include "objfiles.h"
 #include "infcall.h"
 #include "gdbcmd.h"
-#include "gdb_regex.h"
+#include "gdbsupport/gdb_regex.h"
 #include "gdbsupport/enum-flags.h"
 #include "gdbsupport/gdb_optional.h"
 #include "gcore.h"
diff --git a/gdb/mi/mi-cmd-file.c b/gdb/mi/mi-cmd-file.c
index 8fdcf891cf5..23c6d7021e2 100644
--- a/gdb/mi/mi-cmd-file.c
+++ b/gdb/mi/mi-cmd-file.c
@@ -28,7 +28,7 @@
 #include "psymtab.h"
 #include "solib.h"
 #include "solist.h"
-#include "gdb_regex.h"
+#include "gdbsupport/gdb_regex.h"
 
 /* Return to the client the absolute path and line number of the 
    current file being executed.  */
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 787e8d647ea..72470144abf 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -37,7 +37,7 @@
 #include "gdbcore.h"
 #include "gdbcmd.h"
 #include "frame.h"
-#include "gdb_regex.h"
+#include "gdbsupport/gdb_regex.h"
 #include "regcache.h"
 #include "block.h"
 #include "infcall.h"
diff --git a/gdb/probe.c b/gdb/probe.c
index b8da177a0ae..8b984f1650b 100644
--- a/gdb/probe.c
+++ b/gdb/probe.c
@@ -27,7 +27,7 @@
 #include "progspace.h"
 #include "filenames.h"
 #include "linespec.h"
-#include "gdb_regex.h"
+#include "gdbsupport/gdb_regex.h"
 #include "frame.h"
 #include "arch-utils.h"
 #include "value.h"
diff --git a/gdb/producer.c b/gdb/producer.c
index ba6e021b94a..ef1dd93afbc 100644
--- a/gdb/producer.c
+++ b/gdb/producer.c
@@ -20,7 +20,7 @@
 #include "defs.h"
 #include "producer.h"
 #include "gdbsupport/selftest.h"
-#include "gdb_regex.h"
+#include "gdbsupport/gdb_regex.h"
 
 /* See producer.h.  */
 
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 9db8a7aeba2..406b3b3cccb 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -29,7 +29,7 @@
 #include "ui-out.h"
 #include "command.h"
 #include "readline/tilde.h"
-#include "gdb_regex.h"
+#include "gdbsupport/gdb_regex.h"
 #include "dictionary.h"
 #include "language.h"
 #include "cp-support.h"
diff --git a/gdb/rust-parse.c b/gdb/rust-parse.c
index a3969fe4fa9..31a1ee3b38f 100644
--- a/gdb/rust-parse.c
+++ b/gdb/rust-parse.c
@@ -23,7 +23,7 @@
 #include "charset.h"
 #include "cp-support.h"
 #include "gdbsupport/gdb_obstack.h"
-#include "gdb_regex.h"
+#include "gdbsupport/gdb_regex.h"
 #include "rust-lang.h"
 #include "parser-defs.h"
 #include "gdbsupport/selftest.h"
diff --git a/gdb/skip.c b/gdb/skip.c
index 3308252cb47..62825cbddae 100644
--- a/gdb/skip.c
+++ b/gdb/skip.c
@@ -33,7 +33,7 @@
 #include "source.h"
 #include "filenames.h"
 #include "fnmatch.h"
-#include "gdb_regex.h"
+#include "gdbsupport/gdb_regex.h"
 #include "gdbsupport/gdb_optional.h"
 #include <list>
 #include "cli/cli-style.h"
diff --git a/gdb/solib.c b/gdb/solib.c
index 56b86614a16..b9b1d037187 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -29,7 +29,7 @@
 #include "command.h"
 #include "target.h"
 #include "frame.h"
-#include "gdb_regex.h"
+#include "gdbsupport/gdb_regex.h"
 #include "inferior.h"
 #include "gdbsupport/environ.h"
 #include "language.h"
diff --git a/gdb/source.c b/gdb/source.c
index ab5cfc5a9d9..9cfc18b8115 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -31,7 +31,7 @@
 #include <sys/types.h>
 #include <fcntl.h>
 #include "gdbcore.h"
-#include "gdb_regex.h"
+#include "gdbsupport/gdb_regex.h"
 #include "symfile.h"
 #include "objfiles.h"
 #include "annotate.h"
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 3b5c3a07fc7..2f4a076c352 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -30,7 +30,7 @@
 #include "language.h"
 #include "bcache.h"
 #include "block.h"
-#include "gdb_regex.h"
+#include "gdbsupport/gdb_regex.h"
 #include <sys/stat.h>
 #include "dictionary.h"
 #include "typeprint.h"
diff --git a/gdb/symtab.c b/gdb/symtab.c
index cf9f6cec34f..9fc96d7baa1 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -27,7 +27,7 @@
 #include "symfile.h"
 #include "objfiles.h"
 #include "gdbcmd.h"
-#include "gdb_regex.h"
+#include "gdbsupport/gdb_regex.h"
 #include "expression.h"
 #include "language.h"
 #include "demangle.h"
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 740c7ed8c74..55d1b772c45 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -27,7 +27,7 @@
 #include "gdbsupport/gdb_vecs.h"
 #include "gdbtypes.h"
 #include "gdbsupport/gdb_obstack.h"
-#include "gdb_regex.h"
+#include "gdbsupport/gdb_regex.h"
 #include "gdbsupport/enum-flags.h"
 #include "gdbsupport/function-view.h"
 #include "gdbsupport/gdb_optional.h"
diff --git a/gdb/thread.c b/gdb/thread.c
index c43f6613145..c6768a52c42 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -40,7 +40,7 @@
 #include "annotate.h"
 #include "cli/cli-decode.h"
 #include "cli/cli-option.h"
-#include "gdb_regex.h"
+#include "gdbsupport/gdb_regex.h"
 #include "cli/cli-utils.h"
 #include "thread-fsm.h"
 #include "tid-parse.h"
diff --git a/gdb/ui-style.c b/gdb/ui-style.c
index 253e796d57a..f1a5b8c4101 100644
--- a/gdb/ui-style.c
+++ b/gdb/ui-style.c
@@ -18,7 +18,7 @@
 
 #include "defs.h"
 #include "ui-style.h"
-#include "gdb_regex.h"
+#include "gdbsupport/gdb_regex.h"
 
 /* A regular expression that is used for matching ANSI terminal escape
    sequences.  */
diff --git a/gdb/utils.c b/gdb/utils.c
index bda3b7b5f0d..8489d3fec06 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -63,7 +63,7 @@
 #include <chrono>
 
 #include "interps.h"
-#include "gdb_regex.h"
+#include "gdbsupport/gdb_regex.h"
 #include "gdbsupport/job-control.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/gdb_optional.h"
diff --git a/gdb/varobj.c b/gdb/varobj.c
index b59ddc1e772..3aec027a5b6 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -23,7 +23,7 @@
 #include "gdbcmd.h"
 #include "block.h"
 #include "valprint.h"
-#include "gdb_regex.h"
+#include "gdbsupport/gdb_regex.h"
 
 #include "varobj.h"
 #include "gdbthread.h"
diff --git a/gdbsupport/Makefile.am b/gdbsupport/Makefile.am
index 9e4334891b5..6049fac20ef 100644
--- a/gdbsupport/Makefile.am
+++ b/gdbsupport/Makefile.am
@@ -54,6 +54,7 @@ libgdbsupport_a_SOURCES = \
     gdb-dlfcn.cc \
     gdb-hashtab.cc \
     gdb_obstack.cc \
+    gdb_regex.cc \
     gdb_tilde_expand.cc \
     gdb_wait.cc \
     gdb_vecs.cc \
diff --git a/gdbsupport/Makefile.in b/gdbsupport/Makefile.in
index 59e1dfedd8b..852e98c6bdf 100644
--- a/gdbsupport/Makefile.in
+++ b/gdbsupport/Makefile.in
@@ -152,14 +152,15 @@ am_libgdbsupport_a_OBJECTS = agent.$(OBJEXT) btrace-common.$(OBJEXT) \
 	environ.$(OBJEXT) errors.$(OBJEXT) event-loop.$(OBJEXT) \
 	fileio.$(OBJEXT) filestuff.$(OBJEXT) format.$(OBJEXT) \
 	gdb-dlfcn.$(OBJEXT) gdb-hashtab.$(OBJEXT) \
-	gdb_obstack.$(OBJEXT) gdb_tilde_expand.$(OBJEXT) \
-	gdb_wait.$(OBJEXT) gdb_vecs.$(OBJEXT) job-control.$(OBJEXT) \
-	netstuff.$(OBJEXT) new-op.$(OBJEXT) pathstuff.$(OBJEXT) \
-	print-utils.$(OBJEXT) ptid.$(OBJEXT) rsp-low.$(OBJEXT) \
-	run-time-clock.$(OBJEXT) safe-strerror.$(OBJEXT) \
-	scoped_mmap.$(OBJEXT) search.$(OBJEXT) signals.$(OBJEXT) \
-	signals-state-save-restore.$(OBJEXT) tdesc.$(OBJEXT) \
-	thread-pool.$(OBJEXT) xml-utils.$(OBJEXT) $(am__objects_1)
+	gdb_obstack.$(OBJEXT) gdb_regex.$(OBJEXT) \
+	gdb_tilde_expand.$(OBJEXT) gdb_wait.$(OBJEXT) \
+	gdb_vecs.$(OBJEXT) job-control.$(OBJEXT) netstuff.$(OBJEXT) \
+	new-op.$(OBJEXT) pathstuff.$(OBJEXT) print-utils.$(OBJEXT) \
+	ptid.$(OBJEXT) rsp-low.$(OBJEXT) run-time-clock.$(OBJEXT) \
+	safe-strerror.$(OBJEXT) scoped_mmap.$(OBJEXT) search.$(OBJEXT) \
+	signals.$(OBJEXT) signals-state-save-restore.$(OBJEXT) \
+	tdesc.$(OBJEXT) thread-pool.$(OBJEXT) xml-utils.$(OBJEXT) \
+	$(am__objects_1)
 libgdbsupport_a_OBJECTS = $(am_libgdbsupport_a_OBJECTS)
 AM_V_P = $(am__v_P_@AM_V@)
 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
@@ -379,6 +380,7 @@ libgdbsupport_a_SOURCES = \
     gdb-dlfcn.cc \
     gdb-hashtab.cc \
     gdb_obstack.cc \
+    gdb_regex.cc \
     gdb_tilde_expand.cc \
     gdb_wait.cc \
     gdb_vecs.cc \
@@ -486,6 +488,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdb-dlfcn.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdb-hashtab.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdb_obstack.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdb_regex.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdb_tilde_expand.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdb_vecs.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdb_wait.Po@am__quote@
diff --git a/gdb/gdb_regex.c b/gdbsupport/gdb_regex.cc
similarity index 100%
rename from gdb/gdb_regex.c
rename to gdbsupport/gdb_regex.cc
diff --git a/gdb/gdb_regex.h b/gdbsupport/gdb_regex.h
similarity index 100%
rename from gdb/gdb_regex.h
rename to gdbsupport/gdb_regex.h
-- 
2.31.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/4] Move some generic code to gdbsupport
  2022-01-14 19:57 [PATCH 0/4] Move some generic code to gdbsupport Tom Tromey
                   ` (3 preceding siblings ...)
  2022-01-14 19:57 ` [PATCH 4/4] Move gdb_regex to gdbsupport Tom Tromey
@ 2022-01-18 11:52 ` Andrew Burgess
  2022-01-18 17:14   ` Tom Tromey
  4 siblings, 1 reply; 7+ messages in thread
From: Andrew Burgess @ 2022-01-18 11:52 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

* Tom Tromey <tom@tromey.com> [2022-01-14 12:57:01 -0700]:

> I think that relatively generic utility code ought to be in
> gdbsupport, not gdb proper.  This short series moves a few such
> things.  The motivation for this is that I'd like to eliminate
> gdb/utils.h -- maybe not achievable entirely, but we can at least
> shrink it to be quite small.

A worthy goal!

This series looks good to me.

Thanks,
Andrew


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/4] Move some generic code to gdbsupport
  2022-01-18 11:52 ` [PATCH 0/4] Move some generic code " Andrew Burgess
@ 2022-01-18 17:14   ` Tom Tromey
  0 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2022-01-18 17:14 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: Tom Tromey, gdb-patches

Andrew> This series looks good to me.

Thanks.  I'm going to check it in.

Tom

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-01-18 17:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-14 19:57 [PATCH 0/4] Move some generic code to gdbsupport Tom Tromey
2022-01-14 19:57 ` [PATCH 1/4] Move gdb_argv " Tom Tromey
2022-01-14 19:57 ` [PATCH 2/4] Move gdb obstack code " Tom Tromey
2022-01-14 19:57 ` [PATCH 3/4] Introduce gdb-hashtab module in gdbsupport Tom Tromey
2022-01-14 19:57 ` [PATCH 4/4] Move gdb_regex to gdbsupport Tom Tromey
2022-01-18 11:52 ` [PATCH 0/4] Move some generic code " Andrew Burgess
2022-01-18 17:14   ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).