xref: /dflybsd-src/contrib/gdb-7/gdb/linespec.h (revision de8e141f24382815c10a4012d209bbbf7abf1112)
15796c8dcSSimon Schubert /* Header for GDB line completion.
2*ef5ccd6cSJohn Marino    Copyright (C) 2000-2013 Free Software Foundation, Inc.
35796c8dcSSimon Schubert 
45796c8dcSSimon Schubert    This program is free software; you can redistribute it and/or modify
55796c8dcSSimon Schubert    it under the terms of the GNU General Public License as published by
65796c8dcSSimon Schubert    the Free Software Foundation; either version 3 of the License, or
75796c8dcSSimon Schubert    (at your option) any later version.
85796c8dcSSimon Schubert 
95796c8dcSSimon Schubert    This program is distributed in the hope that it will be useful,
105796c8dcSSimon Schubert    but WITHOUT ANY WARRANTY; without even the implied warranty of
115796c8dcSSimon Schubert    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
125796c8dcSSimon Schubert    GNU General Public License for more details.
135796c8dcSSimon Schubert 
145796c8dcSSimon Schubert    You should have received a copy of the GNU General Public License
155796c8dcSSimon Schubert    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
165796c8dcSSimon Schubert 
175796c8dcSSimon Schubert #if !defined (LINESPEC_H)
185796c8dcSSimon Schubert #define LINESPEC_H 1
195796c8dcSSimon Schubert 
205796c8dcSSimon Schubert struct symtab;
215796c8dcSSimon Schubert 
22a45ae5f8SJohn Marino #include "vec.h"
23a45ae5f8SJohn Marino 
24a45ae5f8SJohn Marino /* Flags to pass to decode_line_1 and decode_line_full.  */
25a45ae5f8SJohn Marino 
26a45ae5f8SJohn Marino enum decode_line_flags
27a45ae5f8SJohn Marino   {
28a45ae5f8SJohn Marino     /* Set this flag if you want the resulting SALs to describe the
29a45ae5f8SJohn Marino        first line of indicated functions.  */
30a45ae5f8SJohn Marino     DECODE_LINE_FUNFIRSTLINE = 1,
31a45ae5f8SJohn Marino 
32a45ae5f8SJohn Marino     /* Set this flag if you want "list mode".  In this mode, a
33a45ae5f8SJohn Marino        FILE:LINE linespec will always return a result, and such
34a45ae5f8SJohn Marino        linespecs will not be expanded to all matches.  */
35a45ae5f8SJohn Marino     DECODE_LINE_LIST_MODE = 2
36a45ae5f8SJohn Marino   };
37a45ae5f8SJohn Marino 
38a45ae5f8SJohn Marino /* decode_line_full returns a vector of these.  */
39a45ae5f8SJohn Marino 
40a45ae5f8SJohn Marino struct linespec_sals
41a45ae5f8SJohn Marino {
42a45ae5f8SJohn Marino   /* This is the linespec corresponding to the sals contained in this
43a45ae5f8SJohn Marino      object.  It can be passed as the FILTER argument to future calls
44a45ae5f8SJohn Marino      to decode_line_full.  This is freed by
45a45ae5f8SJohn Marino      destroy_linespec_result.  */
46a45ae5f8SJohn Marino   char *canonical;
47a45ae5f8SJohn Marino 
48a45ae5f8SJohn Marino   /* Sals.  The 'sals' field is destroyed by
49a45ae5f8SJohn Marino      destroy_linespec_result.  */
50a45ae5f8SJohn Marino   struct symtabs_and_lines sals;
51a45ae5f8SJohn Marino };
52a45ae5f8SJohn Marino 
53a45ae5f8SJohn Marino typedef struct linespec_sals linespec_sals;
54a45ae5f8SJohn Marino DEF_VEC_O (linespec_sals);
55a45ae5f8SJohn Marino 
56c50c785cSJohn Marino /* An instance of this may be filled in by decode_line_1.  The caller
57a45ae5f8SJohn Marino    must call init_linespec_result to initialize it and
58a45ae5f8SJohn Marino    destroy_linespec_result to destroy it.  The caller must make copies
59a45ae5f8SJohn Marino    of any data that it needs to keep.  */
60c50c785cSJohn Marino 
61c50c785cSJohn Marino struct linespec_result
62c50c785cSJohn Marino {
63c50c785cSJohn Marino   /* If non-zero, the linespec should be displayed to the user.  This
64c50c785cSJohn Marino      is used by "unusual" linespecs where the ordinary `info break'
65c50c785cSJohn Marino      display mechanism would do the wrong thing.  */
66c50c785cSJohn Marino   int special_display;
67c50c785cSJohn Marino 
68a45ae5f8SJohn Marino   /* If non-zero, the linespec result should be considered to be a
69a45ae5f8SJohn Marino      "pre-expanded" multi-location linespec.  A pre-expanded linespec
70a45ae5f8SJohn Marino      holds all matching locations in a single linespec_sals
71a45ae5f8SJohn Marino      object.  */
72a45ae5f8SJohn Marino   int pre_expanded;
73a45ae5f8SJohn Marino 
74a45ae5f8SJohn Marino   /* If PRE_EXPANDED is non-zero, this is set to the linespec entered
75a45ae5f8SJohn Marino      by the user.  This will be freed by destroy_linespec_result.  */
76a45ae5f8SJohn Marino   char *addr_string;
77a45ae5f8SJohn Marino 
78a45ae5f8SJohn Marino   /* The sals.  The vector will be freed by
79a45ae5f8SJohn Marino      destroy_linespec_result.  */
80a45ae5f8SJohn Marino   VEC (linespec_sals) *sals;
81c50c785cSJohn Marino };
82c50c785cSJohn Marino 
83c50c785cSJohn Marino /* Initialize a linespec_result.  */
84c50c785cSJohn Marino 
85c50c785cSJohn Marino extern void init_linespec_result (struct linespec_result *);
86c50c785cSJohn Marino 
87a45ae5f8SJohn Marino /* Destroy a linespec_result.  */
88a45ae5f8SJohn Marino 
89a45ae5f8SJohn Marino extern void destroy_linespec_result (struct linespec_result *);
90a45ae5f8SJohn Marino 
91a45ae5f8SJohn Marino /* Return a cleanup that destroys a linespec_result.  */
92a45ae5f8SJohn Marino 
93a45ae5f8SJohn Marino extern struct cleanup *
94a45ae5f8SJohn Marino         make_cleanup_destroy_linespec_result (struct linespec_result *);
95a45ae5f8SJohn Marino 
96*ef5ccd6cSJohn Marino /* Decode a linespec using the provided default symtab and line.  */
97*ef5ccd6cSJohn Marino 
985796c8dcSSimon Schubert extern struct symtabs_and_lines
99a45ae5f8SJohn Marino 	decode_line_1 (char **argptr, int flags,
100a45ae5f8SJohn Marino 		       struct symtab *default_symtab, int default_line);
101a45ae5f8SJohn Marino 
102a45ae5f8SJohn Marino /* Parse *ARGPTR as a linespec and return results.  This is the "full"
103a45ae5f8SJohn Marino    interface to this module, which handles multiple results
104a45ae5f8SJohn Marino    properly.
105a45ae5f8SJohn Marino 
106a45ae5f8SJohn Marino    For FLAGS, see decode_line_flags.  DECODE_LINE_LIST_MODE is not
107a45ae5f8SJohn Marino    valid for this function.
108a45ae5f8SJohn Marino 
109a45ae5f8SJohn Marino    DEFAULT_SYMTAB and DEFAULT_LINE describe the default location.
110a45ae5f8SJohn Marino    DEFAULT_SYMTAB can be NULL, in which case the current symtab and
111a45ae5f8SJohn Marino    line are used.
112a45ae5f8SJohn Marino 
113a45ae5f8SJohn Marino    CANONICAL is where the results are stored.  It must not be NULL.
114a45ae5f8SJohn Marino 
115a45ae5f8SJohn Marino    SELECT_MODE must be one of the multiple_symbols_* constants, or
116a45ae5f8SJohn Marino    NULL.  It determines how multiple results will be handled.  If
117a45ae5f8SJohn Marino    NULL, the appropriate CLI value will be used.
118a45ae5f8SJohn Marino 
119a45ae5f8SJohn Marino    FILTER can either be NULL or a string holding a canonical name.
120a45ae5f8SJohn Marino    This is only valid when SELECT_MODE is multiple_symbols_all.
121a45ae5f8SJohn Marino 
122a45ae5f8SJohn Marino    Multiple results are handled differently depending on the
123a45ae5f8SJohn Marino    arguments:
124a45ae5f8SJohn Marino 
125a45ae5f8SJohn Marino    . With multiple_symbols_cancel, an exception is thrown.
126a45ae5f8SJohn Marino 
127a45ae5f8SJohn Marino    . With multiple_symbols_ask, a menu is presented to the user.  The
128a45ae5f8SJohn Marino    user may select none, in which case an exception is thrown; or all,
129a45ae5f8SJohn Marino    which is handled like multiple_symbols_all, below.  Otherwise,
130a45ae5f8SJohn Marino    CANONICAL->SALS will have one entry for each name the user chose.
131a45ae5f8SJohn Marino 
132a45ae5f8SJohn Marino    . With multiple_symbols_all, CANONICAL->SALS will have a single
133a45ae5f8SJohn Marino    entry describing all the matching locations.  If FILTER is
134a45ae5f8SJohn Marino    non-NULL, then only locations whose canonical name is equal (in the
135a45ae5f8SJohn Marino    strcmp sense) to FILTER will be returned; all others will be
136a45ae5f8SJohn Marino    filtered out.  */
137a45ae5f8SJohn Marino 
138a45ae5f8SJohn Marino extern void decode_line_full (char **argptr, int flags,
1395796c8dcSSimon Schubert 			      struct symtab *default_symtab, int default_line,
140a45ae5f8SJohn Marino 			      struct linespec_result *canonical,
141a45ae5f8SJohn Marino 			      const char *select_mode,
142a45ae5f8SJohn Marino 			      const char *filter);
1435796c8dcSSimon Schubert 
144*ef5ccd6cSJohn Marino /* Given a string, return the line specified by it, using the current
145*ef5ccd6cSJohn Marino    source symtab and line as defaults.
146*ef5ccd6cSJohn Marino    This is for commands like "list" and "breakpoint".  */
147*ef5ccd6cSJohn Marino 
148*ef5ccd6cSJohn Marino extern struct symtabs_and_lines decode_line_with_current_source (char *, int);
149*ef5ccd6cSJohn Marino 
150*ef5ccd6cSJohn Marino /* Given a string, return the line specified by it, using the last displayed
151*ef5ccd6cSJohn Marino    codepoint's values as defaults, or nothing if they aren't valid.  */
152*ef5ccd6cSJohn Marino 
153*ef5ccd6cSJohn Marino extern struct symtabs_and_lines decode_line_with_last_displayed (char *, int);
154*ef5ccd6cSJohn Marino 
1555796c8dcSSimon Schubert #endif /* defined (LINESPEC_H) */
156