[Lldb-commits] [PATCH] D76009: [lldb/Target] Initialize new targets environment variables from target.env-vars

2020-03-23 Thread Frederic Riss via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9228a9efc6c5: [lldb/Target] Initialize new targets 
environment variables from target.env-vars (authored by friss).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76009

Files:
  lldb/include/lldb/Target/Target.h
  lldb/source/Target/Target.cpp
  lldb/test/API/commands/settings/TestSettings.py

Index: lldb/test/API/commands/settings/TestSettings.py
===
--- lldb/test/API/commands/settings/TestSettings.py
+++ lldb/test/API/commands/settings/TestSettings.py
@@ -218,6 +218,15 @@
 self.addTearDownHook(
 lambda: self.runCmd("settings clear target.env-vars"))
 
+launch_info = self.dbg.GetTargetAtIndex(0).GetLaunchInfo()
+found_env_var = False
+for i in range(0, launch_info.GetNumEnvironmentEntries()):
+if launch_info.GetEnvironmentEntryAtIndex(i) == "MY_ENV_VAR=YES":
+found_env_var = True
+break
+self.assertTrue(found_env_var,
+"MY_ENV_VAR was not set in LunchInfo object")
+
 self.runCmd("process launch --working-dir '{0}'".format(self.get_process_working_directory()),
 RUN_SUCCEEDED)
 
@@ -238,15 +247,6 @@
 """Test that the host env vars are passed to the launched process."""
 self.build()
 
-exe = self.getBuildArtifact("a.out")
-self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
-
-# By default, inherit-env is 'true'.
-self.expect(
-'settings show target.inherit-env',
-"Default inherit-env is 'true'",
-startstr="target.inherit-env (boolean) = true")
-
 # Set some host environment variables now.
 os.environ["MY_HOST_ENV_VAR1"] = "VAR1"
 os.environ["MY_HOST_ENV_VAR2"] = "VAR2"
@@ -256,6 +256,15 @@
 os.environ.pop("MY_HOST_ENV_VAR1")
 os.environ.pop("MY_HOST_ENV_VAR2")
 
+exe = self.getBuildArtifact("a.out")
+self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+# By default, inherit-env is 'true'.
+self.expect(
+'settings show target.inherit-env',
+"Default inherit-env is 'true'",
+startstr="target.inherit-env (boolean) = true")
+
 self.addTearDownHook(unset_env_variables)
 self.runCmd("process launch --working-dir '{0}'".format(self.get_process_working_directory()),
 RUN_SUCCEEDED)
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -113,6 +113,8 @@
  target_arch.GetArchitectureName(),
  target_arch.GetTriple().getTriple().c_str());
   }
+
+  UpdateLaunchInfoFromProperties();
 }
 
 Target::~Target() {
@@ -3468,18 +3470,6 @@
 ConstString("Experimental settings - setting these won't produce "
 "errors if the setting is not present."),
 true, m_experimental_properties_up->GetValueProperties());
-
-// Update m_launch_info once it was created
-Arg0ValueChangedCallback();
-RunArgsValueChangedCallback();
-// EnvVarsValueChangedCallback(); // FIXME: cause segfault in
-// Target::GetPlatform()
-InputPathValueChangedCallback();
-OutputPathValueChangedCallback();
-ErrorPathValueChangedCallback();
-DetachOnErrorValueChangedCallback();
-DisableASLRValueChangedCallback();
-DisableSTDIOValueChangedCallback();
   } else {
 m_collection_sp =
 std::make_shared(ConstString("target"));
@@ -3498,6 +3488,18 @@
 
 TargetProperties::~TargetProperties() = default;
 
+void TargetProperties::UpdateLaunchInfoFromProperties() {
+  Arg0ValueChangedCallback();
+  RunArgsValueChangedCallback();
+  EnvVarsValueChangedCallback();
+  InputPathValueChangedCallback();
+  OutputPathValueChangedCallback();
+  ErrorPathValueChangedCallback();
+  DetachOnErrorValueChangedCallback();
+  DisableASLRValueChangedCallback();
+  DisableSTDIOValueChangedCallback();
+}
+
 bool TargetProperties::GetInjectLocalVariables(
 ExecutionContext *exe_ctx) const {
   const Property *exp_property = m_collection_sp->GetPropertyAtIndex(
Index: lldb/include/lldb/Target/Target.h
===
--- lldb/include/lldb/Target/Target.h
+++ lldb/include/lldb/Target/Target.h
@@ -211,6 +211,8 @@
 
   bool GetAutoInstallMainExecutable() const;
 
+  void UpdateLaunchInfoFromProperties();
+
 private:
   // Callbacks for m_launch_info.
   void Arg0ValueChangedCallback();
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D76009: [lldb/Target] Initialize new targets environment variables from target.env-vars

2020-03-20 Thread Frederic Riss via Phabricator via lldb-commits
friss updated this revision to Diff 251675.
friss added a comment.

Make helper function name more descriptive.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76009

Files:
  lldb/include/lldb/Target/Target.h
  lldb/source/Target/Target.cpp
  lldb/test/API/commands/settings/TestSettings.py

Index: lldb/test/API/commands/settings/TestSettings.py
===
--- lldb/test/API/commands/settings/TestSettings.py
+++ lldb/test/API/commands/settings/TestSettings.py
@@ -218,6 +218,15 @@
 self.addTearDownHook(
 lambda: self.runCmd("settings clear target.env-vars"))
 
+launch_info = self.dbg.GetTargetAtIndex(0).GetLaunchInfo()
+found_env_var = False
+for i in range(0, launch_info.GetNumEnvironmentEntries()):
+if launch_info.GetEnvironmentEntryAtIndex(i) == "MY_ENV_VAR=YES":
+found_env_var = True
+break
+self.assertTrue(found_env_var,
+"MY_ENV_VAR was not set in LunchInfo object")
+
 self.runCmd("process launch --working-dir '{0}'".format(self.get_process_working_directory()),
 RUN_SUCCEEDED)
 
@@ -238,15 +247,6 @@
 """Test that the host env vars are passed to the launched process."""
 self.build()
 
-exe = self.getBuildArtifact("a.out")
-self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
-
-# By default, inherit-env is 'true'.
-self.expect(
-'settings show target.inherit-env',
-"Default inherit-env is 'true'",
-startstr="target.inherit-env (boolean) = true")
-
 # Set some host environment variables now.
 os.environ["MY_HOST_ENV_VAR1"] = "VAR1"
 os.environ["MY_HOST_ENV_VAR2"] = "VAR2"
@@ -256,6 +256,15 @@
 os.environ.pop("MY_HOST_ENV_VAR1")
 os.environ.pop("MY_HOST_ENV_VAR2")
 
+exe = self.getBuildArtifact("a.out")
+self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+# By default, inherit-env is 'true'.
+self.expect(
+'settings show target.inherit-env',
+"Default inherit-env is 'true'",
+startstr="target.inherit-env (boolean) = true")
+
 self.addTearDownHook(unset_env_variables)
 self.runCmd("process launch --working-dir '{0}'".format(self.get_process_working_directory()),
 RUN_SUCCEEDED)
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -113,6 +113,8 @@
  target_arch.GetArchitectureName(),
  target_arch.GetTriple().getTriple().c_str());
   }
+
+  UpdateLaunchInfoFromProperties();
 }
 
 Target::~Target() {
@@ -3468,18 +3470,6 @@
 ConstString("Experimental settings - setting these won't produce "
 "errors if the setting is not present."),
 true, m_experimental_properties_up->GetValueProperties());
