* gdb.mi/mi-stack.c: New file, based on gdb.mi/basics.c.
* gdb.mi/mi-var-child.c: New file, based on gdb.mi/var-cmd.c.
* gdb.mi/mi-stack.exp: Update to use mi-stack.c as a source file.
* gdb.mi/mi-var-child.exp: Update to use mi-var-child.c as a source
file.
+2005-07-31 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * gdb.mi/basics.c, gdb.mi/var-cmd.c: Revert last change.
+ * gdb.mi/mi-stack.c: New file, based on gdb.mi/basics.c.
+ * gdb.mi/mi-var-child.c: New file, based on gdb.mi/var-cmd.c.
+ * gdb.mi/mi-stack.exp: Update to use mi-stack.c as a source file.
+ * gdb.mi/mi-var-child.exp: Update to use mi-var-child.c as a source
+ file.
+
2005-07-27 Nick Roberts <nickrob@snap.net.nz>
* gdb.mi/var-cmd.c: Give long_array in _struct_decl 12 elements.
-/* Copyright 1999, 2000, 2004, 2005
+/* Copyright 1999, 2000, 2004
Free Software Foundation, Inc.
This file is part of GDB.
int A=1;
int B=2;
int C;
- int D[3] = {0, 1 ,2};
C = A + B;
return 0;
--- /dev/null
+/* Copyright 1999, 2000, 2004, 2005
+ 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.
+
+ 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. */
+
+/*
+ * This simple program that passes different types of arguments
+ * on function calls. Useful to test printing frames, stepping, etc.
+ */
+
+#include <stdio.h>
+
+int callee4 (void)
+{
+ int A=1;
+ int B=2;
+ int C;
+ int D[3] = {0, 1, 2};
+
+ C = A + B;
+ return 0;
+}
+callee3 (char *strarg)
+{
+ callee4 ();
+}
+
+callee2 (int intarg, char *strarg)
+{
+ callee3 (strarg);
+}
+
+callee1 (int intarg, char *strarg, double fltarg)
+{
+ callee2 (intarg, strarg);
+}
+
+main ()
+{
+ callee1 (2, "A string argument.", 3.5);
+ callee1 (2, "A string argument.", 3.5);
+
+ printf ("Hello, World!");
+
+ return 0;
+}
+
+/*
+Local variables:
+change-log-default-name: "ChangeLog-mi"
+End:
+*/
+
continue
}
-set testfile "basics"
+set testfile "mi-stack"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
# -stack-info-frame
mi_gdb_test "231-stack-list-frames" \
- "231\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_callee4_body\"\},frame=\{level=\"1\",addr=\"$hex\",func=\"callee3\",.*\},frame=\{level=\"2\",addr=\"$hex\",func=\"callee2\",.*\},frame=\{level=\"3\",addr=\"$hex\",func=\"callee1\",.*\},frame=\{level=\"4\",addr=\"$hex\",func=\"main\",.*\}\\\]" \
+ "231\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"callee4\",file=\".*${srcfile}\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_callee4_body\"\},frame=\{level=\"1\",addr=\"$hex\",func=\"callee3\",.*\},frame=\{level=\"2\",addr=\"$hex\",func=\"callee2\",.*\},frame=\{level=\"3\",addr=\"$hex\",func=\"callee1\",.*\},frame=\{level=\"4\",addr=\"$hex\",func=\"main\",.*\}\\\]" \
"stack frame listing"
mi_gdb_test "232-stack-list-frames 1 1" \
"232\\^done,stack=\\\[frame=\{level=\"1\",addr=\"$hex\",func=\"callee3\",.*\}\\\]" \
"stack frame listing wrong"
mi_gdb_test "235-stack-info-frame" \
- "235\\^done,frame=\{level=\"0\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_callee4_body\"\}" \
+ "235\\^done,frame=\{level=\"0\",addr=\"$hex\",func=\"callee4\",file=\".*${srcfile}\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_callee4_body\"\}" \
"selected frame listing"
}
# step until A, B, C, D have some reasonable values.
send_gdb "-exec-next 4\n"
gdb_expect {
- -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"callee4\",args=\\\[\\\],file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_callee4_return_0\"\}\r\n$mi_gdb_prompt$" {
+ -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"callee4\",args=\\\[\\\],file=\".*${srcfile}\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_callee4_return_0\"\}\r\n$mi_gdb_prompt$" {
pass "next's in callee4"
}
timeout { fail "next in callee4 (timeout)" }
--- /dev/null
+/* Copyright 1999, 2004, 2005 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.
+
+ 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. */
+
+#include <stdlib.h>
+
+struct _simple_struct {
+ int integer;
+ unsigned int unsigned_integer;
+ char character;
+ signed char signed_character;
+ char *char_ptr;
+ int array_of_10[10];
+};
+
+typedef struct _simple_struct simpleton;
+
+simpleton global_simple;
+
+enum foo {
+ bar = 1,
+ baz
+};
+
+typedef enum foo efoo;
+
+union named_union
+{
+ int integer;
+ char *char_ptr;
+};
+
+typedef struct _struct_decl {
+ int integer;
+ char character;
+ char *char_ptr;
+ long long_int;
+ int **int_ptr_ptr;
+ long long_array[12];
+
+ void (*func_ptr) (void);
+ struct _struct_decl (*func_ptr_struct) (int, char *, long);
+ struct _struct_decl *(*func_ptr_ptr) (int, char *, long);
+ union {
+ int a;
+ char *b;
+ long c;
+ enum foo d;
+ } u1;
+
+ struct {
+ union {
+ struct {
+ int d;
+ char e[10];
+ int *(*func) (void);
+ efoo foo;
+ } u1s1;
+
+ long f;
+ struct {
+ char array_ptr[2];
+ int (*func) (int, char *);
+ } u1s2;
+ } u2;
+
+ int g;
+ char h;
+ long i[10];
+ } s2;
+} weird_struct;
+
+struct _struct_n_pointer {
+ char ****char_ptr;
+ long ****long_ptr;
+ struct _struct_n_pointer *ptrs[3];
+ struct _struct_n_pointer *next;
+};
+
+void do_locals_tests (void);
+void do_block_tests (void);
+void subroutine1 (int, long *);
+void nothing (void);
+void do_children_tests (void);
+void do_special_tests (void);
+void incr_a (char);
+
+void incr_a (char a)
+{
+ int b;
+ b = a;
+}
+
+void
+do_locals_tests ()
+{
+ int linteger;
+ int *lpinteger;
+ char lcharacter;
+ char *lpcharacter;
+ long llong;
+ long *lplong;
+ float lfloat;
+ float *lpfloat;
+ double ldouble;
+ double *lpdouble;
+ struct _simple_struct lsimple;
+ struct _simple_struct *lpsimple;
+ void (*func) (void);
+
+ /* Simple assignments */
+ linteger = 1234;
+ lpinteger = &linteger;
+ lcharacter = 'a';
+ lpcharacter = &lcharacter;
+ llong = 2121L;
+ lplong = &llong;
+ lfloat = 2.1;
+ lpfloat = &lfloat;
+ ldouble = 2.718281828459045;
+ lpdouble = &ldouble;
+ lsimple.integer = 1234;
+ lsimple.unsigned_integer = 255;
+ lsimple.character = 'a';
+ lsimple.signed_character = 21;
+ lsimple.char_ptr = &lcharacter;
+ lpsimple = &lsimple;
+ func = nothing;
+
+ /* Check pointers */
+ linteger = 4321;
+ lcharacter = 'b';
+ llong = 1212L;
+ lfloat = 1.2;
+ ldouble = 5.498548281828172;
+ lsimple.integer = 255;
+ lsimple.unsigned_integer = 4321;
+ lsimple.character = 'b';
+ lsimple.signed_character = 0;
+
+ subroutine1 (linteger, &llong);
+}
+
+void
+nothing ()
+{
+}
+
+void
+subroutine1 (int i, long *l)
+{
+ global_simple.integer = i + 3;
+ i = 212;
+ *l = 12;
+}
+
+void
+do_block_tests ()
+{
+ int cb = 12;
+
+ {
+ int foo;
+ foo = 123;
+ {
+ int foo2;
+ foo2 = 123;
+ {
+ int foo;
+ foo = 321;
+ }
+ foo2 = 0;
+ }
+ foo = 0;
+ }
+
+ cb = 21;
+}
+
+void
+do_children_tests (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;
+ long z0, *z1, **z2, ***z3;
+ long y0, *y1, **y2, ***y3;
+ long x0, *x1, **x2, ***x3;
+ int *foo;
+ int bar;
+
+ struct _struct_decl struct_declarations;
+ weird = &struct_declarations;
+
+ struct_declarations.integer = 123;
+ weird->char_ptr = "hello";
+ bar = 2121;
+ foo = &bar;
+ struct_declarations.int_ptr_ptr = &foo;
+ weird->long_array[0] = 1234;
+ struct_declarations.long_array[1] = 2345;
+ weird->long_array[2] = 3456;
+ struct_declarations.long_array[3] = 4567;
+ weird->long_array[4] = 5678;
+ struct_declarations.long_array[5] = 6789;
+ weird->long_array[6] = 7890;
+ struct_declarations.long_array[7] = 8901;
+ weird->long_array[8] = 9012;
+ struct_declarations.long_array[9] = 1234;
+
+ weird->func_ptr = nothing;
+ struct_declarations.long_array[10] = 3456;
+ struct_declarations.long_array[11] = 5678;
+
+ /* Struct/pointer/array tests */
+ a0 = '0';
+ a1 = &a0;
+ a2 = &a1;
+ a3 = &a2;
+ b0 = '1';
+ b1 = &b0;
+ b2 = &b1;
+ b3 = &b2;
+ c0 = '2';
+ c1 = &c0;
+ c2 = &c1;
+ c3 = &c2;
+ z0 = 0xdead + 0;
+ z1 = &z0;
+ z2 = &z1;
+ z3 = &z2;
+ y0 = 0xdead + 1;
+ y1 = &y0;
+ y2 = &y1;
+ y3 = &y2;
+ x0 = 0xdead + 2;
+ x1 = &x0;
+ x2 = &x1;
+ x3 = &x2;
+ snp0.char_ptr = &a3;
+ snp0.long_ptr = &z3;
+ snp0.ptrs[0] = &snp0;
+ snp0.ptrs[1] = &snp1;
+ snp0.ptrs[2] = &snp2;
+ snp0.next = &snp1;
+ snp1.char_ptr = &b3;
+ snp1.long_ptr = &y3;
+ snp1.ptrs[0] = &snp0;
+ snp1.ptrs[1] = &snp1;
+ snp1.ptrs[2] = &snp2;
+ snp1.next = &snp2;
+ snp2.char_ptr = &c3;
+ snp2.long_ptr = &x3;
+ snp2.ptrs[0] = &snp0;
+ snp2.ptrs[1] = &snp1;
+ snp2.ptrs[2] = &snp2;
+ snp2.next = 0x0;
+ psnp = &snp0;
+ snp0.char_ptr = &b3;
+ snp1.char_ptr = &c3;
+ snp2.char_ptr = &a3;
+ snp0.long_ptr = &y3;
+ snp1.long_ptr = &x3;
+ snp2.long_ptr = &z3;
+}
+
+void
+do_special_tests (void)
+{
+ union named_union u;
+ union {
+ int a;
+ char b;
+ long c;
+ } anonu;
+ struct _simple_struct s;
+ struct {
+ int a;
+ char b;
+ long c;
+ } anons;
+ enum foo e;
+ enum { A, B, C } anone;
+ int array[21];
+ int a;
+
+ a = 1;
+ incr_a(2);
+}
+
+int
+main (int argc, char *argv [])
+{
+ do_locals_tests ();
+ do_block_tests ();
+ do_children_tests ();
+ do_special_tests ();
+ exit (0);
+}
+
+
continue
}
-set testfile "var-cmd"
+set testfile "mi-var-child"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
# Step to "struct_declarations.integer = 123;"
set line_dct_123 [gdb_get_line_number "struct_declarations.integer = 123;"]
-mi_step_to do_children_tests {} {.*var-cmd.c} \
+mi_step_to do_children_tests {} ".*${srcfile}" \
$line_dct_123 "step to line \$line_dct_123"
# Test: c_variable-4.81
"update all vars. None changed"
# Step over "struct_declarations.integer = 123;"
-mi_step_to do_children_tests {} {.*var-cmd.c} \
+mi_step_to do_children_tests {} ".*${srcfile}" \
[expr $line_dct_123 + 1] "step \$line_dct_123 + 1"
# Test: c_variable-5.2
# weird->char_ptr = "hello";
# bar = 2121;
# foo = &bar;
-mi_execute_to "exec-step 3" "end-stepping-range" do_children_tests {} {.*var-cmd.c} \
+mi_execute_to "exec-step 3" "end-stepping-range" do_children_tests {} ".*${srcfile}" \
[expr $line_dct_123 + 4] {} "step \$line_dct_123 + 4"
# Test: c_variable-5.3
"update all vars struct_declarations.char_ptr"
# Step over "struct_declarations.int_ptr_ptr = &foo;"
-mi_step_to do_children_tests {} {.*var-cmd.c} \
+mi_step_to do_children_tests {} ".*${srcfile}" \
[expr $line_dct_123 + 5] "step \$line_dct_123 + 5"
# Test: c_variable-5.4
"update all vars int_ptr_ptr and children changed"
# Step over "weird->long_array[0] = 1234;"
-mi_step_to do_children_tests {} {.*var-cmd.c} \
+mi_step_to do_children_tests {} ".*${srcfile}" \
[expr $line_dct_123 + 6] "step \$line_dct_123 + 6"
# Test: c_variable-5.5
"update all vars struct_declarations.long_array.0 changed"
# Step over "struct_declarations.long_array[1] = 2345;"
-mi_step_to do_children_tests {} {.*var-cmd.c} \
+mi_step_to do_children_tests {} ".*${srcfile}" \
[expr $line_dct_123 + 7] "step \$line_dct_123 + 7"
# Test: c_variable-5.6
"update all vars struct_declarations.long_array.1 changed"
# Step over "weird->long_array[2] = 3456;"
-mi_step_to do_children_tests {} {.*var-cmd.c} \
+mi_step_to do_children_tests {} ".*${srcfile}" \
[expr $line_dct_123 + 8] "step \$line_dct_123 + 8"
# Test: c_variable-5.7
# struct_declarations.long_array[9] = 1234;
set line_dct_nothing [gdb_get_line_number "weird->func_ptr = nothing;"]
-mi_execute_to "exec-step 7" "end-stepping-range" do_children_tests {} {.*var-cmd.c} \
+mi_execute_to "exec-step 7" "end-stepping-range" do_children_tests {} ".*${srcfile}" \
$line_dct_nothing {} "step \$line_dct_nothing"
# Test: c_variable-5.8
# Step over "weird->func_ptr = nothing";
-mi_step_to do_children_tests {} {.*var-cmd.c} \
+mi_step_to do_children_tests {} ".*${srcfile}" \
[expr $line_dct_nothing + 1] "step \$line_dct_nothing + 1"
# Test: c_variable-5.9
"update all vars struct_declarations.func_ptr changed"
# Step over "struct_declarations.long_array[10] = 3456";
-mi_step_to do_children_tests {} {.*var-cmd.c} \
+mi_step_to do_children_tests {} ".*${srcfile}" \
[expr $line_dct_nothing + 2] "step \$line_dct_nothing + 2"
mi_gdb_test "-var-update --no-values *" \
# Step over "struct_declarations.long_array[11] = 5678";
set line_dct_a0_0 [gdb_get_line_number "a0 = '0';"]
-mi_step_to do_children_tests {} {.*var-cmd.c} \
+mi_step_to do_children_tests {} ".*${srcfile}" \
$line_dct_a0_0 "step \$line_dct_a0_0"
mi_gdb_test "-var-update --all-values *" \
# psnp = &snp0;
set line_dct_snp0 [gdb_get_line_number "psnp = &snp0;"]
-mi_execute_to "exec-step 43" "end-stepping-range" do_children_tests {} {.*var-cmd.c} \
+mi_execute_to "exec-step 43" "end-stepping-range" do_children_tests {} ".*${srcfile}" \
[expr $line_dct_snp0 + 1] {} "step \$line_dct_snp0 + 1"
# Test: c_variable-5.10
"get children of psnp->ptrs.0.next.next.ptrs"
# Step over "snp0.char_ptr = &b3;"
-mi_step_to do_children_tests {} {.*var-cmd.c} \
+mi_step_to do_children_tests {} ".*${srcfile}" \
[expr $line_dct_snp0 + 2] "step \$line_dct_snp0 + 2"
# Test: c_variable-5.47
"update all vars psnp->char_ptr (and 0.char_ptr) changed"
# Step over "snp1.char_ptr = &c3;"
-mi_step_to do_children_tests {} {.*var-cmd.c} \
+mi_step_to do_children_tests {} ".*${srcfile}" \
[expr $line_dct_snp0 + 3] "step \$line_dct_snp0 + 3"
# Test: c_variable-5.48
# Step over "snp2.char_ptr = &a3;"
-mi_step_to do_children_tests {} {.*var-cmd.c} \
+mi_step_to do_children_tests {} ".*${srcfile}" \
[expr $line_dct_snp0 + 4] "step \$line_dct_snp0 + 4"
# Test: c_variable-5.49
# Step over "snp0.long_ptr = &y3;"
-mi_step_to do_children_tests {} {.*var-cmd.c} \
+mi_step_to do_children_tests {} ".*${srcfile}" \
[expr $line_dct_snp0 + 5] "step \$line_dct_snp0 + 5"
# Test: c_variable-5.50
# Step over "snp1.long_ptr = &x3;"
-mi_step_to do_children_tests {} {.*var-cmd.c} \
+mi_step_to do_children_tests {} ".*${srcfile}" \
[expr $line_dct_snp0 + 6] "step \$line_dct_snp0 + 6"
# Test: c_variable-5.51
#
# Step over "snp2.long_ptr = &z3;"
-mi_step_to do_children_tests {} {.*var-cmd.c} \
+mi_step_to do_children_tests {} ".*${srcfile}" \
[expr $line_dct_snp0 + 7] "step \$line_dct_snp0 + 7"
# Test: c_variable-5.52
-/* Copyright 1999, 2004, 2005 Free Software Foundation, Inc.
+/* Copyright 1999, 2004 Free Software Foundation, Inc.
This file is part of GDB.
char *char_ptr;
long long_int;
int **int_ptr_ptr;
- long long_array[12];
+ long long_array[10];
void (*func_ptr) (void);
struct _struct_decl (*func_ptr_struct) (int, char *, long);
struct_declarations.long_array[9] = 1234;
weird->func_ptr = nothing;
- struct_declarations.long_array[10] = 3456;
- struct_declarations.long_array[11] = 5678;
/* Struct/pointer/array tests */
a0 = '0';