mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-04 04:06:26 +00:00
kernel/trace: extract common part in process_fetch_insn
Each probe has an instance of process_fetch_insn respectively, but they have something in common. This patch aims to extract the common part into process_common_fetch_insn which can be shared by each probe, and they only need to focus on their special cases. Signed-off-by: Song Chen <chensong_2000@189.cn> Suggested-by: Masami Hiramatsu <mhiramat@kernel.org> Acked-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
This commit is contained in:
parent
672a2bf840
commit
bd78acc89d
@ -396,20 +396,12 @@ static int get_eprobe_size(struct trace_probe *tp, void *rec)
|
|||||||
case FETCH_OP_TP_ARG:
|
case FETCH_OP_TP_ARG:
|
||||||
val = get_event_field(code, rec);
|
val = get_event_field(code, rec);
|
||||||
break;
|
break;
|
||||||
case FETCH_OP_IMM:
|
|
||||||
val = code->immediate;
|
|
||||||
break;
|
|
||||||
case FETCH_OP_COMM:
|
|
||||||
val = (unsigned long)current->comm;
|
|
||||||
break;
|
|
||||||
case FETCH_OP_DATA:
|
|
||||||
val = (unsigned long)code->data;
|
|
||||||
break;
|
|
||||||
case FETCH_NOP_SYMBOL: /* Ignore a place holder */
|
case FETCH_NOP_SYMBOL: /* Ignore a place holder */
|
||||||
code++;
|
code++;
|
||||||
goto retry;
|
goto retry;
|
||||||
default:
|
default:
|
||||||
continue;
|
if (process_common_fetch_insn(code, &val) < 0)
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
code++;
|
code++;
|
||||||
len = process_fetch_insn_bottom(code, val, NULL, NULL);
|
len = process_fetch_insn_bottom(code, val, NULL, NULL);
|
||||||
@ -429,26 +421,20 @@ process_fetch_insn(struct fetch_insn *code, void *rec, void *dest,
|
|||||||
void *base)
|
void *base)
|
||||||
{
|
{
|
||||||
unsigned long val;
|
unsigned long val;
|
||||||
|
int ret;
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
switch (code->op) {
|
switch (code->op) {
|
||||||
case FETCH_OP_TP_ARG:
|
case FETCH_OP_TP_ARG:
|
||||||
val = get_event_field(code, rec);
|
val = get_event_field(code, rec);
|
||||||
break;
|
break;
|
||||||
case FETCH_OP_IMM:
|
|
||||||
val = code->immediate;
|
|
||||||
break;
|
|
||||||
case FETCH_OP_COMM:
|
|
||||||
val = (unsigned long)current->comm;
|
|
||||||
break;
|
|
||||||
case FETCH_OP_DATA:
|
|
||||||
val = (unsigned long)code->data;
|
|
||||||
break;
|
|
||||||
case FETCH_NOP_SYMBOL: /* Ignore a place holder */
|
case FETCH_NOP_SYMBOL: /* Ignore a place holder */
|
||||||
code++;
|
code++;
|
||||||
goto retry;
|
goto retry;
|
||||||
default:
|
default:
|
||||||
return -EILSEQ;
|
ret = process_common_fetch_insn(code, &val);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
code++;
|
code++;
|
||||||
return process_fetch_insn_bottom(code, val, dest, base);
|
return process_fetch_insn_bottom(code, val, dest, base);
|
||||||
|
@ -1225,6 +1225,7 @@ process_fetch_insn(struct fetch_insn *code, void *rec, void *dest,
|
|||||||
{
|
{
|
||||||
struct pt_regs *regs = rec;
|
struct pt_regs *regs = rec;
|
||||||
unsigned long val;
|
unsigned long val;
|
||||||
|
int ret;
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
/* 1st stage: get value from context */
|
/* 1st stage: get value from context */
|
||||||
@ -1241,15 +1242,6 @@ process_fetch_insn(struct fetch_insn *code, void *rec, void *dest,
|
|||||||
case FETCH_OP_RETVAL:
|
case FETCH_OP_RETVAL:
|
||||||
val = regs_return_value(regs);
|
val = regs_return_value(regs);
|
||||||
break;
|
break;
|
||||||
case FETCH_OP_IMM:
|
|
||||||
val = code->immediate;
|
|
||||||
break;
|
|
||||||
case FETCH_OP_COMM:
|
|
||||||
val = (unsigned long)current->comm;
|
|
||||||
break;
|
|
||||||
case FETCH_OP_DATA:
|
|
||||||
val = (unsigned long)code->data;
|
|
||||||
break;
|
|
||||||
#ifdef CONFIG_HAVE_FUNCTION_ARG_ACCESS_API
|
#ifdef CONFIG_HAVE_FUNCTION_ARG_ACCESS_API
|
||||||
case FETCH_OP_ARG:
|
case FETCH_OP_ARG:
|
||||||
val = regs_get_kernel_argument(regs, code->param);
|
val = regs_get_kernel_argument(regs, code->param);
|
||||||
@ -1259,7 +1251,9 @@ process_fetch_insn(struct fetch_insn *code, void *rec, void *dest,
|
|||||||
code++;
|
code++;
|
||||||
goto retry;
|
goto retry;
|
||||||
default:
|
default:
|
||||||
return -EILSEQ;
|
ret = process_common_fetch_insn(code, &val);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
code++;
|
code++;
|
||||||
|
|
||||||
|
@ -98,6 +98,26 @@ fetch_store_symstring(unsigned long addr, void *dest, void *base)
|
|||||||
return sprint_symbol(__dest, addr);
|
return sprint_symbol(__dest, addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* common part of process_fetch_insn*/
|
||||||
|
static nokprobe_inline int
|
||||||
|
process_common_fetch_insn(struct fetch_insn *code, unsigned long *val)
|
||||||
|
{
|
||||||
|
switch (code->op) {
|
||||||
|
case FETCH_OP_IMM:
|
||||||
|
*val = code->immediate;
|
||||||
|
break;
|
||||||
|
case FETCH_OP_COMM:
|
||||||
|
*val = (unsigned long)current->comm;
|
||||||
|
break;
|
||||||
|
case FETCH_OP_DATA:
|
||||||
|
*val = (unsigned long)code->data;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return -EILSEQ;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* From the 2nd stage, routine is same */
|
/* From the 2nd stage, routine is same */
|
||||||
static nokprobe_inline int
|
static nokprobe_inline int
|
||||||
process_fetch_insn_bottom(struct fetch_insn *code, unsigned long val,
|
process_fetch_insn_bottom(struct fetch_insn *code, unsigned long val,
|
||||||
|
@ -220,6 +220,7 @@ process_fetch_insn(struct fetch_insn *code, void *rec, void *dest,
|
|||||||
{
|
{
|
||||||
struct pt_regs *regs = rec;
|
struct pt_regs *regs = rec;
|
||||||
unsigned long val;
|
unsigned long val;
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* 1st stage: get value from context */
|
/* 1st stage: get value from context */
|
||||||
switch (code->op) {
|
switch (code->op) {
|
||||||
@ -235,20 +236,16 @@ process_fetch_insn(struct fetch_insn *code, void *rec, void *dest,
|
|||||||
case FETCH_OP_RETVAL:
|
case FETCH_OP_RETVAL:
|
||||||
val = regs_return_value(regs);
|
val = regs_return_value(regs);
|
||||||
break;
|
break;
|
||||||
case FETCH_OP_IMM:
|
|
||||||
val = code->immediate;
|
|
||||||
break;
|
|
||||||
case FETCH_OP_COMM:
|
case FETCH_OP_COMM:
|
||||||
val = FETCH_TOKEN_COMM;
|
val = FETCH_TOKEN_COMM;
|
||||||
break;
|
break;
|
||||||
case FETCH_OP_DATA:
|
|
||||||
val = (unsigned long)code->data;
|
|
||||||
break;
|
|
||||||
case FETCH_OP_FOFFS:
|
case FETCH_OP_FOFFS:
|
||||||
val = translate_user_vaddr(code->immediate);
|
val = translate_user_vaddr(code->immediate);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return -EILSEQ;
|
ret = process_common_fetch_insn(code, &val);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
code++;
|
code++;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user