This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix runtime/itrace.c to call arch_has_*_step() prior to calling utrace_control


As Roland pointed out in his Mar 31 reply to a posting of mine (subject: Re: Testing insn.block probe point uncovers possible utrace bug), utrace_control() documents that the caller must ensure that arch_has_single_step and arch_has_block_step are defined before trying to use those step modes.  The attached patch addresses that issue.  I've tested this patch on x86_64 arch, and a block step test runs successfully, since block step is supported on that arch.  Testing on ppc64 arch, the test fails as expected (since block step is not supported on ppc64 yet) with:
	"ERROR: callback for <pid> failed: 1"
which is sent to stdderr and
	"usr_itrace_init: arch does not support block step mode"
which is sent to the system log.

This isn't the most user-friendly way of surfacing an error.  Perhaps the stap runtime could have a set of defined return codes that would be mapped to strings so the user can get an idea of what the error is without looking in the system log.  But that's a side issue, of course.

Regards,
-Maynard
diff -paur systemtap-0.9.5/runtime/itrace.c systemtap-0.9.5-insn-fix/runtime/itrace.c
--- systemtap-0.9.5/runtime/itrace.c	2009-03-27 13:02:57.000000000 -0400
+++ systemtap-0.9.5-insn-fix/runtime/itrace.c	2009-04-01 14:26:22.000000000 -0400
@@ -318,6 +318,19 @@ static int usr_itrace_init(int single_st
 	struct task_struct *tsk;
 
 	spin_lock_init(&itrace_lock);
+
+	/* 'arch_has_single_step' needs to be defined for either single step mode
+	 * or branch mode.
+	 */
+	if (!arch_has_single_step()) {
+		printk(KERN_ERR "usr_itrace_init: arch does not support step mode\n");
+		return 1;
+	}
+	if (!single_step && !arch_has_block_step()) {
+		printk(KERN_ERR "usr_itrace_init: arch does not support block step mode\n");
+		return 1;
+	}
+
 	rcu_read_lock();
 #ifdef STAPCONF_FIND_TASK_PID
 	tsk = find_task_by_pid(tid);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]