I take back my first sentence.  It would be two different syntaxes if one argument is a file path and one argument is a non file-path string.  Like for example:<div><br></div><div>(lldb) somecommand testarg c:\foobar<br><br></div><div>In this case yes, the two arguments would have different rules.  But a) they would only have different rules on Windows, and b) I think that's ok, people whose primary operating system is Windows have the \ so engrained in their heads that this will be the most natural behavior.</div><br><div class="gmail_quote">On Wed Jan 14 2015 at 10:47:41 AM Zachary Turner <<a href="mailto:zturner@google.com">zturner@google.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">It wouldn't be two arguments to the same command having a different syntax, it would be one argument to a command having a different syntax depending on how you were using the command.<br><div><br></div><div>If I'm debugging Windows remotely from a Linux machine, and I need to specify a remote executable, it's more natural to use a Windows syntax to specify it.  Of course the default would be the host's default.</div><div><br></div><div>The reason I'm not crazy about the protection character is because any character you use is going to be awkward.  Escaping characters with # signs just isn't very intuitive to anyone on any platform.  On the other hand, escaping characters in filenames just isn't a thing that anyone needs to do on Windows, because characters that require escaping are not valid filename characters.  I guess ultimately I'm looking for a way so that each platform can have the most natural way of doing things on that platform, so nobody feels like a second class citizen.  Using # characters (or really any character other than \) for escaping is going to be unnatural, but even more importantly unnecessary since we only need this for file paths.</div><div><br></div><div>That's what led me to the aforementioned idea.  We already have the ability to mark option values as file paths by using eOptionTypeFileSpec.  So why not just put the logic there, and then there's no setting anywhere, and everyone can use the native path syntax for the platform they're working with.</div><br><div class="gmail_quote">On Wed Jan 14 2015 at 10:28:26 AM <<a href="mailto:jingham@apple.com" target="_blank">jingham@apple.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I don't like this.  Having two arguments to the same command with different syntaxes seems pretty ugly to me.<br>
<br>
I didn't completely follow why having the protection character be settable ended up being annoying to do, but short of that, I think the best option is to have the protection character be a host setting, leave it at "\" for everything but Windows, and pick some likely character for Windows.  Then we'll have to document this somewhere that the average debugger user is likely to find it.<br>
<br>
Jim<br>
<br>
<br>
> On Jan 13, 2015, at 6:38 PM, Zachary Turner <<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>> wrote:<br>
><br>
> For example, one idea i had to fix this in a deeper way was to audit all settings and options. For each one that's a path, make sure the option type is eOptionTypeFileSpec. Then sink the escaping logic into FileSpec. The added benefit of this is that it easily gives you access to the native syntax of a remote platform's file system by way of the PathSyntax enum i added to FileSpec some time ago. So if you're running some command that takes a path in the context of a remote host, you can use that hosts escaping rules. Plus this only changes the behavior for paths, which is the only place we need it, so doesn't break anything else.<br>
><br>
> This is a bigger change though, and not needed immediately, which is why I would prefer postponing.<br>
><br>
> Thoughts about this approach?<br>
> On Tue, Jan 13, 2015 at 6:13 PM Zachary Turner <<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>> wrote:<br>
> I definitely need to be able to specify paths with backslashes unquoted, but whether this is the best approach I'm still undecided.<br>
><br>
> To be honest, I'm ok for now just disabling backslash processing with an #ifndef _WIN32. This might cause other issues down the line for us, but they will be fairly uncommon, and it will fix the common case now. And we can do a more proper fix if/when the problem resurfaces.<br>
> On Tue, Jan 13, 2015 at 5:06 PM Greg Clayton <<a href="mailto:gclayton@apple.com" target="_blank">gclayton@apple.com</a>> wrote:<br>
><br>
> > On Jan 12, 2015, at 5:03 PM, Zachary Turner <<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>> wrote:<br>
> ><br>
> > The way Process does it is a little confusing to me.  It has this ProcessProperties() class which takes a boolean, is_global.  If this value is true, it appends some sub-properties to it, and if it's false, it just initializes itself by calling itself again with true.  So false and true make no difference, it's always the same instance (?)<br>
><br>
> No. is_global is set to true if this is the initial "seed" options for "process" under "target". This is why when "is_global" is set to true that it appends the settings to the "target" global settings, and it doesn't when not.<br>
><br>
> If you think about it you need a set of options that can be editable before any processes exist. So the "is_global" means we are creating this one set of settings, it has nothing to do with the fact that individual settings can be global or instance based. When a lldb_private::Process is made, it inherits from ProcessProperties, and these are the settings that get modified and any global properties are shared with the global versions, and any instance variables copy the current global settings to be the basis for the initial settings in Process.<br>
><br>
> So lets say ProcessProperties has two settings "a" which is global and "b" which is not (set by the bool in each property definition). When we first start out we create the global properties which contain default values for "a" and "b":<br>
><br>
> Global ProcessProperties:<br>
> a = true<br>
> b = false<br>
><br>
> Now we run some commands:<br>
><br>
> (lldb) settings set process.a false<br>
><br>
> So now we have:<br>
><br>
> Global ProcessProperties:<br>
> a = false<br>
> b = false<br>
><br>
> Now we create a process whose pid is 123:<br>
><br>
> (lldb) file /bin/ls<br>
> (lldb) b malloc<br>
> (lldB) r<br>
><br>
> Now a new process gets created and it makes a copy of "Global ProcessProperties":<br>
><br>
> Process 123 ProcessProperties:<br>
> a = false<br>
> b = false<br>
><br>
> Now someone says:<br>
><br>
> (lldb) settings set process.a true<br>
><br>
> Since "a" is global we get:<br>
><br>
> Global ProcessProperties:<br>
> a = true<br>
> b = false<br>
><br>
> Process 123 ProcessProperties:<br>
> a = true<br>
> b = false<br>
><br>
> But if we do:<br>
><br>
> (lldb) settings set process.b true<br>
><br>
> The Global properties remain unchanged, and only Process 123's settings get changed:<br>
><br>
> Global ProcessProperties:<br>
> a = true<br>
> b = false<br>
><br>
> Process 123 ProcessProperties:<br>
> a = true<br>
> b = true<br>
><br>
><br>
> ><br>
> > Then, to further confuse matters, there's a single PropertyDefinition array, where some of them are specified as global and some not via the third argument.  When you call GetGlobalProperties(), it then just returns the whole array.  There's not much choice it has, because it's all just one array, so it can't really return a filtered array with only the items where global==true.<br>
> ><br>
> > I feel like the correct way to do this is to have two separate arrays.  One for global properties and one for instance properties.  Then, instead of inheriting from Properties, just have two instances of it in the class.  An instance instance and a static instance.  This way you don't even need the third argument to PropertyDefinition at all.  And the global properties are added as a subcategory, such as interpreter.global.  This also makes it clear to the user when they run "settings list" which settings are global and which are not.  It might be clearer with an example, so I'll upload this patch so you can see what I'm talking about.  If you don't like the way I've done it let me know.<br>
><br>
> Read what I typed above carefully and make sure that:<br>
> 1 - we need to be able to set non-global properties without any instances so there needs to be global settings that contain all global and all instance based properties so we can set these values before we have any instances around<br>
> 2 - when a new instance is made, it needs to get a copy of the global pref's global and non-global option values<br>
> 3 - if you modify a value that is non-global, there needs to be a way to find the right instance so you can set the settings as the code currently does<br>
><br>
> I would rather you not change this code as it currently works and is relatively bug free. If you do still feel you need to change the code do NOT break anything. This means a lot of testing to make sure it behaves the exact way it used to. Messing with this can really hose things up, so again, don't break anything if you still feel you need to change the code.<br>
><br>
> Greg<br>
><br>
><br>
> ><br>
> > On Mon Jan 12 2015 at 3:01:21 PM Greg Clayton <<a href="mailto:gclayton@apple.com" target="_blank">gclayton@apple.com</a>> wrote:<br>
> > Actually we do have command interpreter settings as Jim just pointed out to me, so feel free to add it there and hook the global settings up correctly for that with a static function on CommandInterpreter to get the escape character.<br>
> ><br>
> > Greg<br>
> ><br>
> > > On Jan 12, 2015, at 2:59 PM, Greg Clayton <<a href="mailto:gclayton@apple.com" target="_blank">gclayton@apple.com</a>> wrote:<br>
> > ><br>
> > > Probably the command interpreter, but we have all the command interpreter settings on the debugger right now anyway, so don't change anything on that end..<br>
> > ><br>
> > >> On Jan 12, 2015, at 2:35 PM, Zachary Turner <<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>> wrote:<br>
> > >><br>
> > >> Thanks for the response.  By the way, is this setting more appropriate on the CommandInterpreter instead of the debugger?<br>
> > >><br>
> > >> On Mon Jan 12 2015 at 2:34:06 PM Greg Clayton <<a href="mailto:gclayton@apple.com" target="_blank">gclayton@apple.com</a>> wrote:<br>
> > >><br>
> > >>> On Jan 12, 2015, at 2:05 PM, Zachary Turner <<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>> wrote:<br>
> > >>><br>
> > >>> There doesn't seem to be a good way to get access to the Debugger object from the Args class.  I tried changing Args to take a Debugger to its constructor, but it seems this isn't always possible, for example with anything having to do with OptionValue.<br>
> > >>> I could provide a default value of NULL for the Debugger, and if NULL it would fall back to the default escape character, but this seems awkward.<br>
> > >>><br>
> > >>> Since I've declared this as a global property, why should I even need a Debugger instance?  Shouldn't the global settings be static on the Debugger so that they can be accessed without an instance?<br>
> > >><br>
> > >><br>
> > >> This is the problem. See how process does it:<br>
> > >><br>
> > >> class Process {<br>
> > >>    static const ProcessPropertiesSP &<br>
> > >>    GetGlobalProperties();<br>
> > >> }<br>
> > >><br>
> > >> The debugger should do the same thing. It should also add static accessors for all of the settings that are truly global settings. Looking at the global settings, they all seem to be set to be global values which probably isn't what we want. Why? Xcode creates a new Debugger for each debugging window that it creates and if someone types "setting set auto-confirm false" in one command interpreter, it shouldn't affect the other.<br>
> > >><br>
> > >> So I would say we need to switch all debugger settings to be non-global (third initialized in each of the PropertyDefinition values should be set to "false" in g_properties in Debugger.cpp) and the only one that should remain global is your new escape character. Then Debugger should get a new static accessor:<br>
> > >><br>
> > >> class Debugger<br>
> > >> {<br>
> > >>    static char<br>
> > >>    GetEscapeCharacter();<br>
> > >> };<br>
> > >><br>
> > >> This in turn will access the global properties and return it to outside folks.<br>
> > >><br>
> > >> Check out the ProcessProperties class in Process.h and check out its constructor. We will need to do something similar for the debugger's settings. Right now Debugger inherits directly from Properties, but we will need to change it to be like the process where there is a DebuggerProperties class. The global version gets constructed with a "bool is_global" set to false, and the instance ones get constructed with that set to true.<br>
> > >><br>
> > >> The Process class is the model we will need to follow if you want to make this change and have a true global property that can be accessed without a Debugger instance.<br>
> > >><br>
> > >><br>
> > >>><br>
> > >>> On Thu Jan 08 2015 at 3:00:30 PM <<a href="mailto:jingham@apple.com" target="_blank">jingham@apple.com</a>> wrote:<br>
> > >>> It's not just file names, you would also have to make sure there's nothing else that might be in command argument or option value that has a single & a double quote, since without the backslashes this would be impossible.<br>
> > >>><br>
> > >>> If you really want to do this, I think it would be better to add a debugger setting for the "protection character".  Then this would be set to something else (maybe "#") on Windows, and backslash on all other systems.  That way you could probably always find a protection character that you could use for whatever gnarly string you ended up having to pass through the command interpreter.<br>
> > >>><br>
> > >>> Jim<br>
> > >>><br>
> > >>><br>
> > >>>> On Jan 8, 2015, at 2:55 PM, Zachary Turner <<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>> wrote:<br>
> > >>>><br>
> > >>>> Actually ' is a valid filename character in Windows, but not ".  That being said, it's so rare, and having a backslash is so common that I would prefer the common case to be easy, and the rare case being either unsupported or difficult is ok with me.  So I'd still prefer to disable this backslash handling on Windows for now, and then fix ' on Windows separately in the future.<br>
> > >>>><br>
> > >>>> On Thu Jan 08 2015 at 2:51:51 PM Zachary Turner <<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>> wrote:<br>
> > >>>> On Windows, that's not a valid file name, and in fact any file name that has an escaped character is not a valid filename.  I see what you're getting at though, that for non-Windows it's necessary.  Can I wrap the backslash handling in #ifndef _WIN32 then?<br>
> > >>>><br>
> > >>>> On Thu Jan 08 2015 at 2:49:49 PM <<a href="mailto:jingham@apple.com" target="_blank">jingham@apple.com</a>> wrote:<br>
> > >>>> If I have a file called foo"bar'baz, how what would I put in the place of <AWKWARD NAME> for<br>
> > >>>><br>
> > >>>> (lldb) file <AWKWARD NAME><br>
> > >>>><br>
> > >>>> Right now, I can do:<br>
> > >>>><br>
> > >>>> (lldb) file foo\"bar\'baz<br>
> > >>>> Current executable set to 'foo"bar'baz' (x86_64).<br>
> > >>>><br>
> > >>>> Jim<br>
> > >>>><br>
> > >>>><br>
> > >>>>> On Jan 8, 2015, at 2:31 PM, Zachary Turner <<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>> wrote:<br>
> > >>>>><br>
> > >>>>> FWIW, Removing backslash handling from this function (essentially ignoring backslashes in command arguments) fixes about 12-15 tests on Windows with no other changes.  I see there's some logic in Args for encoding and decoding escape sequences, but this only happens if a particular command option is set, and that command only only appears to be set for the "prompt" command.  I'm not sure if removing the backslash logic from SetCommandString would interfere with this command in any way, but it doesn't seem like it would interfere with any other commands, unless I'm missing something.<br>
> > >>>>><br>
> > >>>>> On Thu Jan 08 2015 at 1:43:16 PM Zachary Turner <<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>> wrote:<br>
> > >>>>> One thing causing many tests to fail on Windows is the presence of backslashes in argument.  Until now, I've worked around this in many cases by making sure that arguments with backslashes are always quoted.<br>
> > >>>>><br>
> > >>>>> But there are some cases where this is not easy to guarantee and now I'm leaning towards (at least on Windows) allowing backslashes in argument strings.  The code in question comes from the function void SetCommandString (const char *command) in the file Args.cpp<br>
> > >>>>><br>
> > >>>>> In particular, it implements special handling of whitespace, single quotes, double quotes, and backslashes.  For the case of backslashes it removes them from the string.<br>
> > >>>>><br>
> > >>>>> What would be the implications of removing backslash handling from this function for all platforms?  I would prefer to keep platform specific code out of generic code, but I think this needs to be changed on Windows.<br>
> > >>>>> ______________________________<u></u><u></u>_________________<br>
> > >>>>> lldb-dev mailing list<br>
> > >>>>> <a href="mailto:lldb-dev@cs.uiuc.edu" target="_blank">lldb-dev@cs.uiuc.edu</a><br>
> > >>>>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailm<u></u>an/listinfo/lldb-dev</a><br>
> > >>>><br>
> > >>><br>
> > >>> ______________________________<u></u><u></u>_________________<br>
> > >>> lldb-dev mailing list<br>
> > >>> <a href="mailto:lldb-dev@cs.uiuc.edu" target="_blank">lldb-dev@cs.uiuc.edu</a><br>
> > >>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailm<u></u>an/listinfo/lldb-dev</a><br>
> > >><br>
> > ><br>
> ><br>
><br>
<br>
</blockquote></div></blockquote></div>