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 0FE243858C41 for ; Wed, 17 May 2023 17:46:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0FE243858C41 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=1684345578; 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: in-reply-to:in-reply-to:references:references; bh=Mi4v+OKBp7UBb98wWFPfMCrukbOXpmdD8Lqzseh0d40=; b=RnJtKfOHPmuzF/w6zkVp23LGvixSPlbDSbV1Jhy6Vtflzlqjc7KAr+nrJF7c+l1mqdfECr gpMajv5ALY9m1uN4Ym/T5v8QR9F9HwSjwkBoqu3Eh/owD7eQpf1OtR2fHAmhHf326zEdMD 3zxO5RAi2kvW2n2oQ7cE/P6bs449lqk= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-372-V11TN5H-N7aKBg1D51Yrlw-1; Wed, 17 May 2023 13:46:16 -0400 X-MC-Unique: V11TN5H-N7aKBg1D51Yrlw-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3079d15b51dso165770f8f.1 for ; Wed, 17 May 2023 10:46:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684345575; x=1686937575; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Mi4v+OKBp7UBb98wWFPfMCrukbOXpmdD8Lqzseh0d40=; b=bcs0tTknClHO9pP21OrH5ZQLHMh15+K5zY9sWykMB8MC/oaqsRd9a/pmsARXTLLBWq NqbbeQVLwaTiUSwgXAYB8mpQT6hjvrHUZG7R5Uht25Z1lpxO5Qmr/DsOx4hTRhoraNUt dv0R8mtH5WBeJGgvJdtwhGfEmWzLSVv/R/OCaeS1PiwbQOHhn8mKCqzkOIjVnGyqRTgl 73CTdfB+p6uWXgp0gPWtOLa6XYQrEOJ/So6NM8fiLTGIU7PaG3OwmDnFF5bn+p/yUs+w Cwd+i/l5oJN9yirm1054/VaXZcTJE3OcrERJebnwl9OFrVrYYcgbhgfwvbMNwls6e5ZJ f8WQ== X-Gm-Message-State: AC+VfDxwItWtru25oWNG1Ajt4zZA2mABa+vmvhu+KzSDu3eT2W9OVPvm RymMBbmd0+rxJ9ejTdn1sVeXbe3Gn8BU8TIuZ0SedSifd4FpgwtrgT/V6tJgdqlFtAsFx7Pnxuv toJYtCcSxe3Pt/a1ZACfkrHnYYFnynA== X-Received: by 2002:a5d:6751:0:b0:307:5091:5b96 with SMTP id l17-20020a5d6751000000b0030750915b96mr1433239wrw.22.1684345574961; Wed, 17 May 2023 10:46:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4eZC850lwiUogGFWDbi+ZMwNhgHkW/59dnyO3MIi9Vd18DwmOqb5sS4XUJtT4bHNJ1geX9cQ== X-Received: by 2002:a5d:6751:0:b0:307:5091:5b96 with SMTP id l17-20020a5d6751000000b0030750915b96mr1433228wrw.22.1684345574591; Wed, 17 May 2023 10:46:14 -0700 (PDT) Received: from localhost (11.72.115.87.dyn.plus.net. [87.115.72.11]) by smtp.gmail.com with ESMTPSA id l4-20020a7bc444000000b003f42ceb3bf4sm2970612wmi.32.2023.05.17.10.46.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 May 2023 10:46:14 -0700 (PDT) From: Andrew Burgess To: Tom de Vries , gdb-patches@sourceware.org Cc: Eli Zaretskii Subject: Re: [PATCHv3 2/2] gdb/python: extend the Python Disassembler API to allow for styling In-Reply-To: <75aafd23-c764-84ec-29e0-d9aa624ac81a@suse.de> References: <7d8bfee6bf10b136f0d02e9a45ef47249fdcca0a.1683913563.git.aburgess@redhat.com> <75aafd23-c764-84ec-29e0-d9aa624ac81a@suse.de> Date: Wed, 17 May 2023 18:46:13 +0100 Message-ID: <87lehmam1m.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain 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_H2,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE 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: Tom de Vries writes: > On 5/12/23 19:50, Andrew Burgess via Gdb-patches wrote: >> This commit extends the Python Disassembler API to allow for styling >> of the instructions. >> > > I'm running into: > ... > FAIL: gdb.python/py-disasm.exp: > global_disassembler=ErrorCreatingTextPart_NoArgs: disassemble test > FAIL: gdb.python/py-disasm.exp: > global_disassembler=ErrorCreatingAddressPart_NoArgs: disassemble test > FAIL: gdb.python/py-disasm.exp: > global_disassembler=ErrorCreatingTextPart_NoString: disassemble test > FAIL: gdb.python/py-disasm.exp: > global_disassembler=ErrorCreatingTextPart_NoStyle: disassemble test > FAIL: gdb.python/py-disasm.exp: try to create a DisassemblerResult > without a length argument > ... > > First in more detail: > ... > (gdb) disassemble test^M > Dump of assembler code for function test:^M > 0x00000000004004a7 <+0>: push %rbp^M > 0x00000000004004a8 <+1>: mov %rsp,%rbp^M > 0x00000000004004ab <+4>: nop^M > => 0x00000000004004ac <+5>: Python Exception : > Required argument 'style' (pos 1) not found^M > ^M > unknown disassembler error (error = -1)^M > (gdb) FAIL: gdb.python/py-disasm.exp: > global_disassembler=ErrorCreatingTextPart_NoArgs: disassemble test > ... > > This seems to be due to the test-case expecting " function missing > required argument ..." but getting "Required argument ..." Sorry for that. I guess you must be using an older (3.6.x or earlier) version of Python? The patch below should resolve the issues, I'll push this tomorrow. Thanks, Andrew --- commit 416267af2e8272f677461fe9674bb10fcbd19098 Author: Andrew Burgess Date: Wed May 17 18:39:26 2023 +0100 gdb/testsuite: handle older Python versions in gdb.python/py-disasm.exp It was pointed out on the mailing list that the new tests added in this commit: commit 4de4e48514fc47aeb4ca95cd4091e2a333fbe9e1 Date: Tue Jan 24 15:35:45 2023 +0000 gdb/python: extend the Python Disassembler API to allow for styling will fail when GDB is built with Python 3.6 or earlier. This is because the error that is emitted when a function argument is missing changed in Python 3.7, instead of an error like this: Python Exception : function missing required argument 'style' (pos 1) earlier versions of Python emit: Python Exception : Required argument 'style' (pos 1) not found and the new tests didn't allow for this. This commit fixes this by allowing either pattern. I've tested this building GDB against Python 3.7.9 and 3.6.15, with this commit all tests in gdb.python/py-disasm.exp now pass. diff --git a/gdb/testsuite/gdb.python/py-disasm.exp b/gdb/testsuite/gdb.python/py-disasm.exp index 304393f71ab..f2f9225168a 100644 --- a/gdb/testsuite/gdb.python/py-disasm.exp +++ b/gdb/testsuite/gdb.python/py-disasm.exp @@ -75,6 +75,16 @@ proc make_exception_pattern { type msg } { return "${::addr_pattern}Python Exception : $msg\r\n\r\n${::unknown_error_pattern}" } +# Helper proc to build a pattern for the text Python emits when a +# function argument is missing. This string changed in Python 3.7 and +# later. NAME is the parameter name, and POS is its integer position +# in the argument list. +proc missing_arg_pattern { name pos } { + set pattern_1 "function missing required argument '$name' \\(pos $pos\\)" + set pattern_2 "Required argument '$name' \\(pos $pos\\) not found" + return "(?:${pattern_1}|${pattern_2})" +} + set test_plans \ [list \ [list "" "${base_pattern}\r\n.*"] \ @@ -113,16 +123,16 @@ set test_plans \ "Result is not a DisassemblerResult."]] \ [list "ErrorCreatingTextPart_NoArgs" \ [make_exception_pattern "TypeError" \ - "function missing required argument 'style' \\(pos 1\\)"]] \ + [missing_arg_pattern "style" 1]]] \ [list "ErrorCreatingAddressPart_NoArgs" \ [make_exception_pattern "TypeError" \ - "function missing required argument 'address' \\(pos 1\\)"]] \ + [missing_arg_pattern "address" 1]]] \ [list "ErrorCreatingTextPart_NoString" \ [make_exception_pattern "TypeError" \ - "function missing required argument 'string' \\(pos 2\\)"]] \ + [missing_arg_pattern "string" 2]]] \ [list "ErrorCreatingTextPart_NoStyle" \ [make_exception_pattern "TypeError" \ - "function missing required argument 'style' \\(pos 1\\)"]] \ + [missing_arg_pattern "style" 1]]] \ [list "All_Text_Part_Styles" "${addr_pattern}p1p2p3p4p5p6p7p8p9p10\r\n.*"] \ [list "ErrorCreatingTextPart_StringAndParts" \ [make_exception_pattern "ValueError" \ @@ -273,7 +283,7 @@ with_test_prefix "check inheritance" { # Test some error conditions when creating a DisassemblerResult object. gdb_test "python result = gdb.disassembler.DisassemblerResult()" \ [multi_line \ - "TypeError: function missing required argument 'length' \\(pos 1\\)" \ + "TypeError: [missing_arg_pattern length 1]" \ "Error while executing Python code\\."] \ "try to create a DisassemblerResult without a length argument"