This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[PATCH] Fix compilation errors for itrace probe point
- From: Maynard Johnson <maynardj at us dot ibm dot com>
- To: systemtap at sourceware dot org
- Date: Mon, 02 Mar 2009 15:46:25 -0600
- Subject: [PATCH] Fix compilation errors for itrace probe point
Hello,
I recently pulled down the systemtap src onto a Fedora 10 system and tried to use the itrace probe point. The resulting kernel module failed to compile because the runtime/itrace.c file had not been updated to reflect the recent utrace interface changes. This problem had not been caught because the itrace test is currently disabled (since it fails on x86_64). I am working on the itrace test problem and will post a separate patch when I have it resolved. The patch attached to this message addresses mainly the utrace interface changes, but also includes a couple other minor unrelated fixes (e.g., removing unnecessary #includes in runtime/itrace.c and adding a #include for task_finder.c in tapsets.cxx). With this patch, the kernel module with itrace probe point compiles OK on x86_64; however, there is another compilation issue on ppc64 which I will post a separate note about.
NOTE: When I pulled systemtap today (using git clone git://sources.redhat.com/git/systemtap.git) to make sure my patch applied cleanly to current code, there were no ChangeLog files in the src tree. There were ChangeLogs in the tree that I pulled down a few weeks ago. Did something change in the process that I didn't catch?
Thanks for your time in reviewing this patch.
-Maynard
diff -paur systemtap/runtime/itrace.c systemtap-updated/runtime/itrace.c
--- systemtap/runtime/itrace.c 2009-02-10 11:55:26.000000000 -0500
+++ systemtap-updated/runtime/itrace.c 2009-03-02 15:50:13.000000000 -0500
@@ -1,6 +1,6 @@
/*
* user space instruction tracing
- * Copyright (C) 2005, 2006, 2007, 2008 IBM Corp.
+ * Copyright (C) 2005, 2006, 2007, 2008, 2009 IBM Corp.
*
* This file is part of systemtap, and is free software. You can
* redistribute it and/or modify it under the terms of the GNU General
@@ -18,8 +18,6 @@
#include <linux/rcupdate.h>
#include <linux/utrace.h>
#include <asm/string.h>
-#include <asm/tracehook.h>
-#include <asm/ptrace.h>
#include "uprobes/uprobes.h"
#ifndef put_task_struct
@@ -65,10 +63,26 @@ static struct itrace_info *create_itrace
struct task_struct *tsk, u32 step_flag,
struct stap_itrace_probe *itrace_probe);
-static u32 usr_itrace_report_signal(struct utrace_attached_engine *engine,
+static u32 usr_itrace_report_quiesce(enum utrace_resume_action action,
+ struct utrace_attached_engine *engine,
+ struct task_struct *tsk,
+ unsigned long event)
+{
+ int status;
+ struct itrace_info *ui;
+
+ ui = rcu_dereference(engine->data);
+ WARN_ON(!ui);
+
+ return (event == 0 ? ui->step_flag : UTRACE_RESUME);
+}
+
+
+static u32 usr_itrace_report_signal(u32 action,
+ struct utrace_attached_engine *engine,
struct task_struct *tsk,
struct pt_regs *regs,
- u32 action, siginfo_t *info,
+ siginfo_t *info,
const struct k_sigaction *orig_ka,
struct k_sigaction *return_ka)
{
@@ -83,12 +97,10 @@ static u32 usr_itrace_report_signal(stru
WARN_ON(!ui);
if (info->si_signo != SIGTRAP || !ui)
- return UTRACE_ACTION_RESUME;
-
- /* normal case: continue stepping, hide this trap from other engines */
- return_flags = ui->step_flag | UTRACE_ACTION_HIDE | UTRACE_SIGNAL_IGN |
- UTRACE_ACTION_NEWSTATE;
+ return UTRACE_RESUME;
+ /* normal case: continue stepping */
+ return_flags = ui->step_flag | UTRACE_SIGNAL_IGN;
#ifdef CONFIG_PPC
if (ui->ppc_atomic_ss.step_over_atomic) {
remove_atomic_ss_breakpoint(tsk, &ui->ppc_atomic_ss.end_bpt);
@@ -99,8 +111,7 @@ static u32 usr_itrace_report_signal(stru
}
if (handle_ppc_atomic_seq(tsk, regs, &ui->ppc_atomic_ss))
- return_flags = UTRACE_ACTION_RESUME | UTRACE_ACTION_NEWSTATE |
- UTRACE_SIGNAL_IGN;
+ return_flags = UTRACE_RESUME | UTRACE_SIGNAL_IGN;
#endif
enter_itrace_probe(ui->itrace_probe, regs, (void *)&data);
@@ -108,24 +119,26 @@ static u32 usr_itrace_report_signal(stru
return return_flags;
}
-static u32 usr_itrace_report_clone(struct utrace_attached_engine *engine,
+static u32 usr_itrace_report_clone(enum utrace_resume_action action,
+ struct utrace_attached_engine *engine,
struct task_struct *parent, unsigned long clone_flags,
struct task_struct *child)
{
- return UTRACE_ACTION_RESUME;
+ return UTRACE_RESUME;
}
static u32 usr_itrace_report_death(struct utrace_attached_engine *e,
- struct task_struct *tsk)
+ struct task_struct *tsk, bool group_dead, int signal)
{
struct itrace_info *ui = rcu_dereference(e->data);
WARN_ON(!ui);
- return (UTRACE_ACTION_NEWSTATE | UTRACE_ACTION_DETACH);
+ return (UTRACE_DETACH);
}
static const struct utrace_engine_ops utrace_ops =
{
+ .report_quiesce = usr_itrace_report_quiesce,
.report_signal = usr_itrace_report_signal,
.report_clone = usr_itrace_report_clone,
.report_death = usr_itrace_report_death
@@ -137,6 +150,7 @@ static struct itrace_info *create_itrace
struct stap_itrace_probe *itrace_probe)
{
struct itrace_info *ui;
+ int status;
if (debug)
printk(KERN_INFO "create_itrace_info: tid=%d\n", tsk->pid);
@@ -154,20 +168,34 @@ static struct itrace_info *create_itrace
/* push ui onto usr_itrace_info */
spin_lock(&itrace_lock);
list_add(&ui->link, &usr_itrace_info);
+ spin_unlock(&itrace_lock);
/* attach a single stepping engine */
- ui->engine = utrace_attach(ui->tsk, UTRACE_ATTACH_CREATE, &utrace_ops, ui);
+ ui->engine = utrace_attach_task(ui->tsk, UTRACE_ATTACH_CREATE, &utrace_ops, ui);
if (IS_ERR(ui->engine)) {
printk(KERN_ERR "utrace_attach returns %ld\n",
PTR_ERR(ui->engine));
- ui = NULL;
- } else {
- utrace_set_flags(tsk, ui->engine, ui->engine->flags |
- ui->step_flag |
- UTRACE_EVENT(CLONE) | UTRACE_EVENT_SIGNAL_ALL |
- UTRACE_EVENT(DEATH));
+ return NULL;
}
- spin_unlock(&itrace_lock);
+ status = utrace_set_events(tsk, ui->engine, ui->engine->flags |
+ UTRACE_EVENT(QUIESCE) |
+ UTRACE_EVENT(CLONE) | UTRACE_EVENT_SIGNAL_ALL |
+ UTRACE_EVENT(DEATH));
+ if (status < 0) {
+ printk(KERN_ERR "utrace_attach returns %d\n", status);
+ return NULL;
+ }
+
+ status = utrace_control(tsk, ui->engine, UTRACE_STOP);
+ if (status == 0) {
+ status = utrace_control(tsk, ui->engine, step_flag);
+ if (status < 0) {
+ printk(KERN_ERR "utrace_control(%d) returns %d\n",
+ step_flag, status);
+ return NULL;
+ }
+ }
+
return ui;
}
@@ -193,7 +221,7 @@ static int usr_itrace_init(int single_st
struct task_struct *tsk;
rcu_read_lock();
- tsk = find_task_by_pid(tid);
+ tsk = find_task_by_vpid(tid);
if (!tsk) {
printk(KERN_ERR "usr_itrace_init: Cannot find process %d\n", tid);
rcu_read_unlock();
@@ -203,7 +231,7 @@ static int usr_itrace_init(int single_st
get_task_struct(tsk);
ui = create_itrace_info(tsk,
(single_step ?
- UTRACE_ACTION_SINGLESTEP : UTRACE_ACTION_BLOCKSTEP), p);
+ UTRACE_SINGLESTEP : UTRACE_BLOCKSTEP), p);
if (!ui)
return 1;
@@ -223,6 +251,7 @@ static int usr_itrace_init(int single_st
void static remove_usr_itrace_info(struct itrace_info *ui)
{
struct itrace_info *tmp;
+ int status;
if (!ui)
return;
@@ -232,7 +261,11 @@ void static remove_usr_itrace_info(struc
spin_lock(&itrace_lock);
if (ui->tsk && ui->engine) {
- (void) utrace_detach(ui->tsk, ui->engine);
+ status = utrace_control(ui->tsk, ui->engine, UTRACE_DETACH);
+ if (status < 0 && status != -ESRCH)
+ printk(KERN_ERR
+ "utrace_control(UTRACE_DETACH) returns %d\n",
+ status);
}
list_del(&ui->link);
spin_unlock(&itrace_lock);
diff -paur systemtap/tapsets.cxx systemtap-updated/tapsets.cxx
--- systemtap/tapsets.cxx 2009-02-10 11:55:26.000000000 -0500
+++ systemtap-updated/tapsets.cxx 2009-03-02 15:48:58.000000000 -0500
@@ -6078,6 +6078,7 @@ itrace_derived_probe_group::emit_module_
s.op->newline();
s.op->newline() << "/* ---- itrace probes ---- */";
+ s.op->newline() << "#include \"task_finder.c\"";
s.op->newline() << "struct stap_itrace_probe {";
s.op->indent(1);
s.op->newline() << "struct stap_task_finder_target tgt;";