diff options
| author | Dustin Brown <dustinb@codeaurora.org> | 2017-08-04 17:01:11 -0700 |
|---|---|---|
| committer | snandini <snandini@codeaurora.org> | 2017-08-13 15:47:45 -0700 |
| commit | 04757fbafb189ff1799d3af9e4444c640edd45a5 (patch) | |
| tree | 1e6867bad91cbe714d42290646035cf13ebd5f67 | |
| parent | b3657c7ee10983d3ddaa2393ac4e6d5487385514 (diff) | |
qcacmn: Add qdf_print_thread_trace API
Add an abstraction to QDF for printing the stack trace of a given
thread.
Change-Id: Ibea6e6bed7f3ebe67538b8ea8b6b437b643d5541
CRs-Fixed: 2088806
| -rw-r--r-- | qdf/inc/qdf_threads.h | 13 | ||||
| -rw-r--r-- | qdf/linux/src/i_qdf_threads.h | 29 | ||||
| -rw-r--r-- | qdf/linux/src/qdf_threads.c | 25 |
3 files changed, 66 insertions, 1 deletions
diff --git a/qdf/inc/qdf_threads.h b/qdf/inc/qdf_threads.h index d68166013545..d0a1bed175b7 100644 --- a/qdf/inc/qdf_threads.h +++ b/qdf/inc/qdf_threads.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2016 The Linux Foundation. All rights reserved. + * Copyright (c) 2014-2017 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -34,6 +34,9 @@ #define __QDF_THREADS_H #include <qdf_types.h> +#include "i_qdf_threads.h" + +typedef __qdf_thread_t qdf_thread_t; /* Function declarations and documenation */ @@ -43,4 +46,12 @@ void qdf_sleep_us(uint32_t us_interval); void qdf_busy_wait(uint32_t us_interval); +/** + * qdf_print_stack_trace_thread() - prints the stack trace of the given thread + * @thread: the thread for which the stack trace will be printed + * + * Return: None + */ +void qdf_print_thread_trace(qdf_thread_t *thread); + #endif /* __QDF_THREADS_H */ diff --git a/qdf/linux/src/i_qdf_threads.h b/qdf/linux/src/i_qdf_threads.h new file mode 100644 index 000000000000..16862387f143 --- /dev/null +++ b/qdf/linux/src/i_qdf_threads.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 The Linux Foundation. All rights reserved. + * + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all + * copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/** + * DOC: i_qdf_threads + * Header file for linux-specific thead abstractions + */ + +#if !defined(__I_QDF_THREADS_H) +#define __I_QDF_THREADS_H + +typedef struct task_struct __qdf_thread_t; + +#endif /* __I_QDF_THREADS_H */ diff --git a/qdf/linux/src/qdf_threads.c b/qdf/linux/src/qdf_threads.c index 7cf3e9cc28dc..2eb0c247b342 100644 --- a/qdf/linux/src/qdf_threads.c +++ b/qdf/linux/src/qdf_threads.c @@ -40,6 +40,7 @@ #include <linux/delay.h> #include <linux/interrupt.h> #include <linux/export.h> +#include <stacktrace.h> /* Function declarations and documenation */ @@ -106,3 +107,27 @@ void qdf_busy_wait(uint32_t us_interval) udelay(us_interval); } qdf_export_symbol(qdf_busy_wait); + +#if defined(CONFIG_MCL) && (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)) +/* save_stack_trace_tsk is not generally exported for arm architectures */ +#define QDF_PRINT_TRACE_COUNT 32 +void qdf_print_thread_trace(qdf_thread_t *thread) +{ + const int spaces = 4; + struct task_struct *task = (struct task_struct *)thread; + unsigned long entries[QDF_PRINT_TRACE_COUNT] = {0}; + struct stack_trace trace = { + .nr_entries = 0, + .skip = 0, + .entries = &entries[0], + .max_entries = QDF_PRINT_TRACE_COUNT, + }; + + save_stack_trace_tsk(task, &trace); + print_stack_trace(&trace, spaces); +} +#else +void qdf_print_thread_trace(qdf_thread_t *thread) { } +#endif /* CONFIG_MCL */ +qdf_export_symbol(qdf_print_thread_trace); + |
