[Lldb-commits] [lldb] r107403 - in /lldb/trunk: include/lldb/Core/FileSpec.h source/Core/FileSpec.cpp
Greg Clayton
gclayton at apple.com
Thu Jul 1 10:07:49 PDT 2010
Author: gclayton
Date: Thu Jul 1 12:07:48 2010
New Revision: 107403
URL: http://llvm.org/viewvc/llvm-project?rev=107403&view=rev
Log:
Added a missing static function prototype to FileSpec.h for ResolveUsername.
Did a bit of code formatting and cleanup.
Modified:
lldb/trunk/include/lldb/Core/FileSpec.h
lldb/trunk/source/Core/FileSpec.cpp
Modified: lldb/trunk/include/lldb/Core/FileSpec.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FileSpec.h?rev=107403&r1=107402&r2=107403&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/FileSpec.h (original)
+++ lldb/trunk/include/lldb/Core/FileSpec.h Thu Jul 1 12:07:48 2010
@@ -23,8 +23,18 @@
/// @brief A file utility class.
///
/// A file specification class that divides paths up into a directory
-/// and filename. These string values of the paths are put into uniqued
+/// and basename. These string values of the paths are put into uniqued
/// string pools for fast comparisons and efficient memory usage.
+///
+/// Another reason the paths are split into the directory and basename
+/// is to allow efficient debugger searching. Often in a debugger the
+/// user types in the basename of the file, for example setting a
+/// breakpoint by file and line, or specifying a module (shared library)
+/// to limit the scope in which to execute a command. The user rarely
+/// types in a full path. When the paths are already split up, it makes
+/// it easy for us to compare only the basenames of a lot of file
+/// specifications without having to split up the file path each time
+/// to get to the basename.
//----------------------------------------------------------------------
class FileSpec
{
@@ -422,6 +432,9 @@
ReadFileLines (STLStringArray &lines);
static int
+ ResolveUsername (const char *src_path, char *dst_path, size_t dst_len);
+
+ static int
Resolve (const char *src_path, char *dst_path, size_t dst_len);
protected:
Modified: lldb/trunk/source/Core/FileSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FileSpec.cpp?rev=107403&r1=107402&r2=107403&view=diff
==============================================================================
--- lldb/trunk/source/Core/FileSpec.cpp (original)
+++ lldb/trunk/source/Core/FileSpec.cpp Thu Jul 1 12:07:48 2010
@@ -66,23 +66,23 @@
if (src_path == NULL || src_path[0] == '\0')
return 0;
-
+
// If there's no ~, then just copy src_path straight to dst_path (they may be the same string...)
if (src_path[0] != '~')
{
int len = strlen (src_path);
if (len >= dst_len)
{
- bcopy(src_path, dst_path, dst_len - 1);
- dst_path[dst_len] = '\0';
+ ::bcopy (src_path, dst_path, dst_len - 1);
+ dst_path[dst_len] = '\0';
}
else
- bcopy(src_path, dst_path, len + 1);
-
+ ::bcopy (src_path, dst_path, len + 1);
+
return len;
}
- char *first_slash = strchr(src_path, '/');
+ char *first_slash = ::strchr (src_path, '/');
char remainder[PATH_MAX];
if (first_slash == NULL)
@@ -94,13 +94,13 @@
else
{
int user_name_len = first_slash - src_path - 1;
- memcpy(user_home, src_path + 1, user_name_len);
+ ::memcpy (user_home, src_path + 1, user_name_len);
user_home[user_name_len] = '\0';
user_name = user_home;
- strcpy(remainder, first_slash);
+ ::strcpy (remainder, first_slash);
}
-
+
if (user_name == NULL)
return 0;
// User name of "" means the current user...
@@ -114,7 +114,7 @@
}
else
{
- user_entry = getpwnam (user_name);
+ user_entry = ::getpwnam (user_name);
if (user_entry != NULL)
home_dir = user_entry->pw_dir;
}
More information about the lldb-commits
mailing list