public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Keith Seitz <kseitz@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Error when gdb_is_target_1 is called without running gdb instance Date: Mon, 28 Feb 2022 15:40:50 +0000 (GMT) [thread overview] Message-ID: <20220228154050.355BC3858C83@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ea764154c27a11619ba764a4c92f395ba5007234 commit ea764154c27a11619ba764a4c92f395ba5007234 Author: Keith Seitz <keiths@redhat.com> Date: Mon Feb 28 07:40:23 2022 -0800 Error when gdb_is_target_1 is called without running gdb instance This is a snafu that I encountered while implementing the previous patch, which attempted to use gdb_is_target_native. This proc and gdb_is_target_remote both rely on gdb_is_target_1, which actually cannot be called without gdb already running. This patch adds appropriate warning comments to these procs and causes gdb_is_target_1 to issue a Tcl error if it is called without a gdb instance already running. This should prevent unwitting callers from using this at the wrong time. Diff: --- gdb/testsuite/lib/gdb.exp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 0be5b4e6c96..2688a8e0394 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -3876,8 +3876,17 @@ proc skip_compile_feature_tests {} { # is a regexp that will match the output of "maint print target-stack" if # the target in question is currently pushed. PROMPT_REGEXP is a regexp # matching the expected prompt after the command output. +# +# NOTE: GDB must be running BEFORE this procedure is called! proc gdb_is_target_1 { target_name target_stack_regexp prompt_regexp } { + global gdb_spawn_id + + # Throw a Tcl error if gdb isn't already started. + if {![info exists gdb_spawn_id]} { + error "gdb_is_target_1 called with no running gdb instance" + } + set test "probe for target ${target_name}" gdb_test_multiple "maint print target-stack" $test \ -prompt "$prompt_regexp" { @@ -3893,6 +3902,8 @@ proc gdb_is_target_1 { target_name target_stack_regexp prompt_regexp } { } # Helper for gdb_is_target_remote where the expected prompt is variable. +# +# NOTE: GDB must be running BEFORE this procedure is called! proc gdb_is_target_remote_prompt { prompt_regexp } { return [gdb_is_target_1 "remote" ".*emote target using gdb-specific protocol.*" $prompt_regexp] @@ -3900,6 +3911,8 @@ proc gdb_is_target_remote_prompt { prompt_regexp } { # Check whether we're testing with the remote or extended-remote # targets. +# +# NOTE: GDB must be running BEFORE this procedure is called! proc gdb_is_target_remote { } { global gdb_prompt @@ -3908,6 +3921,8 @@ proc gdb_is_target_remote { } { } # Check whether we're testing with the native target. +# +# NOTE: GDB must be running BEFORE this procedure is called! proc gdb_is_target_native { } { global gdb_prompt
reply other threads:[~2022-02-28 15:40 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220228154050.355BC3858C83@sourceware.org \ --to=kseitz@sourceware.org \ --cc=gdb-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).