function name to avoid ambiguity when there are identically named
functions in different source files.
+@item @var{label}
+Specifies the line at which the label named @var{label} appears.
+@value{GDBN} searches for the label in the function corresponding to
+the currently selected stack frame. If there is no current selected
+stack frame (for instance, if the inferior is not running), then
+@value{GDBN} will not search for a label.
+
@item *@var{address}
Specifies the program address @var{address}. For line-oriented
commands, such as @code{list} and @code{edit}, this specifies a source
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,
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.
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. */
\f
+/* 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
}
else
{
- if (funfirstline)
+ if (funfirstline && SYMBOL_CLASS (sym) != LOC_LABEL)
error (_("\"%s\" is not a function"), copy);
else if (SYMBOL_LINE (sym) != 0)
{
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
--- /dev/null
+# Copyright 2010 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+
+if [is_remote target] then {
+ return 0
+}
+
+
+#
+# test running programs
+#
+
+set testfile "label"
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+
+if { [prepare_for_testing ${testfile}.exp $testfile ${testfile}.c debug] } {
+ untested label.exp
+ return -1
+}
+
+
+if {![runto_main]} {
+ fail "label tests suppressed"
+ return -1
+}
+
+gdb_test "break here" \
+ "Breakpoint.*at.*" \
+ "breakpoint here"
+
+gdb_test "break there" \
+ "Breakpoint.*at.*" \
+ "breakpoint there"
+
+gdb_test "cont" \
+ "Breakpoint 3,.*" \
+ "continue to 'there'"
+
+gdb_test "cont" \
+ "Breakpoint 2,.*" \
+ "continue to 'here'"