From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 371963858D33 for ; Tue, 8 Aug 2023 14:46:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 371963858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691505963; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iAy+qFQtaRNbCv43iA4T78GrMXYIkMb9ZL7gfhKR/cY=; b=ZW9O1Rv4pEOSN/nXM0v/3y+4GPD0XLLpRT5QULnAdqCHU+WePFl0N0r0ZhowbMcHIZ+tqX 42w4y+6ovYtBWDIg8D0opsrM442rRPAgwmTgk6ARxiQafNQgiO30wnliJlNIACq2Dbrq+6 7y4AN8KJYPW8532RN/IjvHIprz0RY0A= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-404-yjWUikqlPSudE9D63ni4Hg-1; Tue, 08 Aug 2023 10:46:02 -0400 X-MC-Unique: yjWUikqlPSudE9D63ni4Hg-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-3fe11910e46so28093935e9.0 for ; Tue, 08 Aug 2023 07:46:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691505961; x=1692110761; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iAy+qFQtaRNbCv43iA4T78GrMXYIkMb9ZL7gfhKR/cY=; b=GDtdVjgITcUzufFM8N7mifgaAjgOAIFcxj1lHGlY1Z2igt+uFkptb4c2ZzJXxFPzR0 j8a5HeHLM7/2u6nb+l72UMPueAwyZHxPeW/u4SbvlY/Y1FHLmIgaRbNKVQxeZPu5B9ov TSYbFIN887+R7WIKY1TemLSBS9a+nHhLoUTMoySOYf0FqKT3mQO0M0IhRjQPNo8aXvlz 54+lTn5lEGhSqwv4T/24irYqS1t6WPWK1hjC6crW/Yc/OfMhrPgCTFkBrwVvogPGjz1C UsEuhdCoCITvoSapN/yCPgKwdxIAKERFPEMiejhy7ZPRH9UXHwo//DIjb7Tvjj+Pi57o hNnA== X-Gm-Message-State: AOJu0YzSRZIGmECAd2uoYiWvWfk0Cl+J50q81IuAa5oZcfqTR9Og+2ws 7VnstwEtM7cLgbyyvojousrb6eomUpSqGM1AOOFDbHVvOfUKjVsV/j9dTEG8xkldT4Zp8sNMowH 4WA7tFs7BZMAJlPbY6aSdb1foQhMBnF6itwIFZh0bK2la8haiNVA6zm1j2dVdY0XrrIoSzuv6Su FajLmArw== X-Received: by 2002:a7b:c3d3:0:b0:3fe:1c10:8d04 with SMTP id t19-20020a7bc3d3000000b003fe1c108d04mr25721wmj.19.1691505961307; Tue, 08 Aug 2023 07:46:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGarXJcPxs7/6ywQ90oKtSnIAbSxi0y4svePivah1mCq0H9abg/Z/HZwT3w+BZ5/wttsiqP3Q== X-Received: by 2002:a7b:c3d3:0:b0:3fe:1c10:8d04 with SMTP id t19-20020a7bc3d3000000b003fe1c108d04mr25706wmj.19.1691505960984; Tue, 08 Aug 2023 07:46:00 -0700 (PDT) Received: from localhost ([31.111.84.232]) by smtp.gmail.com with ESMTPSA id z10-20020a7bc7ca000000b003fbc9b9699dsm13919603wmk.45.2023.08.08.07.45.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Aug 2023 07:45:59 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: pedro@palves.net, Andrew Burgess Subject: [PATCH 1/2] gdb/testsuite: add mi_info_frame helper proc (and use it) Date: Tue, 8 Aug 2023 15:45:51 +0100 Message-Id: <58ef6e8eb1a094927b600c1649f6ebc281a93272.1691505844.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: New helper proc mi_info_frame which takes care of running the MI -stack-info-frame command and matching its output. Like the breakpoint helper procs, this new proc takes a name/value argument list and uses this to build the expected result regexp. This means that we can now write something like: mi_info_frame "test name here" \ -level 0 -func name -line 123 Instead of the current equivalent: mi_gdb_test "235-stack-info-frame" \ "235\\^done,frame=\{level=\"0\",addr=\"$hex\",func=\"name\",file=\".*\",fullname=\".*\",line=\"123\",arch=\".*\"\}" \ "test name here" There's also a helper proc mi_make_info_frame_regexp which is responsible for building the 'frame={...}' part of the pattern. I've update the two existing tests that use -stack-info-frame and expect the command to succeed. There is another test that runs -stack-info-frame and expects the command to fail -- the helper proc doesn't help with this case, so that test is not changed. --- gdb/testsuite/gdb.mi/mi-cmd-user-context.exp | 12 ++--- gdb/testsuite/gdb.mi/mi-stack.exp | 7 +-- gdb/testsuite/lib/mi-support.exp | 52 ++++++++++++++++++++ 3 files changed, 62 insertions(+), 9 deletions(-) diff --git a/gdb/testsuite/gdb.mi/mi-cmd-user-context.exp b/gdb/testsuite/gdb.mi/mi-cmd-user-context.exp index 6abdb94addd..b6877b6e0cd 100644 --- a/gdb/testsuite/gdb.mi/mi-cmd-user-context.exp +++ b/gdb/testsuite/gdb.mi/mi-cmd-user-context.exp @@ -84,9 +84,9 @@ mi_gdb_test "frame" \ # Ask about a different frame in the current thread, the current frame # should not change. -mi_gdb_test "-stack-info-frame --thread 2 --frame 1" \ - "\\^done,frame=\{level=\"1\".*" \ - "-stack-info-frame 1" +mi_info_frame "-stack-info-frame 1" \ + -thread 2 -frame 1 \ + -level 1 mi_gdb_test "thread" \ ".*Current thread is 2.*" \ @@ -99,9 +99,9 @@ mi_gdb_test "frame" \ # Ask about a different frame in a different thread. After this the # current thread and frame should not have changed. -mi_gdb_test "-stack-info-frame --thread 3 --frame 1" \ - "\\^done,frame=\{level=\"1\".*" \ - "-stack-info-frame 2" +mi_info_frame "-stack-info-frame 2" \ + -thread 3 -frame 1 \ + -level 1 mi_gdb_test "thread" \ ".*Current thread is 2.*" \ diff --git a/gdb/testsuite/gdb.mi/mi-stack.exp b/gdb/testsuite/gdb.mi/mi-stack.exp index 777a425894f..592a3cfaba4 100644 --- a/gdb/testsuite/gdb.mi/mi-stack.exp +++ b/gdb/testsuite/gdb.mi/mi-stack.exp @@ -65,9 +65,10 @@ proc test_stack_frame_listing {} { "234\\^error,msg=\"-stack-list-frames: Usage.*FRAME_LOW FRAME_HIGH.*\"" \ "stack frame listing wrong" - mi_gdb_test "235-stack-info-frame" \ - "235\\^done,frame=\{level=\"0\",addr=\"$hex\",func=\"callee4\",file=\".*${srcfile}\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$callee4_begin\",arch=\"$any\"\}" \ - "selected frame listing" + mi_info_frame "selected frame listing" \ + -level 0 -addr $hex -func callee4 -file ".*${srcfile}" \ + -fullname "${fullname_syntax}${srcfile}" -line $callee4_begin \ + -arch $any mi_gdb_test "236-stack-list-frames 1 300" \ "236\\^done,stack=\\\[frame=\{level=\"1\",addr=\"$hex\",func=\"callee3\",.*\},frame=\{level=\"2\",addr=\"$hex\",func=\"callee2\",.*\},frame=\{level=\"3\",addr=\"$hex\",func=\"callee1\",.*\}\\\]" \ diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp index 49d5e2ef272..a1dbefe2e8d 100644 --- a/gdb/testsuite/lib/mi-support.exp +++ b/gdb/testsuite/lib/mi-support.exp @@ -2629,6 +2629,58 @@ proc mi_make_breakpoint_1 {attr_list thread cond evaluated-by times \ } +# Construct a regexp to match against a frame description as returned by +# -stack-info-frame. Take a list of name value pairs. Valid names are +# -level, -addr, -func, -file, -fullname, line, and -arch, each takes a +# regexp which is matched against the corresponding field in the +# -stack-info-frame output. + +proc mi_make_info_frame_regexp {args} { + parse_args [list [list level "$::decimal"] [list addr "$::hex"] \ + {func .*} {file .*} {fullname .*} \ + [list line "$::decimal"] {arch .*}] + + set attr_list {} + foreach attr {level addr func file fullname line arch} { + lappend attr_list $attr [set $attr] + } + + set result "frame=\\\{" + append result [mi_build_kv_pairs $attr_list] + append result "\\\}" + return $result +} + +# Run the -stack-info-frame command and match the result, return true if the +# test passes, otherwise, return false. +# +# TEST is the name used for this test. +# +# ARGS is an optional list of name value pairs, the names -frame and -thread +# if present, expect a decimal argument and control the frame and thread for +# which -stack-info-frame is run. If -frame is not given then the +# -stack-info-frame will operate on the current frame. If -thread is not +# given then -stack-info-frame will operate on the current thread. +# +# The remaining arguments are passed to mi_make_frame_regexp and are used to +# build the regexp for matching against the -stack-info-frame output. + +proc mi_info_frame { test args } { + parse_args {{frame ""} {thread ""}} + + set re [eval mi_make_info_frame_regexp $args] + + set cmd "235-stack-info-frame" + if {$frame ne ""} { + append cmd " --frame ${frame}" + } + if {$thread ne ""} { + append cmd " --thread ${thread}" + } + + return [mi_gdb_test $cmd "235\\^done,$re" $test] +} + # Construct a breakpoint regexp, for a breakpoint with multiple # locations. This may be used to test the output of -break-insert, # -dprintf-insert, or -break-info with breakpoints with multiple -- 2.25.4