[PATCH] Fix crash with "maintenance print arc"

Luis Machado luis.machado@arm.com
Thu May 5 09:31:09 GMT 2022


Hi Tom,

On 4/28/22 16:26, Tom Tromey wrote:
>>>>>> "Luis" == Luis Machado via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Luis> While doing something else, I noticed GDB crashed with
> Luis> "maintenance print arc".
> 
> I think the bug here is that this uses add_show_prefix_cmd and not
> add_basic_prefix_cmd.  See the appended, which also fixes the crash.
> 
> Luis> This happens because the code expects to find a "show" string pattern
> Luis> within "maintenance print arc", since "arc" here is a prefix, and skip it.
> Luis> In this case though, it won't find it, and we will have a bad pointer
> Luis> getting dereferenced.
> 
> This looks reasonable to me.
> 
> Tom
> 
> diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c
> index 98bd1c4bc0a..3edfd466f3b 100644
> --- a/gdb/arc-tdep.c
> +++ b/gdb/arc-tdep.c
> @@ -2474,11 +2474,11 @@ _initialize_arc_tdep ()
>     /* Register ARC-specific commands with gdb.  */
>   
>     /* Add root prefix command for "maintenance print arc" commands.  */
> -  add_show_prefix_cmd ("arc", class_maintenance,
> -		       _("ARC-specific maintenance commands for printing GDB "
> -			 "internal state."),
> -		       &maintenance_print_arc_list,
> -		       0, &maintenanceprintlist);
> +  add_basic_prefix_cmd ("arc", class_maintenance,
> +			_("ARC-specific maintenance commands for printing GDB "
> +			  "internal state."),
> +			&maintenance_print_arc_list,
> +			0, &maintenanceprintlist);
>   
>     add_cmd ("arc-instruction", class_maintenance,
>   	   dump_arc_instruction_command,

FTR, I'm happy to go with your patch for this one.


More information about the Gdb-patches mailing list