public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug python/14639] gdb.parameter doesn't flag ambiguous parameter spellings
Date: Wed, 07 Feb 2024 19:01:24 +0000	[thread overview]
Message-ID: <bug-14639-4717-SQYgzDDYMd@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-14639-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=14639

--- Comment #2 from Sourceware Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Hannes Domani <ssbssa@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=276d9db22d768e6904937b8def1b05771588092b

commit 276d9db22d768e6904937b8def1b05771588092b
Author: Hannes Domani <ssbssa@yahoo.de>
Date:   Wed Feb 7 19:59:29 2024 +0100

    Raise exception if ambiguous name is used in gdb.parameter

    Currently gdb.parameter doesn't raise an exception if an
    ambiguous name is used, it instead returns the value of the
    last partly matching parameter:
    ```
    (gdb) show print sym
    Ambiguous show print command "sym": symbol, symbol-filename,
symbol-loading.
    (gdb) show print symbol-loading
    Printing of symbol loading messages is "full".
    (gdb) py print(gdb.parameter("print sym"))
    full
    ```

    It's because lookup_cmd_composition_1 tries to detect
    ambigous names by checking the return value of find_cmd
    for CMD_LIST_AMBIGUOUS, which never happens, since only
    lookup_cmd_1 returns CMD_LIST_AMBIGUOUS.
    Instead the nfound argument contains the number of found
    matches.

    By using it instead, and by setting *CMD to the special value
    CMD_LIST_AMBIGUOUS in this case, gdbpy_parameter can now show
    the appropriate error message:
    ```
    (gdb) py print(gdb.parameter("print sym"))
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    RuntimeError: Parameter `print sym' is ambiguous.
    Error while executing Python code.
    (gdb) py print(gdb.parameter("print symbol"))
    True
    (gdb) py print(gdb.parameter("print symbol-"))
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    RuntimeError: Parameter `print symbol-' is ambiguous.
    Error while executing Python code.
    (gdb) py print(gdb.parameter("print symbol-load"))
    full
    ```

    Since the document command also uses lookup_cmd_composition, it needed
    to check for CMD_LIST_AMBIGUOUS as well, so it now also shows an
    "Ambiguous command" error message in this case.

    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=14639
    Approved-By: Tom Tromey <tom@tromey.com>

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2024-02-07 19:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-27 23:13 [Bug python/14639] New: " dje at google dot com
2023-12-15 18:40 ` [Bug python/14639] " ssbssa at sourceware dot org
2023-12-16  0:22 ` tromey at sourceware dot org
2024-02-07 19:01 ` cvs-commit at gcc dot gnu.org [this message]
2024-02-07 19:02 ` ssbssa at sourceware dot org

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=bug-14639-4717-SQYgzDDYMd@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@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: link
Be 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).