[Lldb-commits] [PATCH] Add -exec-arguments command

Greg Clayton clayborg at gmail.com
Thu Feb 12 11:12:23 PST 2015


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.


================
Comment at: include/lldb/Target/Target.h:200-201
@@ +199,4 @@
+
+    ProcessLaunchInfo
+    GetProcessLaunchInfo() const;
+
----------------
We might want to make this return a "ProcessLaunchInfo &" so it isn't copied when using it internally.

================
Comment at: source/API/SBTarget.cpp:2574
@@ +2573,3 @@
+SBTarget::GetLaunchInfo () const
+{
+    ProcessLaunchInfo launch_info = m_opaque_sp->GetProcessLaunchInfo();
----------------
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();

================
Comment at: source/API/SBTarget.cpp:2584
@@ +2583,3 @@
+{
+    m_opaque_sp->SetProcessLaunchInfo(sb_launch_info.ref());
+}
----------------
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.

http://reviews.llvm.org/D6965

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the lldb-commits mailing list