driver/note: Fix compilation error when CONFIG_SYSLOG_TO_SCHED_NOTE=y

Add compilation condition for 'nx_vsyslog' syscall.
Export 'sched_note_printf_ip' syscall when CONFIG_SYSLOG_TO_SCHED_NOTE=y
Put the implementation of sched_note_printf_ip in libc/misc/lib_note.c

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
This commit is contained in:
yukangzhi
2025-04-24 19:28:10 +08:00
committed by Alan C. Assis
parent 5f92db54a6
commit 1b22f8c65b
7 changed files with 84 additions and 30 deletions
+17 -27
View File
@@ -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, 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_printf_s *note;
FAR struct note_driver_s **driver; FAR struct note_driver_s **driver;
@@ -1549,7 +1549,7 @@ void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
continue; continue;
} }
if (note_vprintf(*driver, ip, fmt, va)) if (note_vprintf(*driver, ip, fmt, *va))
{ {
continue; continue;
} }
@@ -1601,7 +1601,7 @@ void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
{ {
case NOTE_PRINTF_UINT32: case NOTE_PRINTF_UINT32:
{ {
var->i = va_arg(va, int); var->i = va_arg(*va, int);
if (next + sizeof(var->i) > length) if (next + sizeof(var->i) > length)
{ {
break; break;
@@ -1617,14 +1617,14 @@ void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
break; break;
} }
var->ll = va_arg(va, long long); var->ll = va_arg(*va, long long);
next += sizeof(var->ll); next += sizeof(var->ll);
} }
break; break;
case NOTE_PRINTF_STRING: case NOTE_PRINTF_STRING:
{ {
size_t len; size_t len;
var->s = va_arg(va, FAR const char *); var->s = va_arg(*va, FAR const char *);
len = strlen(var->s) + 1; len = strlen(var->s) + 1;
if (next + len > length) if (next + len > length)
{ {
@@ -1637,7 +1637,7 @@ void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
break; break;
case NOTE_PRINTF_DOUBLE: case NOTE_PRINTF_DOUBLE:
{ {
var->d = va_arg(va, double); var->d = va_arg(*va, double);
if (next + sizeof(var->d) > length) if (next + sizeof(var->d) > length)
{ {
break; break;
@@ -1675,7 +1675,7 @@ void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
break; break;
} }
var->im = va_arg(va, intmax_t); var->im = va_arg(*va, intmax_t);
next += sizeof(var->im); next += sizeof(var->im);
} }
#ifdef CONFIG_HAVE_LONG_LONG #ifdef CONFIG_HAVE_LONG_LONG
@@ -1686,7 +1686,7 @@ void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
break; break;
} }
var->ll = va_arg(va, long long); var->ll = va_arg(*va, long long);
next += sizeof(var->ll); next += sizeof(var->ll);
} }
#endif #endif
@@ -1697,7 +1697,7 @@ void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
break; break;
} }
var->l = va_arg(va, long); var->l = va_arg(*va, long);
next += sizeof(var->l); next += sizeof(var->l);
} }
else if (*(p - 2) == 'z') else if (*(p - 2) == 'z')
@@ -1707,7 +1707,7 @@ void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
break; break;
} }
var->sz = va_arg(va, size_t); var->sz = va_arg(*va, size_t);
next += sizeof(var->sz); next += sizeof(var->sz);
} }
else if (*(p - 2) == 't') else if (*(p - 2) == 't')
@@ -1717,7 +1717,7 @@ void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
break; break;
} }
var->ptr = va_arg(va, ptrdiff_t); var->ptr = va_arg(*va, ptrdiff_t);
next += sizeof(var->ptr); next += sizeof(var->ptr);
} }
else else
@@ -1727,7 +1727,7 @@ void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
break; break;
} }
var->i = va_arg(va, int); var->i = va_arg(*va, int);
next += sizeof(var->i); next += sizeof(var->i);
} }
@@ -1745,7 +1745,7 @@ void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
break; break;
} }
var->ld = va_arg(va, long double); var->ld = va_arg(*va, long double);
next += sizeof(var->ld); next += sizeof(var->ld);
} }
else else
@@ -1756,7 +1756,7 @@ void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
break; break;
} }
var->d = va_arg(va, double); var->d = va_arg(*va, double);
next += sizeof(var->d); next += sizeof(var->d);
} }
#endif #endif
@@ -1765,13 +1765,13 @@ void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
} }
else if (c == '*') else if (c == '*')
{ {
var->i = va_arg(va, int); var->i = va_arg(*va, int);
next += sizeof(var->i); next += sizeof(var->i);
} }
else if (c == 's') else if (c == 's')
{ {
size_t len; size_t len;
var->s = va_arg(va, FAR char *); var->s = va_arg(*va, FAR char *);
len = strlen(var->s) + 1; len = strlen(var->s) + 1;
if (next + len > length) if (next + len > length)
{ {
@@ -1789,7 +1789,7 @@ void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
break; break;
} }
var->p = va_arg(va, FAR void *); var->p = va_arg(*va, FAR void *);
next += sizeof(var->p); next += sizeof(var->p);
infmt = false; infmt = false;
} }
@@ -1808,16 +1808,6 @@ void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
note_add(*driver, note, length); 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 */ #endif /* CONFIG_SCHED_INSTRUMENTATION_DUMP */
#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER #ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+2 -2
View File
@@ -185,7 +185,7 @@
#define sched_note_event(tag, event, buf, len) \ #define sched_note_event(tag, event, buf, len) \
sched_note_event_ip(tag, SCHED_NOTE_IP, event, buf, len) sched_note_event_ip(tag, SCHED_NOTE_IP, event, buf, len)
#define sched_note_vprintf(tag, fmt, va) \ #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 #ifdef CONFIG_DRIVERS_NOTE_STRIP_FORMAT
# define sched_note_printf(tag, fmt, ...) \ # define sched_note_printf(tag, fmt, ...) \
@@ -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, void sched_note_event_ip(uint32_t tag, uintptr_t ip, uint8_t event,
FAR const void *buf, size_t len); FAR const void *buf, size_t len);
void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt, 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, void sched_note_printf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
uint32_t type, ...) printf_like(3, 5); uint32_t type, ...) printf_like(3, 5);
#else #else
+4
View File
@@ -402,3 +402,7 @@ SYSCALL_LOOKUP(settimeofday, 2)
/* ANSI C signal handling */ /* ANSI C signal handling */
SYSCALL_LOOKUP(signal, 2) SYSCALL_LOOKUP(signal, 2)
#ifdef CONFIG_SCHED_INSTRUMENTATION_DUMP
SYSCALL_LOOKUP(sched_note_vprintf_ip, 5)
#endif
+4
View File
@@ -122,6 +122,10 @@ if(CONFIG_FDCHECK)
list(APPEND SRCS lib_fdcheck.c) list(APPEND SRCS lib_fdcheck.c)
endif() endif()
if(CONFIG_SCHED_INSTRUMENTATION_DUMP)
list(APPEND SRCS lib_note.c)
endif()
if(NOT CONFIG_LIBC_UNAME_DISABLE_TIMESTAMP) if(NOT CONFIG_LIBC_UNAME_DISABLE_TIMESTAMP)
add_custom_target( add_custom_target(
always_rebuild_lib_utsname always_rebuild_lib_utsname
+6
View File
@@ -80,6 +80,12 @@ ifeq ($(CONFIG_FDCHECK),y)
CSRCS += lib_fdcheck.c CSRCS += lib_fdcheck.c
endif endif
# Note support
ifeq ($(CONFIG_SCHED_INSTRUMENTATION_DUMP),y)
CSRCS += lib_note.c
endif
# To ensure uname information is newest, # To ensure uname information is newest,
# add lib_utsname.o to phony target for force rebuild # add lib_utsname.o to phony target for force rebuild
+49
View File
@@ -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 */
+2 -1
View File
@@ -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_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_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_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 *" "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_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 *" "nxsem_clockwait","nuttx/semaphore.h","","int","FAR sem_t *","clockid_t","FAR const struct timespec *"
@@ -140,6 +140,7 @@
"sched_getscheduler","sched.h","","int","pid_t" "sched_getscheduler","sched.h","","int","pid_t"
"sched_lock","sched.h","","void" "sched_lock","sched.h","","void"
"sched_lockcount","sched.h","","int" "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_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_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 *" "sched_setparam","sched.h","","int","pid_t","const struct sched_param *"
1 _assert assert.h void FAR const char * int FAR const char * FAR void *
84 nx_mkfifo nuttx/fs/fs.h defined(CONFIG_PIPES) && CONFIG_DEV_FIFO_SIZE > 0 int FAR const char * mode_t size_t
85 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
86 nx_pthread_exit nuttx/pthread.h !defined(CONFIG_DISABLE_PTHREAD) noreturn pthread_addr_t
87 nx_vsyslog nuttx/syslog/syslog.h !defined(CONFIG_SYSLOG_TO_SCHED_NOTE) int int FAR const IPTR char * FAR va_list *
88 nxsched_get_stackinfo nuttx/sched.h int pid_t FAR struct stackinfo_s *
89 nxsem_tickwait nuttx/semaphore.h int FAR sem_t * uint32_t
90 nxsem_clockwait nuttx/semaphore.h int FAR sem_t * clockid_t FAR const struct timespec *
140 sched_getscheduler sched.h int pid_t
141 sched_lock sched.h void
142 sched_lockcount sched.h int
143 sched_note_vprintf_ip nuttx/sched_note.h defined(CONFIG_SCHED_INSTRUMENTATION_DUMP) void uint32_t uintptr_t FAR const IPTR char * uint32_t
144 sched_rr_get_interval sched.h int pid_t struct timespec *
145 sched_setaffinity sched.h defined(CONFIG_SMP) int pid_t size_t FAR const cpu_set_t*
146 sched_setparam sched.h int pid_t const struct sched_param *