[Lldb-commits] [PATCH] D17724: Replace getopt with llvm::cl in lldb driver

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Mon Feb 29 09:29:14 PST 2016


Love this change in principle. I will look over it on the windows side to
make sure nothing breaks.

One question: we are using getopt still for parsing interactive command
lines right?
On Mon, Feb 29, 2016 at 9:26 AM Pavel Labath <labath at google.com> wrote:

> labath created this revision.
> labath added reviewers: clayborg, zturner.
> labath added a subscriber: lldb-commits.
>
> This replaces the hand-rolled getopt option parser in lldb driver with the
> one in llvm. This
> results in a lot less code, as the llvm's parser does much of the work
> (e.g., formatting of
> --help output) for us, and side-steps the problem of using the internal
> getopt implementation in
> liblldb on platforms which don't have a system getopt (windows, netbsd).
>
> This change has tiny behaviour changes, which I try to enumerate here:
> - boolean arguments can no longer be specified twice (e.g., --no-lldbinit
> --no-lldbinit will
>   result in an error). I needed to tweak TestFormats to account for this.
> Can be changed, but I'm
>   not sure if there is any need for it.
> - I have removed the --script-language option, as it seemed to be ignored
> anyway.
> - --help output has changed a bit and now reads (note one has to pass
> --help-hidden to see
>   short option letters. again can be changed, but i think it makes the
> initial help more
>   readable):
>
> USAGE: lldb [options] <program-and-arguments>
>
> OPTIONS:
>
> General options:
>
>   -arch=<string>                 - Tells the debugger to use the specified
> architecture when starting and running the program.  <string> must be one
> of the architectures for which the program was compiled.
>   -attach-name=<string>          - Tells the debugger to attach to a
> process with the given name.
>   -attach-pid=<uint>             - Tells the debugger to attach to a
> process with the given pid
>   -batch                         - Tells the debugger to running the
> commands from -s, -S, -o & -O, and then quit.  However if any run command
> stopped due to a signal or crash, the debugger will return to the
> interactive prompt at the place of the crash.
>   -core=<string>                 - Tells the debugger to use the file
> <string> as the core file.
>   -debug                         - Tells the debugger to print out extra
> information for debugging itself.
>   -editor                        - Tells the debugger to open source files
> using the host's "external editor" mechanism.
>   -file=<string>                 - Tells the debugger to use the file
> <string> as the program to be debugged.
>   -no-lldbinit                   - Do not automatically parse any
> '.lldbinit' files.
>   -no-use-colors                 - Do not use colors.
>   -one-line=<string>             - Tells the debugger to execute this
> one-line lldb command after any file provided on the command line has been
> loaded.
>   -one-line-before-file=<string> - Tells the debugger to execute this
> one-line lldb command before any file provided on the command line has been
> loaded.
>   -one-line-on-crash=<string>    - When in batch mode, tells the debugger
> to execute this one-line lldb command if the target crashes.
>   -repl=<string>                 - Runs lldb in REPL mode with a stub
> process.
>   -repl-langauge=<string>        - Chooses the language for the REPL.
>   -source=<string>               - Tells the debugger to read in and
> execute the lldb commands in the given file, after any file provided on the
> command line has been loaded.
>   -source-before-file=<string>   - Tells the debugger to read in and
> execute the lldb commands in the given file, before any file provided on
> the command line has been loaded.
>   -source-on-crash=<string>      - When in batch mode, tells the debugger
> to source this file of lldb commands if the target crashes.
>   -source-quietly                - Don't echo the commands when executing
> them.
>   -wait-for                      - Tells the debugger to wait for a
> process with the given pid or name to launch before attaching.
>
> Generic Options:
>
>   -help                          - Display available options (-help-hidden
> for more)
>   -help-list                     - Display list of available options
> (-help-list-hidden for more)
>   -version                       - Display the version of this program
>
> If you don't provide -file then the first argument will be the file to be
> debugged which means that 'lldb -- <filename> [<ARG1> [<ARG2>]]' also
> works.  But remember to end the options with "--" if any of your
> arguments begin with "-".
>
> Multiple "-source" and "-one-line" options can be provided.  They will be
> processed from left to right in order, with the source files and commands
> interleaved.
>
> http://reviews.llvm.org/D17724
>
> Files:
>   packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py
>   packages/Python/lldbsuite/test/driver/batch_mode/source.file
>   packages/Python/lldbsuite/test/functionalities/format/TestFormats.py
>   tools/driver/Driver.cpp
>   tools/driver/Driver.h
>   tools/driver/Platform.h
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160229/72a1d628/attachment.html>


More information about the lldb-commits mailing list