+2017-12-13 Simon Marchi <simon.marchi@ericsson.com>
+
+ * location.h (string_to_event_location): Add match_type
+ parameter.
+ * location.c (string_to_event_location): Likewise.
+ * python/py-breakpoint.c (bppy_init): Handle qualified
+ parameter.
+
2017-12-13 Pedro Alves <palves@redhat.com>
* completer.c (completion_tracker::maybe_add_completion): New
GDB interpret the specified function name as a complete
fully-qualified name instead. For example, using the same C++
program, the "break -q B::func" command sets a breakpoint on
- "B::func", only.
+ "B::func", only. A parameter has been added to the Python
+ gdb.Breakpoint constructor to achieve the same result when creating
+ a breakpoint from Python.
* Breakpoints on functions marked with C++ ABI tags
2017-12-13 Simon Marchi <simon.marchi@ericsson.com>
+ * python.texi (Manipulating breakpoints using Python): Document
+ qualified parameter to gdb.Breakpoint.
+
+2017-12-13 Simon Marchi <simon.marchi@ericsson.com>
+
* python.texi (Manipulating breakpoints using Python): Split doc
of Breakpoint.__init__ in two, split text in multiple
paragraphs, don't nest parameter square brackets.
arguments similar to @ref{Explicit Locations}, and can only be used to create
breakpoints.
-@defun Breakpoint.__init__ (spec @r{[}, type @r{][}, wp_class @r{][}, internal @r{][}, temporary @r{]})
+@defun Breakpoint.__init__ (spec @r{[}, type @r{][}, wp_class @r{][}, internal @r{][}, temporary @r{][}, qualified @r{]})
Create a new breakpoint according to @var{spec}, which is a string naming the
location of a breakpoint, or an expression that defines a watchpoint. The
string should describe a location in a format recognized by the @code{break}
breakpoint. Temporary breakpoints are deleted after they have been hit. Any
further access to the Python breakpoint after it has been hit will result in a
runtime error (as that breakpoint has now been automatically deleted).
+
+The optional @var{qualified} argument is a boolean that allows interpreting
+the function passed in @code{spec} as a fully-qualified name. It is equivalent
+to @code{break}'s @code{-qualified} flag (@pxref{Linespec Locations} and
+@ref{Explicit Locations}).
+
@end defun
-@defun Breakpoint.__init__ (@r{[} source @r{][}, function @r{][}, label @r{][}, line @r{]}, @r{][} internal @r{][}, temporary @r{]})
+@defun Breakpoint.__init__ (@r{[} source @r{][}, function @r{][}, label @r{][}, line @r{]}, @r{][} internal @r{][}, temporary @r{][}, qualified @r{]})
This second form of creating a new breakpoint specifies the explicit
location (@pxref{Explicit Locations}) using keywords. The new breakpoint will
be created in the specified source file @var{source}, at the specified
@var{function}, @var{label} and @var{line}.
-@var{internal} and @var{temporary} have the same usage as explained previously.
+@var{internal}, @var{temporary} and @var{qualified} have the same usage as
+explained previously.
@end defun
The available types are represented by constants defined in the @code{gdb}
event_location_up
string_to_event_location (const char **stringp,
- const struct language_defn *language)
+ const struct language_defn *language,
+ symbol_name_match_type match_type)
{
const char *arg, *orig;
- symbol_name_match_type match_type = symbol_name_match_type::WILD;
/* Try an explicit location. */
orig = arg = *stringp;
This function is intended to be used by CLI commands and will parse
explicit locations in a CLI-centric way. Other interfaces should use
string_to_event_location_basic if they want to maintain support for
- legacy specifications of probe, address, and linespec locations. */
+ legacy specifications of probe, address, and linespec locations.
-extern event_location_up
- string_to_event_location (const char **argp,
- const struct language_defn *langauge);
+ MATCH_TYPE should be either WILD or FULL. If -q/--qualified is specified
+ in the input string, it will take precedence over this parameter. */
+
+extern event_location_up string_to_event_location
+ (const char **argp, const struct language_defn *langauge,
+ symbol_name_match_type match_type = symbol_name_match_type::WILD);
/* Like string_to_event_location, but does not attempt to parse
explicit locations. MATCH_TYPE indicates how function names should
{
static const char *keywords[] = { "spec", "type", "wp_class", "internal",
"temporary","source", "function",
- "label", "line", NULL };
+ "label", "line", "qualified", NULL };
const char *spec = NULL;
enum bptype type = bp_breakpoint;
int access_type = hw_write;
char *label = NULL;
char *source = NULL;
char *function = NULL;
+ int qualified = 0;
- if (!gdb_PyArg_ParseTupleAndKeywords (args, kwargs, "|siiOOsssO", keywords,
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kwargs, "|siiOOsssOp", keywords,
&spec, &type, &access_type,
&internal,
&temporary, &source,
- &function, &label, &lineobj))
+ &function, &label, &lineobj,
+ &qualified))
return -1;
case bp_breakpoint:
{
event_location_up location;
+ symbol_name_match_type func_name_match_type
+ = (qualified
+ ? symbol_name_match_type::FULL
+ : symbol_name_match_type::WILD);
if (spec != NULL)
{
const char *copy = copy_holder.get ();
location = string_to_event_location (©,
- current_language);
+ current_language,
+ func_name_match_type);
}
else
{
explicit_loc.line_offset =
linespec_parse_line_offset (line.get ());
+ explicit_loc.func_name_match_type = func_name_match_type;
+
location = new_explicit_location (&explicit_loc);
}
+2017-12-13 Simon Marchi <simon.marchi@ericsson.com>
+
+ * gdb.python/py-breakpoint.c (foo_ns::multiply): New function.
+ * gdb.python/py-breakpoint.exp: Compile the test case as c++,
+ call test_bkpt_qualified.
+ (test_bkpt_qualified): New proc.
+
2017-12-13 Pedro Alves <palves@redhat.com>
* lib/completion-support.exp (test_gdb_complete_tab_multiple):
int result = 0;
+namespace foo_ns
+{
+ int multiply (int i)
+ {
+ return i * i;
+ }
+}
+
int multiply (int i)
{
return i * i;
standard_testfile
-if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
+set options {debug c++}
+
+if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} ${options}] } {
return -1
}
"set invalid explicit breakpoint by missing function"
}
+proc_with_prefix test_bkpt_qualified {} {
+ global decimal hex testfile
+
+ # Start with a fresh gdb.
+ clean_restart ${testfile}
+
+ set one_location_re "Breakpoint $decimal at $hex:.*line $decimal."
+ set two_location_re "Breakpoint $decimal at $hex:.*2 locations."
+
+ if ![runto_main] then {
+ fail "cannot run to main."
+ return 0
+ }
+
+ # Test the default value of "qualified".
+ delete_breakpoints
+ gdb_test \
+ "python gdb.Breakpoint(\"multiply\")" \
+ $two_location_re \
+ "qualified implicitly false"
+
+ # Test qualified=False.
+ delete_breakpoints
+ gdb_test \
+ "python gdb.Breakpoint(\"multiply\", qualified=False)" \
+ $two_location_re \
+ "qualified false"
+
+ # Test qualified=True.
+ delete_breakpoints
+ gdb_test \
+ "python gdb.Breakpoint(\"multiply\", qualified=True)" \
+ $one_location_re \
+ "qualified true"
+
+ # Test qualified=True with an explicit function.
+ delete_breakpoints
+ gdb_test \
+ "python gdb.Breakpoint(function=\"multiply\", qualified=True)" \
+ $one_location_re \
+ "qualified true and explicit"
+
+ # Test qualified=False with an explicit function.
+ delete_breakpoints
+ gdb_test \
+ "python gdb.Breakpoint(function=\"multiply\", qualified=False)" \
+ $two_location_re \
+ "qualified false and explicit"
+
+ # Test -q in the spec string.
+ delete_breakpoints
+ gdb_test \
+ "python gdb.Breakpoint(\"-q multiply\")" \
+ $one_location_re \
+ "-q in spec string"
+
+ # Test -q in the spec string with explicit location.
+ delete_breakpoints
+ gdb_test \
+ "python gdb.Breakpoint(\"-q -function multiply\")" \
+ $one_location_re \
+ "-q in spec string with explicit location"
+
+ # Test -q in the spec string and qualified=False (-q should win).
+ delete_breakpoints
+ gdb_test \
+ "python gdb.Breakpoint(\"-q multiply\", qualified=False)" \
+ $one_location_re \
+ "-q in spec string and qualified false"
+}
+
test_bkpt_basic
test_bkpt_deletion
test_bkpt_cond_and_cmds
test_bkpt_pending
test_bkpt_events
test_bkpt_explicit_loc
+test_bkpt_qualified