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/incubator-nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new ef2758c Add note_syscall args support
ef2758c is described below
commit ef2758c0c52e213e5585a9da00d0c5b80c321122
Author: Nakamura, Yuuichi <[email protected]>
AuthorDate: Mon Oct 5 14:54:25 2020 +0900
Add note_syscall args support
---
system/sched_note/note_main.c | 2 +-
system/trace/trace.c | 19 +++++++++++++++++--
system/trace/trace_dump.c | 31 ++++++++++++++++++++++++++++++-
3 files changed, 48 insertions(+), 4 deletions(-)
diff --git a/system/sched_note/note_main.c b/system/sched_note/note_main.c
index ad656e1..7f16350 100644
--- a/system/sched_note/note_main.c
+++ b/system/sched_note/note_main.c
@@ -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",
diff --git a/system/trace/trace.c b/system/trace/trace.c
index 571a44c..ed9db32 100644
--- a/system/trace/trace.c
+++ b/system/trace/trace.c
@@ -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>...] :"
diff --git a/system/trace/trace_dump.c b/system/trace/trace_dump.c
index bc936dd..edaf77a 100644
--- a/system/trace/trace_dump.c
+++ b/system/trace/trace_dump.c
@@ -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;