diff options
author | Tom de Vries <tdevries@suse.de> | 2024-02-20 15:49:33 +0100 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2024-02-20 15:49:33 +0100 |
commit | 1b2c120daf9e2d935453f9051bbeafbac7f9f14d (patch) | |
tree | c9d6fed6cdf7719117accb2cf1d42b614d2a5d26 | |
parent | 9012a09f4f33fa38596c85f5c7fb442548f5e55c (diff) | |
download | gdb-1b2c120daf9e2d935453f9051bbeafbac7f9f14d.zip gdb-1b2c120daf9e2d935453f9051bbeafbac7f9f14d.tar.gz gdb-1b2c120daf9e2d935453f9051bbeafbac7f9f14d.tar.bz2 |
[gdb] Don't init history in batch mode
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.
Approved-By: Andrew Burgess <aburgess@redhat.com>
-rw-r--r-- | gdb/main.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -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 |