public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 2/5] [PR gdb/15224]  Fix incorrectly touched history file even if no commands get,  added to it
@ 2013-08-08  5:19 Muhammad Bilal
  2013-08-13 18:09 ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Muhammad Bilal @ 2013-08-08  5:19 UTC (permalink / raw)
  To: gdb-patches; +Cc: Pedro Alves, jan.kratochvil


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











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

* Re: [PATCH 2/5] [PR gdb/15224]  Fix incorrectly touched history file even if no commands get,  added to it
  2013-08-08  5:19 [PATCH 2/5] [PR gdb/15224] Fix incorrectly touched history file even if no commands get, added to it Muhammad Bilal
@ 2013-08-13 18:09 ` Pedro Alves
  2013-08-15  8:20   ` Muhammad Bilal
  0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2013-08-13 18:09 UTC (permalink / raw)
  To: Muhammad Bilal; +Cc: gdb-patches, jan.kratochvil

On 08/08/2013 06:18 AM, Muhammad Bilal wrote:

> 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

(Just like PR cli/15715, all these bugs should each their own
different number, and then 15224 should be made dependent of
them.  This patch is not about saving history by default, although
it is a necessary dependency for doing that.)

>      * top.c (quit_force): Fixed incorrectly touching history file
>      to use input_from_terminal_p.

"Fixed incorrectly" is a "why" and ambiguous (and sometimes, wrong).

Say:

     * top.c (quit_force): Skip writing history file
     if input is not from terminal.

Otherwise OK.

Thanks,
-- 
Pedro Alves

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

* Re: [PATCH 2/5] [PR gdb/15224]  Fix incorrectly touched history file even if no commands get,  added to it
  2013-08-13 18:09 ` Pedro Alves
@ 2013-08-15  8:20   ` Muhammad Bilal
  0 siblings, 0 replies; 3+ messages in thread
From: Muhammad Bilal @ 2013-08-15  8:20 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches, jan.kratochvil

On 08/13/2013 11:09 PM, Pedro Alves wrote:
> On 08/08/2013 06:18 AM, Muhammad Bilal wrote:
>
>> 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
> (Just like PR cli/15715, all these bugs should each their own
> different number, and then 15224 should be made dependent of
> them.  This patch is not about saving history by default, although
> it is a necessary dependency for doing that.)
>
>>       * top.c (quit_force): Fixed incorrectly touching history file
>>       to use input_from_terminal_p.
> "Fixed incorrectly" is a "why" and ambiguous (and sometimes, wrong).
>
> Say:
>
>       * top.c (quit_force): Skip writing history file
>       if input is not from terminal.
>
> Otherwise OK.
>
> Thanks,
Committed with new PR http://sourceware.org/bugzilla/show_bug.cgi?id=15841


Thanks,
-Bilal

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

end of thread, other threads:[~2013-08-15  8:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-08  5:19 [PATCH 2/5] [PR gdb/15224] Fix incorrectly touched history file even if no commands get, added to it Muhammad Bilal
2013-08-13 18:09 ` Pedro Alves
2013-08-15  8:20   ` Muhammad Bilal

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