public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Pedro Alves <palves@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] "thread apply 1 -- -" vs "frame apply level 0 -- -"
Date: Wed, 12 Jun 2019 23:29:00 -0000	[thread overview]
Message-ID: <20190612232947.32680.qmail@sourceware.org> (raw)

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

commit f7e13587eaf1e2d433e21ac0a9e413a98e53652d
Author: Pedro Alves <palves@redhat.com>
Date:   Thu Jun 13 00:06:54 2019 +0100

    "thread apply 1 -- -" vs "frame apply level 0 -- -"
    
    With the following patch, we'll be able to explicitly tell "thread
    apply" where options end, using the "--" delimiter.  A test added by
    that patch caught a pre-existing inconsistency:
    
     (gdb) thread apply 1 -- -
     Invalid thread ID: -
    
     (gdb) frame apply level 0 -- -
     #0  main () at threads.c:55
     Cannot enable the TUI when output is not a terminal
    
    Above, "thread apply" did not try to run the command, while "frame
    apply level" did.  ("-" is a valid TUI command.)
    
    That "-" is past "--", so it should have not been confused with an
    invalid TID, in the "thread apply" case.
    
    That error actually doesn't come from the TID parser, but instead from
    thread_apply_command directly.
    
    So that error/check needs tweaking.  The next question is what to
    tweak it to.
    
    "-" is actually a valid TUI command:
    
     (gdb) help -
     Scroll window backward.
     Usage: - [WIN] [N]
    
    (gdb) frame apply level 0 -- -
    #0  main () at threads.c:55
    Cannot enable the TUI when output is not a terminal
    
    While I don't imagine it being useful to use that "-" command with
    "thread apply" or "frame apply level", the fact is that you can use it
    with "frame apply level", but not with "thread apply".  And since it's
    an actual command, pedantically it seems right to allow it.
    
    That's what this commit does.
    
    Note: simply removing the "isalpha" check regresses
    gdb.multi/tids.exp -- see related commit 3f5b7598805c.
    
    gdb/ChangeLog:
    2019-06-13  Pedro Alves  <palves@redhat.com>
    
    	* thread.c (thread_apply_command): Check for invalid TID with
    	isdigit instead of !isalpha.

Diff:
---
 gdb/ChangeLog | 5 +++++
 gdb/thread.c  | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index eb0cb7c..a89cb3d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
 2019-06-13  Pedro Alves  <palves@redhat.com>
 
+	* thread.c (thread_apply_command): Check for invalid TID with
+	isdigit instead of !isalpha.
+
+2019-06-13  Pedro Alves  <palves@redhat.com>
+
 	* cli/cli-utils.c (parse_flags_qcs): Use validate_flags_qcs.
 	(validate_flags_qcs): New.
 	* cli/cli-utils.h (struct qcs_flags): Change field types to int.
diff --git a/gdb/thread.c b/gdb/thread.c
index 24906fa..ea87f51 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -1583,7 +1583,7 @@ thread_apply_command (const char *tidlist, int from_tty)
   if (*cmd == '\0')
     error (_("Please specify a command following the thread ID list"));
 
-  if (tidlist == cmd || !isalpha (cmd[0]))
+  if (tidlist == cmd || isdigit (cmd[0]))
     invalid_thread_id_error (cmd);
 
   scoped_restore_current_thread restore_thread;


                 reply	other threads:[~2019-06-12 23:29 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=20190612232947.32680.qmail@sourceware.org \
    --to=palves@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: 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).