Re: some question about snprintf

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi :

2011/2/7 Greg KH <greg@xxxxxxxxx>:
> On Sun, Feb 06, 2011 at 05:23:01PM +0800, loody wrote:
>> hi:
>>
>> 2011/2/6 loody <miloody@xxxxxxxxx>:
>> > hi all:
>> > I want to use snprintf for collecting debug message and print it later.
>> > But I found :
>> > 1. when I add "\n" as below, the buffer will be cleared, that means
>> > the "irq status" will put at the head of Buffer instead of at the end
>> > of "ehci work".
>> >    Size -= snprintf (Buffer , Size,"ehci_work\n");
>> >    Size -= snprintf (Buffer , Size,"irq status 0x%x\n",status);
>> > is it possible to add "\n" in the buffer, but will will not reset the buffer?
>> >
>> > 2. instead of snprintf, is there any better idea for saving debug
>> > message and show it out later?
>> 3. is there any function in kernel, like snprintf, which will also
>> collect strings but tread the buffer as ring buffer, such that I will
>> not need to take care the overflow.
>
> Look at include/linux/ring_buffer.h
I found some code such as ftrace seems use ring_buffer to record the data.
but the source is hard to understand for me right now. :-)
Is there simple sample code or document for me to reference?

-- 
Thank U,
miloody

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux