From patchwork Wed Oct 19 19:07:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 16675 Received: (qmail 34320 invoked by alias); 19 Oct 2016 19:07:40 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 34308 invoked by uid 89); 19 Oct 2016 19:07:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=TCL, margin, gdb_test, maint X-HELO: mailapp01.imgtec.com Received: from mailapp01.imgtec.com (HELO mailapp01.imgtec.com) (195.59.15.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 19 Oct 2016 19:07:38 +0000 Received: from HHMAIL01.hh.imgtec.org (unknown [10.100.10.19]) by Forcepoint Email with ESMTPS id EE88347ACBFD8 for ; Wed, 19 Oct 2016 20:07:31 +0100 (IST) Received: from [10.20.78.157] (10.20.78.157) by HHMAIL01.hh.imgtec.org (10.100.10.21) with Microsoft SMTP Server id 14.3.294.0; Wed, 19 Oct 2016 20:07:34 +0100 Date: Wed, 19 Oct 2016 20:07:25 +0100 From: "Maciej W. Rozycki" To: Subject: [PATCH] testsuite: Avoid a buffer overrun in `gdb.base/maint.exp' Message-ID: User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Similarly to commit ff604a674771 ("gdb/testsuite: Bump up `match_max'") fix a buffer overrun in `gdb.base/maint.exp': PASS: gdb.base/maint.exp: maint w/o args ERROR: internal buffer is full. UNRESOLVED: gdb.base/maint.exp: maint info line-table w/o a file name observed in `mips-mti-linux-gnu' n64 ABI testing. According to `string length $expect_out(buffer)' the count of characters actually retrieved in that testing is in the range of 133000, over twice as many as set for the limit with the latter change, and dependent on the amount of debug information retrieved from the system C library. Therefore rather than bumping the global limit up again just change it temporarily with a suitable margin for the purpose of this single test case only. gdb/testsuite/ * gdb.base/maint.exp: Override the `match_max' setting for the duration of the "maint info line-table w/o a file name" test. --- Hi, I've looked into adjusting the size of the buffer dynamically as the `full_buffer' condition triggers and in principle it appears doable with the tools TCL and `expect' provide and no need to bend backwards to get it done, however it seems to require more than just a trivial intervention in `gdb_test_multiple', so I have decided to leave it for the next time the issue triggers. Maybe it won't. Needless to say, this change has passed `mips-mti-linux-gnu' regression testing. OK to apply? Maciej gdb-test-maint-match-max.diff Index: binutils/gdb/testsuite/gdb.base/maint.exp =================================================================== --- binutils.orig/gdb/testsuite/gdb.base/maint.exp 2016-10-19 05:55:44.965881047 +0100 +++ binutils/gdb/testsuite/gdb.base/maint.exp 2016-10-19 06:40:39.310292228 +0100 @@ -474,9 +474,15 @@ gdb_test "maint" \ "\"maintenance\" must be followed by the name of a maintenance command\\.\r\nList.*unambiguous\\..*" \ "maint w/o args" +# This can produce lots of output, so bump the buffer space a bit +# temporarily, from our default set in `default_gdb_init'. +set old_max [match_max -i $gdb_spawn_id] +match_max -i $gdb_spawn_id 2097152 gdb_test "maint info line-table" \ "symtab: \[^\n\r\]+${srcfile}.*\\(\\(struct symtab \\*\\) $hex\\)\r\nlinetable: \\(\\(struct linetable \\*\\) $hex\\):\r\nINDEX.*LINE.*ADDRESS.*" \ "maint info line-table w/o a file name" +match_max -i $gdb_spawn_id $old_max +unset old_max gdb_test "maint info line-table ${srcfile}" \ "symtab: \[^\n\r\]+${srcfile}.*INDEX.*LINE.*ADDRESS.*" \