Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2018-10-24 15:20:25 -0400
committerEugene Tarassov2018-10-24 20:47:21 -0400
commite8a36aac8d68d10a89ef45016058a17a3649abeb (patch)
treeccdf54cc830e1f6bcc55e03ddacfe7c721792b12
parenta4745581ccb5ad7aa3c614d574f56ee04e23e63e (diff)
downloadorg.eclipse.tcf.agent-e8a36aac8d68d10a89ef45016058a17a3649abeb.tar.gz
org.eclipse.tcf.agent-e8a36aac8d68d10a89ef45016058a17a3649abeb.tar.xz
org.eclipse.tcf.agent-e8a36aac8d68d10a89ef45016058a17a3649abeb.zip
TCF Agent: Breakpoints service: when possible, limit line breakpoint to beginning of a statement
-rw-r--r--agent/tcf/services/breakpoints.c28
-rw-r--r--tests/test-dwarf/tcf/backend/backend.c5
2 files changed, 29 insertions, 4 deletions
diff --git a/agent/tcf/services/breakpoints.c b/agent/tcf/services/breakpoints.c
index 83764522..4448f971 100644
--- a/agent/tcf/services/breakpoints.c
+++ b/agent/tcf/services/breakpoints.c
@@ -265,7 +265,11 @@ static int planted_sw_bp_cnt = 0;
static int bp_location_error = 0;
#if ENABLE_LineNumbers
-static int bp_line_cnt = 0;
+static unsigned bp_line_cnt = 0;
+static unsigned bp_stmt_cnt = 0;
+static unsigned bp_line_addr_cnt = 0;
+static unsigned bp_line_addr_max = 0;
+static ContextAddress * bp_line_addr = NULL;
#endif
static TCFBroadcastGroup * broadcast_group = NULL;
@@ -1704,7 +1708,17 @@ static void plant_breakpoint_address_iterator(CodeArea * area, void * x) {
/* Adjust breakpoint address <addr> if needed */
BREAKPOINT_ADDR_ADJUST;
#endif
- plant_breakpoint(args->ctx, args->bp, addr, 1);
+ if ((addr == area->start_address && area->is_statement) || addr == area->next_stmt_address) {
+ plant_breakpoint(args->ctx, args->bp, addr, 1);
+ bp_stmt_cnt++;
+ }
+ else {
+ if (bp_line_addr_cnt >= bp_line_addr_max) {
+ bp_line_addr_max += 256;
+ bp_line_addr = (ContextAddress *)tmp_realloc(bp_line_addr, sizeof(ContextAddress) * bp_line_addr_max);
+ }
+ bp_line_addr[bp_line_addr_cnt++] = addr;
+ }
}
else {
plant_at_address_expression(args->ctx, area->start_address, args->bp);
@@ -1871,12 +1885,22 @@ static void evaluate_bp_location(void * x) {
if (bp->file != NULL) {
#if ENABLE_LineNumbers
bp_line_cnt = 0;
+ bp_stmt_cnt = 0;
+ bp_line_addr_cnt = 0;
+ bp_line_addr_max = 0;
+ bp_line_addr = NULL;
if (line_to_address(ctx, bp->file, bp->line, bp->column, plant_breakpoint_address_iterator, args) < 0) {
bp_location_error = errno;
}
else if (bp_line_cnt == 0) {
bp_location_error = set_errno(ERR_OTHER, "Unresolved source line information");
}
+ else if (bp_stmt_cnt == 0) {
+ unsigned i;
+ for (i = 0; i < bp_line_addr_cnt; i++) {
+ plant_breakpoint(ctx, bp, bp_line_addr[i], 1);
+ }
+ }
#else
bp_location_error = set_errno(ERR_UNSUPPORTED, "LineNumbers service not available");
#endif
diff --git a/tests/test-dwarf/tcf/backend/backend.c b/tests/test-dwarf/tcf/backend/backend.c
index c5221d28..fb7df57b 100644
--- a/tests/test-dwarf/tcf/backend/backend.c
+++ b/tests/test-dwarf/tcf/backend/backend.c
@@ -333,8 +333,9 @@ static void addr_to_line_callback_p1(CodeArea * area, void * args) {
static void line_to_addr_callback(CodeArea * area, void * args) {
CodeArea * org = (CodeArea *)args;
- if (area->start_line > org->start_line || (area->start_line == org->start_line && area->start_column > org->start_column) ||
- area->end_line < org->start_line || (area->end_line == org->start_line && area->end_column <= org->start_column)) {
+ if (area->start_line > org->start_line || area->end_line < org->start_line ||
+ (org->start_column && area->start_line == org->start_line && area->start_column > org->start_column) ||
+ (org->start_column && area->end_line == org->start_line && area->end_column <= org->start_column)) {
errno = set_errno(ERR_OTHER, "Invalid line area line numbers");
error("line_to_address");
}

Back to the top