-
-// Update m_launch_info once it was created
-Arg0ValueChangedCallback();
-RunArgsValueChangedCallback();
-// EnvVarsValueChangedCallback(); // FIXME: cause segfault in
-// Target::GetPlatform()
-InputPathValueChangedCallback();
-OutputPathValueChangedCallback();
-ErrorPathValueChangedCallback();
-DetachOnErrorValueChangedCallback();
-DisableASLRValueChangedCallback();
-DisableSTDIOValueChangedCallback();
   } else {
 m_collection_sp =
 std::make_shared(ConstString("target"));
@@ -3498,6 +3488,18 @@
 
 TargetProperties::~TargetProperties() = default;
 
+void TargetProperties::UpdateLaunchInfoFromProperties() {
+  Arg0ValueChangedCallback();
+  RunArgsValueChangedCallback();
+  EnvVarsValueChangedCallback();
+  InputPathValueChangedCallback();
+  OutputPathValueChangedCallback();
+  ErrorPathValueChangedCallback();
+  DetachOnErrorValueChangedCallback();
+  DisableASLRValueChangedCallback();
+  DisableSTDIOValueChangedCallback();
+}
+
 bool TargetProperties::GetInjectLocalVariables(
 ExecutionContext *exe_ctx) const {
   const Property *exp_property = m_collection_sp->GetPropertyAtIndex(
Index: lldb/include/lldb/Target/Target.h
===
--- lldb/include/lldb/Target/Target.h
+++ lldb/include/lldb/Target/Target.h
@@ -211,6 +211,8 @@
 
   bool GetAutoInstallMainExecutable() const;
 
+  void UpdateLaunchInfoFromProperties();
+
 private:
   // Callbacks for m_launch_info.
   void Arg0ValueChangedCallback();
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D76009: [lldb/Target] Initialize new targets environment variables from target.env-vars

2020-03-13 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D76009#1920548 , @friss wrote:

> I put up a "fix" for the inherit-env issue mentioned here: 
> https://reviews.llvm.org/D76105
>  It is mostly orthogonal to this patch as Jim showed the behavior today is 
> already broken.


Yeah, I agree the current behavior is pretty bad, and this patch at least 
cleans up one aspect of it.

I don't have an immediate use case for the current env-vars behavior. If this 
helps you in any way, then I don't want to block it just because of that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76009



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D76009: [lldb/Target] Initialize new targets environment variables from target.env-vars

2020-03-12 Thread Frederic Riss via Phabricator via lldb-commits
friss added a comment.

I put up a "fix" for the inherit-env issue mentioned here: 
https://reviews.llvm.org/D76105
It is mostly orthogonal to this patch as Jim showed the behavior today is 
already broken.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76009



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D76009: [lldb/Target] Initialize new targets environment variables from target.env-vars

2020-03-12 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

BTW, don't worry about the `OS_ACTIVITY_DT_MODE` env var.  That's something you 
have to set when debugging or the Foundation loggging method (NSLog) will go to 
the system console not to the current terminal, so we force it on all processes 
on macOS...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76009



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D76009: [lldb/Target] Initialize new targets environment variables from target.env-vars

2020-03-12 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

In D76009#1919554 , @friss wrote:

> In D76009#1919103 , @labath wrote:
>
> > Actually, hang on.
> >
> > > 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).
>
>
> Just to be clear, in that test the host environment was modified between the 
> creation of the target and the launch which I think is pretty unlikely to 
> matter in practice.
>
> > Does this mean that the target-local value of the `target.inherit-env` 
> > setting no longer has any effect? Currently I can set it after creating a 
> > target (but before launching) to stop the process inheriting the default 
> > environment:
> > 
> >   (lldb) file /usr/bin/env
> >   Current executable set to '/usr/bin/env' (x86_64).
> >   (lldb) set set target.inherit-env false
> >   (lldb) pr la
> >   Process 26684 launched: '/usr/bin/env' (x86_64)
> >   Process 26684 exited with status = 0 (0x) 
> > 
> > 
> > I take it that after this, that will no longer be possible? It would still 
> > be possible to do that by setting the global value of the setting before 
> > creating a target, but the target-local setting would be useless (?)
>
> The inherited environment is collected the first time the property is 
> accessed and running the callback triggers this. For some reason just doing 
> `set show target.env-vars` doesn't trigger it though, I'd need to debug this 
> to understand. So yes, with this change, the `target.inherit-env` setting 
> will take effect at target creation time and not at whatever next point in 
> time the lazy logic is triggered.
>
> One way to fix this is to add another callback for the `target.inherit-env` 
> property and remove the variables that are in the environment.
>
> > I'm not really sure how these settings are supposed to work, but this does 
> > not seem ideal to me.
>
> Jim would certainly be able to explain the intent here.


I don't think the current version of the code works very well.  You can 
actually only change the value of target.inherit-env BEFORE the first run.  For 
instance:

   > lldb printenv
  warning: Overwriting existing definition for 'p'.
  warning: Overwriting existing definition for 't'.
  (lldb) target create "printenv"
  Current executable set to 'printenv' (x86_64).
  (lldb) set set target.in
  Available completions:
target.inherit-env   
target.input-path
target.inline-breakpoint-strategy
  (lldb) set set target.inherit-env 0
  (lldb) set show target.env-vars
  target.env-vars (dictionary of strings) =
  (lldb) run
  Process 65813 launched: '/tmp/printenv' (x86_64)
  0  :OS_ACTIVITY_DT_MODE=enable:
  Process 65813 exited with status = 0 (0x) 
  (lldb) set set target.inherit-env 1
  (lldb) run
  Process 65816 launched: '/tmp/printenv' (x86_64)
  0  :OS_ACTIVITY_DT_MODE=enable:
  Process 65816 exited with status = 0 (0x) 

lldb had way more environment variables than that...

And conversely, if you run with inherit-env set to 1 and then set it to 0, you 
still get all the environment variables.

For this to behave correctly, we would as Fred suggests have to add a callback 
to setting inherit-env and add or remove the host's variables as appropriate 
when it changes.

IMO there should really also be a "target create" option for inherit-env.   
This is usually something you want to do depending on the type of target, and 
you don't generally change it after the fact.  It's awkward to have to change a 
setting to create this or that target in a certain mode.  It would be better if 
we had predicates for the settings, then you could do something like `settings 
set target[platform=remote].inherit-env 0`.  But we haven't gotten there yet...

Note, for this to be really useful for remote debugging, lldb should be able to 
fetch the monitor's environment and use that to prime the target's environment 
when inherit-env is on.  That would be a much more useful thing to do.  But 
that's way outside the scope of this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76009



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D76009: [lldb/Target] Initialize new targets environment variables from target.env-vars

2020-03-12 Thread Frederic Riss via Phabricator via lldb-commits
friss added a comment.

In D76009#1919103 , @labath wrote:

> Actually, hang on.
>
> > 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).


Just to be clear, in that test the host environment was modified between the 
creation of the target and the launch which I think is pretty unlikely to 
matter in practice.

> Does this mean that the target-local value of the `target.inherit-env` 
> setting no longer has any effect? Currently I can set it after creating a 
> target (but before launching) to stop the process inheriting the default 
> environment:
> 
>   (lldb) file /usr/bin/env
>   Current executable set to '/usr/bin/env' (x86_64).
>   (lldb) set set target.inherit-env false
>   (lldb) pr la
>   Process 26684 launched: '/usr/bin/env' (x86_64)
>   Process 26684 exited with status = 0 (0x) 
> 
> 
> I take it that after this, that will no longer be possible? It would still be 
> possible to do that by setting the global value of the setting before 
> creating a target, but the target-local setting would be useless (?)

The inherited environment is collected the first time the property is accessed 
and running the callback triggers this. For some reason just doing `set show 
target.env-vars` doesn't trigger it though, I'd need to debug this to 
understand. So yes, with this change, the `target.inherit-env` setting will 
take effect at target creation time and not at whatever next point in time the 
lazy logic is triggered.

One way to fix this is to add another callback for the `target.inherit-env` 
property and remove the variables that are in the environment.

> I'm not really sure how these settings are supposed to work, but this does 
> not seem ideal to me.

Jim would certainly be able to explain the intent here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76009



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D76009: [lldb/Target] Initialize new targets environment variables from target.env-vars

2020-03-12 Thread Pavel Labath via Phabricator via lldb-commits
labath removed a reviewer: labath.
labath added a comment.
This revision now requires review to proceed.

Actually, hang on.

> 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).

