This is an archive of the discontinued LLVM Phabricator instance.

Add -exec-arguments command
ClosedPublic

Authored by ki.stfu on Jan 14 2015, 6:01 AM.

Details

Summary

This patch adds -exec-arguments command for lldb-mi. -exec-arguments command allows to specify arguments for executable file in MI mode. Also it contains tests for that command.

Btw, new added files was formatted by clang-format.

Diff Detail

Repository
rL LLVM

Event Timeline

ki.stfu updated this revision to Diff 18148.Jan 14 2015, 6:01 AM
ki.stfu retitled this revision from to Add -exec-arguments command.
ki.stfu updated this object.
ki.stfu edited the test plan for this revision. (Show Details)
ki.stfu added subscribers: Unknown Object (MLST), abidh.
ki.stfu removed a subscriber: abidh.
ki.stfu updated this object.Jan 14 2015, 6:13 AM
abidh edited edge metadata.Jan 19 2015, 4:44 AM

Looks ok to me. 2 comments though.

  1. Why are changes in SBTarget when you are not using them.
  2. I think the test cases for arguments are currently skipped (@unittest2.skip("requires 'quotes' and 'CLI support' patches")). Currently, we can test for argc. So I think at least that portion should be enabled as that gives us some coverage. I will have to see why argv is not being evaluated.

If nobody else comments then I can commit this patch in a day or 2 with modification suggested above.

So the way you set arguments when you launch a process through the SB API's (besides some old unstructured API's that we'll eventually deprecate) is through the SBLaunchInfo. You're adding another way to get and set the arguments that's independent of that.

I'd rather we didn't create another way to specify launch arguments. You can already do that by creating an SBLaunchInfo with the appropriate args set, and use that for the launch.

The SBTarget already provides a way to get the arguments (SBTarget::GetNumArguments/GetArgumentAtIndex.) If you need to provide a way to get the current or previous launch arguments then we should add an API to copy out the SBLaunchInfo that was used for the launch. That's not currently kept around so you may have to reconstruct it from bits sitting in the target, but that way we keep one structured way to get at all the launch parameters...

In D6965#110399, @abidh wrote:
  1. Why are changes in SBTarget when you are not using them.

Oops. It's the old version. I'll update patch right now.

  1. I think the test cases for arguments are currently skipped (@unittest2.skip("requires 'quotes' and 'CLI support' patches")). Currently, we can test for argc. So I think at least that portion should be enabled as that gives us some coverage. I will have to see why argv is not being evaluated.

Ok. I think that I can fix this test using -interpreter-exec command.

ki.stfu updated this revision to Diff 18397.Jan 19 2015, 12:52 PM
ki.stfu updated this object.
ki.stfu edited edge metadata.

