Changeset e16e0d59 in mainline for kernel/generic/src/debug/symtab.c
- Timestamp:
- 2009-03-17T20:33:18Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5eb90cb
- Parents:
- b1c8dc0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/debug/symtab.c
rb1c8dc0 re16e0d59 42 42 #include <arch/types.h> 43 43 #include <typedefs.h> 44 45 /** Return entry that seems most likely to correspond to argument. 46 * 47 * Return entry that seems most likely to correspond 48 * to address passed in the argument. 49 * 50 * @param addr Address. 51 * 52 * @return Pointer to respective symbol string on success, NULL otherwise. 53 */ 54 char * get_symtab_entry(unative_t addr) 55 { 44 #include <errno.h> 45 46 /** Get name of symbol that seems most likely to correspond to address. 47 * 48 * @param addr Address. 49 * @param name Place to store pointer to the symbol name. 50 * 51 * @return Zero on success or negative error code, ENOENT if not found, 52 * ENOTSUP if symbol table not available. 53 */ 54 int symtab_name_lookup(unative_t addr, char **name) 55 { 56 #ifdef CONFIG_SYMTAB 56 57 count_t i; 57 58 … … 60 61 break; 61 62 } 62 if (addr >= uint64_t_le2host(symbol_table[i - 1].address_le)) 63 return symbol_table[i - 1].symbol_name; 64 return NULL; 65 } 63 if (addr >= uint64_t_le2host(symbol_table[i - 1].address_le)) { 64 *name = symbol_table[i - 1].symbol_name; 65 return EOK; 66 } 67 68 *name = NULL; 69 return ENOENT; 70 #else 71 *name = NULL; 72 return ENOTSUP; 73 #endif 74 } 75 76 /** Lookup symbol by address and format for display. 77 * 78 * Returns name of closest corresponding symbol, "Not found" if none exists 79 * or "N/A" if no symbol information is available. 80 * 81 * @param addr Address. 82 * @param name Place to store pointer to the symbol name. 83 * 84 * @return Pointer to a human-readable string. 85 */ 86 char *symtab_fmt_name_lookup(unative_t addr) 87 { 88 int rc; 89 char *name; 90 91 rc = symtab_name_lookup(addr, &name); 92 switch (rc) { 93 case EOK: return name; 94 case ENOENT: return "Not found"; 95 default: return "N/A"; 96 } 97 } 98 99 #ifdef CONFIG_SYMTAB 66 100 67 101 /** Find symbols that match the parameter forward and print them. … … 103 137 } 104 138 139 #endif 140 105 141 /** Return address that corresponds to the entry 106 142 * 107 143 * Search symbol table, and if there is one match, return it 108 144 * 109 * @param name Name of the symbol 110 * @return 0 - Not found, -1 - Duplicate symbol, other - address of symbol 111 */ 112 uintptr_t get_symbol_addr(const char *name) 113 { 145 * @param name Name of the symbol 146 * @param addr Place to store symbol address 147 * 148 * @return Zero on success, ENOENT - not found, EOVERFLOW - duplicate 149 * symbol, ENOTSUP - no symbol information available. 150 */ 151 int symtab_addr_lookup(const char *name, uintptr_t *addr) 152 { 153 #ifdef CONFIG_SYMTAB 114 154 count_t found = 0; 115 uintptr_t addr = NULL;116 155 char *hint; 117 156 int i; … … 120 159 while ((hint = symtab_search_one(name, &i))) { 121 160 if (!strlen(hint)) { 122 addr = uint64_t_le2host(symbol_table[i].address_le);161 *addr = uint64_t_le2host(symbol_table[i].address_le); 123 162 found++; 124 163 } … … 126 165 } 127 166 if (found > 1) 128 return ((uintptr_t) -1); 129 return addr; 167 return EOVERFLOW; 168 if (found < 1) 169 return ENOENT; 170 return EOK; 171 #else 172 return ENOTSUP; 173 #endif 130 174 } 131 175 … … 133 177 void symtab_print_search(const char *name) 134 178 { 179 #ifdef CONFIG_SYMTAB 135 180 int i; 136 181 uintptr_t addr; … … 145 190 i++; 146 191 } 192 #else 193 printf("No symbol information available.\n"); 194 #endif 147 195 } 148 196 … … 154 202 int symtab_compl(char *input) 155 203 { 204 #ifdef CONFIG_SYMTAB 156 205 char output[MAX_SYMBOL_NAME + 1]; 157 206 int startpos = 0; … … 197 246 strncpy(input, output, MAX_SYMBOL_NAME); 198 247 return found; 199 248 #else 249 return 0; 250 #endif 200 251 } 201 252
Note:
See TracChangeset
for help on using the changeset viewer.