gdb/testsuite: Fix broken regexp in gdbstub case
authorAndrew Burgess <andrew.burgess@embecosm.com>
Thu, 15 Mar 2018 19:41:50 +0000 (19:41 +0000)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Fri, 4 May 2018 10:11:45 +0000 (11:11 +0100)
When $use_gdb_stub is true then, when we start an MI target there's a
regexp to match GDB's startup pattern.  Unfortunately the pattern is
broken, and we're also missing a timeout case in the match list (which
would have helped point out that the regexp was broken).

The changes to the regexp are:

  1. Remove '${run_match}' prefix, the issued command doesn't include
  '${run_prefix}' so expecting '${run_match}' is wrong.

  2. Replaced '\\n' with '\\\\n' in order to match literal '\n' in
  GDBs output (that is, match a backslash followed by 'n', not a
  newline character).

  3. Replaced a '.' (matching any character) with '\.' to match a '.'
  and moved the '\.' into the correct place in the regexp.

  4. Replaced '\r\n' with '[\r\n]+' to match the end of a line.  This
  change isn't esential, but matches the other end of line patterns
  within this regexp.

Here's an example of the output that the regexp should match taken
from a testfile log, the first line is the command sent to GDB, and
the remaining lines are the response from GDB:

  jump *_start
  &"jump *_start\n"
  ~"Continuing at 0x10074.\n"
  ^running
  *running,thread-id="all"
  (gdb)

gdb/testsuite/ChangeLog:

* lib/mi-support.exp (mi_run_cmd_full): Fix regexp and add a
timeout.

gdb/testsuite/ChangeLog
gdb/testsuite/lib/mi-support.exp

index 188e6b135880a266cbfc73bd144dc4d441981ed5..a66b8cc4173ac44040da57c733f21b0458a5ccdd 100644 (file)
@@ -1,3 +1,8 @@
+2018-05-04  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * lib/mi-support.exp (mi_run_cmd_full): Fix regexp and add a
+       timeout.
+
 2018-05-03  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * gdb.base/callfuncs.exp (fetch_all_registers): Add riscv register
index 2846da74e477a561ee7015ccc9997cdd73279a79..851e490f4de206e40ce9305dd93a91ae2fd62500 100644 (file)
@@ -979,7 +979,11 @@ proc mi_run_cmd_full {use_mi_command args} {
        send_gdb  "jump *$start\n"
        warning "Using CLI jump command, expect run-to-main FAIL"
        gdb_expect {
-           -re "${run_match}&\"jump \\*${start}\\n\"\[\r\n\]+~\"Continuing at 0x\[0-9A-Fa-f\]+\\n.\"\[\r\n\]+\^running\[\r\n\]+\\*running,thread-id=\"\[^\"\]+\"\r\n${mi_gdb_prompt}" {}
+           -re "&\"jump \\*${start}\\\\n\"\[\r\n\]+~\"Continuing at 0x\[0-9A-Fa-f\]+\.\\\\n\"\[\r\n\]+\\^running\[\r\n\]+\\*running,thread-id=\"\[^\"\]+\"\[\r\n\]+${mi_gdb_prompt}" {}
+           timeout {
+               perror "Unable to start target"
+               return -1
+           }
        }
        return 0
     }
This page took 0.034514 seconds and 4 git commands to generate.