1 /* Data structures and API for event locations in GDB.
2 Copyright (C) 2013-2022 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #include "gdbsupport/gdb_assert.h"
25 #include "cli/cli-utils.h"
27 #include "cp-support.h"
32 static std::string explicit_location_to_string
33 (const struct explicit_location
*explicit_loc
);
35 /* The base class for all an event locations used to set a stop event
40 virtual ~event_location () = default;
42 /* Clone this object. */
43 virtual event_location_up
clone () const = 0;
45 /* Return true if this location is empty, false otherwise. */
46 virtual bool empty_p () const = 0;
48 /* Return a string representation of this location. */
49 const char *to_string () const
51 if (as_string
.empty ())
52 as_string
= compute_string ();
53 if (as_string
.empty ())
55 return as_string
.c_str ();
58 DISABLE_COPY_AND_ASSIGN (event_location
);
60 /* The type of this breakpoint specification. */
61 enum event_location_type type
;
63 /* Cached string representation of this location. This is used,
64 e.g., to save stop event locations to file. */
65 mutable std::string as_string
;
69 explicit event_location (enum event_location_type t
)
74 event_location (enum event_location_type t
, std::string
&&str
)
76 as_string (std::move (str
))
80 explicit event_location (const event_location
*to_clone
)
81 : type (to_clone
->type
),
82 as_string (to_clone
->as_string
)
86 /* Compute the string representation of this object. This is called
87 by to_string when needed. */
88 virtual std::string
compute_string () const = 0;
92 struct event_location_probe
: public event_location
94 explicit event_location_probe (std::string
&&probe
)
95 : event_location (PROBE_LOCATION
, std::move (probe
))
99 event_location_up
clone () const override
101 return event_location_up (new event_location_probe (this));
104 bool empty_p () const override
111 explicit event_location_probe (const event_location_probe
*to_clone
)
112 : event_location (to_clone
)
116 std::string
compute_string () const override
118 return std::move (as_string
);
122 /* A "normal" linespec. */
123 struct event_location_linespec
: public event_location
125 event_location_linespec (const char **linespec
,
126 symbol_name_match_type match_type
)
127 : event_location (LINESPEC_LOCATION
)
129 linespec_location
.match_type
= match_type
;
130 if (*linespec
!= NULL
)
133 const char *orig
= *linespec
;
135 linespec_lex_to_end (linespec
);
136 p
= remove_trailing_whitespace (orig
, *linespec
);
138 /* If there is no valid linespec then this will leave the
139 spec_string as nullptr. This behaviour is relied on in the
140 breakpoint setting code, where spec_string being nullptr means
141 to use the default breakpoint location. */
143 linespec_location
.spec_string
= savestring (orig
, p
- orig
);
147 ~event_location_linespec ()
149 xfree (linespec_location
.spec_string
);
152 event_location_up
clone () const override
154 return event_location_up (new event_location_linespec (this));
157 bool empty_p () const override
162 struct linespec_location linespec_location
{};
166 explicit event_location_linespec (const event_location_linespec
*to_clone
)
167 : event_location (to_clone
),
168 linespec_location (to_clone
->linespec_location
)
170 if (linespec_location
.spec_string
!= nullptr)
171 linespec_location
.spec_string
= xstrdup (linespec_location
.spec_string
);
174 std::string
compute_string () const override
176 if (linespec_location
.spec_string
!= nullptr)
178 const struct linespec_location
*ls
= &linespec_location
;
179 if (ls
->match_type
== symbol_name_match_type::FULL
)
180 return std::string ("-qualified ") + ls
->spec_string
;
182 return ls
->spec_string
;
188 /* An address in the inferior. */
189 struct event_location_address
: public event_location
191 event_location_address (CORE_ADDR addr
, const char *addr_string
,
193 : event_location (ADDRESS_LOCATION
),
196 if (addr_string
!= nullptr)
197 as_string
= std::string (addr_string
, addr_string_len
);
200 event_location_up
clone () const override
202 return event_location_up (new event_location_address (this));
205 bool empty_p () const override
214 event_location_address (const event_location_address
*to_clone
)
215 : event_location (to_clone
),
216 address (to_clone
->address
)
220 std::string
compute_string () const override
222 const char *addr_string
= core_addr_to_string (address
);
223 return std::string ("*") + addr_string
;
227 /* An explicit location. */
228 struct event_location_explicit
: public event_location
230 explicit event_location_explicit (const struct explicit_location
*loc
)
231 : event_location (EXPLICIT_LOCATION
)
236 ~event_location_explicit ()
238 xfree (explicit_loc
.source_filename
);
239 xfree (explicit_loc
.function_name
);
240 xfree (explicit_loc
.label_name
);
243 event_location_up
clone () const override
245 return event_location_up (new event_location_explicit (this));
248 bool empty_p () const override
250 return (explicit_loc
.source_filename
== nullptr
251 && explicit_loc
.function_name
== nullptr
252 && explicit_loc
.label_name
== nullptr
253 && explicit_loc
.line_offset
.sign
== LINE_OFFSET_UNKNOWN
);
256 struct explicit_location explicit_loc
;
260 explicit event_location_explicit (const event_location_explicit
*to_clone
)
261 : event_location (to_clone
)
263 copy_loc (&to_clone
->explicit_loc
);
266 std::string
compute_string () const override
268 return explicit_location_to_string (&explicit_loc
);
273 void copy_loc (const struct explicit_location
*loc
)
275 initialize_explicit_location (&explicit_loc
);
278 explicit_loc
.func_name_match_type
= loc
->func_name_match_type
;
279 if (loc
->source_filename
!= nullptr)
280 explicit_loc
.source_filename
= xstrdup (loc
->source_filename
);
281 if (loc
->function_name
!= nullptr)
282 explicit_loc
.function_name
= xstrdup (loc
->function_name
);
283 if (loc
->label_name
!= nullptr)
284 explicit_loc
.label_name
= xstrdup (loc
->label_name
);
285 explicit_loc
.line_offset
= loc
->line_offset
;
290 /* See description in location.h. */
292 enum event_location_type
293 event_location_type (const struct event_location
*location
)
295 return location
->type
;
298 /* See description in location.h. */
301 initialize_explicit_location (struct explicit_location
*explicit_loc
)
303 memset (explicit_loc
, 0, sizeof (struct explicit_location
));
304 explicit_loc
->line_offset
.sign
= LINE_OFFSET_UNKNOWN
;
305 explicit_loc
->func_name_match_type
= symbol_name_match_type::WILD
;
308 /* See description in location.h. */
311 new_linespec_location (const char **linespec
,
312 symbol_name_match_type match_type
)
314 return event_location_up (new event_location_linespec (linespec
,
318 /* See description in location.h. */
320 const linespec_location
*
321 get_linespec_location (const struct event_location
*location
)
323 gdb_assert (location
->type
== LINESPEC_LOCATION
);
324 return &((event_location_linespec
*) location
)->linespec_location
;
327 /* See description in location.h. */
330 new_address_location (CORE_ADDR addr
, const char *addr_string
,
333 return event_location_up (new event_location_address (addr
, addr_string
,
337 /* See description in location.h. */
340 get_address_location (const struct event_location
*location
)
342 gdb_assert (location
->type
== ADDRESS_LOCATION
);
343 return ((event_location_address
*) location
)->address
;
346 /* See description in location.h. */
349 get_address_string_location (const struct event_location
*location
)
351 gdb_assert (location
->type
== ADDRESS_LOCATION
);
352 return location
->to_string ();
355 /* See description in location.h. */
358 new_probe_location (std::string
&&probe
)
360 return event_location_up (new event_location_probe (std::move (probe
)));
363 /* See description in location.h. */
366 get_probe_location (const struct event_location
*location
)
368 gdb_assert (location
->type
== PROBE_LOCATION
);
369 return location
->to_string ();
372 /* See description in location.h. */
375 new_explicit_location (const struct explicit_location
*explicit_loc
)
377 return event_location_up (new event_location_explicit (explicit_loc
));
380 /* See description in location.h. */
382 struct explicit_location
*
383 get_explicit_location (struct event_location
*location
)
385 gdb_assert (location
->type
== EXPLICIT_LOCATION
);
386 return &((event_location_explicit
*) location
)->explicit_loc
;
389 /* See description in location.h. */
391 const struct explicit_location
*
392 get_explicit_location_const (const struct event_location
*location
)
394 gdb_assert (location
->type
== EXPLICIT_LOCATION
);
395 return &((event_location_explicit
*) location
)->explicit_loc
;
398 /* This convenience function returns a malloc'd string which
399 represents the location in EXPLICIT_LOC.
401 AS_LINESPEC is true if this string should be a linespec.
402 Otherwise it will be output in explicit form. */
405 explicit_to_string_internal (bool as_linespec
,
406 const struct explicit_location
*explicit_loc
)
408 bool need_space
= false;
409 char space
= as_linespec
? ':' : ' ';
412 if (explicit_loc
->source_filename
!= NULL
)
415 buf
.puts ("-source ");
416 buf
.puts (explicit_loc
->source_filename
);
420 if (explicit_loc
->function_name
!= NULL
)
424 if (explicit_loc
->func_name_match_type
== symbol_name_match_type::FULL
)
425 buf
.puts ("-qualified ");
427 buf
.puts ("-function ");
428 buf
.puts (explicit_loc
->function_name
);
432 if (explicit_loc
->label_name
!= NULL
)
437 buf
.puts ("-label ");
438 buf
.puts (explicit_loc
->label_name
);
442 if (explicit_loc
->line_offset
.sign
!= LINE_OFFSET_UNKNOWN
)
449 (explicit_loc
->line_offset
.sign
== LINE_OFFSET_NONE
? ""
450 : (explicit_loc
->line_offset
.sign
451 == LINE_OFFSET_PLUS
? "+" : "-")),
452 explicit_loc
->line_offset
.offset
);
455 return buf
.release ();
458 /* See description in location.h. */
461 explicit_location_to_string (const struct explicit_location
*explicit_loc
)
463 return explicit_to_string_internal (false, explicit_loc
);
466 /* See description in location.h. */
469 explicit_location_to_linespec (const struct explicit_location
*explicit_loc
)
471 return explicit_to_string_internal (true, explicit_loc
);
474 /* See description in location.h. */
477 copy_event_location (const struct event_location
*src
)
479 return src
->clone ();
483 event_location_deleter::operator() (event_location
*location
) const
488 /* See description in location.h. */
491 event_location_to_string (struct event_location
*location
)
493 return location
->to_string ();
496 /* Find an instance of the quote character C in the string S that is
497 outside of all single- and double-quoted strings (i.e., any quoting
501 find_end_quote (const char *s
, char end_quote_char
)
503 /* zero if we're not in quotes;
504 '"' if we're in a double-quoted string;
505 '\'' if we're in a single-quoted string. */
506 char nested_quote_char
= '\0';
508 for (const char *scan
= s
; *scan
!= '\0'; scan
++)
510 if (nested_quote_char
!= '\0')
512 if (*scan
== nested_quote_char
)
513 nested_quote_char
= '\0';
514 else if (scan
[0] == '\\' && *(scan
+ 1) != '\0')
517 else if (*scan
== end_quote_char
&& nested_quote_char
== '\0')
519 else if (*scan
== '"' || *scan
== '\'')
520 nested_quote_char
= *scan
;
526 /* A lexer for explicit locations. This function will advance INP
527 past any strings that it lexes. Returns a malloc'd copy of the
528 lexed string or NULL if no lexing was done. */
530 static gdb::unique_xmalloc_ptr
<char>
531 explicit_location_lex_one (const char **inp
,
532 const struct language_defn
*language
,
533 explicit_completion_info
*completion_info
)
535 const char *start
= *inp
;
540 /* If quoted, skip to the ending quote. */
541 if (strchr (get_gdb_linespec_parser_quote_characters (), *start
))
543 if (completion_info
!= NULL
)
544 completion_info
->quoted_arg_start
= start
;
546 const char *end
= find_end_quote (start
+ 1, *start
);
550 if (completion_info
== NULL
)
551 error (_("Unmatched quote, %s."), start
);
553 end
= start
+ strlen (start
);
555 return gdb::unique_xmalloc_ptr
<char> (savestring (start
+ 1,
559 if (completion_info
!= NULL
)
560 completion_info
->quoted_arg_end
= end
;
562 return gdb::unique_xmalloc_ptr
<char> (savestring (start
+ 1,
566 /* If the input starts with '-' or '+', the string ends with the next
567 whitespace or comma. */
568 if (*start
== '-' || *start
== '+')
570 while (*inp
[0] != '\0' && *inp
[0] != ',' && !isspace (*inp
[0]))
575 /* Handle numbers first, stopping at the next whitespace or ','. */
576 while (isdigit (*inp
[0]))
578 if (*inp
[0] == '\0' || isspace (*inp
[0]) || *inp
[0] == ',')
579 return gdb::unique_xmalloc_ptr
<char> (savestring (start
,
582 /* Otherwise stop at the next occurrence of whitespace, '\0',
587 && !(isspace ((*inp
)[0])
588 || linespec_lexer_lex_keyword (&(*inp
)[1])))
590 /* Special case: C++ operator,. */
591 if (language
->la_language
== language_cplus
592 && startswith (*inp
, CP_OPERATOR_STR
))
593 (*inp
) += CP_OPERATOR_LEN
;
598 if (*inp
- start
> 0)
599 return gdb::unique_xmalloc_ptr
<char> (savestring (start
, *inp
- start
));
604 /* Return true if COMMA points past "operator". START is the start of
605 the line that COMMAND points to, hence when reading backwards, we
606 must not read any character before START. */
609 is_cp_operator (const char *start
, const char *comma
)
612 && (comma
- start
) >= CP_OPERATOR_LEN
)
614 const char *p
= comma
;
616 while (p
> start
&& isspace (p
[-1]))
618 if (p
- start
>= CP_OPERATOR_LEN
)
620 p
-= CP_OPERATOR_LEN
;
621 if (strncmp (p
, CP_OPERATOR_STR
, CP_OPERATOR_LEN
) == 0
623 || !(isalnum (p
[-1]) || p
[-1] == '_')))
632 /* When scanning the input string looking for the next explicit
633 location option/delimiter, we jump to the next option by looking
634 for ",", and "-". Such a character can also appear in C++ symbols
635 like "operator," and "operator-". So when we find such a
636 character, we call this function to check if we found such a
637 symbol, meaning we had a false positive for an option string. In
638 that case, we keep looking for the next delimiter, until we find
639 one that is not a false positive, or we reach end of string. FOUND
640 is the character that scanning found (either '-' or ','), and START
641 is the start of the line that FOUND points to, hence when reading
642 backwards, we must not read any character before START. Returns a
643 pointer to the next non-false-positive delimiter character, or NULL
644 if none was found. */
647 skip_op_false_positives (const char *start
, const char *found
)
649 while (found
!= NULL
&& is_cp_operator (start
, found
))
651 if (found
[0] == '-' && found
[1] == '-')
655 found
= find_toplevel_char (start
, *found
);
661 /* Assuming both FIRST and NEW_TOK point into the same string, return
662 the pointer that is closer to the start of the string. If FIRST is
663 NULL, returns NEW_TOK. If NEW_TOK is NULL, returns FIRST. */
666 first_of (const char *first
, const char *new_tok
)
670 else if (new_tok
!= NULL
&& new_tok
< first
)
676 /* A lexer for functions in explicit locations. This function will
677 advance INP past a function until the next option, or until end of
678 string. Returns a malloc'd copy of the lexed string or NULL if no
681 static gdb::unique_xmalloc_ptr
<char>
682 explicit_location_lex_one_function (const char **inp
,
683 const struct language_defn
*language
,
684 explicit_completion_info
*completion_info
)
686 const char *start
= *inp
;
691 /* If quoted, skip to the ending quote. */
692 if (strchr (get_gdb_linespec_parser_quote_characters (), *start
))
694 char quote_char
= *start
;
696 /* If the input is not an Ada operator, skip to the matching
697 closing quote and return the string. */
698 if (!(language
->la_language
== language_ada
699 && quote_char
== '\"' && is_ada_operator (start
)))
701 if (completion_info
!= NULL
)
702 completion_info
->quoted_arg_start
= start
;
704 const char *end
= find_toplevel_char (start
+ 1, quote_char
);
708 if (completion_info
== NULL
)
709 error (_("Unmatched quote, %s."), start
);
711 end
= start
+ strlen (start
);
713 char *saved
= savestring (start
+ 1, *inp
- start
- 1);
714 return gdb::unique_xmalloc_ptr
<char> (saved
);
717 if (completion_info
!= NULL
)
718 completion_info
->quoted_arg_end
= end
;
720 char *saved
= savestring (start
+ 1, *inp
- start
- 2);
721 return gdb::unique_xmalloc_ptr
<char> (saved
);
725 const char *comma
= find_toplevel_char (start
, ',');
727 /* If we have "-function -myfunction", or perhaps better example,
728 "-function -[BasicClass doIt]" (objc selector), treat
729 "-myfunction" as the function name. I.e., skip the first char if
730 it is an hyphen. Don't skip the first char always, because we
731 may have C++ "operator<", and find_toplevel_char needs to see the
735 ? find_toplevel_char (start
+ 1, '-')
736 : find_toplevel_char (start
, '-'));
738 /* Check for C++ "operator," and "operator-". */
739 comma
= skip_op_false_positives (start
, comma
);
740 hyphen
= skip_op_false_positives (start
, hyphen
);
742 /* Pick the one that appears first. */
743 const char *end
= first_of (hyphen
, comma
);
745 /* See if a linespec keyword appears first. */
746 const char *s
= start
;
747 const char *ws
= find_toplevel_char (start
, ' ');
748 while (ws
!= NULL
&& linespec_lexer_lex_keyword (ws
+ 1) == NULL
)
751 ws
= find_toplevel_char (s
, ' ');
754 end
= first_of (end
, ws
+ 1);
756 /* If we don't have any terminator, then take the whole string. */
758 end
= start
+ strlen (start
);
760 /* Trim whitespace at the end. */
761 while (end
> start
&& end
[-1] == ' ')
766 if (*inp
- start
> 0)
767 return gdb::unique_xmalloc_ptr
<char> (savestring (start
, *inp
- start
));
772 /* See description in location.h. */
775 string_to_explicit_location (const char **argp
,
776 const struct language_defn
*language
,
777 explicit_completion_info
*completion_info
)
779 /* It is assumed that input beginning with '-' and a non-digit
780 character is an explicit location. "-p" is reserved, though,
781 for probe locations. */
785 || !isalpha ((*argp
)[1])
786 || ((*argp
)[0] == '-' && (*argp
)[1] == 'p'))
789 std::unique_ptr
<event_location_explicit
> location
790 (new event_location_explicit ((const explicit_location
*) nullptr));
792 /* Process option/argument pairs. dprintf_command
793 requires that processing stop on ','. */
794 while ((*argp
)[0] != '\0' && (*argp
)[0] != ',')
799 /* Clear these on each iteration, since they should be filled
800 with info about the last option. */
801 if (completion_info
!= NULL
)
803 completion_info
->quoted_arg_start
= NULL
;
804 completion_info
->quoted_arg_end
= NULL
;
807 /* If *ARGP starts with a keyword, stop processing
809 if (linespec_lexer_lex_keyword (*argp
) != NULL
)
812 /* Mark the start of the string in case we need to rewind. */
815 if (completion_info
!= NULL
)
816 completion_info
->last_option
= start
;
818 /* Get the option string. */
819 gdb::unique_xmalloc_ptr
<char> opt
820 = explicit_location_lex_one (argp
, language
, NULL
);
822 /* Use the length of the option to allow abbreviations. */
823 len
= strlen (opt
.get ());
825 /* Get the argument string. */
826 *argp
= skip_spaces (*argp
);
828 /* All options have a required argument. Checking for this
829 required argument is deferred until later. */
830 gdb::unique_xmalloc_ptr
<char> oarg
;
831 /* True if we have an argument. This is required because we'll
832 move from OARG before checking whether we have an
834 bool have_oarg
= false;
836 /* True if the option needs an argument. */
837 bool need_oarg
= false;
839 /* Convenience to consistently set both OARG/HAVE_OARG from
841 auto set_oarg
= [&] (gdb::unique_xmalloc_ptr
<char> arg
)
843 if (completion_info
!= NULL
)
845 /* We do this here because the set of options that take
846 arguments matches the set of explicit location
848 completion_info
->saw_explicit_location_option
= true;
850 oarg
= std::move (arg
);
851 have_oarg
= oarg
!= NULL
;
855 if (strncmp (opt
.get (), "-source", len
) == 0)
857 set_oarg (explicit_location_lex_one (argp
, language
,
859 location
->explicit_loc
.source_filename
= oarg
.release ();
861 else if (strncmp (opt
.get (), "-function", len
) == 0)
863 set_oarg (explicit_location_lex_one_function (argp
, language
,
865 location
->explicit_loc
.function_name
= oarg
.release ();
867 else if (strncmp (opt
.get (), "-qualified", len
) == 0)
869 location
->explicit_loc
.func_name_match_type
870 = symbol_name_match_type::FULL
;
872 else if (strncmp (opt
.get (), "-line", len
) == 0)
874 set_oarg (explicit_location_lex_one (argp
, language
, NULL
));
875 *argp
= skip_spaces (*argp
);
878 location
->explicit_loc
.line_offset
879 = linespec_parse_line_offset (oarg
.get ());
883 else if (strncmp (opt
.get (), "-label", len
) == 0)
885 set_oarg (explicit_location_lex_one (argp
, language
, completion_info
));
886 location
->explicit_loc
.label_name
= oarg
.release ();
888 /* Only emit an "invalid argument" error for options
889 that look like option strings. */
890 else if (opt
.get ()[0] == '-' && !isdigit (opt
.get ()[1]))
892 if (completion_info
== NULL
)
893 error (_("invalid explicit location argument, \"%s\""), opt
.get ());
897 /* End of the explicit location specification.
898 Stop parsing and return whatever explicit location was
904 *argp
= skip_spaces (*argp
);
906 /* It's a little lame to error after the fact, but in this
907 case, it provides a much better user experience to issue
908 the "invalid argument" error before any missing
910 if (need_oarg
&& !have_oarg
&& completion_info
== NULL
)
911 error (_("missing argument for \"%s\""), opt
.get ());
914 /* One special error check: If a source filename was given
915 without offset, function, or label, issue an error. */
916 if (location
->explicit_loc
.source_filename
!= NULL
917 && location
->explicit_loc
.function_name
== NULL
918 && location
->explicit_loc
.label_name
== NULL
919 && (location
->explicit_loc
.line_offset
.sign
== LINE_OFFSET_UNKNOWN
)
920 && completion_info
== NULL
)
922 error (_("Source filename requires function, label, or "
926 return event_location_up (location
.release ());
929 /* See description in location.h. */
932 string_to_event_location_basic (const char **stringp
,
933 const struct language_defn
*language
,
934 symbol_name_match_type match_type
)
936 event_location_up location
;
939 /* Try the input as a probe spec. */
941 if (cs
!= NULL
&& probe_linespec_to_static_ops (&cs
) != NULL
)
943 location
= new_probe_location (*stringp
);
944 *stringp
+= strlen (*stringp
);
948 /* Try an address location. */
949 if (*stringp
!= NULL
&& **stringp
== '*')
951 const char *arg
, *orig
;
954 orig
= arg
= *stringp
;
955 addr
= linespec_expression_to_pc (&arg
);
956 location
= new_address_location (addr
, orig
, arg
- orig
);
957 *stringp
+= arg
- orig
;
961 /* Everything else is a linespec. */
962 location
= new_linespec_location (stringp
, match_type
);
969 /* See description in location.h. */
972 string_to_event_location (const char **stringp
,
973 const struct language_defn
*language
,
974 symbol_name_match_type match_type
)
976 const char *arg
, *orig
;
978 /* Try an explicit location. */
979 orig
= arg
= *stringp
;
980 event_location_up location
= string_to_explicit_location (&arg
, language
, NULL
);
981 if (location
!= NULL
)
983 /* It was a valid explicit location. Advance STRINGP to
985 *stringp
+= arg
- orig
;
987 /* If the user really specified a location, then we're done. */
988 if (!event_location_empty_p (location
.get ()))
991 /* Otherwise, the user _only_ specified optional flags like
992 "-qualified", otherwise string_to_explicit_location would
993 have thrown an error. Save the flags for "basic" linespec
994 parsing below and discard the explicit location. */
995 event_location_explicit
*xloc
996 = dynamic_cast<event_location_explicit
*> (location
.get ());
997 gdb_assert (xloc
!= nullptr);
998 match_type
= xloc
->explicit_loc
.func_name_match_type
;
1001 /* Everything else is a "basic" linespec, address, or probe
1003 return string_to_event_location_basic (stringp
, language
, match_type
);
1006 /* See description in location.h. */
1009 event_location_empty_p (const struct event_location
*location
)
1011 return location
->empty_p ();
1014 /* See description in location.h. */
1017 set_event_location_string (struct event_location
*location
,
1018 std::string
&&string
)
1020 location
->as_string
= std::move (string
);