@@ -368,40 +368,28 @@ int notesnap_register(void)
368
368
369
369
void notesnap_dump_with_stream (FAR struct lib_outstream_s * stream )
370
370
{
371
+ size_t index = g_notesnap .index % CONFIG_DRIVERS_NOTESNAP_NBUFFERS ;
371
372
size_t i ;
372
- size_t index = atomic_load (& g_notesnap .index ) %
373
- CONFIG_DRIVERS_NOTESNAP_NBUFFERS ;
374
- clock_t lastcount = g_notesnap .buffer [index ].count ;
375
- struct timespec lasttime =
376
- {
377
- 0
378
- };
379
373
380
374
/* Stop recording while dumping */
381
375
382
376
atomic_store (& g_notesnap .dumping , true);
383
377
384
- for (i = index ; i != index - 1 ;
385
- i == CONFIG_DRIVERS_NOTESNAP_NBUFFERS - 1 ? i = 0 : i ++ )
378
+ for (i = 0 ; i < CONFIG_DRIVERS_NOTESNAP_NBUFFERS ; i ++ )
386
379
{
387
- FAR struct notesnap_chunk_s * note = & g_notesnap .buffer [ i ];
388
-
380
+ FAR struct notesnap_chunk_s * note = & g_notesnap .buffer
381
+ [( index + i ) % CONFIG_DRIVERS_NOTESNAP_NBUFFERS ];
389
382
struct timespec time ;
390
- clock_t elapsed = note -> count < lastcount ?
391
- note -> count + CLOCK_MAX - lastcount :
392
- note -> count - lastcount ;
393
- perf_convert (elapsed , & time );
394
- clock_timespec_add (& lasttime , & time , & lasttime );
395
- lastcount = note -> count ;
396
383
384
+ perf_convert (note -> count , & time );
397
385
lib_sprintf (stream ,
398
386
"snapshoot: [%u.%09u] "
399
387
#ifdef CONFIG_SMP
400
388
"[CPU%d] "
401
389
#endif
402
390
"[%d] %-16s %#" PRIxPTR "\n" ,
403
- (unsigned )lasttime .tv_sec ,
404
- (unsigned )lasttime .tv_nsec ,
391
+ (unsigned )time .tv_sec ,
392
+ (unsigned )time .tv_nsec ,
405
393
#ifdef CONFIG_SMP
406
394
note -> cpu ,
407
395
#endif
0 commit comments