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 < revi...@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 > >
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits