summaryrefslogtreecommitdiffstats
path: root/lldb/source/Interpreter/Args.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fixed a ton of gcc compile warningsVince Harron2015-05-131-1/+1
| | | | | | | | | | Removed some unused variables, added some consts, changed some casts to const_cast. I don't think any of these changes are very controversial. Differential Revision: http://reviews.llvm.org/D9674 llvm-svn: 237218
* Fix a problem where 'process launch' was not correctly re-quoting arguments ↵Enrico Granata2015-04-101-1/+2
| | | | | | | | for the inferior process when handing them down for the actual launch This covers most of rdar://20490076, but leaves one corner case still open - namely the case where we try to have arguments of the form foo\ bar (unquoted, but slashed) go through argdumper llvm-svn: 234554
* Fix a bug related to arg escaping, and add unit tests.Zachary Turner2015-03-141-1/+1
| | | | | | | | | A recent refactor had introduced a bug where if you escaped a character, the rest of the string would get processed incorrectly. This patch fixes that bug and adds some unit tests for Args. llvm-svn: 232288
* Fix build breakage on win7-msvc caused by r230955Pavel Labath2015-03-021-2/+1
| | | | llvm-svn: 230958
* Fix handling of backslashes in Args parsingPavel Labath2015-03-021-204/+139
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Presently Args::SetCommandString allows quotes to be escaped with backslash. However, the backslash itself is not removed from the argument, nor there is a way to escape the backslash itself. This leads to surprising results: "a b" c" -> 'a b', 'c' # Here we actually have an unterminated quote, but that is ignored "a b\" c" -> 'a b\" c' # We try to escape the quote. That works but the backslash is not removed. "a b\\" c" -> 'a b\\" c' # Escaping the backslash has no effect. This change changes quote handling to be more shell-like: - single quotes and backquotes are literal and there is no way to escape the closing quote or anything else inside; - inside double quotes you can use backslash to escape the closing quote and another backslash - outside any quotes, you can use backslash to escape quotes, spaces and itself. This makes the parsing more consistent with what the user is familiar and increases the probability that pasting the command line from shell to the "process launch" command "just work". Reviewers: clayborg Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D7855 llvm-svn: 230955
* Handle trailing spaces on "settings set" command more correctlyPavel Labath2015-02-161-19/+17
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Currently we have some settings which treat "\ " on settings set commands specially. E.g., it is a valid way of specifying an argument of " " to a target. However, this fails if "\ " is the last argument as CommandObjectSettingsSet strips trailing whitespace. This resulted in a surprising argument of "\" to the target. This patch disables the training whitespace removal at a global level. Instead, for each argument type we locally determine whether whitespace stripping makes sense. Currently, I strip whitespace for all simple object type except of regex and format-string, with the rationale that these two object types do their own complex parsing and we want to interfere with them as least as possible. Specifically, stripping the whitespace of a regex "\ " will result in a (surprising?) error "trailing backslash". Furthermore, the default value of dissasembly-format setting already contains a trailing space and there is no way for the user to type this in manually if we strip whitespace. Reviewers: clayborg, zturner Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D7592 llvm-svn: 229382
* Don't remove backslashes from arguments unless the following char is recognized.Zachary Turner2015-01-201-11/+9
| | | | | | | | | | | | | This fixes file paths on Windows, as you can now write, for example, file d:\foo\bar.txt, but does not break the case that this tokenization logic was originally designed for, which is to allow escaping of things like quotes and double quotes, so that all of the escapable characters can appear in the same string together. Reviewed by: Jim Ingham, Greg Clayton Differential Revision: http://reviews.llvm.org/D7018 llvm-svn: 226587
* Moved Args::StringToXIntYZ to StringConvert::ToXIntYZVince Harron2015-01-151-74/+2
| | | | | | | | | | The refactor was motivated by some comments that Greg made http://reviews.llvm.org/D6918 and also to break a dependency cascade that caused functions linking in string->int conversion functions to pull in most of lldb llvm-svn: 226199
* Add support for character option types.Zachary Turner2015-01-121-0/+20
| | | | | | | | | | | | | This will allow, in a subsequent patch, the addition of a global setting that allows the user to specify a single character that LLDB will recognize as an escape character when processing arg strings to accomodate differences in Windows/non-Windows path handling. Differential Revision: http://reviews.llvm.org/D6887 Reviewed by: Jim Ingham llvm-svn: 225694
* It's possible for long_options[long_options_index].definition to be nullJason Molenda2014-10-161-1/+1
| | | | | | | | from the previous for() loop - check that it is non-null before trying to deref it. clang static analyzer fixit. llvm-svn: 219887
* Reverse out r219169 related to quote handling.Todd Fiala2014-10-101-43/+1
| | | | | | | | | Addresses pr/21190 (http://llvm.org/bugs/show_bug.cgi?id=21190). r219169 implemented this change list: http://reviews.llvm.org/D5472 for more details. llvm-svn: 219461
* In cases where you'd use an expression to get a value to insert in a ↵Enrico Granata2014-10-091-4/+7
| | | | | | command, be ready to use synthetic children if they are there. Those are now a source of values, so worth checking for llvm-svn: 219452
* Add "target.expr-parser-compiler-args" setting.Todd Fiala2014-10-061-1/+43
| | | | | | | | | | | | | This setting contains the following: A list containing all the arguments to be passed to the expression parser compiler. This change also ensures quoted arguments are handled appropriately. See http://reviews.llvm.org/D5472 for more details. Change by Tong Shen. llvm-svn: 219169
* A quoted - is not the beginning of an option, and should not be completed as ↵Jim Ingham2014-08-271-0/+2
| | | | | | | | | | | | such. This was causing: (lldb) disassemble -n '-<TAB> to crash. <rdar://problem/18134531> llvm-svn: 216626
* Revert "Fix broken tests due to new error output."Zachary Turner2014-07-091-15/+30
| | | | | | | This reverts commit ec7c94f8e6860968d384b578e5564a9c55c80b4a and re-enables OptionValidators. llvm-svn: 212627
* Fix broken tests due to new error output.Todd Fiala2014-07-081-30/+15
| | | | | | | | | | | This reverses out the options validators changes. We'll get these back in once the changes to the output can be resolved. Restores broken tests on FreeBSD, Linux, MacOSX. Changes reverted: r212500, r212317, r212290. llvm-svn: 212543
* Invalidate process UID/GID-related command options on Windows.Zachary Turner2014-07-071-15/+30
| | | | | | | | | | | | Windows uses a different process security model and does not have a concept of process UID or GID. This patch makes these options invalid on Windows. Attempting to specify these options when the current platform is Windows will generate an error. Reviewed by: Jim Ingham Differential Revision: http://reviews.llvm.org/D4373 llvm-svn: 212500
* Args::StringToGenericRegister will now accept "lr" as Jason Molenda2014-05-091-1/+1
| | | | | | | | | | | | | another way to indicate that this register is a generic Return Address register (in addition to "ra") - this is used primarily by OperatingSystem plugins. Correctly annotate the UnwindPlan created by EmulateInstructionARM64 to indicate that it was not sourced from a compiler and it is valid at every instruction. <rdar://problem/16639754> llvm-svn: 208390
* Rename eExecution*** to eExpression*** to be consistent with the result type.Jim Ingham2014-05-051-1/+1
| | | | llvm-svn: 207945
* Make the Expression Execution result enum available to the SB API layer.Jim Ingham2014-05-051-1/+1
| | | | | | | | | Add a callback that will allow an expression to be cancelled between the expression evaluation stages (for the ClangUserExpressions.) <rdar://problem/16790467>, <rdar://problem/16573440> llvm-svn: 207944
* Switch NULL to C++11 nullptr in source/InterpreterEd Maste2014-04-201-36/+36
| | | | | | Patch by Robert Matusewicz llvm-svn: 206711
* Cleanup the code a bit.Greg Clayton2014-04-071-1/+1
| | | | llvm-svn: 205739
* sanitise sign comparisonsSaleem Abdulrasool2014-04-021-3/+3
| | | | | | | | This is a mechanical change addressing the various sign comparison warnings that are identified by both clang and gcc. This helps cleanup some of the warning spew that occurs during builds. llvm-svn: 205390
* This patch does a couple of things. Jim Ingham2013-11-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | It completes the job of using EvaluateExpressionOptions consistently throughout the inferior function calling mechanism in lldb begun in Greg's patch r194009. It removes a handful of alternate calls into the ClangUserExpression/ClangFunction/ThreadPlanCallFunction which were there for convenience. Using the EvaluateExpressionOptions removes the need for them. Using that it gets the --debug option from Greg's patch to work cleanly. It also adds another EvaluateExpressionOption to not trap exceptions when running expressions. You shouldn't use this option unless you KNOW your expression can't throw beyond itself. This is: <rdar://problem/15374885> At present this is only available through the SB API's or python. It fixes a bug where function calls would unset the ObjC & C++ exception breakpoints without checking whether they were set by somebody else already. llvm-svn: 194182
* Roll back the changes I made in r193907 which created a new FrameJason Molenda2013-11-041-1/+1
| | | | | | | | | | pure virtual base class and made StackFrame a subclass of that. As I started to build on top of that arrangement today, I found that it wasn't working out like I intended. Instead I'll try sticking with the single StackFrame class -- there's too much code duplication to make a more complicated class hierarchy sensible I think. llvm-svn: 193983
* Add a new base class, Frame. It is a pure virtual function whichJason Molenda2013-11-021-1/+1
| | | | | | | | | | | | | | | | | | | | | defines a protocol that all subclasses will implement. StackFrame is currently the only subclass and the methods that Frame vends are nearly identical to StackFrame's old methods. Update all callers to use Frame*/Frame& instead of pointers to StackFrames. This is almost entirely a mechanical change that touches a lot of the code base so I'm committing it alone. No new functionality is added with this patch, no new subclasses of Frame exist yet. I'll probably need to tweak some of the separation, possibly moving some of StackFrame's methods up in to Frame, but this is a good starting point. <rdar://problem/15314068> llvm-svn: 193907
* Add OptionParser.hVirgile Bello2013-09-051-79/+60
| | | | llvm-svn: 190063
* MingW compilation (windows). Includes various refactoring to improve ↵Virgile Bello2013-08-231-0/+3
| | | | | | portability. llvm-svn: 189107
* Fix a missing pointer deref that was uncovered by one of the buildbots.Adrian Prantl2013-06-181-1/+1
| | | | llvm-svn: 184216
* Fix linux argument completion with for "--" options (llvm.org/bugs/pr14425)Daniel Malea2013-04-231-2/+1
| | | | | | | | | | | | | | | | | | | Patch by Yacine Belkadi! When __GLIBC__ is defined, optind gets initialized to 0. So for the first parsed option, parse_start is 0, too. If this option has no argument (Like "--continue" of "process attach"), then the position stored is 0, instead of 1. This prevents the completion later on in Options::HandleOptionCompletion() because the opt_pos doesn't match the cursor_index. Fix that by getting the option's position from the value of optind, as it's done for the other types of options. Re-enable test_process_attach_dash_dash_con() on Linux. No regressions detected on Mac OS X (in TestCompletion.py) llvm-svn: 180114
* <rdar://problem/13457391>Greg Clayton2013-04-041-16/+19
| | | | | | LLDB now can use a single dash for all long options for all commands form the command line and from the command interpreter. This involved just switching all calls from getopt_long() to getopt_long_only(). llvm-svn: 178789
* <rdar://problem/13384801>Greg Clayton2013-04-031-5/+6
| | | | | | Make lldb_private::RegularExpression thread safe everywhere. This was done by removing the m_matches array from the lldb_private::RegularExpression class and putting it into the new lldb_private::RegularExpression::Match class. When executing a regular expression you now have the option to create a lldb_private::RegularExpression::Match object and pass a pointer in if you want to get parenthesized matching. If you don't want any matching, you pass in NULL. The lldb_private::RegularExpression::Match object is initialized with the number of matches you desire. Any matching strings are now extracted from the lldb_private::RegularExpression::Match objects. This makes the regular expression objects thread safe and as a result many more regex objects were turned into static objects that end up using a local lldb_private::RegularExpression::Match object when executing. llvm-svn: 178702
* <rdar://problem/13184855>Greg Clayton2013-03-051-0/+27
| | | | | | Spaces in "settings set" value strings no longer cause setting failures. llvm-svn: 176532
* <rdar://problem/12978143>Enrico Granata2013-01-281-1/+1
| | | | | | | | | | | Data formatters now cache themselves. This commit provides a new formatter cache mechanism. Upon resolving a formatter (summary or synthetic), LLDB remembers the resolution for later faster retrieval. Also moved the data formatters subsystem from the core to its own group and folder for easier management, and done some code reorganization. The ObjC runtime v1 now returns a class name if asked for the dynamic type of an object. This is required for formatters caching to work with the v1 runtime. Lastly, this commit disposes of the old hack where ValueObjects had to remember whether they were queried for formatters with their static or dynamic type. Now the ValueObjectDynamicValue class works well enough that we can use its dynamic value setting for the same purpose. llvm-svn: 173728
* <rdar://problem/13069948>Greg Clayton2013-01-251-20/+20
| | | | | | | | | | | | Major fixed to allow reading files that are over 4GB. The main problems were that the DataExtractor was using 32 bit offsets as a data cursor, and since we mmap all of our object files we could run into cases where if we had a very large core file that was over 4GB, we were running into the 4GB boundary. So I defined a new "lldb::offset_t" which should be used for all file offsets. After making this change, I enabled warnings for data loss and for enexpected implicit conversions temporarily and found a ton of things that I fixed. Any functions that take an index internally, should use "size_t" for any indexes and also should return "size_t" for any sizes of collections. llvm-svn: 173463
* <rdar://problem/12820334>Greg Clayton2012-12-061-4/+102
| | | | | | | | | | | | | I modified the "Args::StringtoAddress(...)" function to be able to evaluate address expressions. This is now used for any command line arguments or options that takes addresses like: memory read <addr> [<end-addr>] memory write <addr> breakpoint set --address <addr> disassemble --start-address <addr> --end-address <addr> It calls the expression parser to evaluate the address expression and will also work around the issue where the compiler doesn't like to add offsets to function pointers (which is what happens when you try to evaluate "main + 12"). So there is a temp fix in the Args::StringtoAddress() to work around this until we can get special compiler support for debug expressions with function pointers. llvm-svn: 169556
* Define isprint8() wrapper around isprint() in order to avoid crashes on LinuxDaniel Malea2012-12-051-2/+2
| | | | llvm-svn: 169417
* Fix Linux build warnings due to redefinition of macros:Daniel Malea2012-12-051-0/+2
| | | | | | | | | - add new header lldb-python.h to be included before other system headers - short term fix (eventually python dependencies must be cleaned up) Patch by Matt Kopec! llvm-svn: 169341
* <rdar://problem/12798131> Greg Clayton2012-12-041-13/+17
| | | | | | | | | | | | Cleaned up the option parsing code to always pass around the short options as integers. Previously we cast this down to "char" and lost some information. I recently added an assert that would detect duplicate short character options which was firing during the test suite. This fix does the following: - make sure all short options are treated as "int" - make sure that short options can be non-printable values when a short option is not required or when an option group is mixed into many commands and a short option is not desired - fix the help printing to "do the right thing" in all cases. Previously if there were duplicate short character options, it would just not emit help for the duplicates - fix option parsing when there are duplicates to parse options correctly. Previously the option parsing, when done for an OptionGroup, would just start parsing options incorrectly by omitting table entries and it would end up setting the wrong option value llvm-svn: 169189
* Stop using the "%z" size_t modifier and cast all size_t values to uint64_t. ↵Greg Clayton2012-09-181-9/+0
| | | | | | Some platforms don't support this modification. llvm-svn: 164148
* Made it so changes to the prompt via "settings set prompt" get noticed by ↵Greg Clayton2012-09-011-0/+134
| | | | | | | | | | the command line. Added the ability for OptionValueString objects to take flags. The only flag is currently for parsing escape sequences. Not the prompt string can have escape characters translate which will allow colors in the prompt. Added functions to Args that will parse the escape sequences in a string, and also re-encode the escape sequences for display. This was looted from other parts of LLDB (the Debugger::FormatString() function). llvm-svn: 163043
* Added Args::StringForEncoding(), Args::StringToGenericRegister() and ↵Greg Clayton2012-08-241-0/+54
| | | | | | | | centralized the parsing of the string to encoding and string to generic register. Added code the initialize the register context in the OperatingSystemPython plug-in with the new PythonData classes, and added a test OperatingSystemPython module in lldb/examples/python/operating_system.py that we can use for testing. llvm-svn: 162530
* Handle backslash protection inside unquoted commands like:Jim Ingham2012-07-211-1/+12
| | | | | | | | | (lldb) file hello\ world correctly. <rdar://problem/11093911> llvm-svn: 160591
* Patch from Viktor Kutuzov: changes the method declarations to const for the ↵Greg Clayton2012-04-251-2/+2
| | | | | | Args::GetCommandString and Agrs::GetQuotedCommandString methods. It allows using of these methods within the other const methods. llvm-svn: 155593
* <rdar://problem/11052829>Greg Clayton2012-03-151-0/+8
| | | | | | | | Fixed a case where if you have a argument stirng that ends with a '\' character, it would infinite loop while consuming all of your memory. Also fixed a case where non-quote terminated strings would inefficiently be handled. llvm-svn: 152809
* rdar://problem/10712130Johnny Chen2012-01-191-12/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed an issue where backtick char is not properly honored when setting the frame-format variable, like the following: (lldb) settings set frame-format frame #${frame.index}: ${frame.pc}{ ${module.file.basename}{`${function.name-with-args}${function.pc-offset}}}{ at ${line.file.basename}:${line.number}}\n (lldb) settings show frame-format frame-format (string) = "frame #${frame.index}: ${frame.pc}{ `${module.file.basename}{${function.name-with-args}${function.pc-offset}}}{` at ${line.file.basename}:${line.number}}\n" (lldb) o CommandObjectSettings.h/.cpp: Modify the command object impl to require raw command string instead of parsed command string, which also fixes an outstanding issue that customizing the prompt with trailing spaces doesn't work. o Args.cpp: During CommandInterpreter::HandleCommand(), there is a PreprocessCommand phase which already strips/processes pairs of backticks as an expression eval step. There's no need to treat a backtick as starting a quote. o TestAbbreviations.py and change_prompt.lldb: Fixed incorrect test case/logic. o TestSettings.py: Remove expectedFailure decorator. llvm-svn: 148491
* Added a new class to Process.h: ProcessAttachInfo. This class contains enoughGreg Clayton2011-11-151-0/+20
| | | | | | | | | | | | | | | | | | | | | info for us to attach by pid, or by name and will also allow us to eventually do a lot more powerful attaches. If you look at the options for the "platform process list" command, there are many options which we should be able to specify. This will allow us to do things like "attach to a process named 'tcsh' that has a parent process ID of 123", or "attach to a process named 'x' which has an effective user ID of 345". I finished up the --shell implementation so that it can be used without the --tty option in "process launch". The "--shell" option now can take an optional argument which is the path to the shell to use (or a partial name like "sh" which we will find using the current PATH environment variable). Modified the Process::Attach to use the new ProcessAttachInfo as the sole argument and centralized a lot of code that was in the "process attach" Execute function so that everyone can take advantage of the powerful new attach functionality. llvm-svn: 144615
* Modified all Process::Launch() calls to use a ProcessLaunchInfo structureGreg Clayton2011-11-031-3/+35
| | | | | | | | on internal only (public API hasn't changed) to simplify the paramter list to the launch calls down into just one argument. Also all of the argument, envronment and stdio things are now handled in a much more centralized fashion. llvm-svn: 143656
* Cleaned up many error codes. For any who is filling in error strings intoGreg Clayton2011-10-261-4/+4
| | | | | | | | | | | | | lldb_private::Error objects the rules are: - short strings that don't start with a capitol letter unless the name is a class or anything else that is always capitolized - no trailing newline character - should be one line if possible Implemented a first pass at adding "--gdb-format" support to anything that accepts format with optional size/count. llvm-svn: 142999
* Re-organized the contents of RangeMap.h to be more concise and also allow ↵Greg Clayton2011-10-071-8/+23
| | | | | | | | | | for a Range, RangeArray, RangeData (range + data), or a RangeDataArray. We have many range implementations in LLDB and I will be converting over to using the classes in RangeMap.h so we can have one set of code that does ranges and searching of ranges. Fixed up DWARFDebugAranges to use the new range classes. Fixed the enumeration parsing to take a lldb_private::Error to avoid a lot of duplicated code. Now when an invalid enumeration is supplied, an error will be returned and that error will contain a list of the valid enumeration values. llvm-svn: 141382
OpenPOWER on IntegriCloud