Instead of parsing the complete type on each iteration, move the code to a helper function. This might be slightly faster, but most importantly the main loop doesn't need the "structname" and "separator" variables after this change. Signed-off-by: Petr Tesarik <ptesarik@xxxxxxx> --- symbols.c | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-)
[PATCH 8/11] Helper function to add member info to struct datatype_member Instead of parsing the complete type on each iteration, move the code to a helper function. This might be slightly faster, but most importantly the main loop doesn't need the "structname" and "separator" variables after this change. Signed-off-by: Petr Tesarik <ptesarik@xxxxxxx> --- symbols.c | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) --- a/symbols.c +++ b/symbols.c @@ -135,6 +135,7 @@ static void dump_datatype_flags(ulong, F static long anon_member_offset(char *, char *); static int gdb_whatis(char *); static void do_datatype_declaration(struct datatype_member *, ulong); +static int member_to_datatype(char *, struct datatype_member *, ulong); #define DEBUGINFO_ERROR_MESSAGE1 \ "the use of a System.map file requires that the accompanying namelist\nargument is a kernel file built with the -g CFLAG. The namelist argument\nsupplied in this case is a debuginfo file, which must be accompanied by the\nkernel file from which it was derived.\n" @@ -5917,21 +5918,13 @@ cmd_datatype_common(ulong flags) i = 0; do { if (argc_members) { - *separator = '.'; - strcpy(separator+1, memberlist[i]); - } - - switch (arg_to_datatype(structname, dm, - ANON_MEMBER_QUERY|RETURN_ON_ERROR)) - { - case 0: error(FATAL, "invalid data structure reference: %s\n", - structname); - break; - case 1: break; - case 2: if (flags & SHOW_RAW_DATA) + if (!member_to_datatype(memberlist[i], dm, + ANON_MEMBER_QUERY)) + error(FATAL, "invalid data structure reference: %s.%s\n", + dm->name, memberlist[i]); + if (flags & SHOW_RAW_DATA) error(FATAL, - "member-specific output not allowed with -r\n"); - break; + "member-specific output not allowed with -r\n"); } /* @@ -6106,13 +6099,7 @@ arg_to_datatype(char *s, struct datatype if (!both) return 1; - dm->member = p1+1; - - if ((dm->member_offset = MEMBER_OFFSET(dm->name, dm->member)) >= 0) - return 2; - - if ((flags & ANON_MEMBER_QUERY) && - ((dm->member_offset = ANON_MEMBER_OFFSET(dm->name, dm->member)) >= 0)) + if (member_to_datatype(p1 + 1, dm, flags)) return 2; datatype_member_fatal: @@ -6135,6 +6122,21 @@ datatype_member_fatal: return (error(FATAL, "invalid argument: %s\n", s)); } +static int +member_to_datatype(char *s, struct datatype_member *dm, ulong flags) +{ + dm->member = s; + + if ((dm->member_offset = MEMBER_OFFSET(dm->name, s)) >= 0) + return TRUE; + + if ((flags & ANON_MEMBER_QUERY) && + ((dm->member_offset = ANON_MEMBER_OFFSET(dm->name, s)) >= 0)) + return TRUE; + + return FALSE; +} + /* * debug routine -- not called on purpose by anybody. */
-- Crash-utility mailing list Crash-utility@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/crash-utility