GDB (xrefs)
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Enumerations | Functions | Variables
completer.c File Reference
#include "defs.h"
#include "symtab.h"
#include "gdbtypes.h"
#include "expression.h"
#include "filenames.h"
#include "language.h"
#include "gdbsupport/gdb_signals.h"
#include "target.h"
#include "reggroups.h"
#include "user-regs.h"
#include "arch-utils.h"
#include "location.h"
#include <algorithm>
#include "linespec.h"
#include "cli/cli-decode.h"
#include "gdbcmd.h"
#include "readline/readline.h"
#include "completer.h"

Go to the source code of this file.

Classes

class  completion_tracker::completion_hash_entry
 
struct  gdb_completer_state
 
struct  gdb_rl_completion_word_info
 

Macros

#define INITIAL_COMPLETION_HTAB_SIZE   200
 
#define ELLIPSIS_LEN   3
 

Typedefs

typedef int QSFUNC(const void *, const void *)
 

Enumerations

enum  explicit_location_match_type {
  MATCH_SOURCE , MATCH_FUNCTION , MATCH_QUALIFIED , MATCH_LINE ,
  MATCH_LABEL
}
 
enum  complete_line_internal_reason { handle_brkchars , handle_completions , handle_help }
 
enum  reg_completer_target { complete_register_names = 0x1 , complete_reggroup_names = 0x2 }
 

Functions

const char * get_gdb_completer_quote_characters (void)
 
void noop_completer (struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *prefix)
 
void filename_completer (struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
 
static void filename_completer_handle_brkchars (struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
 
static const char * gdb_rl_find_completion_word (struct gdb_rl_completion_word_info *info, int *qc, int *dp, const char *line_buffer)
 
static const char * advance_to_completion_word (completion_tracker &tracker, const char *word_break_characters, const char *text)
 
const char * advance_to_expression_complete_word_point (completion_tracker &tracker, const char *text)
 
const char * advance_to_filename_complete_word_point (completion_tracker &tracker, const char *text)
 
void complete_nested_command_line (completion_tracker &tracker, const char *text)
 
static void complete_files_symbols (completion_tracker &tracker, const char *text, const char *word)
 
completion_list complete_source_filenames (const char *text)
 
static void complete_address_and_linespec_locations (completion_tracker &tracker, const char *text, symbol_name_match_type match_type)
 
static const char * string_or_empty (const char *string)
 
static void collect_explicit_location_matches (completion_tracker &tracker, location_spec *locspec, enum explicit_location_match_type what, const char *word, const struct language_defn *language)
 
static int skip_keyword (completion_tracker &tracker, const char *const *keywords, const char **text_p)
 
static void complete_explicit_location_spec (completion_tracker &tracker, location_spec *locspec, const char *text, const language_defn *language, const char *quoted_arg_start, const char *quoted_arg_end)
 
void location_completer (struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *)
 
static void location_completer_handle_brkchars (struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word_ignored)
 
void complete_expression (completion_tracker &tracker, const char *text, const char *word)
 
void expression_completer (struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
 
void set_rl_completer_word_break_characters (const char *break_chars)
 
void symbol_completer (struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
 
static void complete_line_internal_normal_command (completion_tracker &tracker, const char *command, const char *word, const char *cmd_args, complete_line_internal_reason reason, struct cmd_list_element *c)
 
static void complete_line_internal_1 (completion_tracker &tracker, const char *text, const char *line_buffer, int point, complete_line_internal_reason reason)
 
static void complete_line_internal (completion_tracker &tracker, const char *text, const char *line_buffer, int point, complete_line_internal_reason reason)
 
static char * make_completion_match_str_1 (const char *match_name, const char *text, const char *word)
 
gdb::unique_xmalloc_ptr< char > make_completion_match_str (const char *match_name, const char *text, const char *word)
 
gdb::unique_xmalloc_ptr< char > make_completion_match_str (gdb::unique_xmalloc_ptr< char > &&match_name, const char *text, const char *word)
 
completion_result complete (const char *line, char const **word, int *quote_char)
 
void complete_line (completion_tracker &tracker, const char *text, const char *line_buffer, int point)
 
void command_completer (struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
 
static void command_completer_handle_brkchars (struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
 
void signal_completer (struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
 
 DEF_ENUM_FLAGS_TYPE (enum reg_completer_target, reg_completer_targets)
 
static void reg_or_group_completer_1 (completion_tracker &tracker, const char *text, const char *word, reg_completer_targets targets)
 
void reg_or_group_completer (struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
 
void reggroup_completer (struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
 
static void default_completer_handle_brkchars (struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
 
completer_handle_brkchars_ftypecompleter_handle_brkchars_func_for_completer (completer_ftype *fn)
 
static char * gdb_completion_word_break_characters_throw ()
 
char * gdb_completion_word_break_characters ()
 
const char * completion_find_completion_word (completion_tracker &tracker, const char *text, int *quote_char)
 
static char * expand_preserving_ws (const char *orig, size_t orig_len, const char *lcd)
 
static char ** gdb_rl_attempted_completion_function_throw (const char *text, int start, int end)
 
char ** gdb_rl_attempted_completion_function (const char *text, int start, int end)
 
const char * skip_quoted_chars (const char *str, const char *quotechars, const char *breakchars)
 
const char * skip_quoted (const char *str)
 
const char * get_max_completions_reached_message (void)
 
static int gdb_get_y_or_n (int for_pager, const struct match_list_displayer *displayer)
 
static int gdb_display_match_list_pager (int lines, const struct match_list_displayer *displayer)
 
static int gdb_path_isdir (const char *filename)
 
static char * gdb_printable_part (char *pathname)
 
static int gdb_fnwidth (const char *string)
 
static int gdb_fnprint (const char *to_print, int prefix_bytes, const struct match_list_displayer *displayer)
 
static int gdb_print_filename (char *to_print, char *full_pathname, int prefix_bytes, const struct match_list_displayer *displayer)
 
static int gdb_complete_get_screenwidth (const struct match_list_displayer *displayer)
 
EXTERN_C int _rl_qsort_string_compare (const void *, const void *)
 
static int gdb_display_match_list_1 (char **matches, int len, int max, const struct match_list_displayer *displayer)
 
void gdb_display_match_list (char **matches, int len, int max, const struct match_list_displayer *displayer)
 
void _initialize_completer ()
 

Variables

static gdb_completer_state current_completion
 
static const char gdb_completer_command_word_break_characters []
 
static const char gdb_completer_file_name_break_characters []
 
static const char gdb_completer_quote_characters [] = "'"
 
static const char *const explicit_options []
 
static const char *const probe_options []
 
int max_completions = 200
 
static char gdb_custom_word_point_brkchars [2]
 
static const char * gdb_org_rl_basic_quote_characters = rl_basic_quote_characters
 
int _rl_completion_prefix_display_length
 
int _rl_print_completions_horizontally
 

Macro Definition Documentation

◆ ELLIPSIS_LEN

#define ELLIPSIS_LEN   3

Definition at line 2442 of file completer.c.

Referenced by gdb_display_match_list_1(), and gdb_fnprint().

◆ INITIAL_COMPLETION_HTAB_SIZE

#define INITIAL_COMPLETION_HTAB_SIZE   200

Definition at line 1471 of file completer.c.

Referenced by completion_tracker::discard_completions().

Typedef Documentation

◆ QSFUNC

typedef int QSFUNC(const void *, const void *)

Definition at line 2816 of file completer.c.

Enumeration Type Documentation

◆ complete_line_internal_reason

Enumerator
handle_brkchars 
handle_completions 
handle_help 

Definition at line 1142 of file completer.c.

◆ explicit_location_match_type

Enumerator
MATCH_SOURCE 
MATCH_FUNCTION 
MATCH_QUALIFIED 
MATCH_LINE 
MATCH_LABEL 

Definition at line 123 of file completer.c.

◆ reg_completer_target

Enumerator
complete_register_names 
complete_reggroup_names 

Definition at line 1784 of file completer.c.

Function Documentation

◆ _initialize_completer()

void _initialize_completer ( )

Definition at line 2996 of file completer.c.

Referenced by initialize_all_files().

◆ _rl_qsort_string_compare()

EXTERN_C int _rl_qsort_string_compare ( const void * ,
const void *  )

◆ advance_to_completion_word()

static const char * advance_to_completion_word ( completion_tracker & tracker,
const char * word_break_characters,
const char * text )
static

◆ advance_to_expression_complete_word_point()

const char * advance_to_expression_complete_word_point ( completion_tracker & tracker,
const char * text )

◆ advance_to_filename_complete_word_point()

const char * advance_to_filename_complete_word_point ( completion_tracker & tracker,
const char * text )

◆ collect_explicit_location_matches()

static void collect_explicit_location_matches ( completion_tracker & tracker,
location_spec * locspec,
enum explicit_location_match_type what,
const char * word,
const struct language_defn * language )
static

◆ command_completer()

void command_completer ( struct cmd_list_element * ignore,
completion_tracker & tracker,
const char * text,
const char * word )

Definition at line 1734 of file completer.c.

References complete_line_internal(), and handle_help.

Referenced by completer_handle_brkchars_func_for_completer().

◆ command_completer_handle_brkchars()

static void command_completer_handle_brkchars ( struct cmd_list_element * ignore,
completion_tracker & tracker,
const char * text,
const char * word )
static

◆ complete()

completion_result complete ( const char * line,
char const ** word,
int * quote_char )

◆ complete_address_and_linespec_locations()

static void complete_address_and_linespec_locations ( completion_tracker & tracker,
const char * text,
symbol_name_match_type match_type )
static

◆ complete_explicit_location_spec()

static void complete_explicit_location_spec ( completion_tracker & tracker,
location_spec * locspec,
const char * text,
const language_defn * language,
const char * quoted_arg_start,
const char * quoted_arg_end )
static

◆ complete_expression()

void complete_expression ( completion_tracker & tracker,
const char * text,
const char * word )

◆ complete_files_symbols()

static void complete_files_symbols ( completion_tracker & tracker,
const char * text,
const char * word )
static

◆ complete_line()

void complete_line ( completion_tracker & tracker,
const char * text,
const char * line_buffer,
int point )

◆ complete_line_internal()

static void complete_line_internal ( completion_tracker & tracker,
const char * text,
const char * line_buffer,
int point,
complete_line_internal_reason reason )
static

◆ complete_line_internal_1()

static void complete_line_internal_1 ( completion_tracker & tracker,
const char * text,
const char * line_buffer,
int point,
complete_line_internal_reason reason )
static

◆ complete_line_internal_normal_command()

static void complete_line_internal_normal_command ( completion_tracker & tracker,
const char * command,
const char * word,
const char * cmd_args,
complete_line_internal_reason reason,
struct cmd_list_element * c )
static

◆ complete_nested_command_line()

void complete_nested_command_line ( completion_tracker & tracker,
const char * text )

◆ complete_source_filenames()

completion_list complete_source_filenames ( const char * text)

◆ completer_handle_brkchars_func_for_completer()

completer_handle_brkchars_ftype * completer_handle_brkchars_func_for_completer ( completer_ftype * fn)

◆ completion_find_completion_word()

const char * completion_find_completion_word ( completion_tracker & tracker,
const char * text,
int * quote_char )

◆ DEF_ENUM_FLAGS_TYPE()

DEF_ENUM_FLAGS_TYPE ( enum reg_completer_target,
reg_completer_targets  )

◆ default_completer_handle_brkchars()

static void default_completer_handle_brkchars ( struct cmd_list_element * ignore,
completion_tracker & tracker,
const char * text,
const char * word )
static

◆ expand_preserving_ws()

static char * expand_preserving_ws ( const char * orig,
size_t orig_len,
const char * lcd )
static

Definition at line 2082 of file completer.c.

Referenced by completion_tracker::build_completion_result().

◆ expression_completer()

void expression_completer ( struct cmd_list_element * ignore,
completion_tracker & tracker,
const char * text,
const char * word )

◆ filename_completer()

void filename_completer ( struct cmd_list_element * ignore,
completion_tracker & tracker,
const char * text,
const char * word )

◆ filename_completer_handle_brkchars()

static void filename_completer_handle_brkchars ( struct cmd_list_element * ignore,
completion_tracker & tracker,
const char * text,
const char * word )
static

◆ gdb_complete_get_screenwidth()

static int gdb_complete_get_screenwidth ( const struct match_list_displayer * displayer)
static

Definition at line 2806 of file completer.c.

References match_list_displayer::width.

Referenced by gdb_display_match_list_1().

◆ gdb_completion_word_break_characters()

char * gdb_completion_word_break_characters ( void )

◆ gdb_completion_word_break_characters_throw()

static char * gdb_completion_word_break_characters_throw ( )
static

◆ gdb_display_match_list()

void gdb_display_match_list ( char ** matches,
int len,
int max,
const struct match_list_displayer * displayer )

◆ gdb_display_match_list_1()

static int gdb_display_match_list_1 ( char ** matches,
int len,
int max,
const struct match_list_displayer * displayer )
static

◆ gdb_display_match_list_pager()

static int gdb_display_match_list_pager ( int lines,
const struct match_list_displayer * displayer )
static

◆ gdb_fnprint()

static int gdb_fnprint ( const char * to_print,
int prefix_bytes,
const struct match_list_displayer * displayer )
static

Definition at line 2619 of file completer.c.

References CTRL_CHAR, ELLIPSIS_LEN, and match_list_displayer::putch.

Referenced by gdb_print_filename().

◆ gdb_fnwidth()

static int gdb_fnwidth ( const char * string)
static

Definition at line 2565 of file completer.c.

References CTRL_CHAR.

Referenced by gdb_display_match_list_1().

◆ gdb_get_y_or_n()

static int gdb_get_y_or_n ( int for_pager,
const struct match_list_displayer * displayer )
static

◆ gdb_path_isdir()

static int gdb_path_isdir ( const char * filename)
static

Definition at line 2512 of file completer.c.

Referenced by gdb_print_filename().

◆ gdb_print_filename()

static int gdb_print_filename ( char * to_print,
char * full_pathname,
int prefix_bytes,
const struct match_list_displayer * displayer )
static

◆ gdb_printable_part()

static char * gdb_printable_part ( char * pathname)
static

Definition at line 2531 of file completer.c.

Referenced by gdb_display_match_list_1().

◆ gdb_rl_attempted_completion_function()

char ** gdb_rl_attempted_completion_function ( const char * text,
int start,
int end )

◆ gdb_rl_attempted_completion_function_throw()

static char ** gdb_rl_attempted_completion_function_throw ( const char * text,
int start,
int end )
static

◆ gdb_rl_find_completion_word()

static const char * gdb_rl_find_completion_word ( struct gdb_rl_completion_word_info * info,
int * qc,
int * dp,
const char * line_buffer )
static

Definition at line 275 of file completer.c.

References scan().

Referenced by advance_to_completion_word(), and completion_find_completion_word().

◆ get_gdb_completer_quote_characters()

const char * get_gdb_completer_quote_characters ( void )

Definition at line 186 of file completer.c.

References gdb_completer_quote_characters.

Referenced by init_main().

◆ get_max_completions_reached_message()

const char * get_max_completions_reached_message ( void )

Definition at line 2415 of file completer.c.

Referenced by complete_command(), and gdb_display_match_list().

◆ location_completer()

void location_completer ( struct cmd_list_element * ignore,
completion_tracker & tracker,
const char * text,
const char *  )

◆ location_completer_handle_brkchars()

static void location_completer_handle_brkchars ( struct cmd_list_element * ignore,
completion_tracker & tracker,
const char * text,
const char * word_ignored )
static

◆ make_completion_match_str() [1/2]

gdb::unique_xmalloc_ptr< char > make_completion_match_str ( const char * match_name,
const char * text,
const char * word )

◆ make_completion_match_str() [2/2]

gdb::unique_xmalloc_ptr< char > make_completion_match_str ( gdb::unique_xmalloc_ptr< char > && match_name,
const char * text,
const char * word )

Definition at line 1658 of file completer.c.

References make_completion_match_str_1().

◆ make_completion_match_str_1()

static char * make_completion_match_str_1 ( const char * match_name,
const char * text,
const char * word )
static

Definition at line 1615 of file completer.c.

References xmalloc().

Referenced by make_completion_match_str(), and make_completion_match_str().

◆ noop_completer()

void noop_completer ( struct cmd_list_element * ignore,
completion_tracker & tracker,
const char * text,
const char * prefix )

Definition at line 195 of file completer.c.

◆ reg_or_group_completer()

void reg_or_group_completer ( struct cmd_list_element * ignore,
completion_tracker & tracker,
const char * text,
const char * word )

◆ reg_or_group_completer_1()

static void reg_or_group_completer_1 ( completion_tracker & tracker,
const char * text,
const char * word,
reg_completer_targets targets )
static

◆ reggroup_completer()

void reggroup_completer ( struct cmd_list_element * ignore,
completion_tracker & tracker,
const char * text,
const char * word )

Definition at line 1846 of file completer.c.

References complete_reggroup_names, and reg_or_group_completer_1().

Referenced by tui_reggroup_completer().

◆ set_rl_completer_word_break_characters()

void set_rl_completer_word_break_characters ( const char * break_chars)

◆ signal_completer()

void signal_completer ( struct cmd_list_element * ignore,
completion_tracker & tracker,
const char * text,
const char * word )

Definition at line 1756 of file completer.c.

References completion_tracker::add_completion().

Referenced by handle_completer().

◆ skip_keyword()

static int skip_keyword ( completion_tracker & tracker,
const char *const * keywords,
const char ** text_p )
static

◆ skip_quoted()

const char * skip_quoted ( const char * str)

Definition at line 2406 of file completer.c.

References skip_quoted_chars().

Referenced by yylex().

◆ skip_quoted_chars()

const char * skip_quoted_chars ( const char * str,
const char * quotechars,
const char * breakchars )

◆ string_or_empty()

static const char * string_or_empty ( const char * string)
static

Definition at line 700 of file completer.c.

Referenced by collect_explicit_location_matches().

◆ symbol_completer()

void symbol_completer ( struct cmd_list_element * ignore,
completion_tracker & tracker,
const char * text,
const char * word )

Variable Documentation

◆ _rl_completion_prefix_display_length

int _rl_completion_prefix_display_length
extern

◆ _rl_print_completions_horizontally

int _rl_print_completions_horizontally
extern

◆ current_completion

gdb_completer_state current_completion
static

◆ explicit_options

const char* const explicit_options[]
static
Initial value:
=
{
"-source",
"-function",
"-qualified",
"-line",
"-label",
NULL
}

Definition at line 677 of file completer.c.

Referenced by collect_explicit_location_matches(), complete_explicit_location_spec(), and location_completer().

◆ gdb_completer_command_word_break_characters

const char gdb_completer_command_word_break_characters[]
static
Initial value:
=
" \t\n!@#$%^&*()+=|~`}{[]\"';:?/><,"

Definition at line 162 of file completer.c.

Referenced by command_completer_handle_brkchars(), and complete_line_internal_1().

◆ gdb_completer_file_name_break_characters

const char gdb_completer_file_name_break_characters[]
static

◆ gdb_completer_quote_characters

const char gdb_completer_quote_characters[] = "'"
static

◆ gdb_custom_word_point_brkchars

char gdb_custom_word_point_brkchars[2]
static

Definition at line 1887 of file completer.c.

Referenced by gdb_completion_word_break_characters_throw().

◆ gdb_org_rl_basic_quote_characters

const char* gdb_org_rl_basic_quote_characters = rl_basic_quote_characters
static

Definition at line 1892 of file completer.c.

Referenced by gdb_rl_attempted_completion_function().

◆ max_completions

int max_completions = 200

◆ probe_options

const char* const probe_options[]
static
Initial value:
=
{
"-probe",
"-probe-stap",
"-probe-dtrace",
NULL
}

Definition at line 689 of file completer.c.

Referenced by location_completer().