2020-09-08 18:44:29 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* drivers/note/noteram_driver.c
|
|
|
|
*
|
2024-11-05 20:02:24 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
2021-03-04 14:10:42 +08:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2020-09-08 18:44:29 +08:00
|
|
|
*
|
2021-03-04 14:10:42 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2020-09-08 18:44:29 +08:00
|
|
|
*
|
2021-03-04 14:10:42 +08:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2020-09-08 18:44:29 +08:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sched.h>
|
2020-09-09 08:06:38 +08:00
|
|
|
#include <fcntl.h>
|
2020-09-08 18:44:29 +08:00
|
|
|
#include <assert.h>
|
|
|
|
#include <errno.h>
|
2023-08-11 10:31:02 +08:00
|
|
|
#include <stdio.h>
|
2020-10-28 09:45:30 +08:00
|
|
|
#include <string.h>
|
2023-11-14 15:50:52 +08:00
|
|
|
#include <inttypes.h>
|
2024-01-24 11:28:49 +08:00
|
|
|
#include <poll.h>
|
2020-09-08 18:44:29 +08:00
|
|
|
|
|
|
|
#include <nuttx/spinlock.h>
|
2020-10-28 09:45:30 +08:00
|
|
|
#include <nuttx/sched.h>
|
2020-09-08 18:44:29 +08:00
|
|
|
#include <nuttx/sched_note.h>
|
2023-04-27 19:42:27 +08:00
|
|
|
#include <nuttx/kmalloc.h>
|
2022-12-16 18:31:28 +08:00
|
|
|
#include <nuttx/note/note_driver.h>
|
2020-09-08 18:44:29 +08:00
|
|
|
#include <nuttx/note/noteram_driver.h>
|
2023-07-05 21:53:33 +08:00
|
|
|
#include <nuttx/panic_notifier.h>
|
2020-09-08 18:44:29 +08:00
|
|
|
#include <nuttx/fs/fs.h>
|
2023-08-11 10:31:04 +08:00
|
|
|
#include <nuttx/streams.h>
|
2020-09-08 18:44:29 +08:00
|
|
|
|
2023-08-11 10:31:02 +08:00
|
|
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL
|
|
|
|
# ifdef CONFIG_LIB_SYSCALL
|
|
|
|
# include <syscall.h>
|
|
|
|
# else
|
|
|
|
# define CONFIG_LIB_SYSCALL
|
|
|
|
# include <syscall.h>
|
|
|
|
# undef CONFIG_LIB_SYSCALL
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#define NCPUS CONFIG_SMP_NCPUS
|
|
|
|
|
|
|
|
/* Renumber idle task PIDs
|
|
|
|
* In NuttX, PID number less than NCPUS are idle tasks.
|
|
|
|
* In Linux, there is only one idle task of PID 0.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define get_pid(pid) ((pid) < NCPUS ? 0 : (pid))
|
|
|
|
|
|
|
|
#define get_task_state(s) \
|
|
|
|
((s) == 0 ? 'X' : ((s) <= LAST_READY_TO_RUN_STATE ? 'R' : 'S'))
|
|
|
|
|
2020-09-08 18:44:29 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Private Types
|
|
|
|
****************************************************************************/
|
|
|
|
|
2023-04-27 19:42:27 +08:00
|
|
|
struct noteram_driver_s
|
2020-09-08 18:44:29 +08:00
|
|
|
{
|
2023-04-27 19:42:27 +08:00
|
|
|
struct note_driver_s driver;
|
2023-04-20 18:27:15 +08:00
|
|
|
FAR uint8_t *ni_buffer;
|
|
|
|
size_t ni_bufsize;
|
2022-03-27 04:51:22 +08:00
|
|
|
unsigned int ni_overwrite;
|
2020-09-08 18:44:29 +08:00
|
|
|
volatile unsigned int ni_head;
|
|
|
|
volatile unsigned int ni_tail;
|
2020-09-09 08:06:38 +08:00
|
|
|
volatile unsigned int ni_read;
|
2023-04-27 19:42:27 +08:00
|
|
|
spinlock_t lock;
|
2024-01-24 11:28:49 +08:00
|
|
|
FAR struct pollfd *pfd;
|
2020-09-08 18:44:29 +08:00
|
|
|
};
|
|
|
|
|
2023-08-11 10:31:02 +08:00
|
|
|
/* The structure to hold the context data of trace dump */
|
|
|
|
|
|
|
|
struct noteram_dump_cpu_context_s
|
|
|
|
{
|
|
|
|
int intr_nest; /* Interrupt nest level */
|
|
|
|
bool pendingswitch; /* sched_switch pending flag */
|
|
|
|
int current_state; /* Task state of the current line */
|
|
|
|
pid_t current_pid; /* Task PID of the current line */
|
|
|
|
pid_t next_pid; /* Task PID of the next line */
|
|
|
|
uint8_t current_priority; /* Task Priority of the current line */
|
|
|
|
uint8_t next_priority; /* Task Priority of the next line */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct noteram_dump_context_s
|
|
|
|
{
|
|
|
|
struct noteram_dump_cpu_context_s cpu[NCPUS];
|
2024-04-09 17:22:06 +08:00
|
|
|
unsigned int mode;
|
2023-08-11 10:31:02 +08:00
|
|
|
};
|
|
|
|
|
2020-09-08 18:44:29 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Private Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
2020-09-09 08:06:38 +08:00
|
|
|
static int noteram_open(FAR struct file *filep);
|
2023-08-11 10:31:02 +08:00
|
|
|
static int noteram_close(FAR struct file *filep);
|
2020-09-08 18:44:29 +08:00
|
|
|
static ssize_t noteram_read(FAR struct file *filep,
|
|
|
|
FAR char *buffer, size_t buflen);
|
2024-01-04 20:07:42 +08:00
|
|
|
static int noteram_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
|
2024-01-24 11:28:49 +08:00
|
|
|
static int noteram_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
|
|
|
bool setup);
|
2022-12-16 18:31:28 +08:00
|
|
|
static void noteram_add(FAR struct note_driver_s *drv,
|
|
|
|
FAR const void *note, size_t len);
|
2023-08-11 10:31:02 +08:00
|
|
|
static void
|
|
|
|
noteram_dump_init_context(FAR struct noteram_dump_context_s *ctx);
|
2023-08-11 10:31:04 +08:00
|
|
|
static int noteram_dump_one(FAR uint8_t *p, FAR struct lib_outstream_s *s,
|
2023-08-11 10:31:02 +08:00
|
|
|
FAR struct noteram_dump_context_s *ctx);
|
|
|
|
|
2020-09-08 18:44:29 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Private Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static const struct file_operations g_noteram_fops =
|
|
|
|
{
|
2020-09-09 08:06:38 +08:00
|
|
|
noteram_open, /* open */
|
2023-08-11 10:31:02 +08:00
|
|
|
noteram_close, /* close */
|
2020-09-08 18:44:29 +08:00
|
|
|
noteram_read, /* read */
|
|
|
|
NULL, /* write */
|
|
|
|
NULL, /* seek */
|
2020-09-09 08:06:38 +08:00
|
|
|
noteram_ioctl, /* ioctl */
|
2024-01-24 11:28:49 +08:00
|
|
|
NULL, /* mmap */
|
|
|
|
NULL, /* truncate */
|
|
|
|
noteram_poll, /* poll */
|
2020-09-08 18:44:29 +08:00
|
|
|
};
|
|
|
|
|
2024-04-07 17:52:59 +08:00
|
|
|
static
|
|
|
|
#ifdef DRIVERS_NOTERAM_SECTION
|
|
|
|
locate_data(DRIVERS_NOTERAM_SECTION)
|
|
|
|
#endif
|
|
|
|
uint8_t g_ramnote_buffer[CONFIG_DRIVERS_NOTERAM_BUFSIZE];
|
2023-04-20 18:27:15 +08:00
|
|
|
|
2022-12-16 18:31:28 +08:00
|
|
|
static const struct note_driver_ops_s g_noteram_ops =
|
|
|
|
{
|
|
|
|
noteram_add
|
|
|
|
};
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
2023-04-27 19:42:27 +08:00
|
|
|
struct noteram_driver_s g_noteram_driver =
|
2022-12-16 18:31:28 +08:00
|
|
|
{
|
2024-04-11 16:53:08 +08:00
|
|
|
{
|
|
|
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
|
|
|
|
"ram",
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE,
|
|
|
|
# ifdef CONFIG_SMP
|
|
|
|
CONFIG_SCHED_INSTRUMENTATION_CPUSET
|
|
|
|
# endif
|
|
|
|
},
|
|
|
|
},
|
|
|
|
#endif
|
|
|
|
&g_noteram_ops
|
|
|
|
},
|
2023-04-27 19:42:27 +08:00
|
|
|
g_ramnote_buffer,
|
|
|
|
CONFIG_DRIVERS_NOTERAM_BUFSIZE,
|
|
|
|
#ifdef CONFIG_DRIVERS_NOTERAM_DEFAULT_NOOVERWRITE
|
|
|
|
NOTERAM_MODE_OVERWRITE_DISABLE
|
|
|
|
#else
|
|
|
|
NOTERAM_MODE_OVERWRITE_ENABLE
|
|
|
|
#endif
|
2022-12-16 18:31:28 +08:00
|
|
|
};
|
|
|
|
|
2020-09-08 18:44:29 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Private Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
2020-09-09 08:06:38 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: noteram_buffer_clear
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Clear all contents of the circular buffer.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* None.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2023-04-27 19:42:27 +08:00
|
|
|
static void noteram_buffer_clear(FAR struct noteram_driver_s *drv)
|
2020-09-09 08:06:38 +08:00
|
|
|
{
|
2023-04-27 19:42:27 +08:00
|
|
|
drv->ni_tail = drv->ni_head;
|
|
|
|
drv->ni_read = drv->ni_head;
|
2020-09-09 08:06:38 +08:00
|
|
|
|
2023-04-27 19:42:27 +08:00
|
|
|
if (drv->ni_overwrite == NOTERAM_MODE_OVERWRITE_OVERFLOW)
|
2020-09-09 08:06:38 +08:00
|
|
|
{
|
2023-04-27 19:42:27 +08:00
|
|
|
drv->ni_overwrite = NOTERAM_MODE_OVERWRITE_DISABLE;
|
2020-09-09 08:06:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-08 18:44:29 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: noteram_next
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Return the circular buffer index at offset from the specified index
|
|
|
|
* value, handling wraparound
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* ndx - Old circular buffer index
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* New circular buffer index
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2023-04-27 19:42:27 +08:00
|
|
|
static inline unsigned int noteram_next(FAR struct noteram_driver_s *drv,
|
|
|
|
unsigned int ndx,
|
2020-09-08 18:44:29 +08:00
|
|
|
unsigned int offset)
|
|
|
|
{
|
|
|
|
ndx += offset;
|
2023-04-27 19:42:27 +08:00
|
|
|
if (ndx >= drv->ni_bufsize)
|
2020-09-08 18:44:29 +08:00
|
|
|
{
|
2023-04-27 19:42:27 +08:00
|
|
|
ndx -= drv->ni_bufsize;
|
2020-09-08 18:44:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return ndx;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: noteram_length
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Length of data currently in circular buffer.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Length of data currently in circular buffer.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2023-04-27 19:42:27 +08:00
|
|
|
static unsigned int noteram_length(FAR struct noteram_driver_s *drv)
|
2020-09-08 18:44:29 +08:00
|
|
|
{
|
2023-04-27 19:42:27 +08:00
|
|
|
unsigned int head = drv->ni_head;
|
|
|
|
unsigned int tail = drv->ni_tail;
|
2020-09-08 18:44:29 +08:00
|
|
|
|
|
|
|
if (tail > head)
|
|
|
|
{
|
2023-04-27 19:42:27 +08:00
|
|
|
head += drv->ni_bufsize;
|
2020-09-08 18:44:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return head - tail;
|
|
|
|
}
|
2020-09-09 08:06:38 +08:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: noteram_unread_length
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Length of unread data currently in circular buffer.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Length of unread data currently in circular buffer.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2023-04-27 19:42:27 +08:00
|
|
|
static unsigned int noteram_unread_length(FAR struct noteram_driver_s *drv)
|
2020-09-09 08:06:38 +08:00
|
|
|
{
|
2023-04-27 19:42:27 +08:00
|
|
|
unsigned int head = drv->ni_head;
|
|
|
|
unsigned int read = drv->ni_read;
|
2020-09-09 08:06:38 +08:00
|
|
|
|
|
|
|
if (read > head)
|
|
|
|
{
|
2023-04-27 19:42:27 +08:00
|
|
|
head += drv->ni_bufsize;
|
2020-09-09 08:06:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return head - read;
|
|
|
|
}
|
2020-09-08 18:44:29 +08:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: noteram_remove
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Remove the variable length note from the tail of the circular buffer
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* We are within a critical section.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2023-04-27 19:42:27 +08:00
|
|
|
static void noteram_remove(FAR struct noteram_driver_s *drv)
|
2020-09-08 18:44:29 +08:00
|
|
|
{
|
|
|
|
unsigned int tail;
|
|
|
|
unsigned int length;
|
|
|
|
|
|
|
|
/* Get the tail index of the circular buffer */
|
|
|
|
|
2023-04-27 19:42:27 +08:00
|
|
|
tail = drv->ni_tail;
|
|
|
|
DEBUGASSERT(tail < drv->ni_bufsize);
|
2020-09-08 18:44:29 +08:00
|
|
|
|
|
|
|
/* Get the length of the note at the tail index */
|
|
|
|
|
2023-11-13 12:11:23 +08:00
|
|
|
length = NOTE_ALIGN(drv->ni_buffer[tail]);
|
2023-04-27 19:42:27 +08:00
|
|
|
DEBUGASSERT(length <= noteram_length(drv));
|
2020-09-08 18:44:29 +08:00
|
|
|
|
|
|
|
/* Increment the tail index to remove the entire note from the circular
|
|
|
|
* buffer.
|
|
|
|
*/
|
|
|
|
|
2023-04-27 19:42:27 +08:00
|
|
|
if (drv->ni_read == drv->ni_tail)
|
2020-09-09 08:06:38 +08:00
|
|
|
{
|
|
|
|
/* The read index also needs increment. */
|
|
|
|
|
2023-04-27 19:42:27 +08:00
|
|
|
drv->ni_read = noteram_next(drv, tail, length);
|
2020-09-09 08:06:38 +08:00
|
|
|
}
|
|
|
|
|
2023-04-27 19:42:27 +08:00
|
|
|
drv->ni_tail = noteram_next(drv, tail, length);
|
2020-09-08 18:44:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: noteram_get
|
|
|
|
*
|
|
|
|
* Description:
|
2020-09-09 08:06:38 +08:00
|
|
|
* Get the next note from the read index of the circular buffer.
|
2020-09-08 18:44:29 +08:00
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* buffer - Location to return the next note
|
|
|
|
* buflen - The length of the user provided buffer.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* On success, the positive, non-zero length of the return note is
|
|
|
|
* provided. Zero is returned only if the circular buffer is empty. A
|
|
|
|
* negated errno value is returned in the event of any failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2023-04-27 19:42:27 +08:00
|
|
|
static ssize_t noteram_get(FAR struct noteram_driver_s *drv,
|
|
|
|
FAR uint8_t *buffer, size_t buflen)
|
2020-09-08 18:44:29 +08:00
|
|
|
{
|
|
|
|
FAR struct note_common_s *note;
|
|
|
|
unsigned int remaining;
|
2020-09-09 08:06:38 +08:00
|
|
|
unsigned int read;
|
2020-09-08 18:44:29 +08:00
|
|
|
ssize_t notelen;
|
|
|
|
size_t circlen;
|
|
|
|
|
|
|
|
DEBUGASSERT(buffer != NULL);
|
|
|
|
|
|
|
|
/* Verify that the circular buffer is not empty */
|
|
|
|
|
2023-04-27 19:42:27 +08:00
|
|
|
circlen = noteram_unread_length(drv);
|
2020-09-08 18:44:29 +08:00
|
|
|
if (circlen <= 0)
|
|
|
|
{
|
2022-12-28 18:00:06 +08:00
|
|
|
return 0;
|
2020-09-08 18:44:29 +08:00
|
|
|
}
|
|
|
|
|
2020-09-09 08:06:38 +08:00
|
|
|
/* Get the read index of the circular buffer */
|
2020-09-08 18:44:29 +08:00
|
|
|
|
2023-04-27 19:42:27 +08:00
|
|
|
read = drv->ni_read;
|
|
|
|
DEBUGASSERT(read < drv->ni_bufsize);
|
2020-09-08 18:44:29 +08:00
|
|
|
|
2020-09-09 08:06:38 +08:00
|
|
|
/* Get the length of the note at the read index */
|
2020-09-08 18:44:29 +08:00
|
|
|
|
2023-04-27 19:42:27 +08:00
|
|
|
note = (FAR struct note_common_s *)&drv->ni_buffer[read];
|
2020-09-08 18:44:29 +08:00
|
|
|
notelen = note->nc_length;
|
|
|
|
DEBUGASSERT(notelen <= circlen);
|
|
|
|
|
|
|
|
/* Is the user buffer large enough to hold the note? */
|
|
|
|
|
|
|
|
if (buflen < notelen)
|
|
|
|
{
|
2020-09-09 08:06:38 +08:00
|
|
|
/* Skip the large note so that we do not get constipated. */
|
2020-09-08 18:44:29 +08:00
|
|
|
|
2024-03-20 14:40:33 +08:00
|
|
|
drv->ni_read = noteram_next(drv, read, NOTE_ALIGN(notelen));
|
2020-09-08 18:44:29 +08:00
|
|
|
|
|
|
|
/* and return an error */
|
|
|
|
|
2022-12-28 18:00:06 +08:00
|
|
|
return -EFBIG;
|
2020-09-08 18:44:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Loop until the note has been transferred to the user buffer */
|
|
|
|
|
|
|
|
remaining = (unsigned int)notelen;
|
|
|
|
while (remaining > 0)
|
|
|
|
{
|
2020-09-09 08:06:38 +08:00
|
|
|
/* Copy the next byte at the read index */
|
2020-09-08 18:44:29 +08:00
|
|
|
|
2023-04-27 19:42:27 +08:00
|
|
|
*buffer++ = drv->ni_buffer[read];
|
2020-09-08 18:44:29 +08:00
|
|
|
|
|
|
|
/* Adjust indices and counts */
|
|
|
|
|
2023-04-27 19:42:27 +08:00
|
|
|
read = noteram_next(drv, read, 1);
|
2020-09-08 18:44:29 +08:00
|
|
|
remaining--;
|
|
|
|
}
|
|
|
|
|
2024-03-20 14:40:33 +08:00
|
|
|
drv->ni_read = noteram_next(drv, drv->ni_read, NOTE_ALIGN(notelen));
|
2020-09-08 18:44:29 +08:00
|
|
|
|
|
|
|
return notelen;
|
|
|
|
}
|
|
|
|
|
2020-09-09 08:06:38 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: noteram_open
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int noteram_open(FAR struct file *filep)
|
|
|
|
{
|
2023-08-11 10:31:02 +08:00
|
|
|
FAR struct noteram_dump_context_s *ctx;
|
|
|
|
FAR struct noteram_driver_s *drv = (FAR struct noteram_driver_s *)
|
|
|
|
filep->f_inode->i_private;
|
2023-04-27 19:42:27 +08:00
|
|
|
|
2020-09-09 08:06:38 +08:00
|
|
|
/* Reset the read index of the circular buffer */
|
|
|
|
|
2023-04-27 19:42:27 +08:00
|
|
|
drv->ni_read = drv->ni_tail;
|
2023-08-11 10:31:02 +08:00
|
|
|
ctx = kmm_zalloc(sizeof(*ctx));
|
|
|
|
if (ctx == NULL)
|
|
|
|
{
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2020-09-09 08:06:38 +08:00
|
|
|
|
2023-08-11 10:31:02 +08:00
|
|
|
filep->f_priv = ctx;
|
|
|
|
noteram_dump_init_context(ctx);
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
int noteram_close(FAR struct file *filep)
|
|
|
|
{
|
|
|
|
FAR struct noteram_dump_context_s *ctx = filep->f_priv;
|
2023-11-14 15:50:52 +08:00
|
|
|
|
2023-08-11 10:31:02 +08:00
|
|
|
kmm_free(ctx);
|
2020-09-09 08:06:38 +08:00
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
2020-09-08 18:44:29 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: noteram_read
|
|
|
|
****************************************************************************/
|
|
|
|
|
2023-08-11 10:31:02 +08:00
|
|
|
static ssize_t noteram_read(FAR struct file *filep, FAR char *buffer,
|
|
|
|
size_t buflen)
|
2020-09-08 18:44:29 +08:00
|
|
|
{
|
2023-08-11 10:31:02 +08:00
|
|
|
FAR struct noteram_dump_context_s *ctx = filep->f_priv;
|
2023-08-11 10:31:04 +08:00
|
|
|
FAR struct noteram_driver_s *drv = filep->f_inode->i_private;
|
|
|
|
FAR struct lib_memoutstream_s stream;
|
|
|
|
ssize_t ret;
|
2024-04-09 17:22:06 +08:00
|
|
|
irqstate_t flags;
|
2020-09-08 18:44:29 +08:00
|
|
|
|
2024-04-09 17:22:06 +08:00
|
|
|
if (ctx->mode == NOTERAM_MODE_READ_BINARY)
|
2020-09-08 18:44:29 +08:00
|
|
|
{
|
2023-08-11 10:31:02 +08:00
|
|
|
flags = spin_lock_irqsave_wo_note(&drv->lock);
|
2024-04-09 17:22:06 +08:00
|
|
|
ret = noteram_get(drv, (FAR uint8_t *)buffer, buflen);
|
2023-08-11 10:31:02 +08:00
|
|
|
spin_unlock_irqrestore_wo_note(&drv->lock, flags);
|
2024-04-09 17:22:06 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lib_memoutstream(&stream, buffer, buflen);
|
|
|
|
|
|
|
|
do
|
2020-09-08 18:44:29 +08:00
|
|
|
{
|
2024-04-09 17:22:06 +08:00
|
|
|
uint8_t note[256];
|
|
|
|
|
|
|
|
/* Get the next note (removing it from the buffer) */
|
2020-09-08 18:44:29 +08:00
|
|
|
|
2024-04-09 17:22:06 +08:00
|
|
|
flags = spin_lock_irqsave_wo_note(&drv->lock);
|
|
|
|
ret = noteram_get(drv, note, sizeof(note));
|
|
|
|
spin_unlock_irqrestore_wo_note(&drv->lock, flags);
|
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
2020-09-08 18:44:29 +08:00
|
|
|
|
2024-04-09 17:22:06 +08:00
|
|
|
/* Parse notes into text format */
|
|
|
|
|
|
|
|
ret = noteram_dump_one(note, (FAR struct lib_outstream_s *)&stream,
|
|
|
|
ctx);
|
|
|
|
}
|
|
|
|
while (ret == 0);
|
2020-09-08 18:44:29 +08:00
|
|
|
}
|
2023-08-11 10:31:02 +08:00
|
|
|
|
2023-08-11 10:31:04 +08:00
|
|
|
return ret;
|
2020-09-08 18:44:29 +08:00
|
|
|
}
|
|
|
|
|
2020-09-09 08:06:38 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: noteram_ioctl
|
|
|
|
****************************************************************************/
|
|
|
|
|
2022-12-26 13:18:33 +08:00
|
|
|
static int noteram_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
2020-09-09 08:06:38 +08:00
|
|
|
{
|
|
|
|
int ret = -ENOSYS;
|
2023-08-29 12:16:49 +08:00
|
|
|
FAR struct noteram_driver_s *drv = filep->f_inode->i_private;
|
2023-04-27 19:42:27 +08:00
|
|
|
irqstate_t flags = spin_lock_irqsave_wo_note(&drv->lock);
|
2020-09-09 08:06:38 +08:00
|
|
|
|
|
|
|
/* Handle the ioctl commands */
|
|
|
|
|
|
|
|
switch (cmd)
|
|
|
|
{
|
|
|
|
/* NOTERAM_CLEAR
|
|
|
|
* - Clear all contents of the circular buffer
|
|
|
|
* Argument: Ignored
|
|
|
|
*/
|
|
|
|
|
|
|
|
case NOTERAM_CLEAR:
|
2023-04-27 19:42:27 +08:00
|
|
|
noteram_buffer_clear(drv);
|
2020-09-09 08:06:38 +08:00
|
|
|
ret = OK;
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* NOTERAM_GETMODE
|
|
|
|
* - Get overwrite mode
|
|
|
|
* Argument: A writable pointer to unsigned int
|
|
|
|
*/
|
|
|
|
|
|
|
|
case NOTERAM_GETMODE:
|
|
|
|
if (arg == 0)
|
|
|
|
{
|
|
|
|
ret = -EINVAL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-25 07:21:12 +08:00
|
|
|
*(FAR unsigned int *)arg = drv->ni_overwrite;
|
2020-09-09 08:06:38 +08:00
|
|
|
ret = OK;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* NOTERAM_SETMODE
|
|
|
|
* - Set overwrite mode
|
|
|
|
* Argument: A read-only pointer to unsigned int
|
|
|
|
*/
|
|
|
|
|
|
|
|
case NOTERAM_SETMODE:
|
|
|
|
if (arg == 0)
|
|
|
|
{
|
|
|
|
ret = -EINVAL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-25 07:21:12 +08:00
|
|
|
drv->ni_overwrite = *(FAR unsigned int *)arg;
|
2020-09-09 08:06:38 +08:00
|
|
|
ret = OK;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2024-04-09 17:22:06 +08:00
|
|
|
/* NOTERAM_GETREADMODE
|
|
|
|
* - Get read mode
|
|
|
|
* Argument: A writable pointer to unsigned int
|
|
|
|
*/
|
|
|
|
|
|
|
|
case NOTERAM_GETREADMODE:
|
|
|
|
if (arg == 0)
|
|
|
|
{
|
|
|
|
ret = -EINVAL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FAR struct noteram_dump_context_s *ctx = filep->f_priv;
|
|
|
|
|
|
|
|
*(FAR unsigned int *)arg = ctx->mode;
|
|
|
|
ret = OK;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* NOTERAM_SETREADMODE
|
|
|
|
* - Set read mode
|
|
|
|
* Argument: A read-only pointer to unsigned int
|
|
|
|
*/
|
|
|
|
|
|
|
|
case NOTERAM_SETREADMODE:
|
|
|
|
if (arg == 0)
|
|
|
|
{
|
|
|
|
ret = -EINVAL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FAR struct noteram_dump_context_s *ctx = filep->f_priv;
|
|
|
|
|
|
|
|
ctx->mode = *(FAR unsigned int *)arg;
|
|
|
|
ret = OK;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2020-09-09 08:06:38 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-04-27 19:42:27 +08:00
|
|
|
spin_unlock_irqrestore_wo_note(&drv->lock, flags);
|
2020-09-09 08:06:38 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2024-01-24 11:28:49 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: noteram_poll
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int noteram_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
|
|
|
bool setup)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
FAR struct inode *inode;
|
|
|
|
FAR struct noteram_driver_s *drv;
|
|
|
|
irqstate_t flags;
|
|
|
|
|
|
|
|
DEBUGASSERT(filep != NULL && fds != NULL);
|
|
|
|
inode = filep->f_inode;
|
|
|
|
|
|
|
|
DEBUGASSERT(inode != NULL && inode->i_private != NULL);
|
|
|
|
drv = inode->i_private;
|
|
|
|
|
|
|
|
flags = spin_lock_irqsave_wo_note(&drv->lock);
|
|
|
|
|
|
|
|
/* Ignore waits that do not include POLLIN */
|
|
|
|
|
|
|
|
if ((fds->events & POLLIN) == 0)
|
|
|
|
{
|
|
|
|
ret = -EDEADLK;
|
|
|
|
goto errout;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Are we setting up the poll? Or tearing it down? */
|
|
|
|
|
|
|
|
if (setup)
|
|
|
|
{
|
|
|
|
/* Check if we can accept this poll.
|
|
|
|
* For now, only one thread can poll the device at any time
|
|
|
|
* (shorter / simpler code)
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (drv->pfd)
|
|
|
|
{
|
|
|
|
ret = -EBUSY;
|
|
|
|
goto errout;
|
|
|
|
}
|
|
|
|
|
|
|
|
drv->pfd = fds;
|
|
|
|
|
|
|
|
/* Is there unread data in noteram? then trigger POLLIN now -
|
|
|
|
* don't wait for RX.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (noteram_unread_length(drv) > 0)
|
|
|
|
{
|
|
|
|
spin_unlock_irqrestore_wo_note(&drv->lock, flags);
|
|
|
|
poll_notify(&drv->pfd, 1, POLLIN);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* Tear it down */
|
|
|
|
{
|
|
|
|
drv->pfd = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
errout:
|
|
|
|
spin_unlock_irqrestore_wo_note(&drv->lock, flags);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-09-08 18:44:29 +08:00
|
|
|
/****************************************************************************
|
2022-12-16 18:31:28 +08:00
|
|
|
* Name: noteram_add
|
2020-09-08 18:44:29 +08:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Add the variable length note to the transport layer
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* note - The note buffer
|
|
|
|
* notelen - The buffer length
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* We are within a critical section.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2023-04-27 19:42:27 +08:00
|
|
|
static void noteram_add(FAR struct note_driver_s *driver,
|
2022-12-16 18:31:28 +08:00
|
|
|
FAR const void *note, size_t notelen)
|
2020-09-08 18:44:29 +08:00
|
|
|
{
|
|
|
|
FAR const char *buf = note;
|
2023-04-27 19:42:27 +08:00
|
|
|
FAR struct noteram_driver_s *drv = (FAR struct noteram_driver_s *)driver;
|
2020-09-08 18:44:29 +08:00
|
|
|
unsigned int head;
|
2023-03-02 16:26:19 +08:00
|
|
|
unsigned int remain;
|
|
|
|
unsigned int space;
|
2020-09-09 08:06:38 +08:00
|
|
|
irqstate_t flags;
|
2020-09-08 18:44:29 +08:00
|
|
|
|
2023-04-27 19:42:27 +08:00
|
|
|
flags = spin_lock_irqsave_wo_note(&drv->lock);
|
2020-09-08 18:44:29 +08:00
|
|
|
|
2023-04-27 19:42:27 +08:00
|
|
|
if (drv->ni_overwrite == NOTERAM_MODE_OVERWRITE_OVERFLOW)
|
2020-09-09 08:06:38 +08:00
|
|
|
{
|
2023-04-27 19:42:27 +08:00
|
|
|
spin_unlock_irqrestore_wo_note(&drv->lock, flags);
|
2020-09-09 08:06:38 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-04-27 19:42:27 +08:00
|
|
|
DEBUGASSERT(note != NULL && notelen < drv->ni_bufsize);
|
|
|
|
remain = drv->ni_bufsize - noteram_length(drv);
|
2020-09-08 18:44:29 +08:00
|
|
|
|
2024-03-20 14:31:57 +08:00
|
|
|
if (remain <= NOTE_ALIGN(notelen))
|
2020-09-08 18:44:29 +08:00
|
|
|
{
|
2023-04-27 19:42:27 +08:00
|
|
|
if (drv->ni_overwrite == NOTERAM_MODE_OVERWRITE_DISABLE)
|
2020-09-08 18:44:29 +08:00
|
|
|
{
|
2023-03-02 16:26:19 +08:00
|
|
|
/* Stop recording if not in overwrite mode */
|
2020-09-09 08:06:38 +08:00
|
|
|
|
2023-04-27 19:42:27 +08:00
|
|
|
drv->ni_overwrite = NOTERAM_MODE_OVERWRITE_OVERFLOW;
|
|
|
|
spin_unlock_irqrestore_wo_note(&drv->lock, flags);
|
2023-03-02 16:26:19 +08:00
|
|
|
return;
|
|
|
|
}
|
2020-09-09 08:06:38 +08:00
|
|
|
|
2023-03-02 16:26:19 +08:00
|
|
|
/* Remove the note at the tail index , make sure there is enough space
|
|
|
|
*/
|
2020-09-08 18:44:29 +08:00
|
|
|
|
2023-03-02 16:26:19 +08:00
|
|
|
do
|
|
|
|
{
|
2023-04-27 19:42:27 +08:00
|
|
|
noteram_remove(drv);
|
|
|
|
remain = drv->ni_bufsize - noteram_length(drv);
|
2020-09-08 18:44:29 +08:00
|
|
|
}
|
2024-03-20 14:31:57 +08:00
|
|
|
while (remain <= NOTE_ALIGN(notelen));
|
2020-09-08 18:44:29 +08:00
|
|
|
}
|
|
|
|
|
2023-04-27 19:42:27 +08:00
|
|
|
head = drv->ni_head;
|
|
|
|
space = drv->ni_bufsize - head;
|
2023-03-02 16:26:19 +08:00
|
|
|
space = space < notelen ? space : notelen;
|
2023-04-27 19:42:27 +08:00
|
|
|
memcpy(drv->ni_buffer + head, note, space);
|
|
|
|
memcpy(drv->ni_buffer, buf + space, notelen - space);
|
2023-11-13 12:11:23 +08:00
|
|
|
drv->ni_head = noteram_next(drv, head, NOTE_ALIGN(notelen));
|
2023-04-27 19:42:27 +08:00
|
|
|
spin_unlock_irqrestore_wo_note(&drv->lock, flags);
|
2024-01-24 11:28:49 +08:00
|
|
|
poll_notify(&drv->pfd, 1, POLLIN);
|
2020-09-08 18:44:29 +08:00
|
|
|
}
|
|
|
|
|
2023-08-11 10:31:02 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: noteram_dump_init_context
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static void noteram_dump_init_context(FAR struct noteram_dump_context_s *ctx)
|
|
|
|
{
|
|
|
|
int cpu;
|
|
|
|
|
|
|
|
/* Initialize the trace dump context */
|
|
|
|
|
|
|
|
for (cpu = 0; cpu < NCPUS; cpu++)
|
|
|
|
{
|
|
|
|
ctx->cpu[cpu].intr_nest = 0;
|
|
|
|
ctx->cpu[cpu].pendingswitch = false;
|
|
|
|
ctx->cpu[cpu].current_state = TSTATE_TASK_RUNNING;
|
|
|
|
ctx->cpu[cpu].current_pid = -1;
|
|
|
|
ctx->cpu[cpu].next_pid = -1;
|
|
|
|
ctx->cpu[cpu].current_priority = -1;
|
|
|
|
ctx->cpu[cpu].next_priority = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-14 15:50:52 +08:00
|
|
|
/****************************************************************************
|
2024-08-28 10:06:52 +08:00
|
|
|
* Name: get_taskname
|
2023-08-11 10:31:02 +08:00
|
|
|
****************************************************************************/
|
|
|
|
|
2024-08-28 16:28:46 +08:00
|
|
|
static const char *get_taskname(pid_t pid)
|
2023-08-11 10:31:02 +08:00
|
|
|
{
|
2024-07-10 10:58:28 +08:00
|
|
|
#if CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE > 0
|
2023-08-11 10:31:03 +08:00
|
|
|
FAR const char *taskname;
|
2023-08-11 10:31:02 +08:00
|
|
|
|
2023-08-11 10:31:03 +08:00
|
|
|
taskname = note_get_taskname(pid);
|
|
|
|
if (taskname != NULL)
|
2023-08-11 10:31:02 +08:00
|
|
|
{
|
2023-08-11 10:31:03 +08:00
|
|
|
return taskname;
|
2023-08-11 10:31:02 +08:00
|
|
|
}
|
2024-07-10 10:58:28 +08:00
|
|
|
#endif
|
2023-08-11 10:31:02 +08:00
|
|
|
|
|
|
|
return "<noname>";
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: noteram_dump_header
|
|
|
|
****************************************************************************/
|
|
|
|
|
2023-08-11 10:31:04 +08:00
|
|
|
static int noteram_dump_header(FAR struct lib_outstream_s *s,
|
2023-08-11 10:31:02 +08:00
|
|
|
FAR struct note_common_s *note,
|
|
|
|
FAR struct noteram_dump_context_s *ctx)
|
|
|
|
{
|
2024-02-05 15:27:08 +08:00
|
|
|
struct timespec ts;
|
2023-08-11 10:31:02 +08:00
|
|
|
pid_t pid;
|
|
|
|
int ret;
|
|
|
|
|
2024-02-05 15:27:08 +08:00
|
|
|
perf_convert(note->nc_systime, &ts);
|
2023-10-31 22:10:06 +08:00
|
|
|
pid = note->nc_pid;
|
2023-08-11 10:31:02 +08:00
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
int cpu = note->nc_cpu;
|
|
|
|
#else
|
|
|
|
int cpu = 0;
|
|
|
|
#endif
|
|
|
|
|
2024-07-15 21:00:08 +08:00
|
|
|
ret = lib_sprintf(s, "%8s-%-3u [%d] %3" PRIu64 ".%09lu: ",
|
|
|
|
get_taskname(pid), get_pid(pid), cpu,
|
2024-02-05 15:27:08 +08:00
|
|
|
(uint64_t)ts.tv_sec, ts.tv_nsec);
|
2024-07-15 21:00:08 +08:00
|
|
|
|
2023-08-11 10:31:02 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if (defined CONFIG_SCHED_INSTRUMENTATION_SWITCH) \
|
|
|
|
|| (defined CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER)
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: noteram_dump_sched_switch
|
|
|
|
****************************************************************************/
|
|
|
|
|
2023-08-11 10:31:04 +08:00
|
|
|
static int noteram_dump_sched_switch(FAR struct lib_outstream_s *s,
|
2023-08-11 10:31:02 +08:00
|
|
|
FAR struct note_common_s *note,
|
|
|
|
FAR struct noteram_dump_context_s *ctx)
|
|
|
|
{
|
|
|
|
FAR struct noteram_dump_cpu_context_s *cctx;
|
|
|
|
uint8_t current_priority;
|
|
|
|
uint8_t next_priority;
|
|
|
|
pid_t current_pid;
|
|
|
|
pid_t next_pid;
|
|
|
|
int ret;
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
int cpu = note->nc_cpu;
|
|
|
|
#else
|
|
|
|
int cpu = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
cctx = &ctx->cpu[cpu];
|
|
|
|
current_pid = cctx->current_pid;
|
|
|
|
next_pid = cctx->next_pid;
|
|
|
|
|
|
|
|
current_priority = cctx->current_priority;
|
|
|
|
next_priority = cctx->next_priority;
|
|
|
|
|
2023-08-11 10:31:04 +08:00
|
|
|
ret = lib_sprintf(s, "sched_switch: prev_comm=%s prev_pid=%u "
|
|
|
|
"prev_prio=%u prev_state=%c ==> "
|
|
|
|
"next_comm=%s next_pid=%u next_prio=%u\n",
|
2024-08-28 16:28:46 +08:00
|
|
|
get_taskname(current_pid), get_pid(current_pid),
|
2023-08-11 10:31:04 +08:00
|
|
|
current_priority, get_task_state(cctx->current_state),
|
2024-08-28 16:28:46 +08:00
|
|
|
get_taskname(next_pid), get_pid(next_pid),
|
2023-08-11 10:31:04 +08:00
|
|
|
next_priority);
|
2023-08-11 10:31:02 +08:00
|
|
|
|
|
|
|
cctx->current_pid = cctx->next_pid;
|
|
|
|
cctx->current_priority = cctx->next_priority;
|
|
|
|
cctx->pendingswitch = false;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-11-24 15:56:37 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: noteram_dump_printf
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_DUMP
|
|
|
|
static int noteram_dump_printf(FAR struct lib_outstream_s *s,
|
|
|
|
FAR struct note_printf_s *note)
|
|
|
|
{
|
|
|
|
size_t ret = 0;
|
|
|
|
|
2023-11-29 12:35:29 +08:00
|
|
|
if (note->npt_type == 0)
|
2023-11-24 15:56:37 +08:00
|
|
|
{
|
noteram_driver.c:noteram_dump_printf function replaced with lib_bsprintf.
open CONFIG_DRIVERS_NOTE_STRIP_FORMAT:
OUT:
NuttShell (NSH) NuttX-12.3.0
nsh> hello
nsh> trace dump
loop_task-1 [0] 0.001728177: sched_wakeup_new: comm=loop_task pid=1 target_cpu=0
Idle_Task-0 [0] 0.001745633: sched_wakeup_new: comm=Idle_Task pid=0 target_cpu=0
hpwork-2 [0] 0.001791495: sched_wakeup_new: comm=hpwork pid=2 target_cpu=0
nsh_main-3 [0] 0.001814164: sched_wakeup_new: comm=nsh_main pid=3 target_cpu=0
hello-4 [0] 2.583795447: sched_wakeup_new: comm=hello pid=4 target_cpu=0
hello-4 [0] 2.583843399: tracing_mark_write:
###### start long args test!!!
hello-4 [0] 2.583844088: tracing_mark_write: 0x48ebe0 97 19299 22155 4294967217 4294957304 4294945141 92.999900 9299.929993 92999299929992 18446743074409621624 61 254 429495799 hello-4 [0] 2.583845991: tracing_mark_write: 0x48ec20 qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvb>�/�L�p�J hello-4 [0] 2.583847105: tracing_mark_write:
###### start long args test!!!
trace-5 [0] 2.928625413: sched_wakeup_new: comm=trace pid=5 target_cpu=0
nsh>
close CONFIG_DRIVERS_NOTE_STRIP_FORMAT:
NuttShell (NSH) NuttX-12.3.0
nsh> hello
nsh> trace dump
loop_task-1 [0] 0.001607506: sched_wakeup_new: comm=loop_task pid=1 target_cpu=0
Idle_Task-0 [0] 0.001624549: sched_wakeup_new: comm=Idle_Task pid=0 target_cpu=0
hpwork-2 [0] 0.001666256: sched_wakeup_new: comm=hpwork pid=2 target_cpu=0
nsh_main-3 [0] 0.001688556: sched_wakeup_new: comm=nsh_main pid=3 target_cpu=0
hello-4 [0] 3.812630763: sched_wakeup_new: comm=hello pid=4 target_cpu=0
hello-4 [0] 0.370899272: tracing_mark_write:
###### start NOTE_STRIP_FORMAT test!!!
hello-4 [0] 0.370900260: tracing_mark_write: uint8_t[97]:[97]
hello-4 [0] 0.370900735: tracing_mark_write: uint16_t[19299]:[19299]
hello-4 [0] 0.370901155: tracing_mark_write: uint32_t[22155]:[22155]
hello-4 [0] 0.370901715: tracing_mark_write: float[92.9999]:[92.999900]
hello-4 [0] 0.370902196: tracing_mark_write: double[9299.929992999299]:[9299.929993]
hello-4 [0] 0.370902978: tracing_mark_write: char[][qweretyuiopasdfghjklzxcvbnm]:[qweretyuiopasdfghjklzxcvbnm]
hello-4 [0] 0.370904061: tracing_mark_write: uint64_t[92999299929992]:[92999299929992]
hello-4 [0] 0.370904554: tracing_mark_write: unsigned char[254]:[254]
hello-4 [0] 0.370904999: tracing_mark_write: unsigned short int[9299]:[9299]
hello-4 [0] 0.370905435: tracing_mark_write: unsigned int[9299992]:[9299992]
hello-4 [0] 0.370905876: tracing_mark_write: unsigned long[929992992]:[929992992]
hello-4 [0] 0.370906402: tracing_mark_write: unsigned long long[9299929924]:[9299929924]
hello-4 [0] 0.370906822: tracing_mark_write:
###### end test!!!
hello-4 [0] 0.370908999: tracing_mark_write:
###### start long args test!!!
hello-4 [0] 0.370909770: tracing_mark_write: 97 19299 22155 97 19299 22155 92.999900 9299.929993 92999299929992 92999299929992 254 254 9299 9299
hello-4 [0] 0.370927340: tracing_mark_write: qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweret>��+�c� hello-4 [0] 0.370928037: tracing_mark_write:
###### start long args test!!!
trace-5 [0] 4.173395106: sched_wakeup_new: comm=trace pid=5 target_cpu=0
nsh>
test SRC:
\#include <nuttx/config.h>
\#include <nuttx/streams.h>
\#include <stdio.h>
\#include <syslog.h>
\#define TOSTR(str) #str
\#define TONNAME(name) TOSTR(name)
\#define v_uint8_t 97
\#define v_uint16_t 19299
\#define v_uint32_t 22155
\#define v_int8_t -79
\#define v_int16_t -9992
\#define v_int32_t -22155
\#define v_float 92.9999
\#define v_double 9299.929992999299
\#define v_char_arr qweretyuiopasdfghjklzxcvbnm
\#define v_uint64_t 92999299929992
\#define v_int64_t -999299929992
\#define v_char 61
\#define v_u_char 254
\#define v_s_int -9299
\#define v_u_s_int 9299
\#define v_int -9299991
\#define v_u_int 9299992
\#define v_long -929992991
\#define v_u_long 929992992
\#define v_l_l -929992993
\#define v_u_l_l 9299929924
\#define v_size_t 29299
\#define v_l_double -9299.9299929912122464755474
int main(int argc, FAR char *argv[])
{
\#ifdef CONFIG_DRIVERS_NOTE_STRIP_FORMAT
sched_note_printf(0, "\n ###### start long args test!!! \n");
sched_note_printf(0, "%u %u %u %d %d %d %f %f %lu %ld %d %u %d %u",
v_uint8_t, v_uint16_t, v_uint32_t, v_int8_t, v_int16_t,
v_int32_t, v_float, v_double, v_uint64_t, v_int64_t,
v_char, v_u_char, v_s_int, v_u_s_int);
sched_note_printf(0, "%s %s %s %s %s %s %s %s %s %s %s %s %s %s",
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr));
sched_note_printf(0, "\n ###### start long args test!!! \n");
\#else
sched_note_printf(0, "\n ###### start NOTE_STRIP_FORMAT test!!! \n");
sched_note_printf(0, " uint8_t["TONNAME(v_uint8_t)"]:[%u]", v_uint8_t);
sched_note_printf(0, " uint16_t["TONNAME(v_uint16_t)"]:[%u]", v_uint16_t);
sched_note_printf(0, " uint32_t["TONNAME(v_uint32_t)"]:[%u]", v_uint32_t);
sched_note_printf(0, " float["TONNAME(v_float)"]:[%f]", v_float);
sched_note_printf(0, " double["TONNAME(v_double)"]:[%f]", v_double);
sched_note_printf(0, " char[]["TONNAME(v_char_arr)"]:[%.32s]", TONNAME(v_char_arr));
sched_note_printf(0, " uint64_t["TONNAME(v_uint64_t)"]:[%lu]", v_uint64_t);
sched_note_printf(0, " unsigned char["TONNAME(v_u_char)"]:[%u]", v_u_char);
sched_note_printf(0, "unsigned short int["TONNAME(v_u_s_int)"]:[%u]", v_u_s_int);
sched_note_printf(0, " unsigned int["TONNAME(v_u_int)"]:[%u]", v_u_int);
sched_note_printf(0, " unsigned long["TONNAME(v_u_long)"]:[%lu]", (unsigned long)v_u_long);
sched_note_printf(0, "unsigned long long["TONNAME(v_u_l_l)"]:[%llu]", (unsigned long long)v_u_l_l);
sched_note_printf(0, "\n ###### end test!!! \n");
sched_note_printf(0, "\n ###### start long args test!!! \n");
sched_note_printf(0, "%u %u %u %d %d %d %f %f %lu %ld %d %u %d %u",
v_uint8_t, v_uint16_t, v_uint32_t, v_uint8_t, v_uint16_t,
v_uint32_t, v_float, v_double, v_uint64_t, v_uint64_t,
v_u_char, v_u_char, v_u_s_int, v_u_s_int);
sched_note_printf(0, "%s %s %s %s %s %s %s %s %s %s %s %s %s %s",
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr));
sched_note_printf(0, "\n ###### start long args test!!! \n");
\#endif // !CONFIG_DRIVERS_NOTE_STRIP_FORMAT
return 0;
}
drivers/note/noteram_driver.c
Signed-off-by: likun17 <likun17@xiaomi.com>
2024-01-21 17:53:30 +08:00
|
|
|
ret = lib_bsprintf(s, note->npt_fmt, note->npt_data);
|
2023-11-29 12:35:29 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
size_t count = NOTE_PRINTF_GET_COUNT(note->npt_type);
|
noteram_driver.c:noteram_dump_printf function replaced with lib_bsprintf.
open CONFIG_DRIVERS_NOTE_STRIP_FORMAT:
OUT:
NuttShell (NSH) NuttX-12.3.0
nsh> hello
nsh> trace dump
loop_task-1 [0] 0.001728177: sched_wakeup_new: comm=loop_task pid=1 target_cpu=0
Idle_Task-0 [0] 0.001745633: sched_wakeup_new: comm=Idle_Task pid=0 target_cpu=0
hpwork-2 [0] 0.001791495: sched_wakeup_new: comm=hpwork pid=2 target_cpu=0
nsh_main-3 [0] 0.001814164: sched_wakeup_new: comm=nsh_main pid=3 target_cpu=0
hello-4 [0] 2.583795447: sched_wakeup_new: comm=hello pid=4 target_cpu=0
hello-4 [0] 2.583843399: tracing_mark_write:
###### start long args test!!!
hello-4 [0] 2.583844088: tracing_mark_write: 0x48ebe0 97 19299 22155 4294967217 4294957304 4294945141 92.999900 9299.929993 92999299929992 18446743074409621624 61 254 429495799 hello-4 [0] 2.583845991: tracing_mark_write: 0x48ec20 qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvb>�/�L�p�J hello-4 [0] 2.583847105: tracing_mark_write:
###### start long args test!!!
trace-5 [0] 2.928625413: sched_wakeup_new: comm=trace pid=5 target_cpu=0
nsh>
close CONFIG_DRIVERS_NOTE_STRIP_FORMAT:
NuttShell (NSH) NuttX-12.3.0
nsh> hello
nsh> trace dump
loop_task-1 [0] 0.001607506: sched_wakeup_new: comm=loop_task pid=1 target_cpu=0
Idle_Task-0 [0] 0.001624549: sched_wakeup_new: comm=Idle_Task pid=0 target_cpu=0
hpwork-2 [0] 0.001666256: sched_wakeup_new: comm=hpwork pid=2 target_cpu=0
nsh_main-3 [0] 0.001688556: sched_wakeup_new: comm=nsh_main pid=3 target_cpu=0
hello-4 [0] 3.812630763: sched_wakeup_new: comm=hello pid=4 target_cpu=0
hello-4 [0] 0.370899272: tracing_mark_write:
###### start NOTE_STRIP_FORMAT test!!!
hello-4 [0] 0.370900260: tracing_mark_write: uint8_t[97]:[97]
hello-4 [0] 0.370900735: tracing_mark_write: uint16_t[19299]:[19299]
hello-4 [0] 0.370901155: tracing_mark_write: uint32_t[22155]:[22155]
hello-4 [0] 0.370901715: tracing_mark_write: float[92.9999]:[92.999900]
hello-4 [0] 0.370902196: tracing_mark_write: double[9299.929992999299]:[9299.929993]
hello-4 [0] 0.370902978: tracing_mark_write: char[][qweretyuiopasdfghjklzxcvbnm]:[qweretyuiopasdfghjklzxcvbnm]
hello-4 [0] 0.370904061: tracing_mark_write: uint64_t[92999299929992]:[92999299929992]
hello-4 [0] 0.370904554: tracing_mark_write: unsigned char[254]:[254]
hello-4 [0] 0.370904999: tracing_mark_write: unsigned short int[9299]:[9299]
hello-4 [0] 0.370905435: tracing_mark_write: unsigned int[9299992]:[9299992]
hello-4 [0] 0.370905876: tracing_mark_write: unsigned long[929992992]:[929992992]
hello-4 [0] 0.370906402: tracing_mark_write: unsigned long long[9299929924]:[9299929924]
hello-4 [0] 0.370906822: tracing_mark_write:
###### end test!!!
hello-4 [0] 0.370908999: tracing_mark_write:
###### start long args test!!!
hello-4 [0] 0.370909770: tracing_mark_write: 97 19299 22155 97 19299 22155 92.999900 9299.929993 92999299929992 92999299929992 254 254 9299 9299
hello-4 [0] 0.370927340: tracing_mark_write: qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweret>��+�c� hello-4 [0] 0.370928037: tracing_mark_write:
###### start long args test!!!
trace-5 [0] 4.173395106: sched_wakeup_new: comm=trace pid=5 target_cpu=0
nsh>
test SRC:
\#include <nuttx/config.h>
\#include <nuttx/streams.h>
\#include <stdio.h>
\#include <syslog.h>
\#define TOSTR(str) #str
\#define TONNAME(name) TOSTR(name)
\#define v_uint8_t 97
\#define v_uint16_t 19299
\#define v_uint32_t 22155
\#define v_int8_t -79
\#define v_int16_t -9992
\#define v_int32_t -22155
\#define v_float 92.9999
\#define v_double 9299.929992999299
\#define v_char_arr qweretyuiopasdfghjklzxcvbnm
\#define v_uint64_t 92999299929992
\#define v_int64_t -999299929992
\#define v_char 61
\#define v_u_char 254
\#define v_s_int -9299
\#define v_u_s_int 9299
\#define v_int -9299991
\#define v_u_int 9299992
\#define v_long -929992991
\#define v_u_long 929992992
\#define v_l_l -929992993
\#define v_u_l_l 9299929924
\#define v_size_t 29299
\#define v_l_double -9299.9299929912122464755474
int main(int argc, FAR char *argv[])
{
\#ifdef CONFIG_DRIVERS_NOTE_STRIP_FORMAT
sched_note_printf(0, "\n ###### start long args test!!! \n");
sched_note_printf(0, "%u %u %u %d %d %d %f %f %lu %ld %d %u %d %u",
v_uint8_t, v_uint16_t, v_uint32_t, v_int8_t, v_int16_t,
v_int32_t, v_float, v_double, v_uint64_t, v_int64_t,
v_char, v_u_char, v_s_int, v_u_s_int);
sched_note_printf(0, "%s %s %s %s %s %s %s %s %s %s %s %s %s %s",
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr));
sched_note_printf(0, "\n ###### start long args test!!! \n");
\#else
sched_note_printf(0, "\n ###### start NOTE_STRIP_FORMAT test!!! \n");
sched_note_printf(0, " uint8_t["TONNAME(v_uint8_t)"]:[%u]", v_uint8_t);
sched_note_printf(0, " uint16_t["TONNAME(v_uint16_t)"]:[%u]", v_uint16_t);
sched_note_printf(0, " uint32_t["TONNAME(v_uint32_t)"]:[%u]", v_uint32_t);
sched_note_printf(0, " float["TONNAME(v_float)"]:[%f]", v_float);
sched_note_printf(0, " double["TONNAME(v_double)"]:[%f]", v_double);
sched_note_printf(0, " char[]["TONNAME(v_char_arr)"]:[%.32s]", TONNAME(v_char_arr));
sched_note_printf(0, " uint64_t["TONNAME(v_uint64_t)"]:[%lu]", v_uint64_t);
sched_note_printf(0, " unsigned char["TONNAME(v_u_char)"]:[%u]", v_u_char);
sched_note_printf(0, "unsigned short int["TONNAME(v_u_s_int)"]:[%u]", v_u_s_int);
sched_note_printf(0, " unsigned int["TONNAME(v_u_int)"]:[%u]", v_u_int);
sched_note_printf(0, " unsigned long["TONNAME(v_u_long)"]:[%lu]", (unsigned long)v_u_long);
sched_note_printf(0, "unsigned long long["TONNAME(v_u_l_l)"]:[%llu]", (unsigned long long)v_u_l_l);
sched_note_printf(0, "\n ###### end test!!! \n");
sched_note_printf(0, "\n ###### start long args test!!! \n");
sched_note_printf(0, "%u %u %u %d %d %d %f %f %lu %ld %d %u %d %u",
v_uint8_t, v_uint16_t, v_uint32_t, v_uint8_t, v_uint16_t,
v_uint32_t, v_float, v_double, v_uint64_t, v_uint64_t,
v_u_char, v_u_char, v_u_s_int, v_u_s_int);
sched_note_printf(0, "%s %s %s %s %s %s %s %s %s %s %s %s %s %s",
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr));
sched_note_printf(0, "\n ###### start long args test!!! \n");
\#endif // !CONFIG_DRIVERS_NOTE_STRIP_FORMAT
return 0;
}
drivers/note/noteram_driver.c
Signed-off-by: likun17 <likun17@xiaomi.com>
2024-01-21 17:53:30 +08:00
|
|
|
char fmt[128];
|
2023-11-29 12:35:29 +08:00
|
|
|
size_t i;
|
|
|
|
|
noteram_driver.c:noteram_dump_printf function replaced with lib_bsprintf.
open CONFIG_DRIVERS_NOTE_STRIP_FORMAT:
OUT:
NuttShell (NSH) NuttX-12.3.0
nsh> hello
nsh> trace dump
loop_task-1 [0] 0.001728177: sched_wakeup_new: comm=loop_task pid=1 target_cpu=0
Idle_Task-0 [0] 0.001745633: sched_wakeup_new: comm=Idle_Task pid=0 target_cpu=0
hpwork-2 [0] 0.001791495: sched_wakeup_new: comm=hpwork pid=2 target_cpu=0
nsh_main-3 [0] 0.001814164: sched_wakeup_new: comm=nsh_main pid=3 target_cpu=0
hello-4 [0] 2.583795447: sched_wakeup_new: comm=hello pid=4 target_cpu=0
hello-4 [0] 2.583843399: tracing_mark_write:
###### start long args test!!!
hello-4 [0] 2.583844088: tracing_mark_write: 0x48ebe0 97 19299 22155 4294967217 4294957304 4294945141 92.999900 9299.929993 92999299929992 18446743074409621624 61 254 429495799 hello-4 [0] 2.583845991: tracing_mark_write: 0x48ec20 qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvb>�/�L�p�J hello-4 [0] 2.583847105: tracing_mark_write:
###### start long args test!!!
trace-5 [0] 2.928625413: sched_wakeup_new: comm=trace pid=5 target_cpu=0
nsh>
close CONFIG_DRIVERS_NOTE_STRIP_FORMAT:
NuttShell (NSH) NuttX-12.3.0
nsh> hello
nsh> trace dump
loop_task-1 [0] 0.001607506: sched_wakeup_new: comm=loop_task pid=1 target_cpu=0
Idle_Task-0 [0] 0.001624549: sched_wakeup_new: comm=Idle_Task pid=0 target_cpu=0
hpwork-2 [0] 0.001666256: sched_wakeup_new: comm=hpwork pid=2 target_cpu=0
nsh_main-3 [0] 0.001688556: sched_wakeup_new: comm=nsh_main pid=3 target_cpu=0
hello-4 [0] 3.812630763: sched_wakeup_new: comm=hello pid=4 target_cpu=0
hello-4 [0] 0.370899272: tracing_mark_write:
###### start NOTE_STRIP_FORMAT test!!!
hello-4 [0] 0.370900260: tracing_mark_write: uint8_t[97]:[97]
hello-4 [0] 0.370900735: tracing_mark_write: uint16_t[19299]:[19299]
hello-4 [0] 0.370901155: tracing_mark_write: uint32_t[22155]:[22155]
hello-4 [0] 0.370901715: tracing_mark_write: float[92.9999]:[92.999900]
hello-4 [0] 0.370902196: tracing_mark_write: double[9299.929992999299]:[9299.929993]
hello-4 [0] 0.370902978: tracing_mark_write: char[][qweretyuiopasdfghjklzxcvbnm]:[qweretyuiopasdfghjklzxcvbnm]
hello-4 [0] 0.370904061: tracing_mark_write: uint64_t[92999299929992]:[92999299929992]
hello-4 [0] 0.370904554: tracing_mark_write: unsigned char[254]:[254]
hello-4 [0] 0.370904999: tracing_mark_write: unsigned short int[9299]:[9299]
hello-4 [0] 0.370905435: tracing_mark_write: unsigned int[9299992]:[9299992]
hello-4 [0] 0.370905876: tracing_mark_write: unsigned long[929992992]:[929992992]
hello-4 [0] 0.370906402: tracing_mark_write: unsigned long long[9299929924]:[9299929924]
hello-4 [0] 0.370906822: tracing_mark_write:
###### end test!!!
hello-4 [0] 0.370908999: tracing_mark_write:
###### start long args test!!!
hello-4 [0] 0.370909770: tracing_mark_write: 97 19299 22155 97 19299 22155 92.999900 9299.929993 92999299929992 92999299929992 254 254 9299 9299
hello-4 [0] 0.370927340: tracing_mark_write: qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweret>��+�c� hello-4 [0] 0.370928037: tracing_mark_write:
###### start long args test!!!
trace-5 [0] 4.173395106: sched_wakeup_new: comm=trace pid=5 target_cpu=0
nsh>
test SRC:
\#include <nuttx/config.h>
\#include <nuttx/streams.h>
\#include <stdio.h>
\#include <syslog.h>
\#define TOSTR(str) #str
\#define TONNAME(name) TOSTR(name)
\#define v_uint8_t 97
\#define v_uint16_t 19299
\#define v_uint32_t 22155
\#define v_int8_t -79
\#define v_int16_t -9992
\#define v_int32_t -22155
\#define v_float 92.9999
\#define v_double 9299.929992999299
\#define v_char_arr qweretyuiopasdfghjklzxcvbnm
\#define v_uint64_t 92999299929992
\#define v_int64_t -999299929992
\#define v_char 61
\#define v_u_char 254
\#define v_s_int -9299
\#define v_u_s_int 9299
\#define v_int -9299991
\#define v_u_int 9299992
\#define v_long -929992991
\#define v_u_long 929992992
\#define v_l_l -929992993
\#define v_u_l_l 9299929924
\#define v_size_t 29299
\#define v_l_double -9299.9299929912122464755474
int main(int argc, FAR char *argv[])
{
\#ifdef CONFIG_DRIVERS_NOTE_STRIP_FORMAT
sched_note_printf(0, "\n ###### start long args test!!! \n");
sched_note_printf(0, "%u %u %u %d %d %d %f %f %lu %ld %d %u %d %u",
v_uint8_t, v_uint16_t, v_uint32_t, v_int8_t, v_int16_t,
v_int32_t, v_float, v_double, v_uint64_t, v_int64_t,
v_char, v_u_char, v_s_int, v_u_s_int);
sched_note_printf(0, "%s %s %s %s %s %s %s %s %s %s %s %s %s %s",
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr));
sched_note_printf(0, "\n ###### start long args test!!! \n");
\#else
sched_note_printf(0, "\n ###### start NOTE_STRIP_FORMAT test!!! \n");
sched_note_printf(0, " uint8_t["TONNAME(v_uint8_t)"]:[%u]", v_uint8_t);
sched_note_printf(0, " uint16_t["TONNAME(v_uint16_t)"]:[%u]", v_uint16_t);
sched_note_printf(0, " uint32_t["TONNAME(v_uint32_t)"]:[%u]", v_uint32_t);
sched_note_printf(0, " float["TONNAME(v_float)"]:[%f]", v_float);
sched_note_printf(0, " double["TONNAME(v_double)"]:[%f]", v_double);
sched_note_printf(0, " char[]["TONNAME(v_char_arr)"]:[%.32s]", TONNAME(v_char_arr));
sched_note_printf(0, " uint64_t["TONNAME(v_uint64_t)"]:[%lu]", v_uint64_t);
sched_note_printf(0, " unsigned char["TONNAME(v_u_char)"]:[%u]", v_u_char);
sched_note_printf(0, "unsigned short int["TONNAME(v_u_s_int)"]:[%u]", v_u_s_int);
sched_note_printf(0, " unsigned int["TONNAME(v_u_int)"]:[%u]", v_u_int);
sched_note_printf(0, " unsigned long["TONNAME(v_u_long)"]:[%lu]", (unsigned long)v_u_long);
sched_note_printf(0, "unsigned long long["TONNAME(v_u_l_l)"]:[%llu]", (unsigned long long)v_u_l_l);
sched_note_printf(0, "\n ###### end test!!! \n");
sched_note_printf(0, "\n ###### start long args test!!! \n");
sched_note_printf(0, "%u %u %u %d %d %d %f %f %lu %ld %d %u %d %u",
v_uint8_t, v_uint16_t, v_uint32_t, v_uint8_t, v_uint16_t,
v_uint32_t, v_float, v_double, v_uint64_t, v_uint64_t,
v_u_char, v_u_char, v_u_s_int, v_u_s_int);
sched_note_printf(0, "%s %s %s %s %s %s %s %s %s %s %s %s %s %s",
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr));
sched_note_printf(0, "\n ###### start long args test!!! \n");
\#endif // !CONFIG_DRIVERS_NOTE_STRIP_FORMAT
return 0;
}
drivers/note/noteram_driver.c
Signed-off-by: likun17 <likun17@xiaomi.com>
2024-01-21 17:53:30 +08:00
|
|
|
fmt[0] = '\0';
|
2023-11-29 12:35:29 +08:00
|
|
|
ret += lib_sprintf(s, "%p", note->npt_fmt);
|
|
|
|
for (i = 0; i < count; i++)
|
2023-11-24 15:56:37 +08:00
|
|
|
{
|
2023-11-29 12:35:29 +08:00
|
|
|
int type = NOTE_PRINTF_GET_TYPE(note->npt_type, i);
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case NOTE_PRINTF_UINT32:
|
|
|
|
{
|
noteram_driver.c:noteram_dump_printf function replaced with lib_bsprintf.
open CONFIG_DRIVERS_NOTE_STRIP_FORMAT:
OUT:
NuttShell (NSH) NuttX-12.3.0
nsh> hello
nsh> trace dump
loop_task-1 [0] 0.001728177: sched_wakeup_new: comm=loop_task pid=1 target_cpu=0
Idle_Task-0 [0] 0.001745633: sched_wakeup_new: comm=Idle_Task pid=0 target_cpu=0
hpwork-2 [0] 0.001791495: sched_wakeup_new: comm=hpwork pid=2 target_cpu=0
nsh_main-3 [0] 0.001814164: sched_wakeup_new: comm=nsh_main pid=3 target_cpu=0
hello-4 [0] 2.583795447: sched_wakeup_new: comm=hello pid=4 target_cpu=0
hello-4 [0] 2.583843399: tracing_mark_write:
###### start long args test!!!
hello-4 [0] 2.583844088: tracing_mark_write: 0x48ebe0 97 19299 22155 4294967217 4294957304 4294945141 92.999900 9299.929993 92999299929992 18446743074409621624 61 254 429495799 hello-4 [0] 2.583845991: tracing_mark_write: 0x48ec20 qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvb>�/�L�p�J hello-4 [0] 2.583847105: tracing_mark_write:
###### start long args test!!!
trace-5 [0] 2.928625413: sched_wakeup_new: comm=trace pid=5 target_cpu=0
nsh>
close CONFIG_DRIVERS_NOTE_STRIP_FORMAT:
NuttShell (NSH) NuttX-12.3.0
nsh> hello
nsh> trace dump
loop_task-1 [0] 0.001607506: sched_wakeup_new: comm=loop_task pid=1 target_cpu=0
Idle_Task-0 [0] 0.001624549: sched_wakeup_new: comm=Idle_Task pid=0 target_cpu=0
hpwork-2 [0] 0.001666256: sched_wakeup_new: comm=hpwork pid=2 target_cpu=0
nsh_main-3 [0] 0.001688556: sched_wakeup_new: comm=nsh_main pid=3 target_cpu=0
hello-4 [0] 3.812630763: sched_wakeup_new: comm=hello pid=4 target_cpu=0
hello-4 [0] 0.370899272: tracing_mark_write:
###### start NOTE_STRIP_FORMAT test!!!
hello-4 [0] 0.370900260: tracing_mark_write: uint8_t[97]:[97]
hello-4 [0] 0.370900735: tracing_mark_write: uint16_t[19299]:[19299]
hello-4 [0] 0.370901155: tracing_mark_write: uint32_t[22155]:[22155]
hello-4 [0] 0.370901715: tracing_mark_write: float[92.9999]:[92.999900]
hello-4 [0] 0.370902196: tracing_mark_write: double[9299.929992999299]:[9299.929993]
hello-4 [0] 0.370902978: tracing_mark_write: char[][qweretyuiopasdfghjklzxcvbnm]:[qweretyuiopasdfghjklzxcvbnm]
hello-4 [0] 0.370904061: tracing_mark_write: uint64_t[92999299929992]:[92999299929992]
hello-4 [0] 0.370904554: tracing_mark_write: unsigned char[254]:[254]
hello-4 [0] 0.370904999: tracing_mark_write: unsigned short int[9299]:[9299]
hello-4 [0] 0.370905435: tracing_mark_write: unsigned int[9299992]:[9299992]
hello-4 [0] 0.370905876: tracing_mark_write: unsigned long[929992992]:[929992992]
hello-4 [0] 0.370906402: tracing_mark_write: unsigned long long[9299929924]:[9299929924]
hello-4 [0] 0.370906822: tracing_mark_write:
###### end test!!!
hello-4 [0] 0.370908999: tracing_mark_write:
###### start long args test!!!
hello-4 [0] 0.370909770: tracing_mark_write: 97 19299 22155 97 19299 22155 92.999900 9299.929993 92999299929992 92999299929992 254 254 9299 9299
hello-4 [0] 0.370927340: tracing_mark_write: qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweret>��+�c� hello-4 [0] 0.370928037: tracing_mark_write:
###### start long args test!!!
trace-5 [0] 4.173395106: sched_wakeup_new: comm=trace pid=5 target_cpu=0
nsh>
test SRC:
\#include <nuttx/config.h>
\#include <nuttx/streams.h>
\#include <stdio.h>
\#include <syslog.h>
\#define TOSTR(str) #str
\#define TONNAME(name) TOSTR(name)
\#define v_uint8_t 97
\#define v_uint16_t 19299
\#define v_uint32_t 22155
\#define v_int8_t -79
\#define v_int16_t -9992
\#define v_int32_t -22155
\#define v_float 92.9999
\#define v_double 9299.929992999299
\#define v_char_arr qweretyuiopasdfghjklzxcvbnm
\#define v_uint64_t 92999299929992
\#define v_int64_t -999299929992
\#define v_char 61
\#define v_u_char 254
\#define v_s_int -9299
\#define v_u_s_int 9299
\#define v_int -9299991
\#define v_u_int 9299992
\#define v_long -929992991
\#define v_u_long 929992992
\#define v_l_l -929992993
\#define v_u_l_l 9299929924
\#define v_size_t 29299
\#define v_l_double -9299.9299929912122464755474
int main(int argc, FAR char *argv[])
{
\#ifdef CONFIG_DRIVERS_NOTE_STRIP_FORMAT
sched_note_printf(0, "\n ###### start long args test!!! \n");
sched_note_printf(0, "%u %u %u %d %d %d %f %f %lu %ld %d %u %d %u",
v_uint8_t, v_uint16_t, v_uint32_t, v_int8_t, v_int16_t,
v_int32_t, v_float, v_double, v_uint64_t, v_int64_t,
v_char, v_u_char, v_s_int, v_u_s_int);
sched_note_printf(0, "%s %s %s %s %s %s %s %s %s %s %s %s %s %s",
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr));
sched_note_printf(0, "\n ###### start long args test!!! \n");
\#else
sched_note_printf(0, "\n ###### start NOTE_STRIP_FORMAT test!!! \n");
sched_note_printf(0, " uint8_t["TONNAME(v_uint8_t)"]:[%u]", v_uint8_t);
sched_note_printf(0, " uint16_t["TONNAME(v_uint16_t)"]:[%u]", v_uint16_t);
sched_note_printf(0, " uint32_t["TONNAME(v_uint32_t)"]:[%u]", v_uint32_t);
sched_note_printf(0, " float["TONNAME(v_float)"]:[%f]", v_float);
sched_note_printf(0, " double["TONNAME(v_double)"]:[%f]", v_double);
sched_note_printf(0, " char[]["TONNAME(v_char_arr)"]:[%.32s]", TONNAME(v_char_arr));
sched_note_printf(0, " uint64_t["TONNAME(v_uint64_t)"]:[%lu]", v_uint64_t);
sched_note_printf(0, " unsigned char["TONNAME(v_u_char)"]:[%u]", v_u_char);
sched_note_printf(0, "unsigned short int["TONNAME(v_u_s_int)"]:[%u]", v_u_s_int);
sched_note_printf(0, " unsigned int["TONNAME(v_u_int)"]:[%u]", v_u_int);
sched_note_printf(0, " unsigned long["TONNAME(v_u_long)"]:[%lu]", (unsigned long)v_u_long);
sched_note_printf(0, "unsigned long long["TONNAME(v_u_l_l)"]:[%llu]", (unsigned long long)v_u_l_l);
sched_note_printf(0, "\n ###### end test!!! \n");
sched_note_printf(0, "\n ###### start long args test!!! \n");
sched_note_printf(0, "%u %u %u %d %d %d %f %f %lu %ld %d %u %d %u",
v_uint8_t, v_uint16_t, v_uint32_t, v_uint8_t, v_uint16_t,
v_uint32_t, v_float, v_double, v_uint64_t, v_uint64_t,
v_u_char, v_u_char, v_u_s_int, v_u_s_int);
sched_note_printf(0, "%s %s %s %s %s %s %s %s %s %s %s %s %s %s",
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr));
sched_note_printf(0, "\n ###### start long args test!!! \n");
\#endif // !CONFIG_DRIVERS_NOTE_STRIP_FORMAT
return 0;
}
drivers/note/noteram_driver.c
Signed-off-by: likun17 <likun17@xiaomi.com>
2024-01-21 17:53:30 +08:00
|
|
|
strcat(fmt, " %u");
|
2023-11-29 12:35:29 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NOTE_PRINTF_UINT64:
|
|
|
|
{
|
noteram_driver.c:noteram_dump_printf function replaced with lib_bsprintf.
open CONFIG_DRIVERS_NOTE_STRIP_FORMAT:
OUT:
NuttShell (NSH) NuttX-12.3.0
nsh> hello
nsh> trace dump
loop_task-1 [0] 0.001728177: sched_wakeup_new: comm=loop_task pid=1 target_cpu=0
Idle_Task-0 [0] 0.001745633: sched_wakeup_new: comm=Idle_Task pid=0 target_cpu=0
hpwork-2 [0] 0.001791495: sched_wakeup_new: comm=hpwork pid=2 target_cpu=0
nsh_main-3 [0] 0.001814164: sched_wakeup_new: comm=nsh_main pid=3 target_cpu=0
hello-4 [0] 2.583795447: sched_wakeup_new: comm=hello pid=4 target_cpu=0
hello-4 [0] 2.583843399: tracing_mark_write:
###### start long args test!!!
hello-4 [0] 2.583844088: tracing_mark_write: 0x48ebe0 97 19299 22155 4294967217 4294957304 4294945141 92.999900 9299.929993 92999299929992 18446743074409621624 61 254 429495799 hello-4 [0] 2.583845991: tracing_mark_write: 0x48ec20 qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvb>�/�L�p�J hello-4 [0] 2.583847105: tracing_mark_write:
###### start long args test!!!
trace-5 [0] 2.928625413: sched_wakeup_new: comm=trace pid=5 target_cpu=0
nsh>
close CONFIG_DRIVERS_NOTE_STRIP_FORMAT:
NuttShell (NSH) NuttX-12.3.0
nsh> hello
nsh> trace dump
loop_task-1 [0] 0.001607506: sched_wakeup_new: comm=loop_task pid=1 target_cpu=0
Idle_Task-0 [0] 0.001624549: sched_wakeup_new: comm=Idle_Task pid=0 target_cpu=0
hpwork-2 [0] 0.001666256: sched_wakeup_new: comm=hpwork pid=2 target_cpu=0
nsh_main-3 [0] 0.001688556: sched_wakeup_new: comm=nsh_main pid=3 target_cpu=0
hello-4 [0] 3.812630763: sched_wakeup_new: comm=hello pid=4 target_cpu=0
hello-4 [0] 0.370899272: tracing_mark_write:
###### start NOTE_STRIP_FORMAT test!!!
hello-4 [0] 0.370900260: tracing_mark_write: uint8_t[97]:[97]
hello-4 [0] 0.370900735: tracing_mark_write: uint16_t[19299]:[19299]
hello-4 [0] 0.370901155: tracing_mark_write: uint32_t[22155]:[22155]
hello-4 [0] 0.370901715: tracing_mark_write: float[92.9999]:[92.999900]
hello-4 [0] 0.370902196: tracing_mark_write: double[9299.929992999299]:[9299.929993]
hello-4 [0] 0.370902978: tracing_mark_write: char[][qweretyuiopasdfghjklzxcvbnm]:[qweretyuiopasdfghjklzxcvbnm]
hello-4 [0] 0.370904061: tracing_mark_write: uint64_t[92999299929992]:[92999299929992]
hello-4 [0] 0.370904554: tracing_mark_write: unsigned char[254]:[254]
hello-4 [0] 0.370904999: tracing_mark_write: unsigned short int[9299]:[9299]
hello-4 [0] 0.370905435: tracing_mark_write: unsigned int[9299992]:[9299992]
hello-4 [0] 0.370905876: tracing_mark_write: unsigned long[929992992]:[929992992]
hello-4 [0] 0.370906402: tracing_mark_write: unsigned long long[9299929924]:[9299929924]
hello-4 [0] 0.370906822: tracing_mark_write:
###### end test!!!
hello-4 [0] 0.370908999: tracing_mark_write:
###### start long args test!!!
hello-4 [0] 0.370909770: tracing_mark_write: 97 19299 22155 97 19299 22155 92.999900 9299.929993 92999299929992 92999299929992 254 254 9299 9299
hello-4 [0] 0.370927340: tracing_mark_write: qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweret>��+�c� hello-4 [0] 0.370928037: tracing_mark_write:
###### start long args test!!!
trace-5 [0] 4.173395106: sched_wakeup_new: comm=trace pid=5 target_cpu=0
nsh>
test SRC:
\#include <nuttx/config.h>
\#include <nuttx/streams.h>
\#include <stdio.h>
\#include <syslog.h>
\#define TOSTR(str) #str
\#define TONNAME(name) TOSTR(name)
\#define v_uint8_t 97
\#define v_uint16_t 19299
\#define v_uint32_t 22155
\#define v_int8_t -79
\#define v_int16_t -9992
\#define v_int32_t -22155
\#define v_float 92.9999
\#define v_double 9299.929992999299
\#define v_char_arr qweretyuiopasdfghjklzxcvbnm
\#define v_uint64_t 92999299929992
\#define v_int64_t -999299929992
\#define v_char 61
\#define v_u_char 254
\#define v_s_int -9299
\#define v_u_s_int 9299
\#define v_int -9299991
\#define v_u_int 9299992
\#define v_long -929992991
\#define v_u_long 929992992
\#define v_l_l -929992993
\#define v_u_l_l 9299929924
\#define v_size_t 29299
\#define v_l_double -9299.9299929912122464755474
int main(int argc, FAR char *argv[])
{
\#ifdef CONFIG_DRIVERS_NOTE_STRIP_FORMAT
sched_note_printf(0, "\n ###### start long args test!!! \n");
sched_note_printf(0, "%u %u %u %d %d %d %f %f %lu %ld %d %u %d %u",
v_uint8_t, v_uint16_t, v_uint32_t, v_int8_t, v_int16_t,
v_int32_t, v_float, v_double, v_uint64_t, v_int64_t,
v_char, v_u_char, v_s_int, v_u_s_int);
sched_note_printf(0, "%s %s %s %s %s %s %s %s %s %s %s %s %s %s",
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr));
sched_note_printf(0, "\n ###### start long args test!!! \n");
\#else
sched_note_printf(0, "\n ###### start NOTE_STRIP_FORMAT test!!! \n");
sched_note_printf(0, " uint8_t["TONNAME(v_uint8_t)"]:[%u]", v_uint8_t);
sched_note_printf(0, " uint16_t["TONNAME(v_uint16_t)"]:[%u]", v_uint16_t);
sched_note_printf(0, " uint32_t["TONNAME(v_uint32_t)"]:[%u]", v_uint32_t);
sched_note_printf(0, " float["TONNAME(v_float)"]:[%f]", v_float);
sched_note_printf(0, " double["TONNAME(v_double)"]:[%f]", v_double);
sched_note_printf(0, " char[]["TONNAME(v_char_arr)"]:[%.32s]", TONNAME(v_char_arr));
sched_note_printf(0, " uint64_t["TONNAME(v_uint64_t)"]:[%lu]", v_uint64_t);
sched_note_printf(0, " unsigned char["TONNAME(v_u_char)"]:[%u]", v_u_char);
sched_note_printf(0, "unsigned short int["TONNAME(v_u_s_int)"]:[%u]", v_u_s_int);
sched_note_printf(0, " unsigned int["TONNAME(v_u_int)"]:[%u]", v_u_int);
sched_note_printf(0, " unsigned long["TONNAME(v_u_long)"]:[%lu]", (unsigned long)v_u_long);
sched_note_printf(0, "unsigned long long["TONNAME(v_u_l_l)"]:[%llu]", (unsigned long long)v_u_l_l);
sched_note_printf(0, "\n ###### end test!!! \n");
sched_note_printf(0, "\n ###### start long args test!!! \n");
sched_note_printf(0, "%u %u %u %d %d %d %f %f %lu %ld %d %u %d %u",
v_uint8_t, v_uint16_t, v_uint32_t, v_uint8_t, v_uint16_t,
v_uint32_t, v_float, v_double, v_uint64_t, v_uint64_t,
v_u_char, v_u_char, v_u_s_int, v_u_s_int);
sched_note_printf(0, "%s %s %s %s %s %s %s %s %s %s %s %s %s %s",
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr));
sched_note_printf(0, "\n ###### start long args test!!! \n");
\#endif // !CONFIG_DRIVERS_NOTE_STRIP_FORMAT
return 0;
}
drivers/note/noteram_driver.c
Signed-off-by: likun17 <likun17@xiaomi.com>
2024-01-21 17:53:30 +08:00
|
|
|
strcat(fmt, " %llu");
|
2023-11-29 12:35:29 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NOTE_PRINTF_STRING:
|
|
|
|
{
|
noteram_driver.c:noteram_dump_printf function replaced with lib_bsprintf.
open CONFIG_DRIVERS_NOTE_STRIP_FORMAT:
OUT:
NuttShell (NSH) NuttX-12.3.0
nsh> hello
nsh> trace dump
loop_task-1 [0] 0.001728177: sched_wakeup_new: comm=loop_task pid=1 target_cpu=0
Idle_Task-0 [0] 0.001745633: sched_wakeup_new: comm=Idle_Task pid=0 target_cpu=0
hpwork-2 [0] 0.001791495: sched_wakeup_new: comm=hpwork pid=2 target_cpu=0
nsh_main-3 [0] 0.001814164: sched_wakeup_new: comm=nsh_main pid=3 target_cpu=0
hello-4 [0] 2.583795447: sched_wakeup_new: comm=hello pid=4 target_cpu=0
hello-4 [0] 2.583843399: tracing_mark_write:
###### start long args test!!!
hello-4 [0] 2.583844088: tracing_mark_write: 0x48ebe0 97 19299 22155 4294967217 4294957304 4294945141 92.999900 9299.929993 92999299929992 18446743074409621624 61 254 429495799 hello-4 [0] 2.583845991: tracing_mark_write: 0x48ec20 qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvb>�/�L�p�J hello-4 [0] 2.583847105: tracing_mark_write:
###### start long args test!!!
trace-5 [0] 2.928625413: sched_wakeup_new: comm=trace pid=5 target_cpu=0
nsh>
close CONFIG_DRIVERS_NOTE_STRIP_FORMAT:
NuttShell (NSH) NuttX-12.3.0
nsh> hello
nsh> trace dump
loop_task-1 [0] 0.001607506: sched_wakeup_new: comm=loop_task pid=1 target_cpu=0
Idle_Task-0 [0] 0.001624549: sched_wakeup_new: comm=Idle_Task pid=0 target_cpu=0
hpwork-2 [0] 0.001666256: sched_wakeup_new: comm=hpwork pid=2 target_cpu=0
nsh_main-3 [0] 0.001688556: sched_wakeup_new: comm=nsh_main pid=3 target_cpu=0
hello-4 [0] 3.812630763: sched_wakeup_new: comm=hello pid=4 target_cpu=0
hello-4 [0] 0.370899272: tracing_mark_write:
###### start NOTE_STRIP_FORMAT test!!!
hello-4 [0] 0.370900260: tracing_mark_write: uint8_t[97]:[97]
hello-4 [0] 0.370900735: tracing_mark_write: uint16_t[19299]:[19299]
hello-4 [0] 0.370901155: tracing_mark_write: uint32_t[22155]:[22155]
hello-4 [0] 0.370901715: tracing_mark_write: float[92.9999]:[92.999900]
hello-4 [0] 0.370902196: tracing_mark_write: double[9299.929992999299]:[9299.929993]
hello-4 [0] 0.370902978: tracing_mark_write: char[][qweretyuiopasdfghjklzxcvbnm]:[qweretyuiopasdfghjklzxcvbnm]
hello-4 [0] 0.370904061: tracing_mark_write: uint64_t[92999299929992]:[92999299929992]
hello-4 [0] 0.370904554: tracing_mark_write: unsigned char[254]:[254]
hello-4 [0] 0.370904999: tracing_mark_write: unsigned short int[9299]:[9299]
hello-4 [0] 0.370905435: tracing_mark_write: unsigned int[9299992]:[9299992]
hello-4 [0] 0.370905876: tracing_mark_write: unsigned long[929992992]:[929992992]
hello-4 [0] 0.370906402: tracing_mark_write: unsigned long long[9299929924]:[9299929924]
hello-4 [0] 0.370906822: tracing_mark_write:
###### end test!!!
hello-4 [0] 0.370908999: tracing_mark_write:
###### start long args test!!!
hello-4 [0] 0.370909770: tracing_mark_write: 97 19299 22155 97 19299 22155 92.999900 9299.929993 92999299929992 92999299929992 254 254 9299 9299
hello-4 [0] 0.370927340: tracing_mark_write: qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweret>��+�c� hello-4 [0] 0.370928037: tracing_mark_write:
###### start long args test!!!
trace-5 [0] 4.173395106: sched_wakeup_new: comm=trace pid=5 target_cpu=0
nsh>
test SRC:
\#include <nuttx/config.h>
\#include <nuttx/streams.h>
\#include <stdio.h>
\#include <syslog.h>
\#define TOSTR(str) #str
\#define TONNAME(name) TOSTR(name)
\#define v_uint8_t 97
\#define v_uint16_t 19299
\#define v_uint32_t 22155
\#define v_int8_t -79
\#define v_int16_t -9992
\#define v_int32_t -22155
\#define v_float 92.9999
\#define v_double 9299.929992999299
\#define v_char_arr qweretyuiopasdfghjklzxcvbnm
\#define v_uint64_t 92999299929992
\#define v_int64_t -999299929992
\#define v_char 61
\#define v_u_char 254
\#define v_s_int -9299
\#define v_u_s_int 9299
\#define v_int -9299991
\#define v_u_int 9299992
\#define v_long -929992991
\#define v_u_long 929992992
\#define v_l_l -929992993
\#define v_u_l_l 9299929924
\#define v_size_t 29299
\#define v_l_double -9299.9299929912122464755474
int main(int argc, FAR char *argv[])
{
\#ifdef CONFIG_DRIVERS_NOTE_STRIP_FORMAT
sched_note_printf(0, "\n ###### start long args test!!! \n");
sched_note_printf(0, "%u %u %u %d %d %d %f %f %lu %ld %d %u %d %u",
v_uint8_t, v_uint16_t, v_uint32_t, v_int8_t, v_int16_t,
v_int32_t, v_float, v_double, v_uint64_t, v_int64_t,
v_char, v_u_char, v_s_int, v_u_s_int);
sched_note_printf(0, "%s %s %s %s %s %s %s %s %s %s %s %s %s %s",
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr));
sched_note_printf(0, "\n ###### start long args test!!! \n");
\#else
sched_note_printf(0, "\n ###### start NOTE_STRIP_FORMAT test!!! \n");
sched_note_printf(0, " uint8_t["TONNAME(v_uint8_t)"]:[%u]", v_uint8_t);
sched_note_printf(0, " uint16_t["TONNAME(v_uint16_t)"]:[%u]", v_uint16_t);
sched_note_printf(0, " uint32_t["TONNAME(v_uint32_t)"]:[%u]", v_uint32_t);
sched_note_printf(0, " float["TONNAME(v_float)"]:[%f]", v_float);
sched_note_printf(0, " double["TONNAME(v_double)"]:[%f]", v_double);
sched_note_printf(0, " char[]["TONNAME(v_char_arr)"]:[%.32s]", TONNAME(v_char_arr));
sched_note_printf(0, " uint64_t["TONNAME(v_uint64_t)"]:[%lu]", v_uint64_t);
sched_note_printf(0, " unsigned char["TONNAME(v_u_char)"]:[%u]", v_u_char);
sched_note_printf(0, "unsigned short int["TONNAME(v_u_s_int)"]:[%u]", v_u_s_int);
sched_note_printf(0, " unsigned int["TONNAME(v_u_int)"]:[%u]", v_u_int);
sched_note_printf(0, " unsigned long["TONNAME(v_u_long)"]:[%lu]", (unsigned long)v_u_long);
sched_note_printf(0, "unsigned long long["TONNAME(v_u_l_l)"]:[%llu]", (unsigned long long)v_u_l_l);
sched_note_printf(0, "\n ###### end test!!! \n");
sched_note_printf(0, "\n ###### start long args test!!! \n");
sched_note_printf(0, "%u %u %u %d %d %d %f %f %lu %ld %d %u %d %u",
v_uint8_t, v_uint16_t, v_uint32_t, v_uint8_t, v_uint16_t,
v_uint32_t, v_float, v_double, v_uint64_t, v_uint64_t,
v_u_char, v_u_char, v_u_s_int, v_u_s_int);
sched_note_printf(0, "%s %s %s %s %s %s %s %s %s %s %s %s %s %s",
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr));
sched_note_printf(0, "\n ###### start long args test!!! \n");
\#endif // !CONFIG_DRIVERS_NOTE_STRIP_FORMAT
return 0;
}
drivers/note/noteram_driver.c
Signed-off-by: likun17 <likun17@xiaomi.com>
2024-01-21 17:53:30 +08:00
|
|
|
strcat(fmt, " %s");
|
2023-11-29 12:35:29 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NOTE_PRINTF_DOUBLE:
|
|
|
|
{
|
noteram_driver.c:noteram_dump_printf function replaced with lib_bsprintf.
open CONFIG_DRIVERS_NOTE_STRIP_FORMAT:
OUT:
NuttShell (NSH) NuttX-12.3.0
nsh> hello
nsh> trace dump
loop_task-1 [0] 0.001728177: sched_wakeup_new: comm=loop_task pid=1 target_cpu=0
Idle_Task-0 [0] 0.001745633: sched_wakeup_new: comm=Idle_Task pid=0 target_cpu=0
hpwork-2 [0] 0.001791495: sched_wakeup_new: comm=hpwork pid=2 target_cpu=0
nsh_main-3 [0] 0.001814164: sched_wakeup_new: comm=nsh_main pid=3 target_cpu=0
hello-4 [0] 2.583795447: sched_wakeup_new: comm=hello pid=4 target_cpu=0
hello-4 [0] 2.583843399: tracing_mark_write:
###### start long args test!!!
hello-4 [0] 2.583844088: tracing_mark_write: 0x48ebe0 97 19299 22155 4294967217 4294957304 4294945141 92.999900 9299.929993 92999299929992 18446743074409621624 61 254 429495799 hello-4 [0] 2.583845991: tracing_mark_write: 0x48ec20 qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvb>�/�L�p�J hello-4 [0] 2.583847105: tracing_mark_write:
###### start long args test!!!
trace-5 [0] 2.928625413: sched_wakeup_new: comm=trace pid=5 target_cpu=0
nsh>
close CONFIG_DRIVERS_NOTE_STRIP_FORMAT:
NuttShell (NSH) NuttX-12.3.0
nsh> hello
nsh> trace dump
loop_task-1 [0] 0.001607506: sched_wakeup_new: comm=loop_task pid=1 target_cpu=0
Idle_Task-0 [0] 0.001624549: sched_wakeup_new: comm=Idle_Task pid=0 target_cpu=0
hpwork-2 [0] 0.001666256: sched_wakeup_new: comm=hpwork pid=2 target_cpu=0
nsh_main-3 [0] 0.001688556: sched_wakeup_new: comm=nsh_main pid=3 target_cpu=0
hello-4 [0] 3.812630763: sched_wakeup_new: comm=hello pid=4 target_cpu=0
hello-4 [0] 0.370899272: tracing_mark_write:
###### start NOTE_STRIP_FORMAT test!!!
hello-4 [0] 0.370900260: tracing_mark_write: uint8_t[97]:[97]
hello-4 [0] 0.370900735: tracing_mark_write: uint16_t[19299]:[19299]
hello-4 [0] 0.370901155: tracing_mark_write: uint32_t[22155]:[22155]
hello-4 [0] 0.370901715: tracing_mark_write: float[92.9999]:[92.999900]
hello-4 [0] 0.370902196: tracing_mark_write: double[9299.929992999299]:[9299.929993]
hello-4 [0] 0.370902978: tracing_mark_write: char[][qweretyuiopasdfghjklzxcvbnm]:[qweretyuiopasdfghjklzxcvbnm]
hello-4 [0] 0.370904061: tracing_mark_write: uint64_t[92999299929992]:[92999299929992]
hello-4 [0] 0.370904554: tracing_mark_write: unsigned char[254]:[254]
hello-4 [0] 0.370904999: tracing_mark_write: unsigned short int[9299]:[9299]
hello-4 [0] 0.370905435: tracing_mark_write: unsigned int[9299992]:[9299992]
hello-4 [0] 0.370905876: tracing_mark_write: unsigned long[929992992]:[929992992]
hello-4 [0] 0.370906402: tracing_mark_write: unsigned long long[9299929924]:[9299929924]
hello-4 [0] 0.370906822: tracing_mark_write:
###### end test!!!
hello-4 [0] 0.370908999: tracing_mark_write:
###### start long args test!!!
hello-4 [0] 0.370909770: tracing_mark_write: 97 19299 22155 97 19299 22155 92.999900 9299.929993 92999299929992 92999299929992 254 254 9299 9299
hello-4 [0] 0.370927340: tracing_mark_write: qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweret>��+�c� hello-4 [0] 0.370928037: tracing_mark_write:
###### start long args test!!!
trace-5 [0] 4.173395106: sched_wakeup_new: comm=trace pid=5 target_cpu=0
nsh>
test SRC:
\#include <nuttx/config.h>
\#include <nuttx/streams.h>
\#include <stdio.h>
\#include <syslog.h>
\#define TOSTR(str) #str
\#define TONNAME(name) TOSTR(name)
\#define v_uint8_t 97
\#define v_uint16_t 19299
\#define v_uint32_t 22155
\#define v_int8_t -79
\#define v_int16_t -9992
\#define v_int32_t -22155
\#define v_float 92.9999
\#define v_double 9299.929992999299
\#define v_char_arr qweretyuiopasdfghjklzxcvbnm
\#define v_uint64_t 92999299929992
\#define v_int64_t -999299929992
\#define v_char 61
\#define v_u_char 254
\#define v_s_int -9299
\#define v_u_s_int 9299
\#define v_int -9299991
\#define v_u_int 9299992
\#define v_long -929992991
\#define v_u_long 929992992
\#define v_l_l -929992993
\#define v_u_l_l 9299929924
\#define v_size_t 29299
\#define v_l_double -9299.9299929912122464755474
int main(int argc, FAR char *argv[])
{
\#ifdef CONFIG_DRIVERS_NOTE_STRIP_FORMAT
sched_note_printf(0, "\n ###### start long args test!!! \n");
sched_note_printf(0, "%u %u %u %d %d %d %f %f %lu %ld %d %u %d %u",
v_uint8_t, v_uint16_t, v_uint32_t, v_int8_t, v_int16_t,
v_int32_t, v_float, v_double, v_uint64_t, v_int64_t,
v_char, v_u_char, v_s_int, v_u_s_int);
sched_note_printf(0, "%s %s %s %s %s %s %s %s %s %s %s %s %s %s",
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr));
sched_note_printf(0, "\n ###### start long args test!!! \n");
\#else
sched_note_printf(0, "\n ###### start NOTE_STRIP_FORMAT test!!! \n");
sched_note_printf(0, " uint8_t["TONNAME(v_uint8_t)"]:[%u]", v_uint8_t);
sched_note_printf(0, " uint16_t["TONNAME(v_uint16_t)"]:[%u]", v_uint16_t);
sched_note_printf(0, " uint32_t["TONNAME(v_uint32_t)"]:[%u]", v_uint32_t);
sched_note_printf(0, " float["TONNAME(v_float)"]:[%f]", v_float);
sched_note_printf(0, " double["TONNAME(v_double)"]:[%f]", v_double);
sched_note_printf(0, " char[]["TONNAME(v_char_arr)"]:[%.32s]", TONNAME(v_char_arr));
sched_note_printf(0, " uint64_t["TONNAME(v_uint64_t)"]:[%lu]", v_uint64_t);
sched_note_printf(0, " unsigned char["TONNAME(v_u_char)"]:[%u]", v_u_char);
sched_note_printf(0, "unsigned short int["TONNAME(v_u_s_int)"]:[%u]", v_u_s_int);
sched_note_printf(0, " unsigned int["TONNAME(v_u_int)"]:[%u]", v_u_int);
sched_note_printf(0, " unsigned long["TONNAME(v_u_long)"]:[%lu]", (unsigned long)v_u_long);
sched_note_printf(0, "unsigned long long["TONNAME(v_u_l_l)"]:[%llu]", (unsigned long long)v_u_l_l);
sched_note_printf(0, "\n ###### end test!!! \n");
sched_note_printf(0, "\n ###### start long args test!!! \n");
sched_note_printf(0, "%u %u %u %d %d %d %f %f %lu %ld %d %u %d %u",
v_uint8_t, v_uint16_t, v_uint32_t, v_uint8_t, v_uint16_t,
v_uint32_t, v_float, v_double, v_uint64_t, v_uint64_t,
v_u_char, v_u_char, v_u_s_int, v_u_s_int);
sched_note_printf(0, "%s %s %s %s %s %s %s %s %s %s %s %s %s %s",
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr));
sched_note_printf(0, "\n ###### start long args test!!! \n");
\#endif // !CONFIG_DRIVERS_NOTE_STRIP_FORMAT
return 0;
}
drivers/note/noteram_driver.c
Signed-off-by: likun17 <likun17@xiaomi.com>
2024-01-21 17:53:30 +08:00
|
|
|
strcat(fmt, " %f");
|
2023-11-29 12:35:29 +08:00
|
|
|
}
|
|
|
|
}
|
2023-11-24 15:56:37 +08:00
|
|
|
}
|
|
|
|
|
noteram_driver.c:noteram_dump_printf function replaced with lib_bsprintf.
open CONFIG_DRIVERS_NOTE_STRIP_FORMAT:
OUT:
NuttShell (NSH) NuttX-12.3.0
nsh> hello
nsh> trace dump
loop_task-1 [0] 0.001728177: sched_wakeup_new: comm=loop_task pid=1 target_cpu=0
Idle_Task-0 [0] 0.001745633: sched_wakeup_new: comm=Idle_Task pid=0 target_cpu=0
hpwork-2 [0] 0.001791495: sched_wakeup_new: comm=hpwork pid=2 target_cpu=0
nsh_main-3 [0] 0.001814164: sched_wakeup_new: comm=nsh_main pid=3 target_cpu=0
hello-4 [0] 2.583795447: sched_wakeup_new: comm=hello pid=4 target_cpu=0
hello-4 [0] 2.583843399: tracing_mark_write:
###### start long args test!!!
hello-4 [0] 2.583844088: tracing_mark_write: 0x48ebe0 97 19299 22155 4294967217 4294957304 4294945141 92.999900 9299.929993 92999299929992 18446743074409621624 61 254 429495799 hello-4 [0] 2.583845991: tracing_mark_write: 0x48ec20 qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvb>�/�L�p�J hello-4 [0] 2.583847105: tracing_mark_write:
###### start long args test!!!
trace-5 [0] 2.928625413: sched_wakeup_new: comm=trace pid=5 target_cpu=0
nsh>
close CONFIG_DRIVERS_NOTE_STRIP_FORMAT:
NuttShell (NSH) NuttX-12.3.0
nsh> hello
nsh> trace dump
loop_task-1 [0] 0.001607506: sched_wakeup_new: comm=loop_task pid=1 target_cpu=0
Idle_Task-0 [0] 0.001624549: sched_wakeup_new: comm=Idle_Task pid=0 target_cpu=0
hpwork-2 [0] 0.001666256: sched_wakeup_new: comm=hpwork pid=2 target_cpu=0
nsh_main-3 [0] 0.001688556: sched_wakeup_new: comm=nsh_main pid=3 target_cpu=0
hello-4 [0] 3.812630763: sched_wakeup_new: comm=hello pid=4 target_cpu=0
hello-4 [0] 0.370899272: tracing_mark_write:
###### start NOTE_STRIP_FORMAT test!!!
hello-4 [0] 0.370900260: tracing_mark_write: uint8_t[97]:[97]
hello-4 [0] 0.370900735: tracing_mark_write: uint16_t[19299]:[19299]
hello-4 [0] 0.370901155: tracing_mark_write: uint32_t[22155]:[22155]
hello-4 [0] 0.370901715: tracing_mark_write: float[92.9999]:[92.999900]
hello-4 [0] 0.370902196: tracing_mark_write: double[9299.929992999299]:[9299.929993]
hello-4 [0] 0.370902978: tracing_mark_write: char[][qweretyuiopasdfghjklzxcvbnm]:[qweretyuiopasdfghjklzxcvbnm]
hello-4 [0] 0.370904061: tracing_mark_write: uint64_t[92999299929992]:[92999299929992]
hello-4 [0] 0.370904554: tracing_mark_write: unsigned char[254]:[254]
hello-4 [0] 0.370904999: tracing_mark_write: unsigned short int[9299]:[9299]
hello-4 [0] 0.370905435: tracing_mark_write: unsigned int[9299992]:[9299992]
hello-4 [0] 0.370905876: tracing_mark_write: unsigned long[929992992]:[929992992]
hello-4 [0] 0.370906402: tracing_mark_write: unsigned long long[9299929924]:[9299929924]
hello-4 [0] 0.370906822: tracing_mark_write:
###### end test!!!
hello-4 [0] 0.370908999: tracing_mark_write:
###### start long args test!!!
hello-4 [0] 0.370909770: tracing_mark_write: 97 19299 22155 97 19299 22155 92.999900 9299.929993 92999299929992 92999299929992 254 254 9299 9299
hello-4 [0] 0.370927340: tracing_mark_write: qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweretyuiopasdfghjklzxcvbnm qweret>��+�c� hello-4 [0] 0.370928037: tracing_mark_write:
###### start long args test!!!
trace-5 [0] 4.173395106: sched_wakeup_new: comm=trace pid=5 target_cpu=0
nsh>
test SRC:
\#include <nuttx/config.h>
\#include <nuttx/streams.h>
\#include <stdio.h>
\#include <syslog.h>
\#define TOSTR(str) #str
\#define TONNAME(name) TOSTR(name)
\#define v_uint8_t 97
\#define v_uint16_t 19299
\#define v_uint32_t 22155
\#define v_int8_t -79
\#define v_int16_t -9992
\#define v_int32_t -22155
\#define v_float 92.9999
\#define v_double 9299.929992999299
\#define v_char_arr qweretyuiopasdfghjklzxcvbnm
\#define v_uint64_t 92999299929992
\#define v_int64_t -999299929992
\#define v_char 61
\#define v_u_char 254
\#define v_s_int -9299
\#define v_u_s_int 9299
\#define v_int -9299991
\#define v_u_int 9299992
\#define v_long -929992991
\#define v_u_long 929992992
\#define v_l_l -929992993
\#define v_u_l_l 9299929924
\#define v_size_t 29299
\#define v_l_double -9299.9299929912122464755474
int main(int argc, FAR char *argv[])
{
\#ifdef CONFIG_DRIVERS_NOTE_STRIP_FORMAT
sched_note_printf(0, "\n ###### start long args test!!! \n");
sched_note_printf(0, "%u %u %u %d %d %d %f %f %lu %ld %d %u %d %u",
v_uint8_t, v_uint16_t, v_uint32_t, v_int8_t, v_int16_t,
v_int32_t, v_float, v_double, v_uint64_t, v_int64_t,
v_char, v_u_char, v_s_int, v_u_s_int);
sched_note_printf(0, "%s %s %s %s %s %s %s %s %s %s %s %s %s %s",
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr));
sched_note_printf(0, "\n ###### start long args test!!! \n");
\#else
sched_note_printf(0, "\n ###### start NOTE_STRIP_FORMAT test!!! \n");
sched_note_printf(0, " uint8_t["TONNAME(v_uint8_t)"]:[%u]", v_uint8_t);
sched_note_printf(0, " uint16_t["TONNAME(v_uint16_t)"]:[%u]", v_uint16_t);
sched_note_printf(0, " uint32_t["TONNAME(v_uint32_t)"]:[%u]", v_uint32_t);
sched_note_printf(0, " float["TONNAME(v_float)"]:[%f]", v_float);
sched_note_printf(0, " double["TONNAME(v_double)"]:[%f]", v_double);
sched_note_printf(0, " char[]["TONNAME(v_char_arr)"]:[%.32s]", TONNAME(v_char_arr));
sched_note_printf(0, " uint64_t["TONNAME(v_uint64_t)"]:[%lu]", v_uint64_t);
sched_note_printf(0, " unsigned char["TONNAME(v_u_char)"]:[%u]", v_u_char);
sched_note_printf(0, "unsigned short int["TONNAME(v_u_s_int)"]:[%u]", v_u_s_int);
sched_note_printf(0, " unsigned int["TONNAME(v_u_int)"]:[%u]", v_u_int);
sched_note_printf(0, " unsigned long["TONNAME(v_u_long)"]:[%lu]", (unsigned long)v_u_long);
sched_note_printf(0, "unsigned long long["TONNAME(v_u_l_l)"]:[%llu]", (unsigned long long)v_u_l_l);
sched_note_printf(0, "\n ###### end test!!! \n");
sched_note_printf(0, "\n ###### start long args test!!! \n");
sched_note_printf(0, "%u %u %u %d %d %d %f %f %lu %ld %d %u %d %u",
v_uint8_t, v_uint16_t, v_uint32_t, v_uint8_t, v_uint16_t,
v_uint32_t, v_float, v_double, v_uint64_t, v_uint64_t,
v_u_char, v_u_char, v_u_s_int, v_u_s_int);
sched_note_printf(0, "%s %s %s %s %s %s %s %s %s %s %s %s %s %s",
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr),
TONNAME(v_char_arr), TONNAME(v_char_arr));
sched_note_printf(0, "\n ###### start long args test!!! \n");
\#endif // !CONFIG_DRIVERS_NOTE_STRIP_FORMAT
return 0;
}
drivers/note/noteram_driver.c
Signed-off-by: likun17 <likun17@xiaomi.com>
2024-01-21 17:53:30 +08:00
|
|
|
ret += lib_bsprintf(s, fmt, note->npt_data);
|
2023-11-29 12:35:29 +08:00
|
|
|
lib_stream_putc(s, '\n');
|
|
|
|
ret++;
|
2023-11-24 15:56:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-08-11 10:31:02 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: noteram_dump_one
|
|
|
|
****************************************************************************/
|
|
|
|
|
2023-08-11 10:31:04 +08:00
|
|
|
static int noteram_dump_one(FAR uint8_t *p, FAR struct lib_outstream_s *s,
|
2023-08-11 10:31:02 +08:00
|
|
|
FAR struct noteram_dump_context_s *ctx)
|
|
|
|
{
|
|
|
|
FAR struct note_common_s *note = (FAR struct note_common_s *)p;
|
|
|
|
FAR struct noteram_dump_cpu_context_s *cctx;
|
2023-08-11 10:31:04 +08:00
|
|
|
int ret = 0;
|
2023-08-11 10:31:02 +08:00
|
|
|
pid_t pid;
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
int cpu = note->nc_cpu;
|
|
|
|
#else
|
|
|
|
int cpu = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
cctx = &ctx->cpu[cpu];
|
2023-10-31 22:10:06 +08:00
|
|
|
pid = note->nc_pid;
|
2023-08-11 10:31:02 +08:00
|
|
|
|
|
|
|
if (cctx->current_pid < 0)
|
|
|
|
{
|
|
|
|
cctx->current_pid = pid;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Output one note */
|
|
|
|
|
|
|
|
switch (note->nc_type)
|
|
|
|
{
|
2024-10-08 23:23:21 +08:00
|
|
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
|
2023-08-11 10:31:02 +08:00
|
|
|
case NOTE_START:
|
|
|
|
{
|
2023-08-11 10:31:04 +08:00
|
|
|
ret += noteram_dump_header(s, note, ctx);
|
|
|
|
ret += lib_sprintf(s, "sched_wakeup_new: comm=%s pid=%d "
|
|
|
|
"target_cpu=%d\n",
|
2024-08-28 16:28:46 +08:00
|
|
|
get_taskname(pid), get_pid(pid), cpu);
|
2023-08-11 10:31:02 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NOTE_STOP:
|
|
|
|
{
|
|
|
|
/* This note informs the task to be stopped.
|
|
|
|
* Change current task state for the succeeding NOTE_RESUME.
|
|
|
|
*/
|
|
|
|
|
|
|
|
cctx->current_state = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NOTE_SUSPEND:
|
|
|
|
{
|
|
|
|
FAR struct note_suspend_s *nsu = (FAR struct note_suspend_s *)p;
|
|
|
|
|
|
|
|
/* This note informs the task to be suspended.
|
|
|
|
* Preserve the information for the succeeding NOTE_RESUME.
|
|
|
|
*/
|
|
|
|
|
|
|
|
cctx->current_state = nsu->nsu_state;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NOTE_RESUME:
|
|
|
|
{
|
|
|
|
/* This note informs the task to be resumed.
|
|
|
|
* The task switch timing depends on the running context.
|
|
|
|
*/
|
|
|
|
|
|
|
|
cctx->next_pid = pid;
|
|
|
|
cctx->next_priority = note->nc_priority;
|
|
|
|
|
|
|
|
if (cctx->intr_nest == 0)
|
|
|
|
{
|
|
|
|
/* If not in the interrupt context, the task switch is
|
|
|
|
* executed immediately.
|
|
|
|
*/
|
|
|
|
|
2023-08-11 10:31:04 +08:00
|
|
|
ret += noteram_dump_header(s, note, ctx);
|
|
|
|
ret += noteram_dump_sched_switch(s, note, ctx);
|
2023-08-11 10:31:02 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* If in the interrupt context, the task switch is postponed
|
|
|
|
* until leaving the interrupt handler.
|
|
|
|
*/
|
|
|
|
|
2023-08-11 10:31:04 +08:00
|
|
|
ret += noteram_dump_header(s, note, ctx);
|
|
|
|
ret += lib_sprintf(s, "sched_waking: comm=%s "
|
|
|
|
"pid=%d target_cpu=%d\n",
|
2024-08-28 16:28:46 +08:00
|
|
|
get_taskname(cctx->next_pid),
|
2023-08-11 10:31:04 +08:00
|
|
|
get_pid(cctx->next_pid), cpu);
|
2023-08-11 10:31:02 +08:00
|
|
|
cctx->pendingswitch = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL
|
|
|
|
case NOTE_SYSCALL_ENTER:
|
|
|
|
{
|
|
|
|
FAR struct note_syscall_enter_s *nsc;
|
|
|
|
int i;
|
|
|
|
uintptr_t arg;
|
|
|
|
|
|
|
|
nsc = (FAR struct note_syscall_enter_s *)p;
|
|
|
|
if (nsc->nsc_nr < CONFIG_SYS_RESERVED ||
|
|
|
|
nsc->nsc_nr >= SYS_maxsyscall)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-08-11 10:31:04 +08:00
|
|
|
ret += noteram_dump_header(s, note, ctx);
|
|
|
|
ret += lib_sprintf(s, "sys_%s(",
|
|
|
|
g_funcnames[nsc->nsc_nr - CONFIG_SYS_RESERVED]);
|
2023-08-11 10:31:02 +08:00
|
|
|
|
2024-11-16 23:04:40 +08:00
|
|
|
for (i = 0; i < nsc->nsc_argc; i++)
|
2023-08-11 10:31:02 +08:00
|
|
|
{
|
2023-10-31 22:10:06 +08:00
|
|
|
arg = nsc->nsc_args[i];
|
2023-08-11 10:31:02 +08:00
|
|
|
if (i == 0)
|
|
|
|
{
|
2023-08-11 10:31:04 +08:00
|
|
|
ret += lib_sprintf(s, "arg%d: 0x%" PRIxPTR, i, arg);
|
2023-08-11 10:31:02 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-08-11 10:31:04 +08:00
|
|
|
ret += lib_sprintf(s, ", arg%d: 0x%" PRIxPTR, i, arg);
|
2023-08-11 10:31:02 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-11 10:31:04 +08:00
|
|
|
ret += lib_sprintf(s, ")\n");
|
2023-08-11 10:31:02 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NOTE_SYSCALL_LEAVE:
|
|
|
|
{
|
|
|
|
FAR struct note_syscall_leave_s *nsc;
|
|
|
|
uintptr_t result;
|
|
|
|
|
|
|
|
nsc = (FAR struct note_syscall_leave_s *)p;
|
|
|
|
if (nsc->nsc_nr < CONFIG_SYS_RESERVED ||
|
|
|
|
nsc->nsc_nr >= SYS_maxsyscall)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-08-11 10:31:04 +08:00
|
|
|
ret += noteram_dump_header(s, note, ctx);
|
2023-10-31 22:10:06 +08:00
|
|
|
result = nsc->nsc_result;
|
2023-08-11 10:31:04 +08:00
|
|
|
ret += lib_sprintf(s, "sys_%s -> 0x%" PRIxPTR "\n",
|
2023-08-11 10:31:02 +08:00
|
|
|
g_funcnames[nsc->nsc_nr - CONFIG_SYS_RESERVED],
|
|
|
|
result);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
|
|
|
|
case NOTE_IRQ_ENTER:
|
|
|
|
{
|
|
|
|
FAR struct note_irqhandler_s *nih;
|
|
|
|
|
|
|
|
nih = (FAR struct note_irqhandler_s *)p;
|
2023-08-11 10:31:04 +08:00
|
|
|
ret += noteram_dump_header(s, note, ctx);
|
2023-06-20 16:56:24 +08:00
|
|
|
ret += lib_sprintf(s, "irq_handler_entry: irq=%u name=%pS\n",
|
|
|
|
nih->nih_irq, (FAR void *)nih->nih_handler);
|
2023-08-11 10:31:02 +08:00
|
|
|
cctx->intr_nest++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NOTE_IRQ_LEAVE:
|
|
|
|
{
|
|
|
|
FAR struct note_irqhandler_s *nih;
|
|
|
|
|
|
|
|
nih = (FAR struct note_irqhandler_s *)p;
|
2023-08-11 10:31:04 +08:00
|
|
|
ret += noteram_dump_header(s, note, ctx);
|
|
|
|
ret += lib_sprintf(s, "irq_handler_exit: irq=%u ret=handled\n",
|
|
|
|
nih->nih_irq);
|
2023-08-11 10:31:02 +08:00
|
|
|
cctx->intr_nest--;
|
|
|
|
|
|
|
|
if (cctx->intr_nest <= 0)
|
|
|
|
{
|
|
|
|
cctx->intr_nest = 0;
|
|
|
|
if (cctx->pendingswitch)
|
|
|
|
{
|
|
|
|
/* If the pending task switch exists, it is executed here */
|
|
|
|
|
2023-08-11 10:31:04 +08:00
|
|
|
ret += noteram_dump_header(s, note, ctx);
|
|
|
|
ret += noteram_dump_sched_switch(s, note, ctx);
|
2023-08-11 10:31:02 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
2024-07-09 17:13:11 +08:00
|
|
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_WDOG
|
|
|
|
case NOTE_WDOG_START:
|
|
|
|
case NOTE_WDOG_CANCEL:
|
|
|
|
case NOTE_WDOG_ENTER:
|
|
|
|
case NOTE_WDOG_LEAVE:
|
|
|
|
{
|
|
|
|
FAR struct note_wdog_s *nw;
|
|
|
|
FAR const char *name[] =
|
|
|
|
{
|
|
|
|
"start", "cancel", "enter", "leave",
|
|
|
|
};
|
|
|
|
|
|
|
|
nw = (FAR struct note_wdog_s *)p;
|
|
|
|
ret += noteram_dump_header(s, note, ctx);
|
|
|
|
ret += lib_sprintf(s, "tracing_mark_write: I|%d|wdog: %s-%pS %p\n",
|
|
|
|
pid, name[note->nc_type - NOTE_WDOG_START],
|
|
|
|
(FAR void *)nw->handler, (FAR void *)nw->arg);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
2023-08-11 10:31:02 +08:00
|
|
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_CSECTION
|
|
|
|
case NOTE_CSECTION_ENTER:
|
|
|
|
case NOTE_CSECTION_LEAVE:
|
|
|
|
{
|
|
|
|
struct note_csection_s *ncs;
|
|
|
|
ncs = (FAR struct note_csection_s *)p;
|
2023-08-11 10:31:04 +08:00
|
|
|
ret += noteram_dump_header(s, &ncs->ncs_cmn, ctx);
|
|
|
|
ret += lib_sprintf(s, "tracing_mark_write: %c|%d|critical_section\n",
|
2023-08-11 10:31:02 +08:00
|
|
|
note->nc_type == NOTE_CSECTION_ENTER ?
|
|
|
|
'B' : 'E', pid);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION
|
|
|
|
case NOTE_PREEMPT_LOCK:
|
|
|
|
case NOTE_PREEMPT_UNLOCK:
|
|
|
|
{
|
|
|
|
struct note_preempt_s *npr;
|
|
|
|
int16_t count;
|
|
|
|
npr = (FAR struct note_preempt_s *)p;
|
2023-10-31 22:10:06 +08:00
|
|
|
count = npr->npr_count;
|
2023-08-11 10:31:04 +08:00
|
|
|
ret += noteram_dump_header(s, &npr->npr_cmn, ctx);
|
|
|
|
ret += lib_sprintf(s, "tracing_mark_write: "
|
2023-08-11 10:31:02 +08:00
|
|
|
"%c|%d|sched_lock:%d\n",
|
|
|
|
note->nc_type == NOTE_PREEMPT_LOCK ?
|
|
|
|
'B' : 'E', pid, count);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_DUMP
|
2023-11-24 15:56:37 +08:00
|
|
|
case NOTE_DUMP_PRINTF:
|
2023-08-11 10:31:02 +08:00
|
|
|
{
|
2023-11-24 15:56:37 +08:00
|
|
|
FAR struct note_printf_s *npt;
|
2023-08-11 10:31:02 +08:00
|
|
|
|
2023-11-24 15:56:37 +08:00
|
|
|
npt = (FAR struct note_printf_s *)p;
|
|
|
|
ret += noteram_dump_header(s, &npt->npt_cmn, ctx);
|
|
|
|
ret += lib_sprintf(s, "tracing_mark_write: ");
|
|
|
|
ret += noteram_dump_printf(s, npt);
|
2023-08-11 10:31:02 +08:00
|
|
|
}
|
|
|
|
break;
|
2023-10-10 22:45:02 +08:00
|
|
|
case NOTE_DUMP_BEGIN:
|
|
|
|
case NOTE_DUMP_END:
|
|
|
|
{
|
2023-11-24 15:56:37 +08:00
|
|
|
FAR struct note_event_s *nbi = (FAR struct note_event_s *)p;
|
2023-10-10 22:45:02 +08:00
|
|
|
char c = note->nc_type == NOTE_DUMP_BEGIN ? 'B' : 'E';
|
2024-08-19 11:39:32 +08:00
|
|
|
int len = note->nc_length - SIZEOF_NOTE_EVENT(0);
|
2023-10-16 11:05:17 +08:00
|
|
|
uintptr_t ip;
|
|
|
|
|
2023-11-24 15:56:37 +08:00
|
|
|
ip = nbi->nev_ip;
|
|
|
|
ret += noteram_dump_header(s, &nbi->nev_cmn, ctx);
|
2023-10-10 22:45:02 +08:00
|
|
|
if (len > 0)
|
|
|
|
{
|
|
|
|
ret += lib_sprintf(s, "tracing_mark_write: %c|%d|%.*s\n",
|
2023-11-24 15:56:37 +08:00
|
|
|
c, pid, len, (FAR const char *)nbi->nev_data);
|
2023-10-10 22:45:02 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ret += lib_sprintf(s, "tracing_mark_write: %c|%d|%pS\n",
|
2023-10-16 11:05:17 +08:00
|
|
|
c, pid, (FAR void *)ip);
|
2023-10-10 22:45:02 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NOTE_DUMP_MARK:
|
|
|
|
{
|
2023-11-24 15:56:37 +08:00
|
|
|
int len = note->nc_length - sizeof(struct note_event_s);
|
|
|
|
FAR struct note_event_s *nbi = (FAR struct note_event_s *)p;
|
|
|
|
ret += noteram_dump_header(s, &nbi->nev_cmn, ctx);
|
2023-10-10 22:45:02 +08:00
|
|
|
ret += lib_sprintf(s, "tracing_mark_write: I|%d|%.*s\n",
|
2023-11-24 15:56:37 +08:00
|
|
|
pid, len, (FAR const char *)nbi->nev_data);
|
2023-10-10 22:45:02 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NOTE_DUMP_COUNTER:
|
|
|
|
{
|
2023-11-24 15:56:37 +08:00
|
|
|
FAR struct note_event_s *nbi = (FAR struct note_event_s *)p;
|
2023-10-10 22:45:02 +08:00
|
|
|
FAR struct note_counter_s *counter;
|
2023-11-24 15:56:37 +08:00
|
|
|
counter = (FAR struct note_counter_s *)nbi->nev_data;
|
|
|
|
ret += noteram_dump_header(s, &nbi->nev_cmn, ctx);
|
2023-10-10 22:45:02 +08:00
|
|
|
ret += lib_sprintf(s, "tracing_mark_write: C|%d|%s|%ld\n",
|
|
|
|
pid, counter->name, counter->value);
|
|
|
|
}
|
|
|
|
break;
|
2023-08-11 10:31:02 +08:00
|
|
|
#endif
|
2023-11-14 15:50:52 +08:00
|
|
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_HEAP
|
2024-07-03 13:28:42 +08:00
|
|
|
case NOTE_HEAP_ADD:
|
|
|
|
case NOTE_HEAP_REMOVE:
|
2024-07-09 14:35:01 +08:00
|
|
|
case NOTE_HEAP_ALLOC:
|
|
|
|
case NOTE_HEAP_FREE:
|
2023-11-14 15:50:52 +08:00
|
|
|
{
|
|
|
|
FAR struct note_heap_s *nmm = (FAR struct note_heap_s *)p;
|
|
|
|
FAR const char *name[] =
|
|
|
|
{
|
2024-07-03 13:28:42 +08:00
|
|
|
"add", "remove", "malloc", "free"
|
2023-11-14 15:50:52 +08:00
|
|
|
};
|
|
|
|
|
2024-07-09 17:13:11 +08:00
|
|
|
ret += noteram_dump_header(s, &nmm->nhp_cmn, ctx);
|
2023-11-14 15:50:52 +08:00
|
|
|
ret += lib_sprintf(s, "tracing_mark_write: C|%d|Heap Usage|%d|%s"
|
|
|
|
": heap: %p size:%" PRIiPTR ", address: %p\n",
|
2024-08-28 10:06:52 +08:00
|
|
|
pid, nmm->used,
|
|
|
|
name[note->nc_type - NOTE_HEAP_ADD],
|
2023-11-14 15:50:52 +08:00
|
|
|
nmm->heap, nmm->size, nmm->mem);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
2023-08-11 10:31:02 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return the length of the processed note */
|
|
|
|
|
2023-08-11 10:31:04 +08:00
|
|
|
return ret;
|
2023-08-11 10:31:02 +08:00
|
|
|
}
|
|
|
|
|
2023-07-05 21:53:33 +08:00
|
|
|
#ifdef CONFIG_DRIVERS_NOTERAM_CRASH_DUMP
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: noteram_dump
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static void noteram_dump(FAR struct noteram_driver_s *drv)
|
|
|
|
{
|
|
|
|
struct noteram_dump_context_s ctx;
|
|
|
|
struct lib_syslograwstream_s stream;
|
2023-11-28 17:02:42 +08:00
|
|
|
uint8_t note[256];
|
2023-07-05 21:53:33 +08:00
|
|
|
|
|
|
|
lib_syslograwstream_open(&stream);
|
2023-09-11 03:32:34 +08:00
|
|
|
lib_sprintf(&stream.common, "# tracer:nop\n#\n");
|
2023-07-05 21:53:33 +08:00
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
ssize_t ret;
|
|
|
|
|
|
|
|
ret = noteram_get(drv, note, sizeof(note));
|
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-09-11 03:32:34 +08:00
|
|
|
noteram_dump_one(note, &stream.common, &ctx);
|
2023-07-05 21:53:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
lib_syslograwstream_close(&stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: noteram_crash_dump
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int noteram_crash_dump(FAR struct notifier_block *nb,
|
|
|
|
unsigned long action, FAR void *data)
|
|
|
|
{
|
|
|
|
if (action == PANIC_KERNEL)
|
|
|
|
{
|
|
|
|
noteram_dump(&g_noteram_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void noteram_crash_dump_register(void)
|
|
|
|
{
|
|
|
|
static struct notifier_block nb;
|
|
|
|
nb.notifier_call = noteram_crash_dump;
|
|
|
|
panic_notifier_chain_register(&nb);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2022-12-16 18:31:28 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
2020-09-08 18:44:29 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: noteram_register
|
|
|
|
*
|
|
|
|
* Description:
|
2022-12-14 12:53:09 +08:00
|
|
|
* Register a serial driver at /dev/note/ram that can be used by an
|
2020-09-08 18:44:29 +08:00
|
|
|
* application to read data from the circular note buffer.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* None.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero on succress. A negated errno value is returned on a failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int noteram_register(void)
|
|
|
|
{
|
2023-07-05 21:53:33 +08:00
|
|
|
#ifdef CONFIG_DRIVERS_NOTERAM_CRASH_DUMP
|
|
|
|
noteram_crash_dump_register();
|
|
|
|
#endif
|
2023-04-27 19:42:27 +08:00
|
|
|
return register_driver("/dev/note/ram", &g_noteram_fops, 0666,
|
|
|
|
&g_noteram_driver);
|
2020-09-08 18:44:29 +08:00
|
|
|
}
|
2023-04-27 19:42:27 +08:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: noteram_initialize
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Register a serial driver at /dev/note/ram that can be used by an
|
|
|
|
* application to read data from the circular note buffer.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* devpath: The path of the Noteram device
|
|
|
|
* bufsize: The size of the circular buffer
|
|
|
|
* overwrite: The overwrite mode
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero on succress. A negated errno value is returned on a failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
FAR struct note_driver_s *
|
|
|
|
noteram_initialize(FAR const char *devpath, size_t bufsize, bool overwrite)
|
|
|
|
{
|
|
|
|
FAR struct noteram_driver_s *drv;
|
2024-04-11 16:53:08 +08:00
|
|
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
|
|
|
|
size_t len = strlen(devpath) + 1;
|
|
|
|
#else
|
|
|
|
size_t len = 0;
|
|
|
|
#endif
|
2023-04-27 19:42:27 +08:00
|
|
|
int ret;
|
|
|
|
|
2024-04-11 16:53:08 +08:00
|
|
|
drv = kmm_malloc(sizeof(*drv) + len + bufsize);
|
2023-04-27 19:42:27 +08:00
|
|
|
if (drv == NULL)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2024-04-11 16:53:08 +08:00
|
|
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
|
|
|
|
|
|
|
|
memcpy(drv + 1, devpath, len);
|
|
|
|
drv->driver.name = (FAR const char *)(drv + 1);
|
|
|
|
drv->driver.filter.mode.flag =
|
|
|
|
CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE;
|
|
|
|
|
|
|
|
# ifdef CONFIG_SMP
|
|
|
|
drv->driver.filter.mode.cpuset =
|
|
|
|
CONFIG_SCHED_INSTRUMENTATION_CPUSET;
|
|
|
|
# endif
|
|
|
|
|
|
|
|
#endif
|
2023-04-27 19:42:27 +08:00
|
|
|
|
|
|
|
drv->driver.ops = &g_noteram_ops;
|
|
|
|
drv->ni_bufsize = bufsize;
|
2024-04-11 16:53:08 +08:00
|
|
|
drv->ni_buffer = (FAR uint8_t *)(drv + 1) + len;
|
2023-04-27 19:42:27 +08:00
|
|
|
drv->ni_overwrite = overwrite;
|
|
|
|
drv->ni_head = 0;
|
|
|
|
drv->ni_tail = 0;
|
|
|
|
drv->ni_read = 0;
|
2024-01-24 11:28:49 +08:00
|
|
|
drv->pfd = NULL;
|
2023-04-27 19:42:27 +08:00
|
|
|
|
|
|
|
ret = note_driver_register(&drv->driver);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
kmm_free(drv);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (devpath == NULL)
|
|
|
|
{
|
|
|
|
return &drv->driver;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = register_driver(devpath, &g_noteram_fops, 0666, drv);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
kmm_free(drv);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return &drv->driver;
|
|
|
|
}
|