Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 17 additions & 27 deletions drivers/note/note_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1533,7 +1533,7 @@ void sched_note_event_ip(uint32_t tag, uintptr_t ip, uint8_t event,
}

void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
uint32_t type, va_list va)
uint32_t type, va_list *va)
{
FAR struct note_printf_s *note;
FAR struct note_driver_s **driver;
Expand All @@ -1549,7 +1549,7 @@ void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
continue;
}

if (note_vprintf(*driver, ip, fmt, va))
if (note_vprintf(*driver, ip, fmt, *va))
{
continue;
}
Expand Down Expand Up @@ -1601,7 +1601,7 @@ void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
{
case NOTE_PRINTF_UINT32:
{
var->i = va_arg(va, int);
var->i = va_arg(*va, int);
if (next + sizeof(var->i) > length)
{
break;
Expand All @@ -1617,14 +1617,14 @@ void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
break;
}

var->ll = va_arg(va, long long);
var->ll = va_arg(*va, long long);
next += sizeof(var->ll);
}
break;
case NOTE_PRINTF_STRING:
{
size_t len;
var->s = va_arg(va, FAR const char *);
var->s = va_arg(*va, FAR const char *);
len = strlen(var->s) + 1;
if (next + len > length)
{
Expand All @@ -1637,7 +1637,7 @@ void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
break;
case NOTE_PRINTF_DOUBLE:
{
var->d = va_arg(va, double);
var->d = va_arg(*va, double);
if (next + sizeof(var->d) > length)
{
break;
Expand Down Expand Up @@ -1675,7 +1675,7 @@ void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
break;
}

var->im = va_arg(va, intmax_t);
var->im = va_arg(*va, intmax_t);
next += sizeof(var->im);
}
#ifdef CONFIG_HAVE_LONG_LONG
Expand All @@ -1686,7 +1686,7 @@ void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
break;
}

var->ll = va_arg(va, long long);
var->ll = va_arg(*va, long long);
next += sizeof(var->ll);
}
#endif
Expand All @@ -1697,7 +1697,7 @@ void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
break;
}

var->l = va_arg(va, long);
var->l = va_arg(*va, long);
next += sizeof(var->l);
}
else if (*(p - 2) == 'z')
Expand All @@ -1707,7 +1707,7 @@ void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
break;
}

var->sz = va_arg(va, size_t);
var->sz = va_arg(*va, size_t);
next += sizeof(var->sz);
}
else if (*(p - 2) == 't')
Expand All @@ -1717,7 +1717,7 @@ void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
break;
}

var->ptr = va_arg(va, ptrdiff_t);
var->ptr = va_arg(*va, ptrdiff_t);
next += sizeof(var->ptr);
}
else
Expand All @@ -1727,7 +1727,7 @@ void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
break;
}

var->i = va_arg(va, int);
var->i = va_arg(*va, int);
next += sizeof(var->i);
}

Expand All @@ -1745,7 +1745,7 @@ void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
break;
}

var->ld = va_arg(va, long double);
var->ld = va_arg(*va, long double);
next += sizeof(var->ld);
}
else
Expand All @@ -1756,7 +1756,7 @@ void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
break;
}

var->d = va_arg(va, double);
var->d = va_arg(*va, double);
next += sizeof(var->d);
}
#endif
Expand All @@ -1765,13 +1765,13 @@ void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
}
else if (c == '*')
{
var->i = va_arg(va, int);
var->i = va_arg(*va, int);
next += sizeof(var->i);
}
else if (c == 's')
{
size_t len;
var->s = va_arg(va, FAR char *);
var->s = va_arg(*va, FAR char *);
len = strlen(var->s) + 1;
if (next + len > length)
{
Expand All @@ -1789,7 +1789,7 @@ void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
break;
}

var->p = va_arg(va, FAR void *);
var->p = va_arg(*va, FAR void *);
next += sizeof(var->p);
infmt = false;
}
Expand All @@ -1808,16 +1808,6 @@ void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
note_add(*driver, note, length);
}
}

void sched_note_printf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
uint32_t type, ...)
{
va_list va;
va_start(va, type);
sched_note_vprintf_ip(tag, ip, fmt, type, va);
va_end(va);
}

#endif /* CONFIG_SCHED_INSTRUMENTATION_DUMP */

#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
Expand Down
4 changes: 2 additions & 2 deletions include/nuttx/sched_note.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
#define sched_note_event(tag, event, buf, len) \
sched_note_event_ip(tag, SCHED_NOTE_IP, event, buf, len)
#define sched_note_vprintf(tag, fmt, va) \
sched_note_vprintf_ip(tag, SCHED_NOTE_IP, fmt, 0, va)
sched_note_vprintf_ip(tag, SCHED_NOTE_IP, fmt, 0, &(va))

