Index: breakpoint.c =================================================================== RCS file: /cvs/src/src/gdb/breakpoint.c,v retrieving revision 1.668 diff -u -p -r1.668 breakpoint.c --- breakpoint.c 24 Apr 2012 14:33:12 -0000 1.668 +++ breakpoint.c 27 Apr 2012 07:55:09 -0000 @@ -8528,7 +8528,7 @@ parse_breakpoint_sals (char **address, /* If no arg given, or if first arg is 'if ', use the default breakpoint. */ - if ((*address) == NULL + if ((*address) == NULL || (*skip_spaces (*address)) == '\0' || (strncmp ((*address), "if", 2) == 0 && isspace ((*address)[2]))) { /* The last displayed codepoint, if it's valid, is our default breakpoint @@ -10054,7 +10054,7 @@ watch_command_1 (char *arg, int accessfl struct watchpoint *w; /* Make sure that we actually have parameters to parse. */ - if (arg != NULL && arg[0] != '\0') + if (arg != NULL && (*skip_spaces (arg)) != '\0') { char *value_start; Index: doc/gdb.texinfo =================================================================== RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v retrieving revision 1.950 diff -u -p -r1.950 gdb.texinfo --- doc/gdb.texinfo 25 Apr 2012 16:13:17 -0000 1.950 +++ doc/gdb.texinfo 27 Apr 2012 07:55:14 -0000 @@ -24981,12 +24981,16 @@ Return the symbol table's source absolut Python code can manipulate breakpoints via the @code{gdb.Breakpoint} class. -@defun Breakpoint.__init__ (spec @r{[}, type @r{[}, wp_class @r{[},internal@r{]]]}) +@defun Breakpoint.__init__ (@r{[}spec @r{[}, type @r{[}, wp_class @r{[},internal@r{]]]]}) Create a new breakpoint. @var{spec} is a string naming the location of the breakpoint, or an expression that defines a watchpoint. The contents can be any location recognized by the @code{break} command, or in the case of a watchpoint, by the @code{watch} -command. The optional @var{type} denotes the breakpoint to create +command. For a breakpoint, omitting or setting @var{spec} to all white +space sets a breakpoint at the current execution address of the selected +stack frame. For a watchpoint, @var{spec} should not be omitted and +should be a valid expression in the current context of the program being +debugged. The optional @var{type} denotes the breakpoint to create from the types defined later in this chapter. This argument can be either: @code{gdb.BP_BREAKPOINT} or @code{gdb.BP_WATCHPOINT}. @var{type} defaults to @code{gdb.BP_BREAKPOINT}. The optional @var{internal} argument Index: python/py-breakpoint.c =================================================================== RCS file: /cvs/src/src/gdb/python/py-breakpoint.c,v retrieving revision 1.33 diff -u -p -r1.33 py-breakpoint.c --- python/py-breakpoint.c 13 Mar 2012 13:30:42 -0000 1.33 +++ python/py-breakpoint.c 27 Apr 2012 07:55:14 -0000 @@ -590,14 +590,14 @@ static int bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) { static char *keywords[] = { "spec", "type", "wp_class", "internal", NULL }; - const char *spec; + const char *spec = NULL; int type = bp_breakpoint; int access_type = hw_write; PyObject *internal = NULL; int internal_bp = 0; volatile struct gdb_exception except; - if (! PyArg_ParseTupleAndKeywords (args, kwargs, "s|iiO", keywords, + if (! PyArg_ParseTupleAndKeywords (args, kwargs, "|ziiO", keywords, &spec, &type, &access_type, &internal)) return -1; @@ -614,8 +614,13 @@ bppy_init (PyObject *self, PyObject *arg TRY_CATCH (except, RETURN_MASK_ALL) { - char *copy = xstrdup (spec); - struct cleanup *cleanup = make_cleanup (xfree, copy); + char *copy = NULL; + struct cleanup *cleanup; + + if (spec) + copy = xstrdup (spec); + + cleanup = make_cleanup (xfree, copy); switch (type) { Index: testsuite/gdb.python/py-breakpoint.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-breakpoint.exp,v retrieving revision 1.14 diff -u -p -r1.14 py-breakpoint.exp --- testsuite/gdb.python/py-breakpoint.exp 16 Jan 2012 16:21:52 -0000 1.14 +++ testsuite/gdb.python/py-breakpoint.exp 27 Apr 2012 07:55:14 -0000 @@ -79,6 +79,14 @@ gdb_test "python print blist\[0\].number gdb_test "python print blist\[1\].number" "2" "Check breakpoint number" gdb_test "python print blist\[2\].number" "3" "Check breakpoint number" +# Test setting breakpoint at the current execution address. +gdb_py_test_silent_cmd "python blist_len = len(gdb.breakpoints())" "Get the number of breakpoints in the list" 0 +gdb_py_test_silent_cmd "python gdb.Breakpoint()" "Check breakpoint set at current execution address with spec omitted" 0 +gdb_py_test_silent_cmd "python gdb.Breakpoint(spec=\"\")" "Check breakpoint set at current execution address with NUL spec" 0 +gdb_py_test_silent_cmd "python gdb.Breakpoint(spec=\" \")" "Check breakpoint set at current execution address with white space spec" 0 +gdb_py_test_silent_cmd "python gdb.Breakpoint(spec=None)" "Check breakpoint set at current execution address with spec None" 0 +gdb_test "python print len(gdb.breakpoints()) == 4 + blist_len" "True" "Check addition of breakpoints" + # Start with a fresh gdb. clean_restart ${testfile}