aboutsummaryrefslogtreecommitdiff
path: root/gdb/linespec.c
diff options
context:
space:
mode:
authorKeith Seitz <keiths@redhat.com>2015-08-11 17:09:36 -0700
committerKeith Seitz <keiths@redhat.com>2015-08-11 17:09:36 -0700
commit87f0e7204722a986f79f245eee716f0870832d47 (patch)
tree80936c86b139d303a7139c46ae00b55f89c91f8d /gdb/linespec.c
parent00e52e5376c7ec604a739e6242e6be36221162d7 (diff)
downloadgdb-87f0e7204722a986f79f245eee716f0870832d47.zip
gdb-87f0e7204722a986f79f245eee716f0870832d47.tar.gz
gdb-87f0e7204722a986f79f245eee716f0870832d47.tar.bz2
Explicit locations: add UI features for CLI
This patch exposes explicit locations to the CLI user. This enables users to "explicitly" specify attributes of the breakpoint location to avoid any ambiguity that might otherwise exist with linespecs. The general syntax of explicit locations is: -source SOURCE_FILENAME -line {+-}LINE -function FUNCTION_NAME -label LABEL_NAME Option names may be abbreviated, e.g., "-s SOURCE_FILENAME -li 3" and users may use the completer with either options or values. gdb/ChangeLog: * completer.c: Include location.h. (enum match_type): New enum. (location_completer): Rename to ... (linespec_completer): ... this. (collect_explicit_location_matches, backup_text_ptr) (explicit_location_completer): New functions. (location_completer): "New" function; handle linespec and explicit location completions. (complete_line_internal): Remove all location completer-specific handling. * linespec.c (linespec_lexer_lex_keyword, is_ada_operator) (find_toplevel_char): Export. (linespec_parse_line_offset): Export. Issue error if STRING is not numerical. (gdb_get_linespec_parser_quote_characters): New function. * linespec.h (linespec_parse_line_offset): Declare. (get_gdb_linespec_parser_quote_characters): Declare. (is_ada_operator): Declare. (find_toplevel_char): Declare. (linespec_lexer_lex_keyword): Declare. * location.c (explicit_to_event_location): New function. (explicit_location_lex_one): New function. (string_to_explicit_location): New function. (string_to_event_location): Handle explicit locations. * location.h (explicit_to_event_location): Declare. (string_to_explicit_location): Declare. gdb/testsuite/ChangeLog: * gdb.linespec/3explicit.c: New file. * gdb.linespec/cpexplicit.cc: New file. * gdb.linespec/cpexplicit.exp: New file. * gdb.linespec/explicit.c: New file. * gdb.linespec/explicit.exp: New file. * gdb.linespec/explicit2.c: New file. * gdb.linespec/ls-errs.exp: Add explicit location tests. * lib/gdb.exp (capture_command_output): Regexp-escape `command' before using in the matching pattern. Clarify that `prefix' is a regular expression.
Diffstat (limited to 'gdb/linespec.c')
-rw-r--r--gdb/linespec.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 84e518f..ff8ae05 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -323,8 +323,6 @@ static int compare_symbols (const void *a, const void *b);
static int compare_msymbols (const void *a, const void *b);
-static const char *find_toplevel_char (const char *s, char c);
-
/* Permitted quote characters for the parser. This is different from the
completer's quote characters to allow backward compatibility with the
previous parser. */
@@ -419,10 +417,9 @@ linespec_lexer_lex_keyword (const char *p)
return NULL;
}
-/* Does STRING represent an Ada operator? If so, return the length
- of the decoded operator name. If not, return 0. */
+/* See description in linespec.h. */
-static int
+int
is_ada_operator (const char *string)
{
const struct ada_opname_map *mapping;
@@ -1140,7 +1137,7 @@ find_methods (struct type *t, const char *name,
strings. Also, ignore the char within a template name, like a ','
within foo<int, int>. */
-static const char *
+const char *
find_toplevel_char (const char *s, char c)
{
int quoted = 0; /* zero if we're not in quotes;
@@ -1551,11 +1548,12 @@ source_file_not_found_error (const char *name)
throw_error (NOT_FOUND_ERROR, _("No source file named %s."), name);
}
-/* Parse and return a line offset in STRING. */
+/* See description in linespec.h. */
-static struct line_offset
+struct line_offset
linespec_parse_line_offset (const char *string)
{
+ const char *start = string;
struct line_offset line_offset = {0, LINE_OFFSET_NONE};
if (*string == '+')
@@ -1569,6 +1567,9 @@ linespec_parse_line_offset (const char *string)
++string;
}
+ if (*string != '\0' && !isdigit (*string))
+ error (_("malformed line offset: \"%s\""), start);
+
/* Right now, we only allow base 10 for offsets. */
line_offset.offset = atoi (string);
return line_offset;
@@ -3903,3 +3904,11 @@ make_cleanup_destroy_linespec_result (struct linespec_result *ls)
{
return make_cleanup (cleanup_linespec_result, ls);
}
+
+/* Return the quote characters permitted by the linespec parser. */
+
+const char *
+get_gdb_linespec_parser_quote_characters (void)
+{
+ return linespec_quote_characters;
+}