From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9501 invoked by alias); 7 Apr 2006 13:33:27 -0000 Received: (qmail 9492 invoked by uid 22791); 7 Apr 2006 13:33:26 -0000 X-Spam-Check-By: sourceware.org Received: from fra-del-02.spheriq.net (HELO fra-del-02.spheriq.net) (195.46.51.98) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 07 Apr 2006 13:33:23 +0000 Received: from fra-out-01.spheriq.net (fra-out-01.spheriq.net [195.46.51.129]) by fra-del-02.spheriq.net with ESMTP id k37DWuFX006284 for ; Fri, 7 Apr 2006 13:32:56 GMT Received: from fra-cus-01.spheriq.net (fra-cus-01.spheriq.net [195.46.51.37]) by fra-out-01.spheriq.net with ESMTP id k37DWeUT005911 for ; Fri, 7 Apr 2006 13:32:53 GMT Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by fra-cus-01.spheriq.net with ESMTP id k37DWc0T013725 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=OK); Fri, 7 Apr 2006 13:32:39 GMT Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 084DEDA45; Fri, 7 Apr 2006 13:32:33 +0000 (GMT) Received: from mail1.bri.st.com (mail1.bri.st.com [164.129.8.218]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 80AD747851; Fri, 7 Apr 2006 13:32:33 +0000 (GMT) Received: from [164.129.15.13] (terrorhawk.bri.st.com [164.129.15.13]) by mail1.bri.st.com (MOS 3.5.8-GR) with ESMTP id CHK83784 (AUTH stubbsa); Fri, 7 Apr 2006 14:32:32 +0100 (BST) Message-ID: <4436695D.4000508@st.com> Date: Fri, 07 Apr 2006 13:33:00 -0000 From: Andrew STUBBS User-Agent: Thunderbird 1.5 (Windows/20051201) MIME-Version: 1.0 To: Michael Snyder , GDB Patches Subject: Re: [PATCH] allow nested sourced commands References: <442BD6F1.8070804@st.com> <44324959.4@st.com> <44324B1E.3070409@st.com> <4432CFC1.4090308@redhat.com> <443395C0.6040709@st.com> <443410E1.50206@redhat.com> <4434E361.40501@st.com> <20060406134012.GA25478@nevyn.them.org> <443649B8.6030909@st.com> <20060407131808.GA20353@nevyn.them.org> In-Reply-To: <20060407131808.GA20353@nevyn.them.org> Content-Type: multipart/mixed; boundary="------------000805090904080906010804" X-O-Spoofed: Not Scanned X-O-General-Status: No X-O-Spam1-Status: Not Scanned X-O-Spam2-Status: Not Scanned X-O-URL-Status: Not Scanned X-O-Virus1-Status: No X-O-Virus2-Status: Not Scanned X-O-Virus3-Status: No X-O-Virus4-Status: No X-O-Virus5-Status: Not Scanned X-O-Image-Status: Not Scanned X-O-Attach-Status: Not Scanned X-SpheriQ-Ver: 4.2.01 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-04/txt/msg00089.txt.bz2 This is a multi-part message in MIME format. --------------000805090904080906010804 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 183 Daniel Jacobowitz wrote: > This is fine, except you lost the explanatory comment. OK with that > readded. Thanks! Quite right, silly mistake. I've committed the attached. Andrew --------------000805090904080906010804 Content-Type: text/plain; name="reentrant-commands.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="reentrant-commands.patch" Content-length: 2562 2006-04-07 Andrew Stubbs gdb/ * cli/cli-script.c (struct user_args): Add command field. (arg_cleanup): Free command string. (setup_user_args): Copy the command line before relying on it. gdb/testsuite/ * gdb.base/commands.exp (recursive_source_test): New test. Index: src/gdb/cli/cli-script.c =================================================================== --- src.orig/gdb/cli/cli-script.c 2006-04-07 12:01:55.000000000 +0100 +++ src/gdb/cli/cli-script.c 2006-04-07 14:25:58.000000000 +0100 @@ -54,6 +54,9 @@ static int control_level; struct user_args { struct user_args *next; + /* It is necessary to store a malloced copy of the command line to + ensure that the arguments are not overwritten before they are used. */ + char *command; struct { char *arg; @@ -483,6 +486,7 @@ arg_cleanup (void *ignore) _("arg_cleanup called with no user args.\n")); user_args = user_args->next; + xfree (oargs->command); xfree (oargs); } @@ -507,6 +511,8 @@ setup_user_args (char *p) if (p == NULL) return old_chain; + user_args->command = p = xstrdup (p); + while (*p) { char *start_arg; Index: src/gdb/testsuite/gdb.base/commands.exp =================================================================== --- src.orig/gdb/testsuite/gdb.base/commands.exp 2006-04-07 12:11:50.000000000 +0100 +++ src/gdb/testsuite/gdb.base/commands.exp 2006-04-07 12:10:02.000000000 +0100 @@ -583,7 +583,40 @@ proc stray_arg0_test { } { "\\\$\[0-9\]* = 1" \ "stray_arg0_test #4" } - + +# Test that GDB can handle arguments when sourcing files recursively. +# If the arguments are overwritten with ####### then the test has failed. +proc recursive_source_test {} { + set fd [open "file1" w] + puts $fd \ +{source file2 +abcdef qwerty} + close $fd + + set fd [open "file2" w] + puts $fd \ +{define abcdef + echo 1: <<<$arg0>>>\n + source file3 + echo 2: <<<$arg0>>>\n +end} + close $fd + + set fd [open "file3" w] + puts $fd \ +"echo in file3\\n +#################################################################" + close $fd + + gdb_test "source file1" \ + "1: <<>>\[\r\n]+in file3\[\r\n]+2: <<>>" \ + "recursive source test" + + file delete file1 + file delete file2 + file delete file3 +} + gdbvar_simple_if_test gdbvar_simple_while_test gdbvar_complex_if_while_test @@ -600,3 +633,4 @@ deprecated_command_test bp_deleted_in_command_test temporary_breakpoint_commands stray_arg0_test +recursive_source_test --------------000805090904080906010804--