Does this mean that the target-local value of the `target.inherit-env` setting 
no longer has any effect? Currently I can set it after creating a target (but 
before launching) to stop the process inheriting the default environment:

  (lldb) file /usr/bin/env
  Current executable set to '/usr/bin/env' (x86_64).
  (lldb) set set target.inherit-env false
  (lldb) pr la
  Process 26684 launched: '/usr/bin/env' (x86_64)
  Process 26684 exited with status = 0 (0x) 

I take it that after this, that will no longer be possible? It would still be 
possible to do that by setting the global value of the setting before creating 
a target, but the target-local setting would be useless (?)

I'm not really sure how these settings are supposed to work, but this does not 
seem ideal to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76009



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D76009: [lldb/Target] Initialize new targets environment variables from target.env-vars

2020-03-12 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

Another option might be to make TargetProperties a member instead of a base 
class. I don't think the current setup makes for a particularly clean design. 
If `TargetProperties` is among the last Target members being initialized, then 
calling the callbacks from the constructor should "just work".




Comment at: lldb/include/lldb/Target/Target.h:214
 
+  void RunCallbacks();
+

This name is very nondescript. I think it would be better to name this 
according to what it does, instead of how it does it. 
`LoadDefaultPropertyValues()` ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76009



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D76009: [lldb/Target] Initialize new targets environment variables from target.env-vars

