+2019-12-10 George Barrett <bob@bob131.so>
+
+ Fix scripted probe breakpoints.
+ * breakpoint.c (tracepoint_probe_breakpoint_ops): Move
+ declaration forward.
+ (breakpoint_ops_for_event_location_type)
+ (breakpoint_ops_for_event_location): Add function definitions.
+ (break_command_1, trace_command): Use
+ breakpoint_ops_for_event_location.
+ * breakpoint.h (breakpoint_ops_for_event_location): Add function
+ declarations.
+ * guile/scm-breakpoint.c (gdbscm_register_breakpoint_x): Use
+ breakpoint_ops_for_event_location.
+ * python/py-breakpoint.c (bppy_init): Use
+ breakpoint_ops_for_event_location.
+
2019-12-09 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* gdbtypes.c (rank_one_type): Return INCOMPATIBLE_TYPE_BADNESS
/* Breakpoints set on probes. */
static struct breakpoint_ops bkpt_probe_breakpoint_ops;
+/* Tracepoints set on probes. */
+static struct breakpoint_ops tracepoint_probe_breakpoint_ops;
+
/* Dynamic printf class type. */
struct breakpoint_ops dprintf_breakpoint_ops;
return sals;
}
+/* Returns the breakpoint ops appropriate for use with with LOCATION_TYPE and
+ according to IS_TRACEPOINT. */
+
+static const struct breakpoint_ops *
+breakpoint_ops_for_event_location_type (enum event_location_type location_type,
+ bool is_tracepoint)
+{
+ if (is_tracepoint)
+ {
+ if (location_type == PROBE_LOCATION)
+ return &tracepoint_probe_breakpoint_ops;
+ else
+ return &tracepoint_breakpoint_ops;
+ }
+ else
+ {
+ if (location_type == PROBE_LOCATION)
+ return &bkpt_probe_breakpoint_ops;
+ else
+ return &bkpt_breakpoint_ops;
+ }
+}
+
+/* See breakpoint.h. */
+
+const struct breakpoint_ops *
+breakpoint_ops_for_event_location (const struct event_location *location,
+ bool is_tracepoint)
+{
+ if (location != nullptr)
+ return breakpoint_ops_for_event_location_type
+ (event_location_type (location), is_tracepoint);
+ return is_tracepoint ? &tracepoint_breakpoint_ops : &bkpt_breakpoint_ops;
+}
+
/* See breakpoint.h. */
int
enum bptype type_wanted = (flag & BP_HARDWAREFLAG
? bp_hardware_breakpoint
: bp_breakpoint);
- struct breakpoint_ops *ops;
event_location_up location = string_to_event_location (&arg, current_language);
-
- /* Matching breakpoints on probes. */
- if (location != NULL
- && event_location_type (location.get ()) == PROBE_LOCATION)
- ops = &bkpt_probe_breakpoint_ops;
- else
- ops = &bkpt_breakpoint_ops;
+ const struct breakpoint_ops *ops = breakpoint_ops_for_event_location
+ (location.get (), false /* is_tracepoint */);
create_breakpoint (get_current_arch (),
location.get (),
struct breakpoint_ops tracepoint_breakpoint_ops;
-/* The breakpoint_ops structure to be use on tracepoints placed in a
- static probe. */
+/* Virtual table for tracepoints on static probes. */
static void
tracepoint_probe_create_sals_from_location
return bkpt_probe_decode_location (b, location, search_pspace);
}
-static struct breakpoint_ops tracepoint_probe_breakpoint_ops;
-
/* Dprintf breakpoint_ops methods. */
static void
static void
trace_command (const char *arg, int from_tty)
{
- struct breakpoint_ops *ops;
-
event_location_up location = string_to_event_location (&arg,
current_language);
- if (location != NULL
- && event_location_type (location.get ()) == PROBE_LOCATION)
- ops = &tracepoint_probe_breakpoint_ops;
- else
- ops = &tracepoint_breakpoint_ops;
+ const struct breakpoint_ops *ops = breakpoint_ops_for_event_location
+ (location.get (), true /* is_tracepoint */);
create_breakpoint (get_current_arch (),
location.get (),
extern void install_breakpoint (int internal, std::unique_ptr<breakpoint> &&b,
int update_gll);
+/* Returns the breakpoint ops appropriate for use with with LOCATION and
+ according to IS_TRACEPOINT. Use this to ensure, for example, that you pass
+ the correct ops to create_breakpoint for probe locations. If LOCATION is
+ NULL, returns bkpt_breakpoint_ops (or tracepoint_breakpoint_ops, if
+ IS_TRACEPOINT is true). */
+
+extern const struct breakpoint_ops *breakpoint_ops_for_event_location
+ (const struct event_location *location, bool is_tracepoint);
+
/* Flags that can be passed down to create_breakpoint, etc., to affect
breakpoint creation in several ways. */
{
case bp_breakpoint:
{
+ const breakpoint_ops *ops =
+ breakpoint_ops_for_event_location (eloc.get (), false);
create_breakpoint (get_current_arch (),
eloc.get (), NULL, -1, NULL,
0,
0, bp_breakpoint,
0,
AUTO_BOOLEAN_TRUE,
- &bkpt_breakpoint_ops,
+ ops,
0, 1, internal, 0);
break;
}
location = new_explicit_location (&explicit_loc);
}
+ const struct breakpoint_ops *ops =
+ breakpoint_ops_for_event_location (location.get (), false);
+
create_breakpoint (python_gdbarch,
location.get (), NULL, -1, NULL,
0,
temporary_bp, bp_breakpoint,
0,
AUTO_BOOLEAN_TRUE,
- &bkpt_breakpoint_ops,
+ ops,
0, 1, internal_bp, 0);
break;
}
+2019-12-10 George Barrett <bob@bob131.so>
+
+ Test scripted probe breakpoints.
+ * gdb.guile/scm-breakpoint.c (main): Add probe point.
+ * gdb.python/py-breakpoint.c (main): Likewise.
+ * gdb.guile/scm-breakpoint.exp (test_bkpt_probe): Add probe
+ specifier test.
+ * gdb.python/py-breakpoint.exp (test_bkpt_probe): Likewise.
+
2019-12-09 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* gdb.cp/rvalue-ref-overload.cc (g): New function that takes
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+#ifdef USE_PROBES
+#include <sys/sdt.h>
+#endif
+
int result = 0;
int multiply (int i)
{
result += multiply (foo); /* Break at multiply. */
result += add (bar); /* Break at add. */
+#ifdef USE_PROBES
+ DTRACE_PROBE1 (test, result_updated, result);
+#endif
}
return 0; /* Break at end. */
".*Breakpoint ($decimal)+ at .*$srcfile, line ($decimal)+\."
}
+proc test_bkpt_probe {} {
+ global decimal hex testfile srcfile
+
+ if { [prepare_for_testing "failed to prepare" ${testfile}-probes \
+ ${srcfile} {additional_flags=-DUSE_PROBES}] } {
+ return -1
+ }
+
+ if ![gdb_guile_runto_main] then {
+ return
+ }
+
+ gdb_scm_test_silent_cmd \
+ "guile (define bp1 (make-breakpoint \"-probe test:result_updated\"))" \
+ "create probe breakpoint"
+
+ gdb_test \
+ "guile (register-breakpoint! bp1)" \
+ "Breakpoint $decimal at $hex" \
+ "register probe breakpoint"
+}
+
test_bkpt_basic
test_bkpt_deletion
test_bkpt_cond_and_cmds
test_bkpt_eval_funcs
test_bkpt_registration
test_bkpt_address
+test_bkpt_probe
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+#ifdef USE_PROBES
+#include <sys/sdt.h>
+#endif
+
int result = 0;
namespace foo_ns
{
result += multiply (foo); /* Break at multiply. */
result += add (bar); /* Break at add. */
+#ifdef USE_PROBES
+ DTRACE_PROBE1 (test, result_updated, result);
+#endif
}
return 0; /* Break at end. */
"-q in spec string and qualified false"
}
+proc_with_prefix test_bkpt_probe {} {
+ global decimal hex testfile srcfile
+
+ if { [prepare_for_testing "failed to prepare" ${testfile}-probes \
+ ${srcfile} {debug c++ additional_flags=-DUSE_PROBES}] } {
+ return -1
+ }
+
+ if ![runto_main] then {
+ fail "cannot run to main."
+ return 0
+ }
+
+ gdb_test \
+ "python gdb.Breakpoint(\"-probe test:result_updated\")" \
+ "Breakpoint $decimal at $hex" \
+ "-probe in spec string"
+}
+
test_bkpt_basic
test_bkpt_deletion
test_bkpt_cond_and_cmds
test_bkpt_events
test_bkpt_explicit_loc
test_bkpt_qualified
+test_bkpt_probe