<div dir="ltr"><div>Just to expand a little more since my last post, the PathSyntax to the constructor and to SetFile() has a default value, which will do the right thing 99% of the time by selecting Host syntax. You only need to specify it if you know what you're doing, so to speak. But without being able to set it, there would be no way to have FileSpec represent a path on a remote machine.</div>
<div><br></div>As for the performance cost of normalization, SmallString<64> only does a malloc if the string is longer than 64 characters. I could try increasing the number, I think 128 would cover probably 95% of all file paths. I agree in principle that it would be nice to not normalize the string on every file set, one idea would be to never normalize it if PathSyntax = Posix (since Normalized form is by definition Posix form) and always normalize it otherwise. But then to avoid the copy I would need to change the SetFile()'s signature to accept a SmallString instead of a const char*. I actually thinking changing raw strings to LLVM strings is a good change, but it's probably going to result in some unrelated churn fixing up function signatures elsewhere, so doing that iteratively as a separate change might make more sense.<div>
<br></div><div>Thoughts?</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jul 30, 2014 at 6:50 PM, Greg Clayton <span dir="ltr"><<a href="mailto:gclayton@apple.com" target="_blank">gclayton@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Looks ok, a few questions:<br>
<br>
Why does the user ever want to specify the PathSyntax? Shouldn't it just be something that can be queried and be set automagically?<br>
<br>
What if I did:<br>
<br>
FileSpec f("C:\Users\me\foo.txt", false, ePathSyntaxPosix);<br>
<br>
If I set it incorrectly, seems like it might "do the wrong thing" in some calls. It might be nice to use a C++11 typed bitfield to store the PathSyntax to keep the size of the FileSpec class down to as small as possible (uint8_t).<br>
<br>
All the other functionality seems fine.<br>
<br>
A few things to keep in mind:<br>
<br>
All debug info is parsed and stored into FileSpec objects. They must match exactly what the user types. What if the user types in:<br>
<br>
(lldb) breakpoint set --file C:/Users/me/foo.txt<br>
<br>
Note the wrong slashes. Are we alway normalizing a path to be native so that this kind of compare will always work even if the user types it in wrong?<br>
<br>
Seems like we shouldn't allow the user to specify the PathSyntax or we can run into problems.<br>
<br>
Also seems like we should check if a string needs to be normalized before calling Normalize and allocating memory and copying and replacing things which can be expensive (think parsing thousands of line table files).<br>
<br>
So I would vote to:<br>
1 - fix it so the user never specifies PathSyntax, but can query it if desired<br>
2 - I would rather not normalize the path on every FileSpec::SetFile(...) if we can avoid it as it will be expensive<br>
3 - If we do need to normalize it every time, either have Normalize return false and not touch the llvm::SmallString<64> argument (no mallocs) if it doesn't need to be normalized to avoid expensive allocations if not required.<br>
<div><div class="h5"><br>
> On Jul 30, 2014, at 4:49 PM, Zachary Turner <<a href="mailto:zturner@google.com">zturner@google.com</a>> wrote:<br>
><br>
>>> ! In D4675#11, @deepak2427 wrote:<br>
>> Thanks for fixing this. I haven't had a chance to test this patch with our cross-platform issues yet, have to look at some other issues first.<br>
>> Just a couple of doubts I had.<br>
>><br>
>> - Are the paths always going to default as ePathSyntaxHostNative and then converted based on the Host?<br>
>> - In 733 llvm::SmallString<64> denormalized; , is the length of 64 enough?<br>
>> - I'm not that familiar with LLVM data structures, however would it be better to keep llvm::SmallString itself for the Normalize/Denormalize functions to keep it consistent?<br>
><br>
> Paths default to SyntaxHostNative because that makes the semantics post-patch equivalent to pre-patch. Normalized form is basically unix form, so if the syntax ends up as ePathSyntaxPosix (either because it was explicitly specified or because host was specified and your host is posix), then normalization and de-normalization are both no-ops.<br>
><br>
> SmallString<64> just means that it keeps 64 bytes on the stack, and if it grows longer than that, it will fallback to help allocation. It still supports arbitrarily long strings, but paths tend to be small, so that's why a small number was chosen.<br>
><br>
> <a href="http://reviews.llvm.org/D4675" target="_blank">http://reviews.llvm.org/D4675</a><br>
><br>
><br>
><br>
</div></div>> _______________________________________________<br>
> lldb-commits mailing list<br>
> <a href="mailto:lldb-commits@cs.uiuc.edu">lldb-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits</a><br>
<br>
</blockquote></div><br></div>