Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 1 | //===-- Target.cpp ----------------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "lldb/Target/Target.h" |
| 11 | |
| 12 | // C Includes |
| 13 | // C++ Includes |
| 14 | // Other libraries and framework includes |
| 15 | // Project includes |
| 16 | #include "lldb/Breakpoint/BreakpointResolver.h" |
| 17 | #include "lldb/Breakpoint/BreakpointResolverAddress.h" |
| 18 | #include "lldb/Breakpoint/BreakpointResolverFileLine.h" |
| 19 | #include "lldb/Breakpoint/BreakpointResolverName.h" |
| 20 | #include "lldb/Core/Event.h" |
| 21 | #include "lldb/Core/Log.h" |
| 22 | #include "lldb/Core/Timer.h" |
| 23 | #include "lldb/Core/StreamString.h" |
| 24 | #include "lldb/Host/Host.h" |
| 25 | #include "lldb/lldb-private-log.h" |
| 26 | #include "lldb/Symbol/ObjectFile.h" |
| 27 | #include "lldb/Target/Process.h" |
| 28 | #include "lldb/Core/Debugger.h" |
| 29 | |
| 30 | using namespace lldb; |
| 31 | using namespace lldb_private; |
| 32 | |
| 33 | //---------------------------------------------------------------------- |
| 34 | // Target constructor |
| 35 | //---------------------------------------------------------------------- |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 | [diff] [blame] | 36 | Target::Target(Debugger &debugger) : |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 37 | Broadcaster("Target"), |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 38 | TargetInstanceSettings (*(Target::GetSettingsController().get())), |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 | [diff] [blame] | 39 | m_debugger (debugger), |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 40 | m_images(), |
Greg Clayton | f5e56de | 2010-09-14 23:36:40 | [diff] [blame] | 41 | m_section_load_list (), |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 42 | m_breakpoint_list (false), |
| 43 | m_internal_breakpoint_list (true), |
| 44 | m_process_sp(), |
| 45 | m_triple(), |
| 46 | m_search_filter_sp(), |
| 47 | m_image_search_paths (ImageSearchPathsChanged, this), |
| 48 | m_scratch_ast_context_ap(NULL) |
| 49 | { |
| 50 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT); |
| 51 | if (log) |
| 52 | log->Printf ("%p Target::Target()", this); |
| 53 | } |
| 54 | |
| 55 | //---------------------------------------------------------------------- |
| 56 | // Destructor |
| 57 | //---------------------------------------------------------------------- |
| 58 | Target::~Target() |
| 59 | { |
| 60 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT); |
| 61 | if (log) |
| 62 | log->Printf ("%p Target::~Target()", this); |
| 63 | DeleteCurrentProcess (); |
| 64 | } |
| 65 | |
| 66 | void |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 | [diff] [blame^] | 67 | Target::Dump (Stream *s, lldb::DescriptionLevel description_level) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 68 | { |
Greg Clayton | 8941142 | 2010-10-08 00:21:05 | [diff] [blame] | 69 | // s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 | [diff] [blame^] | 70 | if (description_level != lldb::eDescriptionLevelBrief) |
| 71 | { |
| 72 | s->Indent(); |
| 73 | s->PutCString("Target\n"); |
| 74 | s->IndentMore(); |
| 75 | m_images.Dump(s); |
| 76 | m_breakpoint_list.Dump(s); |
| 77 | m_internal_breakpoint_list.Dump(s); |
| 78 | } |
| 79 | else |
| 80 | { |
| 81 | char path[PATH_MAX]; |
| 82 | int path_len = PATH_MAX; |
| 83 | if (GetExecutableModule()->GetFileSpec().GetPath (path, path_len)) |
| 84 | s->Printf ("Target: %s\n", path); |
| 85 | else |
| 86 | s->Printf ("Target: <unknown>\n"); |
| 87 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 88 | // if (m_process_sp.get()) |
| 89 | // m_process_sp->Dump(s); |
| 90 | s->IndentLess(); |
| 91 | } |
| 92 | |
| 93 | void |
| 94 | Target::DeleteCurrentProcess () |
| 95 | { |
| 96 | if (m_process_sp.get()) |
| 97 | { |
Greg Clayton | 17f6920 | 2010-09-14 23:52:43 | [diff] [blame] | 98 | m_section_load_list.Clear(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 99 | if (m_process_sp->IsAlive()) |
| 100 | m_process_sp->Destroy(); |
| 101 | else |
| 102 | m_process_sp->Finalize(); |
| 103 | |
| 104 | // Do any cleanup of the target we need to do between process instances. |
| 105 | // NB It is better to do this before destroying the process in case the |
| 106 | // clean up needs some help from the process. |
| 107 | m_breakpoint_list.ClearAllBreakpointSites(); |
| 108 | m_internal_breakpoint_list.ClearAllBreakpointSites(); |
| 109 | m_process_sp.reset(); |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | const lldb::ProcessSP & |
| 114 | Target::CreateProcess (Listener &listener, const char *plugin_name) |
| 115 | { |
| 116 | DeleteCurrentProcess (); |
| 117 | m_process_sp.reset(Process::FindPlugin(*this, plugin_name, listener)); |
| 118 | return m_process_sp; |
| 119 | } |
| 120 | |
| 121 | const lldb::ProcessSP & |
| 122 | Target::GetProcessSP () const |
| 123 | { |
| 124 | return m_process_sp; |
| 125 | } |
| 126 | |
| 127 | lldb::TargetSP |
| 128 | Target::GetSP() |
| 129 | { |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 | [diff] [blame] | 130 | return m_debugger.GetTargetList().GetTargetSP(this); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | BreakpointList & |
| 134 | Target::GetBreakpointList(bool internal) |
| 135 | { |
| 136 | if (internal) |
| 137 | return m_internal_breakpoint_list; |
| 138 | else |
| 139 | return m_breakpoint_list; |
| 140 | } |
| 141 | |
| 142 | const BreakpointList & |
| 143 | Target::GetBreakpointList(bool internal) const |
| 144 | { |
| 145 | if (internal) |
| 146 | return m_internal_breakpoint_list; |
| 147 | else |
| 148 | return m_breakpoint_list; |
| 149 | } |
| 150 | |
| 151 | BreakpointSP |
| 152 | Target::GetBreakpointByID (break_id_t break_id) |
| 153 | { |
| 154 | BreakpointSP bp_sp; |
| 155 | |
| 156 | if (LLDB_BREAK_ID_IS_INTERNAL (break_id)) |
| 157 | bp_sp = m_internal_breakpoint_list.FindBreakpointByID (break_id); |
| 158 | else |
| 159 | bp_sp = m_breakpoint_list.FindBreakpointByID (break_id); |
| 160 | |
| 161 | return bp_sp; |
| 162 | } |
| 163 | |
| 164 | BreakpointSP |
| 165 | Target::CreateBreakpoint (const FileSpec *containingModule, const FileSpec &file, uint32_t line_no, bool check_inlines, bool internal) |
| 166 | { |
| 167 | SearchFilterSP filter_sp(GetSearchFilterForModule (containingModule)); |
| 168 | BreakpointResolverSP resolver_sp(new BreakpointResolverFileLine (NULL, file, line_no, check_inlines)); |
| 169 | return CreateBreakpoint (filter_sp, resolver_sp, internal); |
| 170 | } |
| 171 | |
| 172 | |
| 173 | BreakpointSP |
Greg Clayton | 1b72fcb | 2010-08-24 00:45:41 | [diff] [blame] | 174 | Target::CreateBreakpoint (lldb::addr_t addr, bool internal) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 175 | { |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 176 | Address so_addr; |
| 177 | // Attempt to resolve our load address if possible, though it is ok if |
| 178 | // it doesn't resolve to section/offset. |
| 179 | |
Greg Clayton | 1b72fcb | 2010-08-24 00:45:41 | [diff] [blame] | 180 | // Try and resolve as a load address if possible |
Greg Clayton | f5e56de | 2010-09-14 23:36:40 | [diff] [blame] | 181 | m_section_load_list.ResolveLoadAddress(addr, so_addr); |
Greg Clayton | 1b72fcb | 2010-08-24 00:45:41 | [diff] [blame] | 182 | if (!so_addr.IsValid()) |
| 183 | { |
| 184 | // The address didn't resolve, so just set this as an absolute address |
| 185 | so_addr.SetOffset (addr); |
| 186 | } |
| 187 | BreakpointSP bp_sp (CreateBreakpoint(so_addr, internal)); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 188 | return bp_sp; |
| 189 | } |
| 190 | |
| 191 | BreakpointSP |
| 192 | Target::CreateBreakpoint (Address &addr, bool internal) |
| 193 | { |
| 194 | TargetSP target_sp = this->GetSP(); |
| 195 | SearchFilterSP filter_sp(new SearchFilter (target_sp)); |
| 196 | BreakpointResolverSP resolver_sp (new BreakpointResolverAddress (NULL, addr)); |
| 197 | return CreateBreakpoint (filter_sp, resolver_sp, internal); |
| 198 | } |
| 199 | |
| 200 | BreakpointSP |
Greg Clayton | 0c5cd90 | 2010-06-28 21:30:43 | [diff] [blame] | 201 | Target::CreateBreakpoint (FileSpec *containingModule, const char *func_name, uint32_t func_name_type_mask, bool internal) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 202 | { |
Greg Clayton | 0c5cd90 | 2010-06-28 21:30:43 | [diff] [blame] | 203 | BreakpointSP bp_sp; |
| 204 | if (func_name) |
| 205 | { |
| 206 | SearchFilterSP filter_sp(GetSearchFilterForModule (containingModule)); |
| 207 | BreakpointResolverSP resolver_sp (new BreakpointResolverName (NULL, func_name, func_name_type_mask, Breakpoint::Exact)); |
| 208 | bp_sp = CreateBreakpoint (filter_sp, resolver_sp, internal); |
| 209 | } |
| 210 | return bp_sp; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | |
| 214 | SearchFilterSP |
| 215 | Target::GetSearchFilterForModule (const FileSpec *containingModule) |
| 216 | { |
| 217 | SearchFilterSP filter_sp; |
| 218 | lldb::TargetSP target_sp = this->GetSP(); |
| 219 | if (containingModule != NULL) |
| 220 | { |
| 221 | // TODO: We should look into sharing module based search filters |
| 222 | // across many breakpoints like we do for the simple target based one |
| 223 | filter_sp.reset (new SearchFilterByModule (target_sp, *containingModule)); |
| 224 | } |
| 225 | else |
| 226 | { |
| 227 | if (m_search_filter_sp.get() == NULL) |
| 228 | m_search_filter_sp.reset (new SearchFilter (target_sp)); |
| 229 | filter_sp = m_search_filter_sp; |
| 230 | } |
| 231 | return filter_sp; |
| 232 | } |
| 233 | |
| 234 | BreakpointSP |
| 235 | Target::CreateBreakpoint (FileSpec *containingModule, RegularExpression &func_regex, bool internal) |
| 236 | { |
| 237 | SearchFilterSP filter_sp(GetSearchFilterForModule (containingModule)); |
| 238 | BreakpointResolverSP resolver_sp(new BreakpointResolverName (NULL, func_regex)); |
| 239 | |
| 240 | return CreateBreakpoint (filter_sp, resolver_sp, internal); |
| 241 | } |
| 242 | |
| 243 | BreakpointSP |
| 244 | Target::CreateBreakpoint (SearchFilterSP &filter_sp, BreakpointResolverSP &resolver_sp, bool internal) |
| 245 | { |
| 246 | BreakpointSP bp_sp; |
| 247 | if (filter_sp && resolver_sp) |
| 248 | { |
| 249 | bp_sp.reset(new Breakpoint (*this, filter_sp, resolver_sp)); |
| 250 | resolver_sp->SetBreakpoint (bp_sp.get()); |
| 251 | |
| 252 | if (internal) |
Greg Clayton | 9fed0d8 | 2010-07-23 23:33:17 | [diff] [blame] | 253 | m_internal_breakpoint_list.Add (bp_sp, false); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 254 | else |
Greg Clayton | 9fed0d8 | 2010-07-23 23:33:17 | [diff] [blame] | 255 | m_breakpoint_list.Add (bp_sp, true); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 256 | |
| 257 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS); |
| 258 | if (log) |
| 259 | { |
| 260 | StreamString s; |
| 261 | bp_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose); |
| 262 | log->Printf ("Target::%s (internal = %s) => break_id = %s\n", __FUNCTION__, internal ? "yes" : "no", s.GetData()); |
| 263 | } |
| 264 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 265 | bp_sp->ResolveBreakpoint(); |
| 266 | } |
Jim Ingham | 36f3b36 | 2010-10-14 23:45:03 | [diff] [blame] | 267 | |
| 268 | if (!internal && bp_sp) |
| 269 | { |
| 270 | m_last_created_breakpoint = bp_sp; |
| 271 | } |
| 272 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 273 | return bp_sp; |
| 274 | } |
| 275 | |
| 276 | void |
| 277 | Target::RemoveAllBreakpoints (bool internal_also) |
| 278 | { |
| 279 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS); |
| 280 | if (log) |
| 281 | log->Printf ("Target::%s (internal_also = %s)\n", __FUNCTION__, internal_also ? "yes" : "no"); |
| 282 | |
Greg Clayton | 9fed0d8 | 2010-07-23 23:33:17 | [diff] [blame] | 283 | m_breakpoint_list.RemoveAll (true); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 284 | if (internal_also) |
Greg Clayton | 9fed0d8 | 2010-07-23 23:33:17 | [diff] [blame] | 285 | m_internal_breakpoint_list.RemoveAll (false); |
Jim Ingham | 36f3b36 | 2010-10-14 23:45:03 | [diff] [blame] | 286 | |
| 287 | m_last_created_breakpoint.reset(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | void |
| 291 | Target::DisableAllBreakpoints (bool internal_also) |
| 292 | { |
| 293 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS); |
| 294 | if (log) |
| 295 | log->Printf ("Target::%s (internal_also = %s)\n", __FUNCTION__, internal_also ? "yes" : "no"); |
| 296 | |
| 297 | m_breakpoint_list.SetEnabledAll (false); |
| 298 | if (internal_also) |
| 299 | m_internal_breakpoint_list.SetEnabledAll (false); |
| 300 | } |
| 301 | |
| 302 | void |
| 303 | Target::EnableAllBreakpoints (bool internal_also) |
| 304 | { |
| 305 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS); |
| 306 | if (log) |
| 307 | log->Printf ("Target::%s (internal_also = %s)\n", __FUNCTION__, internal_also ? "yes" : "no"); |
| 308 | |
| 309 | m_breakpoint_list.SetEnabledAll (true); |
| 310 | if (internal_also) |
| 311 | m_internal_breakpoint_list.SetEnabledAll (true); |
| 312 | } |
| 313 | |
| 314 | bool |
| 315 | Target::RemoveBreakpointByID (break_id_t break_id) |
| 316 | { |
| 317 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS); |
| 318 | if (log) |
| 319 | log->Printf ("Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__, break_id, LLDB_BREAK_ID_IS_INTERNAL (break_id) ? "yes" : "no"); |
| 320 | |
| 321 | if (DisableBreakpointByID (break_id)) |
| 322 | { |
| 323 | if (LLDB_BREAK_ID_IS_INTERNAL (break_id)) |
Greg Clayton | 9fed0d8 | 2010-07-23 23:33:17 | [diff] [blame] | 324 | m_internal_breakpoint_list.Remove(break_id, false); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 325 | else |
Jim Ingham | 36f3b36 | 2010-10-14 23:45:03 | [diff] [blame] | 326 | { |
| 327 | if (m_last_created_breakpoint->GetID() == break_id) |
| 328 | m_last_created_breakpoint.reset(); |
Greg Clayton | 9fed0d8 | 2010-07-23 23:33:17 | [diff] [blame] | 329 | m_breakpoint_list.Remove(break_id, true); |
Jim Ingham | 36f3b36 | 2010-10-14 23:45:03 | [diff] [blame] | 330 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 331 | return true; |
| 332 | } |
| 333 | return false; |
| 334 | } |
| 335 | |
| 336 | bool |
| 337 | Target::DisableBreakpointByID (break_id_t break_id) |
| 338 | { |
| 339 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS); |
| 340 | if (log) |
| 341 | log->Printf ("Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__, break_id, LLDB_BREAK_ID_IS_INTERNAL (break_id) ? "yes" : "no"); |
| 342 | |
| 343 | BreakpointSP bp_sp; |
| 344 | |
| 345 | if (LLDB_BREAK_ID_IS_INTERNAL (break_id)) |
| 346 | bp_sp = m_internal_breakpoint_list.FindBreakpointByID (break_id); |
| 347 | else |
| 348 | bp_sp = m_breakpoint_list.FindBreakpointByID (break_id); |
| 349 | if (bp_sp) |
| 350 | { |
| 351 | bp_sp->SetEnabled (false); |
| 352 | return true; |
| 353 | } |
| 354 | return false; |
| 355 | } |
| 356 | |
| 357 | bool |
| 358 | Target::EnableBreakpointByID (break_id_t break_id) |
| 359 | { |
| 360 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS); |
| 361 | if (log) |
| 362 | log->Printf ("Target::%s (break_id = %i, internal = %s)\n", |
| 363 | __FUNCTION__, |
| 364 | break_id, |
| 365 | LLDB_BREAK_ID_IS_INTERNAL (break_id) ? "yes" : "no"); |
| 366 | |
| 367 | BreakpointSP bp_sp; |
| 368 | |
| 369 | if (LLDB_BREAK_ID_IS_INTERNAL (break_id)) |
| 370 | bp_sp = m_internal_breakpoint_list.FindBreakpointByID (break_id); |
| 371 | else |
| 372 | bp_sp = m_breakpoint_list.FindBreakpointByID (break_id); |
| 373 | |
| 374 | if (bp_sp) |
| 375 | { |
| 376 | bp_sp->SetEnabled (true); |
| 377 | return true; |
| 378 | } |
| 379 | return false; |
| 380 | } |
| 381 | |
| 382 | ModuleSP |
| 383 | Target::GetExecutableModule () |
| 384 | { |
| 385 | ModuleSP executable_sp; |
| 386 | if (m_images.GetSize() > 0) |
| 387 | executable_sp = m_images.GetModuleAtIndex(0); |
| 388 | return executable_sp; |
| 389 | } |
| 390 | |
| 391 | void |
| 392 | Target::SetExecutableModule (ModuleSP& executable_sp, bool get_dependent_files) |
| 393 | { |
| 394 | m_images.Clear(); |
| 395 | m_scratch_ast_context_ap.reset(); |
| 396 | |
| 397 | if (executable_sp.get()) |
| 398 | { |
| 399 | Timer scoped_timer (__PRETTY_FUNCTION__, |
| 400 | "Target::SetExecutableModule (executable = '%s/%s')", |
| 401 | executable_sp->GetFileSpec().GetDirectory().AsCString(), |
| 402 | executable_sp->GetFileSpec().GetFilename().AsCString()); |
| 403 | |
| 404 | m_images.Append(executable_sp); // The first image is our exectuable file |
| 405 | |
| 406 | ArchSpec exe_arch = executable_sp->GetArchitecture(); |
Jim Ingham | 5aee162 | 2010-08-09 23:31:02 | [diff] [blame] | 407 | // If we haven't set an architecture yet, reset our architecture based on what we found in the executable module. |
| 408 | if (!m_arch_spec.IsValid()) |
| 409 | m_arch_spec = exe_arch; |
| 410 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 411 | FileSpecList dependent_files; |
| 412 | ObjectFile * executable_objfile = executable_sp->GetObjectFile(); |
| 413 | if (executable_objfile == NULL) |
| 414 | { |
| 415 | |
| 416 | FileSpec bundle_executable(executable_sp->GetFileSpec()); |
Greg Clayton | dd36def | 2010-10-17 22:03:32 | [diff] [blame] | 417 | if (Host::ResolveExecutableInBundle (bundle_executable)) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 418 | { |
| 419 | ModuleSP bundle_exe_module_sp(GetSharedModule(bundle_executable, |
| 420 | exe_arch)); |
| 421 | SetExecutableModule (bundle_exe_module_sp, get_dependent_files); |
| 422 | if (bundle_exe_module_sp->GetObjectFile() != NULL) |
| 423 | executable_sp = bundle_exe_module_sp; |
| 424 | return; |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | if (executable_objfile) |
| 429 | { |
| 430 | executable_objfile->GetDependentModules(dependent_files); |
| 431 | for (uint32_t i=0; i<dependent_files.GetSize(); i++) |
| 432 | { |
| 433 | ModuleSP image_module_sp(GetSharedModule(dependent_files.GetFileSpecPointerAtIndex(i), |
| 434 | exe_arch)); |
| 435 | if (image_module_sp.get()) |
| 436 | { |
| 437 | //image_module_sp->Dump(&s);// REMOVE THIS, DEBUG ONLY |
| 438 | ObjectFile *objfile = image_module_sp->GetObjectFile(); |
| 439 | if (objfile) |
| 440 | objfile->GetDependentModules(dependent_files); |
| 441 | } |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | // Now see if we know the target triple, and if so, create our scratch AST context: |
| 446 | ConstString target_triple; |
| 447 | if (GetTargetTriple(target_triple)) |
| 448 | { |
| 449 | m_scratch_ast_context_ap.reset (new ClangASTContext(target_triple.GetCString())); |
| 450 | } |
| 451 | } |
Caroline Tice | 1559a46 | 2010-09-27 00:30:10 | [diff] [blame] | 452 | |
| 453 | UpdateInstanceName(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 454 | } |
| 455 | |
| 456 | |
| 457 | ModuleList& |
| 458 | Target::GetImages () |
| 459 | { |
| 460 | return m_images; |
| 461 | } |
| 462 | |
| 463 | ArchSpec |
| 464 | Target::GetArchitecture () const |
| 465 | { |
Jim Ingham | 5aee162 | 2010-08-09 23:31:02 | [diff] [blame] | 466 | return m_arch_spec; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 467 | } |
| 468 | |
Jim Ingham | 5aee162 | 2010-08-09 23:31:02 | [diff] [blame] | 469 | bool |
| 470 | Target::SetArchitecture (const ArchSpec &arch_spec) |
| 471 | { |
| 472 | if (m_arch_spec == arch_spec) |
| 473 | { |
| 474 | // If we're setting the architecture to our current architecture, we |
| 475 | // don't need to do anything. |
| 476 | return true; |
| 477 | } |
| 478 | else if (!m_arch_spec.IsValid()) |
| 479 | { |
| 480 | // If we haven't got a valid arch spec, then we just need to set it. |
| 481 | m_arch_spec = arch_spec; |
| 482 | return true; |
| 483 | } |
| 484 | else |
| 485 | { |
| 486 | // If we have an executable file, try to reset the executable to the desired architecture |
| 487 | m_arch_spec = arch_spec; |
| 488 | ModuleSP executable_sp = GetExecutableModule (); |
| 489 | m_images.Clear(); |
| 490 | m_scratch_ast_context_ap.reset(); |
| 491 | m_triple.Clear(); |
| 492 | // Need to do something about unsetting breakpoints. |
| 493 | |
| 494 | if (executable_sp) |
| 495 | { |
| 496 | FileSpec exec_file_spec = executable_sp->GetFileSpec(); |
| 497 | Error error = ModuleList::GetSharedModule(exec_file_spec, |
| 498 | arch_spec, |
| 499 | NULL, |
| 500 | NULL, |
| 501 | 0, |
| 502 | executable_sp, |
| 503 | NULL, |
| 504 | NULL); |
| 505 | |
| 506 | if (!error.Fail() && executable_sp) |
| 507 | { |
| 508 | SetExecutableModule (executable_sp, true); |
| 509 | return true; |
| 510 | } |
| 511 | else |
| 512 | { |
| 513 | return false; |
| 514 | } |
| 515 | } |
| 516 | else |
| 517 | { |
| 518 | return false; |
| 519 | } |
| 520 | } |
| 521 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 522 | |
| 523 | bool |
| 524 | Target::GetTargetTriple(ConstString &triple) |
| 525 | { |
| 526 | triple.Clear(); |
| 527 | |
| 528 | if (m_triple) |
| 529 | { |
| 530 | triple = m_triple; |
| 531 | } |
| 532 | else |
| 533 | { |
| 534 | Module *exe_module = GetExecutableModule().get(); |
| 535 | if (exe_module) |
| 536 | { |
| 537 | ObjectFile *objfile = exe_module->GetObjectFile(); |
| 538 | if (objfile) |
| 539 | { |
| 540 | objfile->GetTargetTriple(m_triple); |
| 541 | triple = m_triple; |
| 542 | } |
| 543 | } |
| 544 | } |
| 545 | return !triple.IsEmpty(); |
| 546 | } |
| 547 | |
| 548 | void |
| 549 | Target::ModuleAdded (ModuleSP &module_sp) |
| 550 | { |
| 551 | // A module is being added to this target for the first time |
| 552 | ModuleList module_list; |
| 553 | module_list.Append(module_sp); |
| 554 | ModulesDidLoad (module_list); |
| 555 | } |
| 556 | |
| 557 | void |
| 558 | Target::ModuleUpdated (ModuleSP &old_module_sp, ModuleSP &new_module_sp) |
| 559 | { |
| 560 | // A module is being added to this target for the first time |
| 561 | ModuleList module_list; |
| 562 | module_list.Append (old_module_sp); |
| 563 | ModulesDidUnload (module_list); |
| 564 | module_list.Clear (); |
| 565 | module_list.Append (new_module_sp); |
| 566 | ModulesDidLoad (module_list); |
| 567 | } |
| 568 | |
| 569 | void |
| 570 | Target::ModulesDidLoad (ModuleList &module_list) |
| 571 | { |
| 572 | m_breakpoint_list.UpdateBreakpoints (module_list, true); |
| 573 | // TODO: make event data that packages up the module_list |
| 574 | BroadcastEvent (eBroadcastBitModulesLoaded, NULL); |
| 575 | } |
| 576 | |
| 577 | void |
| 578 | Target::ModulesDidUnload (ModuleList &module_list) |
| 579 | { |
| 580 | m_breakpoint_list.UpdateBreakpoints (module_list, false); |
| 581 | // TODO: make event data that packages up the module_list |
| 582 | BroadcastEvent (eBroadcastBitModulesUnloaded, NULL); |
| 583 | } |
| 584 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 585 | size_t |
Greg Clayton | 35f3dd2 | 2010-06-30 23:04:24 | [diff] [blame] | 586 | Target::ReadMemory (const Address& addr, void *dst, size_t dst_len, Error &error) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 587 | { |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 588 | error.Clear(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 589 | |
Greg Clayton | dda4f7b | 2010-06-30 23:03:03 | [diff] [blame] | 590 | bool process_is_valid = m_process_sp && m_process_sp->IsAlive(); |
| 591 | |
| 592 | Address resolved_addr(addr); |
| 593 | if (!resolved_addr.IsSectionOffset()) |
| 594 | { |
| 595 | if (process_is_valid) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 596 | { |
Greg Clayton | f5e56de | 2010-09-14 23:36:40 | [diff] [blame] | 597 | m_section_load_list.ResolveLoadAddress (addr.GetOffset(), resolved_addr); |
Greg Clayton | dda4f7b | 2010-06-30 23:03:03 | [diff] [blame] | 598 | } |
| 599 | else |
| 600 | { |
| 601 | m_images.ResolveFileAddress(addr.GetOffset(), resolved_addr); |
| 602 | } |
| 603 | } |
| 604 | |
| 605 | |
| 606 | if (process_is_valid) |
| 607 | { |
Greg Clayton | f5e56de | 2010-09-14 23:36:40 | [diff] [blame] | 608 | lldb::addr_t load_addr = resolved_addr.GetLoadAddress (this); |
Greg Clayton | dda4f7b | 2010-06-30 23:03:03 | [diff] [blame] | 609 | if (load_addr == LLDB_INVALID_ADDRESS) |
| 610 | { |
| 611 | if (resolved_addr.GetModule() && resolved_addr.GetModule()->GetFileSpec()) |
| 612 | error.SetErrorStringWithFormat("%s[0x%llx] can't be resolved, %s in not currently loaded.\n", |
| 613 | resolved_addr.GetModule()->GetFileSpec().GetFilename().AsCString(), |
| 614 | resolved_addr.GetFileAddress()); |
| 615 | else |
| 616 | error.SetErrorStringWithFormat("0x%llx can't be resolved.\n", resolved_addr.GetFileAddress()); |
| 617 | } |
| 618 | else |
| 619 | { |
| 620 | size_t bytes_read = m_process_sp->ReadMemory(load_addr, dst, dst_len, error); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 621 | if (bytes_read != dst_len) |
| 622 | { |
| 623 | if (error.Success()) |
| 624 | { |
| 625 | if (bytes_read == 0) |
Greg Clayton | dda4f7b | 2010-06-30 23:03:03 | [diff] [blame] | 626 | error.SetErrorStringWithFormat("Read memory from 0x%llx failed.\n", load_addr); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 627 | else |
Greg Clayton | dda4f7b | 2010-06-30 23:03:03 | [diff] [blame] | 628 | error.SetErrorStringWithFormat("Only %zu of %zu bytes were read from memory at 0x%llx.\n", bytes_read, dst_len, load_addr); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 629 | } |
| 630 | } |
Greg Clayton | dda4f7b | 2010-06-30 23:03:03 | [diff] [blame] | 631 | if (bytes_read) |
| 632 | return bytes_read; |
| 633 | // If the address is not section offset we have an address that |
| 634 | // doesn't resolve to any address in any currently loaded shared |
| 635 | // libaries and we failed to read memory so there isn't anything |
| 636 | // more we can do. If it is section offset, we might be able to |
| 637 | // read cached memory from the object file. |
| 638 | if (!resolved_addr.IsSectionOffset()) |
| 639 | return 0; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 640 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 641 | } |
Greg Clayton | dda4f7b | 2010-06-30 23:03:03 | [diff] [blame] | 642 | |
| 643 | const Section *section = resolved_addr.GetSection(); |
| 644 | if (section && section->GetModule()) |
| 645 | { |
| 646 | ObjectFile *objfile = section->GetModule()->GetObjectFile(); |
| 647 | return section->ReadSectionDataFromObjectFile (objfile, |
| 648 | resolved_addr.GetOffset(), |
| 649 | dst, |
| 650 | dst_len); |
| 651 | } |
| 652 | return 0; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 653 | } |
| 654 | |
| 655 | |
| 656 | ModuleSP |
| 657 | Target::GetSharedModule |
| 658 | ( |
| 659 | const FileSpec& file_spec, |
| 660 | const ArchSpec& arch, |
| 661 | const UUID *uuid_ptr, |
| 662 | const ConstString *object_name, |
| 663 | off_t object_offset, |
| 664 | Error *error_ptr |
| 665 | ) |
| 666 | { |
| 667 | // Don't pass in the UUID so we can tell if we have a stale value in our list |
| 668 | ModuleSP old_module_sp; // This will get filled in if we have a new version of the library |
| 669 | bool did_create_module = false; |
| 670 | ModuleSP module_sp; |
| 671 | |
| 672 | // If there are image search path entries, try to use them first to acquire a suitable image. |
| 673 | |
| 674 | Error error; |
| 675 | |
| 676 | if (m_image_search_paths.GetSize()) |
| 677 | { |
| 678 | FileSpec transformed_spec; |
| 679 | if (m_image_search_paths.RemapPath (file_spec.GetDirectory(), transformed_spec.GetDirectory())) |
| 680 | { |
| 681 | transformed_spec.GetFilename() = file_spec.GetFilename(); |
| 682 | error = ModuleList::GetSharedModule (transformed_spec, arch, uuid_ptr, object_name, object_offset, module_sp, &old_module_sp, &did_create_module); |
| 683 | } |
| 684 | } |
| 685 | |
| 686 | // If a module hasn't been found yet, use the unmodified path. |
| 687 | |
| 688 | if (!module_sp) |
| 689 | { |
| 690 | error = (ModuleList::GetSharedModule (file_spec, arch, uuid_ptr, object_name, object_offset, module_sp, &old_module_sp, &did_create_module)); |
| 691 | } |
| 692 | |
| 693 | if (module_sp) |
| 694 | { |
| 695 | m_images.Append (module_sp); |
| 696 | if (did_create_module) |
| 697 | { |
| 698 | if (old_module_sp && m_images.GetIndexForModule (old_module_sp.get()) != LLDB_INVALID_INDEX32) |
| 699 | ModuleUpdated(old_module_sp, module_sp); |
| 700 | else |
| 701 | ModuleAdded(module_sp); |
| 702 | } |
| 703 | } |
| 704 | if (error_ptr) |
| 705 | *error_ptr = error; |
| 706 | return module_sp; |
| 707 | } |
| 708 | |
| 709 | |
| 710 | Target * |
| 711 | Target::CalculateTarget () |
| 712 | { |
| 713 | return this; |
| 714 | } |
| 715 | |
| 716 | Process * |
| 717 | Target::CalculateProcess () |
| 718 | { |
| 719 | return NULL; |
| 720 | } |
| 721 | |
| 722 | Thread * |
| 723 | Target::CalculateThread () |
| 724 | { |
| 725 | return NULL; |
| 726 | } |
| 727 | |
| 728 | StackFrame * |
| 729 | Target::CalculateStackFrame () |
| 730 | { |
| 731 | return NULL; |
| 732 | } |
| 733 | |
| 734 | void |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 | [diff] [blame] | 735 | Target::CalculateExecutionContext (ExecutionContext &exe_ctx) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 736 | { |
| 737 | exe_ctx.target = this; |
| 738 | exe_ctx.process = NULL; // Do NOT fill in process... |
| 739 | exe_ctx.thread = NULL; |
| 740 | exe_ctx.frame = NULL; |
| 741 | } |
| 742 | |
| 743 | PathMappingList & |
| 744 | Target::GetImageSearchPathList () |
| 745 | { |
| 746 | return m_image_search_paths; |
| 747 | } |
| 748 | |
| 749 | void |
| 750 | Target::ImageSearchPathsChanged |
| 751 | ( |
| 752 | const PathMappingList &path_list, |
| 753 | void *baton |
| 754 | ) |
| 755 | { |
| 756 | Target *target = (Target *)baton; |
| 757 | if (target->m_images.GetSize() > 1) |
| 758 | { |
| 759 | ModuleSP exe_module_sp (target->GetExecutableModule()); |
| 760 | if (exe_module_sp) |
| 761 | { |
| 762 | target->m_images.Clear(); |
| 763 | target->SetExecutableModule (exe_module_sp, true); |
| 764 | } |
| 765 | } |
| 766 | } |
| 767 | |
| 768 | ClangASTContext * |
| 769 | Target::GetScratchClangASTContext() |
| 770 | { |
| 771 | return m_scratch_ast_context_ap.get(); |
| 772 | } |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 773 | |
| 774 | lldb::UserSettingsControllerSP |
| 775 | Target::GetSettingsController (bool finish) |
| 776 | { |
| 777 | static lldb::UserSettingsControllerSP g_settings_controller (new SettingsController); |
| 778 | static bool initialized = false; |
| 779 | |
| 780 | if (!initialized) |
| 781 | { |
| 782 | initialized = UserSettingsController::InitializeSettingsController (g_settings_controller, |
| 783 | Target::SettingsController::global_settings_table, |
| 784 | Target::SettingsController::instance_settings_table); |
| 785 | } |
| 786 | |
| 787 | if (finish) |
| 788 | { |
| 789 | UserSettingsController::FinalizeSettingsController (g_settings_controller); |
| 790 | g_settings_controller.reset(); |
| 791 | initialized = false; |
| 792 | } |
| 793 | |
| 794 | return g_settings_controller; |
| 795 | } |
| 796 | |
| 797 | ArchSpec |
| 798 | Target::GetDefaultArchitecture () |
| 799 | { |
| 800 | lldb::UserSettingsControllerSP settings_controller = Target::GetSettingsController(); |
| 801 | lldb::SettableVariableType var_type; |
| 802 | Error err; |
| 803 | StringList result = settings_controller->GetVariable ("target.default-arch", var_type, "[]", err); |
| 804 | |
| 805 | const char *default_name = ""; |
| 806 | if (result.GetSize() == 1 && err.Success()) |
| 807 | default_name = result.GetStringAtIndex (0); |
| 808 | |
| 809 | ArchSpec default_arch (default_name); |
| 810 | return default_arch; |
| 811 | } |
| 812 | |
| 813 | void |
| 814 | Target::SetDefaultArchitecture (ArchSpec new_arch) |
| 815 | { |
| 816 | if (new_arch.IsValid()) |
| 817 | Target::GetSettingsController ()->SetVariable ("target.default-arch", new_arch.AsCString(), |
| 818 | lldb::eVarSetOperationAssign, false, "[]"); |
| 819 | } |
| 820 | |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 | [diff] [blame] | 821 | Target * |
| 822 | Target::GetTargetFromContexts (const ExecutionContext *exe_ctx_ptr, const SymbolContext *sc_ptr) |
| 823 | { |
| 824 | // The target can either exist in the "process" of ExecutionContext, or in |
| 825 | // the "target_sp" member of SymbolContext. This accessor helper function |
| 826 | // will get the target from one of these locations. |
| 827 | |
| 828 | Target *target = NULL; |
| 829 | if (sc_ptr != NULL) |
| 830 | target = sc_ptr->target_sp.get(); |
| 831 | if (target == NULL) |
| 832 | { |
| 833 | if (exe_ctx_ptr != NULL && exe_ctx_ptr->process != NULL) |
| 834 | target = &exe_ctx_ptr->process->GetTarget(); |
| 835 | } |
| 836 | return target; |
| 837 | } |
| 838 | |
| 839 | |
Caroline Tice | 1559a46 | 2010-09-27 00:30:10 | [diff] [blame] | 840 | void |
| 841 | Target::UpdateInstanceName () |
| 842 | { |
| 843 | StreamString sstr; |
| 844 | |
| 845 | ModuleSP module_sp = GetExecutableModule(); |
| 846 | if (module_sp) |
| 847 | { |
| 848 | sstr.Printf ("%s_%s", module_sp->GetFileSpec().GetFilename().AsCString(), |
| 849 | module_sp->GetArchitecture().AsCString()); |
| 850 | Target::GetSettingsController()->RenameInstanceSettings (GetInstanceName().AsCString(), |
| 851 | sstr.GetData()); |
| 852 | } |
| 853 | } |
| 854 | |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 855 | //-------------------------------------------------------------- |
| 856 | // class Target::SettingsController |
| 857 | //-------------------------------------------------------------- |
| 858 | |
| 859 | Target::SettingsController::SettingsController () : |
| 860 | UserSettingsController ("target", Debugger::GetSettingsController()), |
| 861 | m_default_architecture () |
| 862 | { |
| 863 | m_default_settings.reset (new TargetInstanceSettings (*this, false, |
| 864 | InstanceSettings::GetDefaultName().AsCString())); |
| 865 | } |
| 866 | |
| 867 | Target::SettingsController::~SettingsController () |
| 868 | { |
| 869 | } |
| 870 | |
| 871 | lldb::InstanceSettingsSP |
| 872 | Target::SettingsController::CreateInstanceSettings (const char *instance_name) |
| 873 | { |
| 874 | TargetInstanceSettings *new_settings = new TargetInstanceSettings (*(Target::GetSettingsController().get()), |
| 875 | false, instance_name); |
| 876 | lldb::InstanceSettingsSP new_settings_sp (new_settings); |
| 877 | return new_settings_sp; |
| 878 | } |
| 879 | |
| 880 | const ConstString & |
| 881 | Target::SettingsController::DefArchVarName () |
| 882 | { |
| 883 | static ConstString def_arch_var_name ("default-arch"); |
| 884 | |
| 885 | return def_arch_var_name; |
| 886 | } |
| 887 | |
| 888 | bool |
| 889 | Target::SettingsController::SetGlobalVariable (const ConstString &var_name, |
| 890 | const char *index_value, |
| 891 | const char *value, |
| 892 | const SettingEntry &entry, |
| 893 | const lldb::VarSetOperationType op, |
| 894 | Error&err) |
| 895 | { |
| 896 | if (var_name == DefArchVarName()) |
| 897 | { |
| 898 | ArchSpec tmp_spec (value); |
| 899 | if (tmp_spec.IsValid()) |
| 900 | m_default_architecture = tmp_spec; |
| 901 | else |
| 902 | err.SetErrorStringWithFormat ("'%s' is not a valid architecture.", value); |
| 903 | } |
| 904 | return true; |
| 905 | } |
| 906 | |
| 907 | |
| 908 | bool |
| 909 | Target::SettingsController::GetGlobalVariable (const ConstString &var_name, |
| 910 | StringList &value, |
| 911 | Error &err) |
| 912 | { |
| 913 | if (var_name == DefArchVarName()) |
| 914 | { |
| 915 | value.AppendString (m_default_architecture.AsCString()); |
| 916 | return true; |
| 917 | } |
| 918 | else |
| 919 | err.SetErrorStringWithFormat ("unrecognized variable name '%s'", var_name.AsCString()); |
| 920 | |
| 921 | return false; |
| 922 | } |
| 923 | |
| 924 | //-------------------------------------------------------------- |
| 925 | // class TargetInstanceSettings |
| 926 | //-------------------------------------------------------------- |
| 927 | |
| 928 | TargetInstanceSettings::TargetInstanceSettings (UserSettingsController &owner, bool live_instance, |
| 929 | const char *name) : |
| 930 | InstanceSettings (owner, (name == NULL ? InstanceSettings::InvalidName().AsCString() : name), live_instance) |
| 931 | { |
| 932 | // CopyInstanceSettings is a pure virtual function in InstanceSettings; it therefore cannot be called |
| 933 | // until the vtables for TargetInstanceSettings are properly set up, i.e. AFTER all the initializers. |
| 934 | // For this reason it has to be called here, rather than in the initializer or in the parent constructor. |
| 935 | // This is true for CreateInstanceName() too. |
| 936 | |
| 937 | if (GetInstanceName () == InstanceSettings::InvalidName()) |
| 938 | { |
| 939 | ChangeInstanceName (std::string (CreateInstanceName().AsCString())); |
| 940 | m_owner.RegisterInstanceSettings (this); |
| 941 | } |
| 942 | |
| 943 | if (live_instance) |
| 944 | { |
| 945 | const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name); |
| 946 | CopyInstanceSettings (pending_settings,false); |
| 947 | //m_owner.RemovePendingSettings (m_instance_name); |
| 948 | } |
| 949 | } |
| 950 | |
| 951 | TargetInstanceSettings::TargetInstanceSettings (const TargetInstanceSettings &rhs) : |
| 952 | InstanceSettings (*(Target::GetSettingsController().get()), CreateInstanceName().AsCString()) |
| 953 | { |
| 954 | if (m_instance_name != InstanceSettings::GetDefaultName()) |
| 955 | { |
| 956 | const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name); |
| 957 | CopyInstanceSettings (pending_settings,false); |
| 958 | //m_owner.RemovePendingSettings (m_instance_name); |
| 959 | } |
| 960 | } |
| 961 | |
| 962 | TargetInstanceSettings::~TargetInstanceSettings () |
| 963 | { |
| 964 | } |
| 965 | |
| 966 | TargetInstanceSettings& |
| 967 | TargetInstanceSettings::operator= (const TargetInstanceSettings &rhs) |
| 968 | { |
| 969 | if (this != &rhs) |
| 970 | { |
| 971 | } |
| 972 | |
| 973 | return *this; |
| 974 | } |
| 975 | |
| 976 | |
| 977 | void |
| 978 | TargetInstanceSettings::UpdateInstanceSettingsVariable (const ConstString &var_name, |
| 979 | const char *index_value, |
| 980 | const char *value, |
| 981 | const ConstString &instance_name, |
| 982 | const SettingEntry &entry, |
| 983 | lldb::VarSetOperationType op, |
| 984 | Error &err, |
| 985 | bool pending) |
| 986 | { |
| 987 | // Currently 'target' does not have any instance settings. |
| 988 | } |
| 989 | |
| 990 | void |
| 991 | TargetInstanceSettings::CopyInstanceSettings (const lldb::InstanceSettingsSP &new_settings, |
| 992 | bool pending) |
| 993 | { |
| 994 | // Currently 'target' does not have any instance settings. |
| 995 | } |
| 996 | |
Caroline Tice | 12cecd7 | 2010-09-20 21:37:42 | [diff] [blame] | 997 | bool |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 998 | TargetInstanceSettings::GetInstanceSettingsValue (const SettingEntry &entry, |
| 999 | const ConstString &var_name, |
| 1000 | StringList &value, |
Caroline Tice | 12cecd7 | 2010-09-20 21:37:42 | [diff] [blame] | 1001 | Error *err) |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 1002 | { |
Greg Clayton | d7aa114 | 2010-09-22 00:23:59 | [diff] [blame] | 1003 | if (err) |
| 1004 | err->SetErrorString ("'target' does not have any instance settings"); |
| 1005 | return false; |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 1006 | } |
| 1007 | |
| 1008 | const ConstString |
| 1009 | TargetInstanceSettings::CreateInstanceName () |
| 1010 | { |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 1011 | StreamString sstr; |
Caroline Tice | 1559a46 | 2010-09-27 00:30:10 | [diff] [blame] | 1012 | static int instance_count = 1; |
| 1013 | |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 1014 | sstr.Printf ("target_%d", instance_count); |
| 1015 | ++instance_count; |
| 1016 | |
| 1017 | const ConstString ret_val (sstr.GetData()); |
| 1018 | return ret_val; |
| 1019 | } |
| 1020 | |
| 1021 | //-------------------------------------------------- |
| 1022 | // Target::SettingsController Variable Tables |
| 1023 | //-------------------------------------------------- |
| 1024 | |
| 1025 | SettingEntry |
| 1026 | Target::SettingsController::global_settings_table[] = |
| 1027 | { |
| 1028 | //{ "var-name", var-type , "default", enum-table, init'd, hidden, "help-text"}, |
Greg Clayton | 0668d1e | 2010-10-25 20:08:15 | [diff] [blame] | 1029 | { "default-arch", eSetVarTypeString, NULL, NULL, false, false, "Default architecture to choose, when there's a choice." }, |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 1030 | { NULL, eSetVarTypeNone, NULL, NULL, 0, 0, NULL } |
| 1031 | }; |
| 1032 | |
| 1033 | SettingEntry |
| 1034 | Target::SettingsController::instance_settings_table[] = |
| 1035 | { |
| 1036 | //{ "var-name", var-type, "default", enum-table, init'd, hidden, "help-text"}, |
| 1037 | { NULL, eSetVarTypeNone, NULL, NULL, 0, 0, NULL } |
| 1038 | }; |