From: Pedro Alves <palves@redhat.com>
To: mbilal <mbilal@codesourcery.com>
Cc: gdb-patches@sourceware.org, jan.kratochvil@redhat.com
Subject: Re: [PATCH 1/7] PR gdb/15224 "set history filename" to by immediately converted to absolute path
Date: Wed, 08 May 2013 15:46:00 -0000 [thread overview]
Message-ID: <518A736C.8070009@redhat.com> (raw)
In-Reply-To: <5188F70A.1030908@codesourcery.com>
On 05/07/2013 01:43 PM, mbilal wrote:
> please find updated patch .
>
> I made new 'set_history_filename' function to solve this problem
Please aim at posting self contained descriptions of patches, or
at least linking to them.
I happen to still recall the original issue, but I bet there are others
who don't. It's also very useful for future archaeology to find
the rationale for the patch close to the patch. Here's an example,
synthesized from <http://sourceware.org/ml/gdb-patches/2013-04/msg00066.html>:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GDB resolves a relative .gdb_history path early on at init time, meaning,
the default history file written is the same that was
read, while "set history filename .gdb_history" resolves to
different history files at read and at write times if the user
changes directory in between, as seen in these examples:
$ unset GDBHISTFILE; gdb -ex "set history filename .gdb_history"
(gdb) show history filename
The filename in which to record the command history is "/tmp/.gdb_history".
(gdb) q
vs
$ cd /tmp
$ mkdir a
$ gdb -ex "set history filename .gdbhist"
(gdb) show history filename
The filename in which to record the command history is ".gdbhist".
(gdb) cd a
Working directory /tmp/a.
(gdb) q
$ cat a/.gdbhist
show history filename
cd a
q
$ ls .gdbhist a/.gdbhist
ls: cannot access .gdbhist: No such file or directory
a/.gdbhist
$
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Bonus points if that ends up in the commit log.
IIRC, a previous version had a test; what happened to it?
Did it cover the issue this patch proposes fixing?
> diff --git a/gdb/top.c b/gdb/top.c
> index 480b67e..20aecc9 100644
> --- a/gdb/top.c
> +++ b/gdb/top.c
> @@ -48,6 +48,7 @@
> #include "interps.h"
> #include "observer.h"
> #include "maint.h"
> +#include "filenames.h"
>
> /* readline include files. */
> #include "readline/readline.h"
> @@ -1607,6 +1608,14 @@ set_verbose (char *args, int from_tty, struct cmd_list_element *c)
> }
> }
>
> +static void
> +set_history_filename (char *args, int from_tty, struct cmd_list_element *c)
> +{
> + if (!IS_ABSOLUTE_PATH (*(char **) c->var))
> + *(char **) c->var = concat (current_directory, "/", *(char **) c->var,
> + (char *)NULL);
> +}
Missing space before NULL. That's a lot of casting. We can just refer
to history_filename directly. It'd be very good to have a comment here with the
rationale for this -- there's one in init_history we can reuse. So:
if (!IS_ABSOLUTE_PATH (history_filename))
{
/* We include the current directory so that if the user changes
directories the file written will be the same as the one
that was read. */
history_filename = concat (current_directory, "/", history_filename,
(char *) NULL);
}
Also, a ChangeLog entry is missing.
Thanks,
--
Pedro Alves
next prev parent reply other threads:[~2013-05-08 15:46 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-06 9:39 [PATCH 0/7] PR gdb/15224 should "set history save on" by default mbilal
2013-05-06 9:40 ` [PATCH 1/7] " mbilal
2013-05-06 9:42 ` [PATCH 2/7] " mbilal
2013-05-06 9:43 ` [PATCH 3/7] " mbilal
[not found] ` <51877BC6.6080007@codesourcery.com>
2013-05-06 9:47 ` [PATCH 4/7] " mbilal
2013-05-07 9:40 ` Abid, Hafiz
2013-05-08 17:14 ` Pedro Alves
2013-05-06 9:48 ` [PATCH 5/7] " mbilal
2013-05-08 8:24 ` mbilal
2013-05-15 11:08 ` [PATCH 5/7] PR gdb/15224 , Change the default set history filename to ~/.gdb_history mbilal
2013-05-15 11:31 ` Eli Zaretskii
2013-05-15 12:07 ` mbilal
2013-05-15 13:27 ` Eli Zaretskii
2013-05-22 17:24 ` Pedro Alves
2013-05-22 17:49 ` Eli Zaretskii
2013-05-22 18:08 ` Pedro Alves
2013-05-22 19:18 ` Eli Zaretskii
2013-05-22 19:39 ` Pedro Alves
2013-08-01 12:43 ` Muhammad Bilal
2013-08-01 15:41 ` Tom Tromey
2013-08-01 22:17 ` Doug Evans
2013-05-22 12:02 ` mbilal
2013-05-08 17:05 ` [PATCH 5/7] PR gdb/15224 should "set history save on" by default Pedro Alves
2013-05-06 9:49 ` [PATCH 6/7] " mbilal
2013-05-06 9:51 ` [PATCH 7/7] " mbilal
2013-05-07 10:17 ` Abid, Hafiz
2013-05-08 17:08 ` Pedro Alves
2013-05-08 8:25 ` mbilal
2013-05-08 16:51 ` Eli Zaretskii
2013-05-08 17:18 ` Pedro Alves
2013-05-08 8:23 ` [PATCH 4/7] " mbilal
2013-05-09 11:12 ` mbilal
2013-05-09 12:05 ` Pedro Alves
[not found] ` <51936853.7050106@codesourcery.com>
[not found] ` <51936944.80108@codesourcery.com>
2013-05-15 10:56 ` [PATCH 4/7] Disable history saving for testsuit mbilal
2013-05-22 12:02 ` mbilal
2013-05-22 17:27 ` Pedro Alves
2013-05-08 8:23 ` [PATCH 3/7] PR gdb/15224 should "set history save on" by default mbilal
2013-05-08 16:24 ` Pedro Alves
2013-05-06 11:26 ` [PATCH 1/7] " Pedro Alves
[not found] ` <5188AA15.5010904@codesourcery.com>
2013-05-07 7:19 ` [PATCH 1/7] PR gdb/15224 "set history filename" to by immediately converted to absolute path mbilal
2013-05-07 8:39 ` Pedro Alves
[not found] ` <5188AC27.1050407@codesourcery.com>
2013-05-07 7:26 ` [PATCH 2/7] PR gdb/15224 fix for Unify interactivity tests to use input_from_terminal_p mbilal
2013-05-08 8:22 ` mbilal
2013-05-08 16:21 ` Pedro Alves
2013-05-09 11:08 ` mbilal
2013-05-09 11:32 ` Pedro Alves
2013-05-07 12:44 ` [PATCH 1/7] PR gdb/15224 "set history filename" to by immediately converted to absolute path mbilal
2013-05-08 8:22 ` mbilal
[not found] ` <519366E2.90105@codesourcery.com>
2013-05-15 10:46 ` mbilal
2013-05-22 17:51 ` Pedro Alves
2013-05-22 12:04 ` mbilal
2013-05-08 15:46 ` Pedro Alves [this message]
2013-05-08 17:25 ` Pedro Alves
2013-05-07 10:01 ` [PATCH 0/7] PR gdb/15224 should "set history save on" by default Abid, Hafiz
2013-08-06 16:35 ` Jan Kratochvil
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=518A736C.8070009@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.com \
--cc=mbilal@codesourcery.com \
/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