aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lib/traceevent/event-parse.c
diff options
context:
space:
mode:
authorKapileshwar Singh <kapileshwar.singh@arm.com>2015-09-22 09:22:03 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-09-22 10:57:04 -0400
commitc2e4b24ff848bb180f9b9cd873a38327cd219ad2 (patch)
tree8877a60171d806ce1d83d86d319b9db9f731bcb4 /tools/lib/traceevent/event-parse.c
parent381c02f6d8ccad8ed574630f879c40fb59715124 (diff)
tools lib traceevent: Fix string handling in heterogeneous arch environments
When a trace recorded on a 32-bit device is processed with a 64-bit binary, the higher 32-bits of the address need to ignored. The lack of this results in the output of the 64-bit pointer value to the trace as the 32-bit address lookup fails in find_printk(). Before: burn-1778 [003] 548.600305: bputs: 0xc0046db2s: 2cec5c058d98c After: burn-1778 [003] 548.600305: bputs: 0xc0046db2s: RT throttling activated The problem occurs in PRINT_FIELD when the field is recognized as a pointer to a string (of the type const char *) Heterogeneous architectures cases below can arise and should be handled: * Traces recorded using 32-bit addresses processed on a 64-bit machine * Traces recorded using 64-bit addresses processed on a 32-bit machine Reported-by: Juri Lelli <juri.lelli@arm.com> Signed-off-by: Kapileshwar Singh <kapileshwar.singh@arm.com> Reviewed-by: Steven Rostedt <rostedt@goodmis.org> Cc: David Ahern <dsahern@gmail.com> Cc: Javi Merino <javi.merino@arm.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: stable@vger.kernel.org Link: http://lkml.kernel.org/r/1442928123-13824-1-git-send-email-kapileshwar.singh@arm.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/lib/traceevent/event-parse.c')
-rw-r--r--tools/lib/traceevent/event-parse.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 4d885934b919..cf42b090477b 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -3795,7 +3795,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
3795 struct format_field *field; 3795 struct format_field *field;
3796 struct printk_map *printk; 3796 struct printk_map *printk;
3797 long long val, fval; 3797 long long val, fval;
3798 unsigned long addr; 3798 unsigned long long addr;
3799 char *str; 3799 char *str;
3800 unsigned char *hex; 3800 unsigned char *hex;
3801 int print; 3801 int print;
@@ -3828,13 +3828,30 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
3828 */ 3828 */
3829 if (!(field->flags & FIELD_IS_ARRAY) && 3829 if (!(field->flags & FIELD_IS_ARRAY) &&
3830 field->size == pevent->long_size) { 3830 field->size == pevent->long_size) {
3831 addr = *(unsigned long *)(data + field->offset); 3831
3832 /* Handle heterogeneous recording and processing
3833 * architectures
3834 *
3835 * CASE I:
3836 * Traces recorded on 32-bit devices (32-bit
3837 * addressing) and processed on 64-bit devices:
3838 * In this case, only 32 bits should be read.
3839 *
3840 * CASE II:
3841 * Traces recorded on 64 bit devices and processed
3842 * on 32-bit devices:
3843 * In this case, 64 bits must be read.
3844 */
3845 addr = (pevent->long_size == 8) ?
3846 *(unsigned long long *)(data + field->offset) :
3847 (unsigned long long)*(unsigned int *)(data + field->offset);
3848
3832 /* Check if it matches a print format */ 3849 /* Check if it matches a print format */
3833 printk = find_printk(pevent, addr); 3850 printk = find_printk(pevent, addr);
3834 if (printk) 3851 if (printk)
3835 trace_seq_puts(s, printk->printk); 3852 trace_seq_puts(s, printk->printk);
3836 else 3853 else
3837 trace_seq_printf(s, "%lx", addr); 3854 trace_seq_printf(s, "%llx", addr);
3838 break; 3855 break;
3839 } 3856 }
3840 str = malloc(len + 1); 3857 str = malloc(len + 1);