From 621c83642d17cf523c20f55f2ed945a7ec95ea6a Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 12 Nov 2010 20:49:43 +0000 Subject: 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. --- gdb/testsuite/gdb.python/py-value.exp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'gdb/testsuite/gdb.python/py-value.exp') diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp index 895969be53a..9bee1c08f04 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 -- cgit v1.2.1