From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13986 invoked by alias); 10 Oct 2014 01:03:13 -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 13970 invoked by uid 89); 10 Oct 2014 01:03:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 10 Oct 2014 01:03:11 +0000 Received: from svr-orw-fem-02x.mgc.mentorg.com ([147.34.96.206] helo=SVR-ORW-FEM-02.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1XcObr-000124-Dn from Yao_Qi@mentor.com ; Thu, 09 Oct 2014 18:03:07 -0700 Received: from GreenOnly (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.3.181.6; Thu, 9 Oct 2014 18:03:06 -0700 From: Yao Qi To: Jan Kratochvil CC: , Miroslav Franc Subject: Re: [patch] save breakpoints does not save signal catchpoints correctly References: <20141003203219.GA30562@host2.jankratochvil.net> <87r3yhs6sr.fsf@codesourcery.com> <20141009175452.GA26010@host2.jankratochvil.net> Date: Fri, 10 Oct 2014 01:03:00 -0000 In-Reply-To: <20141009175452.GA26010@host2.jankratochvil.net> (Jan Kratochvil's message of "Thu, 9 Oct 2014 19:54:52 +0200") Message-ID: <87y4soivu2.fsf@codesourcery.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2014-10/txt/msg00229.txt.bz2 Jan Kratochvil writes: > Sorry but be more specific how you wanted to simplify the code. > Any idea I have is 10x more complicated. > > With the list I have Googled > What is the right way of comparing two lists in TCL? > https://stackoverflow.com/questions/5195153/what-is-the-right-way-of-com= paring-two-lists-in-tcl > > and those solutions seem too complicated to me. I didn't mean to compare two lists. We only have one list here, and we can check each element in it, for example, set fd [open $filename] - set contents [read -nonewline $fd] + set file_data [read $fd] + set data [split $file_data "\n"] + set contents [lindex $data 0] + close $fd contents is the first line of the file, and the pattern matching code can be unchanged. After that, we can check the second line of the file, which should be "break main". The test becomes, set fd [open $filename] set file_data [read $fd] set data [split $file_data "\n"] close $fd if {$arg =3D=3D ""} { set pattern "catch signal" } else { set pattern "catch signal $arg" } # Check the first line. gdb_assert {[string match $pattern [lindex $data 0]]} \ "1st line of save breakpoints for '$arg'" # Check the second line. gdb_assert {[string match "break main" [lindex $data 1]]} \ "2nd line of save breakpoints for '$arg'" This will be more clear and easier to extend when there are more lines in the file. --=20 Yao (=E9=BD=90=E5=B0=A7)