This patch improves handling of struct/union flags:
1. You can now specify a typedef with "*". Previously it failed like
this:
crash> *acct_t ffff8800982ad520
*: invalid argument
2. Report an error if a non-structured type is used, instead of
giving no output, e.g.:
crash> *pid_t
*: invalid argument
3. Produce an error message if the type does not match the command:
crash> union page
union: data type mismatch: page is not a union
crash> struct thread_union
struct: data type mismatch: thread_union is not a struct
Additionaly, these checks are now performed early, that is before
entering the main printing loop.
Signed-off-by: Petr Tesarik <[email protected]>
[PATCH 7/11] Cleanup handling of flags in cmd_datatype_common()
This patch improves handling of struct/union flags:
1. You can now specify a typedef with "*". Previously it failed like
this:
crash> *acct_t ffff8800982ad520
*: invalid argument
2. Report an error if a non-structured type is used, instead of
giving no output, e.g.:
crash> *pid_t
*: invalid argument
3. Produce an error message if the type does not match the command:
crash> union page
union: data type mismatch: page is not a union
crash> struct thread_union
struct: data type mismatch: thread_union is not a struct
Additionaly, these checks are now performed early, that is before
entering the main printing loop.
Signed-off-by: Petr Tesarik <[email protected]>
---
symbols.c | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
--- a/symbols.c
+++ b/symbols.c
@@ -5878,6 +5878,15 @@ cmd_datatype_common(ulong flags)
DATATYPE_QUERY|ANON_MEMBER_QUERY|RETURN_ON_ERROR) < 1))
error(FATAL, "invalid data structure reference: %s\n", structname);
+ if (! (flags & (STRUCT_REQUEST|UNION_REQUEST)) ) {
+ flags |= dm->type;
+ if (!(flags & (UNION_REQUEST|STRUCT_REQUEST)))
+ error(FATAL, "invalid argument");
+ } else if ( (flags &(STRUCT_REQUEST|UNION_REQUEST)) != dm->type) {
+ error(FATAL, "data type mismatch: %s is not a %s\n",
+ dm->name, flags & UNION_REQUEST ? "union" : "struct");
+ }
+
if ((argc_members > 1) && !aflag) {
error(INFO, flags & SHOW_OFFSET ?
"-o option not valid with multiple member format\n" :
@@ -5925,14 +5934,6 @@ cmd_datatype_common(ulong flags)
break;
}
- if (!(dm->flags & TYPEDEF)) {
- if (flags &(STRUCT_REQUEST|UNION_REQUEST) ) {
- if ((flags & (STRUCT_REQUEST|UNION_REQUEST)) != dm->type)
- goto freebuf;
- } else
- flags |= dm->type;
- }
-
/*
* No address was passed -- dump the structure/member declaration.
*/
@@ -5945,9 +5946,6 @@ cmd_datatype_common(ulong flags)
goto freebuf;
}
- if (!(flags & (UNION_REQUEST|STRUCT_REQUEST)))
- error(FATAL, "invalid argument");
-
/*
* Display data.
*/
--
Crash-utility mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/crash-utility