Improve error handling for invalid breakpoint `-t` and `-x` options.
authorJordan Rupprecht <rupprecht@google.com>
Fri, 9 Dec 2022 01:53:54 +0000 (17:53 -0800)
committerJordan Rupprecht <rupprecht@google.com>
Fri, 9 Dec 2022 01:53:54 +0000 (17:53 -0800)
commitf9d8090a90a1f1f9ddf6aebb82e7fc4c1dbcf030
treed768b6641e32469dca7e7b90c7486a82cd376bb4
parente89e8dcfad364d23515de25ac87d26dfe25badbb
Improve error handling for invalid breakpoint `-t` and `-x` options.

Breakpoint option `-t` checks that `option_arg` is empty by checking `option_arg[0] == '\0'`. This is unnecessary: the next two checks for comparing against "current" and calling `getAsInteger` already gracefully handle an empty StringRef. If the `option_arg` string is empty, this crashes (or triggers an assertion failure with asserts enabled). Also, this sets the thread id to `LLDB_INVALID_THREAD_ID` if the thread id is invalid -- it should just not set the thread id.

Likewise of `-x` which checks `option_arg[0] == '\n'` unnecessarily.

I believe both of these bugs are unreachable via normal LLDB usage, and are only accessible via the fuzzer -- most likely some other CLI parsing is trimming whitespace and rejecting empty inputs. Still, it doesn't hurt to simplify this bit.
lldb/source/Commands/CommandObjectBreakpoint.cpp