[Crash-utility] Speed up list/tree '-s' output.

Alexandr Terekhov Alexandr_Terekhov at epam.com
Tue Aug 23 13:20:27 UTC 2016


Hi Dave,

here is updated patch for gdb/symtab.c:

--- gdb-7.6.orig/gdb/symtab.c	2016-08-18 09:06:33.000000000 +0300
+++ gdb-7.6/gdb/symtab.c	2016-08-23 14:28:45.456510348 +0300
@@ -5486,13 +5486,15 @@
 	struct field *nextfield;
 	short nfields;
 	struct type *typedef_type;
+	static int deep = 0;
+	static long offset = 0;
 
 	req->member_offset = -1;
 
 	nfields = TYPE_MAIN_TYPE(type)->nfields;
 	nextfield = TYPE_MAIN_TYPE(type)->flds_bnds.fields;
 
-        if (nfields == 0) {
+	if (nfields == 0 && deep == 0 /* The first call */) {
 		struct type *newtype;
                 newtype = lookup_transparent_type(req->name);
                 if (newtype) {
@@ -5505,13 +5507,21 @@
 
 	for (i = 0; i < nfields; i++) {
 		if (STREQ(req->member, nextfield->name)) {
-			req->member_offset = nextfield->loc.bitpos;
+			req->member_offset = offset + nextfield->loc.bitpos;
 			req->member_length = TYPE_LENGTH(nextfield->type);
 			req->member_typecode = TYPE_CODE(nextfield->type);
 			if ((req->member_typecode == TYPE_CODE_TYPEDEF) &&
 			    (typedef_type = check_typedef(nextfield->type))) 
         			req->member_length = TYPE_LENGTH(typedef_type);
 			return;
+		} else if (*nextfield->name == 0) { /* Anonymous struct/union */
+			deep++;
+			offset += nextfield->loc.bitpos;
+			get_member_data(req, nextfield->type);
+			offset -= nextfield->loc.bitpos;
+			deep--;
+			if (req->member_offset != -1)
+				return;
 		}
 		nextfield++;
 	}
@@ -5705,7 +5715,7 @@
 		req->target_length = target_type->length;
 	}
 
-	if (req->member) 
+	if (req->member)
 		get_member_data(req, type);
 
         do_cleanups (old_chain);

The patch for crash tool can be found on github:
https://raw.githubusercontent.com/hziSot/crash-patches/41abc6f9c91c2a602973ff9564234395deadb80e/crash_speed_up_tree_list.patch

Thanks,
Alexandr




More information about the Crash-utility mailing list