Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sched_note: add function auto-tracing #8988

Merged
merged 1 commit into from Apr 10, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions drivers/note/note_driver.c
Expand Up @@ -1987,3 +1987,26 @@ int note_driver_register(FAR struct note_driver_s *driver)

return -ENOMEM;
}

#ifdef CONFIG_SCHED_INSTRUMENTATION_FUNCTION

/****************************************************************************
* Name: __cyg_profile_func_enter
****************************************************************************/

void noinstrument_function
__cyg_profile_func_enter(void *this_fn, void *call_site)
{
sched_note_string_ip(NOTE_TAG_ALWAYS, (uintptr_t)this_fn, "B");
}

/****************************************************************************
* Name: __cyg_profile_func_exit
****************************************************************************/

void noinstrument_function
__cyg_profile_func_exit(void *this_fn, void *call_site)
{
sched_note_string_ip(NOTE_TAG_ALWAYS, (uintptr_t)this_fn, "E");
}
#endif
14 changes: 14 additions & 0 deletions sched/Kconfig
Expand Up @@ -1088,6 +1088,20 @@ config SCHED_INSTRUMENTATION_DUMP
void sched_note_printf(FAR const char *fmt, ...) printf_like(1, 2);
void sched_note_bprintf(uint32_t module, uint8_t event, FAR const char *fmt, ...);

config SCHED_INSTRUMENTATION_FUNCTION
bool "Enable function auto-tracing"
default n
---help---
After enabling this option, you can automatically trace the function instrumentation without adding tracepoint manually.
This is similar to the Function Trace effect of the linux kernel
Add CFLAGS += -finstrument-functions to the makefile to track the required modules.
The following compilation option can exclude files that do not want to be tracked in this module
CFLAGS += -finstrument-functions-exclude-file-list=xxx
The following compilation option can exclude functions that do not want to be tracked in this module
CFLAGS += -finstrument-functions-exclude-function-list=xxx
For a more detailed description of compilation options,
refer to the "Program Instrumentation Options" chapter in the gcc documentation

endif # SCHED_INSTRUMENTATION
endmenu # Performance Monitoring

Expand Down