Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d4b3754
noteram:overflow may discard all the trace message
Mar 20, 2024
6a1aaf4
note: add ringbuffer aligned access handle
Gary-Hobson Nov 13, 2023
1247743
noteram:read noteram may cause crash
Mar 20, 2024
cfbd57a
ramlog:flush should reset the tail of the reader
Mar 25, 2024
1e98e7a
task: use get_task_name where possible
XuNeo Aug 28, 2024
5f932ca
add mm_uninitialize empty implementation for sim
lion2tomato Jun 11, 2024
b74ee40
note: add memory tracing event support
Gary-Hobson Nov 14, 2023
cca2415
mm: fix memory statistics error
Gary-Hobson Nov 14, 2023
fc68bf3
sched/note: specify note event for heap instrumentation
XuNeo Jul 9, 2024
83856ba
sched/note: add note when mm add new region
XuNeo Jul 3, 2024
e2bbfb9
drivers/noteram: fix compile error
XuNeo Jul 10, 2024
8b00736
drivers/segger: add heap note support
XuNeo Jul 6, 2024
a7a712e
drivers/segger: upgrade segger to v356
XuNeo Oct 6, 2024
b71b69a
drivers/segger: add heap data plot
XuNeo Aug 28, 2024
5e73b00
Documentation: add segger sysview heap trace example
XuNeo Oct 6, 2024
4df3ff4
sched/note: add note for wdog module
XuNeo Jul 9, 2024
fc048c1
sched/note: add wdog note for segger sysview
XuNeo Jul 9, 2024
81ae540
boards/arm/stm32/stm32f429i-disco: use serial console by default
XuNeo Oct 8, 2024
99f3252
note: change sched_note_counter to a macro
Gary-Hobson Nov 20, 2023
c33e78e
gote: implement asynchronous printf formatting
Gary-Hobson Nov 24, 2023
e1947b2
note: print without relying on format strings
Gary-Hobson Nov 29, 2023
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
13 changes: 12 additions & 1 deletion Documentation/components/drivers/special/segger.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Supported Segger drivers:
Segger SystemView
=================

Steps to enable SystemView support:
1. Steps to enable SystemView support:

#. Make sure your architecture supports a high-performance counter.
In most cases it will be:
Expand Down Expand Up @@ -62,3 +62,14 @@ Steps to enable SystemView support:

In case SystemView returns buffer overflow errors, you should increase
``CONFIG_NOTE_RTT_BUFFER_SIZE_UP``.

2. Use SystemView for heap tracing:

Refer to example configuration at ``stm32f429i-disco/configs/systemview``.
Make sure that ``CONFIG_SCHED_INSTRUMENTATION_HEAP`` is enabled.

Example of screenshot from SystemView:

.. image:: sysview.png
:width: 800px
:align: center
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 11 additions & 13 deletions arch/arm/include/cxd56xx/crashdump.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,17 @@ typedef enum

typedef struct
{
struct timespec ts; /* timestamp */
fault_flags_t flags; /* What is in the dump */
uintptr_t current_regs; /* Used to validate the dump */
int lineno; /* __LINE__ to up_assert */
pid_t pid; /* Process ID */
uint32_t regs[XCPTCONTEXT_REGS]; /* Interrupt register save area */
crash_stack_t stacks; /* Stack info */
#if CONFIG_TASK_NAME_SIZE > 0
char name[CONFIG_TASK_NAME_SIZE + 1]; /* Task name (with NULL
* terminator) */
#endif
char filename[MAX_FILE_PATH_LENGTH]; /* the Last of chars in
* __FILE__ to up_assert */
struct timespec ts; /* timestamp */
fault_flags_t flags; /* What is in the dump */
uintptr_t current_regs; /* Used to validate the dump */
int lineno; /* __LINE__ to up_assert */
pid_t pid; /* Process ID */
uint32_t regs[XCPTCONTEXT_REGS]; /* Interrupt register save area */
crash_stack_t stacks; /* Stack info */
char name[CONFIG_TASK_NAME_SIZE + 1]; /* Task name (with NULL
* terminator) */
char filename[MAX_FILE_PATH_LENGTH]; /* the Last of chars in
* __FILE__ to up_assert */
} info_t;

typedef struct
Expand Down
13 changes: 3 additions & 10 deletions arch/risc-v/src/bl602/bl602_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,28 +99,21 @@ __cyg_profile_func_enter(void *this_fn, void *call_site)

