diff options
| author | Hafiz Abid Qadeer <hafiz_abid@mentor.com> | 2015-02-08 20:21:08 +0000 |
|---|---|---|
| committer | Hafiz Abid Qadeer <hafiz_abid@mentor.com> | 2015-02-08 20:21:08 +0000 |
| commit | 93ad6b31ec5a1d3f3f782f331acd179d64b7b0fc (patch) | |
| tree | dd18df52ba10185d5c5a7cfcd4512b5e99fd7953 | |
| parent | 055811ef722c140091f27dcc5f058e8ee17c6305 (diff) | |
| download | bcm5719-llvm-93ad6b31ec5a1d3f3f782f331acd179d64b7b0fc.tar.gz bcm5719-llvm-93ad6b31ec5a1d3f3f782f331acd179d64b7b0fc.zip | |
Fix a handling of full path in break-insert.
For some time, eclipse (CDT) uses full path of the file in break-insert command
when putting breakpoint on a source line. On windows, a typical command looks
like the following.
56-break-insert -f F:\\work\\ws\\test\\main.c:49
Current implementation in lldb-mi have problem in 2 ways.
1. It was assuming that there will be only one : in the path which is wrong if full
path is supplied.
2. CDT sends out path with double backslashes in windows which gives error on
resolution.
Fixed the : issue in lldb-mi. Changed FileSpec::Normalize to make sure that it
handles the path with \\ correctly. Added test cases to check for full path in
both lldb-mi and lldb. Also added a test case to check SBFileSpec with double
slashes.
llvm-svn: 228538
| -rw-r--r-- | lldb/source/Host/common/FileSpec.cpp | 6 | ||||
| -rw-r--r-- | lldb/test/functionalities/breakpoint/breakpoint_command/TestRegexpBreakCommand.py | 5 | ||||
| -rw-r--r-- | lldb/test/functionalities/paths/TestPaths.py | 9 | ||||
| -rw-r--r-- | lldb/test/tools/lldb-mi/TestMiBreakpoint.py | 11 | ||||
| -rw-r--r-- | lldb/test/tools/lldb-mi/main.c | 2 | ||||
| -rw-r--r-- | lldb/tools/lldb-mi/MICmdCmdBreak.cpp | 21 |
6 files changed, 40 insertions, 14 deletions
diff --git a/lldb/source/Host/common/FileSpec.cpp b/lldb/source/Host/common/FileSpec.cpp index ca50aac9d6e..6a6de53cd31 100644 --- a/lldb/source/Host/common/FileSpec.cpp +++ b/lldb/source/Host/common/FileSpec.cpp @@ -240,6 +240,12 @@ void FileSpec::Normalize(llvm::SmallVectorImpl<char> &path, PathSyntax syntax) return; std::replace(path.begin(), path.end(), '\\', '/'); + // Windows path can have \\ slashes which can be changed by replace + // call above to //. Here we remove the duplicate. + auto iter = std::unique ( path.begin(), path.end(), + []( char &c1, char &c2 ){ + return (c1 == '/' && c2 == '/');}); + path.erase(iter, path.end()); } void FileSpec::DeNormalize(llvm::SmallVectorImpl<char> &path, PathSyntax syntax) diff --git a/lldb/test/functionalities/breakpoint/breakpoint_command/TestRegexpBreakCommand.py b/lldb/test/functionalities/breakpoint/breakpoint_command/TestRegexpBreakCommand.py index 26764fabcef..055ca4cf2a1 100644 --- a/lldb/test/functionalities/breakpoint/breakpoint_command/TestRegexpBreakCommand.py +++ b/lldb/test/functionalities/breakpoint/breakpoint_command/TestRegexpBreakCommand.py @@ -43,6 +43,11 @@ class RegexpBreakCommandTestCase(TestBase): break_results = lldbutil.run_break_set_command (self, "b %s:%d" % (self.source, self.line)) lldbutil.check_breakpoint_result (self, break_results, file_name='main.c', line_number=self.line, num_locations=1) + # Check breakpoint with full file path. + full_path = os.path.join(os.getcwd(), self.source) + break_results = lldbutil.run_break_set_command (self, "b %s:%d" % (full_path, self.line)) + lldbutil.check_breakpoint_result (self, break_results, file_name='main.c', line_number=self.line, num_locations=1) + self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. diff --git a/lldb/test/functionalities/paths/TestPaths.py b/lldb/test/functionalities/paths/TestPaths.py index 5bea01a8296..c4bafa0ac6c 100644 --- a/lldb/test/functionalities/paths/TestPaths.py +++ b/lldb/test/functionalities/paths/TestPaths.py @@ -27,7 +27,14 @@ class TestPaths(TestBase): f = lldb.SBHostOS.GetLLDBPath(path_type); # No directory path types should have the filename set self.assertTrue (f.GetFilename() == None); - + + @unittest2.skipUnless(sys.platform.startswith("win32"), "Test for windows only") + def test_windows_double_slash (self): + '''Test to check the path with double slash is handled correctly ''' + # Create a path and see if lldb gets the directory and file right + fspec = lldb.SBFileSpec("C:\\dummy1\\dummy2//unknown_file", True); + self.assertTrue (fspec.GetDirectory() == "C:/dummy1/dummy2"); + self.assertTrue (fspec.GetFilename() == "unknown_file"); if __name__ == '__main__': import atexit diff --git a/lldb/test/tools/lldb-mi/TestMiBreakpoint.py b/lldb/test/tools/lldb-mi/TestMiBreakpoint.py index 9b52c53b243..497ddc4a031 100644 --- a/lldb/test/tools/lldb-mi/TestMiBreakpoint.py +++ b/lldb/test/tools/lldb-mi/TestMiBreakpoint.py @@ -83,6 +83,17 @@ class MiBreakpointTestCase(lldbmi_testcase.MiTestCaseBase): self.runCmd("-break-insert main.c:%d" % line) self.expect("\^done,bkpt={number=\"3\"") + # Check with full path. TODO, figure out why this commands fails + # if -f is not given + line = line_number('main.c', '// BP_doloop') + full_path = os.path.join(os.getcwd(), "main.c") + self.runCmd("-break-insert -f %s:%d" % (full_path, line)) + self.expect("\^done,bkpt={number=\"4\"") + + self.runCmd("-exec-continue") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + self.runCmd("-exec-continue") self.expect("\^running") self.expect("\*stopped,reason=\"breakpoint-hit\"") diff --git a/lldb/test/tools/lldb-mi/main.c b/lldb/test/tools/lldb-mi/main.c index d266e5ace6f..d43e440dfb8 100644 --- a/lldb/test/tools/lldb-mi/main.c +++ b/lldb/test/tools/lldb-mi/main.c @@ -22,7 +22,7 @@ int main (int argc, char const *argv[]) a = a_MyFunction(); //BP_a_MyFunction_call b = b_MyFunction(); //BP_b_MyFunction_call //BP_localstest -- it must be at line #24 (or fix it in main*.micmds) - if (doloop) + if (doloop) // BP_doloop infloop(); if (argc > 1 && *argv[1] == 'l') { a++; diff --git a/lldb/tools/lldb-mi/MICmdCmdBreak.cpp b/lldb/tools/lldb-mi/MICmdCmdBreak.cpp index 9e7a110afca..9ad7ea3540f 100644 --- a/lldb/tools/lldb-mi/MICmdCmdBreak.cpp +++ b/lldb/tools/lldb-mi/MICmdCmdBreak.cpp @@ -180,19 +180,16 @@ CMICmdCmdBreakInsert::Execute(void) CMIUtilString fileName; MIuint nFileLine = 0; CMIUtilString strFileFn; - const MIint nPosColon = m_brkName.find(cColon); - if (nPosColon != (MIint)std::string::npos) + CMIUtilString rStrLineOrFn; + // Full path in windows can have : after drive letter. So look for the + // last colon + const size_t nPosColon = m_brkName.find_last_of(cColon); + if (nPosColon != std::string::npos) { - CMIUtilString::VecString_t vecFileAndLocation; - const MIuint nSplits = m_brkName.Split(cColon, vecFileAndLocation); - MIunused(nSplits); - if (vecFileAndLocation.size() != 2) - { - SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_LOCATION_FORMAT), m_cmdData.strMiCmd.c_str(), m_brkName.c_str())); - return MIstatus::failure; - } - fileName = vecFileAndLocation.at(0); - const CMIUtilString &rStrLineOrFn(vecFileAndLocation.at(1)); + // extract file name and line number from it + fileName = m_brkName.substr(0, nPosColon); + rStrLineOrFn = m_brkName.substr(nPosColon + 1, m_brkName.size() - nPosColon - 1); + if (rStrLineOrFn.empty()) eBrkPtType = eBreakPoint_ByName; else |

