[PATCH 70] move "event << 8" into syscall_code()

Oleg Nesterov oleg at redhat.com
Wed Oct 7 12:12:18 UTC 2009


On 10/07, Roland McGrath wrote:
>
> Make it something like:
>
> 	static inline void set_stop_code(struct ptrace_context *ctx, int event)
> 	{
> 		ctx->stop_code = (event << 8) | SIGTRAP |
> 			(event >= PTRACE_EVENT_SYSCALL_ENTRY &&
> 			 (ctx->options & PTRACE_O_TRACESYSGOOD) ? 0x80 : 0);
> 	}
>
> and pick PTRACE_EVENT_* numbers so SYSCALL_{ENTRY,EXIT} are highest,
> or something along those lines.

Oh, I don't like this. This is unreadable, and ">= PTRACE_EVENT_" complicates
the reading even more.

How about

	void set_stop_code(struct ptrace_context *ctx, int event)
	{
		ctx->stop_code = (event << 8) | SIGTRAP;
	}

	void set_syscall_code(struct ptrace_context *ctx, int event)
	{
		set_stop_code(ctx, event);
		if (PTRACE_O_TRACESYSGOOD)
			ctx->stop_code |= 0x80;
	}

Or,
	void __set_stop_code(struct ptrace_context *ctx, int event, int sig)
	{
		ctx->stop_code = (event << 8) | sig;
	}

	void set_syscall_code(struct ptrace_context *ctx, int event)
	{
		int sig = PTRACE_O_TRACESYSGOOD ? (0x80 | SIGTRAP) : SIGTRAP;

		__set_stop_code(event, sig);
	}

	void set_stop_code(struct ptrace_context *ctx, int event)
	{
		__set_stop_code(event, SIGTRAP);
	}

This way ptrace_report_signal() can use __set_stop_code() too.

But this is minor, if your prefer your version I'll send the patch.

Oleg.




More information about the utrace-devel mailing list