Changeset f0348c8 in mainline for kernel/generic/src/debug/symtab.c


Ignore:
Timestamp:
2012-07-10T13:03:10Z (12 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
97c7682, 9904eb90, ceafd1b, d9812b4, dfc07c1
Parents:
33fc3ae (diff), f4a8734 (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.
Message:

Merge kernel console completion and console interface clean-up

Kernel console completion (#50), thanks Sandeep Kumar

  • tab-completion uses symbol table
  • tab-completion display huge number of hints in user-friendly manner (display all?, more?)

Userspace console interface changes

  • console does not send special keys (arrows etc.) on its VFS interface
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/debug/symtab.c

    r33fc3ae rf0348c8  
    4343#include <typedefs.h>
    4444#include <errno.h>
     45#include <console/prompt.h>
    4546
    4647/** Get name of a symbol that seems most likely to correspond to address.
     
    209210 *
    210211 */
    211 int symtab_compl(char *input, size_t size)
     212int symtab_compl(char *input, size_t size, indev_t * indev)
    212213{
    213214#ifdef CONFIG_SYMTAB
     
    226227        const char *hint;
    227228        char output[MAX_SYMBOL_NAME];
     229        /* Maximum Match Length : Length of longest matching common substring in
     230           case more than one match is found */
     231        size_t max_match_len = size;
     232        size_t max_match_len_tmp = size;
     233        size_t input_len = str_length(input);
     234        char *sym_name;
     235        size_t hints_to_show = MAX_TAB_HINTS - 1;
     236        size_t total_hints_shown = 0;
     237        bool continue_showing_hints = true;
    228238       
    229239        output[0] = 0;
     240
     241        while ((hint = symtab_search_one(name, &pos))) {
     242                ++pos;
     243        }
     244
     245        pos = 0;
    230246       
    231247        while ((hint = symtab_search_one(name, &pos))) {
     
    235251                pos++;
    236252                found++;
     253        }
     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("\n");
     258                continue_showing_hints = console_prompt_display_all_hints(indev, found);
    237259        }
    238260       
     
    241263                pos = 0;
    242264                while (symtab_search_one(name, &pos)) {
    243                         printf("%s\n", symbol_table[pos].symbol_name);
     265                        sym_name = symbol_table[pos].symbol_name;
    244266                        pos++;
     267
     268                        if (continue_showing_hints) { /* We are still showing hints */
     269                                printf("%s\n", sym_name);
     270                                --hints_to_show;
     271                                ++total_hints_shown;
     272
     273                                if (hints_to_show == 0 && total_hints_shown != found) { /* Time to ask user to continue */
     274                                        continue_showing_hints = console_prompt_more_hints(indev, &hints_to_show);
     275                                }
     276                        }
     277
     278                        for(max_match_len_tmp = 0; output[max_match_len_tmp] == sym_name[input_len + max_match_len_tmp]
     279                                        && max_match_len_tmp < max_match_len; ++max_match_len_tmp);
     280                        max_match_len = max_match_len_tmp;
    245281                }
     282                /* keep only the characters common in all completions */
     283                output[max_match_len] = 0;
    246284        }
    247285       
Note: See TracChangeset for help on using the changeset viewer.