From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1726) id 4E64C3858D38; Sun, 2 Oct 2022 16:36:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4E64C3858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1664728587; bh=OzmBo/GZzMGpFPPkakN4re2rESUOTqgsF+oL08/YYlo=; h=From:To:Subject:Date:From; b=QGunRXIqpn84McraXFwZ4lhaue+sZinJYD1lf7Yrmwx5ZRfqqp+kEfjaf29m76+WU kw42+VldEjUGE82Q3C8/GRs12XuF4r5T6O8wLZx3FPDuuGC9ujDqki42/eic2v/8YH C9MlXzNyUGwU5LT8SGzq3nSpK4pC1RU5OcvPHWJI= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Andrew Burgess To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/testsuite: extend styling test for libopcodes styling X-Act-Checkin: binutils-gdb X-Git-Author: Andrew Burgess X-Git-Refname: refs/heads/master X-Git-Oldrev: 637b2f86138a8ec0ab0fe89d3e4c5c111559d7f2 X-Git-Newrev: 5b0e2b48edb9b6c53ed5c2de02b315838a1adae8 Message-Id: <20221002163627.4E64C3858D38@sourceware.org> Date: Sun, 2 Oct 2022 16:36:27 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D5b0e2b48edb9= b6c53ed5c2de02b315838a1adae8 commit 5b0e2b48edb9b6c53ed5c2de02b315838a1adae8 Author: Andrew Burgess Date: Fri Aug 26 21:13:51 2022 +0100 gdb/testsuite: extend styling test for libopcodes styling =20 This commit extends the gdb.base/style.exp test to cover disassembler styling using libopcodes (where available). =20 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. =20 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. =20 If the Pygments module is not available then the Pygments based tests will be skipped just as they were before. Diff: --- 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/styl= e.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] =20 - 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 =3D=3D "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 =3D=3D "off" && $disasm_styling =3D=3D "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 \ } =20 # Check that the disassembler styling can be disabled. -if { $python_disassembly_styling } { - test_disable_disassembler_styling -} +test_disable_disassembler_styling =20 # Finally, check the styling of the version string during startup. test_startup_version_string