[Lldb-commits] [PATCH] D26883: Demonstrate proposed new Args API

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Tue Nov 22 02:59:11 PST 2016


labath added a comment.

In https://reviews.llvm.org/D26883#601638, @jingham wrote:

> The outermost quote character is syntactically significant in the lldb command language.  If you say:
>
> memory read -c `count_var` 0x123345
>
> then lldb evaluates the expression in the backticks, replacing the argument with the result of the expression.  So you can't get rid of the quote character altogether.  The other use is in completion to figure out what an unterminated quoted string should be completed with.
>
> Since only the outermost quoting character is important, I think the problem is more tractable than your examples would suggest.


I didn't mention backticks, as (to use bash parlor) command substitution and word splitting are two separate passes. backticks can be embedded into a single word, which also contains other kinds of quote characters, so storing the quote character alongside the word-split argument is not going to help you implement command substitution. LLDB actually handles this mostly correctly now (notice that in each case the input gets parsed as a single word):

  (lldb) `1+1`
  error: '2' is not a valid command.
  error: Unrecognized command '2'.
  (lldb) a`1+1`a
  error: 'a2a' is not a valid command.
  error: Unrecognized command 'a2a'.
  (lldb) `1+1`a`2+2`
  error: '2a4' is not a valid command.
  error: Unrecognized command '2a4'.
  (lldb) "a a"`1+1`"b a"
  error: unknown command shorthand suffix: ' a'
  error: Unrecognized command 'a a2b a'.

The reason this works is because the command substitution is done in a different place in the code, so I still hold my view that the Args class does not need to differentiate between the different quote characters as it is just a holder for a word-split input.

That said, none of this should affect this patch. If the quote char field has been there until now, it can stay a little longer.


Repository:
  rL LLVM

https://reviews.llvm.org/D26883





More information about the lldb-commits mailing list