Changeset 1e01a35 in mainline
- Timestamp:
- 2012-07-10T12:01:07Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f0d7bd9
- Parents:
- b4ca0a9c
- git-author:
- Sandeep Kumar <> (2012-07-10 12:01:07)
- git-committer:
- Vojtech Horky <vojtechhorky@…> (2012-07-10 12:01:07)
- Location:
- kernel/generic
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/debug.h
rb4ca0a9c r1e01a35 37 37 38 38 #include <panic.h> 39 #include <symtab .h>39 #include <symtab_lookup.h> 40 40 41 41 #define CALLER ((uintptr_t) __builtin_return_address(0)) -
kernel/generic/include/symtab.h
rb4ca0a9c r1e01a35 36 36 #define KERN_SYMTAB_H_ 37 37 38 # include <typedefs.h>38 #define MAX_TAB_HINTS 37 39 39 40 #define MAX_SYMBOL_NAME 64 40 #include <symtab_lookup.h> 41 #include <console/chardev.h> 41 42 42 struct symtab_entry {43 uint64_t address_le;44 char symbol_name[MAX_SYMBOL_NAME];45 };46 47 extern int symtab_name_lookup(uintptr_t, const char **, uintptr_t *);48 extern const char *symtab_fmt_name_lookup(uintptr_t);49 extern int symtab_addr_lookup(const char *, uintptr_t *);50 43 extern void symtab_print_search(const char *); 51 extern int symtab_compl(char *, size_t); 52 53 #ifdef CONFIG_SYMTAB 54 55 /** Symtable linked together by build process 56 * 57 */ 58 extern struct symtab_entry symbol_table[]; 59 60 #endif /* CONFIG_SYMTAB */ 44 extern int symtab_compl(char *, size_t, indev_t *); 61 45 62 46 #endif -
kernel/generic/src/console/kconsole.c
rb4ca0a9c r1e01a35 201 201 * 202 202 */ 203 NO_TRACE static int cmdtab_compl(char *input, size_t size )203 NO_TRACE static int cmdtab_compl(char *input, size_t size, indev_t * indev) 204 204 { 205 205 const char *name = input; 206 206 207 207 size_t found = 0; 208 /* Maximum Match Length : Length of longest matching common substring in 209 case more than one match is found */ 210 size_t max_match_len = size; 211 size_t max_match_len_tmp = size; 212 size_t input_len = str_length(input); 208 213 link_t *pos = NULL; 209 214 const char *hint; 210 215 char *output = malloc(MAX_CMDLINE, 0); 216 char display = 'y'; 217 size_t hints_to_show = MAX_TAB_HINTS - 1; 218 size_t total_hints_shown = 0; 219 char continue_showing_hints = 'y'; 211 220 212 221 output[0] = 0; … … 218 227 pos = pos->next; 219 228 found++; 229 } 230 231 /* If possible completions are more than MAX_TAB_HINTS, ask user whether to display them or not. */ 232 if (found > MAX_TAB_HINTS) { 233 printf("\nDisplay all %zu possibilities? (y or n)", found); 234 do { 235 display = indev_pop_character(indev); 236 } while (display != 'y' && display != 'n' && display != 'Y' && display != 'N'); 220 237 } 221 238 … … 225 242 while (cmdtab_search_one(name, &pos)) { 226 243 cmd_info_t *hlp = list_get_instance(pos, cmd_info_t, link); 227 printf("%s (%s)\n", hlp->name, hlp->description); 244 245 if (display == 'y' || display == 'Y') { /* We are still showing hints */ 246 printf("%s (%s)\n", hlp->name, hlp->description); 247 --hints_to_show; 248 ++total_hints_shown; 249 250 if (hints_to_show == 0 && total_hints_shown != found) { /* Time to ask user to continue */ 251 printf("--More--"); 252 do { 253 continue_showing_hints = indev_pop_character(indev); 254 if (continue_showing_hints == 'y' || continue_showing_hints == 'Y' 255 || continue_showing_hints == ' ') { 256 hints_to_show = MAX_TAB_HINTS - 1; /* Display a full page again */ 257 break; 258 } 259 260 if (continue_showing_hints == 'n' || continue_showing_hints == 'N' 261 || continue_showing_hints == 'q' || continue_showing_hints == 'Q') { 262 display = 'n'; /* Stop displaying hints */ 263 break; 264 } 265 266 if (continue_showing_hints == '\n') { 267 hints_to_show = 1; /* Show one more hint */ 268 break; 269 } 270 } while (1); 271 272 printf("\r \r"); /* Delete the --More-- option */ 273 } 274 } 275 228 276 pos = pos->next; 229 } 277 for(max_match_len_tmp = 0; output[max_match_len_tmp] == hlp->name[input_len + max_match_len_tmp] 278 && max_match_len_tmp < max_match_len; ++max_match_len_tmp); 279 max_match_len = max_match_len_tmp; 280 } 281 /* keep only the characters common in all completions */ 282 output[max_match_len] = 0; 230 283 } 231 284 … … 294 347 if (beg == 0) { 295 348 /* Command completion */ 296 found = cmdtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE) );349 found = cmdtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE), indev); 297 350 } else { 298 351 /* Symbol completion */ 299 found = symtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE) );352 found = symtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE), indev); 300 353 } 301 354 302 355 if (found == 0) 303 356 continue; 304 305 if (found > 1) { 306 /* No unique hint, list was printed */ 307 printf("%s> ", prompt); 308 printf("%ls", current); 309 print_cc('\b', wstr_length(current) - position); 310 continue; 311 } 312 313 /* We have a hint */ 314 357 358 /* We have hints, may be many. In case of more than one hint, 359 tmp will contain the common prefix. */ 315 360 size_t off = 0; 316 361 size_t i = 0; … … 320 365 i++; 321 366 } 367 368 if (found > 1) { 369 /* No unique hint, list was printed */ 370 printf("%s> ", prompt); 371 printf("%ls", current); 372 position += str_length(tmp); 373 print_cc('\b', wstr_length(current) - position); 374 continue; 375 } 376 377 /* We have a hint */ 322 378 323 379 printf("%ls", current + position); … … 540 596 /** Parse command line. 541 597 * 542 * @param cmdline Command line as read from input device. 598 * @param cmdline Command line as read from input device. 543 599 * @param size Size (in bytes) of the string. 544 600 * -
kernel/generic/src/debug/symtab.c
rb4ca0a9c r1e01a35 209 209 * 210 210 */ 211 int symtab_compl(char *input, size_t size )211 int symtab_compl(char *input, size_t size, indev_t * indev) 212 212 { 213 213 #ifdef CONFIG_SYMTAB … … 226 226 const char *hint; 227 227 char output[MAX_SYMBOL_NAME]; 228 /* Maximum Match Length : Length of longest matching common substring in 229 case more than one match is found */ 230 size_t max_match_len = size; 231 size_t max_match_len_tmp = size; 232 size_t input_len = str_length(input); 233 char *sym_name; 234 char display = 'y'; 235 size_t hints_to_show = MAX_TAB_HINTS - 1; 236 size_t total_hints_shown = 0; 237 char continue_showing_hints = 'y'; 228 238 229 239 output[0] = 0; 240 241 while ((hint = symtab_search_one(name, &pos))) { 242 ++pos; 243 } 244 245 pos = 0; 230 246 231 247 while ((hint = symtab_search_one(name, &pos))) { … … 237 253 } 238 254 255 /* If possible completions are more than MAX_TAB_HINTS, ask user whether to display them or not. */ 256 if (found > MAX_TAB_HINTS) { 257 printf("\nDisplay all %zu possibilities? (y or n)", found); 258 do { 259 display = indev_pop_character(indev); 260 } while (display != 'y' && display != 'n' && display != 'Y' && display != 'N'); 261 } 262 239 263 if ((found > 1) && (str_length(output) != 0)) { 240 264 printf("\n"); 241 265 pos = 0; 242 266 while (symtab_search_one(name, &pos)) { 243 printf("%s\n", symbol_table[pos].symbol_name);267 sym_name = symbol_table[pos].symbol_name; 244 268 pos++; 269 270 if (display == 'y' || display == 'Y') { /* We are still showing hints */ 271 printf("%s\n", sym_name); 272 --hints_to_show; 273 ++total_hints_shown; 274 275 if (hints_to_show == 0 && total_hints_shown != found) { /* Time to ask user to continue */ 276 printf("--More--"); 277 do { 278 continue_showing_hints = indev_pop_character(indev); 279 if (continue_showing_hints == 'y' || continue_showing_hints == 'Y' 280 || continue_showing_hints == ' ') { 281 hints_to_show = MAX_TAB_HINTS - 1; /* Display a full page again */ 282 break; 283 } 284 285 if (continue_showing_hints == 'n' || continue_showing_hints == 'N' 286 || continue_showing_hints == 'q' || continue_showing_hints == 'Q') { 287 display = 'n'; /* Stop displaying hints */ 288 break; 289 } 290 291 if (continue_showing_hints == '\n') { 292 hints_to_show = 1; /* Show one more hint */ 293 break; 294 } 295 } while (1); 296 297 printf("\r \r"); /* Delete the --More-- option */ 298 } 299 } 300 301 for(max_match_len_tmp = 0; output[max_match_len_tmp] == sym_name[input_len + max_match_len_tmp] 302 && max_match_len_tmp < max_match_len; ++max_match_len_tmp); 303 max_match_len = max_match_len_tmp; 245 304 } 305 /* keep only the characters common in all completions */ 306 output[max_match_len] = 0; 246 307 } 247 308
Note:
See TracChangeset
for help on using the changeset viewer.