[PATCH v2] ARM: support syscall tracing

Wade Farnsworth wade_farnsworth at mentor.com
Wed Aug 15 12:58:44 EDT 2012


Will Deacon wrote:
> Hi Wade,
>
> On Wed, Aug 15, 2012 at 04:14:20PM +0100, Wade Farnsworth wrote:
>> diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
>> index 3e0fc5f..4e82fc1 100644
>> --- a/arch/arm/kernel/ptrace.c
>> +++ b/arch/arm/kernel/ptrace.c
>> @@ -30,6 +30,9 @@
>>   #include<asm/pgtable.h>
>>   #include<asm/traps.h>
>>
>> +#define CREATE_TRACE_POINTS
>> +#include<trace/events/syscalls.h>
>> +
>>   #define REG_PC	15
>>   #define REG_PSR	16
>>   /*
>> @@ -918,7 +921,8 @@ static int ptrace_syscall_trace(struct pt_regs *regs, int scno,
>>   {
>>   	unsigned long ip;
>>
>> -	if (!test_thread_flag(TIF_SYSCALL_TRACE))
>> +	if (!test_thread_flag(TIF_SYSCALL_TRACE)&&
>> +	    !test_thread_flag(TIF_SYSCALL_TRACEPOINT))
>>   		return scno;
>
> Can we now remove this hunk?
>
>>   	current_thread_info()->syscall = scno;
>> @@ -930,10 +934,12 @@ static int ptrace_syscall_trace(struct pt_regs *regs, int scno,
>>   	ip = regs->ARM_ip;
>>   	regs->ARM_ip = dir;
>>
>> -	if (dir == PTRACE_SYSCALL_EXIT)
>> -		tracehook_report_syscall_exit(regs, 0);
>> -	else if (tracehook_report_syscall_entry(regs))
>> -		current_thread_info()->syscall = -1;
>> +	if (test_thread_flag(TIF_SYSCALL_TRACE)) {
>> +		if (dir == PTRACE_SYSCALL_EXIT)
>> +			tracehook_report_syscall_exit(regs, 0);
>> +		else if (tracehook_report_syscall_entry(regs))
>> +			current_thread_info()->syscall = -1;
>> +	}
>
> and also this one?
>

We need to set current_thread_info()->syscall, since it's used in the 
call to syscall_get_nr() in perf_syscall_{enter,exit}.

What about moving the setting of ->syscall to 
syscall_trace_{enter,exit}?  That would preserve ptrace_syscall_trace() 
for the TIF_SYSCALL_TRACE case only, but ensure that the field is set 
the TRACEPOINT case as well.  Thoughts?

Thanks for the feedback!

Wade




More information about the linux-arm-kernel mailing list