-/* Copyright 1999 Free Software Foundation, Inc.
+/* Copyright 1999, 2004, 2007 Free Software Foundation, Inc.
This file is part of GDB.
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 2 of the License, or (at
- your option) any later version.
+ 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.
+ 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, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <stdlib.h>
struct _simple_struct {
int integer;
b = a;
}
+int array[] = {1,2,3};
+int array2[] = {4,5,6};
+int *array_ptr = array;
+
void
do_locals_tests ()
{
- int linteger;
- int *lpinteger;
- char lcharacter;
- char *lpcharacter;
- long llong;
- long *lplong;
- float lfloat;
- float *lpfloat;
- double ldouble;
- double *lpdouble;
+ int linteger = 0;
+ int *lpinteger = 0;
+ char lcharacter = 0;
+ char *lpcharacter = 0;
+ long llong = 0;
+ long *lplong = 0;
+ float lfloat = 0;
+ float *lpfloat = 0;
+ double ldouble = 0;
+ double *lpdouble = 0;
struct _simple_struct lsimple;
struct _simple_struct *lpsimple;
void (*func) (void);
weird_struct *weird;
struct _struct_n_pointer *psnp;
struct _struct_n_pointer snp0, snp1, snp2;
- char a0, *a1, **a2, ***a3;
- char b0, *b1, **b2, ***b3;
- char c0, *c1, **c2, ***c3;
+ char a0[2] = {}, *a1, **a2, ***a3;
+ char b0[2] = {}, *b1, **b2, ***b3;
+ char c0[2] = {}, *c1, **c2, ***c3;
long z0, *z1, **z2, ***z3;
long y0, *y1, **y2, ***y3;
long x0, *x1, **x2, ***x3;
weird->func_ptr = nothing;
/* Struct/pointer/array tests */
- a0 = '0';
- a1 = &a0;
+ a0[0] = '0';
+ a1 = a0;
a2 = &a1;
a3 = &a2;
- b0 = '1';
- b1 = &b0;
+ b0[0] = '1';
+ b1 = b0;
b2 = &b1;
b3 = &b2;
- c0 = '2';
- c1 = &c0;
+ c0[0] = '2';
+ c1 = c0;
c2 = &c1;
c3 = &c2;
z0 = 0xdead + 0;
snp0.long_ptr = &y3;
snp1.long_ptr = &x3;
snp2.long_ptr = &z3;
+ {int a = 0;}
}
void
int a;
a = 1;
+ u.integer = a;
+ anonu.a = a;
+ s.integer = a;
+ anons.a = a;
+ e = bar;
+ anone = A;
incr_a(2);
}
+void do_frozen_tests ()
+{
+ /*: BEGIN: frozen :*/
+ struct {
+ int i;
+ struct {
+ int j;
+ int k;
+ } nested;
+ } v1 = {1, {2, 3}};
+
+ int v2 = 4;
+ /*:
+ mi_create_varobj V1 v1 "create varobj for v1"
+ mi_create_varobj V2 v2 "create varobj for v2"
+
+ mi_list_varobj_children "V1" {
+ {"V1.i" "i" "0" "int"}
+ {"V1.nested" "nested" "2" "struct {...}"}
+ } "list children of v1"
+
+ mi_list_varobj_children "V1.nested" {
+ {"V1.nested.j" "j" "0" "int"}
+ {"V1.nested.k" "k" "0" "int"}
+ } "list children of v1.nested"
+
+ mi_check_varobj_value V1.i 1 "check V1.i: 1"
+ mi_check_varobj_value V1.nested.j 2 "check V1.nested.j: 2"
+ mi_check_varobj_value V1.nested.k 3 "check V1.nested.k: 3"
+ mi_check_varobj_value V2 4 "check V2: 4"
+ :*/
+ v2 = 5;
+ /*:
+ mi_varobj_update * {V2} "update varobjs: V2 changed"
+ set_frozen V2 1
+ :*/
+ v2 = 6;
+ /*:
+ mi_varobj_update * {} "update varobjs: nothing changed"
+ mi_check_varobj_value V2 5 "check V2: 5"
+ mi_varobj_update V2 {V2} "update V2 explicitly"
+ mi_check_varobj_value V2 6 "check V2: 6"
+ :*/
+ v1.i = 7;
+ v1.nested.j = 8;
+ v1.nested.k = 9;
+ /*:
+ set_frozen V1 1
+ mi_varobj_update * {} "update varobjs: nothing changed"
+ mi_check_varobj_value V1.i 1 "check V1.i: 1"
+ mi_check_varobj_value V1.nested.j 2 "check V1.nested.j: 2"
+ mi_check_varobj_value V1.nested.k 3 "check V1.nested.k: 3"
+ # Check that explicit update for elements of structures
+ # works.
+ # Update v1.j
+ mi_varobj_update V1.nested.j {V1.nested.j} "update V1.nested.j"
+ mi_check_varobj_value V1.i 1 "check V1.i: 1"
+ mi_check_varobj_value V1.nested.j 8 "check V1.nested.j: 8"
+ mi_check_varobj_value V1.nested.k 3 "check V1.nested.k: 3"
+ # Update v1.nested, check that children is updated.
+ mi_varobj_update V1.nested {V1.nested.k} "update V1.nested"
+ mi_check_varobj_value V1.i 1 "check V1.i: 1"
+ mi_check_varobj_value V1.nested.j 8 "check V1.nested.j: 8"
+ mi_check_varobj_value V1.nested.k 9 "check V1.nested.k: 9"
+ # Update v1.i
+ mi_varobj_update V1.i {V1.i} "update V1.i"
+ mi_check_varobj_value V1.i 7 "check V1.i: 7"
+ :*/
+ v1.i = 10;
+ v1.nested.j = 11;
+ v1.nested.k = 12;
+ /*:
+ # Check that unfreeze itself does not updates the values.
+ set_frozen V1 0
+ mi_check_varobj_value V1.i 7 "check V1.i: 7"
+ mi_check_varobj_value V1.nested.j 8 "check V1.nested.j: 8"
+ mi_check_varobj_value V1.nested.k 9 "check V1.nested.k: 9"
+ mi_varobj_update V1 {V1.i V1.nested.j V1.nested.k} "update V1"
+ mi_check_varobj_value V1.i 10 "check V1.i: 10"
+ mi_check_varobj_value V1.nested.j 11 "check V1.nested.j: 11"
+ mi_check_varobj_value V1.nested.k 12 "check V1.nested.k: 12"
+ :*/
+
+ /*: END: frozen :*/
+}
+
int
main (int argc, char *argv [])
{
do_block_tests ();
do_children_tests ();
do_special_tests ();
+ do_frozen_tests ();
exit (0);
}