Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 2948
b: refs/heads/master
c: 852cacc
h: refs/heads/master
v: v3
  • Loading branch information
Anil S Keshavamurthy authored and Linus Torvalds committed Jun 23, 2005
1 parent cf581f8 commit 89bec71
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e539c2331414e73a5a1b79fb57369d79447c1cf8
refs/heads/master: 852caccc89d3883522e87a91bfa89fd9c9cfe15a
49 changes: 43 additions & 6 deletions trunk/arch/ia64/kernel/kprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ extern void jprobe_inst_return(void);
#define KPROBE_HIT_ACTIVE 0x00000001
#define KPROBE_HIT_SS 0x00000002

static struct kprobe *current_kprobe;
static unsigned long kprobe_status;
static struct kprobe *current_kprobe, *kprobe_prev;
static unsigned long kprobe_status, kprobe_status_prev;
static struct pt_regs jprobe_saved_regs;

enum instruction_type {A, I, M, F, B, L, X, u};
Expand Down Expand Up @@ -273,6 +273,23 @@ static int valid_kprobe_addr(int template, int slot, unsigned long addr)
return 0;
}

static inline void save_previous_kprobe(void)
{
kprobe_prev = current_kprobe;
kprobe_status_prev = kprobe_status;
}

static inline void restore_previous_kprobe(void)
{
current_kprobe = kprobe_prev;
kprobe_status = kprobe_status_prev;
}

static inline void set_current_kprobe(struct kprobe *p)
{
current_kprobe = p;
}

int arch_prepare_kprobe(struct kprobe *p)
{
unsigned long addr = (unsigned long) p->addr;
Expand Down Expand Up @@ -436,8 +453,18 @@ static int pre_kprobes_handler(struct die_args *args)
unlock_kprobes();
goto no_kprobe;
}
arch_disarm_kprobe(p);
ret = 1;
/* We have reentered the pre_kprobe_handler(), since
* another probe was hit while within the handler.
* We here save the original kprobes variables and
* just single step on the instruction of the new probe
* without calling any user handlers.
*/
save_previous_kprobe();
set_current_kprobe(p);
p->nmissed++;
prepare_ss(p, regs);
kprobe_status = KPROBE_REENTER;
return 1;
} else if (args->err == __IA64_BREAK_JPROBE) {
/*
* jprobe instrumented function just completed
Expand All @@ -460,7 +487,7 @@ static int pre_kprobes_handler(struct die_args *args)
}

kprobe_status = KPROBE_HIT_ACTIVE;
current_kprobe = p;
set_current_kprobe(p);

if (p->pre_handler && p->pre_handler(p, regs))
/*
Expand All @@ -485,12 +512,22 @@ static int post_kprobes_handler(struct pt_regs *regs)
if (!kprobe_running())
return 0;

if (current_kprobe->post_handler)
if ((kprobe_status != KPROBE_REENTER) && current_kprobe->post_handler) {
kprobe_status = KPROBE_HIT_SSDONE;
current_kprobe->post_handler(current_kprobe, regs, 0);
}

resume_execution(current_kprobe, regs);

/*Restore back the original saved kprobes variables and continue. */
if (kprobe_status == KPROBE_REENTER) {
restore_previous_kprobe();
goto out;
}

unlock_kprobes();

out:
preempt_enable_no_resched();
return 1;
}
Expand Down

0 comments on commit 89bec71

Please sign in to comment.