diff options
author | Tom Tromey <tromey@redhat.com> | 2010-11-12 20:49:43 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2010-11-12 20:49:43 +0000 |
commit | 621c83642d17cf523c20f55f2ed945a7ec95ea6a (patch) | |
tree | 231cb6bb882e72fb68d6a5eb189060af43bb0dad /gdb/testsuite/gdb.python | |
parent | f1b9e6e7ee6f55dd82194417e8f4d1713783ef39 (diff) | |
download | gdb-621c83642d17cf523c20f55f2ed945a7ec95ea6a.zip gdb-621c83642d17cf523c20f55f2ed945a7ec95ea6a.tar.gz gdb-621c83642d17cf523c20f55f2ed945a7ec95ea6a.tar.bz2 |
gdb
* varobj.c (value_get_print_value): Rearrange. Pass stream to
apply_varobj_pretty_printer.
* c-lang.c: Include exceptions.h.
(c_get_string): Throw MEMORY_ERROR when appropriate.
* python/py-prettyprint.c (enum string_repr_result): New.
(print_stack_unless_memory_error): New function.
(print_string_repr): Change return type. Use
print_stack_unless_memory_error.
(print_children): Use print_stack_unless_memory_error.
(apply_val_pretty_printer): Update. Don't print children if
string representation threw an exception.
(apply_varobj_pretty_printer): Add 'stream' argument. Use
print_stack_unless_memory_error.
* python/python.c (gdbpy_gdb_error, gdbpy_gdb_memory_error): New
globals.
(_initialize_python): Initialize them.
* python/python-internal.h (GDB_PY_HANDLE_EXCEPTION): Use
gdbpy_convert_exception.
(GDB_PY_SET_HANDLE_EXCEPTION): Likewise.
(gdbpy_gdb_error, gdbpy_gdb_memory_error): Declare.
(gdbpy_convert_exception): Declare.
(apply_varobj_pretty_printer): Update.
* python/py-utils.c (gdbpy_convert_exception): New function.
gdb/doc
* gdb.texinfo (Basic Python): Update. Add xref.
(Exception Handling): Document new exception classes.
(Types In Python): Update.
(Frames In Python): Update.
gdb/testsuite
* gdb.python/py-prettyprint.c (main): Add new 'ns2' local.
* gdb.python/py-prettyprint.exp (run_lang_tests): Add test for
MemoryError.
* gdb.python/python.exp (gdb_py_test_multiple): Update exception
type.
* gdb.python/py-value.exp (test_value_in_inferior): Add test for
MemoryError.
(test_subscript_regression): Update exception type.
Diffstat (limited to 'gdb/testsuite/gdb.python')
-rw-r--r-- | gdb/testsuite/gdb.python/py-prettyprint.c | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-prettyprint.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-value.exp | 7 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/python.exp | 4 |
4 files changed, 14 insertions, 5 deletions
diff --git a/gdb/testsuite/gdb.python/py-prettyprint.c b/gdb/testsuite/gdb.python/py-prettyprint.c index b633111..23e3ff9 100644 --- a/gdb/testsuite/gdb.python/py-prettyprint.c +++ b/gdb/testsuite/gdb.python/py-prettyprint.c @@ -213,7 +213,7 @@ main () /* Clearing by being `static' could invoke an other GDB C++ bug. */ struct nullstr nullstr; nostring_type nstype; - struct ns ns; + struct ns ns, ns2; struct lazystring estring, estring2; nstype.elements = narray; @@ -231,6 +231,10 @@ main () ns.null_str = "embedded\0null\0string"; ns.length = 20; + /* Make a "corrupted" string. */ + ns2.null_str = NULL; + ns2.length = 20; + estring.lazy_str = "embedded x\201\202\203\204" ; /* Incomplete UTF-8, but ok Latin-1. */ diff --git a/gdb/testsuite/gdb.python/py-prettyprint.exp b/gdb/testsuite/gdb.python/py-prettyprint.exp index b8f37d3..7eda415 100644 --- a/gdb/testsuite/gdb.python/py-prettyprint.exp +++ b/gdb/testsuite/gdb.python/py-prettyprint.exp @@ -87,6 +87,8 @@ proc run_lang_tests {lang} { gdb_py_test_silent_cmd "set print elements 200" "" 1 } + gdb_test "print ns2" ".error reading variable: Address 0x0 out of bounds." + gdb_test "print x" " = \"this is x\"" gdb_test "print cstring" " = \"const string\"" diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp index 895969b..9bee1c0 100644 --- a/gdb/testsuite/gdb.python/py-value.exp +++ b/gdb/testsuite/gdb.python/py-value.exp @@ -210,6 +210,9 @@ proc test_value_in_inferior {} { # Test address attribute gdb_test "python print 'result =', arg0.address" "= 0x\[\[:xdigit:\]\]+" "Test address attribute" + # Test memory error. + gdb_test "python print gdb.parse_and_eval('*(int*)0')" "gdb.MemoryError: Cannot access memory at address 0x0.*" + # Test string fetches, both partial and whole. gdb_test "print st" "\"divide et impera\"" gdb_py_test_silent_cmd "python st = gdb.history (0)" "get value from history" 1 @@ -371,7 +374,7 @@ proc test_subscript_regression {lang} { # Try to access an int with a subscript. This should fail. gdb_test "python print intv" "1" "Baseline print of a Python value" - gdb_test "python print intv\[0\]" "RuntimeError: Cannot subscript requested type.*" \ + gdb_test "python print intv\[0\]" "gdb.error: Cannot subscript requested type.*" \ "Attempt to access an integer with a subscript" # Try to access a string with a subscript. This should pass. @@ -386,7 +389,7 @@ proc test_subscript_regression {lang} { # Try to access a single dimension array with a subscript to the # result. This should fail. - gdb_test "python print pointer\[intv\]\[0\]" "RuntimeError: Cannot subscript requested type.*" \ + gdb_test "python print pointer\[intv\]\[0\]" "gdb.error: Cannot subscript requested type.*" \ "Attempt to access an integer with a subscript" # Lastly, test subscript access to an array with multiple diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp index 301245b..dd9175a 100644 --- a/gdb/testsuite/gdb.python/python.exp +++ b/gdb/testsuite/gdb.python/python.exp @@ -160,7 +160,7 @@ runto [gdb_get_line_number "Break to end."] # Test gdb.decode_line. gdb_test "python gdb.decode_line(\"main.c:43\")" \ - "RuntimeError: No source file named main.c.*" "test decode_line no source named main" + "gdb.error: No source file named main.c.*" "test decode_line no source named main" gdb_py_test_silent_cmd "python symtab = gdb.decode_line()" "test decode_line current location" 1 gdb_test "python print len(symtab)" "2" "Test decode_line current location" @@ -177,7 +177,7 @@ gdb_test "python print symtab\[1\]\[0\].symtab" "gdb/testsuite/gdb.python/python gdb_test "python print symtab\[1\]\[0\].line" "26" "Test decode_line python.c:26 line number" gdb_test "python gdb.decode_line(\"randomfunc\")" \ - "RuntimeError: Function \"randomfunc\" not defined.*" "test decode_line randomfunc" + "gdb.error: Function \"randomfunc\" not defined.*" "test decode_line randomfunc" gdb_py_test_silent_cmd "python symtab = gdb.decode_line(\"func1\")" "test decode_line func1()" 1 gdb_test "python print len(symtab)" "2" "Test decode_line func1 length" gdb_test "python print len(symtab\[1\])" "1" "Test decode_line func1 length" |