summaryrefslogtreecommitdiffstats
path: root/lldb
diff options
context:
space:
mode:
Diffstat (limited to 'lldb')
-rw-r--r--lldb/include/lldb/Utility/FileSpec.h7
-rw-r--r--lldb/lit/SymbolFile/Breakpad/Inputs/line-table-mixed-path-styles.syms7
-rw-r--r--lldb/lit/SymbolFile/Breakpad/line-table-discontinuous-file-ids.test2
-rw-r--r--lldb/lit/SymbolFile/Breakpad/line-table-edgecases.test2
-rw-r--r--lldb/lit/SymbolFile/Breakpad/line-table-missing-file.test2
-rw-r--r--lldb/lit/SymbolFile/Breakpad/line-table-mixed-path-styles.test11
-rw-r--r--lldb/lit/SymbolFile/Breakpad/line-table.test2
-rw-r--r--lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp4
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp17
-rw-r--r--lldb/source/Utility/FileSpec.cpp11
-rw-r--r--lldb/unittests/Utility/FileSpecTest.cpp11
11 files changed, 57 insertions, 19 deletions
diff --git a/lldb/include/lldb/Utility/FileSpec.h b/lldb/include/lldb/Utility/FileSpec.h
index 21fc990ba3c..61d13c7e313 100644
--- a/lldb/include/lldb/Utility/FileSpec.h
+++ b/lldb/include/lldb/Utility/FileSpec.h
@@ -242,6 +242,13 @@ public:
static bool Equal(const FileSpec &a, const FileSpec &b, bool full);
+ /// Attempt to guess path style for a given path string. It returns a style,
+ /// if it was able to make a reasonable guess, or None if it wasn't. The guess
+ /// will be correct if the input path was a valid absolute path on the system
+ /// which produced it. On other paths the result of this function is
+ /// unreliable (e.g. "c:\foo.txt" is a valid relative posix path).
+ static llvm::Optional<Style> GuessPathStyle(llvm::StringRef absolute_path);
+
//------------------------------------------------------------------
/// Case sensitivity of path.
///
diff --git a/lldb/lit/SymbolFile/Breakpad/Inputs/line-table-mixed-path-styles.syms b/lldb/lit/SymbolFile/Breakpad/Inputs/line-table-mixed-path-styles.syms
new file mode 100644
index 00000000000..a0708e54dc0
--- /dev/null
+++ b/lldb/lit/SymbolFile/Breakpad/Inputs/line-table-mixed-path-styles.syms
@@ -0,0 +1,7 @@
+MODULE Linux x86_64 761550E08086333960A9074A9CE2895C0 a.out
+INFO CODE_ID E05015768680393360A9074A9CE2895C
+FILE 0 /tmp/a.c
+FILE 1 c:\tmp\b.c
+FUNC b0 10 0 func
+b0 1 1 0
+b1 1 1 1
diff --git a/lldb/lit/SymbolFile/Breakpad/line-table-discontinuous-file-ids.test b/lldb/lit/SymbolFile/Breakpad/line-table-discontinuous-file-ids.test
index d5113ccb03f..3b48f4f3c5a 100644
--- a/lldb/lit/SymbolFile/Breakpad/line-table-discontinuous-file-ids.test
+++ b/lldb/lit/SymbolFile/Breakpad/line-table-discontinuous-file-ids.test
@@ -1,7 +1,5 @@
# Test that we handle files which has gaps in the FILE record IDs.
-# XFAIL: system-windows
-
# RUN: yaml2obj %S/Inputs/basic-elf.yaml > %T/line-table-discontinuous-file-ids.out
# RUN: %lldb %T/line-table-discontinuous-file-ids.out \
# RUN: -o "target symbols add -s line-table-discontinuous-file-ids.out %S/Inputs/line-table-discontinuous-file-ids.syms" \
diff --git a/lldb/lit/SymbolFile/Breakpad/line-table-edgecases.test b/lldb/lit/SymbolFile/Breakpad/line-table-edgecases.test
index 8aaf0a3fafa..3a097725a97 100644
--- a/lldb/lit/SymbolFile/Breakpad/line-table-edgecases.test
+++ b/lldb/lit/SymbolFile/Breakpad/line-table-edgecases.test
@@ -2,8 +2,6 @@
# input contains a LINE record which does not belong to any function as well as
# a FUNC record without any LINE records.
-# XFAIL: system-windows
-
# RUN: yaml2obj %S/Inputs/basic-elf.yaml > %T/line-table-edgecases.out
# RUN: %lldb %T/line-table-edgecases.out \
# RUN: -o "target symbols add -s line-table-edgecases.out %S/Inputs/line-table-edgecases.syms" \
diff --git a/lldb/lit/SymbolFile/Breakpad/line-table-missing-file.test b/lldb/lit/SymbolFile/Breakpad/line-table-missing-file.test
index c0beeaf67cf..0c0fb3f8ea8 100644
--- a/lldb/lit/SymbolFile/Breakpad/line-table-missing-file.test
+++ b/lldb/lit/SymbolFile/Breakpad/line-table-missing-file.test
@@ -3,8 +3,6 @@
# Right now, "something reasonable" means creating a line entry with an empty
# file.
-# XFAIL: system-windows
-
# RUN: yaml2obj %S/Inputs/basic-elf.yaml > %T/line-table-missing-file.out
# RUN: %lldb %T/line-table-missing-file.out \
# RUN: -o "target symbols add -s line-table-missing-file.out %S/Inputs/line-table-missing-file.syms" \
diff --git a/lldb/lit/SymbolFile/Breakpad/line-table-mixed-path-styles.test b/lldb/lit/SymbolFile/Breakpad/line-table-mixed-path-styles.test
new file mode 100644
index 00000000000..617b5eb6a9f
--- /dev/null
+++ b/lldb/lit/SymbolFile/Breakpad/line-table-mixed-path-styles.test
@@ -0,0 +1,11 @@
+# RUN: yaml2obj %S/Inputs/basic-elf.yaml > %T/line-table-mixed-path-styles.out
+# RUN: %lldb %T/line-table-mixed-path-styles.out \
+# RUN: -o "target symbols add -s line-table-mixed-path-styles.out %S/Inputs/line-table-mixed-path-styles.syms" \
+# RUN: -s %s -o exit | FileCheck %s
+
+image dump line-table a.c
+# CHECK-LABEL: Line table for /tmp/a.c
+# CHECK-NEXT: 0x00000000004000b0: /tmp/a.c:1
+# CHECK-NEXT: 0x00000000004000b1: c:\tmp\b.c:1
+# CHECK-NEXT: 0x00000000004000b2:
+# CHECK-EMPTY:
diff --git a/lldb/lit/SymbolFile/Breakpad/line-table.test b/lldb/lit/SymbolFile/Breakpad/line-table.test
index 1f2aab002d6..f5661cf7ee9 100644
--- a/lldb/lit/SymbolFile/Breakpad/line-table.test
+++ b/lldb/lit/SymbolFile/Breakpad/line-table.test
@@ -1,5 +1,3 @@
-# XFAIL: system-windows
-
# RUN: yaml2obj %S/Inputs/basic-elf.yaml > %T/line-table.out
# RUN: %lldb %T/line-table.out -o "target symbols add -s line-table.out %S/Inputs/line-table.syms" \
# RUN: -s %s -o exit | FileCheck %s
diff --git a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
index 198be6c4803..ec50f9bc2d9 100644
--- a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
+++ b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
@@ -398,7 +398,9 @@ void SymbolFileBreakpad::ParseFileRecords() {
if (record->Number >= m_files->size())
m_files->resize(record->Number + 1);
- (*m_files)[record->Number] = FileSpec(record->Name);
+ FileSpec::Style style = FileSpec::GuessPathStyle(record->Name)
+ .getValueOr(FileSpec::Style::native);
+ (*m_files)[record->Number] = FileSpec(record->Name, style);
}
}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index 6f4d6625822..cdfd672b2aa 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -820,22 +820,19 @@ void DWARFUnit::ComputeCompDirAndGuessPathStyle() {
if (!die)
return;
- auto guess = [](llvm::StringRef str) {
- if (str.startswith("/"))
- return FileSpec::Style::posix;
- if (str.size() > 3 && llvm::isAlpha(str[0]) && str.substr(1, 2) == ":\\")
- return FileSpec::Style::windows;
- return FileSpec::Style::native;
- };
llvm::StringRef comp_dir = removeHostnameFromPathname(
die->GetAttributeValueAsString(m_dwarf, this, DW_AT_comp_dir, NULL));
if (!comp_dir.empty()) {
- m_comp_dir = resolveCompDir(FileSpec(comp_dir, guess(comp_dir)));
+ FileSpec::Style comp_dir_style =
+ FileSpec::GuessPathStyle(comp_dir).getValueOr(FileSpec::Style::native);
+ m_comp_dir = resolveCompDir(FileSpec(comp_dir, comp_dir_style));
} else {
// Try to detect the style based on the DW_AT_name attribute, but just store
// the detected style in the m_comp_dir field.
- m_comp_dir = FileSpec("", guess(die->GetAttributeValueAsString(
- m_dwarf, this, DW_AT_name, NULL)));
+ const char *name =
+ die->GetAttributeValueAsString(m_dwarf, this, DW_AT_name, NULL);
+ m_comp_dir = FileSpec(
+ "", FileSpec::GuessPathStyle(name).getValueOr(FileSpec::Style::native));
}
}
diff --git a/lldb/source/Utility/FileSpec.cpp b/lldb/source/Utility/FileSpec.cpp
index 25d2278fe67..38ce36a18ac 100644
--- a/lldb/source/Utility/FileSpec.cpp
+++ b/lldb/source/Utility/FileSpec.cpp
@@ -365,6 +365,17 @@ bool FileSpec::Equal(const FileSpec &a, const FileSpec &b, bool full) {
return a == b;
}
+llvm::Optional<FileSpec::Style> FileSpec::GuessPathStyle(llvm::StringRef absolute_path) {
+ if (absolute_path.startswith("/"))
+ return Style::posix;
+ if (absolute_path.startswith(R"(\\)"))
+ return Style::windows;
+ if (absolute_path.size() > 3 && llvm::isAlpha(absolute_path[0]) &&
+ absolute_path.substr(1, 2) == R"(:\)")
+ return Style::windows;
+ return llvm::None;
+}
+
//------------------------------------------------------------------
// Dump the object to the supplied stream. If the object contains a valid
// directory name, it will be displayed followed by a directory delimiter, and
diff --git a/lldb/unittests/Utility/FileSpecTest.cpp b/lldb/unittests/Utility/FileSpecTest.cpp
index fa9e8d07235..0f5b1652d29 100644
--- a/lldb/unittests/Utility/FileSpecTest.cpp
+++ b/lldb/unittests/Utility/FileSpecTest.cpp
@@ -189,6 +189,17 @@ TEST(FileSpecTest, EqualDotsPosixRoot) {
}
}
+TEST(FileSpecTest, GuessPathStyle) {
+ EXPECT_EQ(FileSpec::Style::posix, FileSpec::GuessPathStyle("/foo/bar.txt"));
+ EXPECT_EQ(FileSpec::Style::posix, FileSpec::GuessPathStyle("//net/bar.txt"));
+ EXPECT_EQ(FileSpec::Style::windows,
+ FileSpec::GuessPathStyle(R"(C:\foo.txt)"));
+ EXPECT_EQ(FileSpec::Style::windows,
+ FileSpec::GuessPathStyle(R"(\\net\foo.txt)"));
+ EXPECT_EQ(llvm::None, FileSpec::GuessPathStyle("foo.txt"));
+ EXPECT_EQ(llvm::None, FileSpec::GuessPathStyle("foo/bar.txt"));
+}
+
TEST(FileSpecTest, GetNormalizedPath) {
std::pair<const char *, const char *> posix_tests[] = {
{"/foo/.././bar", "/bar"},
OpenPOWER on IntegriCloud