public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFC 0/6] Some user-friendliness changes
@ 2020-04-04 14:54 Tom Tromey
  2020-04-04 14:54 ` [RFC 1/6] Introduce read_entire_file Tom Tromey
                   ` (5 more replies)
  0 siblings, 6 replies; 18+ messages in thread
From: Tom Tromey @ 2020-04-04 14:54 UTC (permalink / raw)
  To: gdb-patches

This series implements a few small user-friendliness changes.  They're
maybe a bit odd, so I thought I'd get feedback before making sure they
pass the test suite (or writing tests for them, if that can even
sensibly be done).

A couple of the patches (#1 and #4) are just infrastructure, but the
rest add user-facing features.

Tom



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

* [RFC 1/6] Introduce read_entire_file
  2020-04-04 14:54 [RFC 0/6] Some user-friendliness changes Tom Tromey
@ 2020-04-04 14:54 ` Tom Tromey
  2020-04-04 14:54 ` [RFC 2/6] Add "help news" Tom Tromey
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 18+ messages in thread
From: Tom Tromey @ 2020-04-04 14:54 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds a new function, read_entire_file, and changes the source
cache to use it.  This will be used in a subsequent patch as well.

gdb/ChangeLog
2020-03-28  Tom Tromey  <tom@tromey.com>

	* utils.h (myread): Don't declare.
	* utils.c (myread): Remove.
	* source-cache.c (source_cache::get_plain_source_lines): Use
	read_entire_file.

gdbsupport/ChangeLog
2020-03-28  Tom Tromey  <tom@tromey.com>

	* filestuff.h (read_entire_file): Declare.
	* filestuff.cc (read_entire_file): New function.
---
 gdb/ChangeLog           |  7 +++++++
 gdb/source-cache.c      | 14 +++++---------
 gdb/utils.c             | 22 ----------------------
 gdb/utils.h             |  2 --
 gdbsupport/ChangeLog    |  5 +++++
 gdbsupport/filestuff.cc | 33 +++++++++++++++++++++++++++++++++
 gdbsupport/filestuff.h  |  9 +++++++++
 7 files changed, 59 insertions(+), 33 deletions(-)

diff --git a/gdb/source-cache.c b/gdb/source-cache.c
index 9196e3a19e3..63e08c3aeb0 100644
--- a/gdb/source-cache.c
+++ b/gdb/source-cache.c
@@ -18,6 +18,7 @@
 
 #include "defs.h"
 #include "source-cache.h"
+#include "gdbsupport/filestuff.h"
 #include "gdbsupport/scoped_fd.h"
 #include "source.h"
 #include "cli/cli-style.h"
@@ -56,14 +57,9 @@ source_cache::get_plain_source_lines (struct symtab *s,
   if (desc.get () < 0)
     perror_with_name (symtab_to_filename_for_display (s));
 
-  struct stat st;
-  if (fstat (desc.get (), &st) < 0)
-    perror_with_name (symtab_to_filename_for_display (s));
-
-  std::string lines;
-  lines.resize (st.st_size);
-  if (myread (desc.get (), &lines[0], lines.size ()) < 0)
-    perror_with_name (symtab_to_filename_for_display (s));
+  time_t file_mtime;
+  std::string lines = read_entire_file (symtab_to_filename_for_display (s),
+					desc.get (), &file_mtime);
 
   time_t mtime = 0;
   if (SYMTAB_OBJFILE (s) != NULL && SYMTAB_OBJFILE (s)->obfd != NULL)
@@ -71,7 +67,7 @@ source_cache::get_plain_source_lines (struct symtab *s,
   else if (exec_bfd)
     mtime = exec_bfd_mtime;
 
-  if (mtime && mtime < st.st_mtime)
+  if (mtime && mtime < file_mtime)
     warning (_("Source file is more recent than executable."));
 
   std::vector<off_t> offsets;
diff --git a/gdb/utils.c b/gdb/utils.c
index bda6bbf5b0e..3fe739eeaf5 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -691,28 +691,6 @@ malloc_failure (long size)
     }
 }
 
-/* My replacement for the read system call.
-   Used like `read' but keeps going if `read' returns too soon.  */
-
-int
-myread (int desc, char *addr, int len)
-{
-  int val;
-  int orglen = len;
-
-  while (len > 0)
-    {
-      val = read (desc, addr, len);
-      if (val < 0)
-	return val;
-      if (val == 0)
-	return orglen - len;
-      len -= val;
-      addr += val;
-    }
-  return orglen;
-}
-
 void
 print_spaces (int n, struct ui_file *file)
 {
diff --git a/gdb/utils.h b/gdb/utils.h
index 3434ff1caa2..d0989204128 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -540,8 +540,6 @@ void dummy_obstack_deallocate (void *object, void *data);
 extern pid_t wait_to_die_with_timeout (pid_t pid, int *status, int timeout);
 #endif
 
-extern int myread (int, char *, int);
-
 /* Resource limits used by getrlimit and setrlimit.  */
 
 enum resource_limit_kind
diff --git a/gdbsupport/filestuff.cc b/gdbsupport/filestuff.cc
index 179c4258918..0f0a238beb0 100644
--- a/gdbsupport/filestuff.cc
+++ b/gdbsupport/filestuff.cc
@@ -501,3 +501,36 @@ mkdir_recursive (const char *dir)
       component_start = component_end;
     }
 }
+
+/* See filestuff.h.  */
+
+std::string
+read_entire_file (const char *name, int fd, time_t *mtime)
+{
+  struct stat st;
+  if (fstat (fd, &st) < 0)
+    perror_with_name (name);
+  size_t len = st.st_size;
+
+  std::string lines;
+  lines.resize (len);
+  char *addr = &lines[0];
+
+  while (len > 0)
+    {
+      int val = read (fd, addr, len);
+      if (val < 0)
+	perror_with_name (name);
+      if (val == 0)
+	break;
+      len -= val;
+      addr += val;
+    }
+
+  if (mtime != nullptr)
+    *mtime = st.st_mtime;
+
+  /* Just in case we really did end up short.  */
+  lines.resize (st.st_size - len);
+  return lines;
+}
diff --git a/gdbsupport/filestuff.h b/gdbsupport/filestuff.h
index e36936a84ce..84924f462e2 100644
--- a/gdbsupport/filestuff.h
+++ b/gdbsupport/filestuff.h
@@ -139,4 +139,13 @@ extern bool is_regular_file (const char *name, int *errno_ptr);
 
 extern bool mkdir_recursive (const char *dir);
 
+/* Read and return the entire contents of a file.  The file must
+   already be open on FD.  NAME is the file name it is used when
+   reporting errors, which is done by throwing an exception.  The
+   mtime of the file is optionally stored in *MTIME; if MTIME is
+   nullptr, this is ignored.  */
+
+extern std::string read_entire_file (const char *name, int fd,
+				     time_t *mtime = nullptr);
+
 #endif /* COMMON_FILESTUFF_H */
-- 
2.17.2


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

* [RFC 2/6] Add "help news"
  2020-04-04 14:54 [RFC 0/6] Some user-friendliness changes Tom Tromey
  2020-04-04 14:54 ` [RFC 1/6] Introduce read_entire_file Tom Tromey
@ 2020-04-04 14:54 ` Tom Tromey
  2020-04-04 16:15   ` Eli Zaretskii
  2020-04-04 14:54 ` [RFC 3/6] Add "tips" file to gdb Tom Tromey
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 18+ messages in thread
From: Tom Tromey @ 2020-04-04 14:54 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds a "help news" subcommand, which simply dumps the NEWS file.
The NEWS file is now installed.

gdb/ChangeLog
2020-03-28  Tom Tromey  <tom@tromey.com>

	* NEWS: Add entry.
	* data-directory/Makefile.in (GDB_FILES): New variable.
	(all): Add gdb-files.
	(gdb-files, install-gdb-files, uninstall-gdb-files): New targets.
	(install-only, uninstall): Update.
	* cli/cli-decode.c (help_news): New file.
	(help_cmd): Handle "news".
	(help_list): Mention "help news".
---
 gdb/ChangeLog                  | 11 +++++++++
 gdb/NEWS                       |  3 +++
 gdb/cli/cli-decode.c           | 41 ++++++++++++++++++++++++++++++++++
 gdb/data-directory/Makefile.in | 28 ++++++++++++++++++++---
 4 files changed, 80 insertions(+), 3 deletions(-)

diff --git a/gdb/NEWS b/gdb/NEWS
index 6657f6fadce..9d85e630e8c 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -44,6 +44,9 @@
 
 * New commands
 
+help news
+  Show this NEWS file.
+
 set exec-file-mismatch -- Set exec-file-mismatch handling (ask|warn|off).
 show exec-file-mismatch -- Show exec-file-mismatch handling (ask|warn|off).
   Set or show the option 'exec-file-mismatch'.  When GDB attaches to
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index 7aecd9897e2..948350c7a7f 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -1030,6 +1030,38 @@ apropos_cmd (struct ui_file *stream,
     }
 }
 
+/* Implement "help news".  */
+
+static void
+help_news (struct ui_file *stream)
+{
+  std::string news_name = std::string (gdb_datadir) + SLASH_STRING + "NEWS";
+  gdb_file_up news_file = gdb_fopen_cloexec (news_name.c_str (), "r");
+  if (news_file == nullptr)
+    perror_with_name (_("could not open the NEWS file"));
+
+  char buffer[1024];
+  size_t offset = 0;
+  while (true)
+    {
+      size_t nbytes = fread (&buffer[offset], 1, sizeof (buffer) - offset,
+			     news_file.get ());
+      if (nbytes == 0)
+	break;
+      size_t n_valid = offset + nbytes;
+      size_t newline;
+      for (newline = n_valid; newline > 0 && buffer[newline] != '\n'; --newline)
+	;
+      if (newline == 0)
+	error (_("NEWS file is malformed"));
+      buffer[newline] = '\0';
+      fputs_filtered (buffer, stream);
+      fputs_filtered ("\n", stream);
+      offset = n_valid - (newline + 1);
+      memmove (buffer, &buffer[newline + 1], offset);
+    }
+}
+
 /* This command really has to deal with two things:
    1) I want documentation on *this string* (usually called by
       "help commandname").
@@ -1058,6 +1090,12 @@ help_cmd (const char *command, struct ui_file *stream)
       return;
     }
 
+  if (strcmp (command, "news") == 0)
+    {
+      help_news (stream);
+      return;
+    }
+
   c = lookup_cmd (&command, cmdlist, "", 0, 0);
 
   if (c == 0)
@@ -1156,6 +1194,9 @@ Type \"help%s\" followed by a class name for a list of commands in ",
 
       fprintf_filtered (stream, "\n\
 Type \"help all\" for the list of all commands.");
+
+      fprintf_filtered (stream, "\n\
+Type \"help news\" to see what is new in GDB.");
     }
 
   fprintf_filtered (stream, "\nType \"help%s\" followed by %scommand name ",
diff --git a/gdb/data-directory/Makefile.in b/gdb/data-directory/Makefile.in
index 68b794a353d..95258d184e7 100644
--- a/gdb/data-directory/Makefile.in
+++ b/gdb/data-directory/Makefile.in
@@ -139,6 +139,8 @@ SYSTEM_GDBINIT_FILES = \
 	elinos.py \
 	wrs-linux.py
 
+GDB_FILES = NEWS
+
 FLAGS_TO_PASS = \
 	"prefix=$(prefix)" \
 	"exec_prefix=$(exec_prefix)" \
@@ -172,7 +174,7 @@ FLAGS_TO_PASS = \
 	"RUNTESTFLAGS=$(RUNTESTFLAGS)"
 
 .PHONY: all
-all: stamp-syscalls stamp-python stamp-guile stamp-system-gdbinit
+all: stamp-syscalls stamp-python stamp-guile stamp-system-gdbinit gdb-files
 
 %.xml: @MAINTAINER_MODE_TRUE@ %.xml.in apply-defaults.xsl linux-defaults.xml.in
 	$(XSLTPROC) -o $(SYSCALLS_SRCDIR)/$@ $(SYSCALLS_SRCDIR)/apply-defaults.xsl\
@@ -234,6 +236,26 @@ uninstall-syscalls:
 	  done \
 	done
 
+gdb-files: $(addprefix $(srcdir)/../,$(GDB_FILES))
+	files='$(GDB_FILES)'; \
+	for file in $$files; do \
+	  cp $(srcdir)/../$$file .; \
+	done
+
+.PHONY: install-gdb-files
+install-gdb-files:
+	files='$(GDB_FILES)'; \
+	for file in $$files; do \
+	  $(INSTALL_DATA) $(srcdir)/../$$file  $(DESTDIR)$(GDB_DATADIR); \
+	done
+
+.PHONY: uninstall-gdb-files
+uninstall-gdb-files:
+	files='$(GDB_FILES)'; \
+	for file in $$files; do \
+	  rm -f $(DESTDIR)$(GDB_DATADIR)/$$file; \
+	done
+
 stamp-python: Makefile $(PYTHON_FILES)
 	rm -rf ./$(PYTHON_DIR)
 	files='$(PYTHON_FILES)' ; \
@@ -379,11 +401,11 @@ install: all
 
 .PHONY: install-only
 install-only: install-syscalls install-python install-guile \
-	install-system-gdbinit
+	install-system-gdbinit install-news
 
 .PHONY: uninstall
 uninstall: uninstall-syscalls uninstall-python uninstall-guile \
-	uninstall-system-gdbinit
+	uninstall-system-gdbinit uninstall-news
 
 .PHONY: clean
 clean: clean-syscalls clean-python clean-guile clean-system-gdbinit
-- 
2.17.2


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

* [RFC 3/6] Add "tips" file to gdb
  2020-04-04 14:54 [RFC 0/6] Some user-friendliness changes Tom Tromey
  2020-04-04 14:54 ` [RFC 1/6] Introduce read_entire_file Tom Tromey
  2020-04-04 14:54 ` [RFC 2/6] Add "help news" Tom Tromey
@ 2020-04-04 14:54 ` Tom Tromey
  2020-04-04 16:16   ` Eli Zaretskii
  2020-04-04 14:54 ` [RFC 4/6] Add get_standard_config_dir function Tom Tromey
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 18+ messages in thread
From: Tom Tromey @ 2020-04-04 14:54 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds a "tips" file to gdb.  This file holds handy tips -- right
now there are just a few, but it's easy to add more.  A random tip is
displayed during interactive startup.

gdb/ChangeLog
2020-03-28  Tom Tromey  <tom@tromey.com>

	* NEWS: Add entry.
	* top.c (startup_style): New global.
	(print_tip): New function.
	(print_gdb_version): Update.  Don't print "show configuration"
	or "apropos" info.  Call print_tip.
	* tips: New file.
	* data-directory/Makefile.in (GDB_FILES): Add "tips".
---
 gdb/ChangeLog                  | 10 +++++
 gdb/NEWS                       |  2 +
 gdb/data-directory/Makefile.in |  2 +-
 gdb/tips                       |  9 ++++
 gdb/top.c                      | 78 +++++++++++++++++++++++++++++-----
 5 files changed, 89 insertions(+), 12 deletions(-)
 create mode 100644 gdb/tips

diff --git a/gdb/NEWS b/gdb/NEWS
index 9d85e630e8c..b376737e409 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -3,6 +3,8 @@
 
 *** Changes since GDB 9
 
+* GDB will now display a helpful tip when starting up.
+
 * GDB now supports debuginfod, an HTTP server for distributing ELF/DWARF
   debugging information as well as source code.
 
diff --git a/gdb/data-directory/Makefile.in b/gdb/data-directory/Makefile.in
index 95258d184e7..5cc7ec80c40 100644
--- a/gdb/data-directory/Makefile.in
+++ b/gdb/data-directory/Makefile.in
@@ -139,7 +139,7 @@ SYSTEM_GDBINIT_FILES = \
 	elinos.py \
 	wrs-linux.py
 
-GDB_FILES = NEWS
+GDB_FILES = NEWS tips
 
 FLAGS_TO_PASS = \
 	"prefix=$(prefix)" \
diff --git a/gdb/tips b/gdb/tips
new file mode 100644
index 00000000000..75957fb853d
--- /dev/null
+++ b/gdb/tips
@@ -0,0 +1,9 @@
+This file is in the old "fortune" format.  Each entry is separated by
+a percent character on a line of its own.  Anything before the first
+percent will never be shown.
+%
+You can use "help news" to see what has changed in GDB.
+%
+Type "apropos word" to search for commands related to "word".
+%
+Type "show configuration" for configuration details.
diff --git a/gdb/top.c b/gdb/top.c
index e2432489dc8..7af820b0bb9 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -56,6 +56,8 @@
 #include "gdbarch.h"
 #include "gdbsupport/pathstuff.h"
 #include "cli/cli-style.h"
+#include "gdbsupport/scoped_fd.h"
+#include <random>
 
 /* readline include files.  */
 #include "readline/readline.h"
@@ -128,6 +130,14 @@ current_ui_current_uiout_ptr ()
 
 int inhibit_gdbinit = 0;
 
+/* The style used for informational messages at startup.  */
+static ui_file_style startup_style =
+{
+  ui_file_style::MAGENTA,
+  ui_file_style::NONE,
+  ui_file_style::BOLD
+};
+
 /* Flag for whether we want to confirm potentially dangerous
    operations.  Default is yes.  */
 
@@ -1376,6 +1386,59 @@ command_line_input (const char *prompt_arg, const char *annotation_suffix)
   return cmd;
 }
 \f
+
+/* Print a useful tip to STREAM.  */
+
+static void
+print_tip (struct ui_file *stream)
+{
+  std::string tip_name = std::string (gdb_datadir) + SLASH_STRING + "tips";
+  scoped_fd fd (gdb_open_cloexec (tip_name.c_str (), O_RDONLY | O_BINARY, 0));
+  if (fd.get () < 0)
+    {
+      perror_warning_with_name ((std::string (_("Could not open tip file "))
+				 + tip_name).c_str ());
+      return;
+    }
+
+  std::string lines;
+  try
+    {
+      lines = read_entire_file (tip_name.c_str (), fd.get ());
+    }
+  catch (const gdb_exception &exc)
+    {
+      exception_print (stream, exc);
+      return;
+    }
+
+  std::vector<gdb::string_view> strings;
+  size_t offset = lines.find ("%\n");
+  if (offset == std::string::npos)
+    return;
+  while (offset != std::string::npos)
+    {
+      offset += 2;
+      size_t next_offset = lines.find ("%\n", offset);
+
+      if (next_offset == std::string::npos)
+	strings.emplace_back (lines.c_str () + offset);
+      else
+	strings.emplace_back (lines.c_str () + offset, next_offset - offset);
+
+      offset = next_offset;
+    }
+
+  std::random_device rd;
+  std::mt19937 mt (rd ());
+  std::uniform_int_distribution<> distr (0, strings.size () - 1);
+  int index = distr (mt);
+  /* Note that the string will include a newline.  */
+  fprintf_styled (stream, startup_style, "\n%.*s",
+		  (int) strings[index].size (),
+		  strings[index].data ());
+}
+
 /* See top.h.  */
 void
 print_gdb_version (struct ui_file *stream, bool interactive)
@@ -1386,11 +1449,7 @@ print_gdb_version (struct ui_file *stream, bool interactive)
 
   ui_file_style style;
   if (interactive)
-    {
-      ui_file_style nstyle = { ui_file_style::MAGENTA, ui_file_style::NONE,
-			       ui_file_style::BOLD };
-      style = nstyle;
-    }
+    style = startup_style;
   fprintf_styled (stream, style, "GNU gdb %s%s\n", PKGVERSION, version);
 
   /* Second line is a copyright notice.  */
@@ -1428,9 +1487,6 @@ There is NO WARRANTY, to the extent permitted by law.");
     }
   fprintf_filtered (stream, "\".\n");
 
