This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v5] Add negative repeat count to 'x' command




On 11/08/16 00:58, Pedro Alves wrote:
On 08/08/2016 03:45 PM, Thomas Preudhomme wrote:
Sorry for the late reply but I noticed an issue in the tests added by
this patch for arm-none-eabi:


FAIL: gdb.base/examine-backward.exp: address zero boundary: examine 3
bytes forward from 0x0
NA->FAIL: gdb.base/examine-backward.exp char-width=1, print-max=20 take
1 string backward (6/6)
NA->FAIL: gdb.base/examine-backward.exp char-width=1, print-max=20 take
6 strings backward (pattern 1)


The first one is a testism:

we match for: 0x\[0-9a-f\]+00.*:${byte}${byte}${byte}
but we get: 0x0:    0x7f    0x45    0x4c

I'd thus suggest to match 0x\(\[0-9a-f\]+0\)?0 instead, with the right
amount of escaping (I don't know whether ? needs escaping and why + does
not need escaping in current pattern).

We're examining at 0x0.  Shouldn't we expect literally "0x0"
instead then?

That's what I would have done but I assumed that the test was passing on the machine it was developed and thus that some machine display 0x00000000 or something.




The other two seems like genuine errors. take 6 strings backward
(pattern 1) gives:

gdb_expect_list pattern: /"ABCDEFGHIJKLMNOPQRST".../
x/-6s^M
0x9aff <_fini+2>: "\277\370\274\b\274\236FpGABCDEFGHIJK"...^M
0x9b13 <TestStrings+11>:        "LMNOPQRSTUVWXYZ"^M
0x9b23 <TestStrings+27>:        ""^M
0x9b24 <TestStrings+28>:        ""^M
0x9b25 <TestStrings+29>:
"\343\201\273\343\201\222\343\201\273\343\201\222"^M
0x9b32 <TestStrings+42>:        "01234567890123456789"...^M
(gdb) FAIL: gdb.base/examine-backward.exp: char-width=1, print-max=20:
take 6 strings backward (pattern 1)


take 1 string backward (6/6) gives:

0x9aff <_fini+2>: "\277\370\274\b\274\236FpGABCDEFGHIJK"...


Please let me know what I can do to help diagnose this error.

The find-strings-backwards algorithm just looks back for '\0' to
find string boundaries.  Looks like it just happens that in your
case, the TestStrings array is immediately preceded by the
tail of _fini, with no gap in between.

Try this.  It's not strictly correct to assume that the linker
places the objects consecutively, but it's probably safe
in practice.

The patch works indeed. Thanks for your quick answer.

Best regards,

Thomas


diff --git c/gdb/testsuite/gdb.base/examine-backward.c w/gdb/testsuite/gdb.base/examine-backward.c
index b338503..187fad1 100644
--- c/gdb/testsuite/gdb.base/examine-backward.c
+++ w/gdb/testsuite/gdb.base/examine-backward.c
@@ -32,6 +32,14 @@ literals.  The content of each array is the same as followings:
   };
 */

+/* This is here just to ensure we have a null character before
+   TestStrings, to avoid showing garbage when we look for strings
+   backwards from TestStrings.  */
+
+const char NullString[] = {
+  0x00
+};
+
 const char TestStrings[] = {
   0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
   0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]