return -1;
}
-/* Prototype of the callback passed to tframe_walk_blocks. */
-typedef int (*walk_blocks_callback_func) (char blocktype, void *data);
-
-/* Callback for traceframe_walk_blocks, used to find a given block
- type in a traceframe. */
-
-static int
-match_blocktype (char blocktype, void *data)
-{
- char *wantedp = (char *) data;
-
- if (*wantedp == blocktype)
- return 1;
-
- return 0;
-}
-
/* Walk over all traceframe block starting at POS offset from
- CUR_OFFSET, and call CALLBACK for each block found, passing in DATA
- unmodified. If CALLBACK returns true, this returns the position in
- the traceframe where the block is found, relative to the start of
- the traceframe (cur_offset). Returns -1 if no callback call
- returned true, indicating that all blocks have been walked. */
+ CUR_OFFSET, and call CALLBACK for each block found. If CALLBACK
+ returns true, this returns the position in the traceframe where the
+ block is found, relative to the start of the traceframe
+ (cur_offset). Returns -1 if no callback call returned true,
+ indicating that all blocks have been walked. */
static int
-traceframe_walk_blocks (walk_blocks_callback_func callback,
- int pos, void *data)
+traceframe_walk_blocks (gdb::function_view<bool (char)> callback, int pos)
{
/* Iterate through a traceframe's blocks, looking for a block of the
requested type. */
++pos;
- if ((*callback) (block_type, data))
+ if (callback (block_type))
return pos;
switch (block_type)
static int
traceframe_find_block_type (char type_wanted, int pos)
{
- return traceframe_walk_blocks (match_blocktype, pos, &type_wanted);
+ return traceframe_walk_blocks ([&] (char blocktype)
+ {
+ return blocktype == type_wanted;
+ }, pos);
}
/* Look for a block of saved registers in the traceframe, and get the
/* Callback for traceframe_walk_blocks. Builds a traceframe_info
object for the tfile target's current traceframe. */
-static int
-build_traceframe_info (char blocktype, void *data)
+static bool
+build_traceframe_info (char blocktype, struct traceframe_info *info)
{
- struct traceframe_info *info = (struct traceframe_info *) data;
-
switch (blocktype)
{
case 'M':
break;
}
- return 0;
+ return false;
}
traceframe_info_up
{
traceframe_info_up info (new struct traceframe_info);
- traceframe_walk_blocks (build_traceframe_info, 0, info.get ());
+ traceframe_walk_blocks ([&] (char blocktype)
+ {
+ return build_traceframe_info (blocktype, info.get ());
+ }, 0);
return info;
}