linespec.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /* Header for GDB line completion.
  2. Copyright (C) 2000-2022 Free Software Foundation, Inc.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  13. #if !defined (LINESPEC_H)
  14. #define LINESPEC_H 1
  15. struct symtab;
  16. #include "location.h"
  17. /* Flags to pass to decode_line_1 and decode_line_full. */
  18. enum decode_line_flags
  19. {
  20. /* Set this flag if you want the resulting SALs to describe the
  21. first line of indicated functions. */
  22. DECODE_LINE_FUNFIRSTLINE = 1,
  23. /* Set this flag if you want "list mode". In this mode, a
  24. FILE:LINE linespec will always return a result, and such
  25. linespecs will not be expanded to all matches. */
  26. DECODE_LINE_LIST_MODE = 2
  27. };
  28. /* decode_line_full returns a vector of these. */
  29. struct linespec_sals
  30. {
  31. /* This is the location corresponding to the sals contained in this
  32. object. It can be passed as the FILTER argument to future calls
  33. to decode_line_full. This is freed by the linespec_result
  34. destructor. */
  35. char *canonical;
  36. /* Sals. */
  37. std::vector<symtab_and_line> sals;
  38. };
  39. /* An instance of this may be filled in by decode_line_1. The caller
  40. must make copies of any data that it needs to keep. */
  41. struct linespec_result
  42. {
  43. linespec_result () = default;
  44. ~linespec_result ();
  45. DISABLE_COPY_AND_ASSIGN (linespec_result);
  46. /* If true, the linespec should be displayed to the user. This
  47. is used by "unusual" linespecs where the ordinary `info break'
  48. display mechanism would do the wrong thing. */
  49. bool special_display = false;
  50. /* If true, the linespec result should be considered to be a
  51. "pre-expanded" multi-location linespec. A pre-expanded linespec
  52. holds all matching locations in a single linespec_sals
  53. object. */
  54. bool pre_expanded = false;
  55. /* If PRE_EXPANDED is non-zero, this is set to the location entered
  56. by the user. */
  57. event_location_up location;
  58. /* The sals. The vector will be freed by the destructor. */
  59. std::vector<linespec_sals> lsals;
  60. };
  61. /* Decode a linespec using the provided default symtab and line. */
  62. extern std::vector<symtab_and_line>
  63. decode_line_1 (const struct event_location *location, int flags,
  64. struct program_space *search_pspace,
  65. struct symtab *default_symtab, int default_line);
  66. /* Parse LOCATION and return results. This is the "full"
  67. interface to this module, which handles multiple results
  68. properly.
  69. For FLAGS, see decode_line_flags. DECODE_LINE_LIST_MODE is not
  70. valid for this function.
  71. If SEARCH_PSPACE is not NULL, symbol search is restricted to just
  72. that program space.
  73. DEFAULT_SYMTAB and DEFAULT_LINE describe the default location.
  74. DEFAULT_SYMTAB can be NULL, in which case the current symtab and
  75. line are used.
  76. CANONICAL is where the results are stored. It must not be NULL.
  77. SELECT_MODE must be one of the multiple_symbols_* constants, or
  78. NULL. It determines how multiple results will be handled. If
  79. NULL, the appropriate CLI value will be used.
  80. FILTER can either be NULL or a string holding a canonical name.
  81. This is only valid when SELECT_MODE is multiple_symbols_all.
  82. Multiple results are handled differently depending on the
  83. arguments:
  84. . With multiple_symbols_cancel, an exception is thrown.
  85. . With multiple_symbols_ask, a menu is presented to the user. The
  86. user may select none, in which case an exception is thrown; or all,
  87. which is handled like multiple_symbols_all, below. Otherwise,
  88. CANONICAL->SALS will have one entry for each name the user chose.
  89. . With multiple_symbols_all, CANONICAL->SALS will have a single
  90. entry describing all the matching locations. If FILTER is
  91. non-NULL, then only locations whose canonical name is equal (in the
  92. strcmp sense) to FILTER will be returned; all others will be
  93. filtered out. */
  94. extern void decode_line_full (struct event_location *location, int flags,
  95. struct program_space *search_pspace,
  96. struct symtab *default_symtab, int default_line,
  97. struct linespec_result *canonical,
  98. const char *select_mode,
  99. const char *filter);
  100. /* Given a string, return the line specified by it, using the current
  101. source symtab and line as defaults.
  102. This is for commands like "list" and "breakpoint". */
  103. extern std::vector<symtab_and_line> decode_line_with_current_source
  104. (const char *, int);
  105. /* Given a string, return the line specified by it, using the last displayed
  106. codepoint's values as defaults, or nothing if they aren't valid. */
  107. extern std::vector<symtab_and_line> decode_line_with_last_displayed
  108. (const char *, int);
  109. /* Does P represent one of the keywords? If so, return
  110. the keyword. If not, return NULL. */
  111. extern const char *linespec_lexer_lex_keyword (const char *p);
  112. /* Parse a line offset from STRING. */
  113. extern struct line_offset linespec_parse_line_offset (const char *string);
  114. /* Return the quote characters permitted by the linespec parser. */
  115. extern const char *get_gdb_linespec_parser_quote_characters (void);
  116. /* Does STRING represent an Ada operator? If so, return the length
  117. of the decoded operator name. If not, return 0. */
  118. extern int is_ada_operator (const char *string);
  119. /* Find the end of the (first) linespec pointed to by *STRINGP.
  120. STRINGP will be advanced to this point. */
  121. extern void linespec_lex_to_end (const char **stringp);
  122. extern const char * const linespec_keywords[];
  123. /* Complete a linespec. */
  124. extern void linespec_complete (completion_tracker &tracker,
  125. const char *text,
  126. symbol_name_match_type match_type);
  127. /* Complete a function symbol, in linespec mode, according to
  128. FUNC_MATCH_TYPE. If SOURCE_FILENAME is non-NULL, limits completion
  129. to the list of functions defined in source files that match
  130. SOURCE_FILENAME. */
  131. extern void linespec_complete_function (completion_tracker &tracker,
  132. const char *function,
  133. symbol_name_match_type func_match_type,
  134. const char *source_filename);
  135. /* Complete a label symbol, in linespec mode. Only labels of
  136. functions named FUNCTION_NAME are considered. If SOURCE_FILENAME
  137. is non-NULL, limits completion to labels of functions defined in
  138. source files that match SOURCE_FILENAME. */
  139. extern void linespec_complete_label (completion_tracker &tracker,
  140. const struct language_defn *language,
  141. const char *source_filename,
  142. const char *function_name,
  143. symbol_name_match_type name_match_type,
  144. const char *label_name);
  145. /* Evaluate the expression pointed to by EXP_PTR into a CORE_ADDR,
  146. advancing EXP_PTR past any parsed text. */
  147. extern CORE_ADDR linespec_expression_to_pc (const char **exp_ptr);
  148. #endif /* defined (LINESPEC_H) */