[Lldb-commits] [lldb] Add option to pass thread ID to thread select command (PR #73596)

via lldb-commits lldb-commits at lists.llvm.org
Tue Nov 28 10:20:18 PST 2023


jimingham wrote:

lldb doesn't have a notion of arguments actually being the value of a default option.  I'm not sure I like that idea, it seems like it could quickly become confusing.  

lldb does have the notion of "groups of options" that work together for a given command.  You can specify `break set -n foo` or `break set -a 0x1234` but `-a` and `-n` are in different option groups so the command parser won't allow you to specify them together.

Someone started to do the same thing with arguments, so you can say "if --something is provided, you can have an argument, but if --something-else is provided you can't".  But I don't think that is currently working (I noticed that hooking up the parsed scripted commands).  For now, you'll have to check the inputs by hand in the DoExecute, but then once we hook up the argument groups properly, you will be able to specify "one option with -t and no arguments" and "one argument" as the two command options, and the parser will handle the checking for you.  So that seems the more "lldb natural" way to do this.

It would have been better if we had made `thread select` take two options as you suggested.  We could have then fixed the `t` alias to specify the thread index so that we would have fast access to the most common command.  Sadly, I think `'thread select" has been around for long enough that changing the way the command line behaves would be disruptive, and I don't think that's a good idea.

JIm


> On Nov 28, 2023, at 9:58 AM, Michael Christensen ***@***.***> wrote:
> 
> 
> @jimingham <https://github.com/jimingham> So it seems that when -t <tid> is supplied, the user shouldn't be able to specify a thread index as well, e.g. the following is disallowed:
> 
> thread select -t 216051 1
> Would it make sense then for thread select to take two possible mutually exclusive options (-t <tid>) and (-i <index>), with the -i option being the default (i.e. doesn't need to be specified)? e.g.
> 
> thread select -t 216051
> and
> 
> thread select -i 1
> thread select 1
> (where the -i doesn't need to be supplied by default)?
> 
> It makes the completer much easier to hook up since the option value can complete against the native thread ID's
> Sounds good, I'll work on adding the complete for the native thread ID option with the above change.
> 
>> Reply to this email directly, view it on GitHub <https://github.com/llvm/llvm-project/pull/73596#issuecomment-1830395111>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ADUPVW3FLTLLF2QBC733FALYGYQ3PAVCNFSM6AAAAAA744LG7GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZQGM4TKMJRGE>.
> You are receiving this because you were mentioned.
> 



https://github.com/llvm/llvm-project/pull/73596


More information about the lldb-commits mailing list