This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[commit] value_static_field cleanup
- From: dje at google dot com (Doug Evans)
- To: gdb-patches at sourceware dot org
- Date: Sun, 27 Jun 2010 09:41:58 -0700 (PDT)
- Subject: [commit] value_static_field cleanup
Hi.
I committed this patch to make value_static_field more robust.
2010-06-27 Doug Evans <dje@google.com>
* value.c (value_static_field): Use `switch' instead of `if'.
Assert-fail if passed invalid TYPE_FIELD_LOC_KIND.
Index: value.c
===================================================================
RCS file: /cvs/src/src/gdb/value.c,v
retrieving revision 1.104
diff -u -p -r1.104 value.c
--- value.c 11 Jun 2010 15:36:05 -0000 1.104
+++ value.c 27 Jun 2010 16:37:41 -0000
@@ -1850,7 +1850,7 @@ unpack_pointer (struct type *type, const
}
-/* Get the value of the FIELDN'th field (which must be static) of
+/* Get the value of the FIELDNO'th field (which must be static) of
TYPE. Return NULL if the field doesn't exist or has been
optimized out. */
@@ -1859,12 +1859,13 @@ value_static_field (struct type *type, i
{
struct value *retval;
- if (TYPE_FIELD_LOC_KIND (type, fieldno) == FIELD_LOC_KIND_PHYSADDR)
+ switch (TYPE_FIELD_LOC_KIND (type, fieldno))
{
+ case FIELD_LOC_KIND_PHYSADDR:
retval = value_at_lazy (TYPE_FIELD_TYPE (type, fieldno),
TYPE_FIELD_STATIC_PHYSADDR (type, fieldno));
- }
- else
+ break;
+ case FIELD_LOC_KIND_PHYSNAME:
{
char *phys_name = TYPE_FIELD_STATIC_PHYSNAME (type, fieldno);
/*TYPE_FIELD_NAME (type, fieldno);*/
@@ -1897,7 +1898,12 @@ value_static_field (struct type *type, i
if (retval && VALUE_LVAL (retval) == lval_memory)
SET_FIELD_PHYSADDR (TYPE_FIELD (type, fieldno),
value_address (retval));
+ break;
}
+ default:
+ gdb_assert (0);
+ }
+
return retval;
}