public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Consolidate definition of current_directory
@ 2022-03-28 17:28 Tom Tromey
  2022-03-29 17:55 ` Pedro Alves
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2022-03-28 17:28 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

I noticed that both gdbserver and gdb define current_directory.
However, as it is referenced by gdbsupport, it seemed better to define
it there as well.  This patch also moves the declaration to
pathstuff.h.  Tested by rebuilding.
---
 gdb/top.c                | 4 ----
 gdbserver/server.cc      | 4 ----
 gdbsupport/common-defs.h | 3 ---
 gdbsupport/pathstuff.cc  | 4 ++++
 gdbsupport/pathstuff.h   | 3 +++
 5 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/gdb/top.c b/gdb/top.c
index 7831b4f96ca..787706ef10b 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -140,10 +140,6 @@ show_confirm (struct ui_file *file, int from_tty,
 		    value);
 }
 
-/* Current working directory.  */
-
-char *current_directory;
-
 /* The last command line executed on the console.  Used for command
    repetitions when the user enters an empty line.  */
 
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index 8e53f226d3c..9f52d6e63fe 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -65,10 +65,6 @@
       break;					\
     }
 
-/* String containing the current directory (what getwd would return).  */
-
-char *current_directory;
-
 /* The environment to pass to the inferior when creating it.  */
 
 static gdb_environ our_environ;
diff --git a/gdbsupport/common-defs.h b/gdbsupport/common-defs.h
index e263d948ee1..eed364a48ce 100644
--- a/gdbsupport/common-defs.h
+++ b/gdbsupport/common-defs.h
@@ -213,9 +213,6 @@
 /* Pull in gdb::unique_xmalloc_ptr.  */
 #include "gdbsupport/gdb_unique_ptr.h"
 
-/* String containing the current directory (what getwd would return).  */
-extern char *current_directory;
-
 /* sbrk on macOS is not useful for our purposes, since sbrk(0) always
    returns the same value.  brk/sbrk on macOS is just an emulation
    that always returns a pointer to a 4MB section reserved for
diff --git a/gdbsupport/pathstuff.cc b/gdbsupport/pathstuff.cc
index cb2dd4f5782..a347123cf2b 100644
--- a/gdbsupport/pathstuff.cc
+++ b/gdbsupport/pathstuff.cc
@@ -29,6 +29,10 @@
 
 /* See gdbsupport/pathstuff.h.  */
 
+char *current_directory;
+
+/* See gdbsupport/pathstuff.h.  */
+
 gdb::unique_xmalloc_ptr<char>
 gdb_realpath (const char *filename)
 {
diff --git a/gdbsupport/pathstuff.h b/gdbsupport/pathstuff.h
index 38828b7c4a3..50e388aad04 100644
--- a/gdbsupport/pathstuff.h
+++ b/gdbsupport/pathstuff.h
@@ -136,4 +136,7 @@ extern const char *get_shell ();
 
 extern gdb::char_vector make_temp_filename (const std::string &f);
 
+/* String containing the current directory (what getwd would return).  */
+extern char *current_directory;
+
 #endif /* COMMON_PATHSTUFF_H */
-- 
2.34.1


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

* Re: [PATCH] Consolidate definition of current_directory
  2022-03-28 17:28 [PATCH] Consolidate definition of current_directory Tom Tromey
@ 2022-03-29 17:55 ` Pedro Alves
  0 siblings, 0 replies; 2+ messages in thread
From: Pedro Alves @ 2022-03-29 17:55 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2022-03-28 18:28, Tom Tromey via Gdb-patches wrote:
> I noticed that both gdbserver and gdb define current_directory.
> However, as it is referenced by gdbsupport, it seemed better to define
> it there as well.  This patch also moves the declaration to
> pathstuff.h.  Tested by rebuilding.

Looks fine.

Thanks,
Pedro Alves

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

end of thread, other threads:[~2022-03-29 17:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-28 17:28 [PATCH] Consolidate definition of current_directory Tom Tromey
2022-03-29 17:55 ` Pedro Alves

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).