[Lldb-commits] [lldb] fb0d2d4 - Fix after c25938d
Adrian McCarthy via lldb-commits
lldb-commits at lists.llvm.org
Tue Feb 4 16:37:58 PST 2020
Author: Adrian McCarthy
Date: 2020-02-04T16:37:22-08:00
New Revision: fb0d2d455f56bca239041c8d7ad7b57da1087b35
URL: https://github.com/llvm/llvm-project/commit/fb0d2d455f56bca239041c8d7ad7b57da1087b35
DIFF: https://github.com/llvm/llvm-project/commit/fb0d2d455f56bca239041c8d7ad7b57da1087b35.diff
LOG: Fix after c25938d
My refactor caused some changes in error reporting that TestAddDsymCommand.py
was checking, so this restores some of the changes to preserve the old
behavior and to un-xfail the affected test.
Differential Revision: https://reviews.llvm.org/D74001
Added:
Modified:
lldb/packages/Python/lldbsuite/test/commands/add-dsym/uuid/TestAddDsymCommand.py
lldb/source/Commands/CommandObjectTarget.cpp
Removed:
################################################################################
diff --git a/lldb/packages/Python/lldbsuite/test/commands/add-dsym/uuid/TestAddDsymCommand.py b/lldb/packages/Python/lldbsuite/test/commands/add-dsym/uuid/TestAddDsymCommand.py
index 91e4c6a9e101..8a0fe377f268 100644
--- a/lldb/packages/Python/lldbsuite/test/commands/add-dsym/uuid/TestAddDsymCommand.py
+++ b/lldb/packages/Python/lldbsuite/test/commands/add-dsym/uuid/TestAddDsymCommand.py
@@ -22,7 +22,6 @@ def setUp(self):
self.teardown_hook_added = False
@no_debug_info_test
- @expectedFailureDarwin('until AdrianM or I find a fix for his 2020-02-03 CommandObjectTarget change')
def test_add_dsym_command_with_error(self):
"""Test that the 'add-dsym' command informs the user about failures."""
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index 0239f7e33e02..50eb46fafca8 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -4119,23 +4119,6 @@ class CommandObjectTargetSymbolsAdd : public CommandObjectParsed {
target->GetImages().FindModules(module_spec, matching_modules);
}
- if (matching_modules.IsEmpty()) {
- StreamString ss_symfile_uuid;
- if (module_spec.GetUUID().IsValid()) {
- ss_symfile_uuid << " (";
- module_spec.GetUUID().Dump(&ss_symfile_uuid);
- ss_symfile_uuid << ')';
- }
- result.AppendErrorWithFormat(
- "symbol file '%s'%s does not match any existing module%s\n",
- symfile_path, ss_symfile_uuid.GetData(),
- !llvm::sys::fs::is_regular_file(symbol_fspec.GetPath())
- ? "\n please specify the full path to the symbol file"
- : "");
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
-
if (matching_modules.GetSize() > 1) {
result.AppendErrorWithFormat("multiple modules match symbol file '%s', "
"use the --uuid option to resolve the "
@@ -4144,65 +4127,72 @@ class CommandObjectTargetSymbolsAdd : public CommandObjectParsed {
result.SetStatus(eReturnStatusFailed);
return false;
}
-
- assert(matching_modules.GetSize() == 1);
- ModuleSP module_sp(matching_modules.GetModuleAtIndex(0));
-
- // The module has not yet created its symbol vendor, we can just give
- // the existing target module the symfile path to use for when it
- // decides to create it!
- module_sp->SetSymbolFileFileSpec(symbol_fspec);
-
- SymbolFile *symbol_file =
- module_sp->GetSymbolFile(true, &result.GetErrorStream());
- if (!symbol_file) {
- result.AppendErrorWithFormat("symbol file '%s' could not be loaded\n",
- symfile_path);
- result.SetStatus(eReturnStatusFailed);
- module_sp->SetSymbolFileFileSpec(FileSpec());
- return false;
- }
- ObjectFile *object_file = symbol_file->GetObjectFile();
- if (!object_file || object_file->GetFileSpec() != symbol_fspec) {
- result.AppendError("the object file could not be loaded\n");
- result.SetStatus(eReturnStatusFailed);
+ if (matching_modules.GetSize() == 1) {
+ ModuleSP module_sp(matching_modules.GetModuleAtIndex(0));
+
+ // The module has not yet created its symbol vendor, we can just give
+ // the existing target module the symfile path to use for when it
+ // decides to create it!
+ module_sp->SetSymbolFileFileSpec(symbol_fspec);
+
+ SymbolFile *symbol_file =
+ module_sp->GetSymbolFile(true, &result.GetErrorStream());
+ if (symbol_file) {
+ ObjectFile *object_file = symbol_file->GetObjectFile();
+ if (object_file && object_file->GetFileSpec() == symbol_fspec) {
+ // Provide feedback that the symfile has been successfully added.
+ const FileSpec &module_fs = module_sp->GetFileSpec();
+ result.AppendMessageWithFormat(
+ "symbol file '%s' has been added to '%s'\n", symfile_path,
+ module_fs.GetPath().c_str());
+
+ // Let clients know something changed in the module if it is
+ // currently loaded
+ ModuleList module_list;
+ module_list.Append(module_sp);
+ target->SymbolsDidLoad(module_list);
+
+ // Make sure we load any scripting resources that may be embedded
+ // in the debug info files in case the platform supports that.
+ Status error;
+ StreamString feedback_stream;
+ module_sp->LoadScriptingResourceInTarget(target, error,
+ &feedback_stream);
+ if (error.Fail() && error.AsCString())
+ result.AppendWarningWithFormat(
+ "unable to load scripting data for module %s - error "
+ "reported was %s",
+ module_sp->GetFileSpec()
+ .GetFileNameStrippingExtension()
+ .GetCString(),
+ error.AsCString());
+ else if (feedback_stream.GetSize())
+ result.AppendWarning(feedback_stream.GetData());
+
+ flush = true;
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+ return true;
+ }
+ }
+ // Clear the symbol file spec if anything went wrong
module_sp->SetSymbolFileFileSpec(FileSpec());
- return false;
}
-
- // Provide feedback that the symfile has been successfully added.
- const FileSpec &module_fs = module_sp->GetFileSpec();
- result.AppendMessageWithFormat(
- "symbol file '%s' has been added to '%s'\n", symfile_path,
- module_fs.GetPath().c_str());
-
- // Let clients know something changed in the module if it is
- // currently loaded
- ModuleList module_list;
- module_list.Append(module_sp);
- target->SymbolsDidLoad(module_list);
- // Make sure we load any scripting resources that may be embedded
- // in the debug info files in case the platform supports that.
- Status error;
- StreamString feedback_stream;
- module_sp->LoadScriptingResourceInTarget(target, error,
- &feedback_stream);
- if (error.Fail() && error.AsCString())
- result.AppendWarningWithFormat(
- "unable to load scripting data for module %s - error "
- "reported was %s",
- module_sp->GetFileSpec()
- .GetFileNameStrippingExtension()
- .GetCString(),
- error.AsCString());
- else if (feedback_stream.GetSize())
- result.AppendWarning(feedback_stream.GetData());
-
- flush = true;
- result.SetStatus(eReturnStatusSuccessFinishResult);
- return true;
+ StreamString ss_symfile_uuid;
+ if (module_spec.GetUUID().IsValid()) {
+ ss_symfile_uuid << " (";
+ module_spec.GetUUID().Dump(&ss_symfile_uuid);
+ ss_symfile_uuid << ')';
+ }
+ result.AppendErrorWithFormat(
+ "symbol file '%s'%s does not match any existing module%s\n",
+ symfile_path, ss_symfile_uuid.GetData(),
+ !llvm::sys::fs::is_regular_file(symbol_fspec.GetPath())
+ ? "\n please specify the full path to the symbol file"
+ : "");
+ result.SetStatus(eReturnStatusFailed);
+ return false;
}
bool DoExecute(Args &args, CommandReturnObject &result) override {
More information about the lldb-commits
mailing list