The following patch adds a new user-visible variable to GDB, 'max-completion-results'. It is used by the completion functions in symtab.c to limit the maximum number of results returned by the completion function, and defaults to 'unlimited'. I find it particuarly useful when using GDB under emacs, to prevent situations where hitting at the wrong time can lead to hundreds of thousands of results having to be sorted by complete_command.