diff options
Diffstat (limited to 'gdb/testsuite/gdb.python')
-rw-r--r-- | gdb/testsuite/gdb.python/py-type.c | 9 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-type.exp | 9 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-value-cc.cc | 23 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-value-cc.exp | 20 |
4 files changed, 61 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.python/py-type.c b/gdb/testsuite/gdb.python/py-type.c index 7cee383..697e29c 100644 --- a/gdb/testsuite/gdb.python/py-type.c +++ b/gdb/testsuite/gdb.python/py-type.c @@ -21,6 +21,12 @@ struct s int b; }; +struct SS +{ + union { int x; char y; }; + union { int a; char b; }; +}; + typedef struct s TS; TS ts; @@ -58,6 +64,7 @@ main () { int ar[2] = {1,2}; struct s st; + struct SS ss; #ifdef __cplusplus C c; c.c = 1; @@ -72,6 +79,8 @@ main () st.b = 5; e = v2; + + ss.x = 100; return 0; /* break to inspect struct and array. */ } diff --git a/gdb/testsuite/gdb.python/py-type.exp b/gdb/testsuite/gdb.python/py-type.exp index 93301d0..6b61f48 100644 --- a/gdb/testsuite/gdb.python/py-type.exp +++ b/gdb/testsuite/gdb.python/py-type.exp @@ -85,6 +85,15 @@ proc test_fields {lang} { gdb_test "python print (fields\[0\].name)" "a" "Check structure field a name" gdb_test "python print (fields\[1\].name)" "b" "Check structure field b name" + # Test that unamed fields have 'None' for name. + gdb_py_test_silent_cmd "python ss = gdb.parse_and_eval('ss')" "init ss" 1 + gdb_py_test_silent_cmd "python ss_fields = ss.type.fields()" \ + "get fields from ss.type" 1 + gdb_test "python print len(ss_fields)" "2" "Check length of ss_fields" + gdb_test "python print ss_fields\[0\].name is None" "True" \ + "Check ss_fields\[0\].name" + gdb_test "python print ss_fields\[1\].name is None" "True" \ + "Check ss_fields\[1\].name" # Regression test for # http://sourceware.org/bugzilla/show_bug.cgi?id=12070. gdb_test "python print ('type' in dir(fields\[0\]))" "True" \ diff --git a/gdb/testsuite/gdb.python/py-value-cc.cc b/gdb/testsuite/gdb.python/py-value-cc.cc index 59f1dec..ace957a 100644 --- a/gdb/testsuite/gdb.python/py-value-cc.cc +++ b/gdb/testsuite/gdb.python/py-value-cc.cc @@ -30,8 +30,21 @@ class B : public A { char a; }; +struct X +{ + union { int x; char y; }; + union { int a; char b; }; +}; + +union UU +{ + union { int x; char y; }; + union { int a; char b; }; +}; + typedef B Btd; typedef int *int_ptr; +typedef X Xtd; int func (const A &a) @@ -57,6 +70,16 @@ func (const A &a) U u; u.a = 99; + X x; + x.x = 101; + x.a = 102; + + UU uu; + uu.x = 1000; + + X *x_ptr = &x; + Xtd *xtd = &x; + return 0; /* Break here. */ } diff --git a/gdb/testsuite/gdb.python/py-value-cc.exp b/gdb/testsuite/gdb.python/py-value-cc.exp index 1faec5f..e6351f6 100644 --- a/gdb/testsuite/gdb.python/py-value-cc.exp +++ b/gdb/testsuite/gdb.python/py-value-cc.exp @@ -53,6 +53,14 @@ gdb_test_no_output "python b_ref = gdb.parse_and_eval('b_ref')" "init b_ref" gdb_test_no_output "python b_td = gdb.parse_and_eval('b_td')" "init b_td" gdb_test_no_output "python u = gdb.parse_and_eval('u')" "init u" gdb_test_no_output "python u_fields = u.type.fields()" "init u_fields" +gdb_test_no_output "python x = gdb.parse_and_eval('x')" "init x" +gdb_test_no_output "python x_fields = x.type.fields()" "init x_fields" +gdb_test_no_output "python uu = gdb.parse_and_eval('uu')" "init uu" +gdb_test_no_output "python uu_fields = uu.type.fields()" "init uu_fields" +gdb_test_no_output "python x_ptr = gdb.parse_and_eval('x_ptr')" "init x_ptr" +gdb_test_no_output "python xtd = gdb.parse_and_eval('xtd')" "init xtd" + +gdb_test "python print(b\[b_fields\[1\]\])" "97 'a'" "b.a via field" gdb_test "python print(b\[b_fields\[1\]\])" "97 'a'" "b.a via field" gdb_test "python print(b\[b_fields\[0\]\].type)" "A" \ @@ -79,3 +87,15 @@ gdb_test "python print(b_td\[b_fields\[0\]\]\['a'\])" "100" \ gdb_test "python print(u\[u_fields\[0\]\])" "99.*" "u's first field via field" gdb_test "python print(u\[u_fields\[1\]\])" "99.*" "u's second field via field" + +gdb_test "python print len(x_fields)" "2" "number for fields in u" +gdb_test "python print x\[x_fields\[0\]\]\['x'\]" "101" "x.x via field" +gdb_test "python print x\[x_fields\[1\]\]\['a'\]" "102" "x.a via field" +gdb_test "python print x_ptr\[x_fields\[0\]\]\['x'\]" "101" "x_ptr->x via field" +gdb_test "python print x_ptr\[x_fields\[1\]\]\['a'\]" "102" "x_ptr->a via field" +gdb_test "python print xtd\[x_fields\[0\]\]\['x'\]" "101" "xtd->x via field" +gdb_test "python print xtd\[x_fields\[1\]\]\['a'\]" "102" "xtd->a via field" + +gdb_test "python print len(uu_fields)" "2" "number of fields in uu" +gdb_test "python print uu\[uu_fields\[0\]\]\['x'\]" "1000" "uu.x via field" +gdb_test "python print uu\[uu_fields\[1\]\]\['a'\]" "1000" "uu.a via field" |