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.