public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
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	[thread overview]
Message-ID: <1757ee9de18bd2e26ed911f0db620ce8ce92fd7e.1661868744.git.aburgess@redhat.com> (raw)
In-Reply-To: <cover.1661868744.git.aburgess@redhat.com>

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


  reply	other threads:[~2022-08-30 14:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-30 14:16 [PATCH 0/3] Improvements for Pygments based disassembly styling Andrew Burgess
2022-08-30 14:16 ` Andrew Burgess [this message]
2022-08-30 14:16 ` [PATCH 2/3] gdb: improve disassembler styling when Pygments raises an exception Andrew Burgess
2022-10-08  2:25   ` Simon Marchi
2022-10-08 16:00     ` Andrew Burgess
2022-10-08 16:01       ` Simon Marchi
2022-10-10  9:32         ` Andrew Burgess
2022-10-10 10:31           ` Tom de Vries
2022-10-10 11:16             ` Andrew Burgess
2022-10-10 13:22               ` Tom de Vries
2022-10-10 14:04                 ` Andrew Burgess
2022-10-10 11:03     ` Andrew Burgess
2022-08-30 14:16 ` [PATCH 3/3] gdb/disasm: better intel flavour disassembly styling with Pygments Andrew Burgess
2022-10-02 16:38 ` [PATCH 0/3] Improvements for Pygments based disassembly styling Andrew Burgess

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1757ee9de18bd2e26ed911f0db620ce8ce92fd7e.1661868744.git.aburgess@redhat.com \
    --to=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).