13125Sdg# Copyright 2005, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
23125Sdg
33125Sdg# This program is free software; you can redistribute it and/or modify
43125Sdg# it under the terms of the GNU General Public License as published by
53125Sdg# the Free Software Foundation; either version 3 of the License, or
63125Sdg# (at your option) any later version.
73125Sdg#
83125Sdg# This program is distributed in the hope that it will be useful,
93125Sdg# but WITHOUT ANY WARRANTY; without even the implied warranty of
103125Sdg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
113125Sdg# GNU General Public License for more details.
123125Sdg#
133125Sdg# You should have received a copy of the GNU General Public License
143125Sdg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
153125Sdg
163125Sdg# This file is part of the gdb testsuite.  It is intended to test that
173125Sdg# gdb can correctly print arrays with indexes for each element of the
183125Sdg# array.
193125Sdg
203125Sdgif $tracelevel {
213125Sdg    strace $tracelevel
223125Sdg}
233125Sdg
243125Sdgset testfile "arrayidx"
253125Sdgset srcfile ${testfile}.c
263125Sdgset binfile ${objdir}/${subdir}/${testfile}
273125Sdgif { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
283125Sdg    untested "Couldn't compile ${srcfile}"
293125Sdg    return -1
303125Sdg}
313125Sdg
328857Srgrimesgdb_exit
333125Sdggdb_start
343125Sdggdb_reinitialize_dir $srcdir/$subdir
353125Sdggdb_load ${binfile}
363125Sdg
373125Sdgif ![runto_main] then {
383125Sdg    perror "couldn't run to breakpoint"
393125Sdg    continue
403125Sdg}
413125Sdg
423125Sdg# First, print the array without the indexes
433125Sdg
443125Sdggdb_test_no_output "set print array-indexes off" \
453125Sdg         "Set print array-indexes to off"
463125Sdg
473125Sdggdb_test "print array" \
483125Sdg         "\\{1, 2, 3, 4\\}" \
493125Sdg         "Print array with array-indexes off"
503125Sdg
513125Sdg# Second, print the same array with the indexes
523125Sdg
533125Sdggdb_test_no_output "set print array-indexes on" \
543125Sdg         "Set print array-indexes to on"
553125Sdg
563125Sdggdb_test "print array" \
573125Sdg         "\\{\\\[0\\\] = 1, \\\[1\\\] = 2, \\\[2\\\] = 3, \\\[3\\\] = 4\\}" \
583125Sdg         "Print array with array-indexes on"
593125Sdg
603125Sdg
613125Sdg