gdb: add lookup_cmd_exact to simplify a common pattern
authorMarco Barisione <mbarisione@undo.io>
Fri, 7 May 2021 14:43:30 +0000 (15:43 +0100)
committerMarco Barisione <mbarisione@undo.io>
Fri, 7 May 2021 14:43:30 +0000 (15:43 +0100)
commita9b49cbcd5935a713da5715799ea3b24e0a52851
treeefd3e48a50d31f4622598915d43f304b38420155
parent97834047e13bb9f30430331c27b11412a5ed6950
gdb: add lookup_cmd_exact to simplify a common pattern

In code dealing with commands, there's a pattern repeated a few times of
calling lookup_cmd with some speficic arguments and then using strcmp
on the returned command to check for an exact match.
As a later patch would add a few more similar lines of code, this patch
adds a new lookup_cmd_exact function which simplify this use case.

gdb/ChangeLog:

* cli/cli-decode.c (lookup_cmd_exact): Add.
* cli/cli-script.c (do_define_command): Use lookup_cmd_exact.
(define_prefix_command): Ditto.
* command.h: Add lookup_cmd_exact.
gdb/cli/cli-decode.c
gdb/cli/cli-script.c
gdb/command.h