Re: [Lldb-commits] [lldb] r222075 - For some reason, sometimes the directory paths that clang emits have internal

2014-11-17 Thread jingham
Thanks for the reminder.  I did check llvm::sys::path before I headed into 
this.  It doesn't have a routine that did exactly that I wanted, though it did 
have a little tokenizer/iterator that I could have used.  But the path utility 
in llvm currently hard-codes the assumption that the paths you are manipulating 
are all Host paths - it's pretty free with the assumption that they exist.  You 
can't make either of those assumptions about include paths in DWARF.  Of 
course, the llvm::sys::path code could be reworked to remove these assumptions, 
etc.  But that would have turned a fairly simple patch into a much bigger deal, 
and I've spend all the time I can afford on this bug for now.

Jim


> On Nov 14, 2014, at 6:55 PM, Zachary Turner  wrote:
> 
> You might check if llvm has a method to remove all the dots and stuff 
> already.  I think it does, but I could be wrong.  
> 
> On Fri Nov 14 2014 at 5:58:15 PM Jim Ingham  wrote:
> Author: jingham
> Date: Fri Nov 14 19:54:26 2014
> New Revision: 222075
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=222075&view=rev
> Log:
> For some reason, sometimes the directory paths that clang emits have internal
> relative paths, like:
> 
> /whatever/llvm/lib/Sema/../../include/llvm/Sema/
> 
> That causes problems with our type uniquing, since we use the declaration file
> and line as one component of the uniquing, and different ways of getting to 
> the
> same file will have different directory spellings, though they are 
> functionally
> equivalent.  We end up with two copies of the exact same type because of this,
> and that makes the expression parser give "duplicate type" errors.
> 
> I added a method to resolve paths with ../ in them and used that in the 
> FileSpec::Equals,
> for comparing Declarations and for doing Breakpoint compares as well, since 
> they also
> suffer from this if you specify breakpoints by full path (since nobody knows 
> what
> ../'s to insert...)
> 
> 
> 
> Modified:
> lldb/trunk/include/lldb/Core/FileSpecList.h
> lldb/trunk/include/lldb/Host/FileSpec.h
> lldb/trunk/source/Core/FileSpecList.cpp
> lldb/trunk/source/Host/common/FileSpec.cpp
> lldb/trunk/source/Symbol/CompileUnit.cpp
> lldb/trunk/source/Symbol/Declaration.cpp
> 
> Modified: lldb/trunk/include/lldb/Core/FileSpecList.h
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FileSpecList.h?rev=222075&r1=222074&r2=222075&view=diff
> ==
> --- lldb/trunk/include/lldb/Core/FileSpecList.h (original)
> +++ lldb/trunk/include/lldb/Core/FileSpecList.h Fri Nov 14 19:54:26 2014
> @@ -119,12 +119,15 @@ public:
>  /// @param[in] full
>  /// Should FileSpec::Equal be called with "full" true or false.
>  ///
> +/// @param[in] remove_backup_dots
> +/// Should FileSpec::Equal be called with "remove_backup_dots" true 
> or false.
> +///
>  /// @return
>  /// The index of the file that matches \a file if it is found,
>  /// else UINT32_MAX is returned.
>  //--
>  size_t
> -FindFileIndex (size_t idx, const FileSpec &file, bool full) const;
> +FindFileIndex (size_t idx, const FileSpec &file, bool full, bool 
> remove_backup_dots = false) const;
> 
>  //--
>  /// Get file at index.
> 
> Modified: lldb/trunk/include/lldb/Host/FileSpec.h
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/FileSpec.h?rev=222075&r1=222074&r2=222075&view=diff
> ==
> --- lldb/trunk/include/lldb/Host/FileSpec.h (original)
> +++ lldb/trunk/include/lldb/Host/FileSpec.h Fri Nov 14 19:54:26 2014
> @@ -246,7 +246,7 @@ public:
>  Compare (const FileSpec& lhs, const FileSpec& rhs, bool full);
> 
>  static bool
> -Equal (const FileSpec& a, const FileSpec& b, bool full);
> +Equal (const FileSpec& a, const FileSpec& b, bool full, bool 
> remove_backups = false);
> 
>  //--
>  /// Dump this object to a Stream.
> @@ -582,6 +582,20 @@ public:
>  static void Normalize(llvm::SmallVectorImpl &path, PathSyntax 
> syntax = ePathSyntaxHostNative);
>  static void DeNormalize(llvm::SmallVectorImpl &path, PathSyntax 
> syntax = ePathSyntaxHostNative);
> 
> +
> +//--
> +/// Run through the input string, replaying the effect of any ".." and 
> produce
> +/// the resultant path.  The input path is not required to be in the 
> host file system
> +/// format, but it is required to be normalized to that system.
> +///
> +/// @param[in] input
> +/// The input path to analyze.
> +///
> +/// @param[out] result
> +/// The backup-reso

Re: [Lldb-commits] [lldb] r222075 - For some reason, sometimes the directory paths that clang emits have internal

2014-11-14 Thread Zachary Turner
You might check if llvm has a method to remove all the dots and stuff
already.  I think it does, but I could be wrong.

On Fri Nov 14 2014 at 5:58:15 PM Jim Ingham  wrote:

> Author: jingham
> Date: Fri Nov 14 19:54:26 2014
> New Revision: 222075
>
> URL: http://llvm.org/viewvc/llvm-project?rev=222075&view=rev
> Log:
> For some reason, sometimes the directory paths that clang emits have
> internal
> relative paths, like:
>
> /whatever/llvm/lib/Sema/../../include/llvm/Sema/
>
> That causes problems with our type uniquing, since we use the declaration
> file
> and line as one component of the uniquing, and different ways of getting
> to the
> same file will have different directory spellings, though they are
> functionally
> equivalent.  We end up with two copies of the exact same type because of
> this,
> and that makes the expression parser give "duplicate type" errors.
>
> I added a method to resolve paths with ../ in them and used that in the
> FileSpec::Equals,
> for comparing Declarations and for doing Breakpoint compares as well,
> since they also
> suffer from this if you specify breakpoints by full path (since nobody
> knows what
> ../'s to insert...)
>
> 
>
> Modified:
> lldb/trunk/include/lldb/Core/FileSpecList.h
> lldb/trunk/include/lldb/Host/FileSpec.h
> lldb/trunk/source/Core/FileSpecList.cpp
> lldb/trunk/source/Host/common/FileSpec.cpp
> lldb/trunk/source/Symbol/CompileUnit.cpp
> lldb/trunk/source/Symbol/Declaration.cpp
>
> Modified: lldb/trunk/include/lldb/Core/FileSpecList.h
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/
> lldb/Core/FileSpecList.h?rev=222075&r1=222074&r2=222075&view=diff
> 
> ==
> --- lldb/trunk/include/lldb/Core/FileSpecList.h (original)
> +++ lldb/trunk/include/lldb/Core/FileSpecList.h Fri Nov 14 19:54:26 2014
> @@ -119,12 +119,15 @@ public:
>  /// @param[in] full
>  /// Should FileSpec::Equal be called with "full" true or false.
>  ///
> +/// @param[in] remove_backup_dots
> +/// Should FileSpec::Equal be called with "remove_backup_dots"
> true or false.
> +///
>  /// @return
>  /// The index of the file that matches \a file if it is found,
>  /// else UINT32_MAX is returned.
>  //--
>  size_t
> -FindFileIndex (size_t idx, const FileSpec &file, bool full) const;
> +FindFileIndex (size_t idx, const FileSpec &file, bool full, bool
> remove_backup_dots = false) const;
>
>  //--
>  /// Get file at index.
>
> Modified: lldb/trunk/include/lldb/Host/FileSpec.h
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/
> lldb/Host/FileSpec.h?rev=222075&r1=222074&r2=222075&view=diff
> 
> ==
> --- lldb/trunk/include/lldb/Host/FileSpec.h (original)
> +++ lldb/trunk/include/lldb/Host/FileSpec.h Fri Nov 14 19:54:26 2014
> @@ -246,7 +246,7 @@ public:
>  Compare (const FileSpec& lhs, const FileSpec& rhs, bool full);
>
>  static bool
> -Equal (const FileSpec& a, const FileSpec& b, bool full);
> +Equal (const FileSpec& a, const FileSpec& b, bool full, bool
> remove_backups = false);
>
>  //--
>  /// Dump this object to a Stream.
> @@ -582,6 +582,20 @@ public:
>  static void Normalize(llvm::SmallVectorImpl &path, PathSyntax
> syntax = ePathSyntaxHostNative);
>  static void DeNormalize(llvm::SmallVectorImpl &path,
> PathSyntax syntax = ePathSyntaxHostNative);
>
> +
> +//--
> +/// Run through the input string, replaying the effect of any ".."
> and produce
> +/// the resultant path.  The input path is not required to be in the
> host file system
> +/// format, but it is required to be normalized to that system.
> +///
> +/// @param[in] input
> +/// The input path to analyze.
> +///
> +/// @param[out] result
> +/// The backup-resolved path will be written here.
> +//--
> +static void RemoveBackupDots (const ConstString &input_const_str,
> ConstString &result_const_str);
> +
>  //--
>  /// Change the file specified with a new path.
>  ///
>
> Modified: lldb/trunk/source/Core/FileSpecList.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/
> Core/FileSpecList.cpp?rev=222075&r1=222074&r2=222075&view=diff
> 
> ==
> --- lldb/trunk/source/Core/FileSpecList.cpp (original)
> +++ lldb/trunk/source/Core/FileSpecList.cpp Fri Nov 14 19:54:26 2014
> @@ -107,7 +107,7 @@ FileSpe

[Lldb-commits] [lldb] r222075 - For some reason, sometimes the directory paths that clang emits have internal

2014-11-14 Thread Jim Ingham
Author: jingham
Date: Fri Nov 14 19:54:26 2014
New Revision: 222075

URL: http://llvm.org/viewvc/llvm-project?rev=222075&view=rev
Log:
For some reason, sometimes the directory paths that clang emits have internal
relative paths, like:

/whatever/llvm/lib/Sema/../../include/llvm/Sema/

That causes problems with our type uniquing, since we use the declaration file
and line as one component of the uniquing, and different ways of getting to the
same file will have different directory spellings, though they are functionally
equivalent.  We end up with two copies of the exact same type because of this, 
and that makes the expression parser give "duplicate type" errors.

I added a method to resolve paths with ../ in them and used that in the 
FileSpec::Equals,
for comparing Declarations and for doing Breakpoint compares as well, since 
they also
suffer from this if you specify breakpoints by full path (since nobody knows 
what
../'s to insert...)



Modified:
lldb/trunk/include/lldb/Core/FileSpecList.h
lldb/trunk/include/lldb/Host/FileSpec.h
lldb/trunk/source/Core/FileSpecList.cpp
lldb/trunk/source/Host/common/FileSpec.cpp
lldb/trunk/source/Symbol/CompileUnit.cpp
lldb/trunk/source/Symbol/Declaration.cpp

Modified: lldb/trunk/include/lldb/Core/FileSpecList.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FileSpecList.h?rev=222075&r1=222074&r2=222075&view=diff
==
--- lldb/trunk/include/lldb/Core/FileSpecList.h (original)
+++ lldb/trunk/include/lldb/Core/FileSpecList.h Fri Nov 14 19:54:26 2014
@@ -119,12 +119,15 @@ public:
 /// @param[in] full
 /// Should FileSpec::Equal be called with "full" true or false.
 ///
+/// @param[in] remove_backup_dots
+/// Should FileSpec::Equal be called with "remove_backup_dots" true or 
false.
+///
 /// @return
 /// The index of the file that matches \a file if it is found,
 /// else UINT32_MAX is returned.
 //--
 size_t
-FindFileIndex (size_t idx, const FileSpec &file, bool full) const;
+FindFileIndex (size_t idx, const FileSpec &file, bool full, bool 
remove_backup_dots = false) const;
 
 //--
 /// Get file at index.

Modified: lldb/trunk/include/lldb/Host/FileSpec.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/FileSpec.h?rev=222075&r1=222074&r2=222075&view=diff
==
--- lldb/trunk/include/lldb/Host/FileSpec.h (original)
+++ lldb/trunk/include/lldb/Host/FileSpec.h Fri Nov 14 19:54:26 2014
@@ -246,7 +246,7 @@ public:
 Compare (const FileSpec& lhs, const FileSpec& rhs, bool full);
 
 static bool
-Equal (const FileSpec& a, const FileSpec& b, bool full);
+Equal (const FileSpec& a, const FileSpec& b, bool full, bool 
remove_backups = false);
 
 //--
 /// Dump this object to a Stream.
@@ -582,6 +582,20 @@ public:
 static void Normalize(llvm::SmallVectorImpl &path, PathSyntax syntax 
= ePathSyntaxHostNative);
 static void DeNormalize(llvm::SmallVectorImpl &path, PathSyntax 
syntax = ePathSyntaxHostNative);
 
+
+//--
+/// Run through the input string, replaying the effect of any ".." and 
produce
+/// the resultant path.  The input path is not required to be in the host 
file system
+/// format, but it is required to be normalized to that system.
+///
+/// @param[in] input
+/// The input path to analyze.
+///
+/// @param[out] result
+/// The backup-resolved path will be written here.
+//--
+static void RemoveBackupDots (const ConstString &input_const_str, 
ConstString &result_const_str);
+
 //--
 /// Change the file specified with a new path.
 ///

Modified: lldb/trunk/source/Core/FileSpecList.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FileSpecList.cpp?rev=222075&r1=222074&r2=222075&view=diff
==
--- lldb/trunk/source/Core/FileSpecList.cpp (original)
+++ lldb/trunk/source/Core/FileSpecList.cpp Fri Nov 14 19:54:26 2014
@@ -107,7 +107,7 @@ FileSpecList::Dump(Stream *s, const char
 // it is found, else UINT32_MAX is returned.
 //--
 size_t
-FileSpecList::FindFileIndex (size_t start_idx, const FileSpec &file_spec, bool 
full) const
+FileSpecList::FindFileIndex (size_t start_idx, const FileSpec &file_spec, bool 
full, bool remove_dots) const
 {
 const size_t nu