static void _stp_stack_user_sprint(char *str, int size, struct context* c,
				   int sym_flags)
{
	/* To get an hex string, we use a simple trick.
	 * First flush the print buffer,
	 * then call _stp_stack_print,
	 * then copy the result into the output string
	 * and clear the print buffer. */
	_stp_pbuf *pb = per_cpu_ptr(Stp_pbuf, smp_processor_id());
	_stp_print_flush();

	_stp_stack_user_print(c, sym_flags);

	strlcpy(str, pb->buf, size < (int)pb->len ? size : (int)pb->len);
	pb->len = 0;
}
Beispiel #2
0
static void _stp_vlog (enum code type, const char *func, int line, const char *fmt, va_list args)
{
	int num;
	char *buf = per_cpu_ptr(Stp_lbuf, get_cpu());
	int start = 0;

	if (type == DBUG) {
		start = _stp_snprintf(buf, STP_LOG_BUF_LEN, "%s:%d: ", func, line);
	} else if (type == WARN) {
		/* This strcpy() is OK, since we know STP_LOG_BUF_LEN
		 * is > sizeof(WARN_STRING). */
		strcpy (buf, WARN_STRING);
		start = sizeof(WARN_STRING) - 1;
	} else if (type == ERROR) {
		/* This strcpy() is OK, since we know STP_LOG_BUF_LEN
		 * is > sizeof(ERR_STRING) (which is < sizeof(WARN_STRING). */
		strcpy (buf, ERR_STRING);
		start = sizeof(ERR_STRING) - 1;
	}

	num = vscnprintf (buf + start, STP_LOG_BUF_LEN - start - 1, fmt, args);
	if (num + start) {
		if (buf[num + start - 1] != '\n') {
			buf[num + start] = '\n';
			num++;
			buf[num + start] = '\0';
		}

#ifdef STAP_DEBUG_PRINTK
                if (type == DBUG) printk (KERN_DEBUG "%s", buf);
                else if (type == WARN) printk (KERN_WARNING "%s", buf);
                else if (type == ERROR) printk (KERN_ERR "%s", buf);
                else printk (KERN_INFO "%s", buf);
#else
		if (type != DBUG) {
			_stp_ctl_send(STP_OOB_DATA, buf, start + num + 1);
		} else {
			_stp_print(buf);
			_stp_print_flush();
		}
#endif
	}
	put_cpu();
}