From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 69248 invoked by alias); 9 Nov 2016 00:26:50 -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 69239 invoked by uid 89); 9 Nov 2016 00:26:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.8 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=vary X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 09 Nov 2016 00:26:49 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 90209C0586A4 for ; Wed, 9 Nov 2016 00:19:36 +0000 (UTC) Received: from cascais.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uA90JVUl022260 for ; Tue, 8 Nov 2016 19:19:36 -0500 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH v2 4/5] Test user-defined gdb commands and arguments stack Date: Wed, 09 Nov 2016 00:26:00 -0000 Message-Id: <1478650771-24430-5-git-send-email-palves@redhat.com> In-Reply-To: <1478650771-24430-1-git-send-email-palves@redhat.com> References: <1478650771-24430-1-git-send-email-palves@redhat.com> X-SW-Source: 2016-11/txt/msg00197.txt.bz2 We're missing a test that makes sure that arguments to user-defined commands are handled correctly when a user-defined command calls another user-defined command / recurses. The following patch changes that code, so add such a test first so we can be confident won't be breaking this use case. gdb/testsuite/ChangeLog: yyyy-mm-dd Pedro Alves * gdb.base/commands.exp (user_defined_command_args_stack_test): New procedure. (top level): Call it. --- gdb/testsuite/gdb.base/commands.exp | 59 +++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/gdb/testsuite/gdb.base/commands.exp b/gdb/testsuite/gdb.base/commands.exp index 0ac2267..a8f777f 100644 --- a/gdb/testsuite/gdb.base/commands.exp +++ b/gdb/testsuite/gdb.base/commands.exp @@ -370,6 +370,64 @@ proc_with_prefix user_defined_command_args_eval {} { gdb_test "command_args_eval 1 2 3" "argc = 3, 1 2 3" "execute command" } +# Test that the $argc/$argN variables are pushed on/popped from the +# args stack correctly when a user-defined command calls another +# user-defined command (or in this case, recurses). + +proc_with_prefix user_defined_command_args_stack_test {} { + global gdb_prompt + + gdb_test_multiple "define args_stack_command" \ + "define args_stack_command" { + -re "End with" { + pass "define" + } + } + + # Make a command that refers to $argc/$argN before and after + # recursing. Also, vary the number of arguments passed to each + # recursion point. + gdb_test \ + [multi_line \ + {printf "before, argc = %d,", $argc} \ + {set $i = 0} \ + {while $i < $argc} \ + { eval "printf \" %%d\", $arg%d", $i} \ + { set $i = $i + 1} \ + {end} \ + {printf "\n"} \ + {} \ + {} \ + {if $argc == 3} \ + { args_stack_command 21 22} \ + {end} \ + {if $argc == 2} \ + { args_stack_command 11} \ + {end} \ + {} \ + {} \ + {printf "after, argc = %d,", $argc} \ + {set $i = 0} \ + {while $i < $argc} \ + { eval "printf \" %%d\", $arg%d", $i} \ + { set $i = $i + 1} \ + {end} \ + {printf "\n"} \ + {end}] \ + "" \ + "enter commands" + + set expected \ + [multi_line \ + "before, argc = 3, 31 32 33" \ + "before, argc = 2, 21 22" \ + "before, argc = 1, 11" \ + "after, argc = 1, 11" \ + "after, argc = 2, 21 22" \ + "after, argc = 3, 31 32 33"] + gdb_test "args_stack_command 31 32 33" $expected "execute command" +} + proc_with_prefix watchpoint_command_test {} { global gdb_prompt @@ -891,6 +949,7 @@ infrun_breakpoint_command_test breakpoint_command_test user_defined_command_test user_defined_command_args_eval +user_defined_command_args_stack_test watchpoint_command_test test_command_prompt_position deprecated_command_test -- 2.5.5