perf tools: Fix bprintk reading in trace output
The bprintk parsing was broken in more ways than one. The file parsing was incorrect, and the words used by the arguments are always 4 bytes aligned, even on 64-bit machines. Signed-off-by: Steven Rostedt <srostedt@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> LKML-Reference: <20091014194359.520931637@goodmis.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
		
					parent
					
						
							
								07a4bdddcf
							
						
					
				
			
			
				commit
				
					
						ffa1895561
					
				
			
		
					 1 changed files with 7 additions and 8 deletions
				
			
		| 
						 | 
					@ -284,18 +284,16 @@ void parse_ftrace_printk(char *file, unsigned int size __unused)
 | 
				
			||||||
	char *line;
 | 
						char *line;
 | 
				
			||||||
	char *next = NULL;
 | 
						char *next = NULL;
 | 
				
			||||||
	char *addr_str;
 | 
						char *addr_str;
 | 
				
			||||||
	int ret;
 | 
						char *fmt;
 | 
				
			||||||
	int i;
 | 
						int i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	line = strtok_r(file, "\n", &next);
 | 
						line = strtok_r(file, "\n", &next);
 | 
				
			||||||
	while (line) {
 | 
						while (line) {
 | 
				
			||||||
		item = malloc_or_die(sizeof(*item));
 | 
							item = malloc_or_die(sizeof(*item));
 | 
				
			||||||
		ret = sscanf(line, "%as : %as",
 | 
							addr_str = strtok_r(line, ":", &fmt);
 | 
				
			||||||
			     (float *)(void *)&addr_str, /* workaround gcc warning */
 | 
					 | 
				
			||||||
			     (float *)(void *)&item->printk);
 | 
					 | 
				
			||||||
		item->addr = strtoull(addr_str, NULL, 16);
 | 
							item->addr = strtoull(addr_str, NULL, 16);
 | 
				
			||||||
		free(addr_str);
 | 
							/* fmt still has a space, skip it */
 | 
				
			||||||
 | 
							item->printk = strdup(fmt+1);
 | 
				
			||||||
		item->next = list;
 | 
							item->next = list;
 | 
				
			||||||
		list = item;
 | 
							list = item;
 | 
				
			||||||
		line = strtok_r(NULL, "\n", &next);
 | 
							line = strtok_r(NULL, "\n", &next);
 | 
				
			||||||
| 
						 | 
					@ -2274,8 +2272,9 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc
 | 
				
			||||||
			case 'u':
 | 
								case 'u':
 | 
				
			||||||
			case 'x':
 | 
								case 'x':
 | 
				
			||||||
			case 'i':
 | 
								case 'i':
 | 
				
			||||||
				bptr = (void *)(((unsigned long)bptr + (long_size - 1)) &
 | 
									/* the pointers are always 4 bytes aligned */
 | 
				
			||||||
						~(long_size - 1));
 | 
									bptr = (void *)(((unsigned long)bptr + 3) &
 | 
				
			||||||
 | 
											~3);
 | 
				
			||||||
				switch (ls) {
 | 
									switch (ls) {
 | 
				
			||||||
				case 0:
 | 
									case 0:
 | 
				
			||||||
				case 1:
 | 
									case 1:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue