[Crash-utility] [RFC PATCH] struct: Fix handing of percpu symbols

Dave Anderson anderson at redhat.com
Mon Apr 18 15:22:57 UTC 2016



----- Original Message -----
> Hi Dave,
> 
> 
> When a percpu symbol is of type pointer, the 'struct' command does
> not generate the expected output. For example:
> 

Aaron,

I haven't gotten a chance to actually test this patch, but this part bothers me:

+               if (typename && (ptype = (LASTCHAR(typename) == '*')))
+                       open_tmpfile2();
                for (c = 0; c < kt->cpus; c++) {
                        ulong cpuaddr;

@@ -6227,9 +6266,25 @@ cmd_datatype_common(ulong flags)
                                continue;
                        }

+                       if (ptype) {
+                               snprintf(buf, sizeof buf, "p *(%s*) 0x%lx",
+                                       typename, cpuaddr);
+                               gdb_pass_through(buf, pc->tmpfile2, GNU_RETURN_ON_ERROR);
+
+                               rewind(pc->tmpfile2);
+                               fgets(buf, BUFSIZE, pc->tmpfile2);
+                               parse_line(buf, argv);
+                               cpuaddr = htol(argv[3], FAULT_ON_ERROR, NULL);
+                               rewind(pc->tmpfile2);
+                               tmpfp = pc->tmpfile2;
+                               pc->tmpfile2 = NULL;
+                       }
                        fprintf(fp, "%lx\n", cpuaddr);
+
                        do_datatype_addr(dm, cpuaddr , count,
                                         flags, memberlist, argc_members);
+                       if (ptype)
+                               set_tmpfile2(tmpfp);
                }
        } else
                do_datatype_addr(dm, addr, count, flags,
@@ -6237,6 +6292,9 @@ cmd_datatype_common(ulong flags)

        restore_current_radix(restore_radix);

+       if (ptype)
+               close_tmpfile2();
+

Can't you accomplish the same thing without kludging the tmpfile2
facility such that it's being used simultaneously above and then later 
via do_datatype_addr()?

I may be missing something, but it seems like you just need it to calculate
cpuaddr each time through the loop, and then you're done with it.  But then
you rewind() it, store it, and keep tmpfp open across the do_datatype_addr()
call?  What am I missing?

Dave




More information about the Crash-utility mailing list