public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH] [gdb] Don't init history in batch mode
Date: Sun, 18 Feb 2024 14:31:53 +0100	[thread overview]
Message-ID: <20240218133153.2032-1-tdevries@suse.de> (raw)

I noticed in captured_main_1 that init_history is called just before bailing
out if batch_flag is true.

The history is used only in an interactive session, so there's no need to
initialize it in batch mode.

Fix this by moving init_history to after the batch mode check.

Tested on x86_64-linux.
---
 gdb/main.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/gdb/main.c b/gdb/main.c
index 2dc76756e98..17826fae95e 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -1303,10 +1303,6 @@ captured_main_1 (struct captured_main_args *context)
   /* Process '-x' and '-ex' options.  */
   execute_cmdargs (&cmdarg_vec, CMDARG_FILE, CMDARG_COMMAND, &ret);
 
-  /* Read in the old history after all the command files have been
-     read.  */
-  init_history ();
-
   if (batch_flag)
     {
       int error_status = EXIT_FAILURE;
@@ -1315,6 +1311,14 @@ captured_main_1 (struct captured_main_args *context)
       /* We have hit the end of the batch file.  */
       quit_force (exit_arg, 0);
     }
+
+  /* We are starting an interactive session.  */
+
+  /* Read in the history.  This is after all the command files have been read,
+     so that the user can change the history file via a .gdbinit file.  This
+     is also after the batch_flag check, because we don't need the history in
+     batch mode.  */
+  init_history ();
 }
 
 static void

base-commit: 989aa9b8e8e340ba65f386cbfd239009a3aba68f
-- 
2.35.3


             reply	other threads:[~2024-02-18 13:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-18 13:31 Tom de Vries [this message]
2024-02-20 12:09 ` Andrew Burgess

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240218133153.2032-1-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).