aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.python
diff options
context:
space:
mode:
authorThiago Jung Bauermann <bauerman@br.ibm.com>2009-02-04 21:55:40 +0000
committerThiago Jung Bauermann <bauerman@br.ibm.com>2009-02-04 21:55:40 +0000
commit08c637dee28a25da97418745fbebb26b2fba8eef (patch)
tree7d7d670deff8204aa4f5deb9152b739b91e0ef53 /gdb/testsuite/gdb.python
parent20261af84c27478a2333f573702ba2b6e4a8b038 (diff)
downloadgdb-08c637dee28a25da97418745fbebb26b2fba8eef.zip
gdb-08c637dee28a25da97418745fbebb26b2fba8eef.tar.gz
gdb-08c637dee28a25da97418745fbebb26b2fba8eef.tar.bz2
gdb/
2009-02-04 Tom Tromey <tromey@redhat.com> Thiago Jung Bauermann <bauerman@br.ibm.com> Phil Muldoon <pmuldoon@redhat.com> * python/python-internal.h (gdbpy_get_value_from_history): Rename prototype to gdbpy_history. (gdbpy_is_string): Declare. (python_string_to_host_string): Declare. * python/python-utils.c (gdbpy_is_string): New function. (unicode_to_encoded_string): New function. (unicode_to_target_string): Use it. (python_string_to_host_string): New function. * python/python-value.c (valpy_address): New function. (convert_value_from_python): Use gdbpy_is_string. Change to throw Python exception instead of a GDB exception on error. Properly check Python booleans. (valpy_getitem): Convert field name to host string. Handle array accesses. Adapt to new behaviour of convert_value_from_python. (valpy_new): Adapt to new behaviour of convert_value_from_python. (enum valpy_opcode) <VALPY_LSH, VALPY_RSH, VALPY_BITAND, VALPY_BITXOR, VALPY_BITOR>: New constants. (valpy_binop): Update. Adapt to new behaviour of convert_value_from_python. (valpy_invert): New function. (valpy_lsh): Likewise. (valpy_rsh): Likewise. (valpy_and): Likewise. (valpy_or): Likewise. (valpy_xor): Likewise. (valpy_richcompare): Call convert_value_from_python instead of doing conversions itself. (is_intlike, valpy_int, valpy_long, valpy_float): New functions. (gdbpy_get_value_from_history): Rename function to gdbpy_history. (gdbpy_initialize_values): Don't set tp_new. (value_object_type): Add valpy_new. (value_object_methods): Add `address' entry. (value_object_as_number): Update for new methods. * python/python.c (GdbMethods): Rename entry from `get_value_from_history' to `history'. gdb/doc/ 2009-02-04 Tom Tromey <tromey@redhat.com> * gdb.texinfo (Basic Python): Document gdb.history. gdb/testsuite/ 2009-02-04 Tom Tromey <tromey@redhat.com> Thiago Jung Bauermann <bauerman@br.ibm.com> * gdb.python/python-value.exp: Use `gdb.history' instead of `gdb.value_from_history'. (test_value_numeric_ops): Add test for conversion of enum constant. * gdb.python/python-value.c (enum e): New type. (evalue): New global. (main): Use argv.
Diffstat (limited to 'gdb/testsuite/gdb.python')
-rw-r--r--gdb/testsuite/gdb.python/python-value.c10
-rw-r--r--gdb/testsuite/gdb.python/python-value.exp13
2 files changed, 19 insertions, 4 deletions
diff --git a/gdb/testsuite/gdb.python/python-value.c b/gdb/testsuite/gdb.python/python-value.c
index 8c10956..17e5c62 100644
--- a/gdb/testsuite/gdb.python/python-value.c
+++ b/gdb/testsuite/gdb.python/python-value.c
@@ -27,6 +27,14 @@ union u
float b;
};
+enum e
+ {
+ ONE = 1,
+ TWO = 2
+ };
+
+enum e evalue = TWO;
+
int
main (int argc, char *argv[])
{
@@ -37,5 +45,7 @@ main (int argc, char *argv[])
s.b = 5;
u.a = 7;
+ argv[0][0] = 'a'; /* Just to avoid getting argv optimized out. */
+
return 0; /* break to inspect struct and union */
}
diff --git a/gdb/testsuite/gdb.python/python-value.exp b/gdb/testsuite/gdb.python/python-value.exp
index 2057e61..8f5e0ab 100644
--- a/gdb/testsuite/gdb.python/python-value.exp
+++ b/gdb/testsuite/gdb.python/python-value.exp
@@ -111,13 +111,18 @@ proc test_value_numeric_ops {} {
gdb_test "python print 'result = ' + str(1-i)" " = -4" "subtract python integer from integer value"
gdb_test "python print 'result = ' + str(1.5+f)" " = 2.75" "add python float with double value"
+ # Conversion test.
+ gdb_test "print evalue" " = TWO"
+ gdb_test "python evalue = gdb.history (0)" ""
+ gdb_test "python print int (evalue)" "2"
+
# Test pointer arithmethic
# First, obtain the pointers
gdb_test "print (void *) 2" "" ""
- gdb_test "python a = gdb.get_value_from_history (0)" "" ""
+ gdb_test "python a = gdb.history (0)" "" ""
gdb_test "print (void *) 5" "" ""
- gdb_test "python b = gdb.get_value_from_history (0)" "" ""
+ gdb_test "python b = gdb.history (0)" "" ""
gdb_test "python print 'result = ' + str(a+5)" " = 0x7" "add pointer value with python integer"
gdb_test "python print 'result = ' + str(b-2)" " = 0x3" "subtract python integer from pointer value"
@@ -205,7 +210,7 @@ proc test_value_in_inferior {} {
# Just get inferior variable s in the value history, available to python.
gdb_test "print s" " = {a = 3, b = 5}" ""
- gdb_py_test_silent_cmd "python s = gdb.get_value_from_history (0)" "get value from history" 1
+ gdb_py_test_silent_cmd "python s = gdb.history (0)" "get value from history" 1
gdb_test "python print 'result = ' + str(s\['a'\])" " = 3" "access element inside struct using 8-bit string name"
gdb_test "python print 'result = ' + str(s\[u'a'\])" " = 3" "access element inside struct using unicode name"
@@ -215,7 +220,7 @@ proc test_value_in_inferior {} {
# Just get inferior variable argv the value history, available to python.
gdb_test "print argv" " = \\(char \\*\\*\\) 0x.*" ""
- gdb_py_test_silent_cmd "python argv = gdb.get_value_from_history (0)" "" 0
+ gdb_py_test_silent_cmd "python argv = gdb.history (0)" "" 0
gdb_py_test_silent_cmd "python arg0 = argv.dereference ()" "dereference value" 1
# Check that the dereferenced value is sane