lkml.org 
[lkml]   [2015]   [May]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH 2/6] perf bpf: Add pt_regs convert table for x86
On 5/5/15 3:10 AM, He Kuang wrote:
> Convert register number in debuginfo to its index in pt_regs.
>
> Signed-off-by: He Kuang <hekuang@huawei.com>
> ---
> tools/perf/arch/x86/util/dwarf-regs.c | 31 +++++++++++++++++++++++++++++++
> 1 file changed, 31 insertions(+)
>
> diff --git a/tools/perf/arch/x86/util/dwarf-regs.c b/tools/perf/arch/x86/util/dwarf-regs.c
> index be22dd4..e586a47 100644
> --- a/tools/perf/arch/x86/util/dwarf-regs.c
> +++ b/tools/perf/arch/x86/util/dwarf-regs.c
> @@ -59,10 +59,31 @@ const char *x86_64_regs_table[X86_64_MAX_REGS] = {
> "%r15",
> };
>
> +const char x86_64_pt_regs_table[X86_64_MAX_REGS] = {
> + 10,
> + 12,
> + 11,
> + 5,
> + 13,
> + 14,
> + 4,
> + 19,
> + 9,
> + 8,
> + 7,
> + 6,
> + 3,
> + 2,
> + 1,
> + 0,
> +};

magic numbers need a comment in .c (not only in commit log)
Also I would combine them into
struct { const char *regname, int index } and
merge with x86_64_regs_table array
and would use something like offsetof(struct pt_regs, di) / 8
instead of hard coding.

In general patch 2 and 3 are in wrong order.
Generic 3 should come first. Otherwise patch 2 introduces things
that no one is using.



\
 
 \ /
  Last update: 2015-05-06 01:21    [W:0.096 / U:0.304 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site