~ubuntu-branches/ubuntu/trusty/llvm-toolchain-snapshot/trusty-201310232150

« back to all changes in this revision

Viewing changes to lldb/source/Target/TargetList.cpp

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-27 15:01:57 UTC
  • mfrom: (0.10.1) (0.9.1) (0.8.1) (0.7.1) (0.6.1) (0.5.2)
  • Revision ID: package-import@ubuntu.com-20130527150157-tdkrsjpuvht7v0qx
Tags: 1:3.4~svn182733-1~exp1
* New snapshot release (3.4 release)
* Add a symlink of libLLVM-3.4.so.1 to usr/lib/llvm-3.4/lib/libLLVM-3.4.so
    to fix make the llvm-config-3.4 --libdir work (Closes: #708677)
  * Various packages rename to allow co installations:
    * libclang1 => libclang1-3.4
    * libclang1-dbg => libclang1-3.4-dbg
    * libclang-dev => libclang-3.4-dev
    * libclang-common-dev => libclang-common-3.4-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
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"
80
82
            return error;
81
83
        }
82
84
    }
83
 
 
 
85
    
84
86
    ArchSpec platform_arch(arch);
 
87
 
 
88
    
 
89
    if (user_exe_path && user_exe_path[0])
 
90
    {
 
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);
 
96
        if (num_specs > 0)
 
97
        {
 
98
            ModuleSpec matching_module_spec;
 
99
 
 
100
            if (num_specs == 1)
 
101
            {
 
102
                if (module_specs.GetModuleSpecAtIndex(0, matching_module_spec))
 
103
                {
 
104
                    if (platform_arch.IsValid())
 
105
                    {
 
106
                        if (!platform_arch.IsCompatibleMatch(matching_module_spec.GetArchitecture()))
 
107
                        {
 
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());
 
112
                            return error;
 
113
                        }
 
114
                    }
 
115
                    else
 
116
                    {
 
117
                        // Only one arch and none was specified
 
118
                        platform_arch = matching_module_spec.GetArchitecture();
 
119
                    }
 
120
                }
 
121
            }
 
122
            else
 
123
            {
 
124
                if (arch.IsValid())
 
125
                {
 
126
                    module_spec.GetArchitecture() = arch;
 
127
                    if (module_specs.FindMatchingModuleSpec(module_spec, matching_module_spec))
 
128
                    {
 
129
                        platform_arch = matching_module_spec.GetArchitecture();
 
130
                    }
 
131
                }
 
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.
 
134
//                else
 
135
//                {
 
136
//                    // No arch specified, select the first arch
 
137
//                    if (module_specs.GetModuleSpecAtIndex(0, matching_module_spec))
 
138
//                    {
 
139
//                        platform_arch = matching_module_spec.GetArchitecture();
 
140
//                    }
 
141
//                }
 
142
            }
 
143
        }
 
144
    }
 
145
 
85
146
    CommandInterpreter &interpreter = debugger.GetCommandInterpreter();
86
147
    if (platform_options)
87
148
    {
157
218
    if (!arch.IsValid())
158
219
        arch = specified_arch;
159
220
 
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] == '~')
 
223
    {
 
224
        file = FileSpec(user_exe_path, true);
 
225
    }
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';
201
266
            {
202
267
                if (arch.IsValid())
203
268
                {
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());
209
272
                }
210
273
                else
211
274
                {
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());
216
277
                }
217
278
                return error;
218
279
            }