diff options
author | Greg Clayton <gclayton@apple.com> | 2012-11-29 22:16:27 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2012-11-29 22:16:27 +0000 |
commit | 50a24bd358b5a2f23ac9241cc8af3799e3d66523 (patch) | |
tree | b71428c7bd54a1d9745c6b7f5e522d1d5fc55f93 /lldb/source/Commands/CommandObjectTarget.cpp | |
parent | 929a94f0263d436e92618097eab008e2d535436e (diff) | |
download | bcm5719-llvm-50a24bd358b5a2f23ac9241cc8af3799e3d66523.tar.gz bcm5719-llvm-50a24bd358b5a2f23ac9241cc8af3799e3d66523.zip |
<rdar://problem/12687087>
Emit an error when using "target modules add PATH" where PATH points to a debug info only (dSYM) file.
Also added a "--uuid" option for "target modules add --uuid UUID" to locate and load a module by UUID if the host supports it.
llvm-svn: 168949
Diffstat (limited to 'lldb/source/Commands/CommandObjectTarget.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectTarget.cpp | 91 |
1 files changed, 85 insertions, 6 deletions
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index bd89f881915..829283dee9f 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -2442,14 +2442,23 @@ public: CommandObjectParsed (interpreter, "target modules add", "Add a new module to the current target's modules.", - "target modules add [<module>]") + "target modules add [<module>]"), + m_option_group (interpreter) { + m_option_group.Append (&m_uuid_option_group, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); + m_option_group.Finalize(); } virtual ~CommandObjectTargetModulesAdd () { } + + virtual Options * + GetOptions () + { + return &m_option_group; + } int HandleArgumentCompletion (Args &input, @@ -2476,6 +2485,11 @@ public: } protected: + + OptionGroupOptions m_option_group; + OptionGroupUUID m_uuid_option_group; + + virtual bool DoExecute (Args& args, CommandReturnObject &result) @@ -2492,9 +2506,66 @@ protected: const size_t argc = args.GetArgumentCount(); if (argc == 0) { - result.AppendError ("one or more executable image paths must be specified"); - result.SetStatus (eReturnStatusFailed); - return false; + if (m_uuid_option_group.GetOptionValue ().OptionWasSet()) + { + // We are given a UUID only, go locate the file + ModuleSpec module_spec; + module_spec.GetUUID() = m_uuid_option_group.GetOptionValue ().GetCurrentValue(); + if (Symbols::DownloadObjectAndSymbolFile (module_spec)) + { + ModuleSP module_sp (target->GetSharedModule (module_spec)); + if (module_sp) + { + result.SetStatus (eReturnStatusSuccessFinishResult); + return true; + } + else + { + StreamString strm; + module_spec.GetUUID().Dump (&strm); + if (module_spec.GetFileSpec()) + { + if (module_spec.GetSymbolFileSpec()) + { + result.AppendErrorWithFormat ("Unable to create the executable or symbol file with UUID %s with path %s/%s and symbol file %s/%s", + strm.GetString().c_str(), + module_spec.GetFileSpec().GetDirectory().GetCString(), + module_spec.GetFileSpec().GetFilename().GetCString(), + module_spec.GetSymbolFileSpec().GetDirectory().GetCString(), + module_spec.GetSymbolFileSpec().GetFilename().GetCString()); + } + else + { + result.AppendErrorWithFormat ("Unable to create the executable or symbol file with UUID %s with path %s/%s", + strm.GetString().c_str(), + module_spec.GetFileSpec().GetDirectory().GetCString(), + module_spec.GetFileSpec().GetFilename().GetCString()); + } + } + else + { + result.AppendErrorWithFormat ("Unable to create the executable or symbol file with UUID %s", + strm.GetString().c_str()); + } + result.SetStatus (eReturnStatusFailed); + return false; + } + } + else + { + StreamString strm; + module_spec.GetUUID().Dump (&strm); + result.AppendErrorWithFormat ("Unable to locate the executable or symbol file with UUID %s", strm.GetString().c_str()); + result.SetStatus (eReturnStatusFailed); + return false; + } + } + else + { + result.AppendError ("one or more executable image paths must be specified"); + result.SetStatus (eReturnStatusFailed); + return false; + } } else { @@ -2507,10 +2578,18 @@ protected: if (file_spec.Exists()) { ModuleSpec module_spec (file_spec); - ModuleSP module_sp (target->GetSharedModule (module_spec)); + if (m_uuid_option_group.GetOptionValue ().OptionWasSet()) + module_spec.GetUUID() = m_uuid_option_group.GetOptionValue ().GetCurrentValue(); + + Error error; + ModuleSP module_sp (target->GetSharedModule (module_spec, &error)); if (!module_sp) { - result.AppendError ("one or more executable image paths must be specified"); + const char *error_cstr = error.AsCString(); + if (error_cstr) + result.AppendError (error_cstr); + else + result.AppendErrorWithFormat ("unsupported module: %s", path); result.SetStatus (eReturnStatusFailed); return false; } |