jingham created this revision. jingham added a reviewer: JDevlieghere. Herald added a project: All. jingham requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits.
When there's an error with the pathname in "command script import" lldb just says "error: module importing failed: invalid pathname" but doesn't actually tell you what the bad pathname was. When you're loading some python module that imports a bunch of other modules, that makes it hard to figure out which one was bad. I changed it to either say "empty path" if that was the error, or report the pathname otherwise. I added a test as well. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D129338 Files: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp lldb/test/API/commands/command/script/import/TestImport.py Index: lldb/test/API/commands/command/script/import/TestImport.py =================================================================== --- lldb/test/API/commands/command/script/import/TestImport.py +++ lldb/test/API/commands/command/script/import/TestImport.py @@ -39,11 +39,10 @@ self.runCmd("command script import ./bar/bar.py --allow-reload") self.expect("command script import ./nosuchfile.py", - error=True, startstr='error: module importing failed') + error=True, startstr="error: module importing failed: invalid pathname './nosuchfile.py'") self.expect("command script import ./nosuchfolder/", error=True, startstr='error: module importing failed') self.expect("command script import ./foo/foo.py", error=False) - self.runCmd("command script import --allow-reload ./thepackage") self.expect("TPcommandA", substrs=["hello world A"]) self.expect("TPcommandB", substrs=["hello world B"]) Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp =================================================================== --- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -2637,7 +2637,7 @@ .SetSetLLDBGlobals(false); if (!pathname || !pathname[0]) { - error.SetErrorString("invalid pathname"); + error.SetErrorString("empty path"); return false; } @@ -2707,7 +2707,7 @@ // if not a valid file of any sort, check if it might be a filename still // dot can't be used but / and \ can, and if either is found, reject if (strchr(pathname, '\\') || strchr(pathname, '/')) { - error.SetErrorString("invalid pathname"); + error.SetErrorStringWithFormatv("invalid pathname '{0}'", pathname); return false; } // Not a filename, probably a package of some sort, let it go through.
Index: lldb/test/API/commands/command/script/import/TestImport.py =================================================================== --- lldb/test/API/commands/command/script/import/TestImport.py +++ lldb/test/API/commands/command/script/import/TestImport.py @@ -39,11 +39,10 @@ self.runCmd("command script import ./bar/bar.py --allow-reload") self.expect("command script import ./nosuchfile.py", - error=True, startstr='error: module importing failed') + error=True, startstr="error: module importing failed: invalid pathname './nosuchfile.py'") self.expect("command script import ./nosuchfolder/", error=True, startstr='error: module importing failed') self.expect("command script import ./foo/foo.py", error=False) - self.runCmd("command script import --allow-reload ./thepackage") self.expect("TPcommandA", substrs=["hello world A"]) self.expect("TPcommandB", substrs=["hello world B"]) Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp =================================================================== --- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -2637,7 +2637,7 @@ .SetSetLLDBGlobals(false); if (!pathname || !pathname[0]) { - error.SetErrorString("invalid pathname"); + error.SetErrorString("empty path"); return false; } @@ -2707,7 +2707,7 @@ // if not a valid file of any sort, check if it might be a filename still // dot can't be used but / and \ can, and if either is found, reject if (strchr(pathname, '\\') || strchr(pathname, '/')) { - error.SetErrorString("invalid pathname"); + error.SetErrorStringWithFormatv("invalid pathname '{0}'", pathname); return false; } // Not a filename, probably a package of some sort, let it go through.
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits