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

Alexandr Terekhov Alexandr_Terekhov at epam.com
Mon Aug 22 14:01:47 UTC 2016


Dave,

Please disregard the previous message. It looks like the patch is going to be more complicated:

diff --git a/gdb-7.6.patch b/gdb-7.6.patch
index 794555f..4718b11 100644
--- a/gdb-7.6.patch
+++ b/gdb-7.6.patch
@@ -351,7 +351,7 @@
    return lookup_symbol_in_language (name, block, domain,
  				    current_language->la_language,
  				    is_a_field_of_this);
-@@ -5100,3 +5115,662 @@ When enabled, debugging messages are pri
+@@ -5100,3 +5115,666 @@ When enabled, debugging messages are pri
  
    observer_attach_executable_changed (symtab_observer_executable_changed);
  }
@@ -362,7 +362,7 @@
 +#define GDB_COMMON
 +#include "../../defs.h"
 +
-+static void get_member_data(struct gnu_request *, struct type *);
++static void get_member_data(struct gnu_request *, struct type *, off_t);
 +static void dump_enum(struct type *, struct gnu_request *);
 +static void eval_enum(struct type *, struct gnu_request *);
 +static void gdb_get_line_number(struct gnu_request *);
@@ -551,7 +551,7 @@
 +                req->typecode = TYPE_CODE(sym->type);
 +                req->length = TYPE_LENGTH(sym->type);
 +		if (req->member)
-+			get_member_data(req, sym->type);
++			get_member_data(req, sym->type, 0);
 +			
 +		if (TYPE_CODE(sym->type) == TYPE_CODE_ENUM) {
 +			if (req->flags & GNU_PRINT_ENUMERATORS) 
@@ -621,7 +621,7 @@
 +		}
 +
 +                if (req->member) 
-+                	get_member_data(req, type); 
++                	get_member_data(req, type, 0);
 +		
 +		break;
 +
@@ -704,7 +704,7 @@
 + *  member field, and when found, return its relevant data.
 + */
 +static void
-+get_member_data(struct gnu_request *req, struct type *type)
++get_member_data(struct gnu_request *req, struct type *type, off_t offset)
 +{
 +	register short i;
 +	struct field *nextfield;
@@ -729,13 +729,17 @@
 +
 +	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 */
++			get_member_data(req, nextfield->type, offset + nextfield->loc.bitpos);
++			if (req->member_offset != -1)
++				return;
 +		}
 +		nextfield++;
 +	}
@@ -930,7 +934,7 @@
 +	}
 +
 +	if (req->member) 
-+		get_member_data(req, type);
++		get_member_data(req, type, 0);
 +
 +        do_cleanups (old_chain);
 +}

Waiting for your comments.

Thanks,
Alexandr.
________________________________________
From: crash-utility-bounces at redhat.com <crash-utility-bounces at redhat.com> on behalf of Alexandr Terekhov <Alexandr_Terekhov at epam.com>
Sent: Monday, August 22, 2016 16:12
To: Discussion list for crash utility usage,    maintenance and development
Subject: Re: [Crash-utility] Speed up list/tree '-s' output.

Hi Dave,

while I was working on your suggestions, I faced the following problem:

(gdb) call datatype_info("page", "mapping", -3)
$1 = 0

It happens because entire anonymous structure is represented as single field
with empty name within gdb.
Please, consider the patch which fixes such behavior:
(gdb) call datatype_info("page", "mapping", -3)
$1 = 1
(gdb) call datatype_info("page", "index", -3)
$5 = 8
(gdb) call datatype_info("page", "lru", -3)
$6 = 3
(gdb) call datatype_info("page", "objects", -3)
$7 = 22

diff --git a/gdb-7.6.patch b/gdb-7.6.patch
index 794555f..8a61f20 100644
--- a/gdb-7.6.patch
+++ b/gdb-7.6.patch
@@ -351,7 +351,7 @@
    return lookup_symbol_in_language (name, block, domain,
                                    current_language->la_language,
                                    is_a_field_of_this);
-@@ -5100,3 +5115,662 @@ When enabled, debugging messages are pri
+@@ -5100,3 +5115,666 @@ When enabled, debugging messages are pri

    observer_attach_executable_changed (symtab_observer_executable_changed);
  }
@@ -736,6 +736,10 @@
 +                          (typedef_type = check_typedef(nextfield->type)))
 +                              req->member_length = TYPE_LENGTH(typedef_type);
 +                      return;
++              } else if (*nextfield->name == 0) { /* Anonymous struct/union */
++                      get_member_data(req, nextfield->type);
++                      if (req->member_offset != -1)
++                              return;
 +              }
 +              nextfield++;
 +      }

______________________________________
From: crash-utility-bounces at redhat.com <crash-utility-bounces at redhat.com> on behalf of Dave Anderson <anderson at redhat.com>
Sent: Thursday, August 18, 2016 23:39
To: Discussion list for crash utility usage,    maintenance and development
Subject: Re: [Crash-utility] Speed up list/tree '-s' output.

Another suggestion:

Use MEMBER_TYPE(), or pass a datatype_member structure to datatype_info(), in
order to determine whether a structure member is TYPE_CODE_PTR, and if so, always
print the member in hexadecimal regardless of the current radix.  (i.e. like
gdb does)

Dave

--
Crash-utility mailing list
Crash-utility at redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility




More information about the Crash-utility mailing list