1# Copyright 1999, 2003, 2004 Free Software Foundation, Inc. 2 3# This program is free software; you can redistribute it and/or modify 4# it under the terms of the GNU General Public License as published by 5# the Free Software Foundation; either version 2 of the License, or 6# (at your option) any later version. 7# 8# This program is distributed in the hope that it will be useful, 9# but WITHOUT ANY WARRANTY; without even the implied warranty of 10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11# GNU General Public License for more details. 12# 13# You should have received a copy of the GNU General Public License 14# along with this program; if not, write to the Free Software 15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 17# 18# Test essential Machine interface (MI) operations 19# 20# Verify that, using the MI, we can run a simple program and perform basic 21# debugging activities like: insert breakpoints, run the program, 22# step, next, continue until it ends and, last but not least, quit. 23# 24# The goal is not to test gdb functionality, which is done by other tests, 25# but to verify the correct output response to MI operations. 26# 27 28load_lib mi-support.exp 29set MIFLAGS "-i=mi" 30 31gdb_exit 32if [mi_gdb_start] { 33 continue 34} 35 36set testfile "basics" 37set srcfile ${testfile}.c 38set binfile ${objdir}/${subdir}/${testfile} 39if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { 40 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." 41} 42 43mi_delete_breakpoints 44mi_gdb_reinitialize_dir $srcdir/$subdir 45mi_gdb_load ${binfile} 46 47proc test_file_list_exec_source_file {} { 48 global srcfile 49 global srcdir 50 global subdir 51 set srcfilepath [string_to_regexp ${srcdir}/${subdir}/${srcfile}] 52 53 # get the path and absolute path to the current executable 54 # 55 # In gdb 6.2 (at least), the default line number is set by 56 # select_source_symtab to the first line of "main" minus 57 # the value of "lines_to_list" (which defaults to 10) plus one. 58 # --chastain 2004-08-13 59 60 set line_main_head [gdb_get_line_number "main ("] 61 set line_main_body [expr $line_main_head + 2] 62 set gdb_lines_to_list 10 63 set line_default [expr $line_main_body - $gdb_lines_to_list + 1] 64 65 mi_gdb_test "111-file-list-exec-source-file" \ 66 "111\\\^done,line=\"$line_default\",file=\"${srcfilepath}\",fullname=\"/.*/${srcfile}\"" \ 67 "request path info of current source file (${srcfile})" 68} 69 70proc test_file_list_exec_source_files {} { 71 global srcfile 72 73 # get the path and absolute path to the current executable 74 mi_gdb_test "222-file-list-exec-source-files" \ 75 "222\\\^done,files=\\\[\{file=\".*/${srcfile}\",fullname=\"/.*/${srcfile}\"\},\{file=\".*\"\},\{file=\".*\"\},\{file=\".*\"\},\{file=\".*\"\}\\\]" \ 76 "Getting a list of source files." 77} 78 79test_file_list_exec_source_file 80test_file_list_exec_source_files 81 82mi_gdb_exit 83return 0 84