aboutsummaryrefslogtreecommitdiff
path: root/gdb/doc
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2010-11-12 20:49:43 +0000
committerTom Tromey <tromey@redhat.com>2010-11-12 20:49:43 +0000
commit621c83642d17cf523c20f55f2ed945a7ec95ea6a (patch)
tree231cb6bb882e72fb68d6a5eb189060af43bb0dad /gdb/doc
parentf1b9e6e7ee6f55dd82194417e8f4d1713783ef39 (diff)
downloadgdb-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/doc')
-rw-r--r--gdb/doc/ChangeLog7
-rw-r--r--gdb/doc/gdb.texinfo47
2 files changed, 39 insertions, 15 deletions
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index d999772..75f6f70 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,10 @@
+2010-11-12 Tom Tromey <tromey@redhat.com>
+
+ * gdb.texinfo (Basic Python): Update. Add xref.
+ (Exception Handling): Document new exception classes.
+ (Types In Python): Update.
+ (Frames In Python): Update.
+
2010-11-11 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Breakpoints In Python): Document "internal"
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index cf70ce4..ddc711b 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -20729,8 +20729,9 @@ spaces if the parameter has a multi-part name. For example,
@samp{print object} is a valid parameter name.
If the named parameter does not exist, this function throws a
-@code{RuntimeError}. Otherwise, the parameter's value is converted to
-a Python value of the appropriate type, and returned.
+@code{gdb.error} (@pxref{Exception Handling}). Otherwise, the
+parameter's value is converted to a Python value of the appropriate
+type, and returned.
@end defun
@findex gdb.history
@@ -20741,7 +20742,7 @@ If @var{number} is negative, then @value{GDBN} will take its absolute value
and count backward from the last element (i.e., the most recent element) to
find the value to return. If @var{number} is zero, then @value{GDBN} will
return the most recent element. If the element specified by @var{number}
-doesn't exist in the value history, a @code{RuntimeError} exception will be
+doesn't exist in the value history, a @code{gdb.error} exception will be
raised.
If no exception is raised, the return value is always an instance of
@@ -20869,15 +20870,31 @@ Traceback (most recent call last):
NameError: name 'foo' is not defined
@end smallexample
-@value{GDBN} errors that happen in @value{GDBN} commands invoked by Python
-code are converted to Python @code{RuntimeError} exceptions. User
-interrupt (via @kbd{C-c} or by typing @kbd{q} at a pagination
-prompt) is translated to a Python @code{KeyboardInterrupt}
-exception. If you catch these exceptions in your Python code, your
-exception handler will see @code{RuntimeError} or
-@code{KeyboardInterrupt} as the exception type, the @value{GDBN} error
-message as its value, and the Python call stack backtrace at the
-Python statement closest to where the @value{GDBN} error occured as the
+@value{GDBN} errors that happen in @value{GDBN} commands invoked by
+Python code are converted to Python exceptions. The type of the
+Python exception depends on the error.
+
+@ftable @code
+@item gdb.error
+This is the base class for most exceptions generated by @value{GDBN}.
+It is derived from @code{RuntimeError}, for compatibility with earlier
+versions of @value{GDBN}.
+
+If an error occurring in @value{GDBN} does not fit into some more
+specific category, then the generated exception will have this type.
+
+@item gdb.MemoryError
+This is a subclass of @code{gdb.error} which is thrown when an
+operation tried to access invalid memory in the inferior.
+
+@item KeyboardInterrupt
+User interrupt (via @kbd{C-c} or by typing @kbd{q} at a pagination
+prompt) is translated to a Python @code{KeyboardInterrupt} exception.
+@end ftable
+
+In all cases, your exception handler will see the @value{GDBN} error
+message as its value and the Python call stack backtrace at the Python
+statement closest to where the @value{GDBN} error occured as the
traceback.
@findex gdb.GdbError
@@ -21242,7 +21259,7 @@ variant of this type. That is, the result is neither @code{const} nor
Return a Python @code{Tuple} object that contains two elements: the
low bound of the argument type and the high bound of that type. If
the type does not have a range, @value{GDBN} will raise a
-@code{RuntimeError} exception.
+@code{gdb.error} exception (@pxref{Exception Handling}).
@end defmethod
@defmethod Type reference
@@ -22433,8 +22450,8 @@ When the debugged program stops, @value{GDBN} is able to analyze its call
stack (@pxref{Frames,,Stack frames}). The @code{gdb.Frame} class
represents a frame in the stack. A @code{gdb.Frame} object is only valid
while its corresponding frame exists in the inferior's stack. If you try
-to use an invalid frame object, @value{GDBN} will throw a @code{RuntimeError}
-exception.
+to use an invalid frame object, @value{GDBN} will throw a @code{gdb.error}
+exception (@pxref{Exception Handling}).
Two @code{gdb.Frame} objects can be compared for equality with the @code{==}
operator, like: