diff --git a/include/nuttx/kmalloc.h b/include/nuttx/kmalloc.h index 7d1c35b4e8..b22196aaf1 100644 --- a/include/nuttx/kmalloc.h +++ b/include/nuttx/kmalloc.h @@ -100,6 +100,7 @@ extern "C" # define kmm_free(p) free(p) # define kmm_mallinfo() mallinfo() # define kmm_heapmember(p) umm_heapmember(p) +# define kmm_memdump(p) umm_memdump(p) #else /* Otherwise, the kernel-space allocators are declared in diff --git a/include/nuttx/mm/mm.h b/include/nuttx/mm/mm.h index 73a6b2bb2d..2cdd2324a1 100644 --- a/include/nuttx/mm/mm.h +++ b/include/nuttx/mm/mm.h @@ -239,6 +239,12 @@ FAR void *mm_zalloc(FAR struct mm_heap_s *heap, size_t size); FAR void *kmm_zalloc(size_t size); #endif +/* Functions contained in kmm_memdump.c *************************************/ + +#ifdef CONFIG_MM_KERNEL_HEAP +void kmm_memdump(pid_t pid); +#endif + /* Functions contained in mm_memalign.c *************************************/ FAR void *mm_memalign(FAR struct mm_heap_s *heap, size_t alignment, @@ -325,6 +331,10 @@ void mm_checkcorruption(FAR struct mm_heap_s *heap); FAR void umm_checkcorruption(void); +/* Functions contained in umm_memdump.c *************************************/ + +void umm_memdump(pid_t pid); + /* Functions contained in kmm_checkcorruption.c *****************************/ #ifdef CONFIG_MM_KERNEL_HEAP diff --git a/mm/kmm_heap/Make.defs b/mm/kmm_heap/Make.defs index 135832fcc5..254a6b89fe 100644 --- a/mm/kmm_heap/Make.defs +++ b/mm/kmm_heap/Make.defs @@ -25,6 +25,7 @@ ifeq ($(CONFIG_MM_KERNEL_HEAP),y) CSRCS += kmm_initialize.c kmm_addregion.c kmm_malloc_size.c CSRCS += kmm_brkaddr.c kmm_calloc.c kmm_extend.c kmm_free.c kmm_mallinfo.c CSRCS += kmm_malloc.c kmm_memalign.c kmm_realloc.c kmm_zalloc.c kmm_heapmember.c +CSRCS += kmm_memdump.c ifeq ($(CONFIG_DEBUG_MM),y) CSRCS += kmm_checkcorruption.c diff --git a/mm/kmm_heap/kmm_memdump.c b/mm/kmm_heap/kmm_memdump.c new file mode 100644 index 0000000000..e4a0b01998 --- /dev/null +++ b/mm/kmm_heap/kmm_memdump.c @@ -0,0 +1,47 @@ +/**************************************************************************** + * mm/kmm_heap/kmm_memdump.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 +#include + +#ifdef CONFIG_MM_KERNEL_HEAP + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: kmm_memdump + * + * Description: + * Dump the memory block allocated by this task + * + ****************************************************************************/ + +void kmm_memdump(pid_t pid) +{ + mm_memdump(g_kmmheap, pid); +} + +#endif /* CONFIG_MM_KERNEL_HEAP */ diff --git a/mm/umm_heap/Make.defs b/mm/umm_heap/Make.defs index c992160c38..e03b0bdaf8 100644 --- a/mm/umm_heap/Make.defs +++ b/mm/umm_heap/Make.defs @@ -23,6 +23,7 @@ CSRCS += umm_globals.c umm_initialize.c umm_addregion.c umm_malloc_size.c CSRCS += umm_brkaddr.c umm_calloc.c umm_extend.c umm_free.c umm_mallinfo.c CSRCS += umm_malloc.c umm_memalign.c umm_realloc.c umm_zalloc.c umm_heapmember.c +CSRCS += umm_memdump.c ifeq ($(CONFIG_BUILD_KERNEL),y) CSRCS += umm_sbrk.c diff --git a/mm/umm_heap/umm_memdump.c b/mm/umm_heap/umm_memdump.c new file mode 100644 index 0000000000..539b38d0aa --- /dev/null +++ b/mm/umm_heap/umm_memdump.c @@ -0,0 +1,45 @@ +/**************************************************************************** + * mm/umm_heap/umm_memdump.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 +#include + +#include "umm_heap/umm_heap.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: umm_memdump + * + * Description: + * Dump the memory block allocated by this task + * + ****************************************************************************/ + +void umm_memdump(pid_t pid) +{ + mm_memdump(USR_HEAP, pid); +}