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.129.124]) by sourceware.org (Postfix) with ESMTPS id A50F73839076 for ; Tue, 30 Aug 2022 14:17:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A50F73839076 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_128_GCM_SHA256) id us-mta-595-ASexoZx7PHi09TD3DTgkOg-1; Tue, 30 Aug 2022 10:17:02 -0400 X-MC-Unique: ASexoZx7PHi09TD3DTgkOg-1 Received: by mail-wm1-f70.google.com with SMTP id a17-20020a05600c349100b003a545125f6eso10151197wmq.4 for ; Tue, 30 Aug 2022 07:17:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=2JIXtwiDoagWwm7uWhzzui6I/0bUasrDuuIB1CUb4hQ=; b=raAYEBQNPjuhLmG1PIYuxZRQALpYjhTZWN6ECyTWF2UQcjj3baigDHjEm2kNOabwEB 4fFYIyEqYgw3P3O3jZ3pJHNV4mfQQomQGLqyS1OClLKl4Lplaf88NtbievDZiwhqBmCJ 5A4NykJ+T1wHKEcSLyZU0JasW2vqW1Io667pNRK7BQKPECOtthFTjwo0m/OPAEGZQA3e 3LuB1345okkj181WCDzO1artKTykikQCcQfwyLVHKUJ6oZfiQeZa8lTI1JUO9kGDNIqB M1DP4jdUY3x5sHQFcf1xQDaE9Y7pl+c1yn5O+pSGnuT9jgyJVG6cZAHv43QdMgvt/ysY rKLA== X-Gm-Message-State: ACgBeo14e1Tup0PaO07H2sVJubmHyMbHwHb91vaNRqmJZ9NQzBQbFsla vZ+JIRiPa7gJ1KAbpmsI2p+Hx/0drrGaxX1a3RrI18YvMDsvmY9GmzK96UG5B3hDQ0roPVdgDhJ 8mryV5IOWj3CSQ10Vo0BmUVFR8/tFaSW5JX33kvqWl4IUu0z+OtwEKE6Uz87QWjYVVr7yLu/xDg == X-Received: by 2002:adf:d846:0:b0:226:defc:3a01 with SMTP id k6-20020adfd846000000b00226defc3a01mr4083710wrl.313.1661869020636; Tue, 30 Aug 2022 07:17:00 -0700 (PDT) X-Google-Smtp-Source: AA6agR5bYQLxzLGB5tPFvokucUvaYgWIulfrxk8Be1fXYpVYNYFtntPa0Xib8yYxyiUyVKsplDnVdg== X-Received: by 2002:adf:d846:0:b0:226:defc:3a01 with SMTP id k6-20020adfd846000000b00226defc3a01mr4083701wrl.313.1661869020367; Tue, 30 Aug 2022 07:17:00 -0700 (PDT) Received: from localhost ([31.111.84.229]) by smtp.gmail.com with ESMTPSA id bi26-20020a05600c3d9a00b003a5ea1cc63csm11864770wmb.39.2022.08.30.07.16.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 07:17:00 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Subject: [PATCH 1/3] gdb/testsuite: extend styling test for libopcodes styling Date: Tue, 30 Aug 2022 15:16:51 +0100 Message-Id: <1757ee9de18bd2e26ed911f0db620ce8ce92fd7e.1661868744.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=-12.2 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_LOW, 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Aug 2022 14:17:08 -0000 This commit extends the gdb.base/style.exp test to cover disassembler styling using libopcodes (where available). The test will try to enable libopcode based styling, if this works (because such styling is available) then some tests are run to check that the output is styled, and that the styling can be disabled using 'set style disassembler enabled off'. If libopcodes styling is not available on the current architecture then these new tests will be skipped. I've moved the Python Pygments module check inside the test_disable_disassembler_styling function now, so that the test will be run even when Python Pygments is not available, this allows the new tests discussed above. If the Pygments module is not available then the Pygments based tests will be skipped just as they were before. --- gdb/testsuite/gdb.base/style.exp | 95 ++++++++++++++++++++++---------- 1 file changed, 65 insertions(+), 30 deletions(-) diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp index 2242c5bf743..3126748bb1c 100644 --- a/gdb/testsuite/gdb.base/style.exp +++ b/gdb/testsuite/gdb.base/style.exp @@ -317,39 +317,76 @@ proc test_disable_disassembler_styling { } { set styled_hex [limited_style $::hex address] set main [limited_style main function] - foreach_with_prefix disasm_styling { on off } { - gdb_test_no_output "set style disassembler enabled ${disasm_styling}" - - set saw_header_line false - set saw_styled_output_line false - set saw_unstyled_output_line false - gdb_test_multiple "disassemble main" "" { - -re "disassemble main\r\n" { - exp_continue - } - -re "^Dump of assembler code for function $main:" { - set saw_header_line true + foreach_with_prefix libopcodes { on off } { + + set command_failed false + gdb_test_multiple "maint set libopcodes-styling enabled ${libopcodes}" "" { + -re "^maint set libopcodes-styling enabled ${libopcodes}\r\n" { exp_continue } - -re "^\\s+${styled_hex}\\s+<\[^>\]+>:\\s+\[^\r\n\033\]+\r\n" { - set saw_unstyled_output_line true + + -re "Use of libopcodes styling not supported on architecture \[^\r\n\]+\r\n" { + set command_failed true exp_continue } - -re "^\\s+${styled_hex}\\s+<\[^>\]+>:\\s+\[^\r\n\]+\033\[^\r\n\]+\r\n" { - set saw_styled_output_line true - exp_continue + + -re "^$::gdb_prompt $" { + gdb_assert { !$command_failed || [string equal $libopcodes "on"] } \ + $gdb_test_name } - -re "^End of assembler dump\\.\r\n" { - exp_continue + } + + if { $libopcodes == "on" && $command_failed } { + # We tried to turn on libopcodes disassembler styling, + # but this is not supported on this architecture. + continue + } + + foreach_with_prefix disasm_styling { on off } { + gdb_test_no_output "set style disassembler enabled ${disasm_styling}" + + if { $libopcodes == "off" && $disasm_styling == "on" \ + && !$::python_disassembly_styling} { + # We have libopcodes based styling off, but + # disassembler styling turned on. We're expecting + # Python Pygments to be used to add styling. + # + # However, if we get here, then we don't have the + # Pygments module, so skip this test. + continue } - -re "^$::gdb_prompt $" { - gdb_assert { $saw_header_line } - if { $disasm_styling } { - gdb_assert { $saw_styled_output_line } - gdb_assert { !$saw_unstyled_output_line } - } else { - gdb_assert { !$saw_styled_output_line } - gdb_assert { $saw_unstyled_output_line } + + set saw_header_line false + set saw_styled_output_line false + set saw_unstyled_output_line false + gdb_test_multiple "disassemble main" "" { + -re "disassemble main\r\n" { + exp_continue + } + -re "^Dump of assembler code for function $main:" { + set saw_header_line true + exp_continue + } + -re "^\\s+${styled_hex}\\s+<\[^>\]+>:\\s+\[^\r\n\033\]+\r\n" { + set saw_unstyled_output_line true + exp_continue + } + -re "^\\s+${styled_hex}\\s+<\[^>\]+>:\\s+\[^\r\n\]+\033\[^\r\n\]+\r\n" { + set saw_styled_output_line true + exp_continue + } + -re "^End of assembler dump\\.\r\n" { + exp_continue + } + -re "^$::gdb_prompt $" { + gdb_assert { $saw_header_line } + if { $disasm_styling } { + gdb_assert { $saw_styled_output_line } + gdb_assert { !$saw_unstyled_output_line } + } else { + gdb_assert { !$saw_styled_output_line } + gdb_assert { $saw_unstyled_output_line } + } } } } @@ -396,9 +433,7 @@ foreach style { title file function highlight variable \ } # Check that the disassembler styling can be disabled. -if { $python_disassembly_styling } { - test_disable_disassembler_styling -} +test_disable_disassembler_styling # Finally, check the styling of the version string during startup. test_startup_version_string -- 2.25.4