This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 71593dffa apps/system/trace: support binary dump of noteram
71593dffa is described below
commit 71593dffad2cee60d6f704da114d6f399adaa072
Author: yukangzhi <[email protected]>
AuthorDate: Fri Apr 25 15:47:14 2025 +0800
apps/system/trace: support binary dump of noteram
This patch adds support for dumping binary contents from noteram via the
`trace dump -b <file>` command. Changes include:
- Add a `binary` parameter to `trace_dump()` and the public header
`system/trace/trace.h` to indicate binary output mode.
- Update `trace_dump()` to set the noteram read mode to binary using
`NOTERAM_SETREADMODE` when requested.
- Update `trace dump` CLI parsing in `system/trace/trace.c` to accept
the `-b` flag and pass it through to `trace_dump()`.
- Update usage/help text to include the new `-b` option.
Signed-off-by: yukangzhi <[email protected]>
---
system/trace/trace.c | 22 +++++++++++++++++-----
system/trace/trace.h | 2 +-
system/trace/trace_dump.c | 14 +++++++++++++-
3 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/system/trace/trace.c b/system/trace/trace.c
index f4a5454a4..f414c41ea 100644
--- a/system/trace/trace.c
+++ b/system/trace/trace.c
@@ -147,10 +147,20 @@ static int trace_cmd_dump(FAR const char *name, int
index, int argc,
{
FAR FILE *out = stdout;
bool changed = false;
+ bool binary = false;
bool cont = false;
int ret;
- /* Usage: trace dump [-c][<filename>] */
+ /* Usage: trace dump [-b][-c][<filename>] */
+
+ if (index < argc)
+ {
+ if (strcmp(argv[index], "-b") == 0)
+ {
+ binary = true;
+ index++;
+ }
+ }
if (index < argc)
{
@@ -192,11 +202,14 @@ static int trace_cmd_dump(FAR const char *name, int
index, int argc,
/* Dump the trace header */
- fputs("# tracer: nop\n#\n", out);
+ if (!binary)
+ {
+ fputs("# tracer: nop\n#\n", out);
+ }
/* Dump the trace data */
- ret = trace_dump(out);
+ ret = trace_dump(out, binary);
if (changed)
{
@@ -803,9 +816,8 @@ static void show_usage(void)
" Get the trace while running <command>\n"
#endif
#ifdef CONFIG_DRIVERS_NOTERAM
- " dump [-a][-c][<filename>] :"
+ " dump [-b][-c][<filename>] :"
" Output the trace result\n"
- " [-a] <Android SysTrace>\n"
#endif
" mode [{+|-}{o|w|s|a|i|d}...] :"
" Set task trace options\n"
diff --git a/system/trace/trace.h b/system/trace/trace.h
index 5ac104841..d94e3568b 100644
--- a/system/trace/trace.h
+++ b/system/trace/trace.h
@@ -57,7 +57,7 @@ extern "C"
*
****************************************************************************/
-int trace_dump(FAR FILE *out);
+int trace_dump(FAR FILE *out, bool binary);
/****************************************************************************
* Name: trace_dump_clear
diff --git a/system/trace/trace_dump.c b/system/trace/trace_dump.c
index d51453da1..c91b7264e 100644
--- a/system/trace/trace_dump.c
+++ b/system/trace/trace_dump.c
@@ -67,7 +67,7 @@ static void note_ioctl(int cmd, unsigned long arg)
*
****************************************************************************/
-int trace_dump(FAR FILE *out)
+int trace_dump(FAR FILE *out, bool binary)
{
uint8_t tracedata[1024];
int ret;
@@ -82,6 +82,18 @@ int trace_dump(FAR FILE *out)
return ERROR;
}
+ if (binary)
+ {
+ unsigned int mode = NOTERAM_MODE_READ_BINARY;
+ ret = ioctl(fd, NOTERAM_SETREADMODE, &mode);
+ if (ret < 0)
+ {
+ fprintf(stderr, "trace: cannot set read mode\n");
+ close(fd);
+ return ERROR;
+ }
+ }
+
/* Read and output all notes */
while (1)