trace: unify ftrace and atrace output formats
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
This commit is contained in:
parent
c7955e5faf
commit
95b0515c30
@ -142,23 +142,11 @@ static int trace_cmd_start(int index, int argc, FAR char **argv,
|
|||||||
static int trace_cmd_dump(int index, int argc, FAR char **argv,
|
static int trace_cmd_dump(int index, int argc, FAR char **argv,
|
||||||
int notectlfd)
|
int notectlfd)
|
||||||
{
|
{
|
||||||
trace_dump_t type = TRACE_TYPE_LTTNG_KERNEL;
|
|
||||||
FAR FILE *out = stdout;
|
FAR FILE *out = stdout;
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
bool cont = false;
|
bool cont = false;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Usage: trace dump [-a] "Custom Format : Android SysTrace" */
|
|
||||||
|
|
||||||
if (index < argc)
|
|
||||||
{
|
|
||||||
if (strcmp(argv[index], "-a") == 0)
|
|
||||||
{
|
|
||||||
index++;
|
|
||||||
type = TRACE_TYPE_ANDROID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Usage: trace dump [-c][<filename>] */
|
/* Usage: trace dump [-c][<filename>] */
|
||||||
|
|
||||||
if (index < argc)
|
if (index < argc)
|
||||||
@ -205,7 +193,7 @@ static int trace_cmd_dump(int index, int argc, FAR char **argv,
|
|||||||
|
|
||||||
/* Dump the trace data */
|
/* Dump the trace data */
|
||||||
|
|
||||||
ret = trace_dump(type, out);
|
ret = trace_dump(out);
|
||||||
|
|
||||||
if (changed)
|
if (changed)
|
||||||
{
|
{
|
||||||
|
@ -41,16 +41,6 @@ extern "C"
|
|||||||
* Public Types
|
* Public Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
TRACE_TYPE_LTTNG_KERNEL = 0, /* Common Trace Format : Linux Kernel Trace */
|
|
||||||
TRACE_TYPE_GENERIC_CTF = 1, /* Common Trace Format : Generic CTF Trace */
|
|
||||||
TRACE_TYPE_LTTNG_UST = 2, /* Common Trace Format : LTTng UST Trace */
|
|
||||||
TRACE_TYPE_CUSTOM_TEXT = 3, /* Custom Text : TmfGeneric */
|
|
||||||
TRACE_TYPE_CUSTOM_XML = 4, /* Custom XML : Custom XML Log */
|
|
||||||
TRACE_TYPE_ANDROID = 5, /* Custom Format : Android ATrace */
|
|
||||||
} trace_dump_t;
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -65,7 +55,7 @@ typedef enum
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int trace_dump(trace_dump_t type, FAR FILE *out);
|
int trace_dump(FAR FILE *out);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: trace_dump_clear
|
* Name: trace_dump_clear
|
||||||
|
@ -356,7 +356,7 @@ static void trace_dump_sched_switch(FAR FILE *out,
|
|||||||
* Name: trace_dump_one
|
* Name: trace_dump_one
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int trace_dump_one(trace_dump_t type, FAR FILE *out, FAR uint8_t *p,
|
static int trace_dump_one(FAR FILE *out, FAR uint8_t *p,
|
||||||
FAR struct trace_dump_context_s *ctx)
|
FAR struct trace_dump_context_s *ctx)
|
||||||
{
|
{
|
||||||
FAR struct note_common_s *note = (FAR struct note_common_s *)p;
|
FAR struct note_common_s *note = (FAR struct note_common_s *)p;
|
||||||
@ -494,16 +494,8 @@ static int trace_dump_one(trace_dump_t type, FAR FILE *out, FAR uint8_t *p,
|
|||||||
}
|
}
|
||||||
|
|
||||||
trace_dump_header(out, note, ctx);
|
trace_dump_header(out, note, ctx);
|
||||||
if (type == TRACE_TYPE_ANDROID)
|
|
||||||
{
|
|
||||||
fprintf(out, "tracing_mark_write: B|%d|sys_%s(",
|
|
||||||
pid, g_funcnames[nsc->nsc_nr - CONFIG_SYS_RESERVED]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fprintf(out, "sys_%s(",
|
fprintf(out, "sys_%s(",
|
||||||
g_funcnames[nsc->nsc_nr - CONFIG_SYS_RESERVED]);
|
g_funcnames[nsc->nsc_nr - CONFIG_SYS_RESERVED]);
|
||||||
}
|
|
||||||
|
|
||||||
for (i = j = 0; i < nsc->nsc_argc; i++)
|
for (i = j = 0; i < nsc->nsc_argc; i++)
|
||||||
{
|
{
|
||||||
@ -560,21 +552,10 @@ static int trace_dump_one(trace_dump_t type, FAR FILE *out, FAR uint8_t *p,
|
|||||||
|
|
||||||
trace_dump_header(out, note, ctx);
|
trace_dump_header(out, note, ctx);
|
||||||
trace_dump_unflatten(&result, nsc->nsc_result, sizeof(result));
|
trace_dump_unflatten(&result, nsc->nsc_result, sizeof(result));
|
||||||
|
|
||||||
if (type == TRACE_TYPE_ANDROID)
|
|
||||||
{
|
|
||||||
fprintf(out, "tracing_mark_write: E|%d|"
|
|
||||||
"sys_%s -> 0x%" PRIxPTR "\n", pid,
|
|
||||||
g_funcnames[nsc->nsc_nr - CONFIG_SYS_RESERVED],
|
|
||||||
result);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fprintf(out, "sys_%s -> 0x%" PRIxPTR "\n",
|
fprintf(out, "sys_%s -> 0x%" PRIxPTR "\n",
|
||||||
g_funcnames[nsc->nsc_nr - CONFIG_SYS_RESERVED],
|
g_funcnames[nsc->nsc_nr - CONFIG_SYS_RESERVED],
|
||||||
result);
|
result);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -626,26 +607,18 @@ static int trace_dump_one(trace_dump_t type, FAR FILE *out, FAR uint8_t *p,
|
|||||||
trace_dump_header(out, note, ctx);
|
trace_dump_header(out, note, ctx);
|
||||||
trace_dump_unflatten(&ip, nst->nst_ip, sizeof(ip));
|
trace_dump_unflatten(&ip, nst->nst_ip, sizeof(ip));
|
||||||
|
|
||||||
if (type == TRACE_TYPE_ANDROID &&
|
if (nst->nst_data[1] == '\0' &&
|
||||||
nst->nst_data[1] == '\0' &&
|
|
||||||
(nst->nst_data[0] == 'B' ||
|
(nst->nst_data[0] == 'B' ||
|
||||||
nst->nst_data[0] == 'E'))
|
nst->nst_data[0] == 'E'))
|
||||||
{
|
{
|
||||||
fprintf(out, "tracing_mark_write: %c|%d|%pS\n",
|
fprintf(out, "tracing_mark_write: %c|%d|%pS\n",
|
||||||
nst->nst_data[0], pid, (FAR void *)ip);
|
nst->nst_data[0], pid, (FAR void *)ip);
|
||||||
}
|
}
|
||||||
else if (type == TRACE_TYPE_ANDROID &&
|
else
|
||||||
nst->nst_data[1] == '|' &&
|
|
||||||
(nst->nst_data[0] == 'B' ||
|
|
||||||
nst->nst_data[0] == 'E'))
|
|
||||||
{
|
{
|
||||||
fprintf(out, "tracing_mark_write: %s\n",
|
fprintf(out, "tracing_mark_write: %s\n",
|
||||||
nst->nst_data);
|
nst->nst_data);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
fprintf(out, "%pS: %s\n", (FAR void *)ip, nst->nst_data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -662,7 +635,8 @@ static int trace_dump_one(trace_dump_t type, FAR FILE *out, FAR uint8_t *p,
|
|||||||
|
|
||||||
trace_dump_unflatten(&ip, nbi->nbi_ip, sizeof(ip));
|
trace_dump_unflatten(&ip, nbi->nbi_ip, sizeof(ip));
|
||||||
|
|
||||||
fprintf(out, "0x%" PRIdPTR ": event=%u count=%u",
|
fprintf(out, "tracing_mark_write: 0x%" PRIdPTR
|
||||||
|
": event=%u count=%u",
|
||||||
ip, nbi->nbi_event, count);
|
ip, nbi->nbi_event, count);
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
@ -697,7 +671,7 @@ static int trace_dump_one(trace_dump_t type, FAR FILE *out, FAR uint8_t *p,
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int trace_dump(trace_dump_t type, FAR FILE *out)
|
int trace_dump(FAR FILE *out)
|
||||||
{
|
{
|
||||||
struct trace_dump_context_s ctx;
|
struct trace_dump_context_s ctx;
|
||||||
uint8_t tracedata[UCHAR_MAX];
|
uint8_t tracedata[UCHAR_MAX];
|
||||||
@ -730,7 +704,7 @@ int trace_dump(trace_dump_t type, FAR FILE *out)
|
|||||||
p = tracedata;
|
p = tracedata;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
size = trace_dump_one(type, out, p, &ctx);
|
size = trace_dump_one(out, p, &ctx);
|
||||||
p += size;
|
p += size;
|
||||||
ret -= size;
|
ret -= size;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user