This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 2/5] [PR gdb/15224] Fix incorrectly touched history file even if no commands get, added to it
- From: Muhammad Bilal <mbilal at codesourcery dot com>
- To: "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Cc: Pedro Alves <palves at redhat dot com>, <jan dot kratochvil at redhat dot com>
- Date: Thu, 8 Aug 2013 10:18:58 +0500
- Subject: [PATCH 2/5] [PR gdb/15224] Fix incorrectly touched history file even if no commands get, added to it
Currently incorrectly history file is touched even if no commands get,
added to it.
below is use case for it (enabled history save on).
$ ls -als ~/gdb_history
0 -rw-rw-r-- 1 mbilal mbilal 0 Aug 8 07:14 /home/mbilal/gdb_history
$ date
Thu Aug 8 07:15:53 PKT 2013
$ ./gdb -ex "set history filename ~/gdb_history" < /dev/null
GNU gdb (GDB) 7.6.50.20130807-cvs
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) quit
$ ls -als ~/gdb_history
0 -rw-rw-r-- 1 mbilal mbilal 0 Aug 8 07:15 /home/mbilal/gdb_history
History save should be perform on interactive debugging.
so, using the input_from_terminal_p fixed this problem.
2013-08-08 Muhammad Bilal <mbilal@codesourcery.com>
PR gdb/15224
* top.c (quit_force): Fixed incorrectly touching history file
to use input_from_terminal_p.
gdb/top.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/gdb/top.c b/gdb/top.c
index 33a78da..7bc9b47 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1433,7 +1433,8 @@ quit_force (char *args, int from_tty)
/* Save the history information if it is appropriate to do so. */
DO_TRY
{
- if (write_history_p && history_filename)
+ if (write_history_p && history_filename
+ && input_from_terminal_p ())
write_history (history_filename);
}
DO_PRINT_EX;
After applying above patch, result would be.
$ ls -als ~/gdb_history
0 -rw-rw-r-- 1 mbilal mbilal 0 Aug 8 07:15 /home/mbilal/gdb_history
$ date
Thu Aug 8 07:19:41 PKT 2013
$ ./gdb -ex "set history filename ~/gdb_history" < /dev/null
GNU gdb (GDB) 7.6.50.20130807-cvs
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) quit
$ ls -als ~/gdb_history
0 -rw-rw-r-- 1 mbilal mbilal 0 Aug 8 07:15 /home/mbilal/gdb_history
Thanks,
-Bilal