gdb: fix command lookup in execute_command ()
authorJan Vrany <jan.vrany@labware.com>
Mon, 19 Dec 2022 11:24:36 +0000 (11:24 +0000)
committerJan Vrany <jan.vrany@labware.com>
Mon, 19 Dec 2022 11:24:36 +0000 (11:24 +0000)
commit37e5833da583310268dc1b04fc6839e81b987897
treebfefb5d1a2af67f4e4dd1593b98013c913a62e29
parent42f39fdedcf3321cab9964945d3f5bca58967b80
gdb: fix command lookup in execute_command ()

Commit b5661ff2 ("gdb: fix possible use-after-free when
executing commands") used lookup_cmd_exact () to lookup
command again after its execution to avoid possible
use-after-free error.

However this change broke test gdb.base/define.exp which
defines a post-hook for subcommand ("target testsuite").
In this case,  lookup_cmd_exact () returned NULL because
there's no command 'testsuite' in top-level commands.

This commit fixes this case by looking up the command again
using the original command line via lookup_cmd ().

Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/top.c