system/dumpstack: add dump stack tool support
Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
parent
4109f0e8ba
commit
72abd300e6
26
system/dumpstack/Kconfig
Normal file
26
system/dumpstack/Kconfig
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#
|
||||||
|
# For a description of the syntax of this configuration file,
|
||||||
|
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||||
|
#
|
||||||
|
|
||||||
|
menuconfig SYSTEM_DUMPSTACK
|
||||||
|
tristate "dumpstack tool for show the task backtrace"
|
||||||
|
default n
|
||||||
|
depends on SCHED_BACKTRACE
|
||||||
|
---help---
|
||||||
|
|
||||||
|
if SYSTEM_DUMPSTACK
|
||||||
|
|
||||||
|
config SYSTEM_DUMPSTACK_STACKSIZE
|
||||||
|
int "dumpstack stack size"
|
||||||
|
default DEFAULT_TASK_STACKSIZE
|
||||||
|
---help---
|
||||||
|
This is the stack size that will be used when starting the dumpstack.
|
||||||
|
|
||||||
|
config SYSTEM_DUMPSTACK_PRIORITY
|
||||||
|
int "dumpstack priority"
|
||||||
|
default 100
|
||||||
|
---help---
|
||||||
|
This is the task priority that will be used when starting the dumpstack.
|
||||||
|
|
||||||
|
endif # SYSTEM_DUMPSTACK
|
23
system/dumpstack/Make.defs
Normal file
23
system/dumpstack/Make.defs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
############################################################################
|
||||||
|
# system/dumpstack/Make.defs
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
ifneq ($(CONFIG_SYSTEM_DUMPSTACK),)
|
||||||
|
CONFIGURED_APPS += $(APPDIR)/system/dumpstack
|
||||||
|
endif
|
30
system/dumpstack/Makefile
Normal file
30
system/dumpstack/Makefile
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
############################################################################
|
||||||
|
# system/dumpstack/Makefile
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
include $(APPDIR)/Make.defs
|
||||||
|
|
||||||
|
MAINSRC = dumpstack.c
|
||||||
|
|
||||||
|
PROGNAME = dumpstack
|
||||||
|
PRIORITY = $(CONFIG_SYSTEM_DUMPSTACK_PRIORITY)
|
||||||
|
STACKSIZE = $(CONFIG_SYSTEM_DUMPSTACK_STACKSIZE)
|
||||||
|
MODULE = $(CONFIG_SYSTEM_DUMPSTACK)
|
||||||
|
|
||||||
|
include $(APPDIR)/Application.mk
|
70
system/dumpstack/dumpstack.c
Normal file
70
system/dumpstack/dumpstack.c
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* apps/system/dumpstack/dumpstack.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 <sys/types.h>
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <syslog.h>
|
||||||
|
|
||||||
|
#include <execinfo.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* hello_main
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int main(int argc, FAR char *argv[])
|
||||||
|
{
|
||||||
|
int spid = -1;
|
||||||
|
int epid = -1;
|
||||||
|
|
||||||
|
if (argc == 2)
|
||||||
|
{
|
||||||
|
spid = epid = atoi(argv[1]);
|
||||||
|
}
|
||||||
|
else if (argc >= 3)
|
||||||
|
{
|
||||||
|
spid = atoi(argv[1]);
|
||||||
|
epid = atoi(argv[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (spid < 0 || epid < 0)
|
||||||
|
{
|
||||||
|
spid = epid = gettid();
|
||||||
|
}
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
sched_dumpstack(spid);
|
||||||
|
}
|
||||||
|
while (spid++ != epid);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user