[Lldb-commits] [lldb] r362844 - Fix lit tests on Windows related to CR+LF

Adrian McCarthy via lldb-commits lldb-commits at lists.llvm.org
Fri Jun 7 14:13:30 PDT 2019


Author: amccarth
Date: Fri Jun  7 14:13:30 2019
New Revision: 362844

URL: http://llvm.org/viewvc/llvm-project?rev=362844&view=rev
Log:
Fix lit tests on Windows related to CR+LF

Problem discovered in the breakpoint lit test, but probably exists in others.
lldb-test splits lines on LF.  Input files that are CR+LF separated (as is
common on Windows) then resulted in commands being sent to LLDB that ended
in CR, which confused the command interpreter.

This could be fixed at different levels:

1.  Treat '\r' like a tab or space in the argument splitter.
2.  Fix the line splitters (plural) in lldb-test.
3.  Normalize the test files to LF only.

If we did only 3, I'd expect similar problems to recur, so this patch does
1 and 2.  I may also do 3 in a separate patch later, but that's tricky
because I believe we have some input files that MUST use CR+LF.

Differential Revision: https://reviews.llvm.org/D62759

Modified:
    lldb/trunk/source/Utility/Args.cpp
    lldb/trunk/tools/lldb-test/lldb-test.cpp

Modified: lldb/trunk/source/Utility/Args.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/Args.cpp?rev=362844&r1=362843&r2=362844&view=diff
==============================================================================
--- lldb/trunk/source/Utility/Args.cpp (original)
+++ lldb/trunk/source/Utility/Args.cpp Fri Jun  7 14:13:30 2019
@@ -95,7 +95,7 @@ ParseSingleArgument(llvm::StringRef comm
   bool arg_complete = false;
   do {
     // Skip over over regular characters and append them.
-    size_t regular = command.find_first_of(" \t\"'`\\");
+    size_t regular = command.find_first_of(" \t\r\"'`\\");
     arg += command.substr(0, regular);
     command = command.substr(regular);
 
@@ -123,6 +123,7 @@ ParseSingleArgument(llvm::StringRef comm
 
     case ' ':
     case '\t':
+    case '\r':
       // We are not inside any quotes, we just found a space after an argument.
       // We are done.
       arg_complete = true;

Modified: lldb/trunk/tools/lldb-test/lldb-test.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-test/lldb-test.cpp?rev=362844&r1=362843&r2=362844&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-test/lldb-test.cpp (original)
+++ lldb/trunk/tools/lldb-test/lldb-test.cpp Fri Jun  7 14:13:30 2019
@@ -312,7 +312,7 @@ int opts::breakpoint::evaluateBreakpoint
   while (!Rest.empty()) {
     StringRef Line;
     std::tie(Line, Rest) = Rest.split('\n');
-    Line = Line.ltrim();
+    Line = Line.ltrim().rtrim();
     if (Line.empty() || Line[0] == '#')
       continue;
 
@@ -939,7 +939,7 @@ int opts::irmemorymap::evaluateMemoryMap
   while (!Rest.empty()) {
     StringRef Line;
     std::tie(Line, Rest) = Rest.split('\n');
-    Line = Line.ltrim();
+    Line = Line.ltrim().rtrim();
 
     if (Line.empty() || Line[0] == '#')
       continue;




More information about the lldb-commits mailing list