xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.mi/mi-file.exp (revision c9055873d0546e63388f027d3d7f85381cde0545)
1# Copyright 1999-2023 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 3 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, see <http://www.gnu.org/licenses/>.
15
16# Test -file-list-exec-source-files.
17
18load_lib mi-support.exp
19set MIFLAGS "-i=mi"
20
21gdb_exit
22if [mi_gdb_start] {
23    return
24}
25
26standard_testfile basics.c
27
28if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
29     untested "failed to compile"
30     return -1
31}
32
33mi_delete_breakpoints
34mi_gdb_reinitialize_dir $srcdir/$subdir
35mi_gdb_file_cmd ${binfile}
36
37proc test_file_list_exec_source_file {} {
38    global srcfile
39    global srcdir
40    global subdir
41    global fullname_syntax
42    if { [is_remote host] } {
43	set srcfilepath ".*${srcfile}"
44    } else {
45	set srcfilepath [string_to_regexp ${srcdir}/${subdir}/${srcfile}]
46    }
47
48    # get the path and absolute path to the current executable
49    #
50    # In gdb 6.2 (at least), the default line number is set by
51    # select_source_symtab to the first line of "main" minus
52    # the value of "lines_to_list" (which defaults to 10) plus one.
53    # --chastain 2004-08-13
54
55    set line_main_head [gdb_get_line_number "main ("]
56    set line_main_body [expr $line_main_head + 2]
57    set gdb_lines_to_list 10
58    set line_default [expr $line_main_body - $gdb_lines_to_list + 1]
59
60    mi_gdb_test "111-file-list-exec-source-file" \
61	    "111\\\^done,line=\"$line_default\",file=\"${srcfilepath}\",fullname=\"$fullname_syntax${srcfile}\",macro-info=\"0\"" \
62               "request path info of current source file (${srcfile})"
63}
64
65proc test_file_list_exec_source_files {} {
66    global srcfile
67    global fullname_syntax
68
69    # get the path and absolute path to the current executable
70    mi_gdb_test "222-file-list-exec-source-files" \
71	    "222\\\^done,files=\\\[\{file=\".*${srcfile}\",fullname=\"$fullname_syntax${srcfile}\",debug-fully-read=\"\[^\"\]+\"\}.*]" \
72              "Getting a list of source files."
73}
74
75test_file_list_exec_source_file
76test_file_list_exec_source_files
77
78mi_gdb_exit
79return 0
80