[Lldb-commits] [PATCH] D54682: [Driver] Extract option parsing and option processing.

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Sun Nov 18 19:29:51 PST 2018


I’ve often thought we should convert LLDB’s command line parsing code over
to use either cl::opt or lib/Option. This would also solve the problem you
describe here at the same time.

Do you think it’s worth trying to do this?
On Sun, Nov 18, 2018 at 7:17 PM Jonas Devlieghere via Phabricator <
reviews at reviews.llvm.org> wrote:

> JDevlieghere created this revision.
> JDevlieghere added reviewers: clayborg, labath, zturner, jingham.
> JDevlieghere added a project: LLDB.
>
> In order to deal consistently with global state in LLDB, the reproducer
> feature affects LLDB's initialization. For example, when replaying, the
> FileSystem singleton is initialized with a virtual file system.
>
> This is a problem for the driver because it initialized the debugger
> before parsing command line options. The reason is that the driver, among
> other things, checks whether files exists (e.g. core files, target, files
> to be sourced). It also relies on the debugger to parse things like the
> (scripting) language, the architecture, etc.
>
> In an initial attempt I tried to populate the OptionData before the
> debugger is initialized. This proved to be complicated, because of the
> sanity checks that are performed by calling into the debugger of the
> filesystem. Although it would be possible to perform these checks after
> parsing, it would cause errors to no longer appear in the same order as
> specified by the user, but in an arbitrary order specified by the driver
> implementation. Although I like the idea conceptually I don't believe this
> is an acceptable regression.
>
> Implemented in this patch is a new `ArgParser` class that extracts the
> existing argument parsing logic. Basically it calls `getopt_long_only`
> repeatedly and populates a list with the short option and its value.
> Because the `ArgParser` is //dumb// it can do all its work before the
> debugger is initialized. Afterwards the driver iterates over the options
> from the argparser (instead of calling `getopt_long_only` every time) and
> do whatever is needed.
>
>
> Repository:
>   rLLDB LLDB
>
> https://reviews.llvm.org/D54682
>
> Files:
>   tools/driver/Driver.cpp
>   tools/driver/Driver.h
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20181118/b1ad4517/attachment.html>


More information about the lldb-commits mailing list