Add note_syscall args support

This commit is contained in:
Nakamura, Yuuichi 2020-10-05 14:54:25 +09:00 committed by Xiang Xiao
parent 2b88677895
commit ef2758c0c5
3 changed files with 48 additions and 4 deletions

View File

@ -595,7 +595,7 @@ static void dump_notes(size_t nread)
FAR struct note_syscall_enter_s *note_sysenter =
(FAR struct note_syscall_enter_s *)note;
if (note->nc_length != sizeof(struct note_syscall_enter_s))
if (note->nc_length < SIZEOF_NOTE_SYSCALL_ENTER(0))
{
syslog(LOG_INFO,
"ERROR: Size incorrect for SYSCALL enter note: %d\n",

View File

@ -295,7 +295,7 @@ static int trace_cmd_mode(int index, int argc, FAR char **argv,
int i;
int count;
/* Usage: trace mode [{+|-}{o|s|i}...] */
/* Usage: trace mode [{+|-}{o|s|a|i}...] */
/* Get current trace mode */
@ -332,6 +332,17 @@ static int trace_cmd_mode(int index, int argc, FAR char **argv,
mode.flag &= ~NOTE_FILTER_MODE_FLAG_SYSCALL;
}
break;
case 'a': /* Record syscall arguments */
if (enable)
{
mode.flag |= NOTE_FILTER_MODE_FLAG_SYSCALL_ARGS;
}
else
{
mode.flag &= ~NOTE_FILTER_MODE_FLAG_SYSCALL_ARGS;
}
break;
#endif
#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
@ -397,6 +408,10 @@ static int trace_cmd_mode(int index, int argc, FAR char **argv,
{
printf(" Filtered Syscalls : %d\n", count);
}
printf(" Syscall trace with args : %s\n",
mode.flag & NOTE_FILTER_MODE_FLAG_SYSCALL_ARGS ?
"on (+a)" : "off (-a)");
#endif
#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
@ -644,7 +659,7 @@ static void show_usage(void)
" dump [-c][<filename>] :"
" Output the trace result\n"
#endif
" mode [{+|-}{o|s|i}...] :"
" mode [{+|-}{o|s|a|i}...] :"
" Set task trace options\n"
#ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL
" syscall [{+|-}<syscallname>...] :"

View File

@ -421,6 +421,9 @@ static int trace_dump_one(FAR FILE *out,
{
FAR struct note_syscall_enter_s *nsc;
FAR struct trace_dump_task_context_s *tctx;
int i;
int j;
uintptr_t arg;
/* Exclude the case of syscall issued by an interrupt handler and
* nested syscalls to correct tracecompass display.
@ -451,8 +454,34 @@ static int trace_dump_one(FAR FILE *out,
}
trace_dump_header(out, note, ctx);
fprintf(out, "sys_%s()\n",
fprintf(out, "sys_%s(",
g_funcnames[nsc->nsc_nr - CONFIG_SYS_RESERVED]);
for (i = j = 0; i < nsc->nsc_argc; i++)
{
arg = (uintptr_t)nsc->nsc_args[j++];
arg |= (uintptr_t)nsc->nsc_args[j++] << 8;
#if UINTPTR_MAX > UINT16_MAX
arg |= (uintptr_t)nsc->nsc_args[j++] << 16;
arg |= (uintptr_t)nsc->nsc_args[j++] << 24;
#if UINTPTR_MAX > UINT32_MAX
arg |= (uintptr_t)nsc->nsc_args[j++] << 32;
arg |= (uintptr_t)nsc->nsc_args[j++] << 40;
arg |= (uintptr_t)nsc->nsc_args[j++] << 48;
arg |= (uintptr_t)nsc->nsc_args[j++] << 56;
#endif
#endif
if (i == 0)
{
fprintf(out, "arg%d: 0x%x", i, arg);
}
else
{
fprintf(out, ", arg%d: 0x%x", i, arg);
}
}
fprintf(out, ")\n");
}
break;