Skip to content

Commit

Permalink
Use the block which contains the symbol for breakpoint conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbssa committed Jul 7, 2024
1 parent 389946f commit eedd8cb
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions gdb/breakpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,19 @@ show_condition_evaluation_mode (struct ui_file *file, int from_tty,
value);
}

static const block *
block_for_pc_sym (CORE_ADDR pc, const symbol *sym)
{
if (sym != nullptr)
{
const block *b = sym->value_block ();
if (b != nullptr)
return b;
}

return block_for_pc (pc);
}

/* Parse COND_STRING in the context of LOC and set as the condition
expression of LOC. BP_NUM is the number of LOC's owner, LOC_NUM is
the number of LOC within its owner. In case of parsing error, mark
Expand All @@ -1046,7 +1059,8 @@ set_breakpoint_location_condition (const char *cond_string, bp_location *loc,
try
{
expression_up new_exp = parse_exp_1 (&cond_string, loc->address,
block_for_pc (loc->address), 0);
block_for_pc_sym (loc->address,
loc->symbol), 0);
if (*cond_string != 0)
has_junk = true;
else
Expand Down Expand Up @@ -1153,7 +1167,7 @@ set_breakpoint_condition (struct breakpoint *b, const char *exp,
{
const char *arg = exp;
parse_exp_1 (&arg, loc.address,
block_for_pc (loc.address), 0);
block_for_pc_sym (loc.address, loc.symbol), 0);
if (*arg != 0)
error (_("Junk at end of expression"));
break;
Expand Down Expand Up @@ -2599,7 +2613,7 @@ build_target_condition_list (struct bp_location *bl)
Return NULL if there was any error during parsing. */

static agent_expr_up
parse_cmd_to_aexpr (CORE_ADDR scope, char *cmd)
parse_cmd_to_aexpr (CORE_ADDR scope, const symbol *sym, char *cmd)
{
const char *cmdrest;
const char *format_start, *format_end;
Expand Down Expand Up @@ -2643,7 +2657,8 @@ parse_cmd_to_aexpr (CORE_ADDR scope, char *cmd)
const char *cmd1;

cmd1 = cmdrest;
expression_up expr = parse_exp_1 (&cmd1, scope, block_for_pc (scope),
expression_up expr = parse_exp_1 (&cmd1, scope,
block_for_pc_sym (scope, sym),
PARSER_COMMA_TERMINATES);
argvec.push_back (expr.release ());
cmdrest = cmd1;
Expand Down Expand Up @@ -2720,7 +2735,7 @@ build_target_command_list (struct bp_location *bl)
force_breakpoint_reinsertion). We just
need to parse the command to bytecodes again. */
loc->cmd_bytecode
= parse_cmd_to_aexpr (bl->address,
= parse_cmd_to_aexpr (bl->address, bl->symbol,
loc->owner->extra_string.get ());
}

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

static void
find_condition_and_thread (const char *tok, CORE_ADDR pc,
find_condition_and_thread (const char *tok, const symtab_and_line &sal,
gdb::unique_xmalloc_ptr<char> *cond_string,
int *thread, int *inferior, int *task,
gdb::unique_xmalloc_ptr<char> *rest)
Expand Down Expand Up @@ -9023,7 +9038,8 @@ find_condition_and_thread (const char *tok, CORE_ADDR pc,
tok = cond_start = end_tok + 1;
try
{
parse_exp_1 (&tok, pc, block_for_pc (pc), 0);
parse_exp_1 (&tok, sal.pc,
block_for_pc_sym (sal.pc, sal.symbol), 0);
}
catch (const gdb_exception_error &)
{
Expand Down Expand Up @@ -9141,7 +9157,7 @@ find_condition_and_thread_for_sals (const std::vector<symtab_and_line> &sals,
condition in the context of each sal. */
try
{
find_condition_and_thread (input, sal.pc, &cond, &thread_id,
find_condition_and_thread (input, sal, &cond, &thread_id,
&inferior_id, &task_id, &remaining);
*cond_string = std::move (cond);
/* A value of -1 indicates that these fields are unset. At most
Expand Down Expand Up @@ -9377,7 +9393,8 @@ create_breakpoint (struct gdbarch *gdbarch,
const char *cond = cond_string;
try
{
parse_exp_1 (&cond, sal.pc, block_for_pc (sal.pc), 0);
parse_exp_1 (&cond, sal.pc,
block_for_pc_sym (sal.pc, sal.symbol), 0);
/* One success is sufficient to keep going. */
break;
}
Expand Down Expand Up @@ -13071,7 +13088,8 @@ update_breakpoint_locations (code_breakpoint *b,
try
{
new_loc->cond = parse_exp_1 (&s, sal.pc,
block_for_pc (sal.pc),
block_for_pc_sym (sal.pc,
sal.symbol),
0);
}
catch (const gdb_exception_error &e)
Expand Down

0 comments on commit eedd8cb

Please sign in to comment.