[Lldb-commits] [lldb] r230065 - Start the refactoring of globbing
Zachary Turner
zturner at google.com
Fri Feb 20 14:47:51 PST 2015
If this doesn't fix it I'll take a look. My repo is in a funny state right
now so it's a little difficult.
On Fri Feb 20 2015 at 2:46:26 PM Enrico Granata <egranata at apple.com> wrote:
> My best guess is a missing include, which I added in 230080. If that
> doesn’t fix it, I am going to need somebody who knows their way around
> Windows to help out
>
> On Feb 20, 2015, at 2:41 PM, Zachary Turner <zturner at google.com> wrote:
>
> You probably already saw the bot failure email, but you can take a look at
> this:
>
>
> http://lab.llvm.org:8011/builders/lldb-x86-windows-msvc/builds/2222/steps/build/logs/stdio
>
> It looks like probably a missing #include, let me know if it's more
> difficult though.
>
> On Fri Feb 20 2015 at 2:26:38 PM Zachary Turner <zturner at google.com>
> wrote:
>
>> Might it ever be possible to expand a string for purposes other than
>> forwarding those arguments on to another executable? For example, maybe we
>> want shell expansion to specify the name of the executable in the first
>> place. Like imagine you're trying to debug "foo", and the path of foo is
>> $FOODIR/foo. In this case the expansion doesn't happen on the argument to
>> the command but the command itself.
>>
>> And... I just saw your other email come through. ShellExpandArguments()
>> sounds fine.
>>
>> On Fri Feb 20 2015 at 2:00:36 PM Enrico Granata <egranata at apple.com>
>> wrote:
>>
>>> Fair enough - ShellExpand is not bad, but I feel like Arguments should
>>> be in there somewhere
>>>
>>> Collective hivemind, something less verbose than
>>> ShellStyleExpandArguments maybe?
>>>
>>> On Feb 20, 2015, at 1:57 PM, Zachary Turner <zturner at google.com> wrote:
>>>
>>> In a followup patch, would you mind changing the terminology from
>>> GlobArguments to something more descriptive, like ShellExpand? When I
>>> think glob I only think of wildcards, not full shell exnapsion. So I think
>>> it would be better if it were more explicit.
>>>
>>> On Fri Feb 20 2015 at 1:51:26 PM Enrico Granata <egranata at apple.com>
>>> wrote:
>>>
>>>> Author: enrico
>>>> Date: Fri Feb 20 15:48:38 2015
>>>> New Revision: 230065
>>>>
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=230065&view=rev
>>>> Log:
>>>> Start the refactoring of globbing
>>>>
>>>> - Add Host::GlobArguments() to perform local-globbing
>>>> I implemented this on OSX and Windows in terms of argdumper (Windows
>>>> implementation is essentially the same as the OSX version + a change in
>>>> binary name and some string magic)
>>>> Other platforms did not specifically chime in, so I left it
>>>> unimplemented for them for the time being. Please feel free to fill in the
>>>> blanks
>>>>
>>>> - Add Platform::GlobArguments() to support remote-globbing
>>>> For now, no feature change here - but now we have infrastructure to
>>>> help GDBRemote targets to support globbing - and patches to that effect
>>>> will follow
>>>>
>>>> No visible feature change
>>>>
>>>>
>>>> Modified:
>>>> lldb/trunk/include/lldb/Host/Host.h
>>>> lldb/trunk/include/lldb/Target/Platform.h
>>>> lldb/trunk/source/Host/freebsd/Host.cpp
>>>> lldb/trunk/source/Host/linux/Host.cpp
>>>> lldb/trunk/source/Host/macosx/Host.mm
>>>> lldb/trunk/source/Host/windows/Host.cpp
>>>> lldb/trunk/source/Target/Platform.cpp
>>>>
>>>> Modified: lldb/trunk/include/lldb/Host/Host.h
>>>> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/
>>>> Host/Host.h?rev=230065&r1=230064&r2=230065&view=diff
>>>> ============================================================
>>>> ==================
>>>> --- lldb/trunk/include/lldb/Host/Host.h (original)
>>>> +++ lldb/trunk/include/lldb/Host/Host.h Fri Feb 20 15:48:38 2015
>>>> @@ -253,6 +253,16 @@ public:
>>>> static Error
>>>> LaunchProcess (ProcessLaunchInfo &launch_info);
>>>>
>>>> + //----------------------------------------------------------
>>>> --------
>>>> + /// Perform globbing of the command-line for this launch info
>>>> + /// This can potentially involve wildcard expansion
>>>> + // environment variable replacement, and whatever other
>>>> + // argument magic the platform defines as part of its typical
>>>> + // user experience
>>>> + //----------------------------------------------------------
>>>> --------
>>>> + static Error
>>>> + GlobArguments (ProcessLaunchInfo &launch_info);
>>>> +
>>>> static Error
>>>> RunShellCommand (const char *command, // Shouldn't be
>>>> NULL
>>>> const char *working_dir, // Pass NULL to
>>>> use the current working directory
>>>>
>>>> Modified: lldb/trunk/include/lldb/Target/Platform.h
>>>> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/
>>>> Target/Platform.h?rev=230065&r1=230064&r2=230065&view=diff
>>>> ============================================================
>>>> ==================
>>>> --- lldb/trunk/include/lldb/Target/Platform.h (original)
>>>> +++ lldb/trunk/include/lldb/Target/Platform.h Fri Feb 20 15:48:38 2015
>>>> @@ -386,6 +386,16 @@ namespace lldb_private {
>>>> LaunchProcess (ProcessLaunchInfo &launch_info);
>>>>
>>>> //----------------------------------------------------------
>>>> --------
>>>> + /// Perform globbing of the command-line for this launch info
>>>> + /// This can potentially involve wildcard expansion
>>>> + // environment variable replacement, and whatever other
>>>> + // argument magic the platform defines as part of its typical
>>>> + // user experience
>>>> + //----------------------------------------------------------
>>>> --------
>>>> + virtual Error
>>>> + GlobArguments (ProcessLaunchInfo &launch_info);
>>>> +
>>>> + //----------------------------------------------------------
>>>> --------
>>>> /// Kill process on a platform.
>>>> //----------------------------------------------------------
>>>> --------
>>>> virtual Error
>>>>
>>>> Modified: lldb/trunk/source/Host/freebsd/Host.cpp
>>>> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/
>>>> freebsd/Host.cpp?rev=230065&r1=230064&r2=230065&view=diff
>>>> ============================================================
>>>> ==================
>>>> --- lldb/trunk/source/Host/freebsd/Host.cpp (original)
>>>> +++ lldb/trunk/source/Host/freebsd/Host.cpp Fri Feb 20 15:48:38 2015
>>>> @@ -312,3 +312,9 @@ Host::GetUnixSignals ()
>>>> return s_unix_signals_sp;
>>>> }
>>>>
>>>> +Error
>>>> +Host::GlobArguments (ProcessLaunchInfo &launch_info)
>>>> +{
>>>> + return Error("unimplemented");
>>>> +}
>>>> +
>>>>
>>>> Modified: lldb/trunk/source/Host/linux/Host.cpp
>>>> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/
>>>> linux/Host.cpp?rev=230065&r1=230064&r2=230065&view=diff
>>>> ============================================================
>>>> ==================
>>>> --- lldb/trunk/source/Host/linux/Host.cpp (original)
>>>> +++ lldb/trunk/source/Host/linux/Host.cpp Fri Feb 20 15:48:38 2015
>>>> @@ -417,3 +417,8 @@ Host::GetUnixSignals ()
>>>> return s_unix_signals_sp;
>>>> }
>>>>
>>>> +Error
>>>> +Host::GlobArguments (ProcessLaunchInfo &launch_info)
>>>> +{
>>>> + return Error("unimplemented");
>>>> +}
>>>>
>>>> Modified: lldb/trunk/source/Host/macosx/Host.mm
>>>> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/
>>>> macosx/Host.mm?rev=230065&r1=230064&r2=230065&view=diff
>>>> ============================================================
>>>> ==================
>>>> --- lldb/trunk/source/Host/macosx/Host.mm (original)
>>>> +++ lldb/trunk/source/Host/macosx/Host.mm Fri Feb 20 15:48:38 2015
>>>> @@ -45,6 +45,7 @@
>>>> #include "lldb/Core/ModuleSpec.h"
>>>> #include "lldb/Core/StreamFile.h"
>>>> #include "lldb/Core/StreamString.h"
>>>> +#include "lldb/Core/StructuredData.h"
>>>> #include "lldb/Host/ConnectionFileDescriptor.h"
>>>> #include "lldb/Host/Endian.h"
>>>> #include "lldb/Host/FileSpec.h"
>>>> @@ -1351,6 +1352,91 @@ Host::LaunchProcess (ProcessLaunchInfo &
>>>> return error;
>>>> }
>>>>
>>>> +Error
>>>> +Host::GlobArguments (ProcessLaunchInfo &launch_info)
>>>> +{
>>>> + Error error;
>>>> + if (launch_info.GetFlags().Test(eLaunchFlagGlobArguments))
>>>> + {
>>>> + FileSpec glob_tool_spec;
>>>> + if (!HostInfo::GetLLDBPath(lldb::ePathTypeSupportExecutableDir,
>>>> glob_tool_spec))
>>>> + {
>>>> + error.SetErrorString("could not find argdumper tool");
>>>> + return error;
>>>> + }
>>>> + glob_tool_spec.AppendPathComponent("argdumper");
>>>> + if (!glob_tool_spec.Exists())
>>>> + {
>>>> + error.SetErrorString("could not find argdumper tool");
>>>> + return error;
>>>> + }
>>>> +
>>>> + std::string quoted_cmd_string;
>>>> + launch_info.GetArguments().GetQuotedCommandString(quoted_cmd
>>>> _string);
>>>> + StreamString glob_command;
>>>> +
>>>> + glob_command.Printf("%s %s",
>>>> + glob_tool_spec.GetPath().c_str(),
>>>> + quoted_cmd_string.c_str());
>>>> +
>>>> + int status;
>>>> + std::string output;
>>>> + RunShellCommand(glob_command.GetData(), launch_info.
>>>> GetWorkingDirectory(), &status, nullptr, &output, 10);
>>>> +
>>>> + if (status != 0)
>>>> + {
>>>> + error.SetErrorStringWithFormat("argdumper exited with
>>>> error %d", status);
>>>> + return error;
>>>> + }
>>>> +
>>>> + auto data_sp = StructuredData::ParseJSON(output);
>>>> + if (!data_sp)
>>>> + {
>>>> + error.SetErrorString("invalid JSON");
>>>> + return error;
>>>> + }
>>>> +
>>>> + auto dict_sp = data_sp->GetAsDictionary();
>>>> + if (!data_sp)
>>>> + {
>>>> + error.SetErrorString("invalid JSON");
>>>> + return error;
>>>> + }
>>>> +
>>>> + auto args_sp = dict_sp->GetObjectForDotSeparatedPath("
>>>> arguments");
>>>> + if (!args_sp)
>>>> + {
>>>> + error.SetErrorString("invalid JSON");
>>>> + return error;
>>>> + }
>>>> +
>>>> + auto args_array_sp = args_sp->GetAsArray();
>>>> + if (!args_array_sp)
>>>> + {
>>>> + error.SetErrorString("invalid JSON");
>>>> + return error;
>>>> + }
>>>> +
>>>> + launch_info.GetArguments().Clear();
>>>> +
>>>> + for (size_t i = 0;
>>>> + i < args_array_sp->GetSize();
>>>> + i++)
>>>> + {
>>>> + auto item_sp = args_array_sp->GetItemAtIndex(i);
>>>> + if (!item_sp)
>>>> + continue;
>>>> + auto str_sp = item_sp->GetAsString();
>>>> + if (!str_sp)
>>>> + continue;
>>>> +
>>>> + launch_info.GetArguments().AppendArgument(str_sp->
>>>> GetValue().c_str());
>>>> + }
>>>> + }
>>>> +
>>>> + return error;
>>>> +}
>>>> +
>>>> HostThread
>>>> Host::StartMonitoringChildProcess(Host::MonitorChildProcessCallback
>>>> callback, void *callback_baton, lldb::pid_t pid, bool monitor_signals)
>>>> {
>>>>
>>>> Modified: lldb/trunk/source/Host/windows/Host.cpp
>>>> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/
>>>> windows/Host.cpp?rev=230065&r1=230064&r2=230065&view=diff
>>>> ============================================================
>>>> ==================
>>>> --- lldb/trunk/source/Host/windows/Host.cpp (original)
>>>> +++ lldb/trunk/source/Host/windows/Host.cpp Fri Feb 20 15:48:38 2015
>>>> @@ -217,4 +217,90 @@ HostThread
>>>> Host::StartMonitoringChildProcess(Host::MonitorChildProcessCallback
>>>> callback, void *callback_baton, lldb::pid_t pid, bool monitor_signals)
>>>> {
>>>> return HostThread();
>>>> -}
>>>> \ No newline at end of file
>>>> +}
>>>> +
>>>> +Error
>>>> +Host::GlobArguments (ProcessLaunchInfo &launch_info)
>>>> +{
>>>> + Error error;
>>>> + if (launch_info.GetFlags().Test(eLaunchFlagGlobArguments))
>>>> + {
>>>> + FileSpec glob_tool_spec;
>>>> + if (!HostInfo::GetLLDBPath(lldb::ePathTypeSupportExecutableDir,
>>>> glob_tool_spec))
>>>> + {
>>>> + error.SetErrorString("could not find argdumper tool");
>>>> + return error;
>>>> + }
>>>> + glob_tool_spec.AppendPathComponent("argdumper.exe");
>>>> + if (!glob_tool_spec.Exists())
>>>> + {
>>>> + error.SetErrorString("could not find argdumper tool");
>>>> + return error;
>>>> + }
>>>> +
>>>> + std::string quoted_cmd_string;
>>>> + launch_info.GetArguments().GetQuotedCommandString(quoted_cmd
>>>> _string);
>>>> + std::replace(quoted_cmd_string.begin(),
>>>> quoted_cmd_string.end(), '\\', '/');
>>>> + StreamString glob_command;
>>>> +
>>>> + glob_command.Printf("%s %s",
>>>> + glob_tool_spec.GetPath().c_str(),
>>>> + quoted_cmd_string.c_str());
>>>> +
>>>> + int status;
>>>> + std::string output;
>>>> + RunShellCommand(glob_command.GetData(), launch_info.
>>>> GetWorkingDirectory(), &status, nullptr, &output, 10);
>>>> +
>>>> + if (status != 0)
>>>> + {
>>>> + error.SetErrorStringWithFormat("argdumper exited with
>>>> error %d", status);
>>>> + return error;
>>>> + }
>>>> +
>>>> + auto data_sp = StructuredData::ParseJSON(output);
>>>> + if (!data_sp)
>>>> + {
>>>> + error.SetErrorString("invalid JSON");
>>>> + return error;
>>>> + }
>>>> +
>>>> + auto dict_sp = data_sp->GetAsDictionary();
>>>> + if (!data_sp)
>>>> + {
>>>> + error.SetErrorString("invalid JSON");
>>>> + return error;
>>>> + }
>>>> +
>>>> + auto args_sp = dict_sp->GetObjectForDotSeparatedPath("
>>>> arguments");
>>>> + if (!args_sp)
>>>> + {
>>>> + error.SetErrorString("invalid JSON");
>>>> + return error;
>>>> + }
>>>> +
>>>> + auto args_array_sp = args_sp->GetAsArray();
>>>> + if (!args_array_sp)
>>>> + {
>>>> + error.SetErrorString("invalid JSON");
>>>> + return error;
>>>> + }
>>>> +
>>>> + launch_info.GetArguments().Clear();
>>>> +
>>>> + for (size_t i = 0;
>>>> + i < args_array_sp->GetSize();
>>>> + i++)
>>>> + {
>>>> + auto item_sp = args_array_sp->GetItemAtIndex(i);
>>>> + if (!item_sp)
>>>> + continue;
>>>> + auto str_sp = item_sp->GetAsString();
>>>> + if (!str_sp)
>>>> + continue;
>>>> +
>>>> + launch_info.GetArguments().AppendArgument(str_sp->
>>>> GetValue().c_str());
>>>> + }
>>>> + }
>>>> +
>>>> + return error;
>>>> +}
>>>>
>>>> Modified: lldb/trunk/source/Target/Platform.cpp
>>>> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target
>>>> /Platform.cpp?rev=230065&r1=230064&r2=230065&view=diff
>>>> ============================================================
>>>> ==================
>>>> --- lldb/trunk/source/Target/Platform.cpp (original)
>>>> +++ lldb/trunk/source/Target/Platform.cpp Fri Feb 20 15:48:38 2015
>>>> @@ -1116,87 +1116,9 @@ Platform::LaunchProcess (ProcessLaunchIn
>>>> }
>>>> else if (launch_info.GetFlags().Test(e
>>>> LaunchFlagGlobArguments))
>>>> {
>>>> - FileSpec glob_tool_spec;
>>>> - if (!HostInfo::GetLLDBPath(lldb::ePathTypeSupportExecutableDir,
>>>> glob_tool_spec))
>>>> - {
>>>> - error.SetErrorString("could not find argdumper tool");
>>>> + error = GlobArguments(launch_info);
>>>> + if (error.Fail())
>>>> return error;
>>>> - }
>>>> -#if defined(_WIN32)
>>>> - glob_tool_spec.AppendPathComponent("argdumper.exe");
>>>> -#else
>>>> - glob_tool_spec.AppendPathComponent("argdumper");
>>>> -#endif
>>>> - if (!glob_tool_spec.Exists())
>>>> - {
>>>> - error.SetErrorString("could not find argdumper tool");
>>>> - return error;
>>>> - }
>>>> -
>>>> - std::string quoted_cmd_string;
>>>> - launch_info.GetArguments().GetQuotedCommandString(quoted_
>>>> cmd_string);
>>>> -#if defined(_WIN32)
>>>> - std::replace(quoted_cmd_string.begin(),
>>>> quoted_cmd_string.end(), '\\', '/');
>>>> -#endif
>>>> - StreamString glob_command;
>>>> -
>>>> - glob_command.Printf("%s %s",
>>>> - glob_tool_spec.GetPath().c_str(),
>>>> - quoted_cmd_string.c_str());
>>>> -
>>>> - int status;
>>>> - std::string output;
>>>> - RunShellCommand(glob_command.GetData(), launch_info.
>>>> GetWorkingDirectory(), &status, nullptr, &output, 10);
>>>> -
>>>> - if (status != 0)
>>>> - {
>>>> - error.SetErrorStringWithFormat("argdumper exited with
>>>> error %d", status);
>>>> - return error;
>>>> - }
>>>> -
>>>> - auto data_sp = StructuredData::ParseJSON(output);
>>>> - if (!data_sp)
>>>> - {
>>>> - error.SetErrorString("invalid JSON");
>>>> - return error;
>>>> - }
>>>> -
>>>> - auto dict_sp = data_sp->GetAsDictionary();
>>>> - if (!data_sp)
>>>> - {
>>>> - error.SetErrorString("invalid JSON");
>>>> - return error;
>>>> - }
>>>> -
>>>> - auto args_sp = dict_sp->GetObjectForDotSeparatedPath("
>>>> arguments");
>>>> - if (!args_sp)
>>>> - {
>>>> - error.SetErrorString("invalid JSON");
>>>> - return error;
>>>> - }
>>>> -
>>>> - auto args_array_sp = args_sp->GetAsArray();
>>>> - if (!args_array_sp)
>>>> - {
>>>> - error.SetErrorString("invalid JSON");
>>>> - return error;
>>>> - }
>>>> -
>>>> - launch_info.GetArguments().Clear();
>>>> -
>>>> - for (size_t i = 0;
>>>> - i < args_array_sp->GetSize();
>>>> - i++)
>>>> - {
>>>> - auto item_sp = args_array_sp->GetItemAtIndex(i);
>>>> - if (!item_sp)
>>>> - continue;
>>>> - auto str_sp = item_sp->GetAsString();
>>>> - if (!str_sp)
>>>> - continue;
>>>> -
>>>> - launch_info.GetArguments().AppendArgument(str_sp->
>>>> GetValue().c_str());
>>>> - }
>>>> }
>>>>
>>>> if (log)
>>>> @@ -1210,6 +1132,14 @@ Platform::LaunchProcess (ProcessLaunchIn
>>>> }
>>>>
>>>> Error
>>>> +Platform::GlobArguments (ProcessLaunchInfo &launch_info)
>>>> +{
>>>> + if (IsHost())
>>>> + return Host::GlobArguments(launch_info);
>>>> + return Error("base lldb_private::Platform class can't glob
>>>> arguments");
>>>> +}
>>>> +
>>>> +Error
>>>> Platform::KillProcess (const lldb::pid_t pid)
>>>> {
>>>> Log *log(lldb_private::GetLogIfAllCategoriesSet
>>>> (LIBLLDB_LOG_PLATFORM));
>>>>
>>>>
>>>> _______________________________________________
>>>> lldb-commits mailing list
>>>> lldb-commits at cs.uiuc.edu
>>>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits
>>>>
>>>
>>> Thanks,
>>> *- Enrico*
>>> 📩 egranata@.com ☎️ 27683
>>>
>>>
>>>
>>>
>>>
> Thanks,
> *- Enrico*
> 📩 egranata@.com ☎️ 27683
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150220/c8e33eb3/attachment.html>
More information about the lldb-commits
mailing list