2009-01-03 05:58:08 +00:00
# Copyright 2002, 2003, 2004, 2005, 2007, 2008, 2009
# Free Software Foundation, Inc.
2003-02-06 01:22:06 +00:00
# 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
2007-08-23 18:14:19 +00:00
# the Free Software Foundation; either version 3 of the License, or
2003-02-06 01:22:06 +00:00
# (at your option) any later version.
2007-08-23 18:14:19 +00:00
#
2003-02-06 01:22:06 +00:00
# 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.
2007-08-23 18:14:19 +00:00
#
2003-02-06 01:22:06 +00:00
# You should have received a copy of the GNU General Public License
2007-08-23 18:14:19 +00:00
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2003-02-06 01:22:06 +00:00
# This file tests that GDB's console can be accessed via the MI.
# Specifically, we are testing the "interpreter-exec" command and that
# the commands that are executed via this command are properly executed.
# Console commands executed via MI should use MI output wrappers, MI event
# handlers, etc.
load_lib mi-support.exp
set MIFLAGS "-i=mi"
gdb_exit
if [mi_gdb_start] {
continue
}
set testfile "basics"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
2006-08-10 05:27:22 +00:00
untested mi-cli.exp
return -1
2003-02-06 01:22:06 +00:00
}
mi_gdb_test "-interpreter-exec" \
{\^error,msg="mi_cmd_interpreter_exec: Usage: -interpreter-exec interp command"} \
"-interpreter-exec with no arguments"
mi_gdb_test "-interpreter-exec console" \
{\^error,msg="mi_cmd_interpreter_exec: Usage: -interpreter-exec interp command"} \
"-interpreter-exec with one argument"
mi_gdb_test "-interpreter-exec bogus command" \
{\^error,msg="mi_cmd_interpreter_exec: could not find interpreter \\\"bogus\\\""} \
"-interpreter-exec with bogus interpreter"
set msg {Undefined command: \\\"bogus\\\"\. Try \\\"help\\\"\.}
mi_gdb_test "-interpreter-exec console bogus" \
"&\\\"$msg\\\\n\\\".*\\^error,msg=\\\"$msg\\\".*" \
"-interpreter-exec console bogus"
# NOTE: cagney/2003-02-03: Not yet.
# mi_gdb_test "-interpreter-exec console \"file $binfile\"" \
# {(=.*)+\^done} \
# "-interpreter-exec console \"file \$binfile\""
mi_gdb_test "-interpreter-exec console \"file $binfile\"" \
2005-09-27 Bob Rossi <bob@brasko.net>
* gdb.mi/mi-disassemble.exp, gdb.mi/mi2-disassemble.exp: Remove .*
from test. Escape the | in mi_gdb_test call.
* gdb.mi/mi-basics.exp, gdb.mi/mi-cli.exp, gdb.mi/mi-disassemble.exp,
gdb.mi/mi-pthreads.exp, gdb.mi/mi-stack.exp, gdb.mi/mi2-basics.exp,
gdb.mi/mi2-cli.exp, gdb.mi/mi2-disassemble.exp,
gdb.mi/mi2-pthreads.exp, gdb.mi/mi2-stack.exp: Add extra details to
expected regex's in mi_gdb_test calls.
* lib/mi-support.exp: Remove arbitrary .* from tests.
(mi_gdb_test): Add string_regex variable. Add anchor to main -re.
Fully anchor GDB/MI expected results in mi_gdb_test.
* lib/gdb.exp (string_to_regexp): Escape the ] character.
* gdb.base/sizeof.exp: Remove escape character. Correct test.
2005-09-27 22:39:04 +00:00
{~"Reading symbols from .*basics...".*done} \
2003-02-06 01:22:06 +00:00
"-interpreter-exec console \"file \$binfile\""
mi_run_to_main
2004-08-15 10:15:58 +00:00
set line_main_head [gdb_get_line_number "main ("]
set line_main_body [expr $line_main_head + 2]
set line_main_hello [gdb_get_line_number "Hello, World!"]
set line_main_return [expr $line_main_hello + 2]
2003-02-06 01:22:06 +00:00
mi_gdb_test "-interpreter-exec console \"set args foobar\"" \
{\^done} \
"-interpreter-exec console \"set args foobar\""
mi_gdb_test "-interpreter-exec console \"show args\"" \
{\~"Argument list to give program being debugged when it is started is \\\"foobar\\\"\.\\n".*\^done} \
"-interpreter-exec console \"show args\""
# NOTE: cagney/2003-02-03: Not yet.
# mi_gdb_test "-interpreter-exec console \"break callee4\"" \
# {(&.*)*.*~"Breakpoint 2 at.*\\n".*=breakpoint-create,number="2".*\^done} \
# "-interpreter-exec console \"break callee4\""
mi_gdb_test "-interpreter-exec console \"break callee4\"" \
{(&.*)*.*~"Breakpoint 2 at.*\\n".*\^done} \
"-interpreter-exec console \"break callee4\""
mi_gdb_test "-interpreter-exec console \"info break\"" \
{\~"Num[ \t]*Type[ \t]*Disp[ \t]*Enb[ \t]*Address[ \t]*What\\n".*~"2[ \t]*breakpoint[ \t]*keep[ \t]*y[ \t]*0x[0-9A-Fa-f]+[ \t]*in callee4 at .*basics.c:[0-9]+\\n".*\^done} \
"-interpreter-exec console \"info break\""
mi_gdb_test "-interpreter-exec console \"set listsize 1\"" \
{\^done} \
"-interpreter-exec console \"set listsize 1\""
2004-08-15 10:15:58 +00:00
# {.*\~"32[ \t(\\t)]*callee1.*\\n".*\^done }
2003-02-06 01:22:06 +00:00
mi_gdb_test "-interpreter-exec console \"list\"" \
2004-08-15 10:15:58 +00:00
".*\~\"$line_main_body\[\\\\t \]*callee1.*;\\\\n\".*\\^done" \
2003-02-06 01:22:06 +00:00
"-interpreter-exec console \"list\""
2008-06-13 19:53:42 +00:00
mi_execute_to "exec-continue" "breakpoint-hit" "callee4" "" ".*basics.c" "28" \
2008-04-15 14:33:55 +00:00
{ "" "disp=\"keep\"" } "continue to callee4"
2003-02-06 01:22:06 +00:00
# NOTE: cagney/2003-02-03: Not yet.
# mi_gdb_test "100-interpreter-exec console \"delete 2\"" \
# {.*=breakpoint-delete,number=\"2\".*\^done} \
# "-interpreter-exec console \"delete 2\""
mi_gdb_test "100-interpreter-exec console \"delete 2\"" \
{100\^done} \
"-interpreter-exec console \"delete 2\""
# NOTE: cagney/2003-02-03: Not yet.
# mi_gdb_test "200-interpreter-exec console \"up\"" \
# {.*=selected-frame-level-changed,level="1".*\^done} \
# "-interpreter-exec console \"up\""
mi_gdb_test "200-interpreter-exec console \"up\"" \
2005-09-27 Bob Rossi <bob@brasko.net>
* gdb.mi/mi-disassemble.exp, gdb.mi/mi2-disassemble.exp: Remove .*
from test. Escape the | in mi_gdb_test call.
* gdb.mi/mi-basics.exp, gdb.mi/mi-cli.exp, gdb.mi/mi-disassemble.exp,
gdb.mi/mi-pthreads.exp, gdb.mi/mi-stack.exp, gdb.mi/mi2-basics.exp,
gdb.mi/mi2-cli.exp, gdb.mi/mi2-disassemble.exp,
gdb.mi/mi2-pthreads.exp, gdb.mi/mi2-stack.exp: Add extra details to
expected regex's in mi_gdb_test calls.
* lib/mi-support.exp: Remove arbitrary .* from tests.
(mi_gdb_test): Add string_regex variable. Add anchor to main -re.
Fully anchor GDB/MI expected results in mi_gdb_test.
* lib/gdb.exp (string_to_regexp): Escape the ] character.
* gdb.base/sizeof.exp: Remove escape character. Correct test.
2005-09-27 22:39:04 +00:00
{~"#.*".*200\^done} \
2003-02-06 01:22:06 +00:00
"-interpreter-exec console \"up\""
# NOTE: cagney/2003-02-03: Not yet.
# mi_gdb_test "300-interpreter-exec console \"down\"" \
# {.*=selected-frame-level-changed,level="0".*\^done} \
# "-interpreter-exec console \"down\""
mi_gdb_test "300-interpreter-exec console \"down\"" \
2005-09-27 Bob Rossi <bob@brasko.net>
* gdb.mi/mi-disassemble.exp, gdb.mi/mi2-disassemble.exp: Remove .*
from test. Escape the | in mi_gdb_test call.
* gdb.mi/mi-basics.exp, gdb.mi/mi-cli.exp, gdb.mi/mi-disassemble.exp,
gdb.mi/mi-pthreads.exp, gdb.mi/mi-stack.exp, gdb.mi/mi2-basics.exp,
gdb.mi/mi2-cli.exp, gdb.mi/mi2-disassemble.exp,
gdb.mi/mi2-pthreads.exp, gdb.mi/mi2-stack.exp: Add extra details to
expected regex's in mi_gdb_test calls.
* lib/mi-support.exp: Remove arbitrary .* from tests.
(mi_gdb_test): Add string_regex variable. Add anchor to main -re.
Fully anchor GDB/MI expected results in mi_gdb_test.
* lib/gdb.exp (string_to_regexp): Escape the ] character.
* gdb.base/sizeof.exp: Remove escape character. Correct test.
2005-09-27 22:39:04 +00:00
{~"#.*".*300\^done} \
2003-02-06 01:22:06 +00:00
"-interpreter-exec console \"down\""
# NOTE: cagney/2003-02-03: Not yet.
# mi_gdb_test "-interpreter-exec console \"frame 2\"" \
# {.*=selected-frame-level-changed,level="2".*\^done} \
# "-interpreter-exec console \"frame 2\""
mi_gdb_test "400-interpreter-exec console \"frame 2\"" \
2005-09-27 Bob Rossi <bob@brasko.net>
* gdb.mi/mi-disassemble.exp, gdb.mi/mi2-disassemble.exp: Remove .*
from test. Escape the | in mi_gdb_test call.
* gdb.mi/mi-basics.exp, gdb.mi/mi-cli.exp, gdb.mi/mi-disassemble.exp,
gdb.mi/mi-pthreads.exp, gdb.mi/mi-stack.exp, gdb.mi/mi2-basics.exp,
gdb.mi/mi2-cli.exp, gdb.mi/mi2-disassemble.exp,
gdb.mi/mi2-pthreads.exp, gdb.mi/mi2-stack.exp: Add extra details to
expected regex's in mi_gdb_test calls.
* lib/mi-support.exp: Remove arbitrary .* from tests.
(mi_gdb_test): Add string_regex variable. Add anchor to main -re.
Fully anchor GDB/MI expected results in mi_gdb_test.
* lib/gdb.exp (string_to_regexp): Escape the ] character.
* gdb.base/sizeof.exp: Remove escape character. Correct test.
2005-09-27 22:39:04 +00:00
{~"#.*".*400\^done} \
2003-02-06 01:22:06 +00:00
"-interpreter-exec console \"frame 2\""
# NOTE: cagney/2003-02-03: Not yet.
# mi_gdb_test "-stack-select-frame 0" \
# {.*=selected-frame-level-changed,level="0".*\^done} \
# "-stack-select-frame 0"
mi_gdb_test "500-stack-select-frame 0" \
{500\^done} \
"-stack-select-frame 0"
2009-02-14 15:24:44 +00:00
mi_execute_to "interpreter-exec console step" "" "callee4" "" ".*basics.c" "29" \
"" "check *stopped from CLI command"
2003-02-06 01:22:06 +00:00
# NOTE: cagney/2003-02-03: Not yet.
2004-08-15 10:15:58 +00:00
# mi_gdb_test "-break-insert -t basics.c:$line_main_hello" \
2003-02-06 01:22:06 +00:00
# {.*=breakpoint-create,number="3".*\^done} \
2004-08-15 10:15:58 +00:00
# "-break-insert -t basics.c:\$line_main_hello"
mi_gdb_test "600-break-insert -t basics.c:$line_main_hello" \
2003-02-06 01:22:06 +00:00
{600\^done,bkpt=.number="3",type="breakpoint".*\}} \
2004-08-15 10:15:58 +00:00
"-break-insert -t basics.c:\$line_main_hello"
2003-02-06 01:22:06 +00:00
2008-04-15 14:33:55 +00:00
mi_execute_to "exec-continue" "breakpoint-hit" "main" "" ".*basics.c" \
$line_main_hello { "" "disp=\"del\"" } \
2008-04-05 17:12:46 +00:00
"-exec-continue to line $line_main_hello"
2003-02-06 01:22:06 +00:00
2008-04-05 17:12:46 +00:00
mi_execute_to "exec-next" "end-stepping-range" "main" "" ".*basics.c" $line_main_return "" \
"-exec-next to line $line_main_return"
2003-02-06 01:22:06 +00:00
mi_gdb_test "-interpreter-exec console \"list\"" \
2008-01-22 19:43:10 +00:00
"\~\"$line_main_return\[\\\\t ]*callme \\(1\\);\\\\n\".*\\^done" \
2004-08-15 10:15:58 +00:00
"-interpreter-exec console \"list\" at basics.c:\$line_main_return"
2003-02-06 01:22:06 +00:00
mi_gdb_test "-interpreter-exec console \"help set args\"" \
{\~"Set argument list to give program being debugged when it is started\.\\nFollow this command with any number of args, to be passed to the program\.".*\^done} \
"-interpreter-exec console \"help set args\""
# NOTE: cagney/2003-02-03: Not yet.
# mi_gdb_test "-interpreter-exec console \"set \$pc=0x0\"" \
# {.*=target-changed.*\^done} \
# "-interpreter-exec console \"set \$pc=0x0\""
mi_gdb_test "888-interpreter-exec console \"set \$pc=0x0\"" \
{888\^done} \
"-interpreter-exec console \"set \$pc=0x0\""
#mi_gdb_test "-interpreter-exec console \"\"" \
{} \
"-interpreter-exec console \"\""
mi_gdb_exit
return 0