if (sp < stack_base)
{
#if CONFIG_TASK_NAME_SIZE > 0
struct tcb_s *rtcb;
#endif

__asm volatile("csrc mstatus, 8");
__asm__("li s11, 0");

#if CONFIG_TASK_NAME_SIZE > 0
/* get current task */

rtcb = running_task();

syslog(LOG_EMERG,
"task %s stack overflow detected! base:0x%x >= sp:0x%x\n",
rtcb->name,
stack_base,
sp);
#else
syslog(LOG_EMERG,
"stack overflow detected! base:0x%x >= sp:0x%x\n",
get_task_name(rtcb),
stack_base,
sp);
#endif

/* PANIC(); */

while (1)
Expand Down
7 changes: 2 additions & 5 deletions arch/risc-v/src/common/riscv_exception.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,8 @@ int riscv_exception(int mcause, void *regs, void *args)
#ifdef CONFIG_ARCH_KERNEL_STACK
if ((tcb->flags & TCB_FLAG_TTYPE_MASK) != TCB_FLAG_TTYPE_KERNEL)
{
# if CONFIG_TASK_NAME_SIZE > 0
_alert("Segmentation fault in PID %d: %s\n", tcb->pid, tcb->name);
# else
_alert("Segmentation fault in PID %d\n", tcb->pid);
# endif
_alert("Segmentation fault in PID %d: %s\n",
tcb->pid, get_task_name(tcb));

tcb->flags |= TCB_FLAG_FORCED_CANCEL;

Expand Down
44 changes: 43 additions & 1 deletion arch/sim/src/sim/sim_heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <nuttx/atomic.h>
#include <nuttx/fs/procfs.h>
#include <nuttx/mm/mm.h>
#include <nuttx/sched_note.h>

#include "sim_internal.h"

Expand Down Expand Up @@ -185,6 +186,7 @@ static void mm_delayfree(struct mm_heap_s *heap, void *mem, bool delay)
int size = host_mallocsize(mem);
atomic_fetch_sub(&heap->aordblks, 1);
atomic_fetch_sub(&heap->uordblks, size);
sched_note_heap(NOTE_HEAP_FREE, heap, mem, size, 0);
host_free(mem);
}
}
Expand Down Expand Up @@ -228,9 +230,37 @@ struct mm_heap_s *mm_initialize(const char *name,
procfs_register_meminfo(&heap->mm_procfs);
#endif

sched_note_heap(NOTE_HEAP_ADD, heap, heap_start, heap_size, 0);
return heap;
}

/****************************************************************************
* Name: mm_uninitialize
*
* Description:
* Uninitialize the selected heap data structures
*
* Input Parameters:
* heap - The selected heap
*
* Returned Value:
* None
*
* Assumptions:
*
****************************************************************************/

void mm_uninitialize(struct mm_heap_s *heap)
{
sched_note_heap(NOTE_HEAP_REMOVE, heap, NULL, 0, 0);

#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MEMINFO)
procfs_unregister_meminfo(&heap->mm_procfs);
#endif
mm_free_delaylist(heap);
host_free(heap);
}

/****************************************************************************
* Name: mm_addregion
*
Expand Down Expand Up @@ -339,6 +369,7 @@ void *mm_realloc(struct mm_heap_s *heap, void *oldmem,
int uordblks;
int usmblks;
int newsize;
int oldsize;

free_delaylist(heap, false);

Expand All @@ -348,13 +379,23 @@ void *mm_realloc(struct mm_heap_s *heap, void *oldmem,
return NULL;
}

atomic_fetch_sub(&heap->uordblks, host_mallocsize(oldmem));
oldsize = host_mallocsize(oldmem);
atomic_fetch_sub(&heap->uordblks, oldsize);
mem = host_realloc(oldmem, size);

atomic_fetch_add(&heap->aordblks, oldmem == NULL && mem != NULL);
newsize = host_mallocsize(mem ? mem : oldmem);
atomic_fetch_add(&heap->uordblks, newsize);
usmblks = atomic_load(&heap->usmblks);
if (mem != NULL)
{
if (oldmem != NULL)
{
sched_note_heap(NOTE_HEAP_FREE, heap, oldmem, oldsize, 0);
}

sched_note_heap(NOTE_HEAP_ALLOC, heap, mem, newsize, 0);
}

do
{
Expand Down Expand Up @@ -445,6 +486,7 @@ void *mm_memalign(struct mm_heap_s *heap, size_t alignment, size_t size)
}

size = host_mallocsize(mem);
sched_note_heap(NOTE_HEAP_ALLOC, heap, mem, size, 0);
atomic_fetch_add(&heap->aordblks, 1);
atomic_fetch_add(&heap->uordblks, size);
usmblks = atomic_load(&heap->usmblks);
Expand Down
13 changes: 3 additions & 10 deletions arch/xtensa/src/common/xtensa_assert.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,8 @@ void xtensa_panic(int xptcode, uint32_t *regs)

syslog_flush();

#if CONFIG_TASK_NAME_SIZE > 0
_alert("Unhandled Exception %d task: %s\n", xptcode, running_task()->name);
#else
_alert("Unhandled Exception %d\n", xptcode);
#endif
_alert("Unhandled Exception %d task: %s\n", xptcode,
get_task_name(running_task()));

PANIC_WITH_REGS("panic", regs); /* Should not return */
for (; ; );
Expand Down Expand Up @@ -177,12 +174,8 @@ void xtensa_user_panic(int exccause, uint32_t *regs)

