From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8902 invoked by alias); 29 Jul 2013 06:12:33 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 8877 invoked by uid 89); 29 Jul 2013 06:12:32 -0000 X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL,BAYES_50,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RDNS_NONE autolearn=no version=3.3.1 Received: from Unknown (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 29 Jul 2013 06:12:31 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1V3ggw-0001jX-Uv from Muhammad_Bilal@mentor.com ; Sun, 28 Jul 2013 23:12:22 -0700 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Sun, 28 Jul 2013 23:12:22 -0700 Received: from [137.202.157.37] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server (TLS) id 14.2.247.3; Mon, 29 Jul 2013 07:12:20 +0100 Message-ID: <51F607C7.7020108@codesourcery.com> Date: Mon, 29 Jul 2013 06:12:00 -0000 From: Muhammad Bilal User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Pedro Alves CC: "gdb-patches@sourceware.org" Subject: Re: [PATCH PR gdb/15715] 'set history filename' to by immediately converted to absolute path. References: <97B73E257CC18646B0B5D3DD77DCBDD15DA063@EU-MBX-02.mgc.mentorg.com> <97B73E257CC18646B0B5D3DD77DCBDD15DA08C@EU-MBX-02.mgc.mentorg.com> <51F27050.6060409@redhat.com> In-Reply-To: <51F27050.6060409@redhat.com> Content-Type: multipart/mixed; boundary="------------060809020403080108090501" X-Virus-Found: No X-SW-Source: 2013-07/txt/msg00674.txt.bz2 --------------060809020403080108090501 Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Content-length: 7135 Hi Pedro, Thanks for review and help to make the ChangeLog entry. please find attached updated patch. ./ChangeLog 2013-07-29 Muhammad Bilal PR gdb/15715 * top.c: include "filenames.h" (set_history_filename):New function. (init_main): Install it as set hook of the "set history filename" command. ./testsuite/ChangeLog 2013-07-29 Muhammad Bilal PR gdb/15715 * gdb.base/setshow.exp: Test that relative paths passed to 'set history filename' are converted to absolute paths. On 07/26/2013 05:49 PM, Pedro Alves wrote: > On 07/12/2013 12:05 PM, Bilal, Muhammad wrote: > >> Please find attached updated patch with new PR in gdb bugzilla. >> A workaround for this patch has been discussed here, > You meant background, right? > >> http://sourceware.org/ml/gdb-patches/2013-05/msg00852.html >> gdb/ChangeLog >> 2013-07-13 Muhammad Bilal >> >> PR gdb/15715 >> * top.c (set_history_filename): New function. >> Converted history filename path to its absolute path. > This is still incomplete. You'll need to mention the inclusion > of filenames.h, and when I said "you must have done something > with the function", I meant that something must be calling the > function. So: > > * top.c: Include "filenames.h". > (set_history_filename): New function. > (init_main): Install it as set hook of the "set history filename" > command. > >> gdb/testsuite/ChangeLog >> 2013-07-13 Muhammad Bilal >> >> PR gdb/15715 >> * gdb.base/setshow.exp: Test 'set history filename' command >> to check its absolute path. > Write instead: > > gdb/testsuite/ChangeLog > 2013-07-13 Muhammad Bilal > > PR gdb/15715 > * gdb.base/setshow.exp: Test that relative paths passed to > 'set history filename' are converted to absolute paths. > >> static void >> +set_history_filename (char *args, int from_tty, struct cmd_list_element *c) >> +{ >> + /*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. */ > There should be a space after '/*' (and then realign the following lines). > >> static void >> +set_history_filename (char *args, int from_tty, struct cmd_list_element *c) >> +{ >> + /*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. */ >> + if (!IS_ABSOLUTE_PATH (history_filename)) >> + history_filename = reconcat (history_filename ,current_directory, "/", history_filename, >> + (char *) NULL); > Wrong formatting. Line too long, spaces around ','. Please check > the GNU coding standards. > > >> Index: gdb/top.c >> =================================================================== >> RCS file: /cvs/src/src/gdb/top.c,v >> retrieving revision 1.238 >> diff -u -p -r1.238 top.c >> --- gdb/top.c 6 Jul 2013 07:34:48 -0000 1.238 >> +++ gdb/top.c 12 Jul 2013 10:43:04 -0000 >> @@ -48,6 +48,7 @@ >> #include "interps.h" >> #include "observer.h" >> #include "maint.h" >> +#include "filenames.h" >> >> /* readline include files. */ >> #include "readline/readline.h" >> @@ -1698,6 +1699,17 @@ set_gdb_datadir (char *args, int from_tt >> } >> >> static void >> +set_history_filename (char *args, int from_tty, struct cmd_list_element *c) >> +{ >> + /*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. */ >> + if (!IS_ABSOLUTE_PATH (history_filename)) >> + history_filename = reconcat (history_filename ,current_directory, "/", history_filename, >> + (char *) NULL); >> +} >> + >> +static void >> init_main (void) >> { >> /* Initialize the prompt to a simple "(gdb) " prompt or to whatever >> @@ -1773,7 +1785,7 @@ variable \"HISTSIZE\", or to 256 if this >> Set the filename in which to record the command history"), _("\ >> Show the filename in which to record the command history"), _("\ >> (the list of previous commands of which a record is kept)."), >> - NULL, >> + set_history_filename, >> show_history_filename, >> &sethistlist, &showhistlist); >> Index: gdb/testsuite/gdb.base/setshow.exp >> =================================================================== >> RCS file: /cvs/src/src/gdb/testsuite/gdb.base/setshow.exp,v >> retrieving revision 1.33 >> diff -u -p -r1.33 setshow.exp >> --- gdb/testsuite/gdb.base/setshow.exp 27 Jun 2013 18:58:28 -0000 1.33 >> +++ gdb/testsuite/gdb.base/setshow.exp 12 Jul 2013 10:44:36 -0000 >> @@ -165,11 +165,36 @@ gdb_test_no_output "set height unlimited >> gdb_test_no_output "set history expansion on" "set history expansion on" >> #test show history expansion on >> gdb_test "show history expansion on" "History expansion on command input is on.*" "show history expansion" >> +#get home directory path >> +set HOME "" >> +gdb_test_multiple "show environment HOME" "show home directory" { >> + -re "\nHOME = (.*).\n.*" { >> + set HOME $expect_out(1,string) >> + pass "show home directory" >> + } >> +} > I'd suggest: > > set HOME "" > set test "show environment HOME" > gdb_test_multiple $test $test { > -re "\nHOME = (.*).\n.*" { > set HOME $expect_out(1,string) > pass $test > } > } > >> +#test set history filename ~/foobar.baz >> +gdb_test_no_output "set history filename ~/foobar.baz" \ >> + "set history filename ~/foobar.baz" >> +#test show history filename ~/foobar.baz >> +gdb_test "show history filename" \ >> + "The filename in which to record the command history is \"$HOME/foobar.baz\"..*" \ >> + "show history filename $HOME/foobar.baz" > The expansion of $HOME is being placed in the test message > (what goes to gdb.sum after PASS/FAIL). That means that the > test message depends on who/where you run it, which is bad > for comparing test results. > >> +#get current working directory >> +set PWD "" >> +gdb_test_multiple "pwd" "show working directory" { >> + -re "\nWorking directory (.*)..\n.*" { >> + set PWD $expect_out(1,string) >> + pass "show working directory" >> + } >> +} >> #test set history filename foobar.baz >> gdb_test_no_output "set history filename foobar.baz" \ >> - "set history filename foobar.baz" >> + "set history filename foobar.baz" >> #test show history filename foobar.baz >> -gdb_test "show history filename" "The filename in which to record the command history is \"foobar.baz\"..*" "show history filename (foobar.baz)" >> +gdb_test "show history filename" \ >> + "The filename in which to record the command history is \"$PWD/foobar.baz\"..*" \ >> + "show history filename $PWD\foobar.baz" > Likewise. Use forward slash, not backslash. > >> #test set history save on >> gdb_test_no_output "set history save on" "set history save on" >> #test show history save on >> Thanks, -Bilal --------------060809020403080108090501 Content-Type: text/x-patch; name="pr15715.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr15715.diff" Content-length: 3482 Index: gdb/top.c =================================================================== RCS file: /cvs/src/src/gdb/top.c,v retrieving revision 1.238 diff -u -p -r1.238 top.c --- gdb/top.c 6 Jul 2013 07:34:48 -0000 1.238 +++ gdb/top.c 29 Jul 2013 05:55:40 -0000 @@ -48,6 +48,7 @@ #include "interps.h" #include "observer.h" #include "maint.h" +#include "filenames.h" /* readline include files. */ #include "readline/readline.h" @@ -1698,6 +1699,17 @@ set_gdb_datadir (char *args, int from_tt } static void +set_history_filename (char *args, int from_tty, struct cmd_list_element *c) +{ + /*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. */ + if (!IS_ABSOLUTE_PATH (history_filename)) + history_filename = reconcat (history_filename, current_directory, "/", + history_filename, (char *) NULL); +} + +static void init_main (void) { /* Initialize the prompt to a simple "(gdb) " prompt or to whatever @@ -1773,7 +1785,7 @@ variable \"HISTSIZE\", or to 256 if this Set the filename in which to record the command history"), _("\ Show the filename in which to record the command history"), _("\ (the list of previous commands of which a record is kept)."), - NULL, + set_history_filename, show_history_filename, &sethistlist, &showhistlist); Index: gdb/testsuite/gdb.base/setshow.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.base/setshow.exp,v retrieving revision 1.33 diff -u -p -r1.33 setshow.exp --- gdb/testsuite/gdb.base/setshow.exp 27 Jun 2013 18:58:28 -0000 1.33 +++ gdb/testsuite/gdb.base/setshow.exp 29 Jul 2013 05:57:23 -0000 @@ -165,11 +165,38 @@ gdb_test_no_output "set height unlimited gdb_test_no_output "set history expansion on" "set history expansion on" #test show history expansion on gdb_test "show history expansion on" "History expansion on command input is on.*" "show history expansion" +#get home directory path +set HOME "" +set test "show environment HOME" +gdb_test_multiple $test $test { + -re "\nHOME = (.*).\n.*" { + set HOME $expect_out(1,string) + pass $test + } +} +#test set history filename ~/foobar.baz +gdb_test_no_output "set history filename ~/foobar.baz" \ + "set history filename ~/foobar.baz" +#test show history filename ~/foobar.baz +gdb_test "show history filename" \ + "The filename in which to record the command history is \"$HOME/foobar.baz\"..*" \ + "show history filename (~/foobar.baz)" +#get current working directory +set PWD "" +set test "show working directory" +gdb_test_multiple "pwd" $test { + -re "\nWorking directory (.*)..\n.*" { + set PWD $expect_out(1,string) + pass $test + } +} #test set history filename foobar.baz gdb_test_no_output "set history filename foobar.baz" \ - "set history filename foobar.baz" + "set history filename foobar.baz" #test show history filename foobar.baz -gdb_test "show history filename" "The filename in which to record the command history is \"foobar.baz\"..*" "show history filename (foobar.baz)" +gdb_test "show history filename" \ + "The filename in which to record the command history is \"$PWD/foobar.baz\"..*" \ + "show history filename (current_directory/foobar.baz)" #test set history save on gdb_test_no_output "set history save on" "set history save on" #test show history save on --------------060809020403080108090501--