Changeset dc5c303 in mainline for kernel/generic/src/debug/stacktrace.c
- Timestamp:
- 2023-12-28T13:59:23Z (14 months ago)
- Children:
- 6b66de6b
- Parents:
- 42c2e65 (diff), f87ff8e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - git-author:
- boba-buba <120932204+boba-buba@…> (2023-12-28 13:59:23)
- git-committer:
- GitHub <noreply@…> (2023-12-28 13:59:23)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/debug/stacktrace.c
r42c2e65 rdc5c303 39 39 #include <stdio.h> 40 40 41 #include <debug/line.h> 42 41 43 #define STACK_FRAMES_MAX 20 42 44 … … 44 46 { 45 47 int cnt = 0; 46 const char *symbol; 47 uintptr_t offset; 48 48 49 uintptr_t fp; 49 50 uintptr_t pc; … … 51 52 while ((cnt++ < STACK_FRAMES_MAX) && 52 53 (ops->stack_trace_context_validate(ctx))) { 54 55 const char *symbol = NULL; 56 uintptr_t symbol_addr = 0; 57 const char *file_name = NULL; 58 const char *dir_name = NULL; 59 int line = 0; 60 int column = 0; 61 62 /* 63 * If this isn't the first frame, move pc back by one byte to read the 64 * position of the call instruction, not the return address. 65 */ 66 pc = cnt == 1 ? ctx->pc : ctx->pc - 1; 67 53 68 if (ops->symbol_resolve && 54 ops->symbol_resolve(ctx->pc, &symbol, &offset)) { 55 if (offset) 56 printf("%p: %s()+%p\n", (void *) ctx->fp, 57 symbol, (void *) offset); 58 else 59 printf("%p: %s()\n", (void *) ctx->fp, symbol); 69 ops->symbol_resolve(pc, 0, &symbol, &symbol_addr, &file_name, &dir_name, &line, &column)) { 70 71 if (symbol == NULL) 72 symbol = "<unknown>"; 73 74 if (file_name == NULL && line == 0) { 75 printf("%p: %24s()+%zu\n", (void *) ctx->fp, symbol, ctx->pc - symbol_addr); 76 } else { 77 if (file_name == NULL) 78 file_name = "<unknown>"; 79 if (dir_name == NULL) 80 dir_name = "<unknown>"; 81 82 printf("%p: %20s()+%zu\t %s/%s:%d:%d\n", 83 (void *) ctx->fp, symbol, ctx->pc - symbol_addr, 84 dir_name, file_name, line, column); 85 } 60 86 } else 61 87 printf("%p: %p()\n", (void *) ctx->fp, (void *) ctx->pc); … … 104 130 105 131 static bool 106 kernel_symbol_resolve(uintptr_t addr, const char **sp, uintptr_t *op) 132 resolve_kernel_address(uintptr_t addr, int op_index, 133 const char **symbol, uintptr_t *symbol_addr, 134 const char **filename, const char **dirname, 135 int *line, int *column) 107 136 { 108 return (symtab_name_lookup(addr, sp, op) == 0); 137 *symbol_addr = 0; 138 *symbol = symtab_name_lookup(addr, symbol_addr, &kernel_sections); 139 140 return debug_line_get_address_info(&kernel_sections, addr, op_index, filename, dirname, line, column) || *symbol_addr != 0; 141 } 142 143 static bool 144 resolve_uspace_address(uintptr_t addr, int op_index, 145 const char **symbol, uintptr_t *symbol_addr, 146 const char **filename, const char **dirname, 147 int *line, int *column) 148 { 149 if (TASK->debug_sections == NULL) 150 return false; 151 152 debug_sections_t *scs = TASK->debug_sections; 153 154 *symbol_addr = 0; 155 *symbol = symtab_name_lookup(addr, symbol_addr, scs); 156 157 return debug_line_get_address_info(scs, addr, op_index, filename, dirname, line, column) || *symbol_addr != 0; 109 158 } 110 159 … … 113 162 .frame_pointer_prev = kernel_frame_pointer_prev, 114 163 .return_address_get = kernel_return_address_get, 115 .symbol_resolve = kernel_symbol_resolve164 .symbol_resolve = resolve_kernel_address, 116 165 }; 117 166 … … 120 169 .frame_pointer_prev = uspace_frame_pointer_prev, 121 170 .return_address_get = uspace_return_address_get, 122 .symbol_resolve = NULL171 .symbol_resolve = resolve_uspace_address, 123 172 }; 124 173
Note:
See TracChangeset
for help on using the changeset viewer.