syslog_flush();

#if CONFIG_TASK_NAME_SIZE > 0
_alert("User Exception: EXCCAUSE=%04x task: %s\n",
exccause, running_task()->name);
#else
_alert("User Exception: EXCCAUSE=%04x\n", exccause);
#endif
exccause, get_task_name(running_task()));

PANIC_WITH_REGS("user panic", regs); /* Should not return */
for (; ; );
Expand Down
4 changes: 2 additions & 2 deletions binfmt/libelf/libelf_coredump.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,11 @@ static void elf_emit_tcb_note(FAR struct elf_dumpinfo_s *cinfo,

elf_emit(cinfo, &nhdr, sizeof(nhdr));

strlcpy(name, tcb->name, sizeof(name));
strlcpy(name, get_task_name(tcb), sizeof(name));
elf_emit(cinfo, name, sizeof(name));

info.pr_pid = tcb->pid;
strlcpy(info.pr_fname, tcb->name, sizeof(info.pr_fname));
strlcpy(info.pr_fname, get_task_name(tcb), sizeof(info.pr_fname));
elf_emit(cinfo, &info, sizeof(info));

/* Fill Process status */
Expand Down
4 changes: 1 addition & 3 deletions boards/arm/cxd56xx/common/src/cxd56_crashdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,7 @@ void board_crashdump(uintptr_t sp, struct tcb_s *tcb,

/* Save Context */

#if CONFIG_TASK_NAME_SIZE > 0
strlcpy(pdump->info.name, tcb->name, sizeof(pdump->info.name));
#endif
strlcpy(pdump->info.name, get_task_name(tcb), sizeof(pdump->info.name));

pdump->info.pid = tcb->pid;

Expand Down
26 changes: 11 additions & 15 deletions boards/arm/stm32/nucleo-f429zi/src/stm32_bbsram.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,18 +232,16 @@ typedef enum

typedef struct
{
fault_flags_t flags; /* What is in the dump */
uintptr_t current_regs; /* Used to validate the dump */
int lineno; /* __LINE__ to up_assert */
pid_t pid; /* Process ID */
uint32_t regs[XCPTCONTEXT_REGS]; /* Interrupt register save area */
stacks_t stacks; /* Stack info */
#if CONFIG_TASK_NAME_SIZE > 0
char name[CONFIG_TASK_NAME_SIZE + 1]; /* Task name (with NULL
* terminator) */
#endif
char filename[MAX_FILE_PATH_LENGTH]; /* the Last of chars in
* __FILE__ to up_assert */
fault_flags_t flags; /* What is in the dump */
uintptr_t current_regs; /* Used to validate the dump */
int lineno; /* __LINE__ to up_assert */
pid_t pid; /* Process ID */
uint32_t regs[XCPTCONTEXT_REGS]; /* Interrupt register save area */
stack_t stacks; /* Stack info */
char name[CONFIG_TASK_NAME_SIZE + 1]; /* Task name (with NULL
* terminator) */
char filename[MAX_FILE_PATH_LENGTH]; /* the Last of chars in
* __FILE__ to up_assert */
} info_t;

typedef struct
Expand Down Expand Up @@ -420,9 +418,7 @@ void board_crashdump(uintptr_t sp, struct tcb_s *tcb,

/* Save Context */

#if CONFIG_TASK_NAME_SIZE > 0
strlcpy(pdump->info.name, tcb->name, sizeof(pdump->info.name));
#endif
strlcpy(pdump->info.name, get_task_name(tcb), sizeof(pdump->info.name));

pdump->info.pid = tcb->pid;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#
# CONFIG_ARCH_FPU is not set
# CONFIG_DRIVERS_NOTERAM is not set
# CONFIG_SERIAL_RTT_CONSOLE is not set
# CONFIG_STANDARD_SERIAL is not set
# CONFIG_STM32_FLASH_PREFETCH is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="stm32f429i-disco"
Expand Down Expand Up @@ -38,8 +40,10 @@ CONFIG_RAM_START=0x20000000
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_INSTRUMENTATION=y
CONFIG_SCHED_INSTRUMENTATION_HEAP=y
CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER=y
CONFIG_SCHED_INSTRUMENTATION_SWITCH=y
CONFIG_SCHED_INSTRUMENTATION_WDOG=y
CONFIG_SEGGER_SYSVIEW=y
CONFIG_SERIAL_RTT0=y
CONFIG_SPI=y
Expand All @@ -51,8 +55,10 @@ CONFIG_STM32_EXTERNAL_RAM=y
CONFIG_STM32_FMC=y
CONFIG_STM32_JTAG_SW_ENABLE=y
CONFIG_STM32_PWR=y
CONFIG_STM32_USART1=y
CONFIG_SYSLOG_CHAR=y
CONFIG_SYSLOG_RTT=y
CONFIG_SYSTEM_NSH=y
CONFIG_SYSTEM_SYSTEM=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USART1_SERIAL_CONSOLE=y
26 changes: 11 additions & 15 deletions boards/arm/stm32f7/nucleo-144/src/stm32_bbsram.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,18 +232,16 @@ typedef enum

typedef struct
{
fault_flags_t flags; /* What is in the dump */
uintptr_t current_regs; /* Used to validate the dump */
int lineno; /* __LINE__ to up_assert */
int pid; /* Process ID */
uint32_t regs[XCPTCONTEXT_REGS]; /* Interrupt register save area */
stacks_t stacks; /* Stack info */
#if CONFIG_TASK_NAME_SIZE > 0
char name[CONFIG_TASK_NAME_SIZE + 1]; /* Task name (with NULL
* terminator) */
#endif
char filename[MAX_FILE_PATH_LENGTH]; /* the Last of chars in
* __FILE__ to up_assert */
fault_flags_t flags; /* What is in the dump */
uintptr_t current_regs; /* Used to validate the dump */
int lineno; /* __LINE__ to up_assert */
int pid; /* Process ID */
uint32_t regs[XCPTCONTEXT_REGS]; /* Interrupt register save area */
stack_t stacks; /* Stack info */
char name[CONFIG_TASK_NAME_SIZE + 1]; /* Task name (with NULL
* terminator) */
char filename[MAX_FILE_PATH_LENGTH]; /* the Last of chars in
* __FILE__ to up_assert */
} info_t;

typedef struct
Expand Down Expand Up @@ -420,9 +418,7 @@ void board_crashdump(uintptr_t sp, struct tcb_s *tcb,

/* Save Context */

#if CONFIG_TASK_NAME_SIZE > 0
strlcpy(pdump->info.name, tcb->name, sizeof(pdump->info.name));
#endif
strlcpy(pdump->info.name, get_task_name(tcb), sizeof(pdump->info.name));

pdump->info.pid = tcb->pid;

Expand Down
26 changes: 11 additions & 15 deletions boards/renesas/rx65n/rx65n-grrose/src/rx65n_sbram.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,16 @@ typedef enum

typedef struct
{
fault_flags_t flags; /* What is in the dump */
uintptr_t current_regs; /* Used to validate the dump */
int lineno; /* __LINE__ to up_assert */
pid_t pid; /* Process ID */
uint32_t regs[XCPTCONTEXT_REGS]; /* Interrupt register save area */
stack_t stacks; /* Stack info */
#if CONFIG_TASK_NAME_SIZE > 0
char name[CONFIG_TASK_NAME_SIZE + 1]; /* Task name (with NULL
* terminator) */
#endif
char filename[MAX_FILE_PATH_LENGTH]; /* the Last of chars in
* __FILE__ to up_assert */
fault_flags_t flags; /* What is in the dump */
uintptr_t current_regs; /* Used to validate the dump */
int lineno; /* __LINE__ to up_assert */
pid_t pid; /* Process ID */
uint32_t regs[XCPTCONTEXT_REGS]; /* Interrupt register save area */
stack_t stacks; /* Stack info */
char name[CONFIG_TASK_NAME_SIZE + 1]; /* Task name (with NULL
* terminator) */
char filename[MAX_FILE_PATH_LENGTH]; /* the Last of chars in
* __FILE__ to up_assert */
} info_t;

struct fullcontext
Expand Down Expand Up @@ -374,9 +372,7 @@ void board_crashdump(uintptr_t sp, struct tcb_s *tcb,

/* Save Context */

#if CONFIG_TASK_NAME_SIZE > 0
strlcpy(pdump->info.name, tcb->name, sizeof(pdump->info.name));
#endif
strlcpy(pdump->info.name, get_task_name(tcb), sizeof(pdump->info.name));

pdump->info.pid = tcb->pid;

Expand Down
Loading