Hi Alexandr,
I'm still testing and sanity-checking the symtab.c patch given that it's
modifying such a commonly-called function. Interestingly enough, it's
actually uncovered a bug with the current determination of the page.list
members, which I found by saving the output of "help -o" into a file,
both without and then with your patch, into /tmp/old and /tmp/new, and
then diff'ed the two files:
# diff /tmp/old /tmp/new
221,223c221,223
< page_list: -1
< page_list_next: -1
< page_list_prev: -1
---
page_list: 32
page_list_next: 32
page_list_prev: 40
#
Fortunately those fields aren't used by the crash code for more recent
kernels, which have gone crazy with the anonymous structures in the page
structure. But anyway, that was a good catch by your patch.
On the other hand, I don't like the use of the deep and offset static
variables, because there's always the remote possibility that a
CTRL-C or other function failure may happen while they are set, and
then leave them in a bogus state. So I would rather they get passed as
arguments.
Thanks,
Dave
----- Original Message -----
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/41abc6f9c91c2a6029...
Thanks,
Alexandr
--
Crash-utility mailing list
Crash-utility(a)redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility