From 41fac0cf495b84994046901e3293d54e8eef3534 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Mon, 2 Jun 2014 22:27:33 +0100 Subject: Installing a breakpoint on top of a dprintf makes GDB lose control. While the full fix for PR 15180 isn't in, it's best if we at least make sure that GDB doesn't lose control when a breakpoint is set at the same address as a dprintf. gdb/ 2014-06-02 Pedro Alves * breakpoint.c (build_target_command_list): Don't build a command list if we have any duplicate location that isn't a dprintf. gdb/testsuite/ 2014-06-02 Pedro Alves * gdb.base/dprintf-bp-same-addr.c: New file. * gdb.base/dprintf-bp-same-addr.exp: New file. --- gdb/breakpoint.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'gdb/breakpoint.c') diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index a966ba2..4e6c627 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -2351,14 +2351,26 @@ build_target_command_list (struct bp_location *bl) /* Release commands left over from a previous insert. */ VEC_free (agent_expr_p, bl->target_info.tcommands); - /* For now, limit to agent-style dprintf breakpoints. */ - if (bl->owner->type != bp_dprintf - || strcmp (dprintf_style, dprintf_style_agent) != 0) + if (!target_can_run_breakpoint_commands ()) return; - if (!target_can_run_breakpoint_commands ()) + /* For now, limit to agent-style dprintf breakpoints. */ + if (dprintf_style != dprintf_style_agent) return; + /* For now, if we have any duplicate location that isn't a dprintf, + don't install the target-side commands, as that would make the + breakpoint not be reported to the core, and we'd lose + control. */ + ALL_BP_LOCATIONS_AT_ADDR (loc2p, locp, bl->address) + { + loc = (*loc2p); + if (is_breakpoint (loc->owner) + && loc->pspace->num == bl->pspace->num + && loc->owner->type != bp_dprintf) + return; + } + /* Do a first pass to check for locations with no assigned conditions or conditions that fail to parse to a valid agent expression bytecode. If any of these happen, then it's no use to send conditions -- cgit v1.1