printf in top.c

walter harms wharms at bfs.de
Wed Jun 3 07:25:54 UTC 2015



Am 03.06.2015 06:54, schrieb Wei, Catherine:
> Hi:
>      Lately I'm trying to debug the top command in an embedded linux 
> box. I've added some printf in top.c, for example:
> 
> fprintf(stderr,"catherine %lu %lu %lu %lu %lu 
> %lu\n",used,mfree,shared,buffers,cached,total);
> printf("catherine--------------------------------------");


warning:
printf debugging can be hugely missleading, due to the buffering.
e.g. you are missing a "\n", so the buffer may be flushed later.

to make sure you can use fflush() or dprintf().

re,
 wh


> 
> in many place, even in the beginning of top_main() function, after 
> building it, I copied the busybox bin file to my box, and the print log 
> can not be printed out. I don't know why. Do I need some special config 
> to build it? Could you please give me some advice? Thank you.
> 
> By the way, the purpose that I'm debugging top command is that some 
> memory display information is not right due to the change of 
> /proc/meminfo, we may need to make a patch for busybox in our system.
> 
> Best regard
> Catherine
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
> 


More information about the busybox mailing list