17
17
#include "lldb/Core/Debugger.h"
18
18
#include "lldb/Core/Event.h"
19
19
#include "lldb/Core/Module.h"
20
#include "lldb/Core/ModuleSpec.h"
20
21
#include "lldb/Core/State.h"
21
22
#include "lldb/Core/Timer.h"
22
23
#include "lldb/Host/Host.h"
23
24
#include "lldb/Interpreter/CommandInterpreter.h"
24
25
#include "lldb/Interpreter/OptionGroupPlatform.h"
26
#include "lldb/Symbol/ObjectFile.h"
25
27
#include "lldb/Target/Platform.h"
26
28
#include "lldb/Target/Process.h"
27
29
#include "lldb/Target/TargetList.h"
84
86
ArchSpec platform_arch(arch);
89
if (user_exe_path && user_exe_path[0])
91
ModuleSpecList module_specs;
92
ModuleSpec module_spec;
93
module_spec.GetFileSpec().SetFile(user_exe_path, true);
94
lldb::offset_t file_offset = 0;
95
const size_t num_specs = ObjectFile::GetModuleSpecifications (module_spec.GetFileSpec(), file_offset, module_specs);
98
ModuleSpec matching_module_spec;
102
if (module_specs.GetModuleSpecAtIndex(0, matching_module_spec))
104
if (platform_arch.IsValid())
106
if (!platform_arch.IsCompatibleMatch(matching_module_spec.GetArchitecture()))
108
error.SetErrorStringWithFormat("the specified architecture '%s' is not compatible with '%s' in '%s'",
109
platform_arch.GetTriple().str().c_str(),
110
matching_module_spec.GetArchitecture().GetTriple().str().c_str(),
111
module_spec.GetFileSpec().GetPath().c_str());
117
// Only one arch and none was specified
118
platform_arch = matching_module_spec.GetArchitecture();
126
module_spec.GetArchitecture() = arch;
127
if (module_specs.FindMatchingModuleSpec(module_spec, matching_module_spec))
129
platform_arch = matching_module_spec.GetArchitecture();
132
// Don't just select the first architecture, we want to let the platform select
133
// the best architecture first when there are multiple archs.
136
// // No arch specified, select the first arch
137
// if (module_specs.GetModuleSpecAtIndex(0, matching_module_spec))
139
// platform_arch = matching_module_spec.GetArchitecture();
85
146
CommandInterpreter &interpreter = debugger.GetCommandInterpreter();
86
147
if (platform_options)
157
218
if (!arch.IsValid())
158
219
arch = specified_arch;
160
FileSpec file (user_exe_path, true);
221
FileSpec file (user_exe_path, false);
222
if (!file.Exists() && user_exe_path && user_exe_path[0] == '~')
224
file = FileSpec(user_exe_path, true);
161
226
bool user_exe_path_is_bundle = false;
162
227
char resolved_bundle_exe_path[PATH_MAX];
163
228
resolved_bundle_exe_path[0] = '\0';
202
267
if (arch.IsValid())
204
error.SetErrorStringWithFormat("\"%s%s%s\" doesn't contain architecture %s",
205
file.GetDirectory().AsCString(),
206
file.GetDirectory() ? "/" : "",
207
file.GetFilename().AsCString(),
269
error.SetErrorStringWithFormat("\"%s\" doesn't contain architecture %s",
270
file.GetPath().c_str(),
208
271
arch.GetArchitectureName());
212
error.SetErrorStringWithFormat("unsupported file type \"%s%s%s\"",
213
file.GetDirectory().AsCString(),
214
file.GetDirectory() ? "/" : "",
215
file.GetFilename().AsCString());
275
error.SetErrorStringWithFormat("unsupported file type \"%s\"",
276
file.GetPath().c_str());