[Lldb-commits] [lldb] r222498 - Change CommandObjectTargetModulesLoad so that the filename argument
Jason Molenda
jmolenda at apple.com
Thu Nov 20 18:25:15 PST 2014
Author: jmolenda
Date: Thu Nov 20 20:25:15 2014
New Revision: 222498
URL: http://llvm.org/viewvc/llvm-project?rev=222498&view=rev
Log:
Change CommandObjectTargetModulesLoad so that the filename argument
is treated as a string instead of a FileSpec.
OptionValueFileSpec::SetValueFromCString() passes the c string to
FileSpec::SetFile(str, true /* resolve */) - and with Zachary's
changes to FileSpec we're using llvm::sys::fs::make_absolute() to
do that "resolve" action now, where we used to use realpath().
One important difference between llvm::sys::fs::make_absolute and
realpath is that when they're handed a filename (no directory),
realpath prepends the current working directory *and if the file exists*,
returns that full path. If that file doesn't exist, the caller
uses the basename only.
llvm::sys::fs::make_absolute prepends the current working directory
regardless of whether it exists or not.
I considered having FileSpec::SetFile save the initial pathname,
call FileSpec::Resolve, and then check to see if the Resolve return
path exists - and if not, go back to the original one.
But instead I just went with changing 'target modules load' to treat its
filename argument as a string instead of a FileSpec. This brings it
in line with how 'target modules list' works.
<rdar://problem/18955416>
Modified:
lldb/trunk/source/Commands/CommandObjectTarget.cpp
Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=222498&r1=222497&r2=222498&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Thu Nov 20 20:25:15 2014
@@ -39,6 +39,7 @@
#include "lldb/Interpreter/OptionGroupPlatform.h"
#include "lldb/Interpreter/OptionGroupUInt64.h"
#include "lldb/Interpreter/OptionGroupUUID.h"
+#include "lldb/Interpreter/OptionGroupString.h"
#include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/FuncUnwinders.h"
@@ -2844,7 +2845,7 @@ public:
"Set the load addresses for one or more sections in a target module.",
"target modules load [--file <module> --uuid <uuid>] <sect-name> <address> [<sect-name> <address> ....]"),
m_option_group (interpreter),
- m_file_option (LLDB_OPT_SET_1, false, "file", 'f', 0, eArgTypeFilename, "Fullpath or basename for module to load."),
+ m_file_option (LLDB_OPT_SET_1, false, "file", 'f', 0, eArgTypeName, "Fullpath or basename for module to load.", ""),
m_slide_option(LLDB_OPT_SET_1, false, "slide", 's', 0, eArgTypeOffset, "Set the load address for all sections to be the virtual address in the file plus the offset.", 0)
{
m_option_group.Append (&m_uuid_option_group, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
@@ -2884,7 +2885,26 @@ protected:
if (m_file_option.GetOptionValue().OptionWasSet())
{
search_using_module_spec = true;
- module_spec.GetFileSpec() = m_file_option.GetOptionValue().GetCurrentValue();
+ const char *arg_cstr = m_file_option.GetOptionValue().GetCurrentValue();
+ const bool use_global_module_list = true;
+ ModuleList module_list;
+ const size_t num_matches = FindModulesByName (target, arg_cstr, module_list, use_global_module_list);
+ if (num_matches == 1)
+ {
+ module_spec.GetFileSpec() = module_list.GetModuleAtIndex(0)->GetFileSpec();
+ }
+ else if (num_matches > 1 )
+ {
+ search_using_module_spec = false;
+ result.AppendErrorWithFormat ("more than 1 module matched by name '%s'\n", arg_cstr);
+ result.SetStatus (eReturnStatusFailed);
+ }
+ else
+ {
+ search_using_module_spec = false;
+ result.AppendErrorWithFormat ("no object file for module '%s'\n", arg_cstr);
+ result.SetStatus (eReturnStatusFailed);
+ }
}
if (m_uuid_option_group.GetOptionValue().OptionWasSet())
@@ -3070,7 +3090,7 @@ protected:
OptionGroupOptions m_option_group;
OptionGroupUUID m_uuid_option_group;
- OptionGroupFile m_file_option;
+ OptionGroupString m_file_option;
OptionGroupUInt64 m_slide_option;
};
More information about the lldb-commits
mailing list