Skip to content

Commit eedd8cb

Browse files
committed
Use the block which contains the symbol for breakpoint conditions
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=26651
1 parent 389946f commit eedd8cb

1 file changed

Lines changed: 28 additions & 10 deletions

File tree

gdb/breakpoint.c

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,19 @@ show_condition_evaluation_mode (struct ui_file *file, int from_tty,
10331033
value);
10341034
}
10351035

1036+
static const block *
1037+
block_for_pc_sym (CORE_ADDR pc, const symbol *sym)
1038+
{
1039+
if (sym != nullptr)
1040+
{
1041+
const block *b = sym->value_block ();
1042+
if (b != nullptr)
1043+
return b;
1044+
}
1045+
1046+
return block_for_pc (pc);
1047+
}
1048+
10361049
/* Parse COND_STRING in the context of LOC and set as the condition
10371050
expression of LOC. BP_NUM is the number of LOC's owner, LOC_NUM is
10381051
the number of LOC within its owner. In case of parsing error, mark
@@ -1046,7 +1059,8 @@ set_breakpoint_location_condition (const char *cond_string, bp_location *loc,
10461059
try
10471060
{
10481061
expression_up new_exp = parse_exp_1 (&cond_string, loc->address,
1049-
block_for_pc (loc->address), 0);
1062+
block_for_pc_sym (loc->address,
1063+
loc->symbol), 0);
10501064
if (*cond_string != 0)
10511065
has_junk = true;
10521066
else
@@ -1153,7 +1167,7 @@ set_breakpoint_condition (struct breakpoint *b, const char *exp,
11531167
{
11541168
const char *arg = exp;
11551169
parse_exp_1 (&arg, loc.address,
1156-
block_for_pc (loc.address), 0);
1170+
block_for_pc_sym (loc.address, loc.symbol), 0);
11571171
if (*arg != 0)
11581172
error (_("Junk at end of expression"));
11591173
break;
@@ -2599,7 +2613,7 @@ build_target_condition_list (struct bp_location *bl)
25992613
Return NULL if there was any error during parsing. */
26002614

26012615
static agent_expr_up
2602-
parse_cmd_to_aexpr (CORE_ADDR scope, char *cmd)
2616+
parse_cmd_to_aexpr (CORE_ADDR scope, const symbol *sym, char *cmd)
26032617
{
26042618
const char *cmdrest;
26052619
const char *format_start, *format_end;
@@ -2643,7 +2657,8 @@ parse_cmd_to_aexpr (CORE_ADDR scope, char *cmd)
26432657
const char *cmd1;
26442658

26452659
cmd1 = cmdrest;
2646-
expression_up expr = parse_exp_1 (&cmd1, scope, block_for_pc (scope),
2660+
expression_up expr = parse_exp_1 (&cmd1, scope,
2661+
block_for_pc_sym (scope, sym),
26472662
PARSER_COMMA_TERMINATES);
26482663
argvec.push_back (expr.release ());
26492664
cmdrest = cmd1;
@@ -2720,7 +2735,7 @@ build_target_command_list (struct bp_location *bl)
27202735
force_breakpoint_reinsertion). We just
27212736
need to parse the command to bytecodes again. */
27222737
loc->cmd_bytecode
2723-
= parse_cmd_to_aexpr (bl->address,
2738+
= parse_cmd_to_aexpr (bl->address, bl->symbol,
27242739
loc->owner->extra_string.get ());
27252740
}
27262741

@@ -8987,7 +9002,7 @@ check_fast_tracepoint_sals (struct gdbarch *gdbarch,
89879002
PC identifies the context at which the condition should be parsed. */
89889003

89899004
static void
8990-
find_condition_and_thread (const char *tok, CORE_ADDR pc,
9005+
find_condition_and_thread (const char *tok, const symtab_and_line &sal,
89919006
gdb::unique_xmalloc_ptr<char> *cond_string,
89929007
int *thread, int *inferior, int *task,
89939008
gdb::unique_xmalloc_ptr<char> *rest)
@@ -9023,7 +9038,8 @@ find_condition_and_thread (const char *tok, CORE_ADDR pc,
90239038
tok = cond_start = end_tok + 1;
90249039
try
90259040
{
9026-
parse_exp_1 (&tok, pc, block_for_pc (pc), 0);
9041+
parse_exp_1 (&tok, sal.pc,
9042+
block_for_pc_sym (sal.pc, sal.symbol), 0);
90279043
}
90289044
catch (const gdb_exception_error &)
90299045
{
@@ -9141,7 +9157,7 @@ find_condition_and_thread_for_sals (const std::vector<symtab_and_line> &sals,
91419157
condition in the context of each sal. */
91429158
try
91439159
{
9144-
find_condition_and_thread (input, sal.pc, &cond, &thread_id,
9160+
find_condition_and_thread (input, sal, &cond, &thread_id,
91459161
&inferior_id, &task_id, &remaining);
91469162
*cond_string = std::move (cond);
91479163
/* A value of -1 indicates that these fields are unset. At most
@@ -9377,7 +9393,8 @@ create_breakpoint (struct gdbarch *gdbarch,
93779393
const char *cond = cond_string;
93789394
try
93799395
{
9380-
parse_exp_1 (&cond, sal.pc, block_for_pc (sal.pc), 0);
9396+
parse_exp_1 (&cond, sal.pc,
9397+
block_for_pc_sym (sal.pc, sal.symbol), 0);
93819398
/* One success is sufficient to keep going. */
93829399
break;
93839400
}
@@ -13071,7 +13088,8 @@ update_breakpoint_locations (code_breakpoint *b,
1307113088
try
1307213089
{
1307313090
new_loc->cond = parse_exp_1 (&s, sal.pc,
13074-
block_for_pc (sal.pc),
13091+
block_for_pc_sym (sal.pc,
13092+
sal.symbol),
1307513093
0);
1307613094
}
1307713095
catch (const gdb_exception_error &e)

0 commit comments

Comments
 (0)