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
commit 90484a33e9cb7638faad51e8976f50a9535281b5 Author: chao.an <anc...@xiaomi.com> AuthorDate: Thu Mar 31 23:16:07 2022 +0800 sched/trace: correct the note print format note print should with Instruction pointer. e.g: trace_printk("hello NuttX"); trace dump: hello-6 [000] .... 23080.367994: 0xc044a005: hello NuttX Signed-off-by: chao.an <anc...@xiaomi.com> --- examples/noteprintf/noteprintf_main.c | 30 +++++++++++++++--------------- system/sched_note/note_main.c | 14 +++++++------- system/trace/trace_dump.c | 15 +++++++-------- 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/examples/noteprintf/noteprintf_main.c b/examples/noteprintf/noteprintf_main.c index a12df95..64d44ee 100644 --- a/examples/noteprintf/noteprintf_main.c +++ b/examples/noteprintf/noteprintf_main.c @@ -77,27 +77,27 @@ int main(int argc, FAR char *argv[]) while (1) { - sched_note_printf("shced note test count = %d.", count++); - sched_note_string(str); - sched_note_dump(MAIN_MODULE, 1, &binary, sizeof(struct binary)); - sched_note_bprintf(MAIN_MODULE, 2, "%hhd", c); - sched_note_bprintf(MAIN_MODULE, 3, "%hd", s); - sched_note_bprintf(MAIN_MODULE, 4, "%d", i); - sched_note_bprintf(MAIN_MODULE, 5, "%ld", l); - sched_note_bprintf(MAIN_MODULE, 6, "%lld", ll); - sched_note_bprintf(MAIN_MODULE, 7, "%jd", im); - sched_note_bprintf(MAIN_MODULE, 8, "%zd", sz); - sched_note_bprintf(MAIN_MODULE, 9, "%td", ptr); + SCHED_NOTE_PRINTF("shced note test count = %d.", count++); + SCHED_NOTE_STRING(str); + SCHED_NOTE_DUMP(1, &binary, sizeof(struct binary)); + SCHED_NOTE_BPRINTF(2, "%hhd", c); + SCHED_NOTE_BPRINTF(3, "%hd", s); + SCHED_NOTE_BPRINTF(4, "%d", i); + SCHED_NOTE_BPRINTF(5, "%ld", l); + SCHED_NOTE_BPRINTF(6, "%lld", ll); + SCHED_NOTE_BPRINTF(7, "%jd", im); + SCHED_NOTE_BPRINTF(8, "%zd", sz); + SCHED_NOTE_BPRINTF(9, "%td", ptr); #ifdef CONFIG_HAVE_FLOAT - sched_note_bprintf(MAIN_MODULE, 10, "%e", f); + SCHED_NOTE_BPRINTF(10, "%e", f); #endif #ifdef CONFIG_HAVE_DOUBLE - sched_note_bprintf(MAIN_MODULE, 11, "%le", d); + SCHED_NOTE_BPRINTF(11, "%le", d); #endif #ifdef CONFIG_HAVE_LONG_DOUBLE - sched_note_bprintf(MAIN_MODULE, 12, "%Le", ld); + SCHED_NOTE_BPRINTF(12, "%Le", ld); #endif - sched_note_bprintf(MAIN_MODULE, 13, + SCHED_NOTE_BPRINTF(13, "%hhd %hd %d %ld %lld %jd %zd %td", c, s, i, l, ll, im, sz, ptr); usleep(10); diff --git a/system/sched_note/note_main.c b/system/sched_note/note_main.c index ae59315..3bef031 100644 --- a/system/sched_note/note_main.c +++ b/system/sched_note/note_main.c @@ -737,7 +737,7 @@ static void dump_notes(size_t nread) { FAR struct note_binary_s *note_binary = (FAR struct note_binary_s *)note; - uint32_t module; + uintptr_t ip; char out[1280]; int count; int ret = 0; @@ -758,15 +758,15 @@ static void dump_notes(size_t nread) ret += sprintf(&out[ret], " 0x%x", note_binary->nbi_data[i]); } - trace_dump_unflatten(&module, - note_binary->nbi_module, - sizeof(module)); + trace_dump_unflatten(&ip, note_binary->nbi_ip, + sizeof(ip)); syslog_time(LOG_INFO, - "Task %u priority %u, binary:module=%lx " - "event=%u count=%u%s\n", + "Task %u priority %u, ip=0x%" PRIdPTR + " event=%u count=%u%s\n", (unsigned int)pid, - (unsigned int)note->nc_priority, module, + (unsigned int)note->nc_priority, + note_binary->nbi_ip, note_binary->nbi_event, count, out); diff --git a/system/trace/trace_dump.c b/system/trace/trace_dump.c index 4951f92..637561e 100644 --- a/system/trace/trace_dump.c +++ b/system/trace/trace_dump.c @@ -615,31 +615,30 @@ static int trace_dump_one(FAR FILE *out, case NOTE_DUMP_STRING: { FAR struct note_string_s *nst; + uintptr_t ip; nst = (FAR struct note_string_s *)p; trace_dump_header(out, note, ctx); - fprintf(out, "dump_string: %s\n", - nst->nst_data); + trace_dump_unflatten(&ip, nst->nst_ip, sizeof(ip)); + fprintf(out, "0x%" PRIdPTR ": %s\n", ip, nst->nst_data); } break; case NOTE_DUMP_BINARY: { FAR struct note_binary_s *nbi; - uint32_t module; uint8_t count; + uintptr_t ip; int i; nbi = (FAR struct note_binary_s *)p; trace_dump_header(out, note, ctx); count = note->nc_length - sizeof(struct note_binary_s) + 1; - trace_dump_unflatten(&module, - note_binary->nbi_module, - sizeof(module)); + trace_dump_unflatten(&ip, nbi->nbi_ip, sizeof(ip)); - fprintf(out, "dump_binary: module=%lx event=%u count=%u", - module, nbi->nbi_event, count); + fprintf(out, "0x%" PRIdPTR ": event=%u count=%u", + ip, nbi->nbi_event, count); for (i = 0; i < count; i++) { fprintf(out, " 0x%x", nbi->nbi_data[i]);