@ -77,6 +77,21 @@ proc test_fields {lang} {
gdb_test "python print (c.type == gdb.parse_and_eval('d').type)" "False"
gdb_test "python print (c.type == gdb.parse_and_eval('d').type.fields()\[0\].type)" \
"True"
# Test fields of a method (its parameters)
gdb_test "python print (len (gdb.parse_and_eval ('C::a_method').type.fields ()))" "3"
gdb_test "python print (gdb.parse_and_eval ('C::a_method').type.fields ()\[0\].type)" "C \\* const"
gdb_test "python print (gdb.parse_and_eval ('C::a_method').type.fields ()\[1\].type)" "int"
gdb_test "python print (gdb.parse_and_eval ('C::a_method').type.fields ()\[2\].type)" "char"
gdb_test "python print (len (gdb.parse_and_eval ('C::a_const_method').type.fields ()))" "3"
gdb_test "python print (gdb.parse_and_eval ('C::a_const_method').type.fields ()\[0\].type)" "const C \\* const"
gdb_test "python print (gdb.parse_and_eval ('C::a_const_method').type.fields ()\[1\].type)" "int"
gdb_test "python print (gdb.parse_and_eval ('C::a_const_method').type.fields ()\[2\].type)" "char"
gdb_test "python print (len (gdb.parse_and_eval ('C::a_static_method').type.fields ()))" "2"
gdb_test "python print (gdb.parse_and_eval ('C::a_static_method').type.fields ()\[0\].type)" "int"
gdb_test "python print (gdb.parse_and_eval ('C::a_static_method').type.fields ()\[1\].type)" "char"
}
# Test normal fields usage in structs.
@ -111,10 +126,10 @@ proc test_fields {lang} {
gdb_test "python print (not not st.type)" "True" "Check conversion to bool"
# Test rejection of mapping operations on scalar types
gdb_test "python print (len (st.type\['a'\].type))" "TypeError: Type is not a structure, union, or enum type.*"
gdb_test "python print (st.type\['a'\].type.has_key ('x'))" "TypeError: Type is not a structure, union, or enum type.*"
gdb_test "python print (st.type\['a'\].type.keys () )" "TypeError: Type is not a structure, union, or enum type.*"
gdb_test "python print (st.type\['a'\].type\['x'\] )" "TypeError: Type is not a structure, union, or enum type.*"
gdb_test "python print (len (st.type\['a'\].type))" "TypeError: Type is not a structure, union, enum, or function type.*"
gdb_test "python print (st.type\['a'\].type.has_key ('x'))" "TypeError: Type is not a structure, union, enum, or function type.*"
gdb_test "python print (st.type\['a'\].type\['x'\] )" "TypeError: Type is not a structure, union, enum, or function type.*"
gdb_test "python print (st.type\['a'\].type.keys () )" "TypeError: Type is not a structure, union, enum, or function type.*"
# Test conversion to bool on scalar types
gdb_test "python print (not not st.type\['a'\].type)" "True"
@ -150,6 +165,11 @@ proc test_fields {lang} {
gdb_test "python print (vec1 == vec2)" "True"
gdb_py_test_silent_cmd "python vec3 = vec_data_2.cast(ar\[0\].type.vector(1))" "set vec3" 1
gdb_test "python print (vec1 == vec3)" "False"
# Test fields of a function (its parameters)
gdb_test "python print (len (gdb.parse_and_eval ('a_function').type.fields ()))" "2"
gdb_test "python print (gdb.parse_and_eval ('a_function').type.fields ()\[0\].type)" "int"
gdb_test "python print (gdb.parse_and_eval ('a_function').type.fields ()\[1\].type)" "char"
}
}