Index: source/Target/PathMappingList.cpp =================================================================== --- source/Target/PathMappingList.cpp +++ source/Target/PathMappingList.cpp @@ -22,6 +22,32 @@ using namespace lldb; using namespace lldb_private; +// slash independent string compare which +// considers '\\' to be the same as '/' +static +int strncmp_path( const char *a, const char *b, const int max ) +{ + // loop until at max chars, end of line, or mismatch + for ( int i = 0; i < max; i++ ) + { + // match slashes + bool skip = true; + skip &= ( a[i] == '\\' || a[i] == '/' ); + skip &= ( b[i] == '\\' || b[i] == '/' ); + + // match character or skip + if ( (a[i] != b[i]) && !skip ) + return i+1; + + // break at end of line + if ( a[i] == '\0' ) + break; + } + + // success + return 0; +} + //---------------------------------------------------------------------- // PathMappingList constructor //---------------------------------------------------------------------- @@ -180,24 +206,38 @@ bool PathMappingList::RemapPath (const ConstString &path, ConstString &new_path) const { + // get the current path as a cstring const char *path_cstr = path.GetCString(); - if (!path_cstr) return false; + // search through all items in the path mapping list const_iterator pos, end = m_pairs.end(); for (pos = m_pairs.begin(); pos != end; ++pos) { + // get the length of the prefix + // + // prefix in this case is the partial string that we are to match const size_t prefixLen = pos->first.GetLength(); - if (::strncmp (pos->first.GetCString(), path_cstr, prefixLen) == 0) + if ( strncmp_path(pos->first.GetCString(), path_cstr, prefixLen) == 0) { std::string new_path_str (pos->second.GetCString()); new_path_str.append(path.GetCString() + prefixLen); new_path.SetCString(new_path_str.c_str()); return true; } + + // we can always match when our current path is empty and prefix is current directory + if ( path.GetLength() == 0 && strncmp_path( pos->first.GetCString(), ".", 1 ) == 0 ) + { + new_path.SetCString( pos->second.GetCString( ) ); + return true; + } + } + + // we cant make a match return false; } @@ -212,7 +252,7 @@ { const size_t prefix_len = pos->first.GetLength(); - if (::strncmp (pos->first.GetCString(), path, prefix_len) == 0) + if ( strncmp_path(pos->first.GetCString(), path, prefix_len) == 0) { new_path = pos->second.GetCString(); new_path.append(path + prefix_len); @@ -239,7 +279,9 @@ if (orig_path_len >= prefix_len) { - if (::strncmp (pos->first.GetCString(), orig_path, prefix_len) == 0) + const char *precstr = pos->first.GetCString( ); + + if ( strncmp_path(precstr, orig_path, prefix_len) == 0) { const size_t new_path_len = snprintf(new_path, sizeof(new_path), "%s/%s", pos->second.GetCString(), orig_path + prefix_len); if (new_path_len < sizeof(new_path)) @@ -329,8 +371,6 @@ return false; } - - uint32_t PathMappingList::FindIndexForPath (const ConstString &path) const {