aboutsummaryrefslogtreecommitdiff
path: root/gdb/linespec.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2010-07-13 20:07:44 +0000
committerTom Tromey <tromey@redhat.com>2010-07-13 20:07:44 +0000
commit0f5238edfdd060ff07a15df61aafdfe21fb6427f (patch)
treeadfbbce9ef20143b41a4b028e22ffdca16fb20fe /gdb/linespec.c
parent131687b4ade7fdff127269e3b92b01ec3d0872c7 (diff)
downloadfsf-binutils-gdb-0f5238edfdd060ff07a15df61aafdfe21fb6427f.zip
fsf-binutils-gdb-0f5238edfdd060ff07a15df61aafdfe21fb6427f.tar.gz
fsf-binutils-gdb-0f5238edfdd060ff07a15df61aafdfe21fb6427f.tar.bz2
gdb
PR breakpoints/8357: * symtab.h (domain_enum_tag) <LABEL_DOMAIN>: Update comment. * linespec.c (decode_line_1): Update comment. Call decode_label. (decode_label): New function. (symbol_found): Handle LOC_LABEL. * dwarf2read.c (new_symbol) <DW_TAG_label>: Set symbol's type and domain. Call add_symbol_to_list. gdb/doc * gdb.texinfo (Specify Location): Document labels. gdb/testsuite * gdb.base/label.exp: New file. * gdb.base/label.c: New file.
Diffstat (limited to 'gdb/linespec.c')
-rw-r--r--gdb/linespec.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 378c6c9..91c5b90 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -122,6 +122,9 @@ static struct symtabs_and_lines decode_dollar (char *copy,
char ***canonical,
struct symtab *file_symtab);
+static int decode_label (char *copy, char ***canonical,
+ struct symtabs_and_lines *result);
+
static struct symtabs_and_lines decode_variable (char *copy,
int funfirstline,
char ***canonical,
@@ -672,6 +675,7 @@ find_method_overload_end (char *p)
FILE:LINENUM -- that line in that file. PC returned is 0.
FUNCTION -- line number of openbrace of that function.
PC returned is the start of the function.
+ LABEL -- a label in the current scope
VARIABLE -- line number of definition of that variable.
PC returned is 0.
FILE:FUNCTION -- likewise, but prefer functions in that file.
@@ -903,6 +907,16 @@ decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab,
return decode_dollar (copy, funfirstline, default_symtab,
canonical, file_symtab);
+ /* Try the token as a label, but only if no file was specified,
+ because we can only really find labels in the current scope. */
+
+ if (!file_symtab)
+ {
+ struct symtabs_and_lines label_result;
+ if (decode_label (copy, canonical, &label_result))
+ return label_result;
+ }
+
/* Look up that token as a variable.
If file specified, use that file's per-file block to start with. */
@@ -1838,6 +1852,27 @@ decode_dollar (char *copy, int funfirstline, struct symtab *default_symtab,
+/* A helper for decode_line_1 that tries to find a label. The label
+ is searched for in the current block.
+ COPY is the name of the label to find.
+ CANONICAL is the same as the "canonical" argument to decode_line_1.
+ RESULT is a pointer to a symtabs_and_lines structure which will be
+ filled in on success.
+ This function returns 1 if a label was found, 0 otherwise. */
+
+static int
+decode_label (char *copy, char ***canonical, struct symtabs_and_lines *result)
+{
+ struct symbol *sym;
+
+ sym = lookup_symbol (copy, get_selected_block (0), LABEL_DOMAIN, 0);
+
+ if (sym != NULL)
+ *result = symbol_found (0, canonical, copy, sym, NULL);
+
+ return sym != NULL;
+}
+
/* Decode a linespec that's a variable. If FILE_SYMTAB is non-NULL,
look in that symtab's static variables first. If NOT_FOUND_PTR is not NULL and
the function cannot be found, store boolean true in the location pointed to
@@ -1917,7 +1952,7 @@ symbol_found (int funfirstline, char ***canonical, char *copy,
}
else
{
- if (funfirstline)
+ if (funfirstline && SYMBOL_CLASS (sym) != LOC_LABEL)
error (_("\"%s\" is not a function"), copy);
else if (SYMBOL_LINE (sym) != 0)
{
@@ -1928,6 +1963,7 @@ symbol_found (int funfirstline, char ***canonical, char *copy,
memset (&values.sals[0], 0, sizeof (values.sals[0]));
values.sals[0].symtab = SYMBOL_SYMTAB (sym);
values.sals[0].line = SYMBOL_LINE (sym);
+ values.sals[0].pspace = SYMTAB_PSPACE (SYMBOL_SYMTAB (sym));
return values;
}
else