On 22/07/2024 16:44, David Malcolm wrote:
Does it help to hack this change into prune.exp:
diff --git a/gcc/testsuite/lib/prune.exp b/gcc/testsuite/lib/prune.exp
index d00d37f015f7..f467d1a97bc6 100644
--- a/gcc/testsuite/lib/prune.exp
+++ b/gcc/testsuite/lib/prune.exp
@@ -109,7 +109,7 @@ proc prune_gcc_output { text } {
# Many tests that use visibility will still pass on platforms that don't
support it.
regsub -all "(^|\n)\[^\n\]*lto1: warning: visibility attribute not supported in this
configuration; ignored\[^\n\]*" $text "" text
- #send_user "After:$text\n"
+ send_user "After:$text\n"
return $text
}
I'm baffled. Isn't that statement there just to debug prune_gcc_output?
I suppose we could prune the whitespace from the diagram, but
prune_gcc_output does not know about types. If there's 'int, that could
be int32_t, int16_t, int64_t, ptrdiff_t, or whatever. Unless you want
to make all integer types be considered equivalent for dejagnu purposes
if they appear somewhere between vertical bars.
Would it make sense to handle this with one multi-line pattern for
newlib based toolchains, ending with
{ dg-end-multiline-output "" { target *-*-elf } } */
and one for glibc based toolchain, ending in
{ dg-end-multiline-output "" { target !*-*-elf } } */
?
Presumably the only difference is in the top-right hand box of the
diagram,
Unfortunately, there's also a lot of white space change in the rest of
the diagram.
I have attached the patch I'm currently using for your perusal.
whereas my objective for those tests was more about the lower
part of the diagram - I wanted to verify how we handle symbolic buffer
sizes (e.g. (size * 4) + 3, and other run-time-computer sizes).
It's rather awkward to test the diagrams with DejaGnu, alas.
Would it might make sense to split out that file into three separate
tests -11a, -11b, and -11c, and be more aggressive about only running
the 2nd test on targets that we know generate "int" in the top-right
box?
No, each dg-end-multiline-output stanza already can have its separate
target selector, there is no point in putting them in separate files.
I guess you could reduce the differences between platforms if you didn't
use types as defined by headerfiles directly, as they might be #defines
or typedefs or whatever, and instead used your own typedef or struct types.Index: c-c++-common/analyzer/out-of-bounds-diagram-8.c
===================================================================
--- c-c++-common/analyzer/out-of-bounds-diagram-8.c (revision 6640)
+++ c-c++-common/analyzer/out-of-bounds-diagram-8.c (revision 6642)
@@ -17,6 +17,24 @@
/* { dg-begin-multiline-output "" }
+ ┌───────────────────────┐
+ │write of '(int32_t) 42'│
+ └───────────────────────┘
+ │
+ │
+ v
+ ┌───────────────────────────────┐ ┌───────────────────────┐
+ │buffer allocated on heap at (1)│ │ after valid range │
+ └───────────────────────────────┘ └───────────────────────┘
+ ├───────────────┬───────────────┤├─────┬──────┤├───────────┬───────────┤
+ │ │ │
+ ╭─────────────┴────────────╮ ╭───┴───╮ ╭─────────┴─────────╮
+ │capacity: 'size * 4' bytes│ │4 bytes│ │overflow of 4 bytes│
+ ╰──────────────────────────╯ ╰───────╯ ╰───────────────────╯
+
+ { dg-end-multiline-output "" { target *-*-elf } } */
+/* { dg-begin-multiline-output "" }
+
┌───────────────────┐
│write of '(int) 42'│
└───────────────────┘
@@ -32,4 +50,4 @@
│capacity: 'size * 4' bytes│ │4 bytes│ │overflow of 4 bytes│
╰──────────────────────────╯ ╰───────╯ ╰───────────────────╯
- { dg-end-multiline-output "" } */
+ { dg-end-multiline-output "" { target !*-*-elf } } */
Index: c-c++-common/analyzer/out-of-bounds-diagram-11.c
===================================================================
--- c-c++-common/analyzer/out-of-bounds-diagram-11.c (revision 6640)
+++ c-c++-common/analyzer/out-of-bounds-diagram-11.c (revision 6642)
@@ -45,8 +45,30 @@
buf[size] = 42; /* { dg-warning "stack-based buffer overflow" } */
}
+/* With a newlib toolchain (at least for esirisc), we end up with int32_t
+ being shown as itself. */
/* { dg-begin-multiline-output "" }
+ ┌────────────────────────────────────────┐
+ │ write of '(int32_t) 42' │
+ └────────────────────────────────────────┘
+ │ │
+ │ │
+ v v
+ ┌────────────────────────────────────────────────┐ ┌───────────────────┐
+ │ buffer allocated on stack at (1) │ │ after valid range │
+ └────────────────────────────────────────────────┘ └───────────────────┘
+ ├───────────────────────┬────────────────────────┤ ├─────────┬─────────┤
+ │ │
+ ╭────────────────┴───────────────╮ ╭─────────┴────────╮
+ │capacity: '(size * 4) + 3' bytes│ │overflow of 1 byte│
+ ╰────────────────────────────────╯ ╰──────────────────╯
+
+ { dg-end-multiline-output "" { target *-*-elf } } */
+/* Linux toolchains, or at least x86_64-pc-linux-gnu, show int32_t as 'int'.
*/
+/* { dg-begin-multiline-output "" }
+
+
┌───────────────────────────────────────┐
│ write of '(int) 42' │
└───────────────────────────────────────┘
@@ -62,7 +84,7 @@
│capacity: '(size * 4) + 3' bytes│ │overflow of 1 byte│
╰────────────────────────────────╯ ╰──────────────────╯
- { dg-end-multiline-output "" } */
+ { dg-end-multiline-output "" { target !*-*-elf } } */
/* We're currently not able to generate a diagram for this case;
Index: gcc.dg/analyzer/out-of-bounds-diagram-10.c
===================================================================
--- gcc.dg/analyzer/out-of-bounds-diagram-10.c (revision 6640)
+++ gcc.dg/analyzer/out-of-bounds-diagram-10.c (revision 6642)
@@ -11,6 +11,24 @@
/* { dg-begin-multiline-output "" }
+ ┌───────────────────────┐
+ │write of '(int32_t) 42'│
+ └───────────────────────┘
+ │
+ │
+ v
+ ┌───────────────────────┐ ┌────────────────────────────────┐
+ │ before valid range │ │buffer allocated on stack at (1)│
+ └───────────────────────┘ └────────────────────────────────┘
+ ├───────────┬───────────┤├─────┬─────┤├───────────────┬────────────────┤
+ │ │ │
+ ╭──────────┴──────────╮ ╭───┴───╮ ╭───────────┴───────────╮
+ │underwrite of 4 bytes│ │4 bytes│ │capacity: 'n * 4' bytes│
+ ╰─────────────────────╯ ╰───────╯ ╰───────────────────────╯
+
+ { dg-end-multiline-output "" { target *-*-elf } } */
+/* { dg-begin-multiline-output "" }
+
┌───────────────────┐
│write of '(int) 42'│
└───────────────────┘
@@ -26,4 +44,4 @@
│underwrite of 4 bytes│ │4 bytes│ │capacity: 'n * 4' bytes│
╰─────────────────────╯ ╰───────╯ ╰───────────────────────╯
- { dg-end-multiline-output "" } */
+ { dg-end-multiline-output "" { target !*-*-elf } } */