aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectTarget.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2014-08-15 18:00:45 +0000
committerGreg Clayton <gclayton@apple.com>2014-08-15 18:00:45 +0000
commit5acc12550f8d94cad2b5498a4842a5079c69ac04 (patch)
tree8e417d278cd0528b521c02c27028a22ec94d9c70 /lldb/source/Commands/CommandObjectTarget.cpp
parentd2308ea5fd583e8d342d9e8baa00486b57c6a9a9 (diff)
downloadllvm-5acc12550f8d94cad2b5498a4842a5079c69ac04.zip
llvm-5acc12550f8d94cad2b5498a4842a5079c69ac04.tar.gz
llvm-5acc12550f8d94cad2b5498a4842a5079c69ac04.tar.bz2
Don't crash when specifying a core file that isn't readable.
Fixes include: 1 - added new FileSpec method: bool FileSpec::Readable() 2 - detect when an executable is not readable and give an appropriate error for: (lldb) file /tmp/unreadablefile 3 - detect when a core file is not readable and give an appropriate error 4 - detect when a specified core file doesn't exist and give an appropriate error <rdar://problem/17727734> llvm-svn: 215741
Diffstat (limited to 'lldb/source/Commands/CommandObjectTarget.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectTarget.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index 95eec4d..c5e8826 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -230,12 +230,38 @@ protected:
FileSpec core_file (m_core_file.GetOptionValue().GetCurrentValue());
FileSpec remote_file (m_remote_file.GetOptionValue().GetCurrentValue());
+ if (core_file)
+ {
+ if (!core_file.Exists())
+ {
+ result.AppendErrorWithFormat("core file '%s' doesn't exist", core_file.GetPath().c_str());
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+
+ }
+ if (!core_file.Readable())
+ {
+ result.AppendErrorWithFormat("core file '%s' is not readable", core_file.GetPath().c_str());
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+ }
+
if (argc == 1 || core_file || remote_file)
{
FileSpec symfile (m_symbol_file.GetOptionValue().GetCurrentValue());
if (symfile)
{
- if (!symfile.Exists())
+ if (symfile.Exists())
+ {
+ if (!symfile.Readable())
+ {
+ result.AppendErrorWithFormat("symbol file '%s' is not readable", core_file.GetPath().c_str());
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+ }
+ else
{
char symfile_path[PATH_MAX];
symfile.GetPath(symfile_path, sizeof(symfile_path));