GDB (xrefs)
/tmp/gdb-7.10/gdb/completer.h
Go to the documentation of this file.
1 /* Header for GDB line completion.
2  Copyright (C) 2000-2015 Free Software Foundation, Inc.
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 3 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see <http://www.gnu.org/licenses/>. */
16 
17 #if !defined (COMPLETER_H)
18 #define COMPLETER_H 1
19 
20 #include "gdb_vecs.h"
21 #include "command.h"
22 
23 /* Types of functions in struct match_list_displayer. */
24 
26 
27 typedef void mld_crlf_ftype (const struct match_list_displayer *);
28 typedef void mld_putch_ftype (const struct match_list_displayer *, int);
29 typedef void mld_puts_ftype (const struct match_list_displayer *,
30  const char *);
31 typedef void mld_flush_ftype (const struct match_list_displayer *);
32 typedef void mld_erase_entire_line_ftype (const struct match_list_displayer *);
33 typedef void mld_beep_ftype (const struct match_list_displayer *);
34 typedef int mld_read_key_ftype (const struct match_list_displayer *);
35 
36 /* Interface between CLI/TUI and gdb_match_list_displayer. */
37 
39 {
40  /* The screen dimensions to work with when displaying matches. */
41  int height, width;
42 
43  /* Print cr,lf. */
45 
46  /* Not "putc" to avoid issues where it is a stdio macro. Sigh. */
48 
49  /* Print a string. */
51 
52  /* Flush all accumulated output. */
54 
55  /* Erase the currently line on the terminal (but don't discard any text the
56  user has entered, readline may shortly re-print it). */
58 
59  /* Ring the bell. */
61 
62  /* Read one key. */
64 };
65 
66 extern void gdb_display_match_list (char **matches, int len, int max,
67  const struct match_list_displayer *);
68 
69 extern const char *get_max_completions_reached_message (void);
70 
71 extern VEC (char_ptr) *complete_line (const char *text,
72  const char *line_buffer,
73  int point);
74 
75 extern char *readline_line_completion_function (const char *text,
76  int matches);
77 
78 extern VEC (char_ptr) *noop_completer (struct cmd_list_element *,
79  const char *, const char *);
80 
81 extern VEC (char_ptr) *filename_completer (struct cmd_list_element *,
82  const char *, const char *);
83 
84 extern VEC (char_ptr) *expression_completer (struct cmd_list_element *,
85  const char *, const char *);
86 
87 extern VEC (char_ptr) *location_completer (struct cmd_list_element *,
88  const char *, const char *);
89 
90 extern VEC (char_ptr) *command_completer (struct cmd_list_element *,
91  const char *, const char *);
92 
93 extern VEC (char_ptr) *signal_completer (struct cmd_list_element *,
94  const char *, const char *);
95 
96 extern VEC (char_ptr) *reg_or_group_completer (struct cmd_list_element *,
97  const char *, const char *);
98 
99 extern VEC (char_ptr) *reggroup_completer (struct cmd_list_element *,
100  const char *, const char *);
101 
102 extern char *get_gdb_completer_quote_characters (void);
103 
104 extern char *gdb_completion_word_break_characters (void);
105 
106 /* Set the word break characters array to the corresponding set of
107  chars, based on FN. This function is useful for cases when the
108  completer doesn't know the type of the completion until some
109  calculation is done (e.g., for Python functions). */
110 
111 extern void set_gdb_completion_word_break_characters (completer_ftype *fn);
112 
113 /* Exported to linespec.c */
114 
115 extern const char *skip_quoted_chars (const char *, const char *,
116  const char *);
117 
118 extern const char *skip_quoted (const char *);
119 
120 /* Maximum number of candidates to consider before the completer
121  bails by throwing MAX_COMPLETIONS_REACHED_ERROR. Negative values
122  disable limiting. */
123 
124 extern int max_completions;
125 
126 /* Object to track how many unique completions have been generated.
127  Used to limit the size of generated completion lists. */
128 
129 typedef htab_t completion_tracker_t;
130 
131 /* Create a new completion tracker.
132  The result is a hash table to track added completions, or NULL
133  if max_completions <= 0. If max_completions < 0, tracking is disabled.
134  If max_completions == 0, the max is indeed zero. */
135 
137 
138 /* Make a cleanup to free a completion tracker, and reset its pointer
139  to NULL. */
140 
142  (completion_tracker_t *tracker_ptr);
143 
144 /* Return values for maybe_add_completion. */
145 
147 {
148  /* NAME has been recorded and max_completions has not been reached,
149  or completion tracking is disabled (max_completions < 0). */
151 
152  /* NAME has been recorded and max_completions has been reached
153  (thus the caller can stop searching). */
155 
156  /* max-completions entries has been reached.
157  Whether NAME is a duplicate or not is not determined. */
159 
160  /* NAME has already been recorded.
161  Note that this is never returned if completion tracking is disabled
162  (max_completions < 0). */
164 };
165 
166 /* Add the completion NAME to the list of generated completions if
167  it is not there already.
168  If max_completions is negative, nothing is done, not even watching
169  for duplicates, and MAYBE_ADD_COMPLETION_OK is always returned.
170 
171  If MAYBE_ADD_COMPLETION_MAX_REACHED is returned, callers are required to
172  record at least one more completion. The final list will be pruned to
173  max_completions, but recording at least one more than max_completions is
174  the signal to the completion machinery that too many completions were
175  found. */
176 
177 extern enum maybe_add_completion_enum
179 
180 /* Wrapper to throw MAX_COMPLETIONS_REACHED_ERROR. */
181 
182 extern void throw_max_completions_reached_error (void);
183 
184 #endif /* defined (COMPLETER_H) */
void mld_crlf_ftype(const struct match_list_displayer *)
Definition: completer.h:27
mld_putch_ftype * putch
Definition: completer.h:47
void mld_puts_ftype(const struct match_list_displayer *, const char *)
Definition: completer.h:29
const char * skip_quoted(const char *)
Definition: completer.c:1188
mld_crlf_ftype * crlf
Definition: completer.h:44
int mld_read_key_ftype(const struct match_list_displayer *)
Definition: completer.h:34
char * char_ptr
Definition: gdb_vecs.h:25
enum maybe_add_completion_enum maybe_add_completion(completion_tracker_t tracker, char *name)
Definition: completer.c:832
mld_read_key_ftype * read_key
Definition: completer.h:63
void set_gdb_completion_word_break_characters(completer_ftype *fn)
Definition: completer.c:461
void mld_erase_entire_line_ftype(const struct match_list_displayer *)
Definition: completer.h:32
const char int point
Definition: completer.h:72
int max_completions
Definition: completer.c:791
const char *const name
Definition: aarch64-tdep.c:68
const char * get_max_completions_reached_message(void)
Definition: completer.c:1197
mld_beep_ftype * beep
Definition: completer.h:60
mld_puts_ftype * puts
Definition: completer.h:50
char * readline_line_completion_function(const char *text, int matches)
Definition: completer.c:102
htab_t completion_tracker_t
Definition: completer.h:129
void mld_beep_ftype(const struct match_list_displayer *)
Definition: completer.h:33
void mld_putch_ftype(const struct match_list_displayer *, int)
Definition: completer.h:28
void gdb_display_match_list(char **matches, int len, int max, const struct match_list_displayer *)
Definition: completer.c:1728
completion_tracker_t new_completion_tracker(void)
Definition: completer.c:796
const char * skip_quoted_chars(const char *, const char *, const char *)
Definition: completer.c:1145
const char const char const char const char const char const char const char const char const char const char const char const char const char const char const char const char *char * get_gdb_completer_quote_characters(void)
Definition: completer.c:94
char * gdb_completion_word_break_characters(void)
Definition: completer.c:1054
#define max(a, b)
Definition: defs.h:109
maybe_add_completion_enum
Definition: completer.h:146
struct cleanup * make_cleanup_free_completion_tracker(completion_tracker_t *tracker_ptr)
Definition: completer.c:821
void throw_max_completions_reached_error(void)
Definition: completer.c:859
void mld_flush_ftype(const struct match_list_displayer *)
Definition: completer.h:31
const char * line_buffer
Definition: completer.h:72
mld_erase_entire_line_ftype * erase_entire_line
Definition: completer.h:57
mld_flush_ftype * flush
Definition: completer.h:53
VEC(char_ptr)*complete_line(const char *text
const ULONGEST const LONGEST len
Definition: target.h:309