From cbaebffb6492e1fe5b033c5695731b0b59f698f5 Mon Sep 17 00:00:00 2001 From: matt rice Date: Sun, 11 Sep 2011 04:40:51 -0700 Subject: [PATCH] Default INTER_MI to version 2, add tests. --- gdb/mi/mi-interp.c | 7 ++-- gdb/testsuite/gdb.base/interp.c | 23 ++++++++++++++ gdb/testsuite/gdb.base/interp.exp | 60 ++++++++++++++++++++++++++++++++----- 3 files changed, 78 insertions(+), 12 deletions(-) create mode 100644 gdb/testsuite/gdb.base/interp.c diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index bd49ebc..f561cd6 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -93,9 +93,11 @@ mi_interpreter_init (struct interp *interp, int top_level) mi->event_channel = mi_console_file_new (raw_stdout, "=", 0); name = interp_name (interp); + /* INTERP_MI selects the most recent released version. "mi2" was + released as part of GDB 6.0. */ if (strcmp (name, INTERP_MI1) == 0) mi_version = 1; - else if (strcmp (name, INTERP_MI2) == 0) + else if (strcmp (name, INTERP_MI2) == 0 || strcmp (name, INTERP_MI) == 0) mi_version = 2; else if (strcmp (name, INTERP_MI3) == 0) mi_version = 3; @@ -742,8 +744,5 @@ _initialize_mi_interp (void) interp_add (interp_new (INTERP_MI1, &procs)); interp_add (interp_new (INTERP_MI2, &procs)); interp_add (interp_new (INTERP_MI3, &procs)); - - /* "mi" selects the most recent released version. "mi2" was - released as part of GDB 6.0. */ interp_add (interp_new (INTERP_MI, &procs)); } diff --git a/gdb/testsuite/gdb.base/interp.c b/gdb/testsuite/gdb.base/interp.c new file mode 100644 index 0000000..2f52d3e --- /dev/null +++ b/gdb/testsuite/gdb.base/interp.c @@ -0,0 +1,23 @@ +/* This test program is part of GDB, the GNU debugger. + + Copyright 2011 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +int main(int argc, const char **argv) +{ + return 0; +} diff --git a/gdb/testsuite/gdb.base/interp.exp b/gdb/testsuite/gdb.base/interp.exp index bb11f04..ca09cb3 100644 --- a/gdb/testsuite/gdb.base/interp.exp +++ b/gdb/testsuite/gdb.base/interp.exp @@ -20,16 +20,29 @@ if $tracelevel then { strace $tracelevel } +set testfile "interp" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { + untested "Couldn't compile $testfile.exp test program" + return -1 +} + +gdb_exit gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load $binfile +# Force these to off for two prompt matching. +gdb_test "maint time 0" "" "" +gdb_test "maint space 0" "" "" + +set twoprompts "\r\n$gdb_prompt \r\n$gdb_prompt $" # Do not use gdb_test for this test, since it has two prompts. set cmd "interpreter-exec mi \"-var-update *\"" gdb_test_multiple $cmd $cmd { - -re "\\^done,changelist=\\\[\\\]\r\n$gdb_prompt " { + -re "\\^done,changelist=\\\[\\\]$twoprompts" { pass "$cmd" - gdb_expect 1 { - -re "\r\n$gdb_prompt $" { } - } } } gdb_test "interpreter-exec console \"show version\"" "GNU gdb .*" @@ -37,12 +50,43 @@ gdb_test "interpreter-exec console \"show version\"" "GNU gdb .*" # Regression test for crash when an exception occurs in mi_parse. gdb_test_multiple "interpreter-exec mi \"-break-insert --thread a\"" \ "regression test for mi_parse crash" { - -re ".error,msg=.Invalid value for the '--thread' option.\r\n$gdb_prompt " { + -re ".error,msg=.Invalid value for the '--thread' option.$twoprompts" { pass "$cmd" - gdb_expect 1 { - -re "\r\n$gdb_prompt $" { } - } } } +set cmd "interpreter-exec mi \"-stack-info-frame\"" +gdb_test_multiple $cmd $cmd { + -re ".error,msg=.No registers\..$twoprompts" { + pass "$cmd" + } +} + +set cmd "interpreter-exec mi1 \"-break-insert main\"" +gdb_test_multiple $cmd $cmd { + -re ".done.bkpt=.number=.\[0-9\].*$twoprompts" { + pass "$cmd" + } +} + +set cmd "interpreter-exec mi2 \"-break-insert main\"" +gdb_test_multiple $cmd $cmd { + -re ".done.bkpt=.number=.\[0-9\].*$twoprompts" { + pass "$cmd" + } +} + +set cmd "interpreter-exec mi3 \"-break-insert main\"" +gdb_test_multiple $cmd $cmd { + -re ".done.bkpt=.number=.\[0-9\].*$twoprompts" { + pass "$cmd" + } +} + +if ![runto_main] then { + fail "${testfile}.exp can run to main." + return -1; +} + +gdb_test "list" ".*\[0-9\].*int main.*" "${testfile}.exp can list sources" gdb_exit -- 1.7.4.4