Update patch:

  • Fix test_lldbmi_setargs test and enable it.
  • Set arguments directly to target (don't save it in SessionInfo)

So the way you set arguments when you launch a process through the SB API's (besides some old unstructured API's that we'll eventually deprecate) is through the SBLaunchInfo. You're adding another way to get and set the arguments that's independent of that.

I'd rather we didn't create another way to specify launch arguments. You can already do that by creating an SBLaunchInfo with the appropriate args set, and use that for the launch.

The SBTarget already provides a way to get the arguments (SBTarget::GetNumArguments/GetArgumentAtIndex.) If you need to provide a way to get the current or previous launch arguments then we should add an API to copy out the SBLaunchInfo that was used for the launch. That's not currently kept around so you may have to reconstruct it from bits sitting in the target, but that way we keep one structured way to get at all the launch parameters...

Yes, I had seen these functions but I was working on CLI support in MI mode. My goal was to fix the following cases:
First:

-file-exec-and-symbols ~/p/hello
-exec-arguments foo bar
-interpreter-exec command "r"

Second:

-file-exec-and-symbols ~/p/hello
-interpreter-exec command "settings set target.run-args foo bar"
-exec-run

Your way didn't work because when we specify arguments via "settings set target.run-args" they are stored as Debugger's property. Initially I had tried to set and get argument directly but it was awful because SBDebugger::GetInternalVariableValue returns arguments in dumped format, like:

[0]: "--arg1"
[1]: "2nd arg"
[2]: "third_arg"
[4]: "fourth=\"4th arg\""

Therefore I decided to extend public API.

If we want to have a way to directly set the arguments in a Target, I would prefer to have the SBTarget vend the SBLaunchInfo that it will use when it launches (if you don't give it another SBLaunchInfo) and then set the arguments there.

Right now it is pretty incoherent, you can set arguments in the run-args, you can set them directly when you call launch, you can set them in a SBLaunchInfo which you pass to the target, and now you can set then by passing in an SBArgs. That's too many ways to do the same thing.

Of the ones that it would be good to reuse, I think the SBLaunchInfo is the best structured, and encapsulates all the various options. So we should expose that rather than make another entity.

If we want to have a way to directly set the arguments in a Target, I would prefer to have the SBTarget vend the SBLaunchInfo that it will use when it launches (if you don't give it another SBLaunchInfo) and then set the arguments there.

The "process launch" command uses lldb_private (i.e. not public lldb API) and it creates LaunchInfo every time it is executed. I can't affect to that LaunchInfo instance using the public API.

Right now it is pretty incoherent, you can set arguments in the run-args, you can set them directly when you call launch, you can set them in a SBLaunchInfo which you pass to the target, and now you can set then by passing in an SBArgs. That's too many ways to do the same thing.

Maybe it's so but I don't want to create one more way of setting arguments in lldb_private::Target class. I just have made a wrapper for the existing method.

My suggestion was to have the SBTarget vend the SBLaunchInfo it WOULD use if you were to call launch without providing an SBLaunchInfo of your own. Unfortunately, the underlying target doesn't actually use a ProcessLaunch info to store these settings, it stores the individual bits. That's purely historical: the ProcessLaunchInfo was a later invention, and was layered onto of the existing code without re-working it. We should probably change that at some point.

So if you want extra credit it would be great to re-plumb this stuff. But I can understand if that's way more than you thought you were biting off for this task. I'm still unhappy about adding yet another way to set run arguments, and once it's in the SB API's we're stuck with it for a while.

But given that it's our fault we are in this situation, it doesn't seem fair to push this too hard.

Jim

clayborg requested changes to this revision.Jan 21 2015, 5:04 PM
clayborg added a reviewer: clayborg.
clayborg added a subscriber: clayborg.

I would vote for a different approach altogether which would be a cleaner all around implementation:

Have the lldb-mi have a variable whose type is: lldb::SBLaunchInfo.

lldb::SBLaunchInfo m_launch_info;

And somehow you make a function that all command can access this launch info with like:

lldb::SBLaunchInfo &GetGlobalLaunchInfo();

This probably should be an instance variable that is part of the global MI interpreter.

Any calls to things like:

-file-exec-and-symbols ~/p/hello

Would do:

bool add_as_first_arg = true;
GetGlobalLaunchInfo().SetExecutableFile(lldb::SBFileSpec("~/p/hello"), add_as_first_arg);

Then:

-exec-arguments foo bar

would do:

const bool append_args = true;
GetGlobalLaunchInfo().SetArguments(argv, append_args);

And then:

-interpreter-exec command "r"

would do:

lldb::SBProcess process = target.Launch (GetGlobalLaunchInfo(), error);

This give you the most flexibility to set/change stuff before you launch, and setting up SBLaunchInfo is the current best practices way to launch a process.

This revision now requires changes to proceed.Jan 21 2015, 5:04 PM

This probably should be an instance variable that is part of the global MI interpreter.

And then:

-interpreter-exec command "r"

would do:

lldb::SBProcess process = target.Launch (GetGlobalLaunchInfo(), error);

This give you the most flexibility to set/change stuff before you launch, and setting up SBLaunchInfo is the current best practices way to launch a process.

The "r" command is the CLI command which is located in source/Commands/CommandObjectProcess.cpp file. The MI module executes it using SBInterpreter::HandleCommand function and it seems like a user has typed the "r" command in the shell. I think that it's inadmissible to reference to MI module's variable in LLDB's commands because MI it's not a part of LLDB kernel. It just a extra module and LLDB shouldn't depend on it.

Are there any other opinions?

ki.stfu requested a review of this revision.Jan 29 2015, 3:41 PM
ki.stfu edited edge metadata.

I stand by my recommendation. There are many commands that build up what is effectively a SBLaunchInfo and eventually a command that makes the program run. It is quite sad to see things like '-interpreter-exec command "r"' in a MI command log. Do you really expect all implementations of MI to implement GDB commands? Is a packet that says "-exe-launch"? The only thing that should be exposing command line execution is when the user types something. And the command interpreter could then be anything and GDB commands would not be expected to work.

Greg

emaste added a subscriber: emaste.Jan 30 2015, 10:51 AM

I stand by my recommendation.

But your recommendation can't be applied in this case (perhaps I explained it poorly).
The "r" command creates LaunchInfo every time it's executed. If you look at CommandObjectProcessLaunch you will see that LaunchInfo (which is passed into Target::Launch) is a class member. And this way is used in many commands. I can't create global LaunchInfo which will be used by these commands and MI. I think it would be strange to use one global variable in CLI commands and MI module because at the moment CommandObjectProcess.cpp looks like separate module which implements and registers commands inside itself and it doesn't provide any external symbols (only 1 class CommandObjectMultiwordProcess). I can't use your recommendation here.

There are many commands that build up what is effectively a SBLaunchInfo and eventually a command that makes the program run.

I agree that LaunchInfo is much better than many-many arguments of Launch method or than a lot of setters/getters for properties. But current implementation of process commands doesn't allow me to use single LaunchInfo for them and MI. I don't create an additional method for setting of arguments. I just have made a wrapper for the existing method.

It is quite sad to see things like '-interpreter-exec command "r"' in a MI command log. Do you really expect all implementations of MI to implement GDB commands? Is a packet that says "-exe-launch"? The only thing that should be exposing command line execution is when the user types something. And the command interpreter could then be anything and GDB commands would not be expected to work.

huh. Perhaps you didn't face with that but it's impossible to specify an architecture (what can be done by using "target create") or select a remote platform and connect to it (using platform commands) or launch a program and stop at entry (process launch -s) or load a python scripts (using script commands) or ... and so on.
It's a known problem and GDB/MI allows to use CLI and MI commands simultaneously. Also smart guys invented -interpreter-exec command (see what this command is doing here if it's not clear) and now we don't need to introduce a new syntax or commands, we can use CLI commands instead.

Therefore I think '-interpreter-exec command "r"' is an important case which should work too, also as the case when arguments are set up by "settings set target.run-args" after that -exec-run is called.

ki.stfu added a subscriber: zturner.

FYI: I looked how run-args are specified for Target class. At the moment it can be done by using "settings set target.run-args" command which sets Debugger's "target.run-args" property. But actually this property is mapped to Target's ePropertyRunArgs property which can be read by Target::GetRunArguments and modified by Target::SetRunArguments. You can see in Target.cpp that Target::Launch gets these arguments by using Target::GetRunArguments.

My implementation of "-exec-arguments" uses Target::SetRunArguments (which is wrapped in SBTarget::SetRunArguments) and as I said above it's the same thing. Thus the my implementation works the same way as "settings set target.run-args" and if you don't like it, then this architecture can be rewritten, but it's outside the scope of this CL.

The fix I requested should be easy to implement as noted above in the code comments.

Step 1:
1 - Add a "SBLaunchInfo m_lldbLaunchInfo" as a member variable in the CMICmnLLDBDebugSessionInfo class next to the "SBTarget m_lldbTarget" member variable
2 - Add a SBAttachInfo for attaching as well if needed
3 - Make code changes I specify above
4 - Hook up more calls to modify data in the SBLaunchInfo and SBAttachInfo
5 - Remove SBArgs.h and SBArgs.cpp

This will provide the cleanest implementation and allow of the most flexibility in setting the environment variables (just modify SBLaunchInfo), working directory (modify SBLaunchInfo), etc, then when you launch you get to just use the launch info you have built up.

tools/lldb-mi/MICmdCmdExec.cpp
95–99 ↗(On Diff #18397)

If we store a SBLaunchInfo in CMICmnLLDBDebugSessionInfo then this becomes:

lldb::SBProcess process = rSessionInfo.m_lldbTarget.Launch(rSessionInfo.m_lldbLaunchInfo, error);

And the SBLaunchInfo doesn't require the lldb::LaunchFlags::eLaunchFlagDebug as that is implied by the launch itself. You can set it in the m_lldbLaunchInfo if you want when you construct it inside CMICmnLLDBDebugSessionInfo.

1076–1110 ↗(On Diff #18397)

If we store a SBLaunchInfo in CMICmnLLDBDebugSessionInfo we can turn this function into:

bool
CMICmdCmdExecArguments::Execute(void)
{
    CMICMDBASE_GETOPTION(pArgArguments, ListOfN, m_constStrArgArguments);

    CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
    const char *argv[2] = { nullptr, nullptr };
    const bool append = true;
    CMIUtilString strArg;
    size_t nArgIndex = 0;
    while (pArgArguments->GetExpectedOption<CMICmdArgValString, CMIUtilString>(strArg, nArgIndex))
    {
        argv[0] = strArg.c_str();
        rSessionInfo.m_lldbLaunchInfo.SetArguments (argv, append);
        ++nArgIndex;
    }

    return MIstatus::success;
}

I forgot one step:

You will need to do a:

m_lldbLaunchInfo.SetListener(rSessionInfo.m_rLlldbListener);

before you call

lldb::SBProcess process  = m_lldbTarget.Launch(m_launch, error);

The fix I requested should be easy to implement as noted above in the code comments.

This will provide the cleanest implementation and allow of the most flexibility in setting the environment variables (just modify SBLaunchInfo), working directory (modify SBLaunchInfo), etc, then when you launch you get to just use the launch info you have built up.

Greg, we are talking about different things. Your patch looks good but it wouldn't work on test case which I described earlier:

So the way you set arguments when you launch a process through the SB API's (besides some old unstructured API's that we'll eventually deprecate) is through the SBLaunchInfo. You're adding another way to get and set the arguments that's independent of that.

I'd rather we didn't create another way to specify launch arguments. You can already do that by creating an SBLaunchInfo with the appropriate args set, and use that for the launch.

The SBTarget already provides a way to get the arguments (SBTarget::GetNumArguments/GetArgumentAtIndex.) If you need to provide a way to get the current or previous launch arguments then we should add an API to copy out the SBLaunchInfo that was used for the launch. That's not currently kept around so you may have to reconstruct it from bits sitting in the target, but that way we keep one structured way to get at all the launch parameters...

Yes, I had seen these functions but I was working on CLI support in MI mode. My goal was to fix the following cases:
First:

-file-exec-and-symbols ~/p/hello
-exec-arguments foo bar
-interpreter-exec command "r"

Second:

-file-exec-and-symbols ~/p/hello
-interpreter-exec command "settings set target.run-args foo bar"
-exec-run

Your way didn't work because when we specify arguments via "settings set target.run-args" they are stored as Debugger's property. Initially I had tried to set and get argument directly but it was awful because SBDebugger::GetInternalVariableValue returns arguments in dumped format, like:

[0]: "--arg1"
[1]: "2nd arg"
[2]: "third_arg"
[4]: "fourth=\"4th arg\""

Therefore I decided to extend public API.

Greg,

I know that it takes a long your time but we didn't decide what need to do with this patch. If you tell me that "process launch" shouldn't work as I have described above then I can remove SBTarget::SetRunArguments, but I think it should.

Sorry that I didn't provide complete information in the description at once.

clayborg requested changes to this revision.Feb 4 2015, 10:18 AM
clayborg edited edge metadata.

So remove everything I listed and add m_lldbLaunchOptions to your CMICmnLLDBDebugSessionInfo object and populate it with all of the -exec calls, then use it to launch

include/lldb/API/SBArgs.h
1–83 ↗(On Diff #18397)

Remove this.

include/lldb/API/SBDefines.h
32 ↗(On Diff #18397)

Remove this.

include/lldb/API/SBTarget.h
1050–1056 ↗(On Diff #18397)

Remove this.

source/API/CMakeLists.txt
8 ↗(On Diff #18397)

Remove this.

source/API/SBArgs.cpp
1–153 ↗(On Diff #18397)

Remove this.

source/API/SBTarget.cpp
16 ↗(On Diff #18397)

Remove this.

2933–2958 ↗(On Diff #18397)

Remove this.

This revision now requires changes to proceed.Feb 4 2015, 10:18 AM
ki.stfu updated this revision to Diff 19642.Feb 9 2015, 10:44 PM
ki.stfu edited edge metadata.

Update patch after r227958; Enable new tests

ki.stfu updated this revision to Diff 19643.Feb 9 2015, 11:20 PM
ki.stfu edited edge metadata.

Enable the related tests in MiExecTestCase

ki.stfu updated this revision to Diff 19644.Feb 9 2015, 11:43 PM

Update patch according to clayborg's remarks

So remove everything I listed and add m_lldbLaunchOptions to your CMICmnLLDBDebugSessionInfo object and populate it with all of the -exec calls, then use it to launch

I have updated the patch according to your remarks. Hope it looks good for you.

But I have a problem: In Diff 4 all tests pass, but now the MiInterpreterExecTestCase.test_lldbmi_settings_set_target_run_args test fails. What we should do with it?

FYI: I was trying to explain this problem in my comments above.

clayborg accepted this revision.Feb 10 2015, 9:35 AM
clayborg edited edge metadata.

Very nice.

This revision is now accepted and ready to land.Feb 10 2015, 9:35 AM

@clayborg, but what about the broken test?

But I have a problem: In Diff 4 all tests pass, but now the MiInterpreterExecTestCase.test_lldbmi_settings_set_target_run_args test fails. What we should do with it?

@clayborg, I meant that I can't make the attached test pass with your solution.

When you launch the SBTarget run args will be set for you from your SBLaunchInfo, so we don't really need to test that the setting gets set explicitly as "settings set target.run-args" is. What were you trying to test with this test? You should be able to get/set the run args in the SBLaunchInfo now before you run. Is this what you should be testing now?

What were you trying to test with this test?

This test checks that we can specify arguments using CLI "settings set target.run-args" command in lldb-mi.

You should be able to get/set the run args in the SBLaunchInfo now before you run. Is this what you should be testing now?

No. I can't get arguments which were set by "settings set target.run-args" command because lldb API doesn't provide this ability.

You could verify that you can set the args with "settings set" and then run with your empty SBLaunchInfo and verify that you got the right args?

It would be nice to have lldb_private::Target have its own ProcessLaunchInfo as a member variable and change all storage of settings (target.run-args, target.arg0 etc) and have the settings just modify the lldb_private::Target's version of this. Then we can add functions to SBTarget:

// Get a _copy_ of the target's launch info
SBLaunchInfo
SBTarget::GetLaunchInfo();

// Set the target's launch info
void
SBTarget::GetLaunchInfo(SBLaunchInfo &launch_info);

// Launch using the target's current launch info
SBProcess
Launch (SBError& error);

This would be fine to add. Then you can make your test work again.

You could verify that you can set the args with "settings set" and then run with your empty SBLaunchInfo and verify that you got the right args?

It doesn't work (test MiInterpreterExecTestCase.test_lldbmi_settings_set_target_run_args by yourself).

When I set arguments using "settings set" it were stored as the Debugger's property. And when I call Target::Launch with empty ProcessLaunchInfo, these arguments are ignored.

It would be nice to have lldb_private::Target have its own ProcessLaunchInfo as a member variable and change all storage of settings (target.run-args, target.arg0 etc) and have the settings just modify the lldb_private::Target's version of this.

I'll try do it but how I can synchronize Target::m_GlobalLaunchInfo and Debugger's property (which can be set by "settings set" command)? I can't update m_GlobalLaunchInfo every time when "settings set target.run-args" is executed. Therefore will be 2 different places where these arguments are stored.

As I said, currently "settings set" stores all values as debugger's properties. And I don't want to do the following:

if (property == "target.run-args") {
    Target::GetGlobalLaunchInfo().SetRunArguments(value);
}
else {
    Debugger.SetProperty(...);
}
ki.stfu updated this revision to Diff 19847.Feb 12 2015, 10:52 AM
ki.stfu edited edge metadata.

Add launch_info to TargetProperties

List of changes:

  • Fix OptionValueArray::SetValueFromCString that notified before the value was changed
  • Add SBLaunchInfo::ref() const
  • Add SBTarget::{GetLaunchInfo,SetLaunchInfo}
  • Add m_launch_info to TargetProperty + add getter and setter. It has RunArgumentsValueChangedCallback callback which called when run-args value was updated.
  • Fix "process launch" command

All tests passed on OS X.

ki.stfu requested a review of this revision.Feb 12 2015, 10:55 AM
ki.stfu edited edge metadata.

@clayborg,

Take a look again please.

clayborg requested changes to this revision.Feb 12 2015, 11:12 AM
clayborg edited edge metadata.

If we are adding a ProcessLaunchInfo to the TargetProperties everything needs to be kept up to date:

{ "arg0"                               , OptionValue::eTypeString    , false, 0                         , NULL, NULL, "The first argument passed to the program in the argument array which can be different from the executable itself." },
{ "run-args"                           , OptionValue::eTypeArgs      , false, 0                         , NULL, NULL, "A list containing all the arguments to be passed to the executable when it is run. Note that this does NOT include the argv[0] which is in target.arg0." },
{ "env-vars"                           , OptionValue::eTypeDictionary, false, OptionValue::eTypeString  , NULL, NULL, "A list of all the environment variables to be passed to the executable's environment, and their values." },
{ "inherit-env"                        , OptionValue::eTypeBoolean   , false, true                      , NULL, NULL, "Inherit the environment from the process that is running LLDB." },
{ "input-path"                         , OptionValue::eTypeFileSpec  , false, 0                         , NULL, NULL, "The file/path to be used by the executable program for reading its standard input." },
{ "output-path"                        , OptionValue::eTypeFileSpec  , false, 0                         , NULL, NULL, "The file/path to be used by the executable program for writing its standard output." },
{ "error-path"                         , OptionValue::eTypeFileSpec  , false, 0                         , NULL, NULL, "The file/path to be used by the executable program for writing its standard error." },
{ "detach-on-error"                    , OptionValue::eTypeBoolean   , false, true                      , NULL, NULL, "debugserver will detach (rather than killing) a process if it loses connection with lldb." },
{ "disable-aslr"                       , OptionValue::eTypeBoolean   , false, true                      , NULL, NULL, "Disable Address Space Layout Randomization (ASLR)" },
{ "disable-stdio"                      , OptionValue::eTypeBoolean   , false, false                     , NULL, NULL, "Disable stdin/stdout for process (e.g. for a GUI application)" },

You will need to install callback functions for each of these and keep your built in ProcessLaunchInfo up to date.

include/lldb/Target/Target.h
200–201 ↗(On Diff #19847)

We might want to make this return a "ProcessLaunchInfo &" so it isn't copied when using it internally.

source/API/SBTarget.cpp
2574 ↗(On Diff #19847)

You must check that m_opaque_sp is valid and also make a copy of it before you use it in case another thread calls SBThread::Clear():

TargetSP target_sp(GetSP());
if (target_sp)
{
    ProcessLaunchInfo launch_info = m_opaque_sp->GetProcessLaunchInfo();
    lldb::SBLaunchInfo sb_launch_info(NULL);
    sb_launch_info.ref() = launch_info;
    return sb_launch_info;   
}
return lldb::SBLaunchInfo();
2584 ↗(On Diff #19847)

Replace with:

TargetSP target_sp(GetSP());
if (target_sp)
{
    m_opaque_sp->SetProcessLaunchInfo(sb_launch_info.ref());
}

You might also want to change this to return a bool in case m_opaque_sp is invalid, you can return false.

This revision now requires changes to proceed.Feb 12 2015, 11:12 AM
ki.stfu added inline comments.Feb 12 2015, 11:17 AM
source/API/SBTarget.cpp
2574 ↗(On Diff #19847)

oops..

ki.stfu updated this revision to Diff 19851.Feb 12 2015, 12:41 PM
ki.stfu edited edge metadata.

Added update other properties in m_launch_info

  • Add TargetProperties::SetEnvironmentFromArgs
  • Add callback for other options

Note, that "inherit-env" doesn't exist in ProcessLaunchInfo. I skipped it.

@clayborg,

Take a look again please.

clayborg accepted this revision.Feb 12 2015, 12:52 PM
clayborg edited edge metadata.

Looks great.

This revision is now accepted and ready to land.Feb 12 2015, 12:52 PM
ki.stfu planned changes to this revision.Feb 12 2015, 1:57 PM
ki.stfu added inline comments.
source/Target/Target.cpp
3061–3069 ↗(On Diff #19851)

I can't set more than 1 callback.

You will need to get the object for each item individual and set the callback on each OptionValue separately. Right now only only the item OptionValue itself will call the callback it won't pass it up to the parent and call the parent's callback. You can change this to happen if you want. then you just need to install one callback and use the "OptionValue *option_value" second param and look at its name using:

ConstString option_name = option_value->GetName();

Then you will need to find out which option it maps to and then set the right value.

Inlined comments

include/lldb/Target/Target.h
213–222 ↗(On Diff #19851)

Either get each option value and set the callback on each indivdual one, or make just one callback and in that callback extract the name from the "OptionValue *" using OptionValue::GetName() and then decoding which value it comes from.

source/Target/Target.cpp
3061–3069 ↗(On Diff #19851)

Either get each option value and set the callback on each indivdual one, or make just one callback and in that callback extract the name from the "OptionValue *" using OptionValue::GetName() and then decoding which value it comes from.

ki.stfu updated this revision to Diff 19863.Feb 12 2015, 4:25 PM
ki.stfu edited edge metadata.

Fix callback; Add test that checks "settings set" before "target create"; Fix "process launch -s"; Fix OptionValueArray::DeepCopy

This revision is now accepted and ready to land.Feb 12 2015, 4:25 PM

@clayborg, Take a look again please.

All tests passed.
BTW, I have disabled initialization of environment variables. See line #3064.

source/Target/Target.cpp
3064 ↗(On Diff #19863)

here

ki.stfu requested a review of this revision.Feb 12 2015, 4:30 PM
ki.stfu edited edge metadata.

As for me it looks bulky and Diff 4 looked better.

clayborg accepted this revision.Feb 12 2015, 4:47 PM
clayborg edited edge metadata.

Looks good.

This revision is now accepted and ready to land.Feb 12 2015, 4:47 PM
ki.stfu closed this revision.Feb 13 2015, 6:32 AM
This revision was automatically updated to reflect the committed changes.