This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: handle errors from value_static_field


I'm checking this in on the trunk.

When printing an object, gdb will try to print static fields from the
object's type.  If printing a static field fails for some reason, the
remainder of the object remains unprinted:

    (gdb) p *yp
    $1 = {
      v = 0, 
      static xp = <error reading variable>
    (gdb) 

This patch changes the C++ value printer to catch the error itself and
continue on:

    (gdb) p *yp
    $1 = {
      v = 0, 
      static xp = <error reading variable: Cannot find thread-local variables on this target>, 
      z = 23
    }

Built and regtested by the buildbot.

Tom

2011-05-17  Tom Tromey  <tromey@redhat.com>

	* cp-valprint.c (cp_print_value_fields): Catch errors from
	value_static_field.

diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 255e9ce..f8516d5 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -340,9 +340,19 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 		}
 	      else if (field_is_static (&TYPE_FIELD (type, i)))
 		{
-		  struct value *v = value_static_field (type, i);
-
-		  if (v == NULL)
+		  volatile struct gdb_exception ex;
+		  struct value *v = NULL;
+
+		  TRY_CATCH (ex, RETURN_MASK_ERROR)
+		    {
+		      v = value_static_field (type, i);
+		    }
+
+		  if (ex.reason < 0)
+		    fprintf_filtered (stream,
+				      _("<error reading variable: %s>"),
+				      ex.message);
+		  else if (v == NULL)
 		    val_print_optimized_out (stream);
 		  else
 		    cp_print_static_field (TYPE_FIELD_TYPE (type, i),


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]