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]

Re: stp_exit change


This change was part of some error handling cleanup I have been meaning
to check in for a while. However after checking in that one change I
realized things have changed some and I will probably go in a slightly
different direction.

Currently the translator emits lots of code like this:
	atomic_set (& session_state, STAP_SESSION_ERROR);
	_stp_exit ();
and
	atomic_set (&session_state, STAP_SESSION_ERROR);
	_stp_error ("foo broke");
and sometimes we want to exit for normal reasons (not an error)
	atomic_set (& session_state, STAP_SESSION_STOPPING);
	_stp_exit ();

Within the runtime, sometimes unexpected errors happen and there is
either no return value for the function of the translator doesn't check
it. Or maybe the runtime function just wants to print out an exact error
message about what happened. These functions call stp_error or stp_exit.
They should really set the session state variable too.

So cleaning this up looks easy enough, 
void _stp_exit (int err)
{
	if (err)
		atomic_set (&session_state, STAP_SESSION_ERROR);
	else
		atomic_set (&session_state, STAP_SESSION_STOPPING);
	_stp_exit_flag = 1;
}

void _stp_error (const char *fmt, ...)
{
	va_list args;
	va_start(args, fmt);
	_stp_vlog (ERROR, NULL, 0, fmt, args);
	va_end(args);
	_stp_exit(1);
}

I recommend eliminating _stp_softerror() unless you can explain the
difference between it and _stp_warn().

Currently, setting session_state to either STAP_SESSION_ERROR or
STAP_SESSION_STOPPING has the same effect; it stops probes except the
end probe from executing. STAP_SESSION_ERROR seems to have no other use.
Do you have plans for it?  Should stap exit with an error code if it is
set?





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