[Lldb-commits] [PATCH] D64194: [lldb] Fix crash due to dollar character in variable names.

Greg Clayton via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Jul 8 13:04:27 PDT 2019


clayborg added a comment.

Do we really expect users to actually write code where variables start with '$'? We will need to make some clear rules of the lookup order if so. I would suggest the following order

- look for real variables by exact name match first
- look for expression global variables next
- look for expression results next ($<digit>)
- look for registers



================
Comment at: lldb/packages/Python/lldbsuite/test/expression_command/dollar-in-variable/main.c:5
+  int $foo = 42;
+  return 0; //%self.expect("expr $foo", substrs=['(int) $0 = 42'])
+}
----------------
The idea was that a "$" prefix wouldn't be found in normal code. In LLDB $ has the following special use cases:
- all expression results are named $<digit> just like LLDB
- if you use $ it can be followed by a register name so you can access registers in expressions ($rax, $sp, etc)
- any definitions in your expression where the variable is prefixed with '$' will become an expression global variable available to all subsequent expressions:
```
(lldb) expr int $my_global = 12;
(lldb) expr ++$my_global
```
- All function names that start with '$' are currently thought to be reserved for expression and so that any functions we create don't interact with real functions


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64194/new/

https://reviews.llvm.org/D64194





More information about the lldb-commits mailing list