[PATCH 9/11] Fix struct -o with an address and array count

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Previously, the array count was ignored with the "-o" option.

While I admit that repeating code is not "good style", the goto from
the middle of a loop was not nice either, and this variant removes
a dependency of the main loop on the "aflag" variable.

Signed-off-by: Petr Tesarik <ptesarik@xxxxxxx>
[PATCH 9/11] Fix struct -o with an address and array count

Previously, the array count was ignored with the "-o" option.

While I admit that repeating code is not "good style", the goto from
the middle of a loop was not nice either, and this variant removes
a dependency of the main loop on the "aflag" variable.

Signed-off-by: Petr Tesarik <ptesarik@xxxxxxx>

---
 symbols.c |   34 +++++++++++++++++++++-------------
 1 file changed, 21 insertions(+), 13 deletions(-)

--- a/symbols.c
+++ b/symbols.c
@@ -5871,6 +5871,11 @@ cmd_datatype_common(ulong flags)
                 strcpy(members, separator+1);
                 replace_string(members, ",", ' ');
                 argc_members = parse_line(members, memberlist);
+
+		if (!aflag) {
+			*separator = '.';
+			strcpy(separator + 1, memberlist[0]);
+		}
         } else
                 structname = args[optind];
 
@@ -5900,6 +5905,16 @@ cmd_datatype_common(ulong flags)
 		error(FATAL, 
 		    "-o option not valid with multiple member format\n");
 
+	/*
+	 *  No address was passed -- dump the structure/member declaration.
+	 */
+	if (!aflag) {
+		set_temporary_radix(radix, &restore_radix);
+		do_datatype_declaration(dm, flags | (dm->flags & TYPEDEF));
+		restore_current_radix(restore_radix);
+		goto freebuf;
+	}
+
 	len = dm->size;
 
 	if (count < 0) {
@@ -5934,22 +5949,15 @@ cmd_datatype_common(ulong flags)
 				break;
 			}
 
-			/* 
-	 		 *  No address was passed -- dump the structure/member declaration.
-	 		 */
-			if (!aflag || (aflag && (flags & SHOW_OFFSET))) {
-				if (aflag)
-					dm->vaddr = addr;
+			/*
+		 	 *  Display member addresses or data
+		 	 */
+			if (flags & SHOW_OFFSET) {
+				dm->vaddr = addr;
 				set_temporary_radix(radix, &restore_radix);
 				do_datatype_declaration(dm, flags | (dm->flags & TYPEDEF));
 				restore_current_radix(restore_radix);
-				goto freebuf;
-			}
-
-			/*
-		 	 *  Display data.
-		 	 */
-			if (flags & SHOW_RAW_DATA)
+			} else if (flags & SHOW_RAW_DATA)
 				raw_data_dump(addr, len, flags & STRUCT_VERBOSE);
 			else if ((flags & DEREF_POINTERS) && !dm->member) {
 				set_temporary_radix(radix, &restore_radix);
--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/crash-utility

[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux