[PATCH 10/11] Move the main loop of cmd_datatype_common() to its own function

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

 



This change allows to reuse the main loop in a different context.

Signed-off-by: Petr Tesarik <ptesarik@xxxxxxx> 
[PATCH 10/11] Move the main loop of cmd_datatype_common() to its own function

This change allows to reuse the main loop in a different context.

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

---
 symbols.c |   41 ++++++++++++++++++++++-------------------
 1 file changed, 22 insertions(+), 19 deletions(-)

--- a/symbols.c
+++ b/symbols.c
@@ -72,6 +72,8 @@ struct elf_common;
 static void Elf32_Sym_to_common(Elf32_Sym *, struct elf_common *); 
 static void Elf64_Sym_to_common(Elf64_Sym *, struct elf_common *); 
 static void cmd_datatype_common(ulong);
+static void do_datatype_addr(struct datatype_member *, ulong, int,
+			     ulong, char **, int);
 static void process_gdb_output(char *, unsigned, const char *, int);
 static int display_per_cpu_info(struct syment *, int, char *);
 static struct load_module *get_module_percpu_sym_owner(struct syment *);
@@ -5708,10 +5710,9 @@ dereference_pointer(ulong addr, struct d
 static void 
 cmd_datatype_common(ulong flags)
 {
-	int i, c;
+	int c;
 	ulong addr, aflag;
 	struct syment *sp;
-	long len;
 	ulong list_head_offset;
 	int count;
 	int argc_members;
@@ -5901,22 +5902,37 @@ cmd_datatype_common(ulong flags)
 		error(FATAL, 
 		    "-o option not valid with multiple member format\n");
 
+	set_temporary_radix(radix, &restore_radix);
+
 	/*
 	 *  No address was passed -- dump the structure/member declaration.
 	 */
 	if (!aflag) {
-		set_temporary_radix(radix, &restore_radix);
 		if (argc_members &&
 		    !member_to_datatype(memberlist[0], dm,
 					ANON_MEMBER_QUERY))
 			error(FATAL, "invalid data structure reference: %s.%s\n",
 			      dm->name, memberlist[0]);
 		do_datatype_declaration(dm, flags | (dm->flags & TYPEDEF));
-		restore_current_radix(restore_radix);
-		goto freebuf;
+	} else
+		do_datatype_addr(dm, addr, count, flags,
+				 memberlist, argc_members);
+
+	restore_current_radix(restore_radix);
+
+freebuf:
+        if (argc_members) {
+                FREEBUF(structname);
+                FREEBUF(members);
 	}
+}
 
-	len = dm->size;
+static void
+do_datatype_addr(struct datatype_member *dm, ulong addr, int count,
+		 ulong flags, char **memberlist, int argc_members)
+{
+	int i, c;
+	long len = dm->size;
 
 	if (count < 0) {
 		addr -= len * abs(count);
@@ -5947,21 +5963,15 @@ cmd_datatype_common(ulong flags)
 		 	 */
 			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);
 			} 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);
 				print_struct_with_dereference(addr, dm, flags);
-				restore_current_radix(restore_radix);
                 	} else {
 	                        if (dm->member)
 	                                open_tmpfile();
 	
-				set_temporary_radix(radix, &restore_radix);
-
 				if (flags & UNION_REQUEST)
 					print_union(dm->name, addr);
 				else if (flags & STRUCT_REQUEST)
@@ -5974,16 +5984,9 @@ cmd_datatype_common(ulong flags)
 					close_tmpfile();
 				}
 
-				restore_current_radix(restore_radix);
                 	}
 		} while (++i < argc_members);
         }
-
-freebuf:
-        if (argc_members) {
-                FREEBUF(structname);
-                FREEBUF(members);
-	}
 }
 
 
--
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