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]

[PATCH] gdb: Use TYPE_LENGTH macro


Fixes a couple of places where we access the length field of the type
structure directly, rather than using the TYPE_LENGTH macro.

gdb/ChangeLog:

	* i386-tdep.c (i386_mpx_info_bounds): Use TYPE_LENGTH.
	(i386_mpx_set_bounds): Likewise.
	* solib-darwin.c (darwin_load_image_infos): Likewise.
	(darwin_solib_read_all_image_info_addr): Likewise.
---
 gdb/ChangeLog      | 7 +++++++
 gdb/i386-tdep.c    | 8 ++++----
 gdb/solib-darwin.c | 8 ++++----
 3 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 03ae010..31e3028 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2015-12-11  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+	* i386-tdep.c (i386_mpx_info_bounds): Use TYPE_LENGTH.
+	(i386_mpx_set_bounds): Likewise.
+	* solib-darwin.c (darwin_load_image_infos): Likewise.
+	(darwin_solib_read_all_image_info_addr): Likewise.
+
 2015-12-10  Antoine Tremblay  <antoine.tremblay@ericsson.com>
 
 	* linux-thread-db.c (find_new_threads_callback): Use record_thread.
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index ebb21fc..58f0a84 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -8807,7 +8807,7 @@ i386_mpx_info_bounds (char *args, int from_tty)
 
   for (i = 0; i < 4; i++)
     bt_entry[i] = read_memory_typed_address (bt_entry_addr
-					     + i * data_ptr_type->length,
+					     + i * TYPE_LENGTH (data_ptr_type),
 					     data_ptr_type);
 
   i386_mpx_print_bounds (bt_entry);
@@ -8853,14 +8853,14 @@ i386_mpx_set_bounds (char *args, int from_tty)
   bt_entry_addr = i386_mpx_get_bt_entry (addr, bd_base);
   for (i = 0; i < 2; i++)
     bt_entry[i] = read_memory_typed_address (bt_entry_addr
-					     + i * data_ptr_type->length,
+					     + i * TYPE_LENGTH (data_ptr_type),
 					     data_ptr_type);
   bt_entry[0] = (uint64_t) lower;
   bt_entry[1] = ~(uint64_t) upper;
 
   for (i = 0; i < 2; i++)
-    write_memory_unsigned_integer (bt_entry_addr + i * data_ptr_type->length,
-				   data_ptr_type->length, byte_order,
+    write_memory_unsigned_integer (bt_entry_addr + i * TYPE_LENGTH (data_ptr_type),
+				   TYPE_LENGTH (data_ptr_type), byte_order,
 				   bt_entry[i]);
 }
 
diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c
index 88a4d73..6829bc5 100644
--- a/gdb/solib-darwin.c
+++ b/gdb/solib-darwin.c
@@ -132,7 +132,7 @@ darwin_load_image_infos (struct darwin_info *info)
 
   /* The structure has 4 fields: version (4 bytes), count (4 bytes),
      info (pointer) and notifier (pointer).  */
-  len = 4 + 4 + 2 * ptr_type->length;
+  len = 4 + 4 + 2 * TYPE_LENGTH (ptr_type);
   gdb_assert (len <= sizeof (buf));
   memset (&info->all_image, 0, sizeof (info->all_image));
 
@@ -148,7 +148,7 @@ darwin_load_image_infos (struct darwin_info *info)
   info->all_image.count = extract_unsigned_integer (buf + 4, 4, byte_order);
   info->all_image.info = extract_typed_address (buf + 8, ptr_type);
   info->all_image.notifier = extract_typed_address
-    (buf + 8 + ptr_type->length, ptr_type);
+    (buf + 8 + TYPE_LENGTH (ptr_type), ptr_type);
 }
 
 /* Link map info to include in an allocated so_list entry.  */
@@ -528,11 +528,11 @@ darwin_solib_read_all_image_info_addr (struct darwin_info *info)
   struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
 
   /* Sanity check.  */
-  if (ptr_type->length > sizeof (buf))
+  if (TYPE_LENGTH (ptr_type) > sizeof (buf))
     return;
 
   len = target_read (&current_target, TARGET_OBJECT_DARWIN_DYLD_INFO, NULL,
-		     buf, 0, ptr_type->length);
+		     buf, 0, TYPE_LENGTH (ptr_type));
   if (len <= 0)
     return;
 
-- 
2.5.1


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