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

Dave Anderson anderson at redhat.com
Tue Apr 19 13:09:59 UTC 2016



----- Original Message -----
> On Mon 2016-04-18 11:22 -0400, Dave Anderson wrote:
> 
> Hi Dave,
> 
> > 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?
> 
> sure -- but I'd prefer to avoid the use of tmpfile()/fclose() in the for loop.
> Albeit since we set OPEN_ONLY_ONCE, the following should be fine:

Yep, much better... 

Thanks,
  Dave


> 
> @@ -6138,6 +6172,8 @@ cmd_datatype_common(ulong flags)
>  	}
>  
>  	if (cpuspec) {
> +		typename = expr_type_name(sp->name);
> +		ptype = typename && LASTCHAR(typename) == '*' ? 1 : 0;
>  		cpus = get_cpumask_buf();
>  		if (STREQ(cpuspec, ""))
>  			SET_BIT(cpus, CURRENT_CONTEXT()->processor);
> @@ -6227,7 +6263,20 @@ cmd_datatype_common(ulong flags)
>  				continue;
>  			}
>  
> +			if (ptype) {
> +				open_tmpfile();
> +				snprintf(buf, sizeof buf, "p *(%s*) 0x%lx",
> +					typename, cpuaddr);
> +				gdb_pass_through(buf, pc->tmpfile, GNU_RETURN_ON_ERROR);
> +
> +				rewind(pc->tmpfile);
> +				fgets(buf, BUFSIZE, pc->tmpfile);
> +				parse_line(buf, argv);
> +				cpuaddr = htol(argv[3], FAULT_ON_ERROR, NULL);
> +				close_tmpfile();
> +			}
>  			fprintf(fp, "%lx\n", cpuaddr);
> +
>  			do_datatype_addr(dm, cpuaddr , count,
>  					 flags, memberlist, argc_members);
>  		}
> @@ -6245,6 +6294,9 @@ freebuf:
>  
>  	if (cpus)
>  		FREEBUF(cpus);
> +
> +	if (typename)
> +		FREEBUF(typename);
>  }
>  
>  static void
> 
> --
> Aaron Tomlin
> 
> --
> Crash-utility mailing list
> Crash-utility at redhat.com
> https://www.redhat.com/mailman/listinfo/crash-utility
> 




More information about the Crash-utility mailing list