#ifdef CONFIG_DRIVERS_NOTE_STRIP_FORMAT
# define sched_note_printf(tag, fmt, ...) \
Expand Down Expand Up @@ -670,7 +670,7 @@ void sched_note_heap(uint8_t event, FAR void *heap, FAR void *mem,
void sched_note_event_ip(uint32_t tag, uintptr_t ip, uint8_t event,
FAR const void *buf, size_t len);
void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
uint32_t type, va_list va) printf_like(3, 0);
uint32_t type, va_list *va) printf_like(3, 0);
void sched_note_printf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
uint32_t type, ...) printf_like(3, 5);
#else
Expand Down
4 changes: 4 additions & 0 deletions include/sys/syscall_lookup.h
Original file line number Diff line number Diff line change
Expand Up @@ -402,3 +402,7 @@ SYSCALL_LOOKUP(settimeofday, 2)
/* ANSI C signal handling */

SYSCALL_LOOKUP(signal, 2)

#ifdef CONFIG_SCHED_INSTRUMENTATION_DUMP
SYSCALL_LOOKUP(sched_note_vprintf_ip, 5)
#endif
4 changes: 4 additions & 0 deletions libs/libc/misc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ if(CONFIG_FDCHECK)
list(APPEND SRCS lib_fdcheck.c)
endif()

if(CONFIG_SCHED_INSTRUMENTATION_DUMP)
list(APPEND SRCS lib_note.c)
endif()

if(NOT CONFIG_LIBC_UNAME_DISABLE_TIMESTAMP)
add_custom_target(
always_rebuild_lib_utsname
Expand Down
6 changes: 6 additions & 0 deletions libs/libc/misc/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ ifeq ($(CONFIG_FDCHECK),y)
CSRCS += lib_fdcheck.c
endif

# Note support

ifeq ($(CONFIG_SCHED_INSTRUMENTATION_DUMP),y)
CSRCS += lib_note.c
endif

# To ensure uname information is newest,
# add lib_utsname.o to phony target for force rebuild

Expand Down
49 changes: 49 additions & 0 deletions libs/libc/misc/lib_note.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/****************************************************************************
* libs/libc/misc/lib_note.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/

/****************************************************************************
* Included Files
****************************************************************************/

#include <nuttx/config.h>

#include <stdarg.h>
#include <syslog.h>

#include <nuttx/sched_note.h>

/****************************************************************************
* Public Functions
****************************************************************************/

#ifdef CONFIG_SCHED_INSTRUMENTATION_DUMP

void sched_note_printf_ip(uint32_t tag, uintptr_t ip,
FAR const char *fmt,
uint32_t type, ...)
{
va_list va;
va_start(va, type);
sched_note_vprintf_ip(tag, ip, fmt, type, &va);
va_end(va);
}

#endif /* CONFIG_SCHED_INSTRUMENTATION_DUMP */

3 changes: 2 additions & 1 deletion syscall/syscall.csv
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"nx_mkfifo","nuttx/fs/fs.h","defined(CONFIG_PIPES) && CONFIG_DEV_FIFO_SIZE > 0","int","FAR const char *","mode_t","size_t"
"nx_pthread_create","nuttx/pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","pthread_trampoline_t","FAR pthread_t *","FAR const pthread_attr_t *","pthread_startroutine_t","pthread_addr_t"
"nx_pthread_exit","nuttx/pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","noreturn","pthread_addr_t"
"nx_vsyslog","nuttx/syslog/syslog.h","","int","int","FAR const IPTR char *","FAR va_list *"
"nx_vsyslog","nuttx/syslog/syslog.h","!defined(CONFIG_SYSLOG_TO_SCHED_NOTE)","int","int","FAR const IPTR char *","FAR va_list *"
"nxsched_get_stackinfo","nuttx/sched.h","","int","pid_t","FAR struct stackinfo_s *"
"nxsem_tickwait","nuttx/semaphore.h","","int","FAR sem_t *","uint32_t"
"nxsem_clockwait","nuttx/semaphore.h","","int","FAR sem_t *","clockid_t","FAR const struct timespec *"
Expand Down Expand Up @@ -140,6 +140,7 @@
"sched_getscheduler","sched.h","","int","pid_t"
"sched_lock","sched.h","","void"
"sched_lockcount","sched.h","","int"
"sched_note_vprintf_ip","nuttx/sched_note.h","defined(CONFIG_SCHED_INSTRUMENTATION_DUMP)","void","uint32_t","uintptr_t","FAR const IPTR char *","uint32_t","FAR va_list *"
"sched_rr_get_interval","sched.h","","int","pid_t","struct timespec *"
"sched_setaffinity","sched.h","defined(CONFIG_SMP)","int","pid_t","size_t","FAR const cpu_set_t*"
"sched_setparam","sched.h","","int","pid_t","const struct sched_param *"
Expand Down
Loading