2020-03-11 Thread Frederic Riss via Phabricator via lldb-commits
friss created this revision.
friss added reviewers: jingham, labath.
Herald added a project: LLDB.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76009

Files:
  lldb/include/lldb/Target/Target.h
  lldb/source/Target/Target.cpp
  lldb/test/API/commands/settings/TestSettings.py

Index: lldb/test/API/commands/settings/TestSettings.py
===
--- lldb/test/API/commands/settings/TestSettings.py
+++ lldb/test/API/commands/settings/TestSettings.py
@@ -218,6 +218,15 @@
 self.addTearDownHook(
 lambda: self.runCmd("settings clear target.env-vars"))
 
+launch_info = self.dbg.GetTargetAtIndex(0).GetLaunchInfo()
+found_env_var = False
+for i in range(0, launch_info.GetNumEnvironmentEntries()):
+if launch_info.GetEnvironmentEntryAtIndex(i) == "MY_ENV_VAR=YES":
+found_env_var = True
+break
+self.assertTrue(found_env_var,
+"MY_ENV_VAR was not set in LunchInfo object")
+
 self.runCmd("process launch --working-dir '{0}'".format(self.get_process_working_directory()),
 RUN_SUCCEEDED)
 
@@ -238,15 +247,6 @@
 """Test that the host env vars are passed to the launched process."""
 self.build()
 
-exe = self.getBuildArtifact("a.out")
-self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
-
-# By default, inherit-env is 'true'.
-self.expect(
-'settings show target.inherit-env',
-"Default inherit-env is 'true'",
-startstr="target.inherit-env (boolean) = true")
-
 # Set some host environment variables now.
 os.environ["MY_HOST_ENV_VAR1"] = "VAR1"
 os.environ["MY_HOST_ENV_VAR2"] = "VAR2"
@@ -256,6 +256,15 @@
 os.environ.pop("MY_HOST_ENV_VAR1")
 os.environ.pop("MY_HOST_ENV_VAR2")
 
+exe = self.getBuildArtifact("a.out")
+self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+# By default, inherit-env is 'true'.
+self.expect(
+'settings show target.inherit-env',
+"Default inherit-env is 'true'",
+startstr="target.inherit-env (boolean) = true")
+
 self.addTearDownHook(unset_env_variables)
 self.runCmd("process launch --working-dir '{0}'".format(self.get_process_working_directory()),
 RUN_SUCCEEDED)
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -81,6 +81,19 @@
   return class_name;
 }
 
+void TargetProperties::RunCallbacks() {
+  // Update m_launch_info once it was created
+  Arg0ValueChangedCallback();
+  RunArgsValueChangedCallback();
+  EnvVarsValueChangedCallback();
+  InputPathValueChangedCallback();
+  OutputPathValueChangedCallback();
+  ErrorPathValueChangedCallback();
+  DetachOnErrorValueChangedCallback();
+  DisableASLRValueChangedCallback();
+  DisableSTDIOValueChangedCallback();
+}
+
 Target::Target(Debugger &debugger, const ArchSpec &target_arch,
const lldb::PlatformSP &platform_sp, bool is_dummy_target)
 : TargetProperties(this),
@@ -113,6 +126,8 @@
  target_arch.GetArchitectureName(),
  target_arch.GetTriple().getTriple().c_str());
   }
+
+  RunCallbacks();
 }
 
 Target::~Target() {
@@ -3468,18 +3483,6 @@
 ConstString("Experimental settings - setting these won't produce "
 "errors if the setting is not present."),
 true, m_experimental_properties_up->GetValueProperties());
-
-// Update m_launch_info once it was created
-Arg0ValueChangedCallback();
-RunArgsValueChangedCallback();
-// EnvVarsValueChangedCallback(); // FIXME: cause segfault in
-// Target::GetPlatform()
-InputPathValueChangedCallback();
-OutputPathValueChangedCallback();
-ErrorPathValueChangedCallback();
-DetachOnErrorValueChangedCallback();
-DisableASLRValueChangedCallback();
-DisableSTDIOValueChangedCallback();
   } else {