diff options
author | Tom Tromey <tom@tromey.com> | 2022-03-03 20:25:32 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2022-03-06 10:50:42 -0700 |
commit | 13835d88dc51497b9bd68dc1f394ca0de099a380 (patch) | |
tree | 8eb0097fbf3bd76149d0fffef65f0924b3f32eef /gdb/tracepoint.c | |
parent | abed5aa88ab304caa3a9e3b812f0dab06d44bdcf (diff) | |
download | gdb-13835d88dc51497b9bd68dc1f394ca0de099a380.zip gdb-13835d88dc51497b9bd68dc1f394ca0de099a380.tar.gz gdb-13835d88dc51497b9bd68dc1f394ca0de099a380.tar.bz2 |
Use function view when iterating over block symbols
This changes iterate_over_block_local_vars and
iterate_over_block_arg_vars to take a gdb::function_view rather than a
function pointer and a user-data. In one spot, this allows us to
remove a helper structure and helper function. In another spot, this
looked more complicated, so I changed the helper function to be an
"operator()" -- also a simplification, just not as big.
Diffstat (limited to 'gdb/tracepoint.c')
-rw-r--r-- | gdb/tracepoint.c | 55 |
1 files changed, 13 insertions, 42 deletions
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 9386880..67b3118 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -1041,36 +1041,6 @@ collection_list::collect_symbol (struct symbol *sym, } } -/* Data to be passed around in the calls to the locals and args - iterators. */ - -struct add_local_symbols_data -{ - struct collection_list *collect; - struct gdbarch *gdbarch; - CORE_ADDR pc; - long frame_regno; - long frame_offset; - int count; - int trace_string; -}; - -/* The callback for the locals and args iterators. */ - -static void -do_collect_symbol (const char *print_name, - struct symbol *sym, - void *cb_data) -{ - struct add_local_symbols_data *p = (struct add_local_symbols_data *) cb_data; - - p->collect->collect_symbol (sym, p->gdbarch, p->frame_regno, - p->frame_offset, p->pc, p->trace_string); - p->count++; - - p->collect->add_wholly_collected (print_name); -} - void collection_list::add_wholly_collected (const char *print_name) { @@ -1085,15 +1055,16 @@ collection_list::add_local_symbols (struct gdbarch *gdbarch, CORE_ADDR pc, int trace_string) { const struct block *block; - struct add_local_symbols_data cb_data; + int count = 0; - cb_data.collect = this; - cb_data.gdbarch = gdbarch; - cb_data.pc = pc; - cb_data.frame_regno = frame_regno; - cb_data.frame_offset = frame_offset; - cb_data.count = 0; - cb_data.trace_string = trace_string; + auto do_collect_symbol = [&] (const char *print_name, + struct symbol *sym) + { + collect_symbol (sym, gdbarch, frame_regno, + frame_offset, pc, trace_string); + count++; + add_wholly_collected (print_name); + }; if (type == 'L') { @@ -1105,8 +1076,8 @@ collection_list::add_local_symbols (struct gdbarch *gdbarch, CORE_ADDR pc, return; } - iterate_over_block_local_vars (block, do_collect_symbol, &cb_data); - if (cb_data.count == 0) + iterate_over_block_local_vars (block, do_collect_symbol); + if (count == 0) warning (_("No locals found in scope.")); } else @@ -1119,8 +1090,8 @@ collection_list::add_local_symbols (struct gdbarch *gdbarch, CORE_ADDR pc, return; } - iterate_over_block_arg_vars (block, do_collect_symbol, &cb_data); - if (cb_data.count == 0) + iterate_over_block_arg_vars (block, do_collect_symbol); + if (count == 0) warning (_("No args found in scope.")); } } |