-  fprintf_filtered (stream, _("Type \"show configuration\" "
-			      "for configuration details.\n"));
-
   if (REPORT_BUGS_TO[0])
     {
       fprintf_filtered (stream,
@@ -1442,9 +1498,9 @@ There is NO WARRANTY, to the extent permitted by law.");
 resources online at:\n    <http://www.gnu.org/software/gdb/documentation/>."));
   fprintf_filtered (stream, "\n\n");
   fprintf_filtered (stream, _("For help, type \"help\".\n"));
-  fprintf_filtered (stream,
-		    _("Type \"apropos word\" to search for commands \
-related to \"word\"."));
+
+  if (interactive)
+    print_tip (stream);
 }
 
 /* Print the details of GDB build-time configuration.  */
-- 
2.17.2


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

* [RFC 4/6] Add get_standard_config_dir function
  2020-04-04 14:54 [RFC 0/6] Some user-friendliness changes Tom Tromey
                   ` (2 preceding siblings ...)
  2020-04-04 14:54 ` [RFC 3/6] Add "tips" file to gdb Tom Tromey
@ 2020-04-04 14:54 ` Tom Tromey
  2020-04-04 14:54 ` [RFC 5/6] Let the user control the startup style Tom Tromey
  2020-04-04 14:54 ` [RFC 6/6] Add "set startup-quietly" Tom Tromey
  5 siblings, 0 replies; 18+ messages in thread
From: Tom Tromey @ 2020-04-04 14:54 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds a new get_standard_config_dir, which returns the name of the
configuration directory.  In XDG, this is ~/.config/gdb/.  Future
patches will make use of this.

gdbsupport/ChangeLog
2020-03-28  Tom Tromey  <tom@tromey.com>

	* pathstuff.h (get_standard_config_dir): Declare.
	* pathstuff.cc (get_standard_config_dir): New function.
---
 gdbsupport/ChangeLog    |  5 +++++
 gdbsupport/pathstuff.cc | 32 ++++++++++++++++++++++++++++++++
 gdbsupport/pathstuff.h  | 14 ++++++++++++++
 3 files changed, 51 insertions(+)

diff --git a/gdbsupport/pathstuff.cc b/gdbsupport/pathstuff.cc
index 1f60fd0c986..9fb5e5cf614 100644
--- a/gdbsupport/pathstuff.cc
+++ b/gdbsupport/pathstuff.cc
@@ -266,6 +266,38 @@ get_standard_temp_dir ()
 #endif
 }
 
+/* See pathstuff.h.  */
+
+std::string
+get_standard_config_dir ()
+{
+#ifdef __APPLE__
+#define HOME_CONFIG_DIR "Library/Preferences"
+#else
+#define HOME_CONFIG_DIR ".config"
+#endif
+
+#ifndef __APPLE__
+  const char *xdg_config_home = getenv ("XDG_CONFIG_HOME");
+  if (xdg_config_home != NULL)
+    {
+      /* Make sure the path is absolute and tilde-expanded.  */
+      gdb::unique_xmalloc_ptr<char> abs (gdb_abspath (xdg_config_home));
+      return string_printf ("%s/gdb", abs.get ());
+    }
+#endif
+
+  const char *home = getenv ("HOME");
+  if (home != NULL)
+    {
+      /* Make sure the path is absolute and tilde-expanded.  */
+      gdb::unique_xmalloc_ptr<char> abs (gdb_abspath (home));
+      return string_printf ("%s/" HOME_CONFIG_DIR "/gdb", abs.get ());
+    }
+
+  return {};
+}
+
 /* See gdbsupport/pathstuff.h.  */
 
 const char *
diff --git a/gdbsupport/pathstuff.h b/gdbsupport/pathstuff.h
index 4bc0d892119..85241bc8c7c 100644
--- a/gdbsupport/pathstuff.h
+++ b/gdbsupport/pathstuff.h
@@ -85,6 +85,20 @@ extern std::string get_standard_cache_dir ();
 
 extern std::string get_standard_temp_dir ();
 
+/* Get the usual user config directory for the current platform.
+
+   On Linux, it follows the XDG Base Directory specification: use
+   $XDG_CONFIG_HOME/gdb if the XDG_CONFIG_HOME environment variable is
+   defined, otherwise $HOME/.config.
+
+   On macOS, it follows the local convention and uses
+   ~/Library/Preferences/gdb.
+
+  The return value is absolute and tilde-expanded.  Return an empty
+  string if neither XDG_CONFIG_HOME (on Linux) or HOME are defined.  */
+
+extern std::string get_standard_config_dir ();
+
 /* Return the file name of the user's shell.  Normally this comes from
    the SHELL environment variable.  */
 
-- 
2.17.2


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

* [RFC 5/6] Let the user control the startup style
  2020-04-04 14:54 [RFC 0/6] Some user-friendliness changes Tom Tromey
                   ` (3 preceding siblings ...)
  2020-04-04 14:54 ` [RFC 4/6] Add get_standard_config_dir function Tom Tromey
@ 2020-04-04 14:54 ` Tom Tromey
  2020-04-04 16:21   ` Eli Zaretskii
  2020-04-04 14:54 ` [RFC 6/6] Add "set startup-quietly" Tom Tromey
  5 siblings, 1 reply; 18+ messages in thread
From: Tom Tromey @ 2020-04-04 14:54 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Some users find the startup text highlighting to be distracting.  This
patch provides a way to change this.  In particular, this adds a new
file to let the user control the styling of the startup text.  When
these styles are changed, they are written to this config file.  The
config file in turn is ready early in startup, so that they can take
effect before the welcome message is printed.

gdb/ChangeLog
2020-03-28  Tom Tromey  <tom@tromey.com>

	* NEWS: Add entry.
	* top.c (startup_style): Remove.
	(print_tip, print_gdb_version): Update.
	* main.c (STARTUP_STYLE_FILE): New define.
	(write_startup_style, read_startup_style): New functions.
	(captured_main_1): Call read_startup_style.
	* cli/cli-style.h (class cli_style_option) <cli_style_option>: Add
	intensity parameter.
	<write>: Declare new method.
	(startup_style): Declare.
	* cli/cli-style.c (startup_style): New global.
	(cli_style_option): Add intensity parameter.
	(cli_style_option::write): New method.
	(_initialize_cli_style): Register new style.

gdb/doc/ChangeLog
2020-03-28  Tom Tromey  <tom@tromey.com>

	* gdb.texinfo (Output Styling): Document "set style startup"
	commands.
---
 gdb/ChangeLog       | 17 ++++++++++++++++
 gdb/NEWS            |  7 +++++++
 gdb/cli/cli-style.c | 49 +++++++++++++++++++++++++++++++++++++++++++--
 gdb/cli/cli-style.h | 11 +++++++++-
 gdb/doc/ChangeLog   |  5 +++++
 gdb/doc/gdb.texinfo | 15 ++++++++++++++
 gdb/main.c          | 43 +++++++++++++++++++++++++++++++++++++++
 gdb/top.c           | 12 ++---------
 8 files changed, 146 insertions(+), 13 deletions(-)

diff --git a/gdb/NEWS b/gdb/NEWS
index b376737e409..bb54c738281 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -60,6 +60,13 @@ show exec-file-mismatch -- Show exec-file-mismatch handling (ask|warn|off).
   whether to load the process executable file; if 'warn', just display
   a warning; if 'off', don't attempt to detect a mismatch.
 
+set style startup foreground COLOR
+set style startup background COLOR
+set style startup intensity VALUE
+  Control the styling of startup text.  This saves the setting into
+  a special configuration file, so that it can be read during startup
+  and applied.
+
 tui new-layout NAME WINDOW WEIGHT [WINDOW WEIGHT]...
   Define a new TUI layout, specifying its name and the windows that
   will be displayed.
diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c
index d2d9928acd5..c9576fa2534 100644
--- a/gdb/cli/cli-style.c
+++ b/gdb/cli/cli-style.c
@@ -22,6 +22,7 @@
 #include "cli/cli-style.h"
 #include "source-cache.h"
 #include "observable.h"
+#include "gdbsupport/pathstuff.h"
 
 /* True if styling is enabled.  */
 
@@ -98,13 +99,19 @@ cli_style_option metadata_style ("metadata", ui_file_style::DIM);
 
 /* See cli-style.h.  */
 
+cli_style_option startup_style ("startup", ui_file_style::MAGENTA,
+				ui_file_style::BOLD);
+
+/* See cli-style.h.  */
+
 cli_style_option::cli_style_option (const char *name,
-				    ui_file_style::basic_color fg)
+				    ui_file_style::basic_color fg,
+				    ui_file_style::intensity intensity)
   : changed (name),
     m_name (name),
     m_foreground (cli_colors[fg - ui_file_style::NONE]),
     m_background (cli_colors[0]),
-    m_intensity (cli_intensities[ui_file_style::NORMAL])
+    m_intensity (cli_intensities[intensity])
 {
 }
 
@@ -257,6 +264,39 @@ cli_style_option::add_setshow_commands (enum command_class theclass,
 			  &m_set_list, &m_show_list, (void *) this);
 }
 
+bool
+cli_style_option::write (const char *filename)
+{
+  std::string config_dir = get_standard_config_dir ();
+
+  if (config_dir.empty ())
+    {
+      warning (_("Couldn't determine a path for the startup style settings."));
+      return false;
+    }
+
+  if (!mkdir_recursive (config_dir.c_str ()))
+    {
+      warning (_("Could not make config directory: %s"),
+	       safe_strerror (errno));
+      return false;
+    }
+
+  std::string fullname = config_dir + "/" + filename;
+  stdio_file outfile;
+
+  if (!outfile.open (fullname.c_str (), FOPEN_WT))
+    perror_with_name (fullname.c_str ());
+  fprintf_unfiltered (&outfile, "set style %s background %s\n",
+		      m_name, m_background);
+  fprintf_unfiltered (&outfile, "set style %s foreground %s\n",
+		      m_name, m_foreground);
+  fprintf_unfiltered (&outfile, "set style %s intensity %s\n",
+		      m_name, m_intensity);
+
+  return true;
+}
+
 static cmd_list_element *style_set_list;
 static cmd_list_element *style_show_list;
 
@@ -422,4 +462,9 @@ TUI active border display styling.\n\
 Configure TUI active border colors\n\
 The \"tui-active-border\" style is used when GDB displays the border of a\n\
 TUI window that does have the focus."), true);
+
+  STYLE_ADD_SETSHOW_COMMANDS (startup_style,
+			      _("\
+Startup display styling.\n\
+Configure colors used in some startup text."), false);
 }
diff --git a/gdb/cli/cli-style.h b/gdb/cli/cli-style.h
index 04009aa3615..28c3c8b2dde 100644
--- a/gdb/cli/cli-style.h
+++ b/gdb/cli/cli-style.h
@@ -30,7 +30,8 @@ class cli_style_option
 public:
 
   /* Construct a CLI style option with a foreground color.  */
-  cli_style_option (const char *name, ui_file_style::basic_color fg);
+  cli_style_option (const char *name, ui_file_style::basic_color fg,
+		    ui_file_style::intensity = ui_file_style::NORMAL);
 
   /* Construct a CLI style option with an intensity.  */
   cli_style_option (const char *name, ui_file_style::intensity i);
@@ -58,6 +59,11 @@ class cli_style_option
   /* Same as SET_LIST but for the show command list.  */
   struct cmd_list_element *show_list () { return m_show_list; };
 
+  /* Write this style to FILENAME, relative to the config directory.
+     (This is only needed for the startup style.)  Returns true on
+     success and false on failure.  */
+  bool write (const char *filename);
+
   /* This style can be observed for any changes.  */
   gdb::observers::observable<> changed;
 
@@ -126,6 +132,9 @@ extern cli_style_option tui_border_style;
 /* The border style of a TUI window that does have the focus.  */
 extern cli_style_option tui_active_border_style;
 
+/* The style to use for (some) startup text.  */
+extern cli_style_option startup_style;
+
 /* True if source styling is enabled.  */
 extern bool source_styling;
 
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 385c832f222..f860b238ff8 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -25573,6 +25573,21 @@ Control the styling of addresses.  These are managed with the
 @code{set style address} family of commands.  By default, this style's
 foreground color is blue.
 
+@item startup
+Control the styling of some text that is printed at startup.  These
+are managed with the @code{set style startup} family of commands.  By
+default, this style's foreground color is magenta and it has bold
+intensity.  Changing these settings will cause them to automatically
+be saved in a special configuration file, which is read by
+@value{GDBN} early in its startup.
+
+The default value for this directory depends on the host platform.  On
+most systems, the index is cached in the @file{gdb} subdirectory of
+the directory pointed to by the @env{XDG_CONFIG_HOME} environment
+variable, if it is defined, else in the @file{.config/gdb} subdirectory
+of your home directory.  However, on some systems, the default may
+differ according to local convention.
+
 @item title
 Control the styling of titles.  These are managed with the
 @code{set style title} family of commands.  By default, this style's
diff --git a/gdb/main.c b/gdb/main.c
index a03ed8117ab..51e422ae496 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -437,6 +437,45 @@ validate_readnow_readnever ()
     }
 }
 
+/* File name for startup style.  */
+
+#define STARTUP_STYLE_FILE "startup-style"
+
+/* Write the startup style to a file.  */
+
+static void
+write_startup_style ()
+{
+  static bool still_ok = true;
+
+  if (still_ok)
+    still_ok = startup_style.write (STARTUP_STYLE_FILE);
+}
+
+/* Read the startup style and arrange to track it.  */
+
+static void
+read_startup_style ()
+{
+  std::string config_dir = get_standard_config_dir ();
+
+  if (!config_dir.empty ())
+    {
+      std::string filename = config_dir + "/" + STARTUP_STYLE_FILE;
+
+      try
+	{
+	  source_script (filename.c_str (), 1);
+	}
+      catch (const gdb_exception &)
+	{
+	  /* Ignore errors.  */
+	}
+
+      startup_style.changed.attach (write_startup_style);
+    }
+}
+
 /* Type of this option.  */
 enum cmdarg_kind
 {
@@ -877,6 +916,10 @@ captured_main_1 (struct captured_main_args *context)
   /* Initialize all files.  */
   gdb_init (gdb_program_name);
 
+  /* Set the startup style.  */
+  if (!inhibit_gdbinit && !inhibit_home_gdbinit)
+    read_startup_style ();
+
   /* Now that gdb_init has created the initial inferior, we're in
      position to set args for that inferior.  */
   if (set_args)
diff --git a/gdb/top.c b/gdb/top.c
index 7af820b0bb9..46781a5c0ef 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -130,14 +130,6 @@ current_ui_current_uiout_ptr ()
 
 int inhibit_gdbinit = 0;
 
-/* The style used for informational messages at startup.  */
-static ui_file_style startup_style =
-{
-  ui_file_style::MAGENTA,
-  ui_file_style::NONE,
-  ui_file_style::BOLD
-};
-
 /* Flag for whether we want to confirm potentially dangerous
    operations.  Default is yes.  */
 
@@ -1434,7 +1426,7 @@ print_tip (struct ui_file *stream)
   std::uniform_int_distribution<> distr (0, strings.size () - 1);
   int index = distr (mt);
   /* Note that the string will include a newline.  */
-  fprintf_styled (stream, startup_style, "\n%.*s",
+  fprintf_styled (stream, startup_style.style (), "\n%.*s",
 		  (int) strings[index].size (),
 		  strings[index].data ());
 }
@@ -1449,7 +1441,7 @@ print_gdb_version (struct ui_file *stream, bool interactive)
 
   ui_file_style style;
   if (interactive)
-    style = startup_style;
+    style = startup_style.style ();
   fprintf_styled (stream, style, "GNU gdb %s%s\n", PKGVERSION, version);
 
   /* Second line is a copyright notice.  */
-- 
2.17.2


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

* [RFC 6/6] Add "set startup-quietly"
  2020-04-04 14:54 [RFC 0/6] Some user-friendliness changes Tom Tromey
                   ` (4 preceding siblings ...)
  2020-04-04 14:54 ` [RFC 5/6] Let the user control the startup style Tom Tromey
@ 2020-04-04 14:54 ` Tom Tromey
  2020-04-04 16:24   ` Eli Zaretskii
  5 siblings, 1 reply; 18+ messages in thread
From: Tom Tromey @ 2020-04-04 14:54 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds a new command to change gdb to behave as though "-quiet"
were always given.  This is done by creating a special sentinel file
in the config directory.

2020-03-28  Tom Tromey  <tom@tromey.com>

	* tips: Add a tip.
	* NEWS: Add entry.
	* top.h (check_quiet_mode): Declare.
	* top.c (startup_quiet, store_startup_quiet): New globals.
	(QUIET_FILE): New define.
	(check_quiet_mode, set_startup_quiet, show_startup_quiet): New
	functions.
	(init_main): Register new command.
	* main.c (captured_main_1): Call check_quiet_mode.

gdb/doc/ChangeLog
2020-03-28  Tom Tromey  <tom@tromey.com>

	* gdb.texinfo (Mode Options): Mention "set startup-quietly".
---
 gdb/ChangeLog       | 12 +++++++
 gdb/NEWS            |  7 ++++
 gdb/doc/ChangeLog   |  4 +++
 gdb/doc/gdb.texinfo | 13 +++++++
 gdb/main.c          |  7 +++-
 gdb/tips            |  3 ++
 gdb/top.c           | 82 +++++++++++++++++++++++++++++++++++++++++++++
 gdb/top.h           |  5 +++
 8 files changed, 132 insertions(+), 1 deletion(-)

diff --git a/gdb/NEWS b/gdb/NEWS
index bb54c738281..a07052be0b1 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -67,6 +67,13 @@ set style startup intensity VALUE
   a special configuration file, so that it can be read during startup
   and applied.
 
+set startup-quietly on|off
+show startup-quietly
+  When enabled, this causes GDB to act as if "-silent" were always
+  passed on the command line.  This saves the setting into a special
+  configuration file, so that it can be read during startup and
+  applied.
+
 tui new-layout NAME WINDOW WEIGHT [WINDOW WEIGHT]...
   Define a new TUI layout, specifying its name and the windows that
   will be displayed.
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index f860b238ff8..6025f39468b 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -1124,6 +1124,19 @@ in your home directory.
 ``Quiet''.  Do not print the introductory and copyright messages.  These
 messages are also suppressed in batch mode.
 
+This can also be enabled using @code{set startup-quietly on}.  The
+default is @code{off}.  Use @code{show startup-quietly} to see the
+current setting.  Unlike most settings in @value{GDBN}, this one is
+automatically saved by creating a special in a configuration
+directory.
+
+The default value for this directory depends on the host platform.  On
+most systems, the index is cached in the @file{gdb} subdirectory of
+the directory pointed to by the @env{XDG_CONFIG_HOME} environment
+variable, if it is defined, else in the @file{.config/gdb} subdirectory
+of your home directory.  However, on some systems, the default may
+differ according to local convention.
+
 @item -batch
 @cindex @code{--batch}
 Run in batch mode.  Exit with status @code{0} after processing all the
diff --git a/gdb/main.c b/gdb/main.c
index 51e422ae496..85d2802cff0 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -918,7 +918,12 @@ captured_main_1 (struct captured_main_args *context)
 
   /* Set the startup style.  */
   if (!inhibit_gdbinit && !inhibit_home_gdbinit)
-    read_startup_style ();
+    {
+      read_startup_style ();
+
+      if (!quiet)
+	quiet = check_quiet_mode ();
+    }
 
   /* Now that gdb_init has created the initial inferior, we're in
      position to set args for that inferior.  */
diff --git a/gdb/tips b/gdb/tips
index 75957fb853d..f0b194d88a4 100644
--- a/gdb/tips
+++ b/gdb/tips
@@ -7,3 +7,6 @@ You can use "help news" to see what has changed in GDB.
 Type "apropos word" to search for commands related to "word".
 %
 Type "show configuration" for configuration details.
+%
+You can use "set startup-quietly on" to have GDB always start up
+silently.
diff --git a/gdb/top.c b/gdb/top.c
index 46781a5c0ef..13d139d238b 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -2198,6 +2198,80 @@ set_history_filename (const char *args,
     }
 }
 
+/* Whether we're in quiet startup mode.  */
+
+static bool startup_quiet;
+
+/* Whether we should try writing changes to startup-quietly to the
+   filesystem.  */
+
+static bool store_startup_quiet;
+
+/* File name for quiet startup.  */
+#define QUIET_FILE "startup-quietly"
+
+/* See top.h.  */
+
+bool
+check_quiet_mode ()
+{
+  std::string config_dir = get_standard_config_dir ();
+
+  if (!config_dir.empty ())
+    {
+      std::string filename = config_dir + "/" + QUIET_FILE;
+      int ignore;
+
+      store_startup_quiet = true;
+      startup_quiet = is_regular_file (filename.c_str (), &ignore);
+      return startup_quiet;
+    }
+
+  return false;
+}
+
+/* Set the startup-quiet flag.  */
+
+static void
+set_startup_quiet (const char *args, int from_tty, struct cmd_list_element *c)
+{
+  if (!store_startup_quiet)
+    return;
+
+  std::string config_dir = get_standard_config_dir ();
+
+  if (!config_dir.empty ())
+    {
+      std::string filename = config_dir + "/" + QUIET_FILE;
+
+      if (startup_quiet)
+	{
+	  if (!mkdir_recursive (config_dir.c_str ()))
+	    {
+	      warning (_("Could not make config directory: %s"),
+		       safe_strerror (errno));
+	      return;
+	    }
+
+	  /* Just touching the file is enough.  */
+	  gdb_file_up f = gdb_fopen_cloexec (filename.c_str (), FOPEN_WT);
+	  if (f == nullptr)
+	    warning (_("Could not make 'quiet' config file: %s"),
+		     safe_strerror (errno));
+	}
+      else
+	unlink (filename.c_str ());
+    }
+}
+
+static void
+show_startup_quiet (struct ui_file *file, int from_tty,
+	      struct cmd_list_element *c, const char *value)
+{
+  fprintf_filtered (file, _("Whether to start up quietly is %s.\n"),
+		    value);
+}
+
 static void
 init_gdb_version_vars (void)
 {
@@ -2352,6 +2426,14 @@ input settings."),
                         show_interactive_mode,
                         &setlist, &showlist);
 
+  add_setshow_boolean_cmd ("startup-quietly", class_support,
+			   &startup_quiet, _("\
+Set whether GDB should start up quietly."), _("\
+Show whether GDB should start up quietly."), NULL,
+			   set_startup_quiet,
+			   show_startup_quiet,
+			   &setlist, &showlist);
+
   c = add_cmd ("new-ui", class_support, new_ui_command, _("\
 Create a new UI.\n\
 Usage: new-ui INTERPRETER TTY\n\
diff --git a/gdb/top.h b/gdb/top.h
index 638e02cad4c..ba09d723908 100644
--- a/gdb/top.h
+++ b/gdb/top.h
@@ -298,4 +298,9 @@ extern char *handle_line_of_input (struct buffer *cmd_line_buffer,
 				   const char *rl, int repeat,
 				   const char *annotation_suffix);
 
+/* Call at startup to see if the user has requested that gdb start up
+   quietly.  */
+
+extern bool check_quiet_mode ();
+
 #endif
-- 
2.17.2


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

* Re: [RFC 2/6] Add "help news"
  2020-04-04 14:54 ` [RFC 2/6] Add "help news" Tom Tromey
@ 2020-04-04 16:15   ` Eli Zaretskii
  2020-04-04 16:41     ` Eli Zaretskii
  2020-06-21 20:23     ` Tom Tromey
  0 siblings, 2 replies; 18+ messages in thread
From: Eli Zaretskii @ 2020-04-04 16:15 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

> From: Tom Tromey <tom@tromey.com>
> Date: Sat,  4 Apr 2020 08:54:18 -0600
> Cc: Tom Tromey <tom@tromey.com>
> 
> This adds a "help news" subcommand, which simply dumps the NEWS file.
> The NEWS file is now installed.

Thanks.

> diff --git a/gdb/NEWS b/gdb/NEWS
> index 6657f6fadce..9d85e630e8c 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -44,6 +44,9 @@
>  
>  * New commands
>  
> +help news
> +  Show this NEWS file.

This part is OK.

> +static void
> +help_news (struct ui_file *stream)
> +{
> +  std::string news_name = std::string (gdb_datadir) + SLASH_STRING + "NEWS";
> +  gdb_file_up news_file = gdb_fopen_cloexec (news_name.c_str (), "r");

Is datadir the best place for NEWS?  Why not somewhere below docdir?

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

* Re: [RFC 3/6] Add "tips" file to gdb
  2020-04-04 14:54 ` [RFC 3/6] Add "tips" file to gdb Tom Tromey
@ 2020-04-04 16:16   ` Eli Zaretskii
  2020-04-04 16:42     ` Eli Zaretskii
  0 siblings, 1 reply; 18+ messages in thread
From: Eli Zaretskii @ 2020-04-04 16:16 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

> From: Tom Tromey <tom@tromey.com>
> Date: Sat,  4 Apr 2020 08:54:19 -0600
> Cc: Tom Tromey <tom@tromey.com>
> 
> diff --git a/gdb/NEWS b/gdb/NEWS
> index 9d85e630e8c..b376737e409 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -3,6 +3,8 @@
>  
>  *** Changes since GDB 9
>  
> +* GDB will now display a helpful tip when starting up.
> +

This part is OK.

Thanks.

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

* Re: [RFC 5/6] Let the user control the startup style
  2020-04-04 14:54 ` [RFC 5/6] Let the user control the startup style Tom Tromey
@ 2020-04-04 16:21   ` Eli Zaretskii
  2020-06-21 20:27     ` Tom Tromey
  0 siblings, 1 reply; 18+ messages in thread
From: Eli Zaretskii @ 2020-04-04 16:21 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

> From: Tom Tromey <tom@tromey.com>
> Date: Sat,  4 Apr 2020 08:54:21 -0600
> Cc: Tom Tromey <tom@tromey.com>
> 
> index b376737e409..bb54c738281 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -60,6 +60,13 @@ show exec-file-mismatch -- Show exec-file-mismatch handling (ask|warn|off).
>    whether to load the process executable file; if 'warn', just display
>    a warning; if 'off', don't attempt to detect a mismatch.
>  
> +set style startup foreground COLOR
> +set style startup background COLOR
> +set style startup intensity VALUE
> +  Control the styling of startup text.  This saves the setting into
> +  a special configuration file, so that it can be read during startup
> +  and applied.

This part is OK.

> diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
> index 385c832f222..f860b238ff8 100644
> --- a/gdb/doc/gdb.texinfo
> +++ b/gdb/doc/gdb.texinfo
> @@ -25573,6 +25573,21 @@ Control the styling of addresses.  These are managed with the
>  @code{set style address} family of commands.  By default, this style's
>  foreground color is blue.
>  
> +@item startup
> +Control the styling of some text that is printed at startup.  These
> +are managed with the @code{set style startup} family of commands.  By
> +default, this style's foreground color is magenta and it has bold
> +intensity.  Changing these settings will cause them to automatically
> +be saved in a special configuration file, which is read by
> +@value{GDBN} early in its startup.
> +
> +The default value for this directory depends on the host platform.  On
> +most systems, the index is cached in the @file{gdb} subdirectory of
> +the directory pointed to by the @env{XDG_CONFIG_HOME} environment
> +variable, if it is defined, else in the @file{.config/gdb} subdirectory
> +of your home directory.  However, on some systems, the default may
> +differ according to local convention.

This is also OK.  But I wonder: we have ~/.gdbinit and ~/config/gdb
(or, if XDG_CONFIG_HOME is set, some utterly different directory) for
the new file?  Sounds confusing.  Also, I'm told that XDG_CONFIG_HOME
is ephemeral: it is set anew each session, so the user could end up
having his/her setting saved in a file he/she will not see the next
time they log in.  Can that happen?

Thanks.

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

* Re: [RFC 6/6] Add "set startup-quietly"
  2020-04-04 14:54 ` [RFC 6/6] Add "set startup-quietly" Tom Tromey
@ 2020-04-04 16:24   ` Eli Zaretskii
  0 siblings, 0 replies; 18+ messages in thread
From: Eli Zaretskii @ 2020-04-04 16:24 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

> From: Tom Tromey <tom@tromey.com>
> Date: Sat,  4 Apr 2020 08:54:22 -0600
> Cc: Tom Tromey <tom@tromey.com>
> 
> This adds a new command to change gdb to behave as though "-quiet"
> were always given.  This is done by creating a special sentinel file
> in the config directory.
> 
> 2020-03-28  Tom Tromey  <tom@tromey.com>
> 
> 	* tips: Add a tip.
> 	* NEWS: Add entry.
> 	* top.h (check_quiet_mode): Declare.
> 	* top.c (startup_quiet, store_startup_quiet): New globals.
> 	(QUIET_FILE): New define.
> 	(check_quiet_mode, set_startup_quiet, show_startup_quiet): New
> 	functions.
> 	(init_main): Register new command.
> 	* main.c (captured_main_1): Call check_quiet_mode.
> 
> gdb/doc/ChangeLog
> 2020-03-28  Tom Tromey  <tom@tromey.com>
> 
> 	* gdb.texinfo (Mode Options): Mention "set startup-quietly".

Thanks, the documentation parts are OK.

> +automatically saved by creating a special in a configuration
                                           ^^^
"file" seems to be missing there.

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

* Re: [RFC 2/6] Add "help news"
  2020-04-04 16:15   ` Eli Zaretskii
@ 2020-04-04 16:41     ` Eli Zaretskii
  2020-06-21 20:23     ` Tom Tromey
  1 sibling, 0 replies; 18+ messages in thread
From: Eli Zaretskii @ 2020-04-04 16:41 UTC (permalink / raw)
  To: tom; +Cc: gdb-patches

> Date: Sat, 04 Apr 2020 19:15:21 +0300
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: gdb-patches@sourceware.org
> 
> > From: Tom Tromey <tom@tromey.com>
> > Date: Sat,  4 Apr 2020 08:54:18 -0600
> > Cc: Tom Tromey <tom@tromey.com>
> > 
> > This adds a "help news" subcommand, which simply dumps the NEWS file.
> > The NEWS file is now installed.
> 
> Thanks.

Btw, I don't see this subcommand described in the manual.  Should it
be?

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

* Re: [RFC 3/6] Add "tips" file to gdb
  2020-04-04 16:16   ` Eli Zaretskii
@ 2020-04-04 16:42     ` Eli Zaretskii
  2020-06-21 20:23       ` Tom Tromey
  0 siblings, 1 reply; 18+ messages in thread
From: Eli Zaretskii @ 2020-04-04 16:42 UTC (permalink / raw)
  To: tom; +Cc: gdb-patches

> Date: Sat, 04 Apr 2020 19:16:51 +0300
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: gdb-patches@sourceware.org
> 
> > From: Tom Tromey <tom@tromey.com>
> > Date: Sat,  4 Apr 2020 08:54:19 -0600
> > Cc: Tom Tromey <tom@tromey.com>
> > 
> > diff --git a/gdb/NEWS b/gdb/NEWS
> > index 9d85e630e8c..b376737e409 100644
> > --- a/gdb/NEWS
> > +++ b/gdb/NEWS
> > @@ -3,6 +3,8 @@
> >  
> >  *** Changes since GDB 9
> >  
> > +* GDB will now display a helpful tip when starting up.
> > +

Should this be in the manual?

Also, I think we want the structure and format of the 'tips' file
documented in the manual, as I presume we'd add tips to it with time

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

* Re: [RFC 2/6] Add "help news"
  2020-04-04 16:15   ` Eli Zaretskii
  2020-04-04 16:41     ` Eli Zaretskii
@ 2020-06-21 20:23     ` Tom Tromey
  2020-06-22  2:23       ` Eli Zaretskii
  1 sibling, 1 reply; 18+ messages in thread
From: Tom Tromey @ 2020-06-21 20:23 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Tom Tromey, gdb-patches

>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:

>> +static void
>> +help_news (struct ui_file *stream)
>> +{
>> +  std::string news_name = std::string (gdb_datadir) + SLASH_STRING + "NEWS";
>> +  gdb_file_up news_file = gdb_fopen_cloexec (news_name.c_str (), "r");

Eli> Is datadir the best place for NEWS?  Why not somewhere below docdir?

I looked into this.  docdir does seem more correct according to the GNU
coding standards, but on the other hand, making it work properly seems
like a lot of work (adding a new setting and command line option) for
what amounts to a minor conformance thing.

So unless someone feels very strongly about it, I'm inclined to leave it
as is.

>> Btw, I don't see this subcommand described in the manual.  Should it
>> be?

Probably but where would be the best place to put it?

Tom

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

* Re: [RFC 3/6] Add "tips" file to gdb
  2020-04-04 16:42     ` Eli Zaretskii
@ 2020-06-21 20:23       ` Tom Tromey
  2020-06-22  2:24         ` Eli Zaretskii
  0 siblings, 1 reply; 18+ messages in thread
From: Tom Tromey @ 2020-06-21 20:23 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: tom, gdb-patches

>> > +* GDB will now display a helpful tip when starting up.
>> > +

Eli> Should this be in the manual?

Yeah, where would you suggest.

Eli> Also, I think we want the structure and format of the 'tips' file
Eli> documented in the manual, as I presume we'd add tips to it with time

It is documented in the file itself.

Tom

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

* Re: [RFC 5/6] Let the user control the startup style
  2020-04-04 16:21   ` Eli Zaretskii
@ 2020-06-21 20:27     ` Tom Tromey
  0 siblings, 0 replies; 18+ messages in thread
From: Tom Tromey @ 2020-06-21 20:27 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Tom Tromey, gdb-patches

>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:

>> +The default value for this directory depends on the host platform.  On
>> +most systems, the index is cached in the @file{gdb} subdirectory of
>> +the directory pointed to by the @env{XDG_CONFIG_HOME} environment
>> +variable, if it is defined, else in the @file{.config/gdb} subdirectory
>> +of your home directory.  However, on some systems, the default may
>> +differ according to local convention.

Eli> This is also OK.  But I wonder: we have ~/.gdbinit and ~/config/gdb
Eli> (or, if XDG_CONFIG_HOME is set, some utterly different directory) for
Eli> the new file?  Sounds confusing.  Also, I'm told that XDG_CONFIG_HOME
Eli> is ephemeral: it is set anew each session, so the user could end up
Eli> having his/her setting saved in a file he/she will not see the next
Eli> time they log in.  Can that happen?

I think XDG_CONFIG_HOME is intended for user config files written by the
app and as such isn't reset each session.  See

https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

The XDG "cache" and "runtime" directories can be reset, on the other
hand.

Tom

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

* Re: [RFC 2/6] Add "help news"
  2020-06-21 20:23     ` Tom Tromey
@ 2020-06-22  2:23       ` Eli Zaretskii
  0 siblings, 0 replies; 18+ messages in thread
From: Eli Zaretskii @ 2020-06-22  2:23 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

> From: Tom Tromey <tom@tromey.com>
> Cc: Tom Tromey <tom@tromey.com>,  gdb-patches@sourceware.org
> Date: Sun, 21 Jun 2020 14:23:13 -0600
> 
> >> Btw, I don't see this subcommand described in the manual.  Should it
> >> be?
> 
> Probably but where would be the best place to put it?

In "Help", I'd say.

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

* Re: [RFC 3/6] Add "tips" file to gdb
  2020-06-21 20:23       ` Tom Tromey
@ 2020-06-22  2:24         ` Eli Zaretskii
  0 siblings, 0 replies; 18+ messages in thread
From: Eli Zaretskii @ 2020-06-22  2:24 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

> From: Tom Tromey <tom@tromey.com>
> Cc: tom@tromey.com,  gdb-patches@sourceware.org
> Date: Sun, 21 Jun 2020 14:23:48 -0600
> 
> >> > +* GDB will now display a helpful tip when starting up.
> >> > +
> 
> Eli> Should this be in the manual?
> 
> Yeah, where would you suggest.

The node "Help" sounds like a good place.

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

end of thread, other threads:[~2020-06-22  2:24 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-04 14:54 [RFC 0/6] Some user-friendliness changes Tom Tromey
2020-04-04 14:54 ` [RFC 1/6] Introduce read_entire_file Tom Tromey
2020-04-04 14:54 ` [RFC 2/6] Add "help news" Tom Tromey
2020-04-04 16:15   ` Eli Zaretskii
2020-04-04 16:41     ` Eli Zaretskii
2020-06-21 20:23     ` Tom Tromey
2020-06-22  2:23       ` Eli Zaretskii
2020-04-04 14:54 ` [RFC 3/6] Add "tips" file to gdb Tom Tromey
2020-04-04 16:16   ` Eli Zaretskii
2020-04-04 16:42     ` Eli Zaretskii
2020-06-21 20:23       ` Tom Tromey
2020-06-22  2:24         ` Eli Zaretskii
2020-04-04 14:54 ` [RFC 4/6] Add get_standard_config_dir function Tom Tromey
2020-04-04 14:54 ` [RFC 5/6] Let the user control the startup style Tom Tromey
2020-04-04 16:21   ` Eli Zaretskii
2020-06-21 20:27     ` Tom Tromey
2020-04-04 14:54 ` [RFC 6/6] Add "set startup-quietly" Tom Tromey
2020-04-04 16:24   ` Eli Zaretskii

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