[Lldb-commits] [PATCH] D106999: [LLDB][GUI] Add Environment Variable Field

Greg Clayton via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Jul 28 16:33:29 PDT 2021


clayborg added inline comments.


================
Comment at: lldb/source/Core/IOHandlerCursesGUI.cpp:1924
+
+class EnvironmentVariableFieldDelegate : public FieldDelegate {
+public:
----------------
There are other things that could benefit from having two text fields, like source mapping:
```
(lldb) apropos target.source-map
No commands found pertaining to 'target.source-map'. Try 'help' to see a complete list of debugger commands.

The following settings variables may relate to 'target.source-map':
  target.source-map -- Source path remappings apply substitutions to the paths of source files, typically needed to debug from a different host than the one that built the
                       target.  The source-map property consists of an array of pairs, the first element is a path prefix, and the second is its replacement.  The syntax is
                       `prefix1 replacement1 prefix2 replacement2...`.  The pairs are checked in order, the first prefix that matches is used, and that prefix is substituted
                       with the replacement.  A common pattern is to use source-map in conjunction with the clang -fdebug-prefix-map flag.  In the build, use
                       `-fdebug-prefix-map=/path/to/build_dir=.` to rewrite the host specific build directory to `.`.  Then for debugging, use `settings set target.source-map .
                       /path/to/local_dir` to convert `.` to a valid local path.
```

This would be very close to the EnvironmentVariableFieldDelegate class, but instead of "Name" and "Value" the fields would be "Prefix" and "Replacement". In the source map case the two fields would be a DirectoryFieldDelegate objects. So we could make a base class like PairFieldDelegate that much of the functionality in this class could be moved to. The constructor for the PairFieldDelegate could take two "FieldDelegate *" arguments. So then EnvironmentVariableFieldDelegate could inherit from PairFieldDelegate and this constructor would look like:

```
EnvironmentVariableFieldDelegate(): 
  PairFieldDelegate(new EnvironmentVariableNameFieldDelegate("Name", ""),
                               new TextFieldDelegate("Value", "", /*required=*/false))
```
Not required, but it might make it a more useful set of reusable classes for this curses field stuff. Let me know if you are up for doing an approach like this or not


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106999



More information about the lldb-commits mailing list