This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCHv2 1/2] gdb: Split func_command into two parts.
On 05/08/2018 05:58 PM, Andrew Burgess wrote:
> The func_command function is used to emulate the dbx 'func' command.
> However, finding a stack frame based on function name might be a useful
> feature, and so the core of func_command is now split out into a
> separate function.
>
> gdb/ChangeLog:
>
> * stack.c (select_and_print_frame): Delete.
> (func_command): Most content moved into new function
> find_frame_for_function, use new function, print result, add
> function comment.
> (find_frame_for_function): New function, now returns a result.
This LGTM, with a couple minor nits.
> /* Return the symbol-block in which the selected frame is executing.
> Can return zero under various legitimate circumstances.
> @@ -2460,19 +2450,19 @@ struct function_bounds
> CORE_ADDR low, high;
> };
>
> -static void
> -func_command (const char *arg, int from_tty)
> +static struct frame_info *
> +find_frame_for_function (const char *function_name)
There's a comment above the structure that is describing
what the func_command function did. That needs to be
updated to describe what the new function does.
> +
> +/* Implements the dbx 'func' command. */
> +
> +static void
> +func_command (const char *arg, int from_tty)
> +{
> + struct frame_info *frame;
> +
> + if (arg == NULL)
> + return;
> +
> + frame = find_frame_for_function (arg);
You can declare and initialize at the same time:
func_command (const char *arg, int from_tty)
{
if (arg == NULL)
return;
frame_info *frame = find_frame_for_function (arg);
Thanks,
Pedro Alves