aboutsummaryrefslogtreecommitdiff
path: root/gdb/c-lang.c
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/c-lang.c
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/c-lang.c')
-rw-r--r--gdb/c-lang.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 015ba16..775a6f8 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -35,6 +35,7 @@
#include "cp-support.h"
#include "gdb_obstack.h"
#include <ctype.h>
+#include "exceptions.h"
extern void _initialize_c_language (void);
@@ -698,13 +699,19 @@ c_get_string (struct value *value, gdb_byte **buffer, int *length,
}
else
{
- err = read_string (value_as_address (value), *length, width, fetchlimit,
- byte_order, buffer, length);
+ CORE_ADDR addr = value_as_address (value);
+
+ err = read_string (addr, *length, width, fetchlimit,
+ byte_order, buffer, length);
if (err)
{
xfree (*buffer);
- error (_("Error reading string from inferior: %s"),
- safe_strerror (err));
+ if (err == EIO)
+ throw_error (MEMORY_ERROR, "Address %s out of bounds",
+ paddress (get_type_arch (type), addr));
+ else
+ error (_("Error reading string from inferior: %s"),
+ safe_strerror (err));
}
}