]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
"thread apply 1 -- -" vs "frame apply level 0 -- -"
authorPedro Alves <palves@redhat.com>
Wed, 12 Jun 2019 23:06:54 +0000 (00:06 +0100)
committerPedro Alves <palves@redhat.com>
Wed, 12 Jun 2019 23:22:53 +0000 (00:22 +0100)
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.

gdb/ChangeLog
gdb/thread.c

index eb0cb7c3875435bbd11e8f2595e971cd88fedb3a..a89cb3df0680c6e029cbeda01d799b21b7b82571 100644 (file)
@@ -1,3 +1,8 @@
+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.
index 24906fa7d60b2d78d026441fdf635f6630430c42..ea87f51c6e6fd541f664fb26ffde732c61306b6f 100644 (file)
@@ -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;