mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-01 20:29:00 +00:00
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 <yukangzhi@xiaomi.com>
This commit is contained in:
parent
c69df55cd0
commit
71593dffad
3 changed files with 31 additions and 7 deletions
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ extern "C"
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
int trace_dump(FAR FILE *out);
|
||||
int trace_dump(FAR FILE *out, bool binary);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: trace_dump_clear
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue