[all-commits] [llvm/llvm-project] 9228a9: [lldb/Target] Initialize new targets environment v...

fredriss via All-commits all-commits at lists.llvm.org
Mon Mar 23 07:59:02 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 9228a9efc6c57a932d936ebb214f6ff5bafe79ff
      https://github.com/llvm/llvm-project/commit/9228a9efc6c57a932d936ebb214f6ff5bafe79ff
  Author: Fred Riss <friss at apple.com>
  Date:   2020-03-23 (Mon, 23 Mar 2020)

  Changed paths:
    M lldb/include/lldb/Target/Target.h
    M lldb/source/Target/Target.cpp
    M lldb/test/API/commands/settings/TestSettings.py

  Log Message:
  -----------
  [lldb/Target] Initialize new targets environment variables from target.env-vars

Summary:
The TargetProperties constructor invokes a series of callbacks to
prime the properties from the default ones. The one callback in
charge of updating the inferior environment was commented out
because it crashed.

The reason for the crash is that TargetProperties is a parent class
of Target and the callbacks were invoked using a Target that was
not fully initialized. This patch moves the initial callback
invocations to a separate function that can be called at the end
the Target constructor, thus preventing the crash.

One existing test had to be modified, because the initialization of
the environment properties now take place at the time the target is
created, not at the first use of the environment (usually launch
time).

The added test checks that the LaunchInfo object returned by
the target has been primed with the values from the settings.

Reviewers: jingham, labath

Subscribers: lldb-commits

Tags: #lldb

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


  Commit: cd7b45057ca9bc72b99a0abc6c9be25e0f72fbcf
      https://github.com/llvm/llvm-project/commit/cd7b45057ca9bc72b99a0abc6c9be25e0f72fbcf
  Author: Fred Riss <friss at apple.com>
  Date:   2020-03-23 (Mon, 23 Mar 2020)

  Changed paths:
    M lldb/include/lldb/API/SBTarget.h
    M lldb/source/API/SBTarget.cpp
    M lldb/test/API/commands/settings/TestSettings.py

  Log Message:
  -----------
  [lldb/API] Make Launch(Simple) use args and env from target properties

Summary:
When no arguments or environment is provided to SBTarget::LaunchSimple,
make it use the values surrently set in the target properties. You can
get the current behavior back by passing an empty array instead.

It seems like using the target defaults is a much more intuitive
behavior for those APIs. It's unllikely that anyone passed NULL/None to
this API after having set properties in order to explicitely ignore them.

One direct application of this change is within the testsuite. We have
plenty of tests calling LaunchSimple and passing None as environment.
If you passed --inferior-env to dotest.py to, for example, set
(DY)LD_LIBRARY_PATH, it wouldn't be taken into account.

Reviewers: jingham, labath, #libc_abi!

Subscribers: libcxx-commits, lldb-commits

Tags: #lldb, #libc_abi

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


  Commit: b4a6e63ea12309bf667d1569a20ec5b081cbf2a4
      https://github.com/llvm/llvm-project/commit/b4a6e63ea12309bf667d1569a20ec5b081cbf2a4
  Author: Fred Riss <friss at apple.com>
  Date:   2020-03-23 (Mon, 23 Mar 2020)

  Changed paths:
    M lldb/include/lldb/Target/Target.h
    M lldb/source/Commands/CommandObjectTarget.cpp
    M lldb/source/Target/Target.cpp
    M lldb/source/Target/TargetProperties.td
    M lldb/test/API/commands/settings/TestSettings.py

  Log Message:
  -----------
  [lldb/Target] Rework the way the inferior environment is created

Summary:
The interactions between the environment settings (`target.env-vars`,
`target.inherit-env`) and the inferior life-cycle are non-obvious
today. For example, if `target.inherit-env` is set, the `target.env-vars`
setting will be augmented with the contents of the host environment
the first time the launch environment is queried (usually at
launch). After that point, toggling `target.inherit-env` will have no
effect as there's no tracking of what comes from the host and what is
a user setting.

This patch computes the environment every time it is queried rather
than updating the contents of the `target.env-vars` property. This
means that toggling the `target.inherit-env` property later will now
have the intended effect.

This patch also adds a `target.unset-env-vars` settings that one can
use to remove variables from the launch environment. Using this, you
can inherit all but a few of the host environment.

The way the launch environment is constructed is:
  1/ if `target.inherit-env` is set, then read the host environment
  into the launch environment.
  2/ Remove for the environment the variables listed in
  `target.unset-env`.
  3/ Augment the launch environment with the contents of
  `target.env-vars`. This overrides any common values with the host
  environment.

The one functional difference here that could be seen as a regression
is that `target.env-vars` will not contain the inferior environment
after launch. The patch implements a better alternative in the
`target show-launch-environment` command which will return the
environment computed through the above rules.

Reviewers: labath, jingham

Subscribers: lldb-commits

Tags: #lldb

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


Compare: https://github.com/llvm/llvm-project/compare/f383fb40b17b...b4a6e63ea123


More information about the All-commits mailing list