Re: [RFC][PATCH 1/2] tracing/events: provide string with undefined size support

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Steven Rostedt
Date: Wednesday, April 15, 2009 - 6:33 pm

On Thu, 16 Apr 2009, Frederic Weisbecker wrote:


And I thought I was the only one that could master CPP wackiness ;-)

BTW, I was confused on IRC, because I was thinking this was printf like, 
but no, we only need to be concerned about a string.

But I have another idea:




We can get rid of the has_ending_string and open_string_assign and have 
this:

 
        TP_STRUCT__entry(
                __field(unsigned long, wait_usec)
                __field(unsigned long, wait_nsec_rem)
                __ending_string(name)
        ),
        TP_fast_assign(
                __entry->wait_nsec_rem = do_div(waittime, NSEC_PER_USEC);
                __entry->wait_usec = (unsigned long) waittime;
                strcpy(__entry->name, lock->name);
        ),


Then we could do the following in the print the assign:

#undef __field
#define __field(a,b)
#undef __array
#define __array(a,b,c)
#undef __ending_sting
#define __ending_string(name) __str_size__ += strlen(name) + 1;

#define TRACE_EVENT(call, proto, args, tstruct, assign, print)
static void ftrace_raw_event_##call(proto)
{
	int __str_size__ = 0;

	tstruct

	event = trace_current_buffer_lock_reserve(event_##call.id,
				sizeof(struct ftrace_raw_##call) +
				__str_size__,
				irq_flags, pc)
	if (!event)
		return;

	entry = ring_buffer_event_data(event);

	assign
}


Yes, I did not add other declarations nor the backslashes for the macro, 
but you get what I'm doing, right?

-- Steve

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC][PATCH 1/2] tracing/events: provide string with undef ..., Frederic Weisbecker, (Wed Apr 15, 4:27 pm)
[RFC][PATCH 2/2] tracing/lock: provide lock_acquired event ..., Frederic Weisbecker, (Wed Apr 15, 4:27 pm)
Re: [RFC][PATCH 1/2] tracing/events: provide string with u ..., Steven Rostedt, (Wed Apr 15, 6:33 pm)
Re: [RFC][PATCH 1/2] tracing/events: provide string with u ..., Frederic Weisbecker, (Thu Apr 16, 12:35 am)
Re: [RFC][PATCH 1/2] tracing/events: provide string with u ..., Frederic Weisbecker, (Thu Apr 16, 12:42 am)
Re: [RFC][PATCH 1/2] tracing/events: provide string with u ..., Frederic Weisbecker, (Thu Apr 16, 9:19 am)