[f6069801] | 1 | /*
|
---|
| 2 | * Copyright (c) 2009 Jakub Jermar
|
---|
| 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
[d99c1d2] | 29 | /** @addtogroup genericdebug
|
---|
[f6069801] | 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /** @file
|
---|
| 33 | */
|
---|
| 34 |
|
---|
| 35 | #ifndef KERN_STACKTRACE_H_
|
---|
| 36 | #define KERN_STACKTRACE_H_
|
---|
| 37 |
|
---|
| 38 | #include <typedefs.h>
|
---|
| 39 |
|
---|
[da1bafb] | 40 | /* Forward declaration. */
|
---|
[f6069801] | 41 | struct istate;
|
---|
| 42 |
|
---|
| 43 | typedef struct {
|
---|
[257ceb1] | 44 | uintptr_t fp;
|
---|
| 45 | uintptr_t pc;
|
---|
| 46 | struct istate *istate;
|
---|
| 47 | } stack_trace_context_t;
|
---|
| 48 |
|
---|
| 49 | typedef struct {
|
---|
| 50 | bool (* stack_trace_context_validate)(stack_trace_context_t *);
|
---|
| 51 | bool (* frame_pointer_prev)(stack_trace_context_t *, uintptr_t *);
|
---|
| 52 | bool (* return_address_get)(stack_trace_context_t *, uintptr_t *);
|
---|
[a000878c] | 53 | bool (* symbol_resolve)(uintptr_t, const char **, uintptr_t *);
|
---|
[f6069801] | 54 | } stack_trace_ops_t;
|
---|
| 55 |
|
---|
| 56 | extern stack_trace_ops_t kst_ops;
|
---|
| 57 | extern stack_trace_ops_t ust_ops;
|
---|
| 58 |
|
---|
| 59 | extern void stack_trace(void);
|
---|
| 60 | extern void stack_trace_istate(struct istate *);
|
---|
[257ceb1] | 61 | extern void stack_trace_ctx(stack_trace_ops_t *, stack_trace_context_t *);
|
---|
[f6069801] | 62 |
|
---|
| 63 | /*
|
---|
| 64 | * The following interface is to be implemented by each architecture.
|
---|
| 65 | */
|
---|
| 66 | extern uintptr_t frame_pointer_get(void);
|
---|
[d32358f] | 67 | extern uintptr_t program_counter_get(void);
|
---|
[f6069801] | 68 |
|
---|
[257ceb1] | 69 | extern bool kernel_stack_trace_context_validate(stack_trace_context_t *);
|
---|
| 70 | extern bool kernel_frame_pointer_prev(stack_trace_context_t *, uintptr_t *);
|
---|
| 71 | extern bool kernel_return_address_get(stack_trace_context_t *, uintptr_t *);
|
---|
[f6069801] | 72 |
|
---|
[257ceb1] | 73 | extern bool uspace_stack_trace_context_validate(stack_trace_context_t *);
|
---|
| 74 | extern bool uspace_frame_pointer_prev(stack_trace_context_t *, uintptr_t *);
|
---|
| 75 | extern bool uspace_return_address_get(stack_trace_context_t *, uintptr_t *);
|
---|
[f6069801] | 76 |
|
---|
| 77 | #endif
|
---|
| 78 |
|
---|
| 79 | /** @}
|
---|
| 80 | */
|
---|