teak-llvm/lldb/packages/Python/lldbsuite/test/python_api
Pavel Labath 62930e57eb Add Utility/Environment class for handling... environments
Summary:
There was some confusion in the code about how to represent process
environment. Most of the code (ab)used the Args class for this purpose,
but some of it used a more basic StringList class instead. In either
case, the fact that the underlying abstraction did not provide primitive
operations for the typical environment operations meant that even a
simple operation like checking for an environment variable value was
several lines of code.

This patch adds a separate Environment class, which is essentialy a
llvm::StringMap<std::string> in disguise. To standard StringMap
functionality, it adds a couple of new functions, which are specific to
the environment use case:
- (most important) envp conversion for passing into execve() and likes.
  Instead of trying to maintain a constantly up-to-date envp view, it
  provides a function which creates a envp view on demand, with the
  expectation that this will be called as the very last thing before
  handing the value to the system function.
- insert(StringRef KeyEqValue) - splits KeyEqValue into (key, value)
  pair and inserts it into the environment map.
- compose(value_type KeyValue) - takes a map entry and converts in back
  into "KEY=VALUE" representation.

With this interface most of the environment-manipulating code becomes
one-liners. The only tricky part was maintaining compatibility in
SBLaunchInfo, which expects that the environment entries are accessible
by index and that the returned const char* is backed by the launch info
object (random access into maps is hard and the map stores the entry in
a deconstructed form, so we cannot just return a .c_str() value). To
solve this, I have the SBLaunchInfo convert the environment into the
"envp" form, and use it to answer the environment queries. Extra code is
added to make sure the envp version is always in sync.

(This also improves the layering situation as Args was in the Interpreter module
whereas Environment is in Utility.)

Reviewers: zturner, davide, jingham, clayborg

Subscribers: emaste, lldb-commits, mgorny

Differential Revision: https://reviews.llvm.org/D41359

llvm-svn: 322174
2018-01-10 11:57:31 +00:00
..
breakpoint Switch SBBreakpointLocation to use a weak_ptr 2017-03-01 10:08:48 +00:00
class_members use assertEquals in TestSBTypeClassMembers 2016-09-28 20:39:50 +00:00
debugger *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
default-constructor Make breakpoint names real entities. 2017-09-14 20:22:49 +00:00
disassemble-raw-data [LLDB][MIPS] All tests get errors in dotest after this test. 2016-10-10 10:47:53 +00:00
event *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
exprpath_synthetic Initial patchset to get the testsuite running against armv7 and arm64 iOS devices. 2017-09-25 18:19:39 +00:00
file_handle Revert r317182 for https://reviews.llvm.org/D39128 2017-11-02 03:17:07 +00:00
findvalue_duplist *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
formatters *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
frame Initial patchset to get the testsuite running against armv7 and arm64 iOS devices. 2017-09-25 18:19:39 +00:00
function_symbol *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
hello_world Initial patchset to get the testsuite running against armv7 and arm64 iOS devices. 2017-09-25 18:19:39 +00:00
interpreter *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
lldbutil Initial patchset to get the testsuite running against armv7 and arm64 iOS devices. 2017-09-25 18:19:39 +00:00
module_section *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
name_lookup Fix TestNameLookup for GCC 2017-02-15 12:27:16 +00:00
objc_type *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
process Enable TestReadMemCString on non-darwin targets 2017-12-22 10:26:59 +00:00
rdar-12481949 *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
sbdata Fix SBData::SetData() so that it always sets the address byte size correctly and added a test. 2017-01-25 21:50:28 +00:00
sblaunchinfo Add Utility/Environment class for handling... environments 2018-01-10 11:57:31 +00:00
sbstructureddata Added new API to SBStructuredData class 2017-05-29 08:25:46 +00:00
sbtype_typeclass Initial patchset to get the testsuite running against armv7 and arm64 iOS devices. 2017-09-25 18:19:39 +00:00
sbvalue_const_addrof
sbvalue_persist Makefile.rules: compile all tests with -fno-limit-debug-info 2017-12-04 13:31:56 +00:00
section *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
signals *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
symbol-context Fix TestSymbolContextTwoFiles on Android after rL281595 2016-09-15 10:49:55 +00:00
target *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
thread *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
type *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
value Fix dereferencing of pointers to empty classes 2017-01-07 16:39:07 +00:00
value_var_update *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
watchpoint Remove android watchpoint xfails 2017-11-02 22:12:55 